¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <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 tipList" :key="index">
|
| | | {{ item }}
|
| | | </li>
|
| | | </ul>
|
| | | <div class="radio_box">
|
| | | <span>åç±»çè·¯å¾ä½¿ç¨ç屿§:</span>
|
| | | <el-radio-group v-model="classifyAttr">
|
| | | <el-radio label="id">åç±»ç¼å·</el-radio>
|
| | | <el-radio label="name">åç±»åç§°</el-radio>
|
| | | </el-radio-group>
|
| | | </div>
|
| | | <Divider text="excelæä»¶ï¼éæ©æä»¶åä¼èªå¨ä¸ä¼ " left="30px"></Divider>
|
| | | <el-upload
|
| | | class="upload"
|
| | | :accept="accept"
|
| | | :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-upload>
|
| | | <template #footer>
|
| | | <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 ShowImportData from "./ShowImportData.vue";
|
| | | import {
|
| | | downloadHistoryImportTemplate,
|
| | | downloadErrorFile,
|
| | | } from "../../api/batchImport/index";
|
| | | import { getToken } from "@/util/auth";
|
| | | export default {
|
| | | name: "BatchImport",
|
| | | components: { ShowImportData },
|
| | | props: {
|
| | | visible: {
|
| | | type: Boolean,
|
| | | default: false,
|
| | | },
|
| | | accept: {
|
| | | type: String,
|
| | | default: ".xlsx, .xls",
|
| | | },
|
| | | codeClassifyOid: {
|
| | | type: String,
|
| | | default: "",
|
| | | },
|
| | | type: {
|
| | | type: String,
|
| | | default: "",
|
| | | },
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | classifyAttr: "id",
|
| | | uploadParams: {},
|
| | | downloadLoading: false,
|
| | | showVisible: false,
|
| | | };
|
| | | },
|
| | | computed: {
|
| | | 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æ¡æ°æ®ï¼å¦æåºéä¼è¿åéè¯¯çæ°æ®ååå ï¼ä½æ¯æ£ç¡®çæ°æ®ä¼ä¿å",
|
| | | "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") {
|
| | | // ä¸ä¼ æ ¼å¼ä¸ç¬¦åè¦æ±ï¼æç¤ºé误信æ¯å¹¶åæ¶ä¸ä¼
|
| | | this.$message.error("åªå
许ä¸ä¼ xlsxãxlsæ ¼å¼çæä»¶");
|
| | | 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>
|
| | |
|
| | | <style lang="scss" scoped>
|
| | | ul {
|
| | | color: rgb(188, 188, 188);
|
| | | margin: 20px 0 0 0;
|
| | | padding: 0;
|
| | | padding-left: 30px;
|
| | | list-style: none;
|
| | | li {
|
| | | margin-bottom: 5px;
|
| | | font-size: 12px;
|
| | | }
|
| | | }
|
| | | .radio_box {
|
| | | padding-left: 30px;
|
| | | margin: 20px 0 25px 0;
|
| | | display: flex;
|
| | | align-items: center;
|
| | | span {
|
| | | margin-right: 20px;
|
| | | }
|
| | | }
|
| | | .upload {
|
| | | padding-left: 30px;
|
| | | margin-top: 30px;
|
| | | }
|
| | | </style>
|