From 07af1dc2df71f77ad8141d2ff9c72eb7dfa244c1 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期五, 28 十一月 2025 14:47:14 +0800
Subject: [PATCH] fix: s

---
 src/views/CustomerManage/components/AddOrEditCustomerView.vue |  560 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 547 insertions(+), 13 deletions(-)

diff --git a/src/views/CustomerManage/components/AddOrEditCustomerView.vue b/src/views/CustomerManage/components/AddOrEditCustomerView.vue
index 76fbab5..578f245 100644
--- a/src/views/CustomerManage/components/AddOrEditCustomerView.vue
+++ b/src/views/CustomerManage/components/AddOrEditCustomerView.vue
@@ -1,10 +1,309 @@
 <template>
-  <div></div>
+  <LoadingLayout :loading="isEdit && isLoading">
+    <AppScrollContainer>
+      <ChunkCell title="浼佷笟鍩烘湰淇℃伅">
+        <ProForm :model="form" ref="formRef" label-width="140px" :is-read="isDetail">
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2
+                label="浼佷笟鍚嶇О:"
+                prop="enterpriseName"
+                :check-rules="[{ message: '璇疯緭鍏ヤ紒涓氬悕绉�' }]"
+              >
+                <ProFormText
+                  v-model.trim="form.enterpriseName"
+                  :maxlength="30"
+                  placeholder="璇疯緭鍏ヤ紒涓氬悕绉�"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="娉曚汉濮撳悕:" prop="legalPerson">
+                <ProFormText
+                  v-model.trim="form.legalPerson"
+                  :maxlength="30"
+                  placeholder="璇疯緭鍏ユ硶浜哄鍚�"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="娉曚汉韬唤璇佸彿:" prop="legalIdentity">
+                <ProFormText
+                  v-model.trim="form.legalIdentity"
+                  :maxlength="30"
+                  placeholder="璇疯緭鍏ユ硶浜鸿韩浠借瘉鍙�"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2
+                label="缁熶竴绀句細淇$敤浠g爜:"
+                prop="societyCreditCode"
+                :check-rules="[{ message: '璇疯緭鍏ョ粺涓�绀句細淇$敤浠g爜', type: 'societyCreditCode' }]"
+              >
+                <ProFormText
+                  v-model.trim="form.societyCreditCode"
+                  placeholder="璇疯緭鍏ョ粺涓�绀句細淇$敤浠g爜"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="娉ㄥ唽璧勬湰:" prop="registeredCapital">
+                <ProFormText v-model.trim="form.registeredCapital" placeholder="璇疯緭鍏ユ敞鍐岃祫鏈�" />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="浼佷笟绫诲瀷:" prop="enterpriseType">
+                <ProFormText v-model.trim="form.enterpriseType" placeholder="璇疯緭鍏ヤ紒涓氱被鍨�" />
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="鎴愮珛鏃ユ湡:" prop="establishmentDate">
+                <ProFormDatePicker
+                  v-model="form.establishmentDate"
+                  type="date"
+                  placeholder="璇烽�夋嫨鎴愮珛鏃ユ湡"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="鎵�鍦ㄥ湴鍖�:" prop="areaList">
+                <ProFromAddressSelectV2
+                  v-model:areaList="form.areaList"
+                  areaListPlaceholder="璇烽�夋嫨鎵�鍦ㄥ湴鍖�"
+                  :layer="AreaType.City"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8"> </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="璇︾粏鍦板潃:" prop="address">
+                <ProFormText v-model.trim="form.address" placeholder="璇疯緭鍏ヨ缁嗗湴鍧�" />
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormItemV2 label="缁忚惀鑼冨洿:" prop="mainBusiness">
+            <ProFormTextArea
+              v-model="form.mainBusiness"
+              maxlength="200"
+              :rows="6"
+              show-word-limit
+              placeholder="璇疯緭鍏ョ粡钀ヨ寖鍥�"
+            />
+          </ProFormItemV2>
+        </ProForm>
+      </ChunkCell>
+      <ChunkCell title="鍚堜綔淇℃伅">
+        <ProForm
+          :model="form"
+          ref="settingFormRef"
+          label-width="140px"
+          :scroll-to-error="false"
+          :is-read="isDetail"
+        >
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2
+                label="鑱旂郴浜�:"
+                prop="contacts"
+                :check-rules="[{ message: '璇疯緭鍏ヨ仈绯讳汉' }]"
+              >
+                <ProFormText
+                  v-model.trim="form.contacts"
+                  :maxlength="30"
+                  placeholder="璇疯緭鍏ヨ仈绯讳汉"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2
+                label="鑱旂郴鐢佃瘽:"
+                prop="contactPhoneNumber"
+                :check-rules="[{ message: '璇疯緭鍏ヨ仈绯荤數璇�', type: 'phone' }]"
+              >
+                <ProFormText v-model.trim="form.contactPhoneNumber" placeholder="璇疯緭鍏ヨ仈绯荤數璇�" />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="鑱旂郴閭:" prop="contactEmail">
+                <ProFormText
+                  v-model.trim="form.contactEmail"
+                  :maxlength="30"
+                  placeholder="璇疯緭鍏ヨ仈绯婚偖绠�"
+                  :formatter="filterCN"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="鍚堜綔鐘舵��:" prop="cooperationStatus">
+                <ProFormRadio
+                  v-model="form.cooperationStatus"
+                  :value-enum="EnumEnterpriseCooperationStatusText"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="绛剧害鐘舵��:" prop="signStatus">
+                <ProFormRadio
+                  v-model="form.signStatus"
+                  :value-enum="EnumEnterpriseCooperationSignStatusText"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="鍚堜綔鍗忚:" prop="cooperationAgreementUrl">
+                <ProFormUpload
+                  v-model:file-url="form.cooperationAgreementUrl"
+                  :limit="1"
+                  :limitFileSize="10"
+                  accept="jpg/jpeg,png,pdf"
+                ></ProFormUpload>
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="鏈嶅姟璐规敹鍙栨柟寮�:" prop="serviceFeeCollectType">
+                <ProFormSelect
+                  v-model="form.serviceFeeCollectType"
+                  :valueEnum="EnumEnterpriseCooperationServiceFeeCollectTypeText"
+                  placeholder="璇烽�夋嫨鏈嶅姟璐规敹鍙栨柟寮�"
+                >
+                </ProFormSelect>
+              </ProFormItemV2>
+            </ProFormColItem>
+            <ProFormColItem :span="8">
+              <ProFormItemV2
+                label="鏈嶅姟璐�:"
+                prop="serviceFeeRate"
+                :check-rules="
+                  form.serviceFeeCollectType ? [{ message: '璇疯緭鍏ユ湇鍔¤垂' }] : undefined
+                "
+                :required="!!form.serviceFeeCollectType"
+              >
+                <ProFormInputNumber
+                  v-model="form.serviceFeeRate"
+                  :controls="false"
+                  :min="0"
+                  :precision="2"
+                  placeholder="璇疯緭鍏�"
+                  :unit="serviceFeeCollectTypeUnit"
+                  :showReadContent="!!form.serviceFeeRate"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2 label="鍙戠エ绋庣偣:" prop="invoiceTaxPointRate">
+                <ProFormInputNumber
+                  v-model="form.invoiceTaxPointRate"
+                  :controls="false"
+                  :min="0"
+                  :precision="2"
+                  placeholder="璇疯緭鍏�"
+                  unit="%"
+                  :showReadContent="!!form.invoiceTaxPointRate"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+        </ProForm>
+      </ChunkCell>
+      <ChunkCell title="璐﹀彿淇℃伅">
+        <ProForm
+          :model="form"
+          ref="accountFormRef"
+          label-width="140px"
+          :scroll-to-error="false"
+          :is-read="isDetail"
+        >
+          <ProFormCol>
+            <ProFormColItem :span="8">
+              <ProFormItemV2
+                label="璐﹀彿:"
+                prop="userName"
+                :check-rules="[{ message: '璇疯緭鍏ヨ处鍙�' }]"
+              >
+                <ProFormText
+                  v-model.trim="form.userName"
+                  :maxlength="30"
+                  placeholder="璇疯緭鍏ヨ处鍙�"
+                />
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol v-if="!isDetail">
+            <ProFormColItem :span="8">
+              <ProFormItemV2
+                label="瀵嗙爜:"
+                prop="password"
+                :check-rules="[{ required: !isEdit, message: '璇疯緭鍏ュ瘑鐮�' }]"
+              >
+                <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>
+          <div class="chuck-add-or-edit-actions">
+            <el-button @click="handleBack">杩斿洖</el-button>
+            <el-button v-if="!isDetail" type="primary" @click="handleSubmit">纭</el-button>
+          </div>
+        </ProForm>
+      </ChunkCell>
+    </AppScrollContainer>
+    <ResetPasswordDialog v-bind="resetPasswordDialogProps"></ResetPasswordDialog>
+    <ResetOperatorPasswordDialog
+      v-bind="resetOperatorPasswordDialogProps"
+    ></ResetOperatorPasswordDialog>
+  </LoadingLayout>
 </template>
 
 <script setup lang="ts">
-import { Message, BoleRegExp } from '@bole-core/core';
-import { useQuery } from '@tanstack/vue-query';
 import {
   LoadingLayout,
   AppScrollContainer,
@@ -12,36 +311,271 @@
   ProFormItemV2,
   ChunkCell,
   ProFormText,
-  ProFormSelect,
+  ProFormUpload,
   ProFormTextArea,
   ProFormCol,
   ProFormColItem,
+  ProFormDatePicker,
+  ProFormRadio,
+  UploadUserFile,
+  useFormDialog,
+  ProFormSelect,
+  ProFormInputNumber,
 } from '@bole-core/components';
-import { FormRules, FormInstance } from 'element-plus';
+import { FormInstance } from 'element-plus';
+import * as enterpriseServices from '@/services/api/enterprise';
+import * as userServices from '@/services/api/user';
+import { useRouteView, useGlobalEventContext } from '@/hooks';
+import _ from 'lodash';
+import {
+  EnumEnterpriseCooperationStatusText,
+  EnumEnterpriseCooperationSignStatusText,
+  EnumEnterpriseCooperationServiceFeeCollectTypeText,
+  EnumEnterpriseCooperationServiceFeeCollectType,
+} 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',
-})
+});
 
 type Props = {
   isDetail: boolean;
-}
+};
 
-const props = withDefaults(defineProps<Props>(), {
-
-})
+const props = withDefaults(defineProps<Props>(), {});
 
 const route = useRoute();
 const id = route.params.id as string;
-const isEdit =  !!id;
+const isEdit = !!id;
 
 const { closeViewPush } = useRouteView();
 const eventContext = useGlobalEventContext();
 
-</script>
+const form = reactive({
+  id: '',
+  enterpriseName: '',
+  legalPerson: '',
+  legalIdentity: '',
+  societyCreditCode: '',
+  registeredCapital: '',
+  enterpriseType: '',
+  establishmentDate: '',
+  areaList: [] as string[],
+  address: '',
+  mainBusiness: '',
+  contacts: '',
+  contactPhoneNumber: '',
+  contactEmail: '',
+  cooperationStatus: EnumEnterpriseCooperationStatus.None,
+  signStatus: EnumEnterpriseCooperationSignStatus.None,
+  cooperationAgreementUrl: [] as UploadUserFile[],
+  userName: '',
+  password: '',
+  operatorPassword: '',
 
+  userId: '',
+
+  serviceFeeCollectType: '' as any as EnumEnterpriseCooperationServiceFeeCollectType,
+  serviceFeeRate: null as any as number,
+  invoiceTaxPointRate: null as any as number,
+});
+
+const { isLoading, refetch } = useQuery({
+  queryKey: ['enterpriseServices/getPartyAEnterprise', id],
+  queryFn: async () => {
+    return await enterpriseServices.getPartyAEnterprise(
+      { id: id },
+      {
+        showLoading: false,
+      }
+    );
+  },
+  onSuccess(data) {
+    form.id = data.id;
+    form.enterpriseName = data.enterpriseName;
+    form.legalPerson = data.legalPerson;
+    form.legalIdentity = data.legalIdentity;
+    form.societyCreditCode = data.societyCreditCode;
+    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.userId = data.userId;
+    form.serviceFeeCollectType = data.serviceFeeCollectType;
+    form.serviceFeeRate = data.serviceFeeRate;
+    form.invoiceTaxPointRate = data.invoiceTaxPointRate;
+  },
+  enabled: computed(() => !!id),
+});
+
+const serviceFeeCollectTypeUnit = computed(() => {
+  if (!form.serviceFeeCollectType) {
+    return '';
+  } else {
+    return form.serviceFeeCollectType === EnumEnterpriseCooperationServiceFeeCollectType.Rate
+      ? '%'
+      : '鍏�/浜�';
+  }
+});
+
+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>();
+const accountFormRef = ref<FormInstance>();
+
+async function handleSubmit() {
+  try {
+    const valid = await validateFormList([
+      formRef.value,
+      settingFormRef.value,
+      accountFormRef.value,
+    ]);
+    if (valid) {
+      handleCreateOrEditFlexEnterprise();
+    }
+  } catch (error) {}
+}
+
+async function handleCreateOrEditFlexEnterprise() {
+  try {
+    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],
+      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,
+      serviceFeeCollectType: form.serviceFeeCollectType,
+      invoiceTaxPointRate: form.invoiceTaxPointRate,
+    };
+    if (form.serviceFeeCollectType === EnumEnterpriseCooperationServiceFeeCollectType.Rate) {
+      params.serviceFeeRate = form.serviceFeeRate;
+    }
+    if (isEdit) {
+      params.id = id;
+    }
+    let res = await enterpriseServices.savePartyAEnterprise(removeEmptyKeys(params));
+    if (res) {
+      Message.successMessage(isEdit ? '缂栬緫鎴愬姛' : '鍙戝竷鎴愬姛');
+      eventContext.emit(isEdit ? 'customerManage:edit' : 'customerManage:add');
+      handleBack();
+    }
+  } catch (error) {}
+}
+
+function handleBack() {
+  closeViewPush(route, {
+    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