From b68fe6af98e37409010e16c93f312d825f6276a3 Mon Sep 17 00:00:00 2001 From: wangting <675591594@qq.com> Date: 星期三, 21 六月 2023 15:34:52 +0800 Subject: [PATCH] 附件列表上传、修改 --- Source/UBCS-WEB/src/components/BatchImport/index.vue | 136 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 108 insertions(+), 28 deletions(-) diff --git a/Source/UBCS-WEB/src/components/BatchImport/index.vue b/Source/UBCS-WEB/src/components/BatchImport/index.vue index cb6d21f..3c674f4 100644 --- a/Source/UBCS-WEB/src/components/BatchImport/index.vue +++ b/Source/UBCS-WEB/src/components/BatchImport/index.vue @@ -1,8 +1,14 @@ <template> - <el-dialog :title="title" :visible="visible" append-to-body> + <el-dialog + v-if="dialogVisible" + :title="title" + :visible.sync="dialogVisible" + append-to-body + v-dialogDrag + > <Divider text="瀵煎叆鎻愮ず" left="30px"></Divider> <ul> - <li v-for="(item, index) in tipInfo" :key="index"> + <li v-for="(item, index) in tipList" :key="index"> {{ item }} </li> </ul> @@ -20,66 +26,140 @@ :action="action" :before-upload="beforeUpload" :on-exceed="handleExceed" + :headers="uploadHeaders" + :on-success="onSuccess" + :show-file-list="false" + :data="{ + codeClassifyOid: this.codeClassifyOid, + classifyAttr: this.classifyAttr, + }" > - <el-button size="small" type="primary"><i class="el-icon-upload"></i> 鐐瑰嚮涓婁紶</el-button> + <el-button size="small" type="primary" + ><i class="el-icon-upload"></i> 鐐瑰嚮涓婁紶</el-button + > </el-upload> <template #footer> - <el-button type="primary" size="small" @click="downloadTemplateFun">涓嬭浇瀵煎叆妯℃澘</el-button> - <el-button size="small">鍏抽棴</el-button> + <el-button + type="primary" + size="small" + @click="downloadTemplateFun" + :loading="downloadLoading" + >涓嬭浇瀵煎叆妯℃澘</el-button + > + <el-button size="small" @click="visible = false">鍏抽棴</el-button> </template> + <ShowImportData :visible="showVisible" v-if="showVisible"></ShowImportData> </el-dialog> </template> <script> -import { downloadTemplate } from '../../api/batchImport/index' +import ShowImportData from "./ShowImportData.vue"; +import { + downloadHistoryImportTemplate, + downloadErrorFile, +} from "../../api/batchImport/index"; +import { getToken } from "@/util/auth"; export default { - name: "", + name: "BatchImport", + components: { ShowImportData }, props: { - title: { - type: String, - default: "鎵归噺鐢宠缂栫爜", - }, - tipInfo: { - type: Array, - default: () => [], - }, visible: { type: Boolean, default: false, }, accept: { type: String, - default: '.xlsx, .xls' + default: ".xlsx, .xls", }, codeClassifyOid: { type: String, - default: '' + default: "", }, - downloadTemplateFun: { - type: Function - } + type: { + type: String, + default: "", + }, }, data() { return { - classType: "classCode", + classifyAttr: "id", + uploadParams: {}, + downloadLoading: false, + showVisible: false, }; }, computed: { - action() { - console.log(process, 'process'); - return '/api/ubcs-code/mdmEngineController/mdmEngineController/batchTopImportCode' - } + uploadHeaders() { + return { + "Blade-Auth": "bearer " + getToken(), + }; + }, + dialogVisible: { + get() { + return this.visible; + }, + set(val) { + this.$emit("update:visible", val); + }, + }, }, methods: { + getDataByType() { + if (this.type === "historyImport") { + this.title = "鍘嗗彶鏁版嵁瀵煎叆"; + this.tipList = [ + "1.鏍囬甯︿簲瑙掓槦鐨勮〃绀哄叧閿睘鎬э紝甯︽槦鍙疯〃绀哄繀杈撻」", + "2.浼佷笟缂栫爜锛岄泦鍥㈢爜鍜岀姸鎬侀兘闇�瑕佸鍏�", + "3.姣忔浠呰兘鏈�澶氬鍏�10000鏉℃暟鎹紝濡傛灉鍑洪敊浼氳繑鍥為敊璇殑鏁版嵁鍜屽師鍥狅紝浣嗘槸姝g‘鐨勬暟鎹細淇濆瓨", + "4.鍒嗙被鐨勮矾寰勯渶瑕佺敤#鍒嗛殧銆備粎濉啓褰撳墠閫夌殑鍒嗙被鏍戜笂鐨勪笅绾у垎绫荤殑璺緞锛屽鏋滃綋鍓嶅垎绫诲凡缁忔槸鍙跺瓙鑺傜偣锛屽垯涓嶅~鍐�", + ]; + this.action = + "/api/ubcs-code/mdmEngineController/batchImportHistoryData"; + } else if (this.type === "codeApply") { + this.title = "鎵归噺缂栫爜鐢宠"; + this.tipList = [ + "1.鏍囬甯︿簲瑙掓槦鐨勮〃绀哄叧閿睘鎬э紝甯︽槦鍙疯〃绀哄繀杈撻」", + "2.鍒嗙被鐨勮矾寰勯渶瑕佺敤#鍒嗛殧銆備粠褰撳墠閫夋嫨鍒嗙被鑺傜偣鐨勪笅绾у紑濮嬪~鍐欙紝鐩村埌鏈�鏈熬鑺傜偣锛屽 浜у搧#涓绘満浜у搧#涓绘満浜у搧", + ]; + } + }, beforeUpload(file) { - const fileType = file.name.split('.').pop() - if (fileType !== 'xlsx' && fileType !== 'xls') { + const fileType = file.name.split(".").pop(); + if (fileType !== "xlsx" && fileType !== "xls") { // 涓婁紶鏍煎紡涓嶇鍚堣姹傦紝鎻愮ず閿欒淇℃伅骞跺彇娑堜笂浼� - this.$message.error('鍙厑璁镐笂浼爔lsx銆亁ls鏍煎紡鐨勬枃浠�'); + this.$message.error("鍙厑璁镐笂浼爔lsx銆亁ls鏍煎紡鐨勬枃浠�"); return false; } return true; }, + // 涓嬭浇瀵煎叆妯℃澘 + downloadTemplateFun() { + this.downloadLoading = true; + downloadHistoryImportTemplate({ + codeClassifyOid: this.codeClassifyOid, + }) + .then((res) => { + this.downloadLoading = false; + this.$utilFunc.downloadFileByBlob(res.data, "鍘嗗彶鏁版嵁瀵煎叆妯℃澘.xls"); + }) + .catch(() => { + this.downloadLoading = false; + }); + }, + onSuccess(res) { + if (res.code === 400) { + this.$message.error(`${res.msg}锛岃涓嬭浇閿欒淇℃伅杩涜鏌ョ湅锛乣); + } + downloadErrorFile({ uuid: res.data.fileOid }); + }, + }, + watch: { + visible: { + immediate: true, + handler() { + this.getDataByType(); + }, + }, }, }; </script> -- Gitblit v1.9.3