|  |  | 
 |  |  |       <ChunkCell title="企业基本信息"> | 
 |  |  |         <ProForm :model="form" ref="formRef" label-width="140px" :is-read="isDetail"> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 | 
 |  |  |                 label="企业名称:" | 
 |  |  |                 prop="enterpriseName" | 
 |  |  | 
 |  |  |                 /> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 label="法人姓名:" prop="legalPerson"> | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.legalPerson" | 
 |  |  | 
 |  |  |                 /> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 label="法人身份证号:" prop="legalIdentity"> | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.legalIdentity" | 
 |  |  | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 | 
 |  |  |                 label="统一社会信用代码:" | 
 |  |  |                 prop="societyCreditCode" | 
 |  |  | 
 |  |  |                 /> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |               <ProFormItemV2 label="所在省份:" prop="proviceId"> | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.proviceId" | 
 |  |  |                   :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"> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 label="所属行业:" prop="industryTypeId"> | 
 |  |  |                 <ProFormSelect | 
 |  |  |                   v-model="form.industryTypeId" | 
 |  |  |                   v-model="form.industryTypeCode" | 
 |  |  |                   placeholder="请选择所属行业" | 
 |  |  |                   :value-enum="typeList" | 
 |  |  |                   enum-value-key="id" | 
 |  |  |                   enum-label-key="name" | 
 |  |  |                   :value-enum="dictionaryDataList" | 
 |  |  |                   clearable | 
 |  |  |                 ></ProFormSelect> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |               <ProFormItemV2 label="所在城市:" prop="cityId"> | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.cityId" | 
 |  |  |                   :maxlength="30" | 
 |  |  |                   placeholder="请输入所在城市" | 
 |  |  |                 /> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  | 
 |  |  |           :is-read="isDetail" | 
 |  |  |         > | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 | 
 |  |  |                 label="账号:" | 
 |  |  |                 prop="userName" | 
 |  |  | 
 |  |  |                   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> | 
 |  |  | 
 |  |  | 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 typeList = ref([]); | 
 |  |  |  | 
 |  |  | const form = reactive({ | 
 |  |  |   id: '', | 
 |  |  | 
 |  |  |   legalPerson: '', | 
 |  |  |   legalIdentity: '', | 
 |  |  |   societyCreditCode: '', | 
 |  |  |   industryTypeId: '', | 
 |  |  |   industryTypeCode: '', | 
 |  |  |   mainBusiness: '', | 
 |  |  |   proviceId: '', | 
 |  |  |   cityId: '', | 
 |  |  |   areaList: [] as string[], | 
 |  |  |   contacts: '', | 
 |  |  |   contactPhoneNumber: '', | 
 |  |  |   contactEmail: '', | 
 |  |  |   userName: '', | 
 |  |  |   password: '', | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | onMounted(async () => {}); | 
 |  |  | console.log('form: ', form); | 
 |  |  |  | 
 |  |  | const { isLoading } = useQuery({ | 
 |  |  |   queryKey: ['enterpriseServices/getEnterprise', props.id], | 
 |  |  |   queryKey: ['enterpriseServices/getEnterprise', id], | 
 |  |  |   queryFn: async () => { | 
 |  |  |     return await enterpriseServices.getEnterprise( | 
 |  |  |       { id: props.id }, | 
 |  |  |       { id: id }, | 
 |  |  |       { | 
 |  |  |         showLoading: false, | 
 |  |  |       } | 
 |  |  |     ); | 
 |  |  |   }, | 
 |  |  |   onSuccess(data) {}, | 
 |  |  |   enabled: computed(() => !!props.id), | 
 |  |  |   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>(); | 
 |  |  | 
 |  |  |       legalPerson: form.legalPerson, | 
 |  |  |       legalIdentity: form.legalIdentity, | 
 |  |  |       societyCreditCode: form.societyCreditCode, | 
 |  |  |       provinceId: form.proviceId, | 
 |  |  |       cityId: form.cityId, | 
 |  |  |       industryTypeId: form.industryTypeId, | 
 |  |  |       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 enterpriseServices.saveEnterprise(params); | 
 |  |  |     let res = await enterpriseServices.saveEnterprise(removeEmptyKeys(params)); | 
 |  |  |     if (res) { | 
 |  |  |       Message.successMessage(isEdit ? '编辑成功' : '发布成功'); | 
 |  |  |       eventContext.emit(isEdit ? 'enterprise:edit' : 'enterprise:add'); |