From dbe1b807e2a0e4aaa37277b69c50dd69dc42dda2 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期日, 25 六月 2023 10:34:36 +0800 Subject: [PATCH] Merge branch 'master' of http://dev.vci-tech.com:1065/r/ubcs --- Source/UBCS-WEB/src/components/BatchImport/index.vue | 174 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 146 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..3c65d7a 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,178 @@ :action="action" :before-upload="beforeUpload" :on-exceed="handleExceed" + :headers="uploadHeaders" + :on-success="onSuccess" + :show-file-list="false" + :on-change="uploadChange" + :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="dialogVisible = false">鍏抽棴</el-button> </template> + <ShowImportData + :visible.sync="showVisible" + v-if="dialogVisible" + :leftTree="leftTree" + :redisOid="redisOid" + ></ShowImportData> </el-dialog> </template> <script> -import { downloadTemplate } from '../../api/batchImport/index' +import ShowImportData from "./ShowImportData.vue"; +import { + downloadHistoryImportTemplate, + downloadErrorFile, + getHistoryLeftTree +} 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, + leftTree: [], + redisOid:'', + pageLoading: null }; }, 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.$utilFunc.downloadFileByBlob(res.data, "鍘嗗彶鏁版嵁瀵煎叆妯℃澘.xls"); + this.downloadLoading = false; + }) + .catch(() => { + this.downloadLoading = false; + }); + }, + onSuccess(res) { + let fileName = res.data.filePath.split('/').pop() + if (res.data.fileOid) { + this.$message.error("璇蜂笅杞介敊璇俊鎭枃浠惰繘琛屾煡鐪嬶紒"); + downloadErrorFile({ uuid: res.data.fileOid }).then((res2) => { + this.$utilFunc.downloadFileByBlob(res2.data, fileName); + }); + } + if (res.data.redisUuid) { + this.redisOid = res.data.redisUuid + getHistoryLeftTree(res.data.redisUuid).then(res => { + this.leftTree = res.obj.map(item => { + return { + ...item.codeClassifyTemplateVO, + cloNamesList: item.cloNamesList + } + }) + this.showVisible = true + }) + } + }, + uploadChange(file) { + if (file.status === 'ready') { + this.pageLoading = this.$loading({ + lock: true, + text: '鏂囦欢涓婁紶涓�', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }); + } + if (file.status === 'success' || file.status === 'error') { + this.pageLoading.close() + } + } + }, + watch: { + visible: { + immediate: true, + handler() { + this.getDataByType(); + }, + }, }, }; </script> -- Gitblit v1.9.3