fanghuisheng 2 лет назад
Родитель
Сommit
4191838933

+ 3 - 3
src/pages/business/mhxf/coordination/index.vue

@@ -5,9 +5,9 @@
 <script setup>
 import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
 import { getCurrentInstance, ref, onMounted, inject, shallowRef, reactive, nextTick } from "vue";
-import useXunJianStore from "@/store/modules/xunJian";
+import publicStore from "@/store/modules/public";
 
-const settingsStore = useXunJianStore(); //全局变量值Store
+const publicStores = publicStore(); //全局公共Store
 
 // 自定义导航事件
 onNavigationBarButtonTap((e) => {
@@ -37,7 +37,7 @@ onMounted(() => {});
 
 .is-selected {
   color: #1989fa;
-} 
+}
 </style>
 
 <style scoped>

+ 2 - 2
src/pages/business/mhxf/deviceManage/index.vue

@@ -77,11 +77,11 @@
 <script setup>
 import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, watchEffect } from "vue";
-import useXunJianStore from "@/store/modules/xunJian";
+import publicStore from "@/store/modules/public";
 
 import { dataRtList } from "@/api/business/mhxf/deviceManage";
 
-const settingsStore = useXunJianStore(); //全局变量值Store
+const publicStores = publicStore(); //全局公共Store
 
 const dataInput = ref("");
 

+ 28 - 31
src/pages/business/mhxf/informationSelect/index.vue

@@ -35,14 +35,14 @@
 
 <script setup>
 import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
-import { ref, onMounted, inject, shallowRef, reactive, watchEffect,getCurrentInstance } from "vue";
-import useXunJianStore from "@/store/modules/xunJian";
+import { ref, onMounted, inject, shallowRef, reactive, watchEffect, getCurrentInstance } from "vue";
+import publicStore from "@/store/modules/public";
 
 import { dataList } from "@/api/business/mhxf/informationSelect";
 
 const { proxy } = getCurrentInstance();
 
-const settingsStore = useXunJianStore(); //全局变量值Store
+const publicStores = publicStore(); //全局公共Store
 
 const dataInput = ref("");
 const current = ref(0);
@@ -179,7 +179,7 @@ function rightscroll(dista) {
   if (current.value >= 1) {
     current.value--;
   } else {
-    current.value = 0;
+    current.value = list.value.length - 1;
   }
 }
 /**
@@ -283,40 +283,37 @@ async function classifySearch(URL, params) {
   proxy.$modal.loading("加载中");
   classifyData.value = [];
   dataList(URL, params).then((res) => {
-	  proxy.$modal.closeLoading();
+    proxy.$modal.closeLoading();
     if (res.status == "SUCCESS") {
-		
       if (current.value == 2) {
-          if(res.data.length){
-            dataRes.value = 1;
-          }else{
-            dataRes.value = 0;
-          }
-          var records = res.data[0][0];
-        
+        if (res.data.length) {
+          dataRes.value = 1;
+        } else {
+          dataRes.value = 0;
+        }
+        var records = res.data[0][0];
       } else if (current.value == 3) {
-          if(res.data.length){
-            dataRes.value = 1;
-          }else{
-            dataRes.value = 0;
-          }
+        if (res.data.length) {
+          dataRes.value = 1;
+        } else {
+          dataRes.value = 0;
+        }
 
         var records = res.data[0];
       } else {
-		  //  console.log('111111111')
-		  // console.log(res.data.records.length)
-		  //  console.log('111222')
-          if(res.data.total){
-            dataRes.value = 1;
-          }else{
-            dataRes.value = 0;
-          }
-            var records = res.data.records[0];
+        //  console.log('111111111')
+        // console.log(res.data.records.length)
+        //  console.log('111222')
+        if (res.data.total) {
+          dataRes.value = 1;
+        } else {
+          dataRes.value = 0;
+        }
+        var records = res.data.records[0];
       }
-	  
-      console.log(dataRes.value+'------1')
-  
-	  
+
+      console.log(dataRes.value + "------1");
+
       switch (current.value) {
         case 0: //警情查询
           var classifyTitle = [

+ 2 - 2
src/pages/business/mhxf/unitInfoCollection/index.vue

@@ -193,7 +193,7 @@ import { companyByNameSelect, addBaseCompany, delBaseBuild } from "@/api/busines
 
 const { proxy } = getCurrentInstance();
 
-const newPublicStore = publicStore();
+const publicStores = publicStore();
 
 const dataList = reactive({
   form: {
@@ -841,7 +841,7 @@ function handleDateTime(value, index, time) {
  * @确定按钮事件
  */
 function timeSubmit(data) {
-  let time = newPublicStore.formatterDate(data.value);
+  let time = publicStores.formatterDateTime(data.value);
   let timeData = time.split(" ")[0];
   if (timeTitle.value == "成立时间") {
     form.value.foundTime = timeData;

+ 4 - 1
src/pages/business/mhxf/xunJian/collect/components/collectDetail.vue

@@ -28,8 +28,11 @@ import {
   onNavigationBarButtonTap,
 } from "@dcloudio/uni-app";
 import { reactive, ref, onMounted, inject, shallowRef } from "vue";
+
+import publicStore from "@/store/modules/public";
 import useXunJianStore from "@/store/modules/xunJian";
 
+const publicStores = publicStore(); //全局公共Store
 const settingsStore = useXunJianStore(); //全局变量值Store
 
 const form = ref(null); //表单refs获取
@@ -62,7 +65,7 @@ function handleInsert() {
     .validate()
     .then((res) => {
       let endTime = new Date();
-      model.siteTime = settingsStore.formatterDate(endTime, "yyyy-MM-dd hh:mm:ss");
+      model.siteTime = publicStores.formatterDate(endTime, "yyyy-MM-dd hh:mm:ss");
 
       settingsStore.collectDataList.push(model);
 

+ 4 - 2
src/pages/business/mhxf/xunJian/plan/index.vue

@@ -164,10 +164,12 @@ import drawer from "./components/drawer.vue";
 
 import { onLoad, onShow, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef } from "vue";
+import publicStore from "@/store/modules/public";
 import useXunJianStore from "@/store/modules/xunJian";
 
 import { recordList, recordOption, planList, patrolInspectionPlan, appPlanStatistics } from "@/api/business/mhxf/xunJian/plan.js";
 
+const publicStores = publicStore(); //全局公共Store
 const settingsStore = useXunJianStore(); //全局变量值Store
 
 /**
@@ -325,7 +327,7 @@ function activitiesApi() {
  * @统计
  * @api接口请求
  */
-const currentDate = ref(settingsStore.getDate().year + "-" + settingsStore.getDate().month + "-" + settingsStore.getDate().dates); //统计时间数据存储
+const currentDate = ref(publicStores.getDate().year + "-" + publicStores.getDate().month + "-" + publicStores.getDate().dates); //统计时间数据存储
 const currentDatevalue = ref(new Date());
 const currentDateList = ref({}); //统计list数据存储
 function currentApi() {
@@ -337,7 +339,7 @@ function currentApi() {
     } else {
     }
   });
-} 
+}
 
 /**
  * @排序按钮

+ 4 - 1
src/pages/business/mhxf/xunJian/xunJian.vue

@@ -47,15 +47,18 @@ import { ref, onMounted, inject } from "vue";
 
 import chart from "./components/echarts/chart.vue";
 import json from "@/static/js/json.js";
+
+import publicStore from "@/store/modules/public";
 import useXunJianStore from "@/store/modules/xunJian";
 
 import { appPlanStatistics } from "@/api/business/mhxf/xunJian/index.js";
 
+const publicStores = publicStore(); //全局公共Store
 const settingsStore = useXunJianStore(); //全局变量值Store
 
 const inspectList = json.xunJianList; //九宫格json数据
 
-const currentDate = settingsStore.getDate().year + "-" + settingsStore.getDate().month + "-" + settingsStore.getDate().dates;
+const currentDate = publicStores.getDate().year + "-" + publicStores.getDate().month + "-" + publicStores.getDate().dates;
 const currentDateList = ref([]);
 
 function navItemClick(url, id) {

+ 14 - 33
src/pages/index.vue

@@ -136,7 +136,7 @@
         <view class="cu-list grid col-5 no-border">
           <view class="cu-item justify-center align-center" @tap="navItemClick(item)" v-for="(item, index) in arrayList.cuIconList" :key="index">
             <image :src="item.icon" style="width: 40px; height: 40px"></image>
-           <!-- <view class="cu-tag badge" v-if="item.badge != 0">
+            <!-- <view class="cu-tag badge" v-if="item.badge != 0">
               <block v-if="item.badge != 0">{{ item.badge > 99 ? "99+" : item.badge }}</block>
             </view> -->
             <text style="font-size: 13px">{{ item.menuName }}</text>
@@ -156,11 +156,11 @@ import * as jwx from "@/utils/jssdk.js"; //引入js sdk的封装
 
 import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance } from "vue";
-import useXunJianStore from "@/store/modules/xunJian.js";
+import publicStore from "@/store/modules/public";
 
-import { scan_push, getHomePageData, getFunctionalModuleStatistics,getAppRouters} from "@/api/index";
+import { scan_push, getHomePageData, getFunctionalModuleStatistics, getAppRouters } from "@/api/index";
 
-const settingsStore = useXunJianStore(); //全局变量值Store
+const publicStores = publicStore(); //全局公共Store
 const BASE_URL = inject("$BASE_URL");
 
 const arrayList = reactive({
@@ -183,10 +183,6 @@ const arrayList = reactive({
 });
 
 onLoad((option) => {
-
-	
-	
-	
   //获取首页标题
   if (uni.getStorageSync("homeTitle")) {
     uni.setNavigationBarTitle({
@@ -215,13 +211,8 @@ onLoad((option) => {
   // nextTick(() => {
   //   hackReset.value = true;
   // });
-  
-  
-  
-  
-  
-  getAppRoutersData()
 
+  getAppRoutersData();
 });
 
 async function init() {
@@ -313,7 +304,7 @@ function navItemClick(item) {
       });
     }
 
-    arrayList.recentlyUsed = settingsStore.sortEvent(arrayList.recentlyUsed, 1);
+    arrayList.recentlyUsed = publicStores.sortEvent(arrayList.recentlyUsed, 1);
 
     uni.setStorageSync("recentlyUsed", arrayList.recentlyUsed);
 
@@ -369,28 +360,20 @@ function InputFocus(e) {
 
 function InputBlur(e) {
   arrayList.InputBottom = 0;
-  
 }
 
 function getAppRoutersData() {
   getAppRouters({
-	  
-   domain :window.location.host.indexOf('localhost') != -1
-	                ? 'localhost:81'
-	                : window.location.host,
-		platformType:'MOB'
-	  // domain :'172.16.120.165:13201'
-	  // domain :'172.16.120.165:13203'
+    domain: window.location.host.indexOf("localhost") != -1 ? "localhost:81" : window.location.host,
+    platformType: "MOB",
+    // domain :'172.16.120.165:13201'
+    // domain :'172.16.120.165:13203'
   }).then((res) => {
-	  console.log(res.data)
-	  arrayList.cuIconList=res.data
-	  console.log(window.location.host)
-   
+    console.log(res.data);
+    arrayList.cuIconList = res.data;
+    console.log(window.location.host);
   });
-} 
-
-
-
+}
 
 //echarts图表请求
 async function getHomeData(param = {}) {
@@ -438,8 +421,6 @@ async function getHomeData(param = {}) {
   });
 }
 
-
-
 // 未处理告警请求
 async function getHandleData(param = {}) {
   getFunctionalModuleStatistics(param).then((res) => {

+ 2 - 2
src/pages/setting/setting.vue

@@ -85,12 +85,12 @@ import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, toRefs } from "vue";
 
 import useStore from "@/store/modules/user";
-import useXunJianStore from "@/store/modules/xunJian";
+import publicStore from "@/store/modules/public";
 
 import { getAuthorization } from "@/api/setting/index.js";
 
 const useStores = useStore(); //全局用户信息Store
-const settingsStore = useXunJianStore(); //全局变量值Store
+const publicStores = publicStore(); //全局公共Store
 
 const permissionLabel = ref(0);
 

+ 101 - 1
src/store/modules/public.js

@@ -140,7 +140,54 @@ const publicStore = defineStore("public", {
     },
   },
   actions: {
-    formatterDate(time3) {
+    getDate() {
+      var date = new Date();
+      var year = date.getFullYear(); //  返回的是年份
+      var month = date.getMonth() + 1; //  返回的月份上个月的月份,记得+1才是当月
+      if (month < 10) {
+        month = "0" + month;
+      }
+      var dates = date.getDate(); //  返回的是几号
+      if (dates < 10) {
+        dates = "0" + dates;
+      }
+      var day = date.getDay(); //  周一返回的是1,周六是6,但是周日是0
+      var arr = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
+      return {
+        year,
+        month,
+        dates,
+        day,
+        arr,
+      };
+    },
+    /**
+     * @处理公共日期格式
+     */
+    formatterDate(date, fmt) {
+      let nowDate = {
+        yyyy: date.getFullYear(), // 年
+        MM: date.getMonth() + 1, // 月份
+        dd: date.getDate(), //日
+        hh: date.getHours(),
+        mm: date.getMinutes(),
+        ss: date.getSeconds(),
+      };
+      if (/(y+)/.test(fmt)) {
+        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
+      }
+      for (var k in nowDate) {
+        if (new RegExp("(" + k + ")").test(fmt)) {
+          fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? nowDate[k] : ("00" + nowDate[k]).substr(("" + nowDate[k]).length));
+        }
+      }
+      return fmt;
+    },
+    /**
+     * @获取年月日时分秒
+     * @returns
+     */
+    formatterDateTime(time3) {
       var date = new Date(time3);
       var Y = date.getFullYear() + "-";
       var M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
@@ -153,6 +200,59 @@ const publicStore = defineStore("public", {
 
       return strDate;
     },
+
+    /**
+     * @统计两个日期之间的月份
+     */
+    getMonths(date1, date2) {
+      //用-分成数组
+      date1 = date1.split("-");
+      date2 = date2.split("-");
+      //获取年,月数
+      var year1 = parseInt(date1[0]),
+        month1 = parseInt(date1[1]),
+        year2 = parseInt(date2[0]),
+        month2 = parseInt(date2[1]),
+        //通过年,月差计算月份差
+        months = (year2 - year1) * 12 + (month2 - month1) + 1;
+      return months;
+    },
+
+    /**
+     * @计算当前坐标和G点坐标的偏差值
+     * @returns
+     */
+    caculateLL(lat1, lng1, lat2, lng2) {
+      var radLat1 = (lat1 * Math.PI) / 180.0;
+      var radLat2 = (lat2 * Math.PI) / 180.0;
+      var a = radLat1 - radLat2;
+      var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
+      var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
+      s = s * 6378.137;
+      s = Math.round(s * 10000) / 10;
+      console.log(s);
+      return s;
+    },
+
+    /**
+     * @数组对象排序
+     * @return
+     * @param {数据} data
+     * @param {0 从小到大 1 从大到小} sort
+     */
+    sortEvent(data, sort) {
+      let arr = [];
+      // 将需要排序的 key, 进行排列
+      let sortKeys = Object.keys(JSON.parse(JSON.stringify(data))).sort((a, b) => {
+        return sort == 0 ? JSON.parse(JSON.stringify(data))[a].sort - JSON.parse(JSON.stringify(data))[b].sort : JSON.parse(JSON.stringify(data))[b].sort - JSON.parse(JSON.stringify(data))[a].sort;
+      });
+      // 循环排列好的 key, 重新组成一个新的数组
+      for (var sortIndex in sortKeys) {
+        arr.push(JSON.parse(JSON.stringify(data))[sortKeys[sortIndex]]);
+      }
+
+      return arr;
+    },
   },
 });
 

+ 1 - 98
src/store/modules/xunJian.js

@@ -24,104 +24,7 @@ const useXunJianStore = defineStore("xunJian", {
       console.log("After" + context);
     },
   },
-  actions: {
-    getDate() {
-      var date = new Date();
-      var year = date.getFullYear(); //  返回的是年份
-      var month = date.getMonth() + 1; //  返回的月份上个月的月份,记得+1才是当月
-      if (month < 10) {
-        month = "0" + month;
-      }
-      var dates = date.getDate(); //  返回的是几号
-      if (dates < 10) {
-        dates = "0" + dates;
-      }
-      var day = date.getDay(); //  周一返回的是1,周六是6,但是周日是0
-      var arr = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
-      return {
-        year,
-        month,
-        dates,
-        day,
-        arr,
-      };
-    },
-    /**
-     * @处理公共日期格式
-     */
-    formatterDate(date, fmt) {
-      let nowDate = {
-        yyyy: date.getFullYear(), // 年
-        MM: date.getMonth() + 1, // 月份
-        dd: date.getDate(), //日
-        hh: date.getHours(),
-        mm: date.getMinutes(),
-        ss: date.getSeconds(),
-      };
-      if (/(y+)/.test(fmt)) {
-        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
-      }
-      for (var k in nowDate) {
-        if (new RegExp("(" + k + ")").test(fmt)) {
-          fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? nowDate[k] : ("00" + nowDate[k]).substr(("" + nowDate[k]).length));
-        }
-      }
-      return fmt;
-    },
-
-    /**
-     * @统计两个日期之间的月份
-     */
-    getMonths(date1, date2) {
-      //用-分成数组
-      date1 = date1.split("-");
-      date2 = date2.split("-");
-      //获取年,月数
-      var year1 = parseInt(date1[0]),
-        month1 = parseInt(date1[1]),
-        year2 = parseInt(date2[0]),
-        month2 = parseInt(date2[1]),
-        //通过年,月差计算月份差
-        months = (year2 - year1) * 12 + (month2 - month1) + 1;
-      return months;
-    },
-
-    /**
-     * @计算当前坐标和G点坐标的偏差值
-     * @returns
-     */
-    caculateLL(lat1, lng1, lat2, lng2) {
-      var radLat1 = (lat1 * Math.PI) / 180.0;
-      var radLat2 = (lat2 * Math.PI) / 180.0;
-      var a = radLat1 - radLat2;
-      var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
-      var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
-      s = s * 6378.137;
-      s = Math.round(s * 10000) / 10;
-      console.log(s);
-      return s;
-    },
-
-    /**
-     * @数组对象排序
-     * @return
-     * @param {数据} data
-     * @param {0 从小到大 1 从大到小} sort
-     */
-    sortEvent(data, sort) {
-      let arr = [];
-      // 将需要排序的 key, 进行排列
-      let sortKeys = Object.keys(JSON.parse(JSON.stringify(data))).sort((a, b) => {
-        return sort == 0 ? JSON.parse(JSON.stringify(data))[a].sort - JSON.parse(JSON.stringify(data))[b].sort : JSON.parse(JSON.stringify(data))[b].sort - JSON.parse(JSON.stringify(data))[a].sort;
-      });
-      // 循环排列好的 key, 重新组成一个新的数组
-      for (var sortIndex in sortKeys) {
-        arr.push(JSON.parse(JSON.stringify(data))[sortKeys[sortIndex]]);
-      }
-
-      return arr;
-    },
-  },
+  actions: {},
 });
 
 export default useXunJianStore;