|
@@ -2,18 +2,17 @@
|
|
|
<div>
|
|
|
<el-dialog :title="title" :close-on-click-modal="false" draggable width="1000px" height="500px" @close="close"
|
|
|
append-to-body v-model="visible">
|
|
|
-
|
|
|
<el-form :model="inputForm" ref="inputForm" :class="method === 'view' ? 'readonly' : ''"
|
|
|
:disabled="status === 'audit' || status === 'taskFormDetail'" label-width="135px"
|
|
|
@submit.native.prevent>
|
|
|
<el-row :gutter="0">
|
|
|
</el-row>
|
|
|
<el-row :gutter="0">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="附件">
|
|
|
- <el-upload ref="upload" action="" :limit="1" :auto-upload="false"
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="附件上传:">
|
|
|
+ <el-upload ref="upload" :on-remove="handleRemove" action="" :limit="1" :auto-upload="false"
|
|
|
:on-change="beforeUploadDetail" :show-file-list="true">
|
|
|
- <el-button type="primary">导入全部</el-button>
|
|
|
+ <el-button type="primary">点击上传Excel文件</el-button>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
@@ -51,9 +50,13 @@ export default {
|
|
|
components: {
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleRemove() {
|
|
|
+ this.inputForm.file.pop()
|
|
|
+ console.log(this.inputForm.file);
|
|
|
+ },
|
|
|
init() {
|
|
|
this.visible = true
|
|
|
- this.title = '发票导入'
|
|
|
+ this.title = '项目导入'
|
|
|
this.inputForm = {
|
|
|
file: []
|
|
|
}
|
|
@@ -63,26 +66,36 @@ export default {
|
|
|
beforeUploadDetail(file) {
|
|
|
this.inputForm.file.push(file)
|
|
|
},
|
|
|
+
|
|
|
// 下载模板
|
|
|
downloadTpl() {
|
|
|
- this.loading = true
|
|
|
+ const loading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: '模板下载中,请稍后',
|
|
|
+ spinner: 'el-icon-loading',
|
|
|
+ background: 'rgba(255, 255, 255, 0.3)'
|
|
|
+ });
|
|
|
projectRecordsService.exportProjectRecordsTemplate().then((res) => {
|
|
|
// 将二进制流文件写入excel表,以下为重要步骤
|
|
|
this.$utils.downloadExcel(res, '项目批量导入模板' + ".xlsx")
|
|
|
- this.loading = false
|
|
|
+ loading.close();
|
|
|
}).catch(function (err) {
|
|
|
- this.loading = false
|
|
|
+ loading.close();
|
|
|
if (err.response) {
|
|
|
console.log(err.response)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
doSubmit() {
|
|
|
+ if (this.inputForm.file.length == 0) {
|
|
|
+ this.$message.warning('未上传文件,无法提交导入')
|
|
|
+ return
|
|
|
+ }
|
|
|
const loading = this.$loading({
|
|
|
lock: true,
|
|
|
text: '导入中,请稍后',
|
|
|
spinner: 'el-icon-loading',
|
|
|
- background: 'rgba(0, 0, 0, 0.7)'
|
|
|
+ background: 'rgba(255, 255, 255, 0.3)'
|
|
|
});
|
|
|
const formBody = new FormData()
|
|
|
formBody.append('file', this.inputForm.file[0].raw)
|
|
@@ -95,6 +108,8 @@ export default {
|
|
|
} else {
|
|
|
loading.close();
|
|
|
}
|
|
|
+ }).catch(err => {
|
|
|
+ loading.close();
|
|
|
})
|
|
|
},
|
|
|
close() {
|