From 50e7cf712afd1f06ae3199f9dbd54623870a0088 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期五, 31 十月 2025 17:18:12 +0800
Subject: [PATCH] fix: bug

---
 src/views/CustomerManage/components/AddOrEditCustomerView.vue |  289 ++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 213 insertions(+), 76 deletions(-)

diff --git a/src/views/CustomerManage/components/AddOrEditCustomerView.vue b/src/views/CustomerManage/components/AddOrEditCustomerView.vue
index 8377969..92bdfbf 100644
--- a/src/views/CustomerManage/components/AddOrEditCustomerView.vue
+++ b/src/views/CustomerManage/components/AddOrEditCustomerView.vue
@@ -50,87 +50,54 @@
               </ProFormItemV2>
             </ProFormColItem>
             <ProFormColItem :span="8">
-              <ProFormItemV2
-                label="娉ㄥ唽璧勬湰:"
-                prop="societyCreditCode"
-                :check-rules="[{ message: '璇疯緭鍏ユ敞鍐岃祫鏈�', type: 'societyCreditCode' }]"
-              >
-                <ProFormText v-model.trim="form.societyCreditCode" placeholder="璇疯緭鍏ユ敞鍐岃祫鏈�" />
+              <ProFormItemV2 label="娉ㄥ唽璧勬湰:" prop="registeredCapital">
+                <ProFormText v-model.trim="form.registeredCapital" placeholder="璇疯緭鍏ユ敞鍐岃祫鏈�" />
               </ProFormItemV2>
             </ProFormColItem>
             <ProFormColItem :span="8">
-              <ProFormItemV2
-                label="浼佷笟绫诲瀷:"
-                prop="societyCreditCode"
-                :check-rules="[{ message: '璇疯緭鍏ヤ紒涓氱被鍨�', type: 'societyCreditCode' }]"
-              >
-                <ProFormText v-model.trim="form.societyCreditCode" placeholder="璇疯緭鍏ヤ紒涓氱被鍨�" />
+              <ProFormItemV2 label="浼佷笟绫诲瀷:" prop="enterpriseType">
+                <ProFormText v-model.trim="form.enterpriseType" placeholder="璇疯緭鍏ヤ紒涓氱被鍨�" />
               </ProFormItemV2>
             </ProFormColItem>
           </ProFormCol>
           <ProFormCol>
             <ProFormColItem :span="8">
-              <ProFormItemV2
-                label="鎴愮珛鏃ユ湡:"
-                prop="date"
-                :check-rules="[{ message: '璇烽�夋嫨鎴愮珛鏃ユ湡' }]"
-              >
-                <ProFormDatePicker v-model="form.date" type="date" placeholder="璇烽�夋嫨鎴愮珛鏃ユ湡" />
-              </ProFormItemV2>
-            </ProFormColItem>
-            <ProFormColItem :span="8">
-              <ProFormItemV2
-                label="鎵�鍦ㄧ渷浠�:"
-                prop="areaList"
-                :check-rules="[
-                  {
-                    type: 'array',
-                    message: '璇烽�夋嫨',
-                  },
-                ]"
-              >
-                <ProFromAddressSelectV2
-                  v-model:areaList="form.areaList"
-                  areaListPlaceholder="璇烽�夋嫨"
-                  :layer="AreaType.City"
+              <ProFormItemV2 label="鎴愮珛鏃ユ湡:" prop="establishmentDate">
+                <ProFormDatePicker
+                  v-model="form.establishmentDate"
+                  type="date"
+                  placeholder="璇烽�夋嫨鎴愮珛鏃ユ湡"
                 />
               </ProFormItemV2>
             </ProFormColItem>
             <ProFormColItem :span="8">
               <ProFormItemV2
-                label="鎵�鍦ㄥ煄甯�:"
+                label="鎵�鍦ㄥ湴鍖�:"
                 prop="areaList"
                 :check-rules="[
                   {
                     type: 'array',
-                    message: '璇烽�夋嫨',
+                    message: '璇烽�夋嫨鎵�鍦ㄥ湴鍖�',
                   },
                 ]"
               >
                 <ProFromAddressSelectV2
                   v-model:areaList="form.areaList"
-                  areaListPlaceholder="璇烽�夋嫨"
+                  areaListPlaceholder="璇烽�夋嫨鎵�鍦ㄥ湴鍖�"
                   :layer="AreaType.City"
                 />
               </ProFormItemV2>
             </ProFormColItem>
+            <ProFormColItem :span="8"> </ProFormColItem>
           </ProFormCol>
           <ProFormCol>
             <ProFormColItem :span="8">
-              <ProFormItemV2
-                label="璇︾粏鍦板潃:"
-                prop="societyCreditCode"
-                :check-rules="[{ message: '璇疯緭鍏ヨ缁嗗湴鍧�' }]"
-              >
-                <ProFormText v-model.trim="form.societyCreditCode" placeholder="璇疯緭鍏ヨ缁嗗湴鍧�" />
+              <ProFormItemV2 label="璇︾粏鍦板潃:" prop="address">
+                <ProFormText v-model.trim="form.address" placeholder="璇疯緭鍏ヨ缁嗗湴鍧�" />
               </ProFormItemV2>
             </ProFormColItem>
           </ProFormCol>
-          <ProFormItemV2
-            label="缁忚惀鑼冨洿:"
-            prop="mainBusiness"
-            :check-rules="[{ message: '璇疯緭鍏ョ粡钀ヨ寖鍥�' }]"
-          >
+          <ProFormItemV2 label="缁忚惀鑼冨洿:" prop="mainBusiness">
             <ProFormTextArea
               v-model="form.mainBusiness"
               maxlength="200"
@@ -185,13 +152,30 @@
           </ProFormCol>
           <ProFormCol>
             <ProFormColItem :span="8">
-              <ProFormItemV2 label="鍚堜綔鐘舵��:" prop="contacts"> </ProFormItemV2>
+              <ProFormItemV2 label="鍚堜綔鐘舵��:" prop="cooperationStatus">
+                <ProFormRadio
+                  v-model="form.cooperationStatus"
+                  :value-enum="EnumEnterpriseCooperationStatusText"
+                />
+              </ProFormItemV2>
             </ProFormColItem>
             <ProFormColItem :span="8">
-              <ProFormItemV2 label="绛剧害鐘舵��:" prop="contacts"> </ProFormItemV2>
+              <ProFormItemV2 label="绛剧害鐘舵��:" prop="signStatus">
+                <ProFormRadio
+                  v-model="form.signStatus"
+                  :value-enum="EnumEnterpriseCooperationSignStatusText"
+                />
+              </ProFormItemV2>
             </ProFormColItem>
             <ProFormColItem :span="8">
-              <ProFormItemV2 label="鍚堜綔鍗忚:" prop="contacts"> </ProFormItemV2>
+              <ProFormItemV2 label="鍚堜綔鍗忚:" prop="cooperationAgreementUrl">
+                <ProFormUpload
+                  v-model:file-url="form.cooperationAgreementUrl"
+                  :limit="1"
+                  :limitFileSize="10"
+                  accept="jpg/jpeg,png,pdf"
+                ></ProFormUpload>
+              </ProFormItemV2>
             </ProFormColItem>
           </ProFormCol>
         </ProForm>
@@ -218,17 +202,52 @@
                 />
               </ProFormItemV2>
             </ProFormColItem>
-            <ProFormColItem :span="8" v-if="!isEdit">
+          </ProFormCol>
+          <ProFormCol v-if="!isDetail">
+            <ProFormColItem :span="8">
               <ProFormItemV2
                 label="瀵嗙爜:"
                 prop="password"
-                :check-rules="[{ message: '璇疯緭鍏ュ瘑鐮�' }]"
+                :check-rules="[{ required: !isEdit, message: '璇疯緭鍏ュ瘑鐮�' }]"
               >
-                <ProFormText
-                  v-model.trim="form.password"
-                  :maxlength="30"
-                  placeholder="璇疯緭鍏ュ瘑鐮�"
-                />
+                <div class="password-input">
+                  <ProFormText
+                    v-if="!isEdit"
+                    v-model.trim="form.password"
+                    :maxlength="30"
+                    placeholder="璇疯緭鍏ュ瘑鐮�"
+                  />
+                  <el-button v-else type="primary" link @click="openResetPasswordDialog"
+                    >淇敼瀵嗙爜</el-button
+                  >
+                </div>
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol v-if="!isDetail">
+            <ProFormColItem :span="8">
+              <ProFormItemV2
+                label="鎿嶄綔瀵嗙爜:"
+                prop="operatorPassword"
+                :check-rules="[
+                  {
+                    required: false,
+                    message: '璇疯緭鍏�6浣嶆暟瀛�',
+                    pattern: /\b\d{6}\b/,
+                  },
+                ]"
+              >
+                <div class="password-input">
+                  <ProFormText
+                    v-if="!isEdit"
+                    v-model.trim="form.operatorPassword"
+                    :maxlength="6"
+                    placeholder="璇疯緭鍏ユ搷浣滃瘑鐮�(6浣嶆暟瀛�)"
+                  />
+                  <el-button type="primary" v-else link @click="openResetOperatorPasswordDialog"
+                    >淇敼瀵嗙爜</el-button
+                  >
+                </div>
               </ProFormItemV2>
             </ProFormColItem>
           </ProFormCol>
@@ -239,6 +258,10 @@
         </ProForm>
       </ChunkCell>
     </AppScrollContainer>
+    <ResetPasswordDialog v-bind="resetPasswordDialogProps"></ResetPasswordDialog>
+    <ResetOperatorPasswordDialog
+      v-bind="resetOperatorPasswordDialogProps"
+    ></ResetOperatorPasswordDialog>
   </LoadingLayout>
 </template>
 
@@ -250,20 +273,36 @@
   ProFormItemV2,
   ChunkCell,
   ProFormText,
-  ProFormSelect,
+  ProFormUpload,
   ProFormTextArea,
   ProFormCol,
   ProFormColItem,
   ProFormDatePicker,
+  ProFormRadio,
+  UploadUserFile,
+  useFormDialog,
 } from '@bole-core/components';
-import { FormRules, FormInstance } from 'element-plus';
+import { FormInstance } from 'element-plus';
 import * as enterpriseServices from '@/services/api/enterprise';
-import { useRouteView, useGlobalEventContext, GlobalEvent } from '@/hooks';
+import * as userServices from '@/services/api/user';
+import { useRouteView, useGlobalEventContext } from '@/hooks';
 import _ from 'lodash';
-import { validateFormList, filterCN, removeEmptyKeys } from '@/utils';
-import { Message, BoleRegExp } from '@bole-core/core';
+import {
+  EnumEnterpriseCooperationStatusText,
+  EnumEnterpriseCooperationSignStatusText,
+} from '@/constants';
+import {
+  validateFormList,
+  filterCN,
+  removeEmptyKeys,
+  format,
+  convertApi2FormUrlOnlyOne,
+} from '@/utils';
+import { Message } from '@bole-core/core';
 import { useQuery } from '@tanstack/vue-query';
 import { AreaType } from '@/constants';
+import ResetPasswordDialog from './ResetPasswordDialog.vue';
+import ResetOperatorPasswordDialog from './ResetOperatorPasswordDialog.vue';
 
 defineOptions({
   name: 'AddOrEditCustomerView',
@@ -288,21 +327,29 @@
   legalPerson: '',
   legalIdentity: '',
   societyCreditCode: '',
-  industryTypeCode: '',
-  mainBusiness: '',
+  registeredCapital: '',
+  enterpriseType: '',
+  establishmentDate: '',
   areaList: [] as string[],
+  address: '',
+  mainBusiness: '',
   contacts: '',
   contactPhoneNumber: '',
   contactEmail: '',
+  cooperationStatus: EnumEnterpriseCooperationStatus.None,
+  signStatus: EnumEnterpriseCooperationSignStatus.None,
+  cooperationAgreementUrl: [] as UploadUserFile[],
   userName: '',
   password: '',
-  date: '',
+  operatorPassword: '',
+
+  userId: '',
 });
 
-const { isLoading } = useQuery({
-  queryKey: ['enterpriseServices/getEnterprise', id],
+const { isLoading, refetch } = useQuery({
+  queryKey: ['enterpriseServices/getPartyAEnterprise', id],
   queryFn: async () => {
-    return await enterpriseServices.getEnterprise(
+    return await enterpriseServices.getPartyAEnterprise(
       { id: id },
       {
         showLoading: false,
@@ -315,16 +362,90 @@
     form.legalPerson = data.legalPerson;
     form.legalIdentity = data.legalIdentity;
     form.societyCreditCode = data.societyCreditCode;
-    form.industryTypeCode = data.industryTypeCode ?? '';
+    form.registeredCapital = data.registeredCapital;
+    form.enterpriseType = data.enterpriseType;
+    form.establishmentDate = data.establishmentDate;
+    form.areaList = [data.provinceCode, data.cityCode].filter(Boolean);
+    form.address = data.address;
     form.mainBusiness = data.mainBusiness;
     form.contacts = data.contacts;
     form.contactPhoneNumber = data.contactPhoneNumber;
     form.contactEmail = data.contactEmail;
+    form.cooperationStatus = data.cooperationStatus;
+    form.signStatus = data.signStatus;
+    form.cooperationAgreementUrl = convertApi2FormUrlOnlyOne(data.cooperationAgreementUrl);
     form.userName = data.userName;
-    form.areaList = [data.provinceCode, data.cityCode].filter(Boolean);
+
+    form.userId = data.userId;
   },
   enabled: computed(() => !!id),
 });
+
+const {
+  dialogProps: resetPasswordDialogProps,
+  handleAdd: handleResetPasswordAdd,
+  editForm: resetPasswordEditForm,
+} = useFormDialog({
+  onConfirm: resetPassword,
+  defaultFormParams: {
+    ids: '',
+    password: '',
+  },
+});
+
+function openResetPasswordDialog() {
+  handleResetPasswordAdd({
+    ids: form.userId,
+    password: '',
+  });
+}
+
+async function resetPassword() {
+  try {
+    let params: API.ResetUserPasswordsCommand = {
+      ids: [resetPasswordEditForm.ids],
+      password: resetPasswordEditForm.password,
+    };
+    let res = await userServices.resetUserPasswords(params);
+    if (res) {
+      Message.successMessage('鎿嶄綔鎴愬姛');
+      refetch();
+    }
+  } catch (error) {}
+}
+
+const {
+  dialogProps: resetOperatorPasswordDialogProps,
+  handleAdd: handleResetOperatorPasswordAdd,
+  editForm: resetOperatorPasswordEditForm,
+} = useFormDialog({
+  onConfirm: resetOperatorPassword,
+  defaultFormParams: {
+    ids: '',
+    operatorPassword: '',
+  },
+});
+
+function openResetOperatorPasswordDialog() {
+  handleResetOperatorPasswordAdd({
+    ids: form.userId,
+    operatorPassword: '',
+  });
+}
+
+async function resetOperatorPassword() {
+  try {
+    let params: API.ResetUserOperatorPasswordsCommand = {
+      ids: [resetOperatorPasswordEditForm.ids],
+      operatorPassword: resetOperatorPasswordEditForm.operatorPassword,
+    };
+    let res = await userServices.resetUserOperatorPasswords(params);
+    if (res) {
+      Message.successMessage('鎿嶄綔鎴愬姛');
+      refetch();
+    }
+  } catch (error) {}
+}
 
 const formRef = ref<FormInstance>();
 const settingFormRef = ref<FormInstance>();
@@ -345,25 +466,32 @@
 
 async function handleCreateOrEditFlexEnterprise() {
   try {
-    let params: API.SaveEnterpriseCommand = {
+    let params: API.SavePartyAEnterpriseCommand = {
       enterpriseName: form.enterpriseName,
       legalPerson: form.legalPerson,
       legalIdentity: form.legalIdentity,
       societyCreditCode: form.societyCreditCode,
+      registeredCapital: form.registeredCapital,
+      enterpriseType: form.enterpriseType,
+      establishmentDate: format(form.establishmentDate, 'YYYY-MM-DD'),
       provinceCode: form.areaList[0],
       cityCode: form.areaList[1],
-      industryTypeCode: form.industryTypeCode,
+      address: form.address,
       mainBusiness: form.mainBusiness,
       contacts: form.contacts,
       contactPhoneNumber: form.contactPhoneNumber,
       contactEmail: form.contactEmail,
+      cooperationStatus: form.cooperationStatus,
+      signStatus: form.signStatus,
+      cooperationAgreementUrl: form.cooperationAgreementUrl[0]?.path,
       userName: form.userName,
       password: form.password,
+      operatorPassword: form.operatorPassword,
     };
     if (isEdit) {
       params.id = id;
     }
-    let res = await enterpriseServices.saveEnterprise(removeEmptyKeys(params));
+    let res = await enterpriseServices.savePartyAEnterprise(removeEmptyKeys(params));
     if (res) {
       Message.successMessage(isEdit ? '缂栬緫鎴愬姛' : '鍙戝竷鎴愬姛');
       eventContext.emit(isEdit ? 'customerManage:edit' : 'customerManage:add');
@@ -374,7 +502,16 @@
 
 function handleBack() {
   closeViewPush(route, {
-    name: 'EnterpriseManageList',
+    name: 'CustomerManage',
   });
 }
 </script>
+<style lang="scss" scoped>
+@use '@/style/common.scss' as *;
+
+.password-input {
+  display: flex;
+  flex: 1;
+  min-width: 0;
+}
+</style>

--
Gitblit v1.9.1