|
@ -1,65 +1,99 @@ |
|
|
<template> |
|
|
<template> |
|
|
<!-- 自定义表单 --> |
|
|
<!-- 自定义表单 --> |
|
|
<BasicModal v-bind="$attrs" @register="registerModal" title="上传文件" width="1200px" :showOkBtn="false" |
|
|
<BasicModal |
|
|
:showCancelBtn="false"> |
|
|
v-bind="$attrs" |
|
|
<el-form ref="importFormRef"> |
|
|
@register="registerModal" |
|
|
<el-form-item label="上传文件:"> |
|
|
title="上传文件" |
|
|
<el-upload class="upload-demo" ref="upload" action :http-request="httpRequest" |
|
|
width="1200px" |
|
|
:before-upload="beforeUpload" :on-exceed="handleExceed" :limit="10" :on-remove="removeFile"> |
|
|
:showOkBtn="false" |
|
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button> |
|
|
:showCancelBtn="false" |
|
|
<div slot="tip" class="el-upload__tip">文件大小且不超过500M</div> |
|
|
> |
|
|
<div slot="tip" class="el-upload__tip">必须上传《部门联审意见》</div> |
|
|
<el-divider content-position="left">上传《部门联审意见》</el-divider> |
|
|
</el-upload> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<el-form-item> |
|
|
<el-form ref="importFormRef"> |
|
|
<el-button type="primary" @click="submitImportForm">开始导入</el-button> |
|
|
<el-form-item label="上传文件:"> |
|
|
<el-button type="info" @click="dialogVisible">关闭窗口</el-button> |
|
|
<el-upload |
|
|
</el-form-item> |
|
|
class="upload-demo" |
|
|
</el-form> |
|
|
ref="upload" |
|
|
</BasicModal> |
|
|
action |
|
|
|
|
|
:http-request="httpRequest" |
|
|
|
|
|
:before-upload="beforeUpload" |
|
|
|
|
|
:on-exceed="handleExceed" |
|
|
|
|
|
:limit="10" |
|
|
|
|
|
:on-remove="removeFile" |
|
|
|
|
|
> |
|
|
|
|
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button> |
|
|
|
|
|
<div slot="tip" class="el-upload__tip">文件大小且不超过500M</div> |
|
|
|
|
|
</el-upload> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-form> |
|
|
|
|
|
|
|
|
|
|
|
<el-divider content-position="left">上传最终稿</el-divider> |
|
|
|
|
|
|
|
|
|
|
|
<el-form ref="importFormRef"> |
|
|
|
|
|
<el-form-item label="上传文件:"> |
|
|
|
|
|
<el-upload |
|
|
|
|
|
class="upload-demo" |
|
|
|
|
|
ref="upload" |
|
|
|
|
|
action |
|
|
|
|
|
:http-request="httpRequest" |
|
|
|
|
|
:before-upload="beforeUpload" |
|
|
|
|
|
:on-exceed="handleExceed" |
|
|
|
|
|
:limit="10" |
|
|
|
|
|
:on-remove="removeFile" |
|
|
|
|
|
> |
|
|
|
|
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button> |
|
|
|
|
|
<div slot="tip" class="el-upload__tip">文件大小且不超过500M</div> |
|
|
|
|
|
</el-upload> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<el-form-item> |
|
|
|
|
|
<el-button type="primary" @click="submitImportForm">开始导入</el-button> |
|
|
|
|
|
<el-button type="info" @click="dialogVisible">关闭窗口</el-button> |
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
</el-form> |
|
|
|
|
|
</BasicModal> |
|
|
</template> |
|
|
</template> |
|
|
<script lang="ts" name="setProjectWorkReport" setup> |
|
|
<script lang="ts" name="setProjectWorkReport" setup> |
|
|
import { reactive, defineEmits, onMounted, ref } from 'vue'; |
|
|
import { reactive, defineEmits, onMounted, ref } from 'vue'; |
|
|
import { ElMessage } from 'element-plus'; |
|
|
import { ElMessage } from 'element-plus'; |
|
|
|
|
|
|
|
|
import { useModalInner, BasicModal } from '@/components/Modal'; |
|
|
import { useModalInner, BasicModal } from '@/components/Modal'; |
|
|
import { uploadURTFile } from '@/views/projectLib/projectPlan/projectPlan.api'; |
|
|
import { uploadURTFile } from '@/views/projectLib/projectPlan/projectPlan.api'; |
|
|
import { queryProjectInfoById } from '@/views/projectLib/projectInfo/projectInfo.api'; |
|
|
import { queryProjectInfoById } from '@/views/projectLib/projectInfo/projectInfo.api'; |
|
|
const [registerModal, { closeModal }] = useModalInner(init); |
|
|
const [registerModal, { closeModal }] = useModalInner(init); |
|
|
let fileList = reactive<Array<any>>([]); |
|
|
let fileList = reactive<Array<any>>([]); |
|
|
let projectid = ref("") |
|
|
let planinfoid = ref(''); |
|
|
async function init(data) { |
|
|
async function init(data) { |
|
|
console.log('datadatadata', data); |
|
|
console.log('datadatadata', data); |
|
|
projectid.value = data.projectid; |
|
|
planinfoid.value = data.planinfoid; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const emit = defineEmits(['close']); |
|
|
const emit = defineEmits(['close']); |
|
|
//加载项目数据 |
|
|
//加载项目数据 |
|
|
onMounted(async () => { |
|
|
onMounted(async () => {}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function httpRequest(option) { |
|
|
function httpRequest(option) { |
|
|
fileList.push(option); |
|
|
fileList.push(option); |
|
|
console.log(fileList, option); |
|
|
console.log(fileList, option); |
|
|
} |
|
|
} |
|
|
function removeFile(option) { |
|
|
function removeFile(option) { |
|
|
for (let i = 0; i < fileList.length; i++) { |
|
|
for (let i = 0; i < fileList.length; i++) { |
|
|
if (fileList[i].file.name == option.name) { |
|
|
if (fileList[i].file.name == option.name) { |
|
|
fileList.splice(i, 1); |
|
|
fileList.splice(i, 1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
console.log(fileList, option); |
|
|
console.log(fileList, option); |
|
|
} |
|
|
} |
|
|
// 上传前处理 |
|
|
// 上传前处理 |
|
|
function beforeUpload(file, item) { |
|
|
function beforeUpload(file, item) { |
|
|
console.log('file,item', file, item); |
|
|
console.log('file,item', file, item); |
|
|
let fileSize = file.size; |
|
|
let fileSize = file.size; |
|
|
const FIVE_M = 500 * 1024 * 1024; |
|
|
const FIVE_M = 500 * 1024 * 1024; |
|
|
//大于5M,不允许上传 |
|
|
//大于5M,不允许上传 |
|
|
if (fileSize > FIVE_M) { |
|
|
if (fileSize > FIVE_M) { |
|
|
ElMessage.error('最大上传500M'); |
|
|
ElMessage.error('最大上传500M'); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
// let geShi = ['xlx', 'xlsx', 'docx', 'doc', 'pdf'] as Array<string>; |
|
|
// let geShi = ['xlx', 'xlsx', 'docx', 'doc', 'pdf'] as Array<string>; |
|
|
// if (geShi.indexOf(file.name.substring(file.name.indexOf('.') + 1)) == -1) { |
|
|
// if (geShi.indexOf(file.name.substring(file.name.indexOf('.') + 1)) == -1) { |
|
@ -74,45 +108,45 @@ function beforeUpload(file, item) { |
|
|
console.log('文件上传成功'); |
|
|
console.log('文件上传成功'); |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
// 文件数量过多时提醒 |
|
|
// 文件数量过多时提醒 |
|
|
function handleExceed() { |
|
|
function handleExceed() { |
|
|
ElMessage.warning('最多只能上传十个文件'); |
|
|
ElMessage.warning('最多只能上传十个文件'); |
|
|
} |
|
|
} |
|
|
//导入Excel病种信息数据 |
|
|
//导入Excel病种信息数据 |
|
|
async function submitImportForm() { |
|
|
async function submitImportForm() { |
|
|
if (fileList.length == 0) { |
|
|
if (fileList.length == 0) { |
|
|
ElMessage({ |
|
|
ElMessage({ |
|
|
message: '未选择任何文件,无法上传!', |
|
|
message: '未选择任何文件,无法上传!', |
|
|
type: 'error', |
|
|
type: 'error', |
|
|
}); |
|
|
}); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
let cunzai = false; |
|
|
let cunzai = false; |
|
|
fileList.forEach((x) => { |
|
|
fileList.forEach((x) => { |
|
|
console.log('xxxxxxxxxx', x, x.file); |
|
|
console.log('xxxxxxxxxx', x, x.file); |
|
|
if(x.file.name.includes('部门联审意见')){ |
|
|
if (x.file.name.includes('部门联审意见')) { |
|
|
cunzai = true; |
|
|
cunzai = true; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
if(!cunzai){ |
|
|
if (!cunzai) { |
|
|
ElMessage.error('请上传《部门联审意见》'); |
|
|
ElMessage.error('请上传《部门联审意见》'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
// // 使用form表单的数据格式 |
|
|
// // 使用form表单的数据格式 |
|
|
const params = new FormData(); |
|
|
const params = new FormData(); |
|
|
// 将上传文件数组依次添加到参数paramsData中 |
|
|
// 将上传文件数组依次添加到参数paramsData中 |
|
|
fileList.forEach((x) => { |
|
|
fileList.forEach((x) => { |
|
|
console.log('xxxxxxxxxx', x, x.file); |
|
|
console.log('xxxxxxxxxx', x, x.file); |
|
|
params.append('file', x.file); |
|
|
params.append('file', x.file); |
|
|
}); |
|
|
}); |
|
|
params.append('projectid', projectid.value); |
|
|
params.append('planinfoid', planinfoid.value); |
|
|
uploadURTFile(params).then(() => { |
|
|
uploadURTFile(params).then(() => { |
|
|
emit('close'); |
|
|
emit('close'); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
function dialogVisible() { |
|
|
function dialogVisible() { |
|
|
emit('close'); |
|
|
emit('close'); |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
<style></style> |
|
|
<style></style> |
|
|