Browse Source

Merge branch 'master' of http://47.111.81.118:3000/uskycloud/usky-web-mobile into fanghuisheng

fanghuisheng 3 tuần trước cách đây
mục cha
commit
3d59dc81cd

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

@@ -10,3 +10,13 @@ export function reportInfoList( param) {
     data: param,
   });
 }
+/**
+ * @报告状态读取修改接口
+ */
+export function putReportStatus( data) {
+  return request({
+    url: "/service-fire/demReportInfo/updateReadStatus" ,
+    method: "PUT",
+    data
+  });
+}

+ 8 - 0
src/api/system/user.js

@@ -115,3 +115,11 @@ export function getTenantByUser(params) {
       method: 'get',
   })
 }
+// 修改用户默认企业
+export function putTenantByUser(data) {
+  return request({
+      url: '/system/sysUserTenant/',
+      method: 'put',
+      data
+  })
+}

+ 1 - 1
src/pages/business/mhxf/fireReport/components/detailedPath.vue

@@ -39,7 +39,7 @@ host = window.location.host;
 if (host.indexOf(config.ip) != -1) {
   viewerUrl.value = `http://${config.ip}/statics/pdf_js/web/viewer.html`;
 } else {
-  viewerUrl.value = "http://file.usky.cn/statics/pdf_js/web/viewer.html";
+  viewerUrl.value = "https://file.usky.cn/statics/pdf_js/web/viewer.html";
 }
 
 watchEffect(() => {});

+ 37 - 21
src/pages/business/mhxf/fireReport/index.vue

@@ -16,14 +16,13 @@
     <template #default>
       <view class="fireReport-area">
         <view class="fireReport-area_center" v-for="(li, index) in dataList" :key="index">
-          <view class="fireReport-area_center_img" @click="handleSelect()">
+          <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>
@@ -33,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();
 
@@ -46,8 +45,13 @@ const total = ref(0);
 /**
  * @列表点击事件
  */
-function handleSelect(reportPath) {
-  proxy.$tab.navigateTo("/pages/business/mhxf/fireReport/components/detailedPath?reportPath=" + reportPath);
+function handleSelect(val) {
+  if(!val.isRead){
+    putReportStatus({id:val.id}).then((res) => {
+      reportInfoListApi()
+    })
+  }
+  proxy.$tab.navigateTo("/pages/business/mhxf/fireReport/components/detailedPath?reportPath=" + val.reportPath);
 }
 
 /**
@@ -58,10 +62,13 @@ function reportInfoListApi() {
   reportInfoList({
     pageSize: pageSize.value,
     pageNum: pageNum.value,
-    companyId: "",
     sourceType: 2,
   }).then((res) => {
-    dataList.value = res.data.records;
+    if(pageSize.value == 20){
+      dataList.value = res.data.records;
+    }else{
+      dataList.value = dataList.value.concat(res.data.records);
+    }
     total.value = res.data.total;
   });
 }
@@ -70,21 +77,28 @@ function reportInfoListApi() {
  * @下载
  * @按钮点击事件
  */
-function handleDownload(reportPath) {
+function handleDownload(val) {
   proxy.$modal.loading("报告下载中,请耐心等待...");
-
-  setTimeout(() => {
     //  #ifdef H5
-    window.open(reportPath);
+    if(!val.isRead){
+      putReportStatus({id:val.id}).then(() => {
+        reportInfoListApi()
+      })
+    }
+    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) {
+          if(!val.isRead){
+            putReportStatus({id:val.id}).then(() => {
+              reportInfoListApi()
+            })
+          }
           // 预览pdf文件
           uni.openDocument({
             filePath: res.tempFilePath,
@@ -100,10 +114,14 @@ function handleDownload(reportPath) {
 
     // #ifdef APP-PLUS
     uni.downloadFile({
-      url: reportPath,
+      url: val.reportPath,
       success: (res) => {
-        console.log(res);
         if (res.statusCode === 200) {
+          if(!val.isRead){
+            putReportStatus({id:val.id}).then(() => {
+              reportInfoListApi()
+            })
+          }
           // 保存pdf文件至手机,一般安卓端存储路径为:手机存储/dcim/camera文件夹下
           uni.saveImageToPhotosAlbum({
             filePath: res.tempFilePath,
@@ -134,16 +152,13 @@ function handleDownload(reportPath) {
       },
     });
     // #endif
-
     proxy.$modal.closeLoading();
-  }, 2000);
 }
-
 /**
  * @scrollView加载数据
  */
 function load() {
-  pageSize.value += 10;
+  pageNum.value += 1;
   reportInfoListApi();
 }
 
@@ -152,6 +167,7 @@ function load() {
  */
 function refresh() {
   pageSize.value = 20;
+  pageNum.value = 1;
   reportInfoListApi();
 }
 

+ 68 - 47
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" @click="changeTenantId(item.id)">
-              <image class="list-image" src="@/static/images/index/unit-active.png" v-if="item.id == useStore.tenantId"></image>
-              <image class="list-image" src="@/static/images/index/unit.png" v-if="item.id != useStore.tenantId"></image>
-              <text class="list-name">{{ item.tenantName }}</text>
-              <image class="list-right" src="@/static/images/index/right.png" v-if="item.id == useStore.tenantId"></image>
-              <!-- <text class="list-state">默认企业</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";
 /*----------------------------------组件引入-----------------------------------*/
@@ -125,7 +125,7 @@ import { useStores, commonStores } from "@/store/modules/index";
 import * as jwx from "@/utils/jssdk.js"; //引入js sdk的封装
 import { getToken, setToken, removeToken } from "@/utils/auth";
 import { storage, storageSystem } from "@/utils/storage"; // 公共方法引用
-import { getTenantByUser } from "@/api/system/user.js";
+import { getTenantByUser, putTenantByUser } from "@/api/system/user.js";
 import { decrypt, encrypt } from "@/plugins/jsencrypt";
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
@@ -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,
@@ -176,53 +176,75 @@ function getTenantList(id) {
       tenantIdList.value = res.data
       accountState.value = true;
     }
+    for(let i=0;i<tenantIdList.value.length;i++){
+      if(tenantIdList.value[i].isDefault){
+        useStore.SET_STORAGE_OBJECT_KEYS({ tenantId: tenantIdList.value[i].id });
+        break;
+      }
+    }
   });
 }
 /**
  * @企业切换
  */
 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)
+            });
           });
-        });
-  });
+    });
+  }
+}
+
+/**
+ * 默认企业
+ * @param {Object} val 企业对象
+ */
+ function defaultEnterprise(val){
+  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
@@ -466,7 +488,6 @@ onShow(() => {
   });
 });
 </script>
-
 <style lang="scss" scoped>
 .home-container {
   .transition {
@@ -582,14 +603,14 @@ onShow(() => {
     &-right {
       position: absolute;
       top: 38%;
-      right: 10%;
+      right: 25%;
       width: 16px;
       height: 11px;
       vertical-align: middle;
     }
     &-state {
       position: absolute;
-      right: 20px;
+      right: 10px;
       top: 16px;
       font-size: 12px;
       color: #2a98ff;

+ 1 - 1
src/pages/mine/secure/loginLog/index.vue

@@ -101,7 +101,7 @@ function selectListApi() {
   loginLogList({
     pageNum: state.pageNum,
     pageSize: state.pageSize,
-    userName: useStore.user.userName,
+    userName: uni.getStorageSync("storage_data").name,
   }).then((requset) => {
     if (requset.status === "SUCCESS") {
       state.dataList = requset.data.rows;

+ 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) => {