|
@@ -1,151 +1,112 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
|
|
+import type { ScqyEntity } from '@vben/types';
|
|
|
|
|
+
|
|
|
import { computed, ref } from 'vue';
|
|
import { computed, ref } from 'vue';
|
|
|
|
|
|
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
|
|
|
|
|
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
|
|
+
|
|
|
import { useVbenForm, z } from '#/adapter/form';
|
|
import { useVbenForm, z } from '#/adapter/form';
|
|
|
-import { getCustomerDetailApi } from '#/api/customer-manage';
|
|
|
|
|
|
|
+import { addScqyApi, editScqyApi, getScqyDetailApi } from '#/api/scqy-manage';
|
|
|
|
|
|
|
|
|
|
+const emit = defineEmits(['finish']);
|
|
|
const data = ref();
|
|
const data = ref();
|
|
|
|
|
+const formType = ref<'create' | 'detail' | 'edit'>('create');
|
|
|
|
|
+
|
|
|
|
|
+const titleMap = {
|
|
|
|
|
+ create: '新增生产企业',
|
|
|
|
|
+ detail: '生产企业详情',
|
|
|
|
|
+ edit: '编辑生产企业',
|
|
|
|
|
+} as const;
|
|
|
|
|
|
|
|
-const getTitle = computed(() => (data.value?.create ? '新增客户' : '编辑客户'));
|
|
|
|
|
|
|
+const getTitle = computed(() => titleMap[formType.value]);
|
|
|
|
|
|
|
|
const [BaseForm, baseFormApi] = useVbenForm({
|
|
const [BaseForm, baseFormApi] = useVbenForm({
|
|
|
showDefaultActions: false,
|
|
showDefaultActions: false,
|
|
|
// 所有表单项共用,可单独在表单内覆盖
|
|
// 所有表单项共用,可单独在表单内覆盖
|
|
|
commonConfig: {
|
|
commonConfig: {
|
|
|
- labelWidth: 120,
|
|
|
|
|
|
|
+ labelWidth: 140,
|
|
|
// 所有表单项
|
|
// 所有表单项
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
class: 'w-full',
|
|
class: 'w-full',
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ wrapperClass: 'grid-cols-1 lg:grid-cols-2',
|
|
|
schema: [
|
|
schema: [
|
|
|
- // { title: '用户名称', field: 'usersname' },
|
|
|
|
|
- // { title: '用户性质', field: 'usersnature' },
|
|
|
|
|
- // { title: '用户证件号码', field: 'usersidcardnumber' },
|
|
|
|
|
- // { title: '用户开户银行名称', field: 'usersbankname' },
|
|
|
|
|
- // { title: '用户开户银行账号', field: 'usersbanknumber' },
|
|
|
|
|
- // { title: '用户手机号', field: 'usersphone' },
|
|
|
|
|
- // { title: '用户邮箱', field: 'usersemail' },
|
|
|
|
|
- // { title: '用户地址', field: 'usersaddress' },
|
|
|
|
|
- // { title: '用户联系手机号', field: 'userscontactphone' },
|
|
|
|
|
- // { title: '用户联系邮箱', field: 'userscontactemail' },
|
|
|
|
|
- // { title: '用户联系地址', field: 'userscontactaddress' },
|
|
|
|
|
- {
|
|
|
|
|
- component: 'Input',
|
|
|
|
|
- fieldName: 'usersname',
|
|
|
|
|
- label: '用户名称',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- placeholder: '请输入用户名称',
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- },
|
|
|
|
|
- rules: z.string().min(1, { message: '请输入用户名称' }),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- component: 'Input',
|
|
|
|
|
- fieldName: 'usersnature',
|
|
|
|
|
- label: '用户性质',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- placeholder: '请输入用户性质',
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- },
|
|
|
|
|
- rules: z.number().min(1, { message: '请输入用户性质' }),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- component: 'Input',
|
|
|
|
|
- fieldName: 'usersidcardnumber',
|
|
|
|
|
- label: '用户证件号码',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- placeholder: '请输入用户证件号码',
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- },
|
|
|
|
|
- rules: z.string().min(1, { message: '请输入用户证件号码' }),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- component: 'Input',
|
|
|
|
|
- fieldName: 'usersbankname',
|
|
|
|
|
- label: '用户开户银行名称',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- placeholder: '请输入用户开户银行名称',
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- },
|
|
|
|
|
- rules: z.string().min(1, { message: '请输入用户开户银行名称' }),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- component: 'Input',
|
|
|
|
|
- fieldName: 'usersbanknumber',
|
|
|
|
|
- label: '用户开户银行账号',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- placeholder: '请输入用户开户银行账号',
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- },
|
|
|
|
|
- rules: z.string().min(1, { message: '请输入用户开户银行账号' }),
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ // { title: '生产企业名称', field: 'scqyinfomc' },
|
|
|
|
|
+ // { title: '生产企业地址', field: 'scqyinfoaddress' },
|
|
|
|
|
+ // { title: '生产企业法人姓名', field: 'scqyinfofrmc' },
|
|
|
|
|
+ // { title: '生产企业电子邮箱', field: 'scqyinfomail' },
|
|
|
|
|
+ // { title: '生产企业销售联系人', field: 'scqyinfoxsmc' },
|
|
|
|
|
+ // { title: '生产企业销售联系手机号', field: 'scqyinfoxsphone' },
|
|
|
{
|
|
{
|
|
|
component: 'Input',
|
|
component: 'Input',
|
|
|
- fieldName: 'usersphone',
|
|
|
|
|
- label: '用户手机号',
|
|
|
|
|
|
|
+ fieldName: 'scqyinfomc',
|
|
|
|
|
+ label: '企业名称',
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
- placeholder: '请输入用户手机号',
|
|
|
|
|
|
|
+ placeholder: '请输入生产企业名称',
|
|
|
allowClear: true,
|
|
allowClear: true,
|
|
|
},
|
|
},
|
|
|
- rules: z.string().min(1, { message: '请输入用户手机号' }),
|
|
|
|
|
|
|
+ rules: z.string().min(1, { message: '请输入生产企业名称' }),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
component: 'Input',
|
|
component: 'Input',
|
|
|
- fieldName: 'usersemail',
|
|
|
|
|
- label: '用户邮箱',
|
|
|
|
|
|
|
+ fieldName: 'scqyinfoaddress',
|
|
|
|
|
+ label: '企业地址',
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
- placeholder: '请输入用户邮箱',
|
|
|
|
|
|
|
+ placeholder: '请输入生产企业地址',
|
|
|
allowClear: true,
|
|
allowClear: true,
|
|
|
},
|
|
},
|
|
|
- rules: z.string().min(1, { message: '请输入用户邮箱' }),
|
|
|
|
|
|
|
+ rules: z.string().min(1, { message: '请输入生产企业地址' }),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
component: 'Input',
|
|
component: 'Input',
|
|
|
- fieldName: 'usersaddress',
|
|
|
|
|
- label: '用户地址',
|
|
|
|
|
|
|
+ fieldName: 'scqyinfofrmc',
|
|
|
|
|
+ label: '法人姓名',
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
- placeholder: '请输入用户地址',
|
|
|
|
|
|
|
+ placeholder: '请输入生产企业法人姓名',
|
|
|
allowClear: true,
|
|
allowClear: true,
|
|
|
},
|
|
},
|
|
|
- rules: z.string().min(1, { message: '请输入用户地址' }),
|
|
|
|
|
|
|
+ rules: z.string().min(1, { message: '请输入生产企业法人姓名' }),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
component: 'Input',
|
|
component: 'Input',
|
|
|
- fieldName: 'userscontactphone',
|
|
|
|
|
- label: '用户联系手机号',
|
|
|
|
|
|
|
+ fieldName: 'scqyinfomail',
|
|
|
|
|
+ label: '电子邮箱',
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
- placeholder: '请输入用户联系手机号',
|
|
|
|
|
|
|
+ placeholder: '请输入生产企业电子邮箱',
|
|
|
allowClear: true,
|
|
allowClear: true,
|
|
|
},
|
|
},
|
|
|
- rules: z.string().min(1, { message: '请输入用户联系手机号' }),
|
|
|
|
|
|
|
+ rules: z.string().email({ message: '请输入正确的电子邮箱格式' }),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
component: 'Input',
|
|
component: 'Input',
|
|
|
- fieldName: 'userscontactemail',
|
|
|
|
|
- label: '用户联系邮箱',
|
|
|
|
|
|
|
+ fieldName: 'scqyinfoxsmc',
|
|
|
|
|
+ label: '销售联系人',
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
- placeholder: '请输入用户联系邮箱',
|
|
|
|
|
|
|
+ placeholder: '请输入生产企业销售联系人',
|
|
|
allowClear: true,
|
|
allowClear: true,
|
|
|
},
|
|
},
|
|
|
- rules: z.string().min(1, { message: '请输入用户联系邮箱' }),
|
|
|
|
|
|
|
+ rules: z.string().min(1, { message: '请输入生产企业销售联系人' }),
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
component: 'Input',
|
|
component: 'Input',
|
|
|
- fieldName: 'userscontactaddress',
|
|
|
|
|
- label: '用户联系地址',
|
|
|
|
|
|
|
+ fieldName: 'scqyinfoxsphone',
|
|
|
|
|
+ label: '销售联系手机号',
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
- placeholder: '请输入用户联系地址',
|
|
|
|
|
|
|
+ placeholder: '请输入生产企业销售联系手机号',
|
|
|
allowClear: true,
|
|
allowClear: true,
|
|
|
},
|
|
},
|
|
|
- rules: z.string().min(1, { message: '请输入用户联系地址' }),
|
|
|
|
|
|
|
+ rules: z
|
|
|
|
|
+ .string()
|
|
|
|
|
+ .regex(/^1[3-9]\d{9}$/, { message: '请输入正确的手机号格式' }),
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const [Modal, modalApi] = useVbenModal({
|
|
const [Modal, modalApi] = useVbenModal({
|
|
|
|
|
+ class: 'w-7/12',
|
|
|
onCancel() {
|
|
onCancel() {
|
|
|
modalApi.close();
|
|
modalApi.close();
|
|
|
},
|
|
},
|
|
@@ -156,23 +117,47 @@ const [Modal, modalApi] = useVbenModal({
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- modalApi.close();
|
|
|
|
|
- // const values = await baseFormApi.getValues();
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 调用新增或编辑接口
|
|
|
|
|
+ const apiMap = {
|
|
|
|
|
+ create: () => addScqyApi(validate.values as ScqyEntity),
|
|
|
|
|
+ edit: () =>
|
|
|
|
|
+ editScqyApi({
|
|
|
|
|
+ ...validate.values,
|
|
|
|
|
+ 'scqyinfoid.value': data.value.row.scqyinfoid,
|
|
|
|
|
+ } as any),
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ if (formType.value === 'detail') {
|
|
|
|
|
+ modalApi.close();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ await apiMap[formType.value]();
|
|
|
|
|
+ ElMessage.success('操作成功');
|
|
|
|
|
|
|
|
- // console.log(Object.keys(values));
|
|
|
|
|
|
|
+ emit('finish');
|
|
|
|
|
+ modalApi.close();
|
|
|
|
|
+ } catch {}
|
|
|
},
|
|
},
|
|
|
async onOpenChange(isOpen) {
|
|
async onOpenChange(isOpen) {
|
|
|
if (isOpen) {
|
|
if (isOpen) {
|
|
|
data.value = modalApi.getData();
|
|
data.value = modalApi.getData();
|
|
|
|
|
|
|
|
- if (data.value.create) {
|
|
|
|
|
|
|
+ formType.value = data.value.formType;
|
|
|
|
|
+
|
|
|
|
|
+ baseFormApi.setState({
|
|
|
|
|
+ commonConfig: { disabled: formType.value === 'detail' },
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ if (data.value.formType === 'create') {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
modalApi.setState({ loading: true });
|
|
modalApi.setState({ loading: true });
|
|
|
- const detailData = await getCustomerDetailApi({
|
|
|
|
|
- usersid: data.value.row.usersid,
|
|
|
|
|
|
|
+ const detailData = await getScqyDetailApi({
|
|
|
|
|
+ scqyinfoid: data.value.row.scqyinfoid,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
baseFormApi.setValues(detailData);
|
|
baseFormApi.setValues(detailData);
|