From cb530d0be7fed472d3ec97dc8e8494f69ad1921c Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期二, 21 十月 2025 10:28:21 +0800
Subject: [PATCH] fix: saveContractTemplateValues
---
src/views/EnterpriseManage/components/AddOrEditEnterpriseView.vue | 244 +++++++++++++++++++++++++++---------------------
1 files changed, 136 insertions(+), 108 deletions(-)
diff --git a/src/views/EnterpriseManage/components/AddOrEditEnterpriseView.vue b/src/views/EnterpriseManage/components/AddOrEditEnterpriseView.vue
index bdc92b9..d69605a 100644
--- a/src/views/EnterpriseManage/components/AddOrEditEnterpriseView.vue
+++ b/src/views/EnterpriseManage/components/AddOrEditEnterpriseView.vue
@@ -2,34 +2,34 @@
<LoadingLayout :loading="isEdit && isLoading">
<AppScrollContainer>
<ChunkCell title="浼佷笟鍩烘湰淇℃伅">
- <ProForm :model="form" :rules="rules" ref="formRef" label-width="120px" :is-read="isDetail">
+ <ProForm :model="form" ref="formRef" label-width="140px" :is-read="isDetail">
<ProFormCol>
- <ProFormColItem :span="12">
- <ProFormItemV2 label="浼佷笟鍚嶇О:" prop="enterpriseName">
+ <ProFormColItem :span="8">
+ <ProFormItemV2
+ label="浼佷笟鍚嶇О:"
+ prop="enterpriseName"
+ :check-rules="[{ message: '璇疯緭鍏ヤ紒涓氬悕绉�' }]"
+ >
<ProFormText
v-model.trim="form.enterpriseName"
:maxlength="30"
- placeholder="璇疯緭鍏ヤ緵搴斿晢鍚嶇О"
+ placeholder="璇疯緭鍏ヤ紒涓氬悕绉�"
/>
</ProFormItemV2>
</ProFormColItem>
- </ProFormCol>
- <ProFormCol>
- <ProFormColItem :span="12">
- <ProFormItemV2 label="娉曚汉濮撳悕:" prop="legalPersonName">
+ <ProFormColItem :span="8">
+ <ProFormItemV2 label="娉曚汉濮撳悕:" prop="legalPerson">
<ProFormText
- v-model.trim="form.legalPersonName"
+ v-model.trim="form.legalPerson"
:maxlength="30"
placeholder="璇疯緭鍏ユ硶浜哄鍚�"
/>
</ProFormItemV2>
</ProFormColItem>
- </ProFormCol>
- <ProFormCol>
- <ProFormColItem :span="12">
- <ProFormItemV2 label="娉曚汉韬唤璇佸彿:" prop="legalPersonIdNumber">
+ <ProFormColItem :span="8">
+ <ProFormItemV2 label="娉曚汉韬唤璇佸彿:" prop="legalIdentity">
<ProFormText
- v-model.trim="form.legalPersonIdNumber"
+ v-model.trim="form.legalIdentity"
:maxlength="30"
placeholder="璇疯緭鍏ユ硶浜鸿韩浠借瘉鍙�"
/>
@@ -37,56 +37,52 @@
</ProFormColItem>
</ProFormCol>
<ProFormCol>
- <ProFormColItem :span="12">
- <ProFormItemV2 label="缁熶竴绀句細淇$敤浠g爜:" prop="societyCreditCode">
+ <ProFormColItem :span="8">
+ <ProFormItemV2
+ label="缁熶竴绀句細淇$敤浠g爜:"
+ prop="societyCreditCode"
+ :check-rules="[{ message: '璇疯緭鍏ョ粺涓�绀句細淇$敤浠g爜', type: 'societyCreditCode' }]"
+ >
<ProFormText
v-model.trim="form.societyCreditCode"
placeholder="璇疯緭鍏ョ粺涓�绀句細淇$敤浠g爜"
/>
</ProFormItemV2>
</ProFormColItem>
- </ProFormCol>
- <ProFormCol>
- <ProFormColItem :span="12">
- <ProFormItemV2 label="鎵�鍦ㄧ渷浠�:" prop="proviceName">
- <ProFormText
- v-model.trim="form.proviceName"
- :maxlength="30"
- placeholder="璇疯緭鍏ユ墍鍦ㄧ渷浠�"
+ <ProFormColItem :span="8">
+ <ProFormItemV2
+ label="鎵�鍦ㄥ湴鍖�:"
+ prop="areaList"
+ :check-rules="[
+ {
+ type: 'array',
+ message: '璇烽�夋嫨',
+ },
+ ]"
+ >
+ <ProFromAddressSelectV2
+ v-model:areaList="form.areaList"
+ areaListPlaceholder="璇烽�夋嫨"
+ :layer="AreaType.City"
/>
</ProFormItemV2>
</ProFormColItem>
- </ProFormCol>
- <ProFormCol>
- <ProFormColItem :span="12">
- <ProFormItemV2 label="鎵�灞炶涓�:" prop="belongIndustryType">
+ <ProFormColItem :span="8">
+ <ProFormItemV2 label="鎵�灞炶涓�:" prop="industryTypeCode">
<ProFormSelect
+ v-model="form.industryTypeCode"
placeholder="璇烽�夋嫨鎵�灞炶涓�"
- :value-enum="typeList"
- enum-value-key="id"
- enum-label-key="name"
+ :value-enum="dictionaryDataList"
clearable
- v-model="form.belongIndustryType"
></ProFormSelect>
</ProFormItemV2>
</ProFormColItem>
</ProFormCol>
<ProFormCol>
- <ProFormColItem :span="12">
- <ProFormItemV2 label="鎵�鍦ㄥ煄甯�:" prop="cityName">
- <ProFormText
- v-model.trim="form.cityName"
- :maxlength="30"
- placeholder="璇疯緭鍏ユ墍鍦ㄥ煄甯�"
- />
- </ProFormItemV2>
- </ProFormColItem>
- </ProFormCol>
- <ProFormCol>
<ProFormColItem :span="24">
- <ProFormItemV2 label="涓昏惀涓氬姟:" prop="cityName">
+ <ProFormItemV2 label="涓昏惀涓氬姟:" prop="mainBusiness">
<ProFormTextArea
- v-model="form.cityName"
+ v-model="form.mainBusiness"
maxlength="200"
:rows="6"
show-word-limit
@@ -100,7 +96,6 @@
<ChunkCell title="鑱旂郴淇℃伅">
<ProForm
:model="form"
- :rules="rules"
ref="settingFormRef"
label-width="140px"
:scroll-to-error="false"
@@ -108,9 +103,13 @@
>
<ProFormCol>
<ProFormColItem :span="12">
- <ProFormItemV2 label="鑱旂郴浜�:" prop="contact">
+ <ProFormItemV2
+ label="鑱旂郴浜�:"
+ prop="contacts"
+ :check-rules="[{ message: '璇疯緭鍏ヨ仈绯讳汉' }]"
+ >
<ProFormText
- v-model.trim="form.contact"
+ v-model.trim="form.contacts"
:maxlength="30"
placeholder="璇疯緭鍏ヨ仈绯讳汉"
/>
@@ -119,16 +118,20 @@
</ProFormCol>
<ProFormCol>
<ProFormColItem :span="12">
- <ProFormItemV2 label="鑱旂郴鐢佃瘽:" prop="contactPhone">
- <ProFormText v-model.trim="form.contactPhone" placeholder="璇疯緭鍏ヨ仈绯荤數璇�" />
+ <ProFormItemV2
+ label="鑱旂郴鐢佃瘽:"
+ prop="contactPhoneNumber"
+ :check-rules="[{ message: '璇疯緭鍏ヨ仈绯荤數璇�', type: 'phone' }]"
+ >
+ <ProFormText v-model.trim="form.contactPhoneNumber" placeholder="璇疯緭鍏ヨ仈绯荤數璇�" />
</ProFormItemV2>
</ProFormColItem>
</ProFormCol>
<ProFormCol>
<ProFormColItem :span="12">
- <ProFormItemV2 label="閭:" prop="email">
+ <ProFormItemV2 label="閭:" prop="contactEmail">
<ProFormText
- v-model.trim="form.email"
+ v-model.trim="form.contactEmail"
:maxlength="30"
placeholder="璇疯緭鍏ラ偖绠�"
:formatter="filterCN"
@@ -141,16 +144,36 @@
<ChunkCell title="璐﹀彿淇℃伅">
<ProForm
:model="form"
- :rules="rules"
ref="accountFormRef"
label-width="140px"
:scroll-to-error="false"
:is-read="isDetail"
>
<ProFormCol>
- <ProFormColItem :span="12">
- <ProFormItemV2 label="璐﹀彿:" prop="contact">
- <ProFormText v-model.trim="form.contact" :maxlength="30" placeholder="璇疯緭鍏ヨ处鍙�" />
+ <ProFormColItem :span="8">
+ <ProFormItemV2
+ label="璐﹀彿:"
+ prop="userName"
+ :check-rules="[{ message: '璇疯緭鍏ヨ处鍙�' }]"
+ >
+ <ProFormText
+ v-model.trim="form.userName"
+ :maxlength="30"
+ placeholder="璇疯緭鍏ヨ处鍙�"
+ />
+ </ProFormItemV2>
+ </ProFormColItem>
+ <ProFormColItem :span="8" v-if="!isEdit">
+ <ProFormItemV2
+ label="瀵嗙爜:"
+ prop="password"
+ :check-rules="[{ message: '璇疯緭鍏ュ瘑鐮�' }]"
+ >
+ <ProFormText
+ v-model.trim="form.password"
+ :maxlength="30"
+ placeholder="璇疯緭鍏ュ瘑鐮�"
+ />
</ProFormItemV2>
</ProFormColItem>
</ProFormCol>
@@ -177,82 +200,84 @@
ProFormColItem,
} from '@bole-core/components';
import { FormRules, FormInstance } from 'element-plus';
-import { SearchType } from '@/constants';
-import * as flexEnterpriseServices from '@/services/api/FlexEnterprise';
-import { useRouteView, useGlobalEventContext, GlobalEvent, useSearchSettingType } from '@/hooks';
+import * as enterpriseServices from '@/services/api/enterprise';
+import { useRouteView, useGlobalEventContext, GlobalEvent } from '@/hooks';
import _ from 'lodash';
-import { validateFormList, filterCN } from '@/utils';
+import { validateFormList, filterCN, removeEmptyKeys } from '@/utils';
import { Message, BoleRegExp } from '@bole-core/core';
import { useQuery } from '@tanstack/vue-query';
+import { AreaType } from '@/constants';
defineOptions({ name: 'AddOrEditEnterpriseView' });
type Props = {
isDetail: boolean;
- id?: string;
emitAddEvent?: keyof GlobalEvent;
emitEditEvent?: keyof GlobalEvent;
backRouteName?: string;
};
const props = withDefaults(defineProps<Props>(), {
- id: '',
emitAddEvent: 'enterprise:add',
emitEditEvent: 'enterprise:edit',
backRouteName: 'EnterpriseManageList',
});
const route = useRoute();
-const isEdit = computed(() => !!props.id);
+const id = route.params.id as string;
+const isEdit = computed(() => !!id);
+const { dictionaryDataList } = useDictionaryDataSelect({
+ categoryCode: computed(() => CategoryCode.IndustryCategory),
+});
const { closeViewPush } = useRouteView();
const eventContext = useGlobalEventContext();
-
-const { searchSettingTypeList: typeList } = useSearchSettingType({
- searchType: SearchType.IndustryCategory,
-});
const form = reactive({
id: '',
enterpriseName: '',
- legalPersonName: '',
- legalPersonIdNumber: '',
+ legalPerson: '',
+ legalIdentity: '',
societyCreditCode: '',
- proviceName: '',
- cityName: '',
- belongIndustryType: '',
- contact: '',
- contactPhone: '',
- email: '',
+ industryTypeCode: '',
+ mainBusiness: '',
+ areaList: [] as string[],
+ contacts: '',
+ contactPhoneNumber: '',
+ contactEmail: '',
+ userName: '',
+ password: '',
});
-onMounted(async () => {});
-
const { isLoading } = useQuery({
- // queryKey: ['insureSupplierService/getInsureSupplierInfoById', props.id],
- // queryFn: async () => {
- // return await insureSupplierService.getInsureSupplierInfoById(
- // { id: props.id },
- // {
- // showLoading: false,
- // }
- // );
- // },
- onSuccess(data) {},
- enabled: computed(() => !!props.id),
+ queryKey: ['enterpriseServices/getEnterprise', id],
+ queryFn: async () => {
+ return await enterpriseServices.getEnterprise(
+ { 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.industryTypeCode = data.industryTypeCode ?? '';
+ form.mainBusiness = data.mainBusiness;
+ form.contacts = data.contacts;
+ form.contactPhoneNumber = data.contactPhoneNumber;
+ form.contactEmail = data.contactEmail;
+ form.userName = data.userName;
+ form.areaList = [data.provinceCode, data.cityCode].filter(Boolean);
+ },
+ enabled: computed(() => !!id),
});
const formRef = ref<FormInstance>();
const settingFormRef = ref<FormInstance>();
const accountFormRef = ref<FormInstance>();
-
-const rules = reactive<FormRules>({
- enterpriseName: [{ required: true, message: '璇疯緭鍏ヤ紒涓氬悕绉�', trigger: 'blur' }],
- contact: [{ required: true, message: '璇疯緭鍏ヨ仈绯讳汉', trigger: 'blur' }],
- contactPhone: [
- { required: true, message: '璇疯緭鍏ヨ仈绯荤數璇�', trigger: 'blur' },
- { message: '璇疯緭鍏ユ纭殑鑱旂郴鐢佃瘽', trigger: 'blur', pattern: BoleRegExp.RegPhoneNumber },
- ],
-});
async function handleSubmit() {
try {
@@ -269,22 +294,25 @@
async function handleCreateOrEditFlexEnterprise() {
try {
- let params: API.CreateOrEditFlexEnterpriseInput = {
+ let params: API.SaveEnterpriseCommand = {
enterpriseName: form.enterpriseName,
- legalPersonName: form.legalPersonName,
- legalPersonIdNumber: form.legalPersonIdNumber,
+ legalPerson: form.legalPerson,
+ legalIdentity: form.legalIdentity,
societyCreditCode: form.societyCreditCode,
- proviceName: form.proviceName,
- cityName: form.cityName,
- belongIndustryType: form.belongIndustryType,
- contact: form.contact,
- contactPhone: form.contactPhone,
- // email: form.email,
+ provinceCode: form.areaList[0],
+ cityCode: form.areaList[1],
+ industryTypeCode: form.industryTypeCode,
+ mainBusiness: form.mainBusiness,
+ contacts: form.contacts,
+ contactPhoneNumber: form.contactPhoneNumber,
+ contactEmail: form.contactEmail,
+ userName: form.userName,
+ password: form.password,
};
if (isEdit.value) {
- params.id = props.id;
+ params.id = id;
}
- let res = await flexEnterpriseServices.createOrEditFlexEnterprise(params);
+ let res = await enterpriseServices.saveEnterprise(removeEmptyKeys(params));
if (res) {
Message.successMessage(isEdit ? '缂栬緫鎴愬姛' : '鍙戝竷鎴愬姛');
eventContext.emit(isEdit ? 'enterprise:edit' : 'enterprise:add');
--
Gitblit v1.9.1