From 82e77f2e73e262776748b94f1978c2aafaf724e8 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期五, 31 十月 2025 09:21:13 +0800
Subject: [PATCH] feat: 1.3
---
src/views/CustomerManage/components/AddOrEditCustomerView.vue | 486 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 473 insertions(+), 13 deletions(-)
diff --git a/src/views/CustomerManage/components/AddOrEditCustomerView.vue b/src/views/CustomerManage/components/AddOrEditCustomerView.vue
index 76fbab5..f667e9f 100644
--- a/src/views/CustomerManage/components/AddOrEditCustomerView.vue
+++ b/src/views/CustomerManage/components/AddOrEditCustomerView.vue
@@ -1,10 +1,261 @@
<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"
+ :check-rules="[
+ {
+ type: 'array',
+ message: '璇烽�夋嫨鎵�鍦ㄥ湴鍖�',
+ },
+ ]"
+ >
+ <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>
+ </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">
+ <div class="password-input">
+ <ProFormText
+ v-if="!isEdit"
+ v-model.trim="form.operatorPassword"
+ :maxlength="30"
+ placeholder="璇疯緭鍏ユ搷浣滃瘑鐮�"
+ />
+ <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 +263,245 @@
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 * as userServices from '@/services/api/user';
+import { useRouteView, useGlobalEventContext } from '@/hooks';
+import _ from 'lodash';
+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',
-})
+});
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: '',
+});
+
+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;
+ },
+ 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>();
+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,
+ };
+ 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