Explorar el Código

统计改为接口

CzRger hace 1 año
padre
commit
93bd5c93c4

+ 6 - 0
src/api/modules/enterprise.ts

@@ -14,4 +14,10 @@ export const deviceQuery = (params: any) => handle({
   url: `/${suffix}/deviceQuery`,
   method: 'post',
   params
+})
+
+//  根据圆心和半径查找周边企业设备
+export const staticsQuery = () => handle({
+  url: `/${suffix}/staticsQuery`,
+  method: 'post',
 })

+ 1 - 14
src/store/modules/gis.ts

@@ -4,12 +4,6 @@ const state = {
   activeQyId: null,
   gisLayer: null,
   gisSource: null,
-  tempStatistic: {
-    total: 0,
-    lgszyjkscsb: 0,
-    jgzzmgs: 0,
-    lgsjkyfl: 0
-  }
 }
 
 const getters = {
@@ -21,10 +15,6 @@ const mutations = {
   },
   SET_ACTIVE_QY_ID(state, id) {
     state.activeQyId = id
-  },
-  SET_tempStatistic(state, data) {
-    state.tempStatistic = data
-    console.log(data)
   }
 }
 
@@ -34,10 +24,7 @@ const actions = {
   },
   LOAD_ACTIVE_QY_ID({ commit }: any, id: any) {
     commit('SET_ACTIVE_QY_ID', id)
-  },
-  LOAD_tempStatistic({ commit }: any, data: any) {
-    commit('SET_tempStatistic', data)
-  },
+  }
 }
 
 export default {

+ 19 - 19
src/views/gis/business/enterprise/index.vue

@@ -5,34 +5,30 @@
       <FocusContentCom class="one" v-loading="loading.statistic">
         <div class="one-top">
           <img src="@/assets/images/gis-business/enterprise_icon1.png" alt=""/>
-          <!--          <StatisticTitleCom title="企业总数" :num="statistic.qy.total" unit="家"/>-->
-          <StatisticTitleCom title="企业总数" :num="$store.state.gis.tempStatistic.total" unit="家"/>
+          <StatisticTitleCom title="企业总数" :num="statistic.qy.total" unit="家"/>
         </div>
         <div class="one-bottom">
           <div class="one-bottom-item">
             <div class="chart">
-              <!--              <PieSimpleChartCom :num="statistic.qy.lgszyjkscsb" :total="statistic.qy.total" color="#00FFFF"/>-->
-              <PieSimpleChartCom :num="$store.state.gis.tempStatistic.lgszyjkscsb" :total="$store.state.gis.tempStatistic.total" color="#00FFFF"/>
+              <PieSimpleChartCom :num="statistic.qy.lgszyjkscsb" :total="statistic.qy.total" color="#00FFFF"/>
             </div>
             <div class="text">零关税自用<br/>进口生产设备</div>
           </div>
           <div class="one-bottom-item">
             <div class="chart">
-              <!--              <PieSimpleChartCom :num="statistic.qy.jgzzmgs" :total="statistic.qy.total" color="#FFCC8F"/>-->
-              <PieSimpleChartCom :num="$store.state.gis.tempStatistic.jgzzmgs" :total="$store.state.gis.tempStatistic.total" color="#FFCC8F"/>
+              <PieSimpleChartCom :num="statistic.qy.jgzzmgs" :total="statistic.qy.total" color="#FFCC8F"/>
             </div>
             <div class="text">加工增值免关税</div>
           </div>
           <div class="one-bottom-item">
             <div class="chart">
-              <!--              <PieSimpleChartCom :num="statistic.qy.lgsjkyfl" :total="statistic.qy.total" color="#EB90FF"/>-->
-              <PieSimpleChartCom :num="$store.state.gis.tempStatistic.lgsjkyfl" :total="$store.state.gis.tempStatistic.total" color="#EB90FF"/>
+              <PieSimpleChartCom :num="statistic.qy.lgsjkyfl" :total="statistic.qy.total" color="#EB90FF"/>
             </div>
             <div class="text">零关税进口<br/>原辅料</div>
           </div>
         </div>
       </FocusContentCom>
-      <FocusContentCom class="two">
+      <FocusContentCom class="two" v-loading="loading.statistic">
         <div class="two-main">
           <img src="@/assets/images/gis-business/enterprise_icon2.png" alt=""/>
           <StatisticTitleCom title="预警总数" :num="statistic.warning" unit="条"/>
@@ -117,7 +113,7 @@ import BusinessMainCom from '../common/business-main.vue'
 import FocusContentCom from '../common/focus-content.vue'
 import PieSimpleChartCom from '../common/pie-simple-chart.vue'
 import StatisticTitleCom from '../common/statistic-title.vue'
-import {enterpriseQuery} from "@/api/modules/enterprise";
+import {enterpriseQuery, staticsQuery} from "@/api/modules/enterprise";
 
 export default defineComponent({
   name: '',
@@ -197,17 +193,21 @@ export default defineComponent({
     }
     const initStatistic = () => {
       state.loading.statistic = true
-      setTimeout(() => {
-        state.statistic = {
-          qy: {
-            total: 0,
-            lgszyjkscsb: 0,
-            jgzzmgs: 0,
-            lgsjkyfl: 0
-          },
-          warning: 0
+      that.$api.staticsQuery().then(res => {
+        if (res.resp_code === 0) {
+          state.statistic = {
+            qy: {
+              total: res.datas?.count || 0,
+              lgszyjkscsb: res.datas?.deviceCount || 0,
+              jgzzmgs: res.datas?.noTaxCount || 0,
+              lgsjkyfl: res.datas?.materialCount || 0
+            },
+            warning: res.datas?.alertCount || 0
+          }
         }
         state.loading.statistic = false
+      }).catch(() => {
+        state.loading.statistic = false
       })
     }
     const handleClick = (item) => {

+ 0 - 10
src/views/gis/layout/index.vue

@@ -361,25 +361,16 @@ export default defineComponent({
         // "entType":"加工增值"
       }).then((res: any) => {
         if (res.resp_code === 0 && res.datas?.length > 0) {
-          const tempStatistic = {
-            total: res.datas.length,
-            lgszyjkscsb: 0,
-            jgzzmgs: 0,
-            lgsjkyfl: 0
-          }
           const features: any = []
           res.datas.forEach(v => {
             try {
               const feat: any = new format.WKT().readFeature(`POINT(${v.longitude} ${v.latitude})`)
               let type = ''
               if (v.qykx === '零关税自用进口生产设备') {
-                tempStatistic.lgszyjkscsb += 1
                 type = 'lgszyjkscsb'
               } else if (v.qykx === '加工增值免关税') {
-                tempStatistic.jgzzmgs  += 1
                 type = 'jgzzmgs'
               } else if (v.qykx === '零关税进口原辅料') {
-                tempStatistic.lgsjkyfl += 1
                 type = 'lgsjkyfl'
               }
               feat.set('defaultStyle', QyStyle.qyStyle(type))
@@ -438,7 +429,6 @@ export default defineComponent({
               console.error('异常企业:', v)
             }
           })
-          store.dispatch('gis/LOAD_tempStatistic', tempStatistic)
           state.qyParams.source = new source.Vector({
             features: features,
             wrapX: false