From da51e7d5bbf5ff1610209510571e94d0523b515c Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 24 四月 2024 17:40:37 +0800
Subject: [PATCH] 完善自动评估模块,规范性分析报告的后台任务和结果下载逻辑

---
 src/views/fytz/user/UserInfo.vue |  170 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 108 insertions(+), 62 deletions(-)

diff --git a/src/views/fytz/user/UserInfo.vue b/src/views/fytz/user/UserInfo.vue
index 27d814e..7957a89 100644
--- a/src/views/fytz/user/UserInfo.vue
+++ b/src/views/fytz/user/UserInfo.vue
@@ -3,10 +3,14 @@
     <template #options>
       <FYOptionLocation
         :allOption="true"
-        :level="4"
+        :level="5"
         v-model:value="formSearch._locations"
       ></FYOptionLocation>
-      <FYOptionText label="鍏抽敭瀛�" placeholder="杈撳叆鍚嶇О鍏抽敭瀛�" v-model:value="formSearch.searchText"></FYOptionText>
+      <FYOptionText
+        label="鍦烘櫙鍚嶇О"
+        placeholder="杈撳叆鍚嶇О鍏抽敭瀛�"
+        v-model:value="formSearch.searchText"
+      ></FYOptionText>
       <FYOptionScene
         :allOption="true"
         :type="1"
@@ -19,13 +23,7 @@
     </template>
 
     <template #table-column>
-      <el-table-column
-        type="index"
-        fixed="left"
-        prop="userInfo.realname"
-        label="鍚嶇О"
-        width="400"
-      >
+      <el-table-column type="index" fixed="left" prop="userInfo.realname" label="鍚嶇О" width="400">
         <template #default="scope">
           <el-tooltip
             effect="dark"
@@ -38,54 +36,84 @@
         </template>
       </el-table-column>
       <el-table-column prop="userInfo.acountname" label="璐﹀彿" width="110" />
-      <el-table-column prop="sceneTypeName" label="绫诲瀷" width="130" />
-      <el-table-column prop="biProvinceName" label="鐪�" width="90" />
-      <el-table-column prop="biCityName" label="甯�" width="90" />
+      <el-table-column prop="sceneTypeName" label="绫诲瀷" width="100" />
+      <el-table-column prop="biProvinceName" label="鐪�" width="80" />
+      <el-table-column prop="biCityName" label="甯�" width="80" />
       <!-- <el-table-column prop="districtname" label="鍖哄幙" width="90" /> -->
-      <el-table-column prop="userInfo.extension1" label="鍖哄幙" width="90" />
+      <el-table-column prop="userInfo.extension1" label="鍖哄幙" width="80" />
       <el-table-column prop="biTownName" label="琛楅亾" width="110" />
       <el-table-column prop="biArea" label="闆嗕腑鍖�" width="110" />
-      <el-table-column prop="biManagementCompany" label="鐗╀笟" min-width="110"/>
+      <el-table-column prop="biManagementCompany" label="鐗╀笟" min-width="110" />
       <el-table-column prop="userInfo.isenable" label="鐘舵��" width="90">
-        <template #default="scope">
-          {{ scope.row.userInfo.isenable ? '涓婄嚎涓�' : '宸蹭笅绾�' }}
+        <template #default="{ row }">
+          {{ row.userInfo.isenable ? '涓婄嚎涓�' : '宸蹭笅绾�' }}
         </template>
       </el-table-column>
       <el-table-column prop="userInfo.usertype" label="鐢ㄦ埛绫诲瀷" width="90" />
-      <el-table-column fixed="right" align="right" label="鎿嶄綔" width="140">
+      <el-table-column fixed="right" align="right" label="鎿嶄綔" width="190">
         <template #header>
-          <el-button
-            icon="DocumentAdd"
-            size="default"
-            type="success"
-            @click="drawer = true"
+          <el-button icon="DocumentAdd" size="default" type="success" @click="drawer = true"
             >鏂板鐢ㄦ埛</el-button
           >
         </template>
-        <template #default="scope">
-          <el-button
-            :loading="scope.row.loading1"
-            type="primary"
-            size="small"
-            @click="editRow(scope)"
-            >鏌ョ湅</el-button
-          >
-          <!-- <el-button
-            :loading="scope.row.loading2"
-            :type="scope.row.extension1 != '0' ? 'danger' : 'primary'"
-            size="small"
-            @click="itemActive(scope)"
-            >{{ scope.row.extension1 != '0' ? '涓嬬嚎' : '涓婄嚎' }}</el-button
-          > -->
+        <template #default="{ row }">
+          <el-space>
+            <el-button
+              :loading="row.loading2"
+              :type="row.userInfo.isenable != '0' ? 'danger' : 'primary'"
+              size="small"
+              @click="itemActive(row)"
+              >{{ row.userInfo.isenable != '0' ? '涓嬬嚎' : '涓婄嚎' }}</el-button
+            >
+            <el-button-group>
+              <el-button type="primary" :loading="row.loading1" size="small" @click="editRow(row)"
+                >鏌ョ湅</el-button
+              >
+              <el-dropdown @command="handleCommand" trigger="click">
+                <el-button
+                  type="primary"
+                  :loading="row.downloadLoading"
+                  size="small"
+                  :icon="row.downloadLoading ? '' : 'ArrowDown'"
+                ></el-button>
+                <template #dropdown>
+                  <el-dropdown-menu>
+                    <el-dropdown-item icon="Download" :command="{ c: 1, p: row }"
+                      >涓嬭浇鐜俊鐮�</el-dropdown-item
+                    >
+                  </el-dropdown-menu>
+                </template>
+              </el-dropdown>
+            </el-button-group>
+            <!-- <el-dropdown
+              split-button
+              :loading="row.loading1"
+              size="small"
+              type="primary"
+              @click="editRow(row)"
+              @command="handleCommand"
+              trigger="click"
+            >
+              鏌ョ湅
+              <template #dropdown>
+                <el-dropdown-menu>
+                  <el-dropdown-item icon="Download" :command="{ c: 1, p: row }"
+                    >涓嬭浇鐜俊鐮�</el-dropdown-item
+                  >
+                </el-dropdown-menu>
+              </template>
+            </el-dropdown> -->
+          </el-space>
         </template>
       </el-table-column>
     </template>
   </FYTable>
-  <CompUserInfoAddDrawer v-model:drawer="drawer"></CompUserInfoAddDrawer>
+  <CompUserInfoAddDrawer v-model="drawer"></CompUserInfoAddDrawer>
 </template>
 
 <script>
 import userApi from '@/api/fytz/userApi';
+import creditApi from '@/api/fytz/creditApi';
 import { useLoadingStore } from '@/stores/loadingStore';
 import { mapStores } from 'pinia';
 import { useMessageBoxTip } from '@/composables/messageBox';
@@ -93,34 +121,36 @@
 
 export default {
   components: {
-    CompUserInfoAddDrawer,
+    CompUserInfoAddDrawer
   },
   data() {
     return {
+      // 鏌ヨ鏉′欢
       formSearch: {
         _locations: {},
         searchText: '',
         scensetype: {},
-        online: {},
+        online: {}
       },
-      drawer: false,
+      // 鏂板鐢ㄦ埛寮瑰嚭妗�
+      drawer: false
     };
   },
   computed: {
-    ...mapStores(useLoadingStore),
+    ...mapStores(useLoadingStore)
   },
   methods: {
     onSearch(page, func) {
       const f = this.formSearch;
       const area = {};
       // 琛屾斂鍖哄垝
-      area.provinceCode = f._locations.pCode ? f._locations.pCode + '0000' : undefined
+      area.provinceCode = f._locations.pCode;
       area.provinceName = f._locations.pName;
       if (area.provinceCode == null) {
         area.provinceCode = null;
         area.provinceName = null;
       }
-      area.cityCode = f._locations.cCode ? f._locations.cCode.substring(0, 3) + '100' : undefined
+      area.cityCode = f._locations.cCode;
       area.cityName = f._locations.cName;
       area.districtCode = f._locations.dCode;
       area.districtName = f._locations.dName;
@@ -140,43 +170,59 @@
         if (res) {
           func({
             data: res.data,
-            total: res.head.totalCount,
+            total: res.head.totalCount
           });
         }
       });
     },
-    editRow(scope) {
-      scope.row.loading1 = true;
-      this.loadingStore.loadingStatus.push(() => (scope.row.loading1 = false));
-      this.$router.push(`userEdit/${scope.row.biGuid}`);
+    editRow(row) {
+      row.loading1 = true;
+      this.loadingStore.pushLoading(() => (row.loading1 = false));
+      this.$router.push(`userEdit/${row.userInfo.guid}`);
     },
-    itemActive(scope) {
-      const rb = {};
-      rb.guid = scope.row.guid;
-      rb.extension1 = scope.row.extension1 != '0' ? '0' : '1';
-      const msg = scope.row.extension1 != '0' ? '涓嬬嚎' : '涓婄嚎';
+    itemActive(row) {
+      const param = {
+        guid: row.userInfo.guid,
+        isenable: !row.userInfo.isenable
+      };
+      const msg = row.userInfo.isenable ? '涓嬬嚎' : '涓婄嚎';
       useMessageBoxTip({
         confirmMsg: `纭${msg}璇ュ満鏅紵`,
         confirmTitle: msg,
-        onConfirm: () => {
-          scope.row.loading2 = true;
+        onConfirm: async () => {
+          row.loading2 = true;
           return userApi
-            .updateScene(rb)
+            .updateUserInfo(param)
             .then((res) => {
-              if (res == 1) {
-                scope.row.extension1 = rb.extension1;
+              if (res.success) {
+                row.userInfo.isenable = param.isenable;
               }
             })
             .finally(() => {
-              scope.row.loading2 = false;
+              row.loading2 = false;
             });
-        },
+        }
       });
     },
     tableRowClassName({ row }) {
       return row.userInfo.isenable ? 'online-row' : 'offline-row';
     },
-  },
+    handleCommand(e) {
+      const userId = e.p.userInfo.guid;
+      switch (e.c) {
+        // 涓嬭浇鐜俊鐮�
+        case 1:
+          e.p.downloadLoading = true;
+          creditApi.downloadCode(userId).finally(() => {
+            e.p.downloadLoading = false;
+          });
+          break;
+
+        default:
+          break;
+      }
+    }
+  }
 };
 </script>
 <style></style>

--
Gitblit v1.9.3