|  |  | 
 |  |  |   <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="name" required> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 | 
 |  |  |                 label="企业名称:" | 
 |  |  |                 prop="enterpriseName" | 
 |  |  |                 :check-rules="[{ message: '请输入企业名称' }]" | 
 |  |  |               > | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.name" | 
 |  |  |                   v-model.trim="form.enterpriseName" | 
 |  |  |                   :maxlength="30" | 
 |  |  |                   placeholder="请输入供应商名称" | 
 |  |  |                   placeholder="请输入企业名称" | 
 |  |  |                 /> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |               <ProFormItemV2 label="法人姓名:" prop="name" required> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 label="法人姓名:" prop="legalPerson"> | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.name" | 
 |  |  |                   v-model.trim="form.legalPerson" | 
 |  |  |                   :maxlength="30" | 
 |  |  |                   placeholder="请输入法人姓名" | 
 |  |  |                 /> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |               <ProFormItemV2 label="法人身份证号:" prop="name" required> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 label="法人身份证号:" prop="legalIdentity"> | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.name" | 
 |  |  |                   v-model.trim="form.legalIdentity" | 
 |  |  |                   :maxlength="30" | 
 |  |  |                   placeholder="请输入法人身份证号" | 
 |  |  |                 /> | 
 |  |  | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |               <ProFormItemV2 label="统一社会信用代码:" prop="societyCreditCode"> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 | 
 |  |  |                 label="统一社会信用代码:" | 
 |  |  |                 prop="societyCreditCode" | 
 |  |  |                 :check-rules="[{ message: '请输入统一社会信用代码', type: 'societyCreditCode' }]" | 
 |  |  |               > | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.societyCreditCode" | 
 |  |  |                   placeholder="请输入统一社会信用代码" | 
 |  |  |                 /> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |               <ProFormItemV2 label="所在省份:" prop="name" required> | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.name" | 
 |  |  |                   :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="name" required> | 
 |  |  |             <ProFormColItem :span="8"> | 
 |  |  |               <ProFormItemV2 label="所属行业:" prop="industryTypeId"> | 
 |  |  |                 <ProFormSelect | 
 |  |  |                   v-model="form.industryTypeCode" | 
 |  |  |                   placeholder="请选择所属行业" | 
 |  |  |                   :value-enum="typeList" | 
 |  |  |                   :value-enum="dictionaryDataList" | 
 |  |  |                   clearable | 
 |  |  |                   v-model="form.name" | 
 |  |  |                 ></ProFormSelect> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="12"> | 
 |  |  |               <ProFormItemV2 label="所在城市:" prop="name" required> | 
 |  |  |                 <ProFormText | 
 |  |  |                   v-model.trim="form.name" | 
 |  |  |                   :maxlength="30" | 
 |  |  |                   placeholder="请输入所在城市" | 
 |  |  |                 /> | 
 |  |  |               </ProFormItemV2> | 
 |  |  |             </ProFormColItem> | 
 |  |  |           </ProFormCol> | 
 |  |  |           <ProFormCol> | 
 |  |  |             <ProFormColItem :span="24"> | 
 |  |  |               <ProFormItemV2 label="主营业务:" prop="name"> | 
 |  |  |               <ProFormItemV2 label="主营业务:" prop="mainBusiness"> | 
 |  |  |                 <ProFormTextArea | 
 |  |  |                   v-model="form.name" | 
 |  |  |                   v-model="form.mainBusiness" | 
 |  |  |                   maxlength="200" | 
 |  |  |                   :rows="6" | 
 |  |  |                   show-word-limit | 
 |  |  | 
 |  |  |       <ChunkCell title="联系信息"> | 
 |  |  |         <ProForm | 
 |  |  |           :model="form" | 
 |  |  |           :rules="rules" | 
 |  |  |           ref="settingFormRef" | 
 |  |  |           label-width="140px" | 
 |  |  |           :scroll-to-error="false" | 
 |  |  | 
 |  |  |         > | 
 |  |  |           <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="请输入联系人" | 
 |  |  |                 /> | 
 |  |  | 
 |  |  |           </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" | 
 |  |  | 
 |  |  |               </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> | 
 |  |  |             <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> | 
 |  |  |           <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> | 
 |  |  | 
 |  |  |   ProFormColItem, | 
 |  |  | } from '@bole-core/components'; | 
 |  |  | import { FormRules, FormInstance } from 'element-plus'; | 
 |  |  | import { SearchType } from '@/constants'; | 
 |  |  | import * as searchSettingServices from '@/services/api/SearchSetting'; | 
 |  |  | 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: '', | 
 |  |  |   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: '', | 
 |  |  |   name: '', | 
 |  |  |   enterpriseName: '', | 
 |  |  |   legalPerson: '', | 
 |  |  |   legalIdentity: '', | 
 |  |  |   societyCreditCode: '', | 
 |  |  |   contact: '', | 
 |  |  |   contactPhone: '', | 
 |  |  |   email: '', | 
 |  |  |   industryTypeCode: '', | 
 |  |  |   mainBusiness: '', | 
 |  |  |   areaList: [] as string[], | 
 |  |  |   contacts: '', | 
 |  |  |   contactPhoneNumber: '', | 
 |  |  |   contactEmail: '', | 
 |  |  |   userName: '', | 
 |  |  |   password: '', | 
 |  |  | }); | 
 |  |  |  | 
 |  |  | onMounted(async () => {}); | 
 |  |  | console.log('form: ', form); | 
 |  |  |  | 
 |  |  | 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 rules = reactive<FormRules>({ | 
 |  |  |   name: [{ required: true, message: '请输入供应商名称', trigger: 'blur' }], | 
 |  |  |   societyCreditCode: [{ required: true, message: '请输入统一信用代码', trigger: 'blur' }], | 
 |  |  |   categoryType: [{ required: true, message: '请选择行业配套', trigger: 'change' }], | 
 |  |  |   areaList: [{ required: true, message: '请选择所在地区', trigger: 'change', type: 'array' }], | 
 |  |  |   companyAddress: [{ required: true, message: '请输入公司地址', trigger: 'blur' }], | 
 |  |  |   contact: [{ required: true, message: '请输入联系人', trigger: 'blur' }], | 
 |  |  |   suppierLevel: [{ required: true, message: '请选择供应商等级', trigger: 'change' }], | 
 |  |  |   // suppierType: [{ required: true, message: '请选择供应商类型', trigger: 'change' }], | 
 |  |  |   contactPhone: [ | 
 |  |  |     { required: true, message: '请输入联系电话', trigger: 'blur' }, | 
 |  |  |     { message: '请输入正确的联系电话', trigger: 'blur', pattern: BoleRegExp.RegPhoneNumber }, | 
 |  |  |   ], | 
 |  |  | }); | 
 |  |  | const accountFormRef = ref<FormInstance>(); | 
 |  |  |  | 
 |  |  | async function handleSubmit() { | 
 |  |  |   try { | 
 |  |  |     const valid = await validateFormList([formRef.value, settingFormRef.value]); | 
 |  |  |     const valid = await validateFormList([ | 
 |  |  |       formRef.value, | 
 |  |  |       settingFormRef.value, | 
 |  |  |       accountFormRef.value, | 
 |  |  |     ]); | 
 |  |  |     if (valid) { | 
 |  |  |       handleCreateOrEditInsureSupplier(); | 
 |  |  |       handleCreateOrEditFlexEnterprise(); | 
 |  |  |     } | 
 |  |  |   } catch (error) {} | 
 |  |  | } | 
 |  |  |  | 
 |  |  | async function handleCreateOrEditInsureSupplier() { | 
 |  |  | async function handleCreateOrEditFlexEnterprise() { | 
 |  |  |   try { | 
 |  |  |     // let params: API.CreateOrEditSearchInput = { | 
 |  |  |     //   name: form.name, | 
 |  |  |     // }; | 
 |  |  |     // if (isEdit.value) { | 
 |  |  |     //   params.id = props.id; | 
 |  |  |     // } | 
 |  |  |     // let res = await searchSettingServices.createOrEditSearchSetting(params); | 
 |  |  |     // if (res) { | 
 |  |  |     //   Message.successMessage(isEdit ? '编辑成功' : '发布成功'); | 
 |  |  |     //   eventContext.emit(isEdit ? 'enterprise:edit' : 'enterprise:add'); | 
 |  |  |     //   handleBack(); | 
 |  |  |     // } | 
 |  |  |     let params: API.SaveEnterpriseCommand = { | 
 |  |  |       enterpriseName: form.enterpriseName, | 
 |  |  |       legalPerson: form.legalPerson, | 
 |  |  |       legalIdentity: form.legalIdentity, | 
 |  |  |       societyCreditCode: form.societyCreditCode, | 
 |  |  |       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 = id; | 
 |  |  |     } | 
 |  |  |     let res = await enterpriseServices.saveEnterprise(removeEmptyKeys(params)); | 
 |  |  |     if (res) { | 
 |  |  |       Message.successMessage(isEdit ? '编辑成功' : '发布成功'); | 
 |  |  |       eventContext.emit(isEdit ? 'enterprise:edit' : 'enterprise:add'); | 
 |  |  |       handleBack(); | 
 |  |  |     } | 
 |  |  |   } catch (error) {} | 
 |  |  | } | 
 |  |  |  |