wsp пре 1 година
родитељ
комит
d8131baf2f
6 измењених фајлова са 95 додато и 30 уклоњено
  1. 0 15
      components.d.ts
  2. 1 0
      index.html
  3. 14 0
      public/js/global.js
  4. 21 4
      src/request/api.js
  5. 11 1
      src/request/index.ts
  6. 48 10
      src/views/areaman/index.vue

+ 0 - 15
components.d.ts

@@ -11,43 +11,28 @@ declare module 'vue' {
     ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
     ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
     ElButton: typeof import('element-plus/es')['ElButton']
-    ElCalendar: typeof import('element-plus/es')['ElCalendar']
     ElCard: typeof import('element-plus/es')['ElCard']
     ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
-    ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
     ElCol: typeof import('element-plus/es')['ElCol']
     ElContainer: typeof import('element-plus/es')['ElContainer']
-    ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
     ElDialog: typeof import('element-plus/es')['ElDialog']
     ElDropdown: typeof import('element-plus/es')['ElDropdown']
     ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
     ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
     ElForm: typeof import('element-plus/es')['ElForm']
     ElFormItem: typeof import('element-plus/es')['ElFormItem']
-    ElHeade: typeof import('element-plus/es')['ElHeade']
     ElHeader: typeof import('element-plus/es')['ElHeader']
     ElIcon: typeof import('element-plus/es')['ElIcon']
     ElInput: typeof import('element-plus/es')['ElInput']
     ElMain: typeof import('element-plus/es')['ElMain']
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
-    ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
-    ElOption: typeof import('element-plus/es')['ElOption']
     ElPagination: typeof import('element-plus/es')['ElPagination']
-    ElRadio: typeof import('element-plus/es')['ElRadio']
-    ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
     ElRow: typeof import('element-plus/es')['ElRow']
-    ElSegmented: typeof import('element-plus/es')['ElSegmented']
-    ElSelect: typeof import('element-plus/es')['ElSelect']
-    ElSelectV2: typeof import('element-plus/es')['ElSelectV2']
-    ElSubmenu: typeof import('element-plus/es')['ElSubmenu']
-    ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
-    ElSwitch: typeof import('element-plus/es')['ElSwitch']
     ElTable: typeof import('element-plus/es')['ElTable']
     ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
     ElTabPane: typeof import('element-plus/es')['ElTabPane']
     ElTabs: typeof import('element-plus/es')['ElTabs']
-    ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
     HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
     IconCommunity: typeof import('./src/components/icons/IconCommunity.vue')['default']
     IconDocumentation: typeof import('./src/components/icons/IconDocumentation.vue')['default']

+ 1 - 0
index.html

@@ -8,6 +8,7 @@
   </head>
   <body>
     <div id="app"></div>
+    <script  src="/js/global.js"></script>
     <script  src="/js/echarts.js"></script>
     <script type="module" src="/src/main.ts"></script>
   </body>

+ 14 - 0
public/js/global.js

@@ -0,0 +1,14 @@
+var baseUrl='https://khy.xiaole.vip'
+var loginPageUrl='http://localhost:5173/login'
+var systemType='测试环境'
+
+switch(systemType){
+    case '测试环境':
+        baseUrl='https://khy.xiaole.vip'
+        loginPageUrl='http://localhost:5173/login'
+        break;
+    case '线上环境':
+        baseUrl=''
+        loginPageUrl=''
+    break;
+}

+ 21 - 4
src/request/api.js

@@ -27,10 +27,27 @@ export const  apisystemdzbcArealist = query => {
 };
 
 //https://khy.xiaole.vip/api/system/dzbcArea/export导出定制班车-区域列表
-export const  apisystemdzbcArealist = query => {
+export const  apisystemdzbcAreaexport = query => {
     return service({
-        url: '/api/system/dzbcArea/list',
-        method: 'GET',
-		data:query
+        url: '/api/system/dzbcArea/export',
+        method: 'POST',
+		data:query,
+        responseType: 'blob'
+    });
+};
+
+///api/system/dzbcArea/{ids}删除定制班车-区域
+export const  apisystemdzbcAreaDel = query => {
+    return service({
+        url: `/api/system/dzbcArea/${query.id}`,
+        method: 'DELETE'
+    });
+};
+//新增定制班车-区域https://khy.xiaole.vip/api/system/dzbcArea
+export const  apisystemdzbcAreaAdd = query => {
+    return service({
+        url: `/api/system/dzbcArea`,
+        method: 'POST',
+        data:query
     });
 };

+ 11 - 1
src/request/index.ts

@@ -1,9 +1,10 @@
 import axios from 'axios';
 import NProgress from 'NProgress'
 import { ElMessage } from 'element-plus'
+
 // 创建axios实例
 const service = axios.create({
-  baseURL: 'https://khy.xiaole.vip', // api的base_url
+  baseURL: window.baseUrl, // api的base_url
   timeout: 5000 // 请求超时时间
 });
  
@@ -37,11 +38,14 @@ service.interceptors.request.use(
 // 响应拦截器
 service.interceptors.response.use(
   response => {
+    console.log(response)
     // 可以在这里对响应数据进行处理,例如:对返回的状态码进行判断
     const res = response.data;
+    
     NProgress.done(true);   // 强制完成
     switch(res.code){
       case 200:
+        
         break;
         case 401:
         ElMessage({
@@ -49,6 +53,12 @@ service.interceptors.response.use(
           type: 'error',
           duration: 5 * 1000
         });
+
+        setTimeout(function(){
+          window.location.replace(loginPageUrl)
+          //window.Location.href=loginPageUrl
+        },2000)
+       
         break;
       case 500:
         ElMessage({

+ 48 - 10
src/views/areaman/index.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { apisystemdzbcArealist } from '../../request/api.js'
+import { apisystemdzbcArealist,apisystemdzbcAreaexport,apisystemdzbcAreaDel,apisystemdzbcAreaAdd } from '../../request/api.js'
 import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
 
 interface RuleForm {
@@ -97,7 +97,11 @@ const submitForm = async (formEl: FormInstance | undefined) => {
   if (!formEl) return
   await formEl.validate((valid, fields) => {
     if (valid) {
-      console.log('submit!')
+      apisystemdzbcAreaAdd(ruleForm).then((res:any)=>{
+
+      }).catch((err:any)=>{
+        console.log(err)
+      })
     } else {
       console.log('error submit!', fields)
     }
@@ -113,25 +117,59 @@ let pageNum=ref(1)
 let dialogVisible=ref(false)
 let logtitle=ref('新增用户')
 let loading=ref(true)
+let excellloading=ref(false)
 const tableData = ref([])
-
+//v-loading="excellloading" @click="downExcell"
 let activeName=ref('first')
 
 const addUser=val=>{
   dialogVisible.value=val
 }
-
+const downExcell=()=>{
+  excellloading.value=true
+  apisystemdzbcAreaexport({}).then((res:any)=>{
+
+     // 这里 data 是返回来的二进制数据
+     let blob = new Blob([res], {
+        type: "application/x-msdownload;charset=UTF-8",
+    });
+    // 创建一个blob的对象链接
+    const url = window.URL.createObjectURL(blob);
+    const link = document.createElement('a');
+    link.href = url;
+    // 把获得的blob的对象链接赋值给新创建的这个 a 链接
+    link.setAttribute('download', '数据管理列表.xls'); // 设置下载文件名
+    document.body.appendChild(link);
+    // 使用js点击这个链接
+    link.click();
+    document.body.removeChild(link) // 下载完成移除元素
+    window.URL.revokeObjectURL(url) // 释放blob对象
+    excellloading.value=false
+  }).catch((err:any)=>{
+    console.log(err)
+  })
+}
 const getTableData=()=>{
   apisystemdzbcArealist({
     
   }).then(res=>{
+    if(res.code==200){
+      tableData.value=res.rows
+    }
     loading.value=false
-    tableData.value=res.data.rows
+    
   }).catch(err=>{
     console.log(err)
   })
 }
+//
+const deleteItem=(id)=>{
+  apisystemdzbcAreaDel({id}).then((res:any)=>{
 
+  }).catch((err:any)=>{
+    console.log(err)
+  })
+}
 
 onMounted(()=>{
   getTableData()
@@ -173,8 +211,8 @@ onMounted(()=>{
                       </div>
                       <div class="right-part">
                       
-                        <!-- <el-button :icon="Download">导出</el-button>
-                        <el-button :icon="Tools">设置</el-button> -->
+                        <el-button :loading="excellloading" @click="downExcell" :icon="Download">{{ excellloading?'正在导出':'导出' }}</el-button>
+                        <!-- <el-button :icon="Tools">设置</el-button> -->
                       </div>
                     </div>
                     <el-table element-loading-text='加载中' header-row-class-name="reset-gray-head" :data="tableData"  style="width: 100%" v-loading="loading">
@@ -190,11 +228,11 @@ onMounted(()=>{
                         </el-table-column>
                         <el-table-column prop="by" label="所属客运站" />
                         <el-table-column fixed="right" label="操作" min-width="120">
-                          <template #default>
+                          <template #default="scope">
                             <el-button link type="primary" size="small">
                               编辑
                             </el-button>
-                            <el-button link type="danger" size="small">删除</el-button>
+                            <el-button @click="deleteItem(scope.row.id)" link type="danger" size="small">删除</el-button>
                           </template>
                         </el-table-column>
                     </el-table>
@@ -280,7 +318,7 @@ onMounted(()=>{
           <template #footer>
             <div class="dialog-footer">
               <el-button @click="dialogVisible = false" :icon="Close">取消</el-button>
-              <el-button type="primary" :icon="Check" @click="addUser(false)">
+              <el-button type="primary" :icon="Check" @click="submitForm(ruleFormRef)">
                 确认创建
               </el-button>
             </div>