Selaa lähdekoodia

1.企业切换优化 2.报告添加已读状态修改

wangtao 2 päivää sitten
vanhempi
commit
0da6e90495

+ 9 - 0
src/api/business/mhxf/fireReport/index.js

@@ -10,3 +10,12 @@ export function reportInfoList( param) {
     data: param,
   });
 }
+/**
+ * @历史报告列表查询接口
+ */
+export function putReportStatus( data) {
+  return request({
+    url: "/service-fire/demReportInfo/updateReadStatus?id=" + data.id ,
+    method: "POST",
+  });
+}

+ 13 - 16
src/pages/business/mhxf/fireReport/index.vue

@@ -19,10 +19,10 @@
           <view class="fireReport-area_center_img">
             <u-image src="@/static/images/common/fireReport.png" width="13px" height="13px"></u-image>
           </view>
-          <view class="fireReport-area_center_title" @click="handleSelect(li.reportPath)">
+          <view class="fireReport-area_center_title" @click="handleSelect(li)">
             <view>{{ li.reportName }}</view>
           </view>
-          <view class="fireReport-area_center_button" @click="handleDownload(li.reportPath)">下载报告</view>
+          <view class="fireReport-area_center_button" @click="handleDownload(li)">下载报告</view>
         </view>
       </view>
     </template>
@@ -32,7 +32,7 @@
 <script setup>
 import { onReady, onLoad, onShow, onReachBottom, onNavigationBarButtonTap } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, watchEffect, getCurrentInstance } from "vue";
-import { reportInfoList } from "@/api/business/mhxf/fireReport";
+import { reportInfoList, putReportStatus } from "@/api/business/mhxf/fireReport";
 
 const { proxy } = getCurrentInstance();
 
@@ -45,8 +45,9 @@ const total = ref(0);
 /**
  * @列表点击事件
  */
-function handleSelect(reportPath) {
-    proxy.$tab.navigateTo("/pages/business/mhxf/fireReport/components/detailedPath?reportPath=" + reportPath);
+function handleSelect(val) {
+  putReportStatus({id:val.id})
+  proxy.$tab.navigateTo("/pages/business/mhxf/fireReport/components/detailedPath?reportPath=" + val.reportPath);
 }
 
 /**
@@ -72,21 +73,20 @@ function reportInfoListApi() {
  * @下载
  * @按钮点击事件
  */
-function handleDownload(reportPath) {
+function handleDownload(val) {
   proxy.$modal.loading("报告下载中,请耐心等待...");
-
-  // setTimeout(() => {
     //  #ifdef H5
-    window.open(reportPath);
+    putReportStatus({id:val.id})
+    window.open(val.reportPath);
     // #endif
 
     // 微信下载文件需要在微信公众平台>开发>开发管理>服务器域名>downloadFile合法域名>配置白名单域名
     // #ifdef MP-WEIXIN
     uni.downloadFile({
-      url: reportPath,
+      url: val.reportPath,
       success: (res) => {
-        console.log(res);
         if (res.statusCode === 200) {
+          putReportStatus({id:val.id})
           // 预览pdf文件
           uni.openDocument({
             filePath: res.tempFilePath,
@@ -102,10 +102,10 @@ function handleDownload(reportPath) {
 
     // #ifdef APP-PLUS
     uni.downloadFile({
-      url: reportPath,
+      url: val.reportPath,
       success: (res) => {
-        console.log(res);
         if (res.statusCode === 200) {
+          putReportStatus({id:val.id})
           // 保存pdf文件至手机,一般安卓端存储路径为:手机存储/dcim/camera文件夹下
           uni.saveImageToPhotosAlbum({
             filePath: res.tempFilePath,
@@ -136,11 +136,8 @@ function handleDownload(reportPath) {
       },
     });
     // #endif
-
     proxy.$modal.closeLoading();
-  // }, 2000);
 }
-
 /**
  * @scrollView加载数据
  */

+ 52 - 50
src/pages/index.vue

@@ -98,13 +98,13 @@
     <scroll-view style="height: calc(100% - 4px);width:100vw;background:#0d2e59;" scroll-y="true">
       <view class="unit">
         <view class="unit-title">切换企业</view>
-            <view :class="item.id == useStore.tenantId ? 'active' : ''" class="list" v-for="(item, index) in tenantIdList" :key="index">
-              <image class="list-image" src="@/static/images/index/unit-active.png" v-if="item.id == useStore.tenantId" @click="changeTenantId(item.id)"></image>
-              <image class="list-image" src="@/static/images/index/unit.png" v-if="item.id != useStore.tenantId" @click="changeTenantId(item.id)"></image>
-              <text class="list-name" @click="changeTenantId(item.id)">{{ item.tenantName }}</text>
-              <image class="list-right" src="@/static/images/index/right.png" v-if="item.id == useStore.tenantId"></image>
-              <text class="list-state" @click="defaultEnterprise(item)" :style="{ color: item.isDefault ? '#8D8F93' : '#2A98FF' }">{{ item.isDefault ? '默认企业' : '设为默认' }}</text>
-        </view>
+          <view :class="item.id == tenantIdChange ? 'active' : ''" class="list" v-for="(item, index) in tenantIdList" :key="index">
+            <image class="list-image" src="@/static/images/index/unit-active.png" v-if="item.id == tenantIdChange" @click="changeTenantId(item.id)"></image>
+            <image class="list-image" src="@/static/images/index/unit.png" v-if="item.id != tenantIdChange" @click="changeTenantId(item.id)"></image>
+            <text class="list-name" @click="changeTenantId(item.id)">{{ item.tenantName }}</text>
+            <image class="list-right" src="@/static/images/index/right.png" v-if="item.id == tenantIdChange"></image>
+            <text class="list-state" @click="defaultEnterprise(item)" :style="{ color: item.isDefault ? '#8D8F93' : '#2A98FF' }">{{ item.isDefault ? '默认企业' : '设为默认' }}</text>
+          </view>
       </view>
     </scroll-view>
   </uni-drawer>
@@ -114,7 +114,7 @@
 <script setup>
 /*----------------------------------依赖引入-----------------------------------*/
 import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
-import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs, nextTick } from "vue";
+import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs, nextTick, watch } from "vue";
 /*----------------------------------接口引入-----------------------------------*/
 import { scan_push, getHomePageData, getFunctionalModuleStatistics, getAppRouters, qrCodeSend, getMobileBanner } from "@/api/index";
 /*----------------------------------组件引入-----------------------------------*/
@@ -135,7 +135,7 @@ const commonStore = commonStores();
 const accountState = ref(false); // 有效账号状态(用于企业切换)
 const showLeft = ref(false); // 左侧菜单
 const showLeftState = ref(false); // 左侧菜单显示状态
-const tenantIdChange = ref(""); // 切换租户ID
+const tenantIdChange = ref(useStore.selectTenantId); // 切换租户ID
 const tenantIdList = ref([]); // 租户ID列表
 const state = reactive({
   dialogFlag: false,
@@ -188,40 +188,42 @@ function getTenantList(id) {
  * @企业切换
  */
 function changeTenantId(id) {
-  storage.set("tenantId", id);
-  var info = JSON.parse(
-    JSON.stringify({
-      userName: storage.get("account")?.userName,
-      passWord: storage.get("account")?.passWord,
-      tenantId: id,
-    })
-  );
-  useStore.LogOut().then(() => {
-    proxy.$modal.loading("加载中...");
-      useStore
-        .Login({
-          username: decrypt(info.userName),
-          password: decrypt(info.passWord),
-          tenantId: id,
-          method: "switch",
-          cids: proxy.$settingStore.pushClientId || undefined,
-          type: proxy.$common.isWechatMp() ? "wx" : "app",
-          openId: proxy.$common.isWechatMp() ? localStorage.getItem("wxOpenId") : undefined,
-        })
-        .then(() => {
-          // /** 获取用户信息 */
-          useStore.SET_STORAGE_OBJECT_KEYS({ tenantId: id });
-          useStore.GetInfo().then((res) => {
-            proxy.$settingStore.initThemeColor(storageSystem.get("themeColor")); //初始化默认主题
-            state.recentlyUsed = []
-            init();
-            setTimeout(() => {
-              showLeftStateClick();
-              proxy.$modal.closeLoading();
-            },1000)
+  if(tenantIdChange.value!= id){
+    tenantIdChange.value = id;
+    var info = JSON.parse(
+      JSON.stringify({
+        userName: storage.get("account")?.userName,
+        passWord: storage.get("account")?.passWord,
+        tenantId: id,
+      })
+    );
+    useStore.LogOut().then(() => {
+      proxy.$modal.loading("加载中...");
+        useStore
+          .Login({
+            username: decrypt(info.userName),
+            password: decrypt(info.passWord),
+            tenantId: id,
+            method: "switch",
+            cids: proxy.$settingStore.pushClientId || undefined,
+            type: proxy.$common.isWechatMp() ? "wx" : "app",
+            openId: proxy.$common.isWechatMp() ? localStorage.getItem("wxOpenId") : undefined,
+          })
+          .then(() => {
+            // /** 获取用户信息 */
+            useStore.SET_STORAGE_OBJECT_KEYS({ tenantId: id });
+            useStore.GetInfo().then((res) => {
+              proxy.$settingStore.initThemeColor(storageSystem.get("themeColor")); //初始化默认主题
+              state.recentlyUsed = []
+              init();
+              setTimeout(() => {
+                showLeftStateClick();
+                proxy.$modal.closeLoading();
+              },1000)
+            });
           });
-        });
-  });
+    });
+  }
 }
 
 /**
@@ -229,19 +231,20 @@ function changeTenantId(id) {
  * @param {Object} val 企业对象
  */
  function defaultEnterprise(val){
-  putTenantByUser({
-    userId:useStore?.userId,
-    tenantId:val.id
-  }).then(() => {
-    changeTenantId(val.id)
-  })
+  if(!val.isDefault){
+    putTenantByUser({
+      userId:useStore?.userId,
+      tenantId:val.id
+    }).then(() => {
+      changeTenantId(val.id)
+    })
+  }
 }
 /**
  * @初始化
  */
 async function init(options) {
   if (useStore?.userId) {
-    tenantIdChange.value = useStore.tenantId; //切换租户ID
     getTenantList(useStore.userId); //调用获取企业列表方法
   }
   //#ifdef H5
@@ -485,7 +488,6 @@ onShow(() => {
   });
 });
 </script>
-
 <style lang="scss" scoped>
 .home-container {
   .transition {

+ 2 - 3
src/store/modules/user.js

@@ -35,7 +35,7 @@ const useStores = defineStore("useStores", {
     loginBg: storage.get("loginBg"),
     loginLogo: storage.get("loginLogo"),
     tenantId: storage.get("tenantId"),
-
+    selectTenantId: storage.get("selectTenantId"),
     user: {},
     userArr: {},
     postGroup: "", //岗位
@@ -54,8 +54,8 @@ const useStores = defineStore("useStores", {
             setToken(res.data.access_token);
             this.codeTime = 0
             storage.set("account",{ userName:encrypt(data.username),passWord:encrypt(data.password) })
+            storage.set("selectTenantId", res.data.tenantId);
             resolve(res);
-            resolve();
           })
           .catch((error) => {
             modal.closeLoading();
@@ -113,7 +113,6 @@ const useStores = defineStore("useStores", {
               email: data.user.email,//邮箱
               sex: data.user.sex,//性别
             })
-
             resolve(res);
           })
           .catch((error) => {