From 83af3dd309889489f541fc8e21894c9f79e5788c Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期五, 22 八月 2025 16:09:58 +0800
Subject: [PATCH] 用户管理

---
 src/views/mine/index.vue |  247 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 170 insertions(+), 77 deletions(-)

diff --git a/src/views/mine/index.vue b/src/views/mine/index.vue
index 9e9b734..0bb79f7 100644
--- a/src/views/mine/index.vue
+++ b/src/views/mine/index.vue
@@ -4,25 +4,40 @@
 import { useUserStoreHook } from "@/store/modules/user";
 import type { FormInstance, FormRules, UploadProps } from "element-plus";
 import { cloneDeep } from "@pureadmin/utils";
-import { onMounted, reactive, ref, watch } from "vue";
+import { onMounted, reactive, ref, watch, computed, onBeforeUpdate } from "vue";
 import { getToken } from "@/utils/auth";
 const { route } = useNav();
 import { baseUrlApi } from "@/api/util";
 import { cusExtendInfo, changeCusExtend } from "@/api/mine";
 import { Edit } from "@element-plus/icons-vue";
 import { enterpriseTypes } from "@/api/register/index";
-
-import {
-  addDialog,
-  closeDialog,
-  updateDialog,
-  closeAllDialog
-} from "@/components/ReDialog";
-
+import { initRouter, getTopMenu, handleAliveRoute } from "@/router/utils";
+const isManager = useUserStoreHook().isManager;
+import { type CusExtendDto } from "@/utils/auth";
 const ruleFormRef = ref<FormInstance>();
 const isLoading = ref(false);
 const showDialog = ref(false);
-const nowRole = ref({});
+const nowRole = computed(() => {
+  if (!state?.ruleForm?.exRoles) {
+    return {};
+  }
+  let nowRoleLiet;
+  let obj = {};
+  let nowRole = useUserStoreHook()?.nowRole;
+  if (state?.ruleForm?.exRoles.length > 1) {
+    nowRoleLiet = state.ruleForm.exRoles.find(item => {
+      return item.exRoleId == nowRole.id;
+    });
+    obj = Object.assign(nowRole, nowRoleLiet);
+  } else {
+    obj = Object.assign(nowRole, state.ruleForm.exRoles[0]);
+  }
+  return obj;
+});
+const userInfo = computed<CusExtendDto>(() => {
+  let obj = useUserStoreHook().enterpriseInfo;
+  return obj;
+});
 const state = reactive({
   userInfo: useUserStoreHook().enterpriseInfo,
   headers: {
@@ -40,7 +55,7 @@
     // 浜ゆ槗涓讳綋浠g爜锛堝悓瑙掕壊浠g爜锛屼笉鍙┖锛屾渶灏忛暱搴︿负1锛�
     transactionCode: "", // string锛屽繀濉�
     // 浜ゆ槗涓讳綋鍚嶇О
-    transactionName: null, // string锛屽彲绌�
+    transactionName: "", // string锛屽彲绌�
     // 钀ヤ笟鎵х収鏂囦欢璺緞
     businessLicense: null, // string锛屽彲绌�
     // 浼佷笟鍚嶇О
@@ -78,7 +93,9 @@
     // 浼佷笟寮�鎴疯
     bankName: null, // string锛屽彲绌�
     // 浼佷笟閾惰璐﹀彿
-    bankAccount: null // string锛屽彲绌�
+    bankAccount: null, // string锛屽彲绌�
+    bankAccountIMG: null,
+    exRoles: null
   },
   enterpriseList: [],
   type: "",
@@ -186,24 +203,37 @@
   expirySeconds: 60, // 楠岃瘉鐮佽繃鏈熸椂闂�
   phoneSeconds: 0, // 鎵嬫満楠岃瘉鐮佸�掕鏃�
   roleList: [],
-  showDialog: false
+  showDialog: false,
+  srcList: []
 });
 onMounted(async () => {
   state.ruleForm = cloneDeep(state.userInfo);
   state.ruleForm.enterpriseType = state.ruleForm.enterpriseType.split(",");
-  nowRole.value = useUserStoreHook()?.nowRole;
-  console.log(nowRole.value);
+  // nowRole.value = useUserStoreHook()?.nowRole;
   if (nowRole.value) {
     state.ruleForm.transactionCode = nowRole.value.code;
-    state.userInfo.transactionName = nowRole.value.name;
+    // let nowRoleLiet;
+    // if (state.ruleForm.exRoles.length > 1) {
+    //   nowRoleLiet = state.ruleForm.exRoles.find(item => {
+    //     return item.exRoleId == nowRole.value.id;
+    //   });
+    //   nowRole.value = Object.assign(nowRole.value, nowRoleLiet);
+    // } else {
+    //   nowRole.value = Object.assign(nowRole.value, state.ruleForm.exRoles[0]);
+    // }
+    // state.userInfo.transactionName = nowRole.value.name;
   } else {
-    state.ruleForm.transactionCode = route.query.code;
-    state.userInfo.enterpriseTypeName = route.query.name;
+    state.ruleForm.transactionCode = route.query.code as string;
+    // state.userInfo.enterpriseTypeName = route.query.name;
   }
-
   let restypes = await enterpriseTypes();
   state.enterpriseList = restypes?.result;
 });
+const showPreview = ref(false);
+const showImg = (name: string | number) => {
+  showPreview.value = true;
+  state.srcList = [state.ruleForm[name]];
+};
 const isLeaf = data => {
   data.forEach(item => {
     if (!item.child) {
@@ -223,24 +253,24 @@
   }
 };
 
-const showImg = name => {
-  addDialog({
-    width: "40%",
-    title: "鏌ョ湅钀ヤ笟鎵х収",
-    contentRenderer: () => <img src={state.userInfo[name]} />, // jsx 璇硶 锛堟敞鎰忓湪.vue鏂囦欢鍚敤jsx璇硶锛岄渶瑕佸湪script寮�鍚痩ang="tsx"锛�
-    closeCallBack: ({ options, args }) => {
-      // options.props 鏄搷搴斿紡鐨�
-      // const { formInline } = options.props as FormProps;
-      // const text = `濮撳悕锛�${formInline.user} 鍩庡競锛�${formInline.region}`;
-      if (args?.command === "cancel") {
-        // 鎮ㄧ偣鍑讳簡鍙栨秷鎸夐挳
-        // active.value -= 1;
-      } else if (args?.command === "sure") {
-      } else {
-      }
-    }
-  });
-};
+// const showImg = name => {
+//   addDialog({
+//     width: "40%",
+//     title: "鏌ョ湅钀ヤ笟鎵х収",
+//     contentRenderer: () => <img src={state.userInfo[name]} />, // jsx 璇硶 锛堟敞鎰忓湪.vue鏂囦欢鍚敤jsx璇硶锛岄渶瑕佸湪script寮�鍚痩ang="tsx"锛�
+//     closeCallBack: ({ options, args }) => {
+//       // options.props 鏄搷搴斿紡鐨�
+//       // const { formInline } = options.props as FormProps;
+//       // const text = `濮撳悕锛�${formInline.user} 鍩庡競锛�${formInline.region}`;
+//       if (args?.command === "cancel") {
+//         // 鎮ㄧ偣鍑讳簡鍙栨秷鎸夐挳
+//         // active.value -= 1;
+//       } else if (args?.command === "sure") {
+//       } else {
+//       }
+//     }
+//   });
+// };
 const handleAvatarSuccess: UploadProps["onSuccess"] = (
   response,
   uploadFile
@@ -321,7 +351,10 @@
   let res = await changeCusExtend(obj);
   if (res.code == "200") {
     showDialog.value = false;
-    await useUserStoreHook().getCusExtendInfo();
+    await useUserStoreHook().changeLogoInExRule({
+      ruleCode: useUserStoreHook().nowRole.code
+    });
+    initRouter();
     message("淇敼鎴愬姛锛�", {
       type: "success"
     });
@@ -331,6 +364,22 @@
     });
   }
 };
+
+const handlebankAccountIMG: UploadProps["onSuccess"] = (
+  response,
+  uploadFile
+) => {
+  if (response.code == "200") {
+    // state.ruleForm.businessLicense = URL.createObjectURL(uploadFile.raw!);
+    state.ruleForm.bankAccountIMG = response.result;
+  } else {
+    message(response.message, {
+      type: "error"
+    });
+  }
+  isLoading.value = false;
+};
+
 defineOptions({
   name: "mine"
 });
@@ -338,7 +387,13 @@
 
 <template>
   <div>
-    <el-descriptions class="margin-top" title="" :column="3" border>
+    <el-descriptions
+      v-if="state.userInfo.enterpriseName"
+      class="margin-top"
+      title=""
+      :column="3"
+      border
+    >
       <!-- <template #extra>
       <el-button type="primary">Operation</el-button>
     </template> -->
@@ -346,14 +401,18 @@
         <template #label>
           <div class="cell-item">浜ゆ槗涓讳綋</div>
         </template>
-        {{ state.userInfo.transactionName }}
-        <el-tag v-if="!nowRole.hasFlsh" type="danger">璧勬枡瀹℃牳涓� </el-tag>
+        {{ nowRole?.name }}
+        <el-tag v-if="nowRole.steps == 2" type="success">瀹℃牳宸查�氳繃 </el-tag>
+        <el-tag v-else-if="nowRole.steps == 3" type="danger"
+          >璧勬枡鏈�氳繃
+        </el-tag>
+        <el-tag v-else type="warning">璧勬枡瀹℃牳涓� </el-tag>
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">浼佷笟鍚嶇О</div>
         </template>
-        {{ state.userInfo.enterpriseName }}
+        {{ userInfo.enterpriseName }}
 
         <span @click="showImg('businessLicense')">
           <el-link type="primary" underline>鏌ョ湅钀ヤ笟鎵х収</el-link>
@@ -363,62 +422,62 @@
         <template #label>
           <div class="cell-item">缁熶竴绀句細淇$敤浠g爜</div>
         </template>
-        {{ state.userInfo.unifiedSocialCreditCode }}
+        {{ userInfo.unifiedSocialCreditCode }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">娉ㄥ唽璧勯噾</div>
         </template>
-        {{ state.userInfo.registeredCapital }}
+        {{ userInfo.registeredCapital }}
       </el-descriptions-item>
       <el-descriptions-item :span="2">
         <template #label>
           <div class="cell-item">浼佷笟绫诲瀷</div>
         </template>
-        {{ state.userInfo.enterpriseType }}
+        {{ userInfo.enterpriseType }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">浣忔墍鍦�</div>
         </template>
-        {{ state.userInfo.residence }}
+        {{ userInfo.residence }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">鑱旂郴鐢佃瘽</div>
         </template>
-        {{ state.userInfo.legalRepresentativePhone }}
+        {{ userInfo.enterprisePhone }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">鎴愮珛鏃堕棿</div>
         </template>
-        {{ state.userInfo.establishmentTime }}
+        {{ userInfo.establishmentTime }}
       </el-descriptions-item>
       <el-descriptions-item :span="2">
         <template #label>
           <div class="cell-item">鐢靛瓙閭</div>
         </template>
-        {{ state.userInfo.enterpriseEmail }}
+        {{ userInfo.enterpriseEmail }}
       </el-descriptions-item>
       <el-descriptions-item :span="3" label-width="100">
         <template #label>
           <div class="cell-item">涓昏惀涓氬姟</div>
         </template>
-        {{ state.userInfo.mainBusiness }}
+        {{ userInfo.mainBusiness }}
       </el-descriptions-item>
 
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">娉曞畾浠h〃浜�</div>
         </template>
-        {{ state.userInfo.legalRepresentativeName }}
+        {{ userInfo.legalRepresentativeName }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">韬唤璇�</div>
         </template>
-        {{ state.userInfo.legalRepresentativeIdNumber }}
+        {{ userInfo.legalRepresentativeIdNumber }}
         <span @click="showImg('legalRepresentativeIdCard')">
           <el-link type="primary" underline>鏌ョ湅韬唤璇�</el-link>
         </span>
@@ -427,19 +486,19 @@
         <template #label>
           <div class="cell-item">鑱旂郴鐢佃瘽</div>
         </template>
-        {{ state.userInfo.legalRepresentativePhone }}
+        {{ userInfo.legalRepresentativePhone }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">涓氬姟缁忓姙浜�</div>
         </template>
-        {{ state.userInfo.operatorName }}
+        {{ userInfo.operatorName }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">韬唤璇�</div>
         </template>
-        {{ state.userInfo.operatorIdNumber }}
+        {{ userInfo.operatorIdNumber }}
         <span style="margin-right: auto" @click="showImg('operatorIdCard')">
           <el-link type="primary" underline>鏌ョ湅韬唤璇�</el-link>
         </span>
@@ -448,22 +507,30 @@
         <template #label>
           <div class="cell-item">鑱旂郴鐢佃瘽</div>
         </template>
-        {{ state.userInfo.operatorPhone }}
+        {{ userInfo.operatorPhone }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">寮�鎴烽摱琛�</div>
         </template>
-        {{ state.userInfo.bankName }}
+        {{ userInfo.bankName }}
       </el-descriptions-item>
       <el-descriptions-item>
         <template #label>
           <div class="cell-item">閾惰璐﹀彿</div>
         </template>
-        {{ state.userInfo.bankAccount }}
+        {{ userInfo.bankAccount }}
+      </el-descriptions-item>
+      <el-descriptions-item>
+        <template #label>
+          <div class="cell-item">閾惰鏀舵浜岀淮鐮�</div>
+        </template>
+        <span style="margin-right: auto" @click="showImg('bankAccountIMG')">
+          <el-link type="primary" underline>鏌ョ湅浜岀淮鐮�</el-link>
+        </span>
       </el-descriptions-item>
     </el-descriptions>
-    <div class="m-5">
+    <div v-if="isManager" class="m-5">
       <el-button type="primary" :icon="Edit" @click="() => (showDialog = true)"
         >淇敼璧勬枡</el-button
       >
@@ -539,8 +606,8 @@
                   <img
                     v-if="state.ruleForm.businessLicense"
                     :src="state.ruleForm.businessLicense"
-                    width="200px"
-                    height="150px"
+                    width="80px"
+                    height="50px"
                   />
                   <el-button v-else type="primary">涓婁紶</el-button>
                 </el-upload>
@@ -635,7 +702,43 @@
                 />
               </el-form-item>
             </el-col>
+            <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
+              <el-form-item label="寮�鎴疯" prop="bankName">
+                <el-input
+                  v-model="state.ruleForm.bankName"
+                  placeholder="璇疯緭鍏�"
+                />
+              </el-form-item>
+            </el-col>
+            <el-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
+              <el-form-item label="閾惰璐﹀彿" prop="bankAccount">
+                <el-input
+                  v-model="state.ruleForm.bankAccount"
+                  placeholder="璇疯緭鍏�"
+                />
+              </el-form-item>
+            </el-col>
+            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <el-form-item label="寮�鎴疯鏀舵浜岀淮鐮�" prop="bankAccountIMG">
+                <el-upload
+                  :action="`${baseUrlApi('/api/upFile/file')}`"
+                  :show-file-list="false"
+                  :on-success="handlebankAccountIMG"
+                  :before-upload="beforeAvatarUpload"
+                  :headers="state.headers"
+                >
+                  <img
+                    v-if="state.ruleForm.bankAccountIMG"
+                    :src="state.ruleForm.bankAccountIMG"
+                    width="85.6px"
+                    height="5.4px"
+                  />
+                  <el-button v-else type="primary">涓婁紶</el-button>
+                </el-upload>
+              </el-form-item>
+            </el-col>
           </el-row>
+
           <el-row>
             <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
               <el-form-item label="娉曞畾浠h〃浜�" prop="legalRepresentativeIdCard">
@@ -733,22 +836,6 @@
                 />
               </el-form-item>
             </el-col>
-            <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
-              <el-form-item label="寮�鎴疯" prop="bankName">
-                <el-input
-                  v-model="state.ruleForm.bankName"
-                  placeholder="璇疯緭鍏�"
-                />
-              </el-form-item>
-            </el-col>
-            <el-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
-              <el-form-item label="閾惰璐﹀彿" prop="bankAccount">
-                <el-input
-                  v-model="state.ruleForm.bankAccount"
-                  placeholder="璇疯緭鍏�"
-                />
-              </el-form-item>
-            </el-col>
           </el-row>
         </el-form>
       </div>
@@ -761,6 +848,12 @@
         </span>
       </template>
     </el-dialog>
+    <el-image-viewer
+      v-if="showPreview"
+      :url-list="state.srcList"
+      show-progress
+      @close="showPreview = false"
+    />
   </div>
 </template>
 

--
Gitblit v1.9.1