客户新增

This commit is contained in:
‘huanghaiixia’
2025-11-25 12:12:15 +08:00
parent 65575b40ad
commit c8c20d5b52
6 changed files with 556 additions and 78 deletions

View File

@ -0,0 +1,206 @@
<template>
<div class="bankListTb">
<BasicModal v-bind="$attrs" @register="registerModal" width="60%" :title="getTitle" @ok="handleSubmit" >
<BasicTable @register="registerTable" class="bankListModal">
</BasicTable>
</BasicModal>
</div>
</template>
<script lang="ts" setup>
import { ref, computed, unref } from 'vue';
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { BasicTable, useTable, FormSchema, BasicColumn, TableAction } from '/@/components/Table';
import { addCodeRule, getCodeRuleInfo, editCodeRule } from '/@/api/system/code';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { getLngBBankPage } from '/@/api/mdm/Bank';
const { t } = useI18n();
const codeFormSchema: FormSchema[] = [
{
field: 'shortName',
label: '银行名称/简称',
component: 'Input',
},
];
const columns: BasicColumn[] = [
{
dataIndex: 'code',
title: '编码',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'fullName',
title: '名称',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'shortName',
title: '简称',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'bankCode',
title: '联行号',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'regionName',
title: '所属国家和地区',
componentType: 'input',
align: 'left',
sorter: true,
},
{
dataIndex: 'swift',
title: 'SWIFT',
componentType: 'input',
align: 'left',
sorter: true,
},
];
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
const selectedKeys = ref<string[]>([]);
const selectedValues = ref([]);
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
rowId.value = data.record.id;
const record = await getCodeRuleInfo(data.record.id);
let datas = JSON.parse({ ...record }.formatJson);
datas.forEach((data) => {
if (!data.sortNum) {
data.sortNum = 0;
}
});
setTableData(datas);
} else {
setTableData([]);
}
});
const [registerTable, { getDataSource, setTableData, updateTableDataRecord }] = useTable({
title: t('银行列表'),
api: getLngBBankPage,
columns,
bordered: true,
pagination: true,
canResize: false,
formConfig: {
labelCol:{span: 9, offSet:10},
schemas: codeFormSchema,
showResetButton: true,
},
beforeFetch: (params) => {
return { ...params, valid: 'Y'};
},
rowSelection: {
type: 'radio',
onChange: onSelectChange
},
});
function onSelectChange(rowKeys: string[], e) {
selectedKeys.value = rowKeys;
selectedValues.value = e
}
const getTitle = computed(() => (!unref(isUpdate) ? t('银行列表') : t('')));
async function handleSubmit() {
if (!selectedValues.value.length) {
notification.warning({
message: t('提示'),
description: t('请选择银行')
});
return
}
closeModal();
emit('success', selectedValues.value);
// try {
// const values = await validate();
// let data = getDataSource();
// data.sort((a, b) => {
// return a.sortNum - b.sortNum;
// });
// values.formatJson = JSON.stringify(data);
// setModalProps({ confirmLoading: true });
// if (values.formatJson === '[]') {
// notification.warning({
// message: t('提示'),
// description: t('编码规则不能为空')
// });
// return;
// }
// // TODO custom api
// if (!unref(isUpdate)) {
// //false 新增
// await addCodeRule(values);
// notification.success({
// message: t('提示'),
// description: t('新增成功')
// }); //提示消息
// } else {
// values.id = rowId.value;
// await editCodeRule(values);
// notification.success({
// message: t('提示'),
// description: t('修改成功!')
// }); //提示消息
// }
// closeModal();
// emit('success');
// } finally {
// setModalProps({ confirmLoading: false });
// }
}
</script>
<style >
.bankListModal .basicCol{
position: inherit !important;
top: 0;
}
.bankListTb .ant-modal-wrap{
z-index: 1001 !important;
}
</style>

View File

@ -0,0 +1,117 @@
<template>
<BasicModal v-bind="$attrs" destroyOnClose @register="registerModal" showFooter :title="getTitle" @ok="handleSubmit" @cancel="handleCancel">
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="{labelCol: { span: 8 },wrapperCol: { span: 16 },}">
<a-row>
<a-col :span="12">
<a-form-item label="银行名称" name="bankName" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input-search v-model:value="formState.bankName" placeholder="请选择银行名称" readonly @search="onSearch"/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="联行号" name="aaaa" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.aaaa" placeholder="请输入联行号" disabled />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="账户名称" name="accountName" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.accountName" placeholder="请输入账户名称" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="银行账号" name="account" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.account" placeholder="请输入银行账号" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="默认银行" name="defaultSign" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-radio-group v-model:value="formState.defaultSign" style="display: flex;">
<a-radio v-for="item in optionList" :value="item.code">{{ item.name }}</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="备注" name="note" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.note" placeholder="请输入备注最多50字" :maxlength="50" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</BasicModal>
<bankListModal @register="registerModalBankList" @success="handleSuccessBankList" />
</template>
<script setup lang="ts">
import { ref, onMounted, computed, unref,reactive } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { Form } from 'ant-design-vue';
import { useI18n } from '/@/hooks/web/useI18n';
import type { Rule } from 'ant-design-vue/es/form';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDictionary } from '/@/api/sales/Customer';
import bankListModal from './bankListModal.vue'
import { useModal } from '/@/components/Modal';
const { t } = useI18n();
const isUpdate = ref(true);
const disable = ref(false);
let optionList = reactive([])
const formRef = ref()
const { notification } = useMessage();
const emit = defineEmits(['success','register']);
const getTitle = computed(() => (!unref(isUpdate) ? t('新增银行') : t('编辑银行')));
let formState = reactive({
});
const rules = {
bankName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
accountName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
account: [{ required: true, message: "该项为必填项", trigger: 'change' }],
defaultSign: [{ required: true, message: "该项为必填项", trigger: 'change' }],
};
const [registerModalBankList, { openModal:openModalBankList }] = useModal();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
getOption()
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
console.log(isUpdate, 8,!unref(isUpdate),data?.isUpdate )
disable.value = data?.btnType == 'view' ? true : false
if (unref(isUpdate)) {
formState=data.record || {}
}
});
onMounted(() => {
getOption()
});
async function getOption() {
optionList = await getDictionary('LNG_YN')
}
const onSearch = () => {
openModalBankList(true,{isUpdate: false})
}
const handleSuccessBankList = (val) => {
console.log(val, 414)
formState.bankCode = val[0].code
formState.bankName = val[0].fullName
formState.aaaa = val[0].bankCode
}
const handleCancel = () => {
formRef.value.resetFields();
}
const handleSubmit = async () => {
try {
await formRef.value.validate();
// 验证通过,提交表单
console.log('表单数据:', formState);
emit('success', {...formState});
notification.success({
message: t('操作'),
description:!unref(isUpdate)? t('新增成功') : t('编辑成功')
}); //提示消息
formRef.value.resetFields();
closeModal();
} catch (error) {
console.log('验证失败:', error);
}
};
</script>

View File

@ -1,5 +1,5 @@
<template>
<BasicModal v-bind="$attrs" destroyOnClose @register="registerModal" showFooter :title="getTitle" width="40%" @ok="handleSubmit">
<BasicModal v-bind="$attrs" destroyOnClose @register="registerModal" showFooter :title="getTitle" width="40%" @ok="handleSubmit" @cancel="handleCancel">
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="{labelCol: { span: 8 },wrapperCol: { span: 16 },}">
<a-row>
<a-col :span="24">
@ -52,6 +52,7 @@ import dayjs from 'dayjs';
const { t } = useI18n();
const isUpdate = ref(true);
const disable = ref(false);
let optionList = reactive([])
const fileTip = '支持格式.rar .zip .doc .docx .pdf 单个文件不能超过20MB';
const accept ='.rar,.zip, .doc, .docx, .pdf, .RAR, .ZIP, .DOC, .DOCX, .PDF'
@ -64,17 +65,13 @@ let formState = reactive({
});
const rules = {
docTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
// email: [
// { required: true, message: '请输入邮箱', trigger: 'blur' },
// { type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' },
// ],
};
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
getOption()
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
disable.value = data?.btnType == 'view' ? true : false
if (unref(isUpdate)) {
formState=data.record || {}
}
@ -104,11 +101,13 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
async function getOption() {
optionList = await getDocCpList({'valid': 'Y'})
}
const handleCancel = () => {
formRef.value.resetFields();
}
const handleSubmit = async () => {
try {
await formRef.value.validate();
// 验证通过,提交表单
console.log('表单数据:', formState);
let docNo = (optionList.find(v=>v.code === formState.docTypeCode) || {}).fullName
let obj = {
...formState,

View File

@ -26,6 +26,7 @@
field: 'tel',
label: t('联系人电话'),
component: 'Input',
required: true,
colProps: { lg: 12, md: 12 }
},
{
@ -33,9 +34,9 @@
label: t('电子邮箱'),
component: 'Input',
colProps: { lg: 12, md: 12 },
componentProps: {
rules: [{ pattern: '/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/', message: '邮箱格式错误\n' }],
},
rules: [{ type: 'email', message: '邮箱格式错误\n' }],
},
{
field: 'position',