客户表单附件

This commit is contained in:
‘huanghaiixia’
2025-12-01 16:55:28 +08:00
parent b1cd0a5168
commit 3232319675
6 changed files with 85 additions and 86 deletions

View File

@ -28,7 +28,7 @@
</a-col>
<a-col :span="24">
<a-form-item label="上传附件" name="fileList" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<Upload v-model:value="formState.filePath" @change="changeUplod" :multiple="true" :maxSize="200" :accept="accept"></Upload>
<Upload v-model:value="formState.filePath" @change="changeUplod" ref="uploadRef" :multiple="true" :maxSize="200" :accept="accept"></Upload>
<div style="color: #ccc; font-size: 12px">{{ fileTip }}</div>
</a-form-item>
@ -49,12 +49,12 @@ 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';
import { object } from 'vue-types';
const { t } = useI18n();
const isUpdate = ref(true);
const isDisable = ref(false);
let optionList = reactive([])
const uploadRef = ref()
const fileTip = '支持格式.rar .zip .doc .docx .pdf 单个文件不能超过20MB';
const accept ='.rar,.zip, .doc, .docx, .pdf, .RAR, .ZIP, .DOC, .DOCX, .PDF'
const formRef = ref()
@ -98,12 +98,9 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
}
return endValue.valueOf() <= startValue.valueOf();
}
const handleChangeFile = (val) => {
}
function changeUplod (val) {
console.log(val, 532)
formState.fileList = val
console.log(val, 532, formState.filePath)
}
async function getOption() {
optionList = await getDocCpList({'valid': 'Y'})
@ -115,13 +112,21 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
try {
await formRef.value.validate();
// 验证通过,提交表单
let arr = uploadRef.value.getValue() || []
let obj = {
...formState,
dateFrom: formState.dateFrom ? dayjs(formState.dateFrom).format('YYYY-MM-DD') : '',
dateTo: formState.dateTo ? dayjs(formState.dateTo).format('YYYY-MM-DD') : '',
fileList: arr.map(v => {
return {
fileOrg: v.name,
filePath: v.url,
filesize: v.fileSize
}
})
}
console.log(obj,543)
console.log(obj,543, uploadRef.value.getValue())
formState.filePath = ''
emit('success', obj);
notification.success({
message: t('操作'),

View File

@ -1,25 +1,6 @@
<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 style="margin-right: 10px" @click="handleSubmit('save')">
<slot name="icon"><save-outlined /></slot>保存
</a-button>
<a-button style="margin-right: 10px" type="primary" @click="handleSubmit('submit')">
<slot name="icon"><check-circle-outlined /></slot>保存并提交
</a-button>
<a-button style="margin-right: 10px" >
<slot name="icon"><download-outlined /></slot>下载模板
</a-button>
<a-button >
<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>
@ -314,7 +295,7 @@
<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>
<a :href="record.presignedUrl||record.filePath" :download="record.fileOrg" target="_blank">{{record.fileOrg}}</a>
</template>
<template v-if="column.dataIndex === 'docDesc' && !isDisable">
<a-input :placeholder="t('请输入附件说明')" :disabled="isDisable" v-model:value="record.docDesc" />
@ -653,7 +634,6 @@
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;
@ -664,6 +644,7 @@
let obj = {
fileOrg: data.fileName,
filePath: data.photoUrl,
filesize: info?.file?.response?.data?.fileSize
}
dataFile.push(obj)
@ -709,26 +690,30 @@
let obj = {
...formState,
lngCustomerBankList: dataBank,
lngCustomerDocList: dataCertificate,
lngCustomerDocList: dataCertificate.map(v =>{
return {
...v,
dateFrom: v.dateFrom ? dayjs(v.dateFrom ).format('YYYY-MM-DD HH:mm:ss') : '',
dateTo: v.dateTo ? dayjs(v.dateTo ).format('YYYY-MM-DD HH:mm:ss'): ''
}
}),
lngCustomerContactList: dataContact,
lngFileUploadList: dataFile
}
spinning.value = true;
let request = pageType.value === 'add' ? addLngCustomer :updateLngCustomer
let request = !formState.id ? addLngCustomer :updateLngCustomer
try {
obj.lngCustomerDocList.forEach(v => {
v.dateFrom = dayjs(v.dateFrom ).valueOf()
v.dateTo = dayjs(v.dateTo ).valueOf()
})
const data = await addLngCustomer(obj);
// notification.success({
// message: 'Tip',
// description: pageType.value === 'add' ? t('新增成功!') : t('修改成功!')
// }); //提示消息
const data = await request(obj);
if (type) {
data?.id && (formState.id = data.id)
data?.cuCode && (formState.cuCode = data.cuCode)
notification.success({
message: 'Tip',
description: !data?.id ? t('新增成功!') : t('修改成功!')
}); //提示消息
}
// formRef.value.resetFields();
return data
// setTimeout(() => {
@ -751,33 +736,6 @@
}
}
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);
}
}
defineExpose({
handleSubmit,
getFormValue