上传组件

This commit is contained in:
‘huanghaiixia’
2025-12-09 17:13:57 +08:00
parent c44db962c3
commit 9b43f5ed55
8 changed files with 142 additions and 43 deletions

View File

@ -33,9 +33,9 @@
</a-col>
<a-col :span="24">
<a-form-item label="上传附件" name="fileList" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<UploadNew :file-list="formState.fileList" :disabled="isDisable" @change="changeUplod" :multiple="true" :maxSize="200" :accept="accept" />
<div style="color: #ccc; font-size: 12px">{{ fileTip }}</div>
<Upload :disabled="isDisable" v-model:value="formState.filePath" v-model:tableName="tableName" v-model:columnName="columnName"
:multiple="true" @change="changeUplod" :dataDelete="true" :file-list="formState.fileList" :maxSize="200" :accept="accept"></Upload>
</a-form-item>
</a-col>
</a-row>
@ -50,11 +50,13 @@ import { Form, message } 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 UploadNew from '/@/components/Form/src/components/UploadNew.vue';
import { getDocCpList } from '/@/api/sales/Customer';
import type { FormInstance } from 'ant-design-vue';
import dayjs from 'dayjs';
import Upload from '/@/components/Form/src/components/Upload.vue';
const tableName = 'Customer'
const columnName = 'fileList'
const { t } = useI18n();
const isUpdate = ref(true);
const isDisable = ref(false);
@ -68,14 +70,18 @@ const emit = defineEmits(['success','register']);
const getTitle = computed(() => (!unref(isUpdate) ? t('新增证书') : t('编辑证书')));
let formState = reactive({
docTypeCode: '',
fileList: []
fileList: [],
filePath: ''
});
const list = ref()
const rules = {
docTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
};
const curData = ref()
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
curData.value = ''
formState.filePath = ''
getOption()
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
@ -85,7 +91,9 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
let dateFrom = data.record?.dateFrom ? dayjs(data.record?.dateFrom) : null
let dateTo = data.record?.dateTo ? dayjs(data.record?.dateTo) : null
Object.assign(formState, {...data.record,dateFrom, dateTo})
formState.filePath = formState.fileList[0]?.xjrFileId
let json = JSON.parse(JSON.stringify(data.record))
formState.filePath = (json?.fileList||[])[0]?.tableId
curData.value = json?.docTypeCode
}
});
@ -108,7 +116,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
}
function changeUplod (val) {
formState.fileList = val
console.log(val, 532, formState.filePath)
console.log(val, 532, )
}
async function getOption() {
optionList = await getDocCpList({'valid': 'Y'})
@ -124,17 +132,10 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
...formState,
dateFrom: formState.dateFrom ? dayjs(formState.dateFrom).format('YYYY-MM-DD') : '',
dateTo: formState.dateTo ? dayjs(formState.dateTo).format('YYYY-MM-DD') : '',
fileList: formState.fileList.map(v => {
return {
fileOrg: v.name,
filePath: v.url,
fileSize: v.fileSize,
xjrFileId: v.tableId
}
})
fileList: formState.fileList || []
}
let idx =list.value.findIndex(v => v.docTypeCode == obj.docTypeCode)
if (idx > -1) {
if (idx > -1 && formState.docTypeCode !=curData.value) {
message.warn('证书已存在')
formRef.value.resetFields();
closeModal();