Browse Source

事件上报功能模块完成

fanghuisheng 11 months ago
parent
commit
9bcbfbb8f6

+ 2 - 2
src/components/oa-upload/index.vue

@@ -104,7 +104,7 @@ function uploadClick() {
     sourceType: ["album", "camera"], //从相册选择、摄像头
     success: function (res) {
       res.tempFilePaths.forEach((url) => {
-        if (uploadList.value.length >= uploadCount.value) {
+        if (uploadCount.value >= uploadList.value.length) {
           uploadApi(url);
         }
       });
@@ -118,7 +118,6 @@ function uploadClick() {
  */
 function uploadApi(url) {
   let data = { name: "file", filePath: url };
-
   uploadAvatar(data).then((response) => {
     emit("uploadSuccessChange", response.data);
   });
@@ -141,6 +140,7 @@ function uploadViewClose(index) {
 
 <style scoped>
 .oa-upload {
+  width: 100%;
   display: flex;
   flex-wrap: wrap;
 }

+ 1 - 2
src/main.js

@@ -6,7 +6,7 @@ import "./permission"; // permission
 
 // 引入json导出组件
 import JsonExcel from "vue-json-excel";
-import { useDict } from '@/utils/dict'
+
 // 引入UI组件
 import uviewPlus from "@/uni_modules/uview-plus";
 import oaCalendar from "@/components/oa-calendar/uni-calendar";
@@ -45,7 +45,6 @@ export function createApp() {
   // 添加全局变量
   app.provide("$store", store);
   app.config.globalProperties.$store = store;
-  app.config.globalProperties.useDict = useDict
 
   app
     .use(uviewPlus)

+ 225 - 0
src/pages/business/zhaf/xunJian/error/index.vue

@@ -0,0 +1,225 @@
+<template>
+  <scroll-view id="exception" class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
+    <u--form ref="uForm" :model="form" :rules="rules" labelWidth="90">
+      <view style="padding: 10px 10px 20px 20px; background: #ffffff">
+        <u-form-item label="姓名" prop="nickName" required :borderBottom="true">
+          <u-input v-model="form.nickName" placeholder="姓名(必填)" border="none" maxlength="50" disabledColor="transparent" disabled />
+        </u-form-item>
+        <u-form-item label="事件名称" prop="eventName" required :borderBottom="true">
+          <u-input v-model="form.eventName" placeholder="事件名称(必填)" border="none" maxlength="50" />
+        </u-form-item>
+        <u-form-item label="事件分类" prop="eventCategory" required :borderBottom="true" @click="handleAction('事件分类')">
+          <u-input v-model="form.eventCategoryName" placeholder="事件分类(必选)" suffixIcon="arrow-right" suffixIconStyle="color: #909399" border="none" disabledColor="transparent" disabled />
+        </u-form-item>
+        <u-form-item label="事件类型" prop="eventType" required :borderBottom="true" @click="handleAction('事件类型')">
+          <u-input v-model="form.eventTypeName" placeholder="事件类型(必选)" suffixIcon="arrow-right" suffixIconStyle="color: #909399" border="none" disabledColor="transparent" disabled />
+        </u-form-item>
+        <u-form-item label="事件等级" prop="eventLevel" required :borderBottom="true" @click="handleAction('事件等级')">
+          <u-input v-model="form.eventLevelName" placeholder="事件类型(必选)" suffixIcon="arrow-right" suffixIconStyle="color: #909399" border="none" disabledColor="transparent" disabled />
+        </u-form-item>
+        <u-form-item label="现场图片" prop="pictureUrl" :borderBottom="true">
+          <oa-upload :uploadCount="5" :uploadList="form.imageList" :uploadListSrc="'url'" @uploadSuccessChange="uploadSuccessChange" @uploadDeleteChange="uploadDeleteChange"></oa-upload>
+        </u-form-item>
+        <u-form-item label="备注" prop="remark" :borderBottom="true">
+          <u--textarea v-model="form.remark" placeholder="备注信息,最多可输入50个字" :count="true" border="none" maxlength="50"></u--textarea>
+        </u-form-item>
+      </view>
+    </u--form>
+
+    <view class="app-button">
+      <view class="app-button-padding"></view>
+      <view class="app-button-fixed">
+        <u-button class="app-buttom" type="primary" @click="handleSubmit()" shape="circle"> 上报异常 </u-button>
+      </view>
+    </view>
+
+    <u-picker
+      :show="actionShow"
+      :columns="actionsList"
+      :title="'请选择' + actionTitle"
+      keyName="label"
+      visibleItemCount="6"
+      :defaultIndex="[actionDefaultIndex]"
+      :closeOnClickOverlay="true"
+      @close="actionShow = false"
+      @cancel="actionShow = false"
+      @confirm="selectAction"
+    ></u-picker>
+  </scroll-view>
+</template>
+
+<script setup>
+/*----------------------------------依赖引入-----------------------------------*/
+import { onLoad, onShow, onHide, onLaunch, onReady } from "@dcloudio/uni-app";
+import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance, computed } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
+import { errorApi } from "@/api/business/zhaf/xunJian/index.js";
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
+import { useStores, commonStores } from "@/store/modules/index";
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
+const { proxy } = getCurrentInstance();
+const useStore = useStores();
+const commonStore = commonStores();
+const { patrol_event_classify, patrol_event_grade, patrol_event_type } = proxy.useDict("patrol_event_classify", "patrol_event_grade", "patrol_event_type");
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
+  form: {
+    nickName: computed(() => {
+      return useStore.nickName;
+    }),
+    eventCategory: "", //事件分类
+    eventCategoryName: "", //事件分类名称
+    eventType: "", //事件类型
+    eventTypeName: "", //事件类型名称
+    eventLevel: "", //事件等级
+    eventLevelName: "", //事件等级名称
+    remark: "", //备注
+    deviceId: computed(() => {
+      return proxy.$settingStore.deviceList.deviceId;
+    }), //设备Id
+    planId: undefined, //计划Id
+    imageList: [],
+  },
+
+  rules: {
+    nickName: [{ required: true, message: "请输入姓名", trigger: ["blur", "change"] }],
+    eventCategory: [{ required: true, message: "请选择事件分类", trigger: ["blur", "change"] }],
+    eventType: [{ required: true, message: "请选择事件类型", trigger: ["blur", "change"] }],
+    eventLevel: [{ required: true, message: "请选择事件等级", trigger: ["blur", "change"] }],
+  },
+
+  actionIndex: 0,
+  actionTitle: "",
+  actionShow: false,
+  actionDefaultIndex: 0,
+  actionsList: [[]],
+});
+
+const { form, rules, actionTitle, actionIndex, actionsList, actionShow, actionDefaultIndex } = toRefs(state);
+
+/**
+ * @按钮点击事件
+ */
+function handleSubmit(value) {
+  proxy.$refs["uForm"]
+    .validate()
+    .then((res) => {
+      proxy.$modal.msg("校验通过");
+
+      var param = {
+        eventName: state.form.eventName, //事件名称
+        eventType: state.form.eventType, //事件类型
+        eventLevel: state.form.eventLevel, //事件等级
+        eventCategory: state.form.eventCategory, //事件分类
+        deviceId: state.form.deviceId, //设备Id
+        planId: state.form.planId, //计划Id
+        eventImage: JSON.stringify(state.form.imageList),
+        remark: state.form.remark,
+      };
+
+      errorApi()
+        .Insert(param)
+        .then(() => {
+          uni.showToast({
+            title: "提交成功",
+          });
+          uni.navigateBack({
+            delta: 1, //返回到需要执行方法的页面
+          });
+        })
+        .catch((err) => {
+          proxy.$modal.msg("网络异常,请稍后重试!");
+        });
+    })
+    .catch((errors) => {
+      proxy.$modal.msg("校验失败");
+    });
+}
+
+/**
+ * @action弹出框点击事件
+ */
+function handleAction(value, index, ind) {
+  if (value == "事件分类") {
+    state.actionTitle = "事件分类";
+    state.actionIndex = index;
+
+    state.actionsList[0] = patrol_event_classify.value;
+    state.actionDefaultIndex = 0;
+  }
+
+  if (value == "事件类型") {
+    state.actionTitle = "事件类型";
+    state.actionIndex = index;
+
+    state.actionsList[0] = patrol_event_type.value;
+    state.actionDefaultIndex = 0;
+  }
+
+  if (value == "事件等级") {
+    state.actionTitle = "事件等级";
+    state.actionIndex = index;
+
+    state.actionsList[0] = patrol_event_grade.value;
+    state.actionDefaultIndex = 0;
+  }
+
+  state.actionShow = true;
+}
+
+/**
+ * @action弹出框选择事件
+ */
+function selectAction(e) {
+  if (state.actionTitle == "事件分类") {
+    state.form.eventCategory = e.value[0].value;
+    state.form.eventCategoryName = e.value[0].label;
+  }
+
+  if (state.actionTitle == "事件类型") {
+    state.form.eventType = e.value[0].value;
+    state.form.eventTypeName = e.value[0].label;
+  }
+
+  if (state.actionTitle == "事件等级") {
+    state.form.eventLevel = e.value[0].value;
+    state.form.eventLevelName = e.value[0].label;
+  }
+
+  state.actionShow = false;
+}
+
+/**
+ * @图片上传成功回调
+ */
+function uploadSuccessChange(e) {
+  state.form.imageList.push({
+    name: e.name,
+    url: e.url,
+  });
+}
+
+/**
+ * @图片删除回调
+ */
+function uploadDeleteChange(e) {
+  state.form.imageList = e;
+}
+
+onLoad((options) => {});
+
+onShow(() => {
+  //调用系统主题颜色
+  proxy.$settingStore.systemThemeColor([1]);
+});
+</script>
+
+<style lang="scss">
+#exception {
+  :deep(.u-picker__view__column__item) {
+    font-size: 13px;
+  }
+}
+</style>

+ 23 - 17
src/pages/mine.vue

@@ -4,14 +4,14 @@
     <view class="top-area" :class="'bg-' + themeColor.name" :style="{ paddingTop: proxy.$settingStore.StatusBar ? proxy.$settingStore.StatusBar + 20 + 'px' : '55px' }">
       <view class="flex justify-between p15">
         <view class="flex align-center">
-          <view class="cu-avatar xl round border bg-white" v-if="!avatar" @click="!data.nickName ? proxy.$settingStore.handleToLogin() : proxy.$settingStore.handleToAvatar(1)">
+          <view class="cu-avatar xl round border bg-white" v-if="!avatar" @click="!state.nickName ? proxy.$settingStore.handleToLogin() : proxy.$settingStore.handleToAvatar(1)">
             <view class="iconfont oaIcon-people text-gray"></view>
           </view>
           <image class="cu-avatar xl round border bg-white" v-if="avatar" :src="avatar" @click="proxy.$settingStore.handleToAvatar(2)"> </image>
-          <view class="login-tip" v-if="!data.nickName" @click="proxy.$settingStore.handleToLogin()"> 点击登录 </view>
-          <view class="user-info" v-if="data.nickName">
-            <view class="u_title"> {{ data.nickName }} </view>
-            <view class="u_title"> {{ data.phone ? data.phone.substr(0, 3) + "******" + data.phone.substr(9) : "" }} </view>
+          <view class="login-tip" v-if="!state.nickName" @click="proxy.$settingStore.handleToLogin()"> 点击登录 </view>
+          <view class="user-info" v-if="state.nickName">
+            <view class="u_title"> {{ state.nickName }} </view>
+            <view class="u_title"> {{ state.phone ? state.phone.substr(0, 3) + "******" + state.phone.substr(9) : "" }} </view>
           </view>
         </view>
         <view class="flex align-center"> </view>
@@ -165,22 +165,28 @@
 </template>
 
 <script setup>
-import config from "@/config";
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
 import { useStores, commonStores } from "@/store/modules/index";
-
-const useStore = useStores();
+/*----------------------------------公共方法引入-----------------------------------*/
+import config from "@/config";
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
+const useStore = useStores();
+const commonStore = commonStores();
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
+  avatar: computed(() => {
+    return useStore.avatar;
+  }),
+  themeColor: computed(() => {
+    return proxy.$settingStore.themeColor;
+  }),
 
-const avatar = computed(() => {
-  return useStore.avatar;
-});
-const themeColor = computed(() => {
-  return proxy.$settingStore.themeColor;
-});
-
-const data = reactive({
   nickName: useStore.nickName,
   phone: useStore.phonenumber,
   version: config.appInfo.version,
@@ -189,7 +195,7 @@ const data = reactive({
   themeList: proxy.$constData.themeList,
 });
 
-const { colorModal, themeList } = toRefs(data);
+const { avatar, themeColor, colorModal, themeList } = toRefs(state);
 
 /**
  * @检查更新

+ 11 - 7
src/pages/register.vue

@@ -46,16 +46,20 @@
 </template>
 
 <script setup>
-import config from "@/config";
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
 import { useStores, commonStores } from "@/store/modules/index";
-import { getToken, setToken, removeToken } from "@/utils/auth";
-
-const useStore = useStores();
+/*----------------------------------公共方法引入-----------------------------------*/
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-
-const dataList = reactive({
+const useStore = useStores();
+const commonStore = commonStores();
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
   nickName: undefined,
   phone: undefined,
   verify: undefined,
@@ -65,7 +69,7 @@ const dataList = reactive({
   confirmPasswordBool: true,
 });
 
-const { nickName, phone, verify, newPassword, newPasswordBool, confirmPassword, confirmPasswordBool } = toRefs(dataList);
+const { nickName, phone, verify, newPassword, newPasswordBool, confirmPassword, confirmPasswordBool } = toRefs(state);
 
 /**
  * @点击发送验证码

+ 12 - 10
src/pages/serveConfig.vue

@@ -34,25 +34,27 @@
 </template>
 
 <script setup>
-import config from "@/config";
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance } from "vue";
+/*----------------------------------接口引入-----------------------------------*/
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
 import { useStores, commonStores } from "@/store/modules/index";
-import { getToken, setToken, removeToken } from "@/utils/auth";
-
-const commonStore = commonStores();
-
+/*----------------------------------公共方法引入-----------------------------------*/
+import config from "@/config";
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-
-const dataList = reactive({
+const useStore = useStores();
+const commonStore = commonStores();
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
   linkUrl: "", //链接地址
   port: "",
   content: "",
   index: "",
 });
-
-const uForm = ref(null);
-const { linkUrl, port, content, index } = toRefs(dataList);
+const { linkUrl, port, content, index } = toRefs(state);
 
 /**
  * @扫一扫

+ 12 - 10
src/pages/serveConfigSelect.vue

@@ -52,23 +52,25 @@
 </template>
 
 <script setup>
-import config from "@/config";
+/*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance, watchEffect } from "vue";
-import { getToken, setToken, removeToken } from "@/utils/auth";
+/*----------------------------------接口引入-----------------------------------*/
+/*----------------------------------组件引入-----------------------------------*/
+/*----------------------------------store引入-----------------------------------*/
 import { useStores, commonStores } from "@/store/modules/index";
-
-const commonStore = commonStores();
-
+/*----------------------------------公共方法引入-----------------------------------*/
+import config from "@/config";
+/*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
-
-const dataList = reactive({
+const useStore = useStores();
+const commonStore = commonStores();
+/*----------------------------------变量声明-----------------------------------*/
+const state = reactive({
   radiolist: [],
   radiovalue: "",
 });
-
-const uForm = ref(null);
-const { radiolist, radiovalue } = toRefs(dataList);
+const { radiolist, radiovalue } = toRefs(state);
 
 /**
  * @切换单选

+ 3 - 0
src/plugins/index.js

@@ -8,6 +8,7 @@ import grid from "./grid.plugins.js";
 import nfc from "./nfc.plugins.js";
 
 import config from "@/config"; // config
+import { useDict } from '@/utils/dict'
 import { settingStores } from "@/store/modules/index";
 
 export default {
@@ -45,5 +46,7 @@ export default {
     // 公共设置stroe
     app.provide("$settingStore", settingStores());
     app.config.globalProperties.$settingStore = settingStores();
+    // 公共字典模块
+    app.config.globalProperties.useDict = useDict
   },
 };

+ 17 - 21
src/store/modules/setting.js

@@ -13,8 +13,6 @@ import modal from "@/plugins/modal.plugins.js";
 import common from "@/plugins/common.plugins.js";
 import setting from "@/plugins/setting.plugins.js";
 
-
-
 const settingStore = defineStore("storage-setting", {
     state: () => ({
         pushClientId: undefined,//应用消息推送cid
@@ -24,10 +22,18 @@ const settingStore = defineStore("storage-setting", {
         StatusBar: 0,//APP顶部安全距离
         tabBarHeight: "",//APP底部安全距离
         barHightTop: "",//APP头部计算距离
+        deviceList: {
+            networkType: null, //网络类型
+            deviceBrand: null, //设备品牌
+            deviceId: null, //设备编号
+            deviceModel: null, //设备型号
+            userName: null, //用户账号
+            longitude: "", //经度
+            latitude: "", //纬度
+        },
 
         themeColor: storage.get("themeColor"),//主题
         fingerprintUserList: storage.get("fingerprintUserList"),//指纹登录用户数据
-
         nfcWaiting: "请将手机靠近NFC标签", //nfc读取页面-提示文字-数据存储
     }),
     actions: {
@@ -82,37 +88,27 @@ const settingStore = defineStore("storage-setting", {
          * @动态获取用户设备信息
          */
         baseAppInfo() {
-            var params = {
-                networkType: null, //网络类型
-                deviceBrand: null, //设备品牌
-                deviceId: null, //设备编号
-                deviceModel: null, //设备型号
-                userName: null, //用户账号
-                longitude: "", //经度
-                latitude: "", //纬度
-            };
-
             uni.getNetworkType({
                 success: function (res) {
-                    params.networkType = res.networkType;
+                    this.deviceList.networkType = res.networkType;
                 },
             });
 
             // 获取系统信息
             const systemInfo = uni.getSystemInfoSync();
-            params.deviceBrand = systemInfo.deviceBrand;
-            params.deviceId = systemInfo.deviceId;
-            params.deviceModel = systemInfo.deviceModel;
-            params.operateSystem = systemInfo.platform;
+            this.deviceList.deviceBrand = systemInfo.deviceBrand;
+            this.deviceList.deviceId = systemInfo.deviceId;
+            this.deviceList.deviceModel = systemInfo.deviceModel;
+            this.deviceList.operateSystem = systemInfo.platform;
 
             uni.getLocation({
                 type: "gcj02",
                 geocode: true,
                 highAccuracyExpireTime: 5000,
                 success: (res) => {
-                    params.longitude = res.longitude.toString();
-                    params.latitude = res.latitude.toString();
-                    baseAppInfoApi(params).then((res) => { })
+                    this.deviceList.longitude = res.longitude.toString();
+                    this.deviceList.latitude = res.latitude.toString();
+                    baseAppInfoApi(this.deviceList).then((res) => { })
                 },
                 fail: (res) => {
                 },