2022-01-16 10:40:57 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div id="importChannel" v-loading="isLoging">
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="导入通道数据"
|
|
|
|
|
width="30rem"
|
|
|
|
|
top="2rem"
|
|
|
|
|
:append-to-body="true"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
:visible.sync="showDialog"
|
|
|
|
|
:destroy-on-close="true"
|
|
|
|
|
@close="close()"
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
|
<el-upload
|
|
|
|
|
class="upload-box"
|
|
|
|
|
drag
|
2022-01-17 09:41:43 +08:00
|
|
|
|
:action="uploadUrl"
|
2022-01-16 10:40:57 +08:00
|
|
|
|
name="file"
|
2022-01-20 16:48:30 +08:00
|
|
|
|
:on-success="successHook"
|
|
|
|
|
:on-error="errorHook"
|
2022-01-16 10:40:57 +08:00
|
|
|
|
>
|
|
|
|
|
<i class="el-icon-upload"></i>
|
|
|
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
|
|
<div class="el-upload__tip" slot="tip">只能上传 csv / xls / xlsx 文件</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
2022-01-20 16:48:30 +08:00
|
|
|
|
<ShowErrorData ref="showErrorData" :gbIds="errorGBIds" :streams="errorStreams" ></ShowErrorData>
|
2022-01-16 10:40:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
2022-01-20 16:48:30 +08:00
|
|
|
|
import ShowErrorData from './importChannelShowErrorData.vue'
|
|
|
|
|
|
2022-01-16 10:40:57 +08:00
|
|
|
|
export default {
|
|
|
|
|
name: "importChannel",
|
2022-01-20 16:48:30 +08:00
|
|
|
|
components: {
|
|
|
|
|
ShowErrorData,
|
|
|
|
|
},
|
2022-01-16 10:40:57 +08:00
|
|
|
|
created() {},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
submitCallback: null,
|
|
|
|
|
showDialog: false,
|
|
|
|
|
isLoging: false,
|
|
|
|
|
isEdit: false,
|
2022-02-07 18:30:43 +08:00
|
|
|
|
errorStreams: [],
|
|
|
|
|
errorGBIds: [],
|
2022-01-17 10:16:58 +08:00
|
|
|
|
uploadUrl: process.env.NODE_ENV === 'development'?`debug/api/push/upload`:`api/push/upload`,
|
2022-01-16 10:40:57 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
openDialog: function (callback) {
|
|
|
|
|
this.showDialog = true;
|
|
|
|
|
this.submitCallback = callback;
|
|
|
|
|
},
|
|
|
|
|
onSubmit: function () {
|
|
|
|
|
console.log("onSubmit");
|
|
|
|
|
console.log(this.form);
|
|
|
|
|
this.$axios({
|
|
|
|
|
method:"post",
|
2023-02-07 20:59:33 +08:00
|
|
|
|
url:`./api/platform/catalog/${!this.isEdit? "add":"edit"}`,
|
2022-01-16 10:40:57 +08:00
|
|
|
|
data: this.form
|
|
|
|
|
})
|
|
|
|
|
.then((res)=> {
|
|
|
|
|
if (res.data.code === 0) {
|
|
|
|
|
console.log("添加/修改成功")
|
|
|
|
|
if (this.submitCallback)this.submitCallback()
|
|
|
|
|
}else {
|
|
|
|
|
this.$message({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: res.data.msg,
|
|
|
|
|
type: "error",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.close();
|
|
|
|
|
})
|
|
|
|
|
.catch((error)=> {
|
|
|
|
|
console.log(error);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
close: function () {
|
|
|
|
|
this.showDialog = false;
|
|
|
|
|
},
|
2022-01-20 16:48:30 +08:00
|
|
|
|
successHook: function(response, file, fileList){
|
|
|
|
|
if (response.code === 0) {
|
|
|
|
|
this.$message({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: response.msg,
|
|
|
|
|
type: "success",
|
|
|
|
|
});
|
|
|
|
|
}else if (response.code === 1) {
|
|
|
|
|
this.errorGBIds = response.data.gbId
|
|
|
|
|
this.errorStreams = response.data.stream
|
|
|
|
|
console.log(this.$refs)
|
|
|
|
|
console.log(this.$refs.showErrorData)
|
|
|
|
|
this.$refs.showErrorData.openDialog()
|
|
|
|
|
}else {
|
|
|
|
|
this.$message({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: response.msg,
|
|
|
|
|
type: "error",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
errorHook: function (err, file, fileList) {
|
|
|
|
|
this.$message({
|
|
|
|
|
showClose: true,
|
|
|
|
|
message: err,
|
|
|
|
|
type: "error",
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-01-16 10:40:57 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
<style>
|
|
|
|
|
.upload-box{
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
2022-01-20 16:48:30 +08:00
|
|
|
|
.errDataBox{
|
|
|
|
|
max-height: 15rem;
|
|
|
|
|
overflow: auto;
|
|
|
|
|
}
|
2022-01-16 10:40:57 +08:00
|
|
|
|
</style>
|