This commit is contained in:
‘huanghaiixia’
2025-11-21 16:38:17 +08:00
parent 0f112bc78e
commit 65575b40ad
7 changed files with 903 additions and 36 deletions

View File

@ -12,6 +12,8 @@ enum Api {
Enable = '/sales/customer/enable', Enable = '/sales/customer/enable',
Disable= '/sales/customer/disable', Disable= '/sales/customer/disable',
dictionary = '/system/dictionary-detail',
docCpList ='/mdm/docCp/queryList'
} }
@ -119,3 +121,33 @@ export async function disableLngCustomer(ids: string[], mode: ErrorMessageMode =
}, },
); );
} }
/**
* @description: 获取数据字典
*/
export async function getDictionary(itemCode: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<LngCustomerPageModel>(
{
url: Api.dictionary,
params: { itemCode },
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 查询LngCustomer分页列表
*/
export async function getDocCpList(params: LngCustomerPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<LngCustomerPageResult>(
{
url: Api.docCpList,
params,
},
{
errorMessageMode: mode,
},
);
}

View File

@ -223,6 +223,14 @@ export const FLOW_ROUTE: AppRouteRecordRaw[] = [{
meta: { meta: {
title: (route) => '查看'+(route.query.formName||'表单') title: (route) => '查看'+(route.query.formName||'表单')
} }
},
{
path: 'createFormCustomer',
name: 'createFormCustomer',
component: () => import('/@/views/sales/Customer/formCreatePage.vue'),
meta: {
title: (route) => '新建'+(route.query.formName||'表单')
}
} }
] ]
}]; }];

View File

@ -0,0 +1,130 @@
<template>
<BasicModal v-bind="$attrs" destroyOnClose @register="registerModal" showFooter :title="getTitle" width="40%" @ok="handleSubmit">
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="{labelCol: { span: 8 },wrapperCol: { span: 16 },}">
<a-row>
<a-col :span="24">
<a-form-item label="证书名称" name="docTypeCode" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<a-select v-model:value="formState.docTypeCode" placeholder="请选择证书名称" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionList" :key="item.code" :value="item.code">
{{ item.fullName }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="有效期开始" name="dateFrom" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-date-picker v-model:value="formState.dateFrom" format="YYYY-MM-DD" :disabled-date="disabledDateStart" style="width: 100%" placeholder="请选择有效期开始" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="有效期结束" name="dateTo" :label-col="{ span: 8 }" :wrapper-col="{ span: 24 }">
<a-date-picker v-model:value="formState.dateTo" format="YYYY-MM-DD" :disabled-date="disabledDateEnd" style="width: 100%" placeholder="请选择有效期结束" />
</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-col :span="24">
<a-form-item label="上传附件" name="parentNname" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<Upload :fileList="formState.fileList" :maxSize="200" :accept="accept"></Upload>
<div style="color: #ccc; font-size: 12px">{{ fileTip }}</div>
</a-form-item>
</a-col>
</a-row>
</a-form>
</BasicModal>
</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 Upload from '/@/components/Form/src/components/Upload.vue';
import { getDocCpList } from '/@/api/sales/Customer';
import type { FormInstance } from 'ant-design-vue';
import dayjs from 'dayjs';
const { t } = useI18n();
const isUpdate = ref(true);
let optionList = reactive([])
const fileTip = '支持格式.rar .zip .doc .docx .pdf 单个文件不能超过20MB';
const accept ='.rar,.zip, .doc, .docx, .pdf, .RAR, .ZIP, .DOC, .DOCX, .PDF'
const formRef = ref()
const { notification } = useMessage();
const emit = defineEmits(['success','register']);
const getTitle = computed(() => (!unref(isUpdate) ? t('新增证书') : t('编辑证书')));
let formState = reactive({
docTypeCode: '',
});
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;
if (unref(isUpdate)) {
formState=data.record || {}
}
});
onMounted(() => {
getOption()
});
const disabledDateStart = (startValue) => {
const endValue = formState.dateTo;
if (!startValue || !endValue) {
return false
}
return startValue.valueOf() >= endValue.valueOf();
}
const disabledDateEnd = (endValue) => {
const startValue = formState.dateFrom;
if (!endValue || !startValue) {
return false
}
return endValue.valueOf() <= startValue.valueOf();
}
const handleChangeFile = (val) => {
}
async function getOption() {
optionList = await getDocCpList({'valid': 'Y'})
}
const handleSubmit = async () => {
try {
await formRef.value.validate();
// 验证通过,提交表单
console.log('表单数据:', formState);
let docNo = (optionList.find(v=>v.code === formState.docTypeCode) || {}).fullName
let obj = {
...formState,
docNo: docNo,
dateFrom: formState.dateFrom ? dayjs(formState.dateFrom).format('YYYY-MM-DD') : null,
dateTo: formState.dateTo ? dayjs(formState.dateTo).format('YYYY-MM-DD') : null,
}
emit('success', obj);
notification.success({
message: t('操作'),
description:!unref(isUpdate)? t('新增成功') : t('编辑成功')
}); //提示消息
formRef.value.resetFields();
closeModal();
} catch (error) {
console.log('验证失败:', error);
}
};
</script>

View File

@ -6,46 +6,12 @@ export const formConfig = {
}; };
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{
field: 'cuCode',
label: '客户编码',
component: 'Input',
},
{ {
field: 'cuName', field: 'cuName',
label: '客户名称', label: '客户名称',
component: 'Input', component: 'Input',
}, },
{
field: 'cuSname',
label: '客户简称',
component: 'Input',
},
{
field: 'cuMcode',
label: '企业性质',
component: 'Input',
},
{
field: 'classCode',
label: '客户分类',
component: 'Input',
},
{
field: 'typeCode',
label: '客户类别',
component: 'Input',
},
{
field: 'natureCode',
label: '国内国际',
component: 'Input',
},
{
field: 'valid',
label: '有效',
component: 'Input',
},
{ {
field: 'approCode', field: 'approCode',
label: '审批状态', label: '审批状态',

View File

@ -0,0 +1,122 @@
<template>
<BasicModal v-bind="$attrs" destroyOnClose @register="registerDrawer" showFooter :title="getTitle" width="40%" @ok="handleSubmit">
<BasicForm @register="registerForm" :style="{ 'margin-right': '10px' }" />
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, computed, unref } from 'vue';
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { usePermissionStore } from '/@/store/modules/permission';
import { addSubSystem, updateSubSystem } from '/@/api/system/subSystem';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
import { useAppInject } from '/@/hooks/web/useAppInject';
const { t } = useI18n();
export const formSchema: FormSchema[] = [
{
field: 'contactName',
label: t('联系人姓名'),
component: 'Input',
required: true,
colProps: { lg: 12, md: 12 }
},
{
field: 'tel',
label: t('联系人电话'),
component: 'Input',
colProps: { lg: 12, md: 12 }
},
{
field: 'email',
label: t('电子邮箱'),
component: 'Input',
colProps: { lg: 12, md: 12 },
componentProps: {
rules: [{ pattern: '/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/', message: '邮箱格式错误\n' }],
},
},
{
field: 'position',
label: t('职位'),
component: 'Input',
colProps: { lg: 12, md: 12 }
},
{
field: 'addrMail',
label: t('通讯地址'),
component: 'InputTextArea',
colProps: { lg: 24, md: 24 }
},
{
field: 'note',
label: t('备注'),
component: 'InputTextArea',
colProps: { lg: 24, md: 24 }
},
];
export default defineComponent({
name: 'MenuDrawer',
components: {
BasicModal,
BasicForm
},
emits: ['success', 'register'],
setup(_, { emit }) {
const isUpdate = ref(true);
const { notification } = useMessage();
const permissionStore = usePermissionStore();
const { t } = useI18n();
const { getShowTopMenu } = useMenuSetting();
const { getIsMobile } = useAppInject();
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { lg: 12, md: 24 }
});
const [registerDrawer, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
setFieldsValue({
...data.record
});
}
});
const getTitle = computed(() => (!unref(isUpdate) ? t('新增联系人') : t('编辑联系人')));
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
notification.success({
message: t('操作'),
description:!unref(isUpdate)? t('新增成功') : t('编辑成功')
}); //提示消息
closeModal();
emit('success', values);
} catch (error) {
setModalProps({ confirmLoading: false });
}
}
return {
registerDrawer,
registerForm,
getTitle,
handleSubmit,
t
};
}
});
</script>
<style scoped></style>

View File

@ -0,0 +1,609 @@
<template>
<a-spin :spinning="spinning" tip="请稍后...">
<div class="page-bg-wrap">
<div class="top-toolbar" id="formViewPage">
<a-space :size="10" wrap style="gap: 0">
<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">
<slot name="icon"><save-outlined /></slot>保存
</a-button>
<a-button v-if="mode != 'view'" style="margin-right: 10px" type="primary" @click="handleSubmit">
<slot name="icon"><check-circle-outlined /></slot>保存并提交
</a-button>
<a-button v-if="mode != 'view'" style="margin-right: 10px" type="primary" @click="handleSubmit">
<slot name="icon"><download-outlined /></slot>下载模板
</a-button>
<a-button v-if="mode != 'view'" type="primary" @click="handleSubmit">
<slot name="icon"><upload-outlined /></slot>导入
</a-button>
</a-space>
</div>
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="layout">
<a-card title="客户基本信息" :bordered="false" >
<div>
<h4>基本信息</h4>
<a-row>
<a-col :span="8">
<a-form-item label="客户编码" name="cuCode">
<a-input v-model:value="formState.cuCode" disabled />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="集团编码" name="cuName">
<a-input v-model:value="formState.cuName" placeholder="请输入集团编码" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="企业性质" name="cuMcode">
<a-select v-model:value="formState.cuMcode" placeholder="请选择企业性质" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.cuMcodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</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>
</a-col>
<a-col :span="8">
<a-form-item label="客户简称" name="cuSname">
<a-input v-model:value="formState.cuSname" placeholder="请输入客户简称" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="国内/国际" name="natureCode">
<a-select v-model:value="formState.natureCode" placeholder="请选择国内/国际" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.natureCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="母公司名称" name="parentNname">
<a-input v-model:value="formState.parentNname" placeholder="请输入母公司名称" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="统一社会信用代码" name="creditNo">
<a-input v-model:value="formState.creditNo" placeholder="请输入统一社会信用代码" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="纳税人识别号" name="tiNo">
<a-input v-model:value="formState.tiNo" placeholder="请输入纳税人识别号" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="法定代表人" name="representative">
<a-input v-model:value="formState.representative" placeholder="请输入法定代表人" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="成立日期" name="dateEstab">
<a-date-picker v-model:value="formState.dateEstab" style="width: 100%" placeholder="请选择成立日期" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="准入时间" name="dateEntry">
<a-date-picker v-model:value="formState.dateEntry" style="width: 100%" placeholder="请选择准入时间" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="注册资本(万元)" name="amtReg">
<a-input-number v-model:value="formState.amtReg" :min="0" style="width: 100%" placeholder="请输入注册资本"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="注册地址" name="addrReg" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.addrReg" placeholder="请输入注册地址" :auto-size="{ minRows: 1, maxRows: 5 }"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="通讯地址" name="addrMail" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.addrMail" placeholder="请输入通讯地址" :auto-size="{ minRows: 1, maxRows: 5 }"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="是否有效" name="valid">
<a-select v-model:value="formState.valid" disabled style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.validList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="审批状态" name="approCode">
<a-select v-model:value="formState.approCode" disabled style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.approCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="备注" name="note" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.note" placeholder="请输入备注最多200字" :maxlength="200" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
</a-row>
</div>
<div>
<h4>资信/业务信息</h4>
<a-row>
<a-col :span="8">
<a-form-item label="客户分类" name="classCode">
<a-select v-model:value="formState.classCode" placeholder="请选择客户分类" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.classCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="客户类别" name="typeCode">
<a-select v-model:value="formState.typeCode" placeholder="请选择客户类别" @change="typeCodeChange" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.typeCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="统计分类" name="propCode">
<a-select v-model:value="formState.propCode" placeholder="请选择统计分类" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.propCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="国有企业持股" name="stateSign" :offset="8">
<div style="display: flex;">
<a-radio-group v-model:value="formState.stateSign" style="display: flex;" @change="stateSignChange">
<a-radio v-for="item in optionSelect.signList" :value="item.code">{{ item.name }}</a-radio>
</a-radio-group>
<a-form-item label="持股比例" name="rateShare" style="position: relative;">
<a-input-number v-model:value="formState.rateShare" :disabled="formState.stateSign!='Y'" :min="0" :max="100"></a-input-number>
<span class="rateStyle">%</span>
</a-form-item>
</div>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="第一大股东名称" name="shareName">
<a-input v-model:value="formState.shareName" placeholder="请输入第一大股东名称" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="集团持股比例" name="rateShareGn">
<a-input-number v-model:value="formState.rateShareGn" style="width: 100%" :min="0" :max="100"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="预付款校验" name="prepaySign">
<a-radio-group v-model:value="formState.prepaySign">
<a-radio v-for="item in optionSelect.signList" :value="item.code">{{ item.name }}</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="竞拍" name="onlineSign">
<a-radio-group v-model:value="formState.onlineSign">
<a-radio v-for="item in optionSelect.signList" :value="item.code">{{ item.code == 'Y'?'': '' }}</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="自有终端" name="tSign">
<a-radio-group v-model:value="formState.tSign">
<a-radio v-for="item in optionSelect.signList" :value="item.code">{{ item.name }}</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
</a-row>
<div style="display:flex">
<h4>电厂业务信息</h4>
<div style="font-size: 12px;">客户类别为 电厂 时填写</div>
</div>
<a-row>
<a-col :span="8">
<a-form-item label="装机量(万KW)" name="capacity">
<a-input-number v-model:value="formState.lngCustomerAttrPowerList[0].capacity" :disabled="formState.typeCode!='DC'" style="width: 100%" :min="0" placeholder="请输入机量"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="备注" name="note" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.lngCustomerAttrPowerList[0].note" :disabled="formState.typeCode!='DC'" placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
</a-row>
</div>
</a-card>
<a-card :bordered="false" >
<template #title>
<div style="display: flex; align-items: center;">
<span style="color: red;">*</span>
<span style="margin-left: 8px;">资质证书信息</span>
<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-table :columns="columnsCertificate" :data-source="dataCertificate" >
<template #bodyCell="{ column, record }">
<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', '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)" />
</template>
</template>
</a-table>
</a-card>
<a-card :bordered="false" >
<template #title>
<div style="display: flex; align-items: center;">
<span style="color: red;">*</span>
<span style="margin-left: 8px;">银行账户信息</span>
<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-table :columns="columnsBank" :data-source="dataBank" >
</a-table>
</a-card>
<a-card :bordered="false" >
<template #title>
<div style="display: flex; align-items: center;">
<span style="color: red;">*</span>
<span style="margin-left: 8px;">联系人信息</span>
<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-table :columns="columnsContact" :data-source="dataContact" >
<template #bodyCell="{ column, record }">
<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>
</template>
</template>
</a-table>
</a-card>
<a-card :bordered="false" >
<template #title>
<div style="display: flex; align-items: center;">
<span style="margin-left: 8px;">附件信息</span>
<span style="font-size: 12px;font-weight: normal;">上传公司财报等附件</span>
</div>
</template>
<a-upload
v-model:file-list="fileList"
:multiple="true"
name="file"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
@change="handleChangeFile"
>
<a-button>
<upload-outlined></upload-outlined>
上传
</a-button>
</a-upload>
<a-table :columns="columnsFile" :data-source="dataFile" >
</a-table>
</a-card>
</a-form>
</div>
</a-spin>
<certificateModal @register="registerCertificate" @success="handleSuccessCertificate" />
<contactModal @register="registerContact" @success="handleSuccessContact" />
</template>
<script lang="ts" setup>
import { useRouter } from 'vue-router';
import { FromPageType } from '/@/enums/workflowEnum';
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent, reactive, defineComponent} from 'vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { CheckCircleOutlined, StopOutlined, CloseOutlined, UploadOutlined, SaveOutlined, DownloadOutlined,ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons-vue';
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
import useEventBus from '/@/hooks/event/useEventBus';
import type { Rule } from 'ant-design-vue/es/form';
import { getDictionary } from '/@/api/sales/Customer';
import certificateModal from './components/certificateModal.vue';
import contactModal from './components/contactModal.vue';
import { useModal } from '/@/components/Modal';
import { validateScript } from '/@/utils/event/design';
const dynamicComponent = ref(null);
const formType = ref('2'); // 0 新建 1 修改 2 查看
const formRef = ref();
const props = defineProps({});
const { bus, FORM_LIST_MODIFIED } = useEventBus();
const router = useRouter();
const { currentRoute } = router;
const { formPath } = currentRoute.value.query;
const pathArr = formPath.split('/');
const tabStore = useMultipleTabStore();
const formProps = ref(null);
const formId = 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 formState = reactive({
valid: 'Y',
approCode: 'WTJ',
lngCustomerAttrPowerList:[
{
"capacity": '',
"note": null,
}
]
});
const [registerCertificate, { openModal:openModalCertificate }] = useModal();
const [registerContact, { openModal:openModalContact }] = useModal();
const fileList = reactive([])
const rules: Record<string, Rule[]> = {
cuMcode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
cuName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
cuSname: [{ required: true, message: "该项为必填项", trigger: 'change'}],
natureCode: [{ required: true, message: "该项为必填项", trigger: 'change'}],
classCode: [{ required: true, message: "该项为必填项", trigger: 'change'}],
typeCode: [{ required: true, message: "该项为必填项", trigger: 'change'}],
prepaySign: [{ required: true, message: "该项为必填项", trigger: 'change'}],
onlineSign: [{ required: true, message: "该项为必填项", trigger: 'change'}],
rateShare: [{ required: false, message: "该项为必填项", trigger: 'change'}],
};
const layout = {
labelCol: { span: 9 },
wrapperCol: { span: 15 },
}
const columnsCertificate = ref([
{ title: t('序号'), dataIndex: 'index', key: 'index', sorter: true, customRender: (column) => `${column.index + 1}` ,width: 100},
{ title: t('资质证书名称'), dataIndex: 'docNo', sorter: true, width:200},
{ title: t('有效期开始'), dataIndex: 'dateFrom', sorter: true, width: 140},
{ title: t('有效期结束'), dataIndex: 'dateTo', sorter: true, width: 140},
{ title: t('备注'), dataIndex: 'note', sorter: true},
{ title: t('操作'), dataIndex: 'operation', width: 220},
]);
const columnsBank = ref([
{ title: t('序号'), dataIndex: 'index', sorter: true, customRender: (column) => `${column.index + 1}`},
{ title: t('银行名称'), dataIndex: 'bankCode', sorter: true},
{ title: t('联行号'), dataIndex: 'code', sorter: true},
{ title: t('账号名称'), dataIndex: 'accountName', sorter: true},
{ title: t('银行账号'), dataIndex: 'account', sorter: true},
{ title: t('默认银行'), dataIndex: 'defaultSign', sorter: true},
{ title: t('操作'), dataIndex: 'operation', sorter: true},
]);
const columnsContact = ref([
{ title: t('序号'), dataIndex: 'index', sorter: true, customRender: (column) => `${column.index + 1}`},
{ title: t('姓名'), dataIndex: 'contactName', sorter: true},
{ title: t('联系电话'), dataIndex: 'tel', sorter: true},
{ title: t('电子邮箱'), dataIndex: 'email', sorter: true},
{ title: t('通讯地址'), dataIndex: 'addrMail', sorter: true},
{ title: t('职位'), dataIndex: 'position', sorter: true},
{ title: t('备注'), dataIndex: 'note', sorter: true},
{ title: t('操作'), dataIndex: 'operation', sorter: true},
]);
const columnsFile = ref([
{ title: t('序号'), dataIndex: 'index', sorter: true, customRender: (column) => `${column.index + 1}`},
{ title: t('附件名称'), dataIndex: 'fileOrg', sorter: true},
{ title: t('附件说明'), dataIndex: 'docDesc', sorter: true},
{ title: t('操作'), dataIndex: 'operation', sorter: true},
]);
const dataCertificate= reactive([]);
const dataBank= reactive([]);
const dataFile = reactive([]);
const dataContact= reactive([]);
let optionSelect= reactive({
cuMcodeList: [],
natureCodeList: [],
validList: [],
approCodeList: [],
classCodeList: [],
typeCodeList: [],
propCodeList: [],
signList: []
});
onMounted(() => {
getOption()
});
async function getOption() {
optionSelect.cuMcodeList = await getDictionary('LNG_ENT_PR')
optionSelect.natureCodeList = await getDictionary('LNG_NATURE')
optionSelect.classCodeList = await getDictionary('LNG_CLASS')
optionSelect.typeCodeList = await getDictionary('LNG_CU_TYP')
optionSelect.propCodeList = await getDictionary('LNG_CU_RPT')
optionSelect.signList = await getDictionary('LNG_YN')
optionSelect.validList = await getDictionary('LNG_VALID')
optionSelect.approCodeList = await getDictionary('LNG_APPRO')
}
function stateSignChange(val) {
if (val!='Y'){
formState.rateShare = ''
}
}
function typeCodeChange(val) {
if (val!='DC'){
formState.lngCustomerAttrPowerList[0].note = ''
formState.lngCustomerAttrPowerList[0].capacity = ''
}
}
const handleAdd = (val)=> {
if (val ==='certificate') {
openModalCertificate(true,);
}
if (val ==='contact'){
openModalContact(true, {});
}
}
const btnCheck = (type, btn, record, index) => {
// 证书
if (type == 'certificate') {
if (btn == 'edit') {
openModalCertificate(true, {record: record,isUpdate: true});
}
if (type === 'delete') {
dataCertificate.splice(index, 1)
}
}
// 联系人
if (type == 'contact') {
if (btn == 'edit') {
openModalContact(true, {record: record,isUpdate: true});
}
if (type === 'delete') {
dataContact.splice(index, 1)
}
}
}
const handleSuccessCertificate = (val) => {
let idx =dataCertificate.findIndex(v => v.docTypeCode == val.docTypeCode)
if (!idx) {
dataCertificate.push(val)
}
}
const handleSuccessContact = (val)=> {
dataContact.push(val)
}
function handleChangeFile(val) {
}
dynamicComponent.value = defineAsyncComponent({
loader: () => import(`./../../views/${pathArr[0]}/${pathArr[1]}/components/Form.vue`)
});
function onFormMounted(_formProps) {
formProps.value = _formProps;
setFormType();
}
async function setFormType() {
const _mode = mode.value;
if (_mode === 'create') {
return;
}
await nextTick();
if (_mode === 'view') {
await formRef.value.setDisabledForm();
}
await formRef.value.setFormDataFromId(formId.value);
}
function close() {
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;
}
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;
}
}
async function saveModal() {
let saveSuccess = false;
const _mode = mode.value;
try {
await formRef.value?.validate();
const values = (formRef.value?.getFormModal && formRef.value.getFormModal()) || (await formRef.value?.validate());
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
if (values !== false) {
try {
if (_mode === 'create') {
saveSuccess = await formRef.value.add(values);
} else {
saveSuccess = await formRef.value.update({ values, rowId: formId.value });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
console.error('saveModal Error: ', error);
}
}
</script>
<style lang="less" scoped>
.page-bg-wrap {
background-color: #fff;
}
.top-toolbar {
min-height: 44px;
margin-bottom: 12px;
border-bottom: 1px solid #eee;
}
.rateStyle {
position: absolute;
right: -25px;
top:4px;
}
.btn {
color: #5e95ff;
font-size: 20px;
font-weight: bold;
}
</style>

View File

@ -200,7 +200,7 @@
}); });
} else { } else {
router.push({ router.push({
path: '/form/Customer/0/createForm', path: '/form/Customer/0/createFormCustomer',
query: { query: {
formPath: 'sales/Customer', formPath: 'sales/Customer',
formName: formName, formName: formName,