From dc4ba8076aebd30f33282121a414262b4d4919f4 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 09 九月 2024 10:40:34 +0800 Subject: [PATCH] 1. 编写设备匹配功能 --- .env.development | 0 src/views/fysp/config/DeviceMatch.vue | 81 +++++++++++++++++++++++++++ src/api/index.js | 30 ++++++--- .env | 0 .env.production | 0 src/components/search-option/FYSearchBar.vue | 9 +- src/constants/menu.js | 5 + src/router/index.js | 6 ++ 8 files changed, 116 insertions(+), 15 deletions(-) diff --git a/.env b/.env new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.env diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.env.development diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.env.production diff --git a/src/api/index.js b/src/api/index.js index f8dbaf2..36408b4 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -13,7 +13,7 @@ if (debug) { ip1 = 'http://192.168.0.138:8082/'; // ip1_file = 'http://47.100.191.150:9005/'; - // ip2 = 'http://192.168.0.138:8080/'; + ip2 = 'http://192.168.0.138:8080/'; // ip2_file = 'https://fyami.com.cn/'; } @@ -38,17 +38,21 @@ i.interceptors.request.use( function (config) { // 鍦ㄥ彂閫佽姹備箣鍓嶅仛浜涗粈涔� - console.log('==>璇锋眰寮�濮�'); - console.log(`${config.baseURL}${config.url}`); - if (config.data) { - console.log('==>璇锋眰鏁版嵁', config.data); + if (import.meta.env.DEV) { + console.log('==>璇锋眰寮�濮�'); + console.log(`${config.baseURL}${config.url}`); + if (config.data) { + console.log('==>璇锋眰鏁版嵁', config.data); + } } return config; }, function (error) { // 瀵硅姹傞敊璇仛浜涗粈涔� - console.log('==>璇锋眰寮�濮�'); - console.log(error); + if (import.meta.env.DEV) { + console.log('==>璇锋眰寮�濮�'); + console.log(error); + } ElMessage({ message: error, type: 'error' @@ -62,8 +66,10 @@ function (response) { // 2xx 鑼冨洿鍐呯殑鐘舵�佺爜閮戒細瑙﹀彂璇ュ嚱鏁般�� // 瀵瑰搷搴旀暟鎹仛鐐逛粈涔� - console.log(response); - console.log('==>璇锋眰缁撴潫'); + if (import.meta.env.DEV) { + console.log(response); + console.log('==>璇锋眰缁撴潫'); + } if (response.status == 200) { if (response.data.success != undefined && response.data.success != null) { if (response.data.success == true) { @@ -85,8 +91,10 @@ function (error) { // 瓒呭嚭 2xx 鑼冨洿鐨勭姸鎬佺爜閮戒細瑙﹀彂璇ュ嚱鏁般�� // 瀵瑰搷搴旈敊璇仛鐐逛粈涔� - console.log(error); - console.log('==>璇锋眰缁撴潫'); + if (import.meta.env.DEV) { + console.log(error); + console.log('==>璇锋眰缁撴潫'); + } ElMessage({ message: error, type: 'error' diff --git a/src/components/search-option/FYSearchBar.vue b/src/components/search-option/FYSearchBar.vue index 9fe8c2b..fc96c81 100644 --- a/src/components/search-option/FYSearchBar.vue +++ b/src/components/search-option/FYSearchBar.vue @@ -2,7 +2,7 @@ <el-form :inline="true"> <slot name="options"></slot> <el-form-item> - <el-button icon="Search" type="primary" @click="search">{{ btnText }}</el-button> + <el-button icon="Search" type="primary" :loading="loading" @click="search">{{ btnText }}</el-button> <slot name="buttons"></slot> </el-form-item> </el-form> @@ -14,13 +14,14 @@ btnText: { type: String, default: '鏌ヨ' - } + }, + loading: Boolean }, emits: ['search'], methods: { search() { - this.$emit('search') + this.$emit('search'); } } -} +}; </script> diff --git a/src/constants/menu.js b/src/constants/menu.js index 08247bd..49c2faf 100644 --- a/src/constants/menu.js +++ b/src/constants/menu.js @@ -54,6 +54,11 @@ icon: 'List', name: '鐩戠闂', }, + { + path: '/fysp/config/deviceMatch', + icon: 'List', + name: '璁惧鍖归厤', + }, ], }, { diff --git a/src/router/index.js b/src/router/index.js index 1b3cb80..7f1db70 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -78,6 +78,12 @@ component: () => import('@/views/fysp/config/ProblemType.vue') }, { + //璁惧鍖归厤 + name: 'fyspDeviceMatch', + path: '/fysp/config/deviceMatch', + component: () => import('@/views/fysp/config/DeviceMatch.vue') + }, + { //璇勪及鏁版嵁婧� name: 'fyspEvalutationTask', path: '/fysp/evaluation/evalutationTask', diff --git a/src/views/fysp/config/DeviceMatch.vue b/src/views/fysp/config/DeviceMatch.vue new file mode 100644 index 0000000..82eafd2 --- /dev/null +++ b/src/views/fysp/config/DeviceMatch.vue @@ -0,0 +1,81 @@ +<template> + <FYTable @search="onSearch" :pagination="true" ref="tableRef"> + <template #options> + <!-- 鍖哄幙 --> + <FYOptionLocation + :allOption="false" + :level="3" + :checkStrictly="false" + v-model:value="formSearch.locations" + ></FYOptionLocation> + <!-- 鍦烘櫙绫诲瀷 --> + <FYOptionScene + :allOption="false" + :type="2" + v-model:value="formSearch.scenetype" + ></FYOptionScene> + <FYOptionTime :initValue="false" type="month" v-model:value="formSearch.time"></FYOptionTime> + </template> + <template #buttons> </template> + + <template #options-expand> + <el-form :inline="true"> + <CompQuickSet @quick-set="setOptions"></CompQuickSet> + </el-form> + </template> + + <template #table-column> + <el-table-column prop="sceneName" :show-overflow-tooltip="true" label="鍚嶇О"> + </el-table-column> + </template> + </FYTable> +</template> +<script setup> +/** + * 鐩戞祴璁惧鍜屽満鏅尮閰嶈褰曠鐞� + */ +import dayjs from 'dayjs'; +import { ref, reactive, computed, getCurrentInstance } from 'vue'; +import userMapApi from '@/api/fysp/userMapApi'; +import CompQuickSet from '@/views/fysp/evaluation/components/CompQuickSet.vue'; + +const { $fm } = getCurrentInstance().appContext.config.globalProperties; + +const tableRef = ref(); +const formSearch = reactive({ + locations: {}, + scenetype: {}, + time: dayjs().add(-1, 'M').date(1).toDate() +}); + +const area = computed(() => { + return { + provincecode: formSearch.locations.pCode, + provincename: formSearch.locations.pName, + citycode: formSearch.locations.cCode, + cityname: formSearch.locations.cName, + districtcode: formSearch.locations.dCode, + districtname: formSearch.locations.dName, + towncode: formSearch.locations.tCode, + townname: formSearch.locations.tName, + starttime: $fm.formatYMDH(formSearch.time), + scensetypeid: formSearch.scenetype.value, + online: true, + // 姝ゅ鏁版嵁鏉ユ簮鍥哄畾涓洪缇界洃绠$郴缁� + sourceType: 2 + }; +}); + +function onSearch(page, func) { + userMapApi.fetchDeviceMap(area.value).then((res) => { + func({ data: res.data }); + }); +} + +function setOptions(param) { + formSearch.locations = param.locations; + formSearch.scenetype = param.scenetype; + // formSearch.sourceType = param.sourceType; + tableRef.value.onSearch(); +} +</script> -- Gitblit v1.9.3