|
@@ -1,74 +1,75 @@
|
|
|
<template>
|
|
|
- <Base-dialog
|
|
|
- title="导入"
|
|
|
- width="660px"
|
|
|
- :isShow.sync="isShow"
|
|
|
- :isShowFooter="false"
|
|
|
- >
|
|
|
- <div>
|
|
|
- <div class="swq">
|
|
|
- <img
|
|
|
- style="width: 182px; height: 168px"
|
|
|
- src="@/assets/images/dr.png"
|
|
|
- alt=""
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div style="padding-left: 100px">
|
|
|
- <p>第一步:下载导入模板</p>
|
|
|
- <p style="padding-left: 50px">
|
|
|
- <i class="el-icon-upload"></i
|
|
|
- ><span class="dowmStys" @click="getDowm">下载模板</span>
|
|
|
- </p>
|
|
|
- <p>第二步:(批量新增):点击“上传Excel”完成导入</p>
|
|
|
- <div
|
|
|
- v-loading="loading"
|
|
|
- element-loading-text="正在处理中"
|
|
|
- style="margin: 0 0 20px 50px; width: 130px; height: 60px"
|
|
|
- >
|
|
|
- <label
|
|
|
- v-show="!loading"
|
|
|
- for="mobles"
|
|
|
- class="el-button el-button--primary"
|
|
|
- >上传Excel</label
|
|
|
- ><input
|
|
|
- style="display: none"
|
|
|
- type="file"
|
|
|
- id="mobles"
|
|
|
- ref="input1"
|
|
|
- @change="importMobleadd"
|
|
|
+ <div>
|
|
|
+ <Base-dialog
|
|
|
+ title="导入"
|
|
|
+ width="660px"
|
|
|
+ :isShow.sync="isShow"
|
|
|
+ :isShowFooter="false"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <div class="swq">
|
|
|
+ <img
|
|
|
+ style="width: 182px; height: 168px"
|
|
|
+ src="@/assets/images/dr.png"
|
|
|
+ alt=""
|
|
|
/>
|
|
|
</div>
|
|
|
+ <div style="padding-left: 100px">
|
|
|
+ <p>第一步:下载导入模板</p>
|
|
|
+ <p style="padding-left: 50px">
|
|
|
+ <i class="el-icon-upload"></i
|
|
|
+ ><span class="dowmStys" @click="getDowm">下载模板</span>
|
|
|
+ </p>
|
|
|
+ <p>第二步:(批量新增):点击“上传{{ type }}”完成导入</p>
|
|
|
+ <div
|
|
|
+ v-loading="loading"
|
|
|
+ element-loading-text="正在处理中"
|
|
|
+ style="margin: 0 0 20px 50px; width: 130px; height: 60px"
|
|
|
+ >
|
|
|
+ <label
|
|
|
+ v-show="!loading"
|
|
|
+ for="mobles"
|
|
|
+ class="el-button el-button--primary"
|
|
|
+ >上传 {{ type }}</label
|
|
|
+ ><input
|
|
|
+ style="display: none"
|
|
|
+ type="file"
|
|
|
+ id="mobles"
|
|
|
+ ref="input1"
|
|
|
+ @change="importMobleadd"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="isShow = false">取消</el-button>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="isShow = false">取消</el-button>
|
|
|
- </span>
|
|
|
- <Base-dialog
|
|
|
- title="提示"
|
|
|
- width="660px"
|
|
|
- :isShow.sync="isShowErr"
|
|
|
- :appendToBody="true"
|
|
|
- :isShowFooter="false"
|
|
|
- >
|
|
|
+ </Base-dialog>
|
|
|
+ <Base-dialog
|
|
|
+ title="提示"
|
|
|
+ width="660px"
|
|
|
+ :isShow.sync="isShowErr"
|
|
|
+ :isShowFooter="false"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
<div>
|
|
|
- <div>
|
|
|
- <h4 style="margin-top: 0px; font-weight: bold; text-align: center">
|
|
|
- 导入失败原因
|
|
|
- </h4>
|
|
|
- <el-input
|
|
|
- readonly
|
|
|
- type="textarea"
|
|
|
- :autosize="{ minRows: 6, maxRows: 24 }"
|
|
|
- v-model="errorData"
|
|
|
- >
|
|
|
- </el-input>
|
|
|
- </div>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="isShowErr = false">确定</el-button>
|
|
|
- </span>
|
|
|
+ <h4 style="margin-top: 0px; font-weight: bold; text-align: center">
|
|
|
+ 导入失败原因
|
|
|
+ </h4>
|
|
|
+ <el-input
|
|
|
+ readonly
|
|
|
+ type="textarea"
|
|
|
+ :autosize="{ minRows: 6, maxRows: 24 }"
|
|
|
+ v-model="errorData"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
</div>
|
|
|
- </Base-dialog>
|
|
|
- </div>
|
|
|
- </Base-dialog>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="isShowErr = false">确定</el-button>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </Base-dialog>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -98,6 +99,24 @@ export default {
|
|
|
type: Boolean,
|
|
|
default: true,
|
|
|
},
|
|
|
+ isShowTip: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true,
|
|
|
+ },
|
|
|
+ param: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {
|
|
|
+ return {};
|
|
|
+ },
|
|
|
+ },
|
|
|
+ type: {
|
|
|
+ type: String,
|
|
|
+ default: "Excel",
|
|
|
+ },
|
|
|
+ isSuccessBack: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -108,7 +127,10 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
getDowm() {
|
|
|
- let url = baseUrls.BASE_IMG_URL + this.temUrl;
|
|
|
+ let url =
|
|
|
+ baseUrls.BASE_IMG_URL +
|
|
|
+ this.temUrl +
|
|
|
+ `?time=${this.$methodsTools.getNewTime()}`;
|
|
|
let link = document.createElement("a");
|
|
|
let fileName = "导入模板" + ".xlsx";
|
|
|
document.body.appendChild(link);
|
|
@@ -118,27 +140,36 @@ export default {
|
|
|
link.remove();
|
|
|
},
|
|
|
importMobleadd(e) {
|
|
|
- var self = this;
|
|
|
var file = e.target.files[0];
|
|
|
if (file === undefined) {
|
|
|
e.target.value = "";
|
|
|
return;
|
|
|
}
|
|
|
var type = e.target.value.toLowerCase().split(".").splice(-1);
|
|
|
- if (type[0] != "xlsx" && type[0] != "xls") {
|
|
|
- self.$message.error("请上传excel文件,且上传格式需为:.xlsx");
|
|
|
- return;
|
|
|
+ if (this.type == "Excel") {
|
|
|
+ if (type[0] != "xlsx" && type[0] != "xls") {
|
|
|
+ e.target.value = "";
|
|
|
+ this.$message.error("请上传excel文件,且上传格式需为:.xlsx、.xls");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (type[0] != "docx") {
|
|
|
+ e.target.value = "";
|
|
|
+ this.$message.error("请上传word文件,且上传格式需为:.docx");
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
this.loading = true;
|
|
|
let formData = new FormData();
|
|
|
- this.isCheck &&
|
|
|
- formData.append("businessJson", JSON.stringify(this.newSujectApis));
|
|
|
formData.append("file", file);
|
|
|
+ for (const key in this.param) {
|
|
|
+ formData.append(key, this.param[key]);
|
|
|
+ }
|
|
|
this.$api[this.apiKey](formData)
|
|
|
.then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
this.isCheck && this.getFestivalList(res.data);
|
|
|
- this.getErrorData(res.data.errorLog);
|
|
|
+ this.getErrorData(res.data || res);
|
|
|
}
|
|
|
})
|
|
|
.finally(() => {
|
|
@@ -153,10 +184,10 @@ export default {
|
|
|
* @remards 失败时也需查询是否有成功的数据导入数据库,如存在 则加列队列同时提示
|
|
|
*/
|
|
|
getFestivalList({ importNo, errorLog }) {
|
|
|
- this.$api[checkKey]({ importNo })
|
|
|
+ this.$api[this.checkKey]({ importNo })
|
|
|
.then((res) => {
|
|
|
if (res.rows.length) {
|
|
|
- !errorLog &&
|
|
|
+ errorLog &&
|
|
|
this.$message({
|
|
|
type: "success",
|
|
|
message: `成功导入${res.rows.length}条数据,`,
|
|
@@ -167,7 +198,9 @@ export default {
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
- getErrorData(errorLog) {
|
|
|
+ getErrorData(data) {
|
|
|
+ this.isShow = false;
|
|
|
+ let { errorLog } = data;
|
|
|
if (errorLog) {
|
|
|
let ary = errorLog.split("\r\n");
|
|
|
ary = ary
|
|
@@ -183,13 +216,15 @@ export default {
|
|
|
this.errorData = ary;
|
|
|
this.isShowErr = true;
|
|
|
} else {
|
|
|
- this.$message({
|
|
|
- type: "success",
|
|
|
- message: `添加成功`,
|
|
|
- customClass: "myMessageClass",
|
|
|
- });
|
|
|
- this.$emit("success", []);
|
|
|
- this.isShow = false;
|
|
|
+ this.isShowTip &&
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: `添加成功`,
|
|
|
+ customClass: "myMessageClass",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!errorLog || this.isSuccessBack) {
|
|
|
+ this.$emit("success", data);
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@@ -203,11 +238,6 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- watch: {
|
|
|
- dialogVisible(val) {
|
|
|
- this.isShowErr = false;
|
|
|
- },
|
|
|
- },
|
|
|
};
|
|
|
</script>
|
|
|
|