Merge branch 'dev' of http://47.94.165.164:13000/geg-gas/geg-gas-web into dev
This commit is contained in:
206
src/views/sales/Customer/components/bankListModal.vue
Normal file
206
src/views/sales/Customer/components/bankListModal.vue
Normal 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>
|
||||
117
src/views/sales/Customer/components/bankModal.vue
Normal file
117
src/views/sales/Customer/components/bankModal.vue
Normal 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>
|
||||
@ -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,
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -6,10 +6,10 @@
|
||||
<a-button style="margin-right: 10px" @click="close">
|
||||
<slot name="icon"><close-outlined /></slot>取消
|
||||
</a-button>
|
||||
<a-button v-if="mode != 'view'" style="margin-right: 10px" type="primary" @click="handleSubmit">
|
||||
<a-button v-if="mode != 'view'" style="margin-right: 10px" type="primary" @click="handleSubmit('save')">
|
||||
<slot name="icon"><save-outlined /></slot>保存
|
||||
</a-button>
|
||||
<a-button v-if="mode != 'view'" style="margin-right: 10px" type="primary" @click="handleSubmit">
|
||||
<a-button v-if="mode != 'view'" style="margin-right: 10px" type="primary" @click="handleSubmit('submit')">
|
||||
<slot name="icon"><check-circle-outlined /></slot>保存并提交
|
||||
</a-button>
|
||||
<a-button v-if="mode != 'view'" style="margin-right: 10px" type="primary" @click="handleSubmit">
|
||||
@ -45,13 +45,13 @@
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="客户名称" name="cuName" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
|
||||
<a-textarea v-model:value="formState.cuName" placeholder="请输入客户名称" :auto-size="{ minRows: 1, maxRows: 5 }"/>
|
||||
<a-form-item label="客户名称" name="cuSname" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
|
||||
<a-textarea v-model:value="formState.cuSname" placeholder="请输入客户名称" :auto-size="{ minRows: 1, maxRows: 5 }"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-form-item label="客户简称" name="cuSname">
|
||||
<a-input v-model:value="formState.cuSname" placeholder="请输入客户简称" />
|
||||
<a-form-item label="客户简称" name="di">
|
||||
<a-input v-model:value="formState.di" placeholder="请输入客户简称" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
@ -235,15 +235,15 @@
|
||||
<span style="font-size: 12px;font-weight: normal;">(需上传证书营业执照,危险化学品许可证/燃气经营许可证/危险化学品道路运输许可证等证书。)</span>
|
||||
</div>
|
||||
</template>
|
||||
<a-button v-if="mode != 'view'" type="primary" @click="handleAdd('certificate')">新增证书</a-button>
|
||||
<a-button v-if="mode != 'view'" type="primary" style="margin-bottom: 10px;" @click="handleAdd('certificate')">新增证书</a-button>
|
||||
<a-table :columns="columnsCertificate" :data-source="dataCertificate" >
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.dataIndex === 'operation'">
|
||||
<a style="margin-right: 10px" @click="btnCheck('certificate', 'edit', record)">编辑</a>
|
||||
<a style="margin-right: 10px" @click="btnCheck('certificate', 'delete', record)">删除</a>
|
||||
<a style="margin-right: 10px" @click="btnCheck('certificate', 'delete', record, index)">删除</a>
|
||||
<a style="margin-right: 10px" @click="btnCheck('certificate', 'view', record)">查看</a>
|
||||
<ArrowUpOutlined style="margin-right: 10px;" class="btn" @click="btnCheck('certificate', 'up', record, column.index)" />
|
||||
<ArrowDownOutlined class="btn" @click="btnCheck('certificate', 'down', record, column.index)" />
|
||||
<ArrowUpOutlined style="margin-right: 10px;" class="btn" @click="btnCheck('certificate', 'up', record, index)" />
|
||||
<ArrowDownOutlined class="btn" @click="btnCheck('certificate', 'down', record, index)" />
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
@ -256,8 +256,14 @@
|
||||
<span style="font-size: 12px;font-weight: normal;">(至少填写一条银行信息)</span>
|
||||
</div>
|
||||
</template>
|
||||
<a-button v-if="mode != 'view'" type="primary" @click="handleAdd('bank')">新增银行账户</a-button>
|
||||
<a-button v-if="mode != 'view'" type="primary" style="margin-bottom: 10px;" @click="handleAdd('bank')">新增银行账户</a-button>
|
||||
<a-table :columns="columnsBank" :data-source="dataBank" >
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.dataIndex === 'operation'">
|
||||
<a style="margin-right: 10px" @click="btnCheck('bank', 'edit', record)">编辑</a>
|
||||
<a style="margin-right: 10px" @click="btnCheck('bank', 'delete', record, index)">删除</a>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
<a-card :bordered="false" >
|
||||
@ -268,12 +274,12 @@
|
||||
<span style="font-size: 12px;font-weight: normal;">(至少填写一条联系人信息)</span>
|
||||
</div>
|
||||
</template>
|
||||
<a-button v-if="mode != 'view'" type="primary" @click="handleAdd('contact')">新增联系人</a-button>
|
||||
<a-button v-if="mode != 'view'" type="primary" style="margin-bottom: 10px;" @click="handleAdd('contact')">新增联系人</a-button>
|
||||
<a-table :columns="columnsContact" :data-source="dataContact" >
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.dataIndex === 'operation'">
|
||||
<a style="margin-right: 10px" @click="btnCheck('contact', 'edit', record)">编辑</a>
|
||||
<a style="margin-right: 10px" @click="btnCheck('contact', 'delete', record)">删除</a>
|
||||
<a style="margin-right: 10px" @click="btnCheck('contact', 'delete', record, index)">删除</a>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
@ -286,10 +292,11 @@
|
||||
</div>
|
||||
</template>
|
||||
<a-upload
|
||||
v-model:file-list="fileList"
|
||||
:multiple="true"
|
||||
:showUploadList="false"
|
||||
name="file"
|
||||
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
||||
:action="data.action"
|
||||
:headers="data.headers"
|
||||
@change="handleChangeFile"
|
||||
>
|
||||
<a-button>
|
||||
@ -298,6 +305,19 @@
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<a-table :columns="columnsFile" :data-source="dataFile" >
|
||||
<template #bodyCell="{ column,record,index, text }">
|
||||
<template v-if="column.dataIndex === 'fileOrg'">
|
||||
<a :href="record.filePath" :download="record.fileOrg" target="_blank">{{record.fileOrg}}</a>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'docDesc'">
|
||||
<a-input :placeholder="t('请输入附件说明')" v-model:value="record.docDesc" />
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'operation'">
|
||||
<a style="margin-right: 10px" @click="btnCheck('file', 'delete', record, index)">删除</a>
|
||||
<ArrowUpOutlined style="margin-right: 10px;" class="btn" @click="btnCheck('file', 'up', record, index)" />
|
||||
<ArrowDownOutlined class="btn" @click="btnCheck('file', 'down', record, index)" />
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</a-form>
|
||||
@ -305,6 +325,7 @@
|
||||
</a-spin>
|
||||
<certificateModal @register="registerCertificate" @success="handleSuccessCertificate" />
|
||||
<contactModal @register="registerContact" @success="handleSuccessContact" />
|
||||
<bankModal @register="registerBank" @success="handleSuccessBank"/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@ -320,9 +341,15 @@
|
||||
import { getDictionary } from '/@/api/sales/Customer';
|
||||
import certificateModal from './components/certificateModal.vue';
|
||||
import contactModal from './components/contactModal.vue';
|
||||
import bankModal from './components/bankModal.vue';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { validateScript } from '/@/utils/event/design';
|
||||
|
||||
import { addLngCustomer,updateLngCustomer,getLngCustomer } from '/@/api/sales/Customer';
|
||||
import dayjs from 'dayjs';
|
||||
import { getAppEnvConfig } from '/@/utils/env';
|
||||
import { getToken } from '/@/utils/auth';
|
||||
import { uploadSrc, uploadBlobApi } from '/@/api/sys/upload';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
const dynamicComponent = ref(null);
|
||||
const formType = ref('2'); // 0 新建 1 修改 2 查看
|
||||
const formRef = ref();
|
||||
@ -338,24 +365,22 @@ import { validateScript } from '/@/utils/event/design';
|
||||
const tabStore = useMultipleTabStore();
|
||||
const formProps = ref(null);
|
||||
const formId = ref(currentRoute.value?.params?.id);
|
||||
|
||||
const pageType = ref(currentRoute.value?.params?.type);
|
||||
const pageId = ref(currentRoute.value?.params?.id || '');
|
||||
const spinning = ref(false);
|
||||
|
||||
const { notification } = useMessage();
|
||||
const { t } = useI18n();
|
||||
const hash = location.hash || location.pathname;
|
||||
const mode = ref('read');
|
||||
if (hash.indexOf('createForm') > 0) {
|
||||
mode.value = 'create';
|
||||
} else if (hash.indexOf('updateForm') > 0) {
|
||||
mode.value = 'update';
|
||||
} else if (hash.indexOf('viewForm') > 0) {
|
||||
mode.value = 'view';
|
||||
}
|
||||
|
||||
const data = reactive({
|
||||
info: {},
|
||||
action: '',
|
||||
headers: { Authorization: '' },
|
||||
photoUrl: '',
|
||||
});
|
||||
const formState = reactive({
|
||||
valid: 'Y',
|
||||
approCode: 'WTJ',
|
||||
tSign: 'N',
|
||||
lngCustomerAttrPowerList:[
|
||||
{
|
||||
"capacity": '',
|
||||
@ -366,11 +391,12 @@ import { validateScript } from '/@/utils/event/design';
|
||||
|
||||
const [registerCertificate, { openModal:openModalCertificate }] = useModal();
|
||||
const [registerContact, { openModal:openModalContact }] = useModal();
|
||||
const [registerBank, { openModal:openModalBank}] = useModal();
|
||||
|
||||
const fileList = reactive([])
|
||||
const rules: Record<string, Rule[]> = {
|
||||
cuMcode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
|
||||
cuName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
|
||||
di: [{ required: true, message: "该项为必填项", trigger: 'change' }],
|
||||
cuSname: [{ required: true, message: "该项为必填项", trigger: 'change'}],
|
||||
natureCode: [{ required: true, message: "该项为必填项", trigger: 'change'}],
|
||||
classCode: [{ required: true, message: "该项为必填项", trigger: 'change'}],
|
||||
@ -378,6 +404,7 @@ import { validateScript } from '/@/utils/event/design';
|
||||
prepaySign: [{ required: true, message: "该项为必填项", trigger: 'change'}],
|
||||
onlineSign: [{ required: true, message: "该项为必填项", trigger: 'change'}],
|
||||
rateShare: [{ required: false, message: "该项为必填项", trigger: 'change'}],
|
||||
tSign: [{ required: false, message: "该项为必填项", trigger: 'change'}],
|
||||
};
|
||||
const layout = {
|
||||
labelCol: { span: 9 },
|
||||
@ -434,8 +461,22 @@ import { validateScript } from '/@/utils/event/design';
|
||||
|
||||
onMounted(() => {
|
||||
getOption()
|
||||
if (pageId.value) {
|
||||
getList(pageId.value)
|
||||
}
|
||||
data.action = getAppEnvConfig().VITE_GLOB_API_URL + uploadSrc;
|
||||
data.headers.Authorization = `Bearer ${getToken()}`;
|
||||
|
||||
});
|
||||
async function getList(id) {
|
||||
let data = await getLngCustomer(id)
|
||||
Object.assign(formState, {...data})
|
||||
formState.lngCustomerAttrPowerList = formState.lngCustomerAttrPowerList || [{}]
|
||||
Object.assign(dataBank, formState.lngCustomerBankList || [])
|
||||
Object.assign(dataCertificate, formState.lngCustomerDocList || [])
|
||||
Object.assign(dataContact, formState.lngCustomerContactList || [])
|
||||
Object.assign(dataUpload, formState.lngFileUploadList || [])
|
||||
}
|
||||
async function getOption() {
|
||||
optionSelect.cuMcodeList = await getDictionary('LNG_ENT_PR')
|
||||
optionSelect.natureCodeList = await getDictionary('LNG_NATURE')
|
||||
@ -461,44 +502,122 @@ import { validateScript } from '/@/utils/event/design';
|
||||
}
|
||||
const handleAdd = (val)=> {
|
||||
if (val ==='certificate') {
|
||||
openModalCertificate(true,);
|
||||
openModalCertificate(true,{isUpdate: false});
|
||||
}
|
||||
if (val ==='contact'){
|
||||
openModalContact(true, {});
|
||||
}
|
||||
if (val == 'bank'){
|
||||
openModalBank(true,{isUpdate: false})
|
||||
}
|
||||
|
||||
}
|
||||
const btnCheck = (type, btn, record, index) => {
|
||||
console.log(index, 555, type, )
|
||||
// 证书
|
||||
if (type == 'certificate') {
|
||||
if (btn == 'edit') {
|
||||
openModalCertificate(true, {record: record,isUpdate: true});
|
||||
if (btn == 'edit' || btn == 'view') {
|
||||
openModalCertificate(true, {record: record,isUpdate: true, btnType: btn});
|
||||
}
|
||||
if (type === 'delete') {
|
||||
if (btn == 'delete') {
|
||||
dataCertificate.splice(index, 1)
|
||||
}
|
||||
if (btn == 'up') {
|
||||
if (index === 0) {
|
||||
return
|
||||
}
|
||||
dataCertificate[index] = dataCertificate.splice(index-1, 1, dataCertificate[index])[0];
|
||||
}
|
||||
if (btn == 'down') {
|
||||
if (index === dataCertificate.length - 1) {
|
||||
return
|
||||
}
|
||||
dataCertificate[index] = dataCertificate.splice(index+1, 1, dataCertificate[index])[0];
|
||||
}
|
||||
}
|
||||
|
||||
// 联系人
|
||||
if (type == 'contact') {
|
||||
if (btn == 'edit') {
|
||||
openModalContact(true, {record: record,isUpdate: true});
|
||||
}
|
||||
if (type === 'delete') {
|
||||
if (btn == 'delete') {
|
||||
dataContact.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 银行
|
||||
if (type == 'bank') {
|
||||
if (btn == 'edit') {
|
||||
openModalBank(true, {record: record,isUpdate: true});
|
||||
}
|
||||
if (btn == 'delete') {
|
||||
dataBank.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 附件
|
||||
if (type == 'file') {
|
||||
if (btn == 'delete') {
|
||||
dataFile.splice(index, 1)
|
||||
}
|
||||
if (btn == 'up') {
|
||||
if (index === 0) {
|
||||
return
|
||||
}
|
||||
dataFile[index] = dataFile.splice(index-1, 1, dataFile[index])[0];
|
||||
}
|
||||
if (btn == 'down') {
|
||||
if (index === dataFile.length - 1) {
|
||||
return
|
||||
}
|
||||
dataFile[index] = dataFile.splice(index+1, 1, dataFile[index])[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
const swapItems = (arr, index1, index2,direction) =>{
|
||||
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
|
||||
return arr;
|
||||
};
|
||||
const handleSuccessCertificate = (val) => {
|
||||
let idx =dataCertificate.findIndex(v => v.docTypeCode == val.docTypeCode)
|
||||
if (!idx) {
|
||||
if (idx <0) {
|
||||
dataCertificate.push(val)
|
||||
}
|
||||
}
|
||||
const handleSuccessContact = (val)=> {
|
||||
dataContact.push(val)
|
||||
}
|
||||
function handleChangeFile(val) {
|
||||
const handleSuccessBank = (val) => {
|
||||
dataBank.push(val)
|
||||
}
|
||||
function handleChangeFile(info) {
|
||||
console.log(info, 'info', info.file.status)
|
||||
if (info.file.status !== 'uploading') {
|
||||
}
|
||||
if (info.file.status === 'done') {
|
||||
if (info.file && info.file.response && info.file.response.code == 0) {
|
||||
message.success(t(`{name}上传成功!`, { name: info.file.name }));
|
||||
console.log(info, t('上传成功'));
|
||||
// 存储原始URL到info.fileUrl(用于提交)(改了)
|
||||
data.info.fileUrl = info.file.response.data.fileUrl;
|
||||
data.fileName = info.file.response.data.fileName;
|
||||
|
||||
// 显示使用fileUrlFixed(如果有),否则使用fileUrl (改了)
|
||||
data.photoUrl = info.file.response.data.fileUrlFixed || info.file.response.data.fileUrl;
|
||||
|
||||
let obj = {
|
||||
fileOrg: data.fileName,
|
||||
filePath: data.photoUrl,
|
||||
}
|
||||
dataFile.push(obj)
|
||||
|
||||
} else {
|
||||
message.error(t('上传照片失败'));
|
||||
}
|
||||
} else if (info.file.status === 'error') {
|
||||
message.error(t(`{name}上传失败.`, { name: info.file.name }));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -525,37 +644,70 @@ import { validateScript } from '/@/utils/event/design';
|
||||
}
|
||||
|
||||
function close() {
|
||||
tabStore.closeTab(currentRoute.value, router);
|
||||
tabStore.closeTab(currentRoute.value, router);
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value.validateFields();
|
||||
console.log(44454)
|
||||
return true;
|
||||
} catch (errorInfo) {
|
||||
console.log(444)
|
||||
return false;
|
||||
async function handleSubmit(type) {
|
||||
try {
|
||||
await formRef.value.validateFields();
|
||||
if (!dataBank.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: '请添加银行信息'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!dataCertificate.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: '请添加资质证书'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!dataContact.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: '请添加联系人'
|
||||
})
|
||||
return
|
||||
}
|
||||
let obj = {
|
||||
...formState,
|
||||
lngCustomerBankList: dataBank,
|
||||
lngCustomerDocList: dataCertificate,
|
||||
lngCustomerContactList: dataContact,
|
||||
|
||||
|
||||
}
|
||||
spinning.value = true;
|
||||
let request = pageType.value === 'add' ? addLngCustomer :updateLngCustomer
|
||||
|
||||
try {
|
||||
obj.lngCustomerDocList.forEach(v => {
|
||||
v.dateFrom = dayjs(v.dateFrom ).valueOf()
|
||||
v.dateTo = dayjs(v.dateTo ).valueOf()
|
||||
})
|
||||
await request(obj);
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: pageType.value === 'add' ? t('新增成功!') : t('修改成功!')
|
||||
}); //提示消息
|
||||
formRef.value.resetFields();
|
||||
setTimeout(() => {
|
||||
bus.emit(FORM_LIST_MODIFIED, { path: formPath });
|
||||
close();
|
||||
}, 1000);
|
||||
|
||||
} finally {
|
||||
spinning.value = false;
|
||||
}
|
||||
|
||||
return
|
||||
spinning.value = true;
|
||||
try {
|
||||
const saveSuccess = await saveModal();
|
||||
if (saveSuccess) {
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: formType.value === '0' ? t('新增成功!') : t('修改成功!')
|
||||
}); //提示消息
|
||||
formRef.value.resetFields();
|
||||
setTimeout(() => {
|
||||
bus.emit(FORM_LIST_MODIFIED, { path: formPath, mode });
|
||||
close();
|
||||
}, 1000);
|
||||
}
|
||||
} finally {
|
||||
spinning.value = false;
|
||||
}
|
||||
} catch (errorInfo) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: '请完善信息'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function saveModal() {
|
||||
|
||||
@ -204,7 +204,8 @@
|
||||
query: {
|
||||
formPath: 'sales/Customer',
|
||||
formName: formName,
|
||||
formId:currentRoute.value.meta.formId
|
||||
formId:currentRoute.value.meta.formId,
|
||||
type:'add'
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -213,11 +214,13 @@
|
||||
function handleEdit(record: Recordable) {
|
||||
|
||||
router.push({
|
||||
path: '/form/Customer/' + record.id + '/updateForm',
|
||||
path: '/form/Customer/' + record.id + '/createFormCustomer',
|
||||
query: {
|
||||
formPath: 'sales/Customer',
|
||||
formName: formName,
|
||||
formId:currentRoute.value.meta.formId
|
||||
formId:currentRoute.value.meta.formId,
|
||||
type:'edit',
|
||||
id: record.id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user