<template>
|
<LoadingLayout :loading="isEdit && isLoading">
|
<AppScrollContainer>
|
<ChunkCell title="企业基本信息">
|
<ProForm :model="form" ref="formRef" label-width="140px" :is-read="isDetail">
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<ProFormItemV2
|
label="企业名称:"
|
prop="enterpriseName"
|
:check-rules="[{ message: '请输入企业名称' }]"
|
>
|
<ProFormText
|
v-model.trim="form.enterpriseName"
|
:maxlength="30"
|
placeholder="请输入企业名称"
|
/>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 label="法人姓名:" prop="legalPersonName">
|
<ProFormText
|
v-model.trim="form.legalPersonName"
|
:maxlength="30"
|
placeholder="请输入法人姓名"
|
/>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 label="法人身份证号:" prop="legalPersonIdNumber">
|
<ProFormText
|
v-model.trim="form.legalPersonIdNumber"
|
:maxlength="30"
|
placeholder="请输入法人身份证号"
|
/>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<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="proviceName">
|
<ProFormText
|
v-model.trim="form.proviceName"
|
:maxlength="30"
|
placeholder="请输入所在省份"
|
/>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 label="所属行业:" prop="belongIndustryType">
|
<ProFormSelect
|
placeholder="请选择所属行业"
|
:value-enum="typeList"
|
enum-value-key="id"
|
enum-label-key="name"
|
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">
|
<ProFormTextArea
|
v-model="form.cityName"
|
maxlength="200"
|
:rows="6"
|
show-word-limit
|
placeholder="请输入主营业务"
|
/>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
</ProForm>
|
</ChunkCell>
|
<ChunkCell title="联系信息">
|
<ProForm
|
:model="form"
|
ref="settingFormRef"
|
label-width="140px"
|
:scroll-to-error="false"
|
:is-read="isDetail"
|
>
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<ProFormItemV2
|
label="联系人:"
|
prop="contact"
|
:check-rules="[{ message: '请输入联系人' }]"
|
>
|
<ProFormText
|
v-model.trim="form.contact"
|
:maxlength="30"
|
placeholder="请输入联系人"
|
/>
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<ProFormItemV2
|
label="联系电话:"
|
prop="contactPhone"
|
:check-rules="[{ message: '请输入联系电话', type: 'phone' }]"
|
>
|
<ProFormText v-model.trim="form.contactPhone" placeholder="请输入联系电话" />
|
</ProFormItemV2>
|
</ProFormColItem>
|
</ProFormCol>
|
<ProFormCol>
|
<ProFormColItem :span="12">
|
<ProFormItemV2 label="邮箱:" prop="email">
|
<ProFormText
|
v-model.trim="form.email"
|
: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="12">
|
<ProFormItemV2
|
label="账号:"
|
prop="contact"
|
:check-rules="[{ message: '请输入账号' }]"
|
>
|
<ProFormText v-model.trim="form.contact" :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>
|
</LoadingLayout>
|
</template>
|
<script setup lang="ts">
|
import {
|
LoadingLayout,
|
AppScrollContainer,
|
ProForm,
|
ProFormItemV2,
|
ChunkCell,
|
ProFormText,
|
ProFormSelect,
|
ProFormTextArea,
|
ProFormCol,
|
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 _ from 'lodash';
|
import { validateFormList, filterCN } from '@/utils';
|
import { Message, BoleRegExp } from '@bole-core/core';
|
import { useQuery } from '@tanstack/vue-query';
|
|
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 { closeViewPush } = useRouteView();
|
const eventContext = useGlobalEventContext();
|
|
const { searchSettingTypeList: typeList } = useSearchSettingType({
|
searchType: SearchType.IndustryCategory,
|
});
|
|
const form = reactive({
|
id: '',
|
enterpriseName: '',
|
legalPersonName: '',
|
legalPersonIdNumber: '',
|
societyCreditCode: '',
|
proviceName: '',
|
cityName: '',
|
belongIndustryType: '',
|
contact: '',
|
contactPhone: '',
|
email: '',
|
});
|
|
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),
|
});
|
|
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.CreateOrEditFlexEnterpriseInput = {
|
enterpriseName: form.enterpriseName,
|
legalPersonName: form.legalPersonName,
|
legalPersonIdNumber: form.legalPersonIdNumber,
|
societyCreditCode: form.societyCreditCode,
|
proviceName: form.proviceName,
|
cityName: form.cityName,
|
belongIndustryType: form.belongIndustryType,
|
contact: form.contact,
|
contactPhone: form.contactPhone,
|
// email: form.email,
|
};
|
if (isEdit.value) {
|
params.id = props.id;
|
}
|
let res = await flexEnterpriseServices.createOrEditFlexEnterprise(params);
|
if (res) {
|
Message.successMessage(isEdit ? '编辑成功' : '发布成功');
|
eventContext.emit(isEdit ? 'enterprise:edit' : 'enterprise:add');
|
handleBack();
|
}
|
} catch (error) {}
|
}
|
|
function handleBack() {
|
closeViewPush(route, {
|
name: 'EnterpriseManageList',
|
});
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@use '@/style/common.scss' as *;
|
</style>
|