|
|
@ -1,6 +1,39 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div class="ds-file">
|
|
|
|
<div class="ds-file">
|
|
|
|
<a-button v-if="show" type="primary" @click="openFileModel">附件上传</a-button>
|
|
|
|
<a-form
|
|
|
|
|
|
|
|
v-if="succinct"
|
|
|
|
|
|
|
|
ref="fileForm"
|
|
|
|
|
|
|
|
:model="formData"
|
|
|
|
|
|
|
|
name="basic"
|
|
|
|
|
|
|
|
layout="vertical"
|
|
|
|
|
|
|
|
autocomplete="off"
|
|
|
|
|
|
|
|
@finishFailed="onFinishFailed"
|
|
|
|
|
|
|
|
@finish="onFinish"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<a-form-item name="upFileList">
|
|
|
|
|
|
|
|
<a-upload
|
|
|
|
|
|
|
|
ref="RefsUpload"
|
|
|
|
|
|
|
|
:file-list="upFileList"
|
|
|
|
|
|
|
|
:before-upload="beforeUpload"
|
|
|
|
|
|
|
|
:maxCount="maxCount"
|
|
|
|
|
|
|
|
accept=".xlsm,.xlsx,.xls,.pdf,.txt,.pms,.jpeg,.png"
|
|
|
|
|
|
|
|
:rules="[{ required: true, message: '请上传文件!' }]"
|
|
|
|
|
|
|
|
@remove="handleRemove"
|
|
|
|
|
|
|
|
@change="ChangeUpload"
|
|
|
|
|
|
|
|
:showUploadList="false"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<a-button>
|
|
|
|
|
|
|
|
<span
|
|
|
|
|
|
|
|
class="iconfont icon-shujushangchuan-shixin"
|
|
|
|
|
|
|
|
:style="{ fontSize: '12px', marginRight: '5px' }"
|
|
|
|
|
|
|
|
></span>
|
|
|
|
|
|
|
|
选择文件
|
|
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
|
|
</a-upload>
|
|
|
|
|
|
|
|
</a-form-item>
|
|
|
|
|
|
|
|
</a-form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-button v-if="show && !succinct" type="primary" @click="openFileModel">附件上传</a-button>
|
|
|
|
<a-modal
|
|
|
|
<a-modal
|
|
|
|
class="ds-form-detail"
|
|
|
|
class="ds-form-detail"
|
|
|
|
v-model:visible="visible"
|
|
|
|
v-model:visible="visible"
|
|
|
@ -38,6 +71,7 @@
|
|
|
|
</a-form-item>
|
|
|
|
</a-form-item>
|
|
|
|
<a-form-item label="附件" name="upFileList">
|
|
|
|
<a-form-item label="附件" name="upFileList">
|
|
|
|
<a-upload
|
|
|
|
<a-upload
|
|
|
|
|
|
|
|
ref="RefsUpload"
|
|
|
|
:file-list="upFileList"
|
|
|
|
:file-list="upFileList"
|
|
|
|
:before-upload="beforeUpload"
|
|
|
|
:before-upload="beforeUpload"
|
|
|
|
:maxCount="maxCount"
|
|
|
|
:maxCount="maxCount"
|
|
|
@ -135,6 +169,11 @@
|
|
|
|
type: Number,
|
|
|
|
type: Number,
|
|
|
|
default: null,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// 简洁模式 点击附件上传 直接选择文件
|
|
|
|
|
|
|
|
succinct: {
|
|
|
|
|
|
|
|
type: Boolean,
|
|
|
|
|
|
|
|
default: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// 弹窗开关
|
|
|
|
// 弹窗开关
|
|
|
|
const visible = ref(false)
|
|
|
|
const visible = ref(false)
|
|
|
@ -146,12 +185,17 @@
|
|
|
|
typeName: '',
|
|
|
|
typeName: '',
|
|
|
|
fileList: [],
|
|
|
|
fileList: [],
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const RefsUpload = ref<any>(null)
|
|
|
|
// 初始化数据
|
|
|
|
// 初始化数据
|
|
|
|
const init = () => {
|
|
|
|
const init = () => {
|
|
|
|
let code = props.fileType ? `${props.fileType}_file_type` : 'file_type'
|
|
|
|
let code = props.fileType ? `${props.fileType}_file_type` : 'file_type'
|
|
|
|
getDictOption(code).then((res) => {
|
|
|
|
getDictOption(code).then((res) => {
|
|
|
|
fileTypeList.value = res
|
|
|
|
fileTypeList.value = res
|
|
|
|
|
|
|
|
if (!props.succinct) {
|
|
|
|
visible.value = true
|
|
|
|
visible.value = true
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
RefsUpload.value.click()
|
|
|
|
|
|
|
|
}
|
|
|
|
formData.typeCode = props.dynamicDisabled
|
|
|
|
formData.typeCode = props.dynamicDisabled
|
|
|
|
fileTypeList.value.forEach((e: any) => {
|
|
|
|
fileTypeList.value.forEach((e: any) => {
|
|
|
|
if (e.value == props.dynamicDisabled) {
|
|
|
|
if (e.value == props.dynamicDisabled) {
|
|
|
@ -170,6 +214,34 @@
|
|
|
|
newFileList.splice(index, 1)
|
|
|
|
newFileList.splice(index, 1)
|
|
|
|
upFileList.value = newFileList
|
|
|
|
upFileList.value = newFileList
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function ChangeUpload(e) {
|
|
|
|
|
|
|
|
const postData = new FormData()
|
|
|
|
|
|
|
|
const list = unref(upFileList)
|
|
|
|
|
|
|
|
list.forEach((item) => {
|
|
|
|
|
|
|
|
postData.append('formCollection[]', item)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
postData.append('linkId', props.id)
|
|
|
|
|
|
|
|
postData.append('typeCode', formData.typeCode)
|
|
|
|
|
|
|
|
postData.append('typeName', formData.typeName)
|
|
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
|
|
AddMultiFiles(postData)
|
|
|
|
|
|
|
|
.then((res) => {
|
|
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
|
|
visible.value = false
|
|
|
|
|
|
|
|
upFileList.value = []
|
|
|
|
|
|
|
|
if (props.showFileList) {
|
|
|
|
|
|
|
|
dsFileList.value.init()
|
|
|
|
|
|
|
|
emits('handleSuccess', { id: res.data })
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
emits('handleSuccess')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
createMessage.success('上传成功!')
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((res) => {
|
|
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
|
|
createMessage.error('上传失败!')
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
function beforeUpload(file) {
|
|
|
|
function beforeUpload(file) {
|
|
|
|
// 判断文件大小
|
|
|
|
// 判断文件大小
|
|
|
|
if (props.maxSize) {
|
|
|
|
if (props.maxSize) {
|
|
|
@ -206,6 +278,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const fileForm = ref(null)
|
|
|
|
const fileForm = ref(null)
|
|
|
|
|
|
|
|
|
|
|
|
// 附件列表组件
|
|
|
|
// 附件列表组件
|
|
|
|
const dsFileList = ref(null)
|
|
|
|
const dsFileList = ref(null)
|
|
|
|
const emits = defineEmits(['handleSuccess', 'FnTriggerSave'])
|
|
|
|
const emits = defineEmits(['handleSuccess', 'FnTriggerSave'])
|
|
|
|