|
|
@@ -1,203 +1,189 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { computed, ref } from 'vue';
|
|
|
|
|
|
-// import { useVbenDrawer } from '@vben/common-ui';
|
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
|
-import { $t } from '@vben/locales';
|
|
|
|
|
|
-// import { notification } from 'ant-design-vue';
|
|
|
import { useVbenForm, z } from '#/adapter/form';
|
|
|
-// import { authorityList, useOrganizationStore, useUserStore } from '#/store';
|
|
|
-
|
|
|
-// const userStore = useUserStore();
|
|
|
-// const orgStore = useOrganizationStore();
|
|
|
+import { getCustomerDetailApi } from '#/api/customer-manage';
|
|
|
|
|
|
const data = ref();
|
|
|
|
|
|
-const getTitle = computed(() =>
|
|
|
- data.value?.create
|
|
|
- ? $t('ui.modal.create', { moduleName: $t('page.user.moduleName') })
|
|
|
- : $t('ui.modal.update', { moduleName: $t('page.user.moduleName') }),
|
|
|
-);
|
|
|
-// const isCreate = computed(() => data.value?.create);
|
|
|
+const getTitle = computed(() => (data.value?.create ? '新增客户' : '编辑客户'));
|
|
|
|
|
|
-const [BaseForm] = useVbenForm({
|
|
|
+const [BaseForm, baseFormApi] = useVbenForm({
|
|
|
showDefaultActions: false,
|
|
|
// 所有表单项共用,可单独在表单内覆盖
|
|
|
commonConfig: {
|
|
|
+ labelWidth: 120,
|
|
|
// 所有表单项
|
|
|
componentProps: {
|
|
|
class: 'w-full',
|
|
|
},
|
|
|
},
|
|
|
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: 'userName',
|
|
|
- label: $t('page.user.table.userName'),
|
|
|
+ fieldName: 'usersname',
|
|
|
+ label: '用户名称',
|
|
|
componentProps: {
|
|
|
- placeholder: $t('ui.placeholder.input'),
|
|
|
+ placeholder: '请输入用户名称',
|
|
|
allowClear: true,
|
|
|
},
|
|
|
- rules: z.string().min(1, { message: $t('ui.formRules.required') }),
|
|
|
+ rules: z.string().min(1, { message: '请输入用户名称' }),
|
|
|
},
|
|
|
- // {
|
|
|
- // component: 'VbenInputPassword',
|
|
|
- // fieldName: 'password',
|
|
|
- // label: '密码',
|
|
|
- // componentProps: {
|
|
|
- // passwordStrength: true,
|
|
|
- // placeholder: $t('ui.placeholder.input'),
|
|
|
- // },
|
|
|
- // rules: 'required',
|
|
|
- // },
|
|
|
{
|
|
|
- component: 'Select',
|
|
|
- fieldName: 'authority',
|
|
|
- label: $t('page.user.table.authority'),
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'usersnature',
|
|
|
+ label: '用户性质',
|
|
|
componentProps: {
|
|
|
- placeholder: $t('ui.placeholder.select'),
|
|
|
- // options: authorityList,
|
|
|
- options: [],
|
|
|
+ placeholder: '请输入用户性质',
|
|
|
+ allowClear: true,
|
|
|
},
|
|
|
- rules: 'selectRequired',
|
|
|
+ rules: z.number().min(1, { message: '请输入用户性质' }),
|
|
|
},
|
|
|
{
|
|
|
- component: 'ApiTreeSelect',
|
|
|
- fieldName: 'orgId',
|
|
|
- label: $t('page.user.table.orgId'),
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'usersidcardnumber',
|
|
|
+ label: '用户证件号码',
|
|
|
componentProps: {
|
|
|
- placeholder: $t('ui.placeholder.select'),
|
|
|
- api: async () => {
|
|
|
- // const result = await orgStore.listOrganization(true);
|
|
|
- // return result.items;
|
|
|
- },
|
|
|
- numberToString: true,
|
|
|
- childrenField: 'children',
|
|
|
- labelField: 'name',
|
|
|
- valueField: 'id',
|
|
|
- // afterFetch: (data: any) => {
|
|
|
- // return data.map((item: any) => ({
|
|
|
- // label: item.name,
|
|
|
- // value: item.id,
|
|
|
- // }));
|
|
|
- // },
|
|
|
+ placeholder: '请输入用户证件号码',
|
|
|
+ allowClear: true,
|
|
|
},
|
|
|
- rules: 'selectRequired',
|
|
|
+ rules: z.string().min(1, { message: '请输入用户证件号码' }),
|
|
|
},
|
|
|
{
|
|
|
component: 'Input',
|
|
|
- fieldName: 'nickName',
|
|
|
- label: $t('page.user.table.nickName'),
|
|
|
+ fieldName: 'usersbankname',
|
|
|
+ label: '用户开户银行名称',
|
|
|
componentProps: {
|
|
|
- placeholder: $t('ui.placeholder.input'),
|
|
|
+ placeholder: '请输入用户开户银行名称',
|
|
|
allowClear: true,
|
|
|
},
|
|
|
- rules: 'required',
|
|
|
+ rules: z.string().min(1, { message: '请输入用户开户银行名称' }),
|
|
|
},
|
|
|
{
|
|
|
component: 'Input',
|
|
|
- fieldName: 'email',
|
|
|
- label: $t('page.user.table.email'),
|
|
|
+ fieldName: 'usersbanknumber',
|
|
|
+ label: '用户开户银行账号',
|
|
|
componentProps: {
|
|
|
- placeholder: $t('ui.placeholder.input'),
|
|
|
+ placeholder: '请输入用户开户银行账号',
|
|
|
allowClear: true,
|
|
|
},
|
|
|
- rules: 'required',
|
|
|
+ rules: z.string().min(1, { message: '请输入用户开户银行账号' }),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'usersphone',
|
|
|
+ label: '用户手机号',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入用户手机号',
|
|
|
+ allowClear: true,
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请输入用户手机号' }),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'usersemail',
|
|
|
+ label: '用户邮箱',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入用户邮箱',
|
|
|
+ allowClear: true,
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请输入用户邮箱' }),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'usersaddress',
|
|
|
+ label: '用户地址',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入用户地址',
|
|
|
+ allowClear: true,
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请输入用户地址' }),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'userscontactphone',
|
|
|
+ label: '用户联系手机号',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入用户联系手机号',
|
|
|
+ allowClear: true,
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请输入用户联系手机号' }),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'userscontactemail',
|
|
|
+ label: '用户联系邮箱',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入用户联系邮箱',
|
|
|
+ allowClear: true,
|
|
|
+ },
|
|
|
+ rules: z.string().min(1, { message: '请输入用户联系邮箱' }),
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
component: 'Input',
|
|
|
- fieldName: 'remark',
|
|
|
- label: $t('ui.table.remark'),
|
|
|
+ fieldName: 'userscontactaddress',
|
|
|
+ label: '用户联系地址',
|
|
|
componentProps: {
|
|
|
- placeholder: $t('ui.placeholder.input'),
|
|
|
+ placeholder: '请输入用户联系地址',
|
|
|
allowClear: true,
|
|
|
- type: 'textarea',
|
|
|
},
|
|
|
+ rules: z.string().min(1, { message: '请输入用户联系地址' }),
|
|
|
},
|
|
|
],
|
|
|
});
|
|
|
|
|
|
-// const [Drawer, drawerApi] = useVbenDrawer({
|
|
|
-// onCancel() {
|
|
|
-// drawerApi.close();
|
|
|
-// },
|
|
|
-
|
|
|
-// async onConfirm() {
|
|
|
-// console.log('onConfirm');
|
|
|
-
|
|
|
-// // 校验输入的数据
|
|
|
-// const validate = await baseFormApi.validate();
|
|
|
-// if (!validate.valid) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-
|
|
|
-// // 加载条设置为加载状态
|
|
|
-// setLoading(true);
|
|
|
-
|
|
|
-// // 获取表单数据
|
|
|
-// const values = await baseFormApi.getValues();
|
|
|
-
|
|
|
-// console.log(getTitle.value, Object.keys(values));
|
|
|
-
|
|
|
-// try {
|
|
|
-// // await (data.value?.create
|
|
|
-// // ? userStore.createUser(values)
|
|
|
-// // : userStore.updateUser(data.value.row.id, values));
|
|
|
-// // notification.success({
|
|
|
-// // message: data.value?.create
|
|
|
-// // ? $t('ui.notification.create_success')
|
|
|
-// // : $t('ui.notification.update_success'),
|
|
|
-// // });
|
|
|
-// } catch {
|
|
|
-// // notification.error({
|
|
|
-// // message: data.value?.create
|
|
|
-// // ? $t('ui.notification.create_failed')
|
|
|
-// // : $t('ui.notification.update_failed'),
|
|
|
-// // });
|
|
|
-// } finally {
|
|
|
-// // 关闭窗口
|
|
|
-// drawerApi.close();
|
|
|
-// setLoading(false);
|
|
|
-// }
|
|
|
-// },
|
|
|
-
|
|
|
-// onOpenChange(isOpen: boolean) {
|
|
|
-// if (isOpen) {
|
|
|
-// // 获取传入的数据
|
|
|
-// data.value = drawerApi.getData<Record<string, any>>();
|
|
|
-
|
|
|
-// // 为表单赋值
|
|
|
-// if (data.value.row !== undefined) {
|
|
|
-// data.value.row.orgId = data.value?.row?.orgId.toString();
|
|
|
-// baseFormApi.setValues(data.value?.row);
|
|
|
-// }
|
|
|
-
|
|
|
-// setLoading(false);
|
|
|
-
|
|
|
-// console.log('onOpenChange', data.value, data.value?.create);
|
|
|
-// }
|
|
|
-// },
|
|
|
-// });
|
|
|
-
|
|
|
const [Modal, modalApi] = useVbenModal({
|
|
|
onCancel() {
|
|
|
modalApi.close();
|
|
|
},
|
|
|
- onConfirm() {
|
|
|
- // console.log('onConfirm');
|
|
|
+ async onConfirm() {
|
|
|
+ // 校验输入的数据
|
|
|
+ const validate = await baseFormApi.validate();
|
|
|
+ if (!validate.valid) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ modalApi.close();
|
|
|
+ // const values = await baseFormApi.getValues();
|
|
|
+
|
|
|
+ // console.log(Object.keys(values));
|
|
|
},
|
|
|
- onOpenChange(isOpen) {
|
|
|
+ async onOpenChange(isOpen) {
|
|
|
if (isOpen) {
|
|
|
- // handleUpdate(10);
|
|
|
+ data.value = modalApi.getData();
|
|
|
+
|
|
|
+ if (data.value.create) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ modalApi.setState({ loading: true });
|
|
|
+ const detailData = await getCustomerDetailApi({
|
|
|
+ usersid: data.value.row.usersid,
|
|
|
+ });
|
|
|
+
|
|
|
+ baseFormApi.setValues(detailData);
|
|
|
+ } catch {
|
|
|
+ // console.log(error);
|
|
|
+ }
|
|
|
+
|
|
|
+ modalApi.setState({ loading: false });
|
|
|
}
|
|
|
},
|
|
|
});
|
|
|
-
|
|
|
-// function setLoading(loading: boolean) {
|
|
|
-// modalApi.setState({ confirmLoading: loading });
|
|
|
-// }
|
|
|
</script>
|
|
|
|
|
|
<template>
|