|
|
@@ -1,10 +1,16 @@
|
|
|
<script lang="ts" setup>
|
|
|
+import type { CustomerEntity } from '@vben/types';
|
|
|
+
|
|
|
import { computed, ref } from 'vue';
|
|
|
|
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
|
|
|
|
import { useVbenForm, z } from '#/adapter/form';
|
|
|
-import { getCustomerDetailApi } from '#/api/customer-manage';
|
|
|
+import {
|
|
|
+ addCustomerApi,
|
|
|
+ editCustomerApi,
|
|
|
+ getCustomerDetailApi,
|
|
|
+} from '#/api/customer-manage';
|
|
|
|
|
|
const data = ref();
|
|
|
|
|
|
@@ -23,6 +29,7 @@ const [BaseForm, baseFormApi] = useVbenForm({
|
|
|
schema: [
|
|
|
// { title: '用户名称', field: 'usersname' },
|
|
|
// { title: '用户性质', field: 'usersnature' },
|
|
|
+ // { title: '用户类型', field: 'userstype' },
|
|
|
// { title: '用户证件号码', field: 'usersidcardnumber' },
|
|
|
// { title: '用户开户银行名称', field: 'usersbankname' },
|
|
|
// { title: '用户开户银行账号', field: 'usersbanknumber' },
|
|
|
@@ -43,24 +50,77 @@ const [BaseForm, baseFormApi] = useVbenForm({
|
|
|
rules: z.string().min(1, { message: '请输入用户名称' }),
|
|
|
},
|
|
|
{
|
|
|
- component: 'Input',
|
|
|
+ component: 'Select',
|
|
|
fieldName: 'usersnature',
|
|
|
label: '用户性质',
|
|
|
componentProps: {
|
|
|
placeholder: '请输入用户性质',
|
|
|
allowClear: true,
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ label: '用户',
|
|
|
+ value: '用户',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '渠道',
|
|
|
+ value: '渠道',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请输入用户性质' }),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Select',
|
|
|
+ fieldName: 'userstype',
|
|
|
+ label: '用户类型',
|
|
|
+ defaultValue: '个人',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入用户类型',
|
|
|
+ allowClear: true,
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ label: '个人',
|
|
|
+ value: '个人',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '企业',
|
|
|
+ value: '企业',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请输入用户类型' }),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'usersidcardnumber',
|
|
|
+ label: '用户身份证号码',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入用户身份证号码',
|
|
|
+ allowClear: true,
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请输入用户身份证号码' }),
|
|
|
+ dependencies: {
|
|
|
+ if(values) {
|
|
|
+ return values.userstype && values.userstype === '个人';
|
|
|
+ },
|
|
|
+ triggerFields: ['userstype'],
|
|
|
},
|
|
|
- rules: z.number().min(1, { message: '请输入用户性质' }),
|
|
|
},
|
|
|
{
|
|
|
component: 'Input',
|
|
|
fieldName: 'usersidcardnumber',
|
|
|
- label: '用户证件号码',
|
|
|
+ label: '纳税人识别号',
|
|
|
componentProps: {
|
|
|
- placeholder: '请输入用户证件号码',
|
|
|
+ placeholder: '请输入纳税人识别号',
|
|
|
allowClear: true,
|
|
|
},
|
|
|
- rules: z.string().min(1, { message: '请输入用户证件号码' }),
|
|
|
+ rules: z.string().min(1, { message: '请输入纳税人识别号' }),
|
|
|
+ dependencies: {
|
|
|
+ if(values) {
|
|
|
+ return values.userstype && values.userstype === '企业';
|
|
|
+ },
|
|
|
+ triggerFields: ['userstype'],
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
component: 'Input',
|
|
|
@@ -156,7 +216,19 @@ const [Modal, modalApi] = useVbenModal({
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- modalApi.close();
|
|
|
+ // 调用新增或编辑接口
|
|
|
+ const res = await (data.value.create
|
|
|
+ ? addCustomerApi(validate.values as CustomerEntity)
|
|
|
+ : editCustomerApi(validate.values as CustomerEntity));
|
|
|
+
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ console.log(res);
|
|
|
+
|
|
|
+ // if (res.code === 200) {
|
|
|
+ // modalApi.close();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // modalApi.close();
|
|
|
// const values = await baseFormApi.getValues();
|
|
|
|
|
|
// console.log(Object.keys(values));
|