Mr.zhou 2 роки тому
батько
коміт
48287f6a40
3 змінених файлів з 167 додано та 143 видалено
  1. 66 52
      web/src/mixins/infoList.js
  2. 87 87
      web/src/utils/request.js
  3. 14 4
      web/src/view/place/place.vue

+ 66 - 52
web/src/mixins/infoList.js

@@ -1,57 +1,71 @@
 import { getDict } from '@/utils/dictionary'
 import { formatTimeToStr } from '@/utils/date'
-
+import { getOrganizationList } from "@/api/organization"
 export default {
-  data() {
-    return {
-      page: 1,
-      total: 10,
-      pageSize: 10,
-      tableData: [],
-      searchInfo: {}
-    }
-  },
-  methods: {
-    formatBoolean: function(bool) {
-      if (bool !== null) {
-        return bool ? '是' : '否'
-      } else {
-        return ''
-      }
-    },
-    formatDate: function(time) {
-      if (time !== null && time !== '') {
-        var date = new Date(time)
-        return formatTimeToStr(date, 'yyyy-MM-dd hh:mm:ss')
-      } else {
-        return ''
-      }
-    },
-    filterDict(value, type) {
-      const rowLabel = this[type + 'Options'] && this[type + 'Options'].filter(item => item.value === value)
-      return rowLabel && rowLabel[0] && rowLabel[0].label
-    },
-    async getDict(type) {
-      const dicts = await getDict(type)
-      this[type + 'Options'] = dicts
-      return dicts
+    data() {
+        return {
+            page: 1,
+            total: 10,
+            pageSize: 10,
+            tableData: [],
+            searchInfo: {}
+        }
     },
-    handleSizeChange(val) {
-      this.pageSize = val
-      this.getTableData()
-    },
-    handleCurrentChange(val) {
-      this.page = val
-      this.getTableData()
-    },
-    async getTableData(page = this.page, pageSize = this.pageSize) {
-      const table = await this.listApi({ page, pageSize, ...this.searchInfo })
-      if (table.code === 0) {
-        this.tableData = table.data.list
-        this.total = table.data.total
-        this.page = table.data.page
-        this.pageSize = table.data.pageSize
-      }
+    methods: {
+        formatBoolean: function(bool) {
+            if (bool !== null) {
+                return bool ? '是' : '否'
+            } else {
+                return ''
+            }
+        },
+        formatDate: function(time) {
+            if (time !== null && time !== '') {
+                var date = new Date(time)
+                return formatTimeToStr(date, 'yyyy-MM-dd hh:mm:ss')
+            } else {
+                return ''
+            }
+        },
+        filterDict(value, type) {
+            const rowLabel = this[type + 'Options'] && this[type + 'Options'].filter(item => item.value === value)
+            return rowLabel && rowLabel[0] && rowLabel[0].label
+        },
+        async getDict(type) {
+            const dicts = await getDict(type)
+            this[type + 'Options'] = dicts
+            return dicts
+        },
+        handleSizeChange(val) {
+            this.pageSize = val
+            this.getTableData()
+        },
+        handleCurrentChange(val) {
+            this.page = val
+            this.getTableData()
+        },
+        async getTableData(page = this.page, pageSize = this.pageSize) {
+            const table = await this.listApi({ page, pageSize, ...this.searchInfo })
+            if (table.code === 0) {
+                this.tableData = table.data.list
+                this.total = table.data.total
+                this.page = table.data.page
+                this.pageSize = table.data.pageSize
+                if (this.tableData[0].organCode) {
+                    this.tableData.forEach((element, index) => {
+                        getOrganizationList({ parentcode: '1307' }).then(res => {
+                            res.data.list.forEach((e, i) => {
+                                if (element.organCode == e.code) {
+                                    element.organName = e.name
+                                }
+                            })
+
+                        })
+                    })
+                }
+
+
+            }
+        }
     }
-  }
-}
+}

+ 87 - 87
web/src/utils/request.js

@@ -4,113 +4,113 @@ import { store } from '@/store'
 import { emitter } from '@/utils/bus.js'
 
 const service = axios.create({
-  baseURL: import.meta.env.VITE_BASE_API,
-  timeout: 99999
+    baseURL: import.meta.env.VITE_BASE_API,
+    timeout: 99999
 })
 let acitveAxios = 0
 let timer
 const showLoading = () => {
-  acitveAxios++
-  if (timer) {
-    clearTimeout(timer)
-  }
-  timer = setTimeout(() => {
-    if (acitveAxios > 0) {
-      emitter.emit('showLoading')
+    acitveAxios++
+    if (timer) {
+        clearTimeout(timer)
     }
-  }, 400)
+    timer = setTimeout(() => {
+        if (acitveAxios > 0) {
+            emitter.emit('showLoading')
+        }
+    }, 400)
 }
 
 const closeLoading = () => {
-  acitveAxios--
-  if (acitveAxios <= 0) {
-    clearTimeout(timer)
-    emitter.emit('closeLoading')
-  }
-}
-// http request 拦截器
-service.interceptors.request.use(
-  config => {
-    if (!config.donNotShowLoading) {
-      showLoading()
+        acitveAxios--
+        if (acitveAxios <= 0) {
+            clearTimeout(timer)
+            emitter.emit('closeLoading')
+        }
     }
-    const token = store.getters['user/token']
-    const user = store.getters['user/userInfo']
-    config.data = JSON.stringify(config.data)
-    config.headers = {
-      'Content-Type': 'application/json',
-      'x-token': token,
-      'x-user-id': user.ID
+    // http request 拦截器
+service.interceptors.request.use(
+    config => {
+        if (!config.donNotShowLoading) {
+            showLoading()
+        }
+        const token = store.getters['user/token']
+        const user = store.getters['user/userInfo']
+        config.data = JSON.stringify(config.data)
+        config.headers = {
+            'Content-Type': 'application/json',
+            'x-token': token,
+            'x-user-id': user.ID
+        }
+        return config
+    },
+    error => {
+        closeLoading()
+        ElMessage({
+            showClose: true,
+            message: error,
+            type: 'error'
+        })
+        return error
     }
-    return config
-  },
-  error => {
-    closeLoading()
-    ElMessage({
-      showClose: true,
-      message: error,
-      type: 'error'
-    })
-    return error
-  }
 )
 
 // http response 拦截器
 service.interceptors.response.use(
-  response => {
-    closeLoading()
-    if (response.headers['new-token']) {
-      store.commit('user/setToken', response.headers['new-token'])
-    }
-    if (response.data.code === 0 || response.headers.success === 'true') {
-      if (response.headers.msg) {
-        response.data.msg = decodeURI(response.headers.msg)
-      }
-      return response.data
-    } else {
-      ElMessage({
-        showClose: true,
-        message: response.data.msg,
-        type: 'error'
-      })
-      if (response.data.data && response.data.data.reload) {
-        store.commit('user/LoginOut')
-      }
-      return response.data.msg ? response.data : response
-    }
-  },
-  error => {
-    closeLoading()
-    switch (error.response.status) {
-      case 500:
-        ElMessageBox.confirm(`
+    response => {
+        closeLoading()
+        if (response.headers['new-token']) {
+            store.commit('user/setToken', response.headers['new-token'])
+        }
+        if (response.data.code === 0 || response.headers.success === 'true') {
+            if (response.headers.msg) {
+                response.data.msg = decodeURI(response.headers.msg)
+            }
+            return response.data
+        } else {
+            ElMessage({
+                showClose: true,
+                message: response.data.msg,
+                type: 'error'
+            })
+            if (response.data.data && response.data.data.reload) {
+                store.commit('user/LoginOut')
+            }
+            return response.data.msg ? response.data : response
+        }
+    },
+    error => {
+        closeLoading()
+        switch (error.response.status) {
+            case 500:
+                ElMessageBox.confirm(`
         <p>检测到接口错误${error}</p>
         <p>错误码<span style="color:red"> 500 </span>:此类错误内容常见于后台panic,请先查看后台日志,如果影响您正常使用可强制登出清理缓存</p>
         `, '接口报错', {
-          dangerouslyUseHTMLString: true,
-          distinguishCancelAndClose: true,
-          confirmButtonText: '清理缓存',
-          cancelButtonText: '取消'
-        })
-          .then(() => {
-            store.commit('user/LoginOut')
-          })
-        break
-      case 404:
-        ElMessageBox.confirm(`
+                        dangerouslyUseHTMLString: true,
+                        distinguishCancelAndClose: true,
+                        confirmButtonText: '清理缓存',
+                        cancelButtonText: '取消'
+                    })
+                    .then(() => {
+                        store.commit('user/LoginOut')
+                    })
+                break
+            case 404:
+                ElMessageBox.confirm(`
           <p>检测到接口错误${error}</p>
           <p>错误码<span style="color:red"> 404 </span>:此类错误多为接口未注册(或未重启)或者请求路径(方法)与api路径(方法)不符--如果为自动化代码请检查是否存在空格</p>
           `, '接口报错', {
-          dangerouslyUseHTMLString: true,
-          distinguishCancelAndClose: true,
-          confirmButtonText: '我知道了',
-          cancelButtonText: '取消'
-        })
-        break
-    }
+                    dangerouslyUseHTMLString: true,
+                    distinguishCancelAndClose: true,
+                    confirmButtonText: '我知道了',
+                    cancelButtonText: '取消'
+                })
+                break
+        }
 
-    return error
-  }
+        return error
+    }
 )
 
-export default service
+export default service

+ 14 - 4
web/src/view/place/place.vue

@@ -55,7 +55,7 @@
         }}</template>
       </el-table-column>
       <el-table-column label="站点名称" prop="name" />
-      <el-table-column label="站点定位" prop="position">
+      <el-table-column label="站点定位" prop="position" width="150">
         <template #default="scope">
           <el-link
             :underline="false"
@@ -77,8 +77,14 @@
           <dict-tag :options="dict.type.site_type" :value="scope.row.type" />
         </template>
       </el-table-column>
-      <el-table-column label="区域" prop="region" />
-      <el-table-column label="操作">
+      <el-table-column label="区域" width="140">
+        <template #default="scope">
+          <div>{{ scope.row.organName }}</div>
+        </template>
+      </el-table-column>
+
+      <el-table-column label="地址" prop="region" />
+      <el-table-column label="操作" width="220">
         <template #default="scope">
           <el-button
             size="small"
@@ -215,7 +221,8 @@ import {
   findPlacePro,
   getPlaceProList,
 } from "@/api/placePro"; //  此处请自行替换地址
-import { areaList } from "@/api/organization"
+
+import { areaList, getOrganizationList } from "@/api/organization"
 import infoList from "@/mixins/infoList";
 import { getDict } from "@/utils/dictionary";
 
@@ -251,7 +258,10 @@ export default {
   },
   async created() {
     this.siteType = await getDict("site_type");
+    // await this.getTableData();
+    
     await this.getTableData();
+
   },
   methods: {
     openMapHandle(position, name, region) {