<template>
|
<!--导入-->
|
<el-dialog
|
class="height-auto"
|
title="导入"
|
:visible="value"
|
width=""
|
:modal="false"
|
:show-close="false"
|
:before-close="onCancel"
|
>
|
<div class="loading-box" v-loading="loading">
|
<span class="import-btn" v-for="(text, index) in importData" :key="index">
|
<el-upload
|
name="file"
|
accept=".xls, .xlsx"
|
:headers="{ Authorization: Authorization }"
|
class="upload-demo"
|
:show-file-list="false"
|
:action="text.url"
|
:on-success="success"
|
:on-error="error"
|
:before-upload="beforeUpload"
|
multiple
|
>
|
<el-button type="primary" plain class="m_btn bgc_primary"
|
>{{ text.name }}
|
</el-button>
|
</el-upload>
|
</span>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<!-- 导入错误按钮 -->
|
<el-button type="text" class="danger-text" v-if="errUrl" @click="dowErr"
|
>下载错误表格</el-button
|
>
|
<el-button @click="onCancel">取 消</el-button>
|
<el-button type="primary" @click="onOk('ruleForm')">确 定</el-button>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
export default {
|
props: {
|
value: { type: Boolean },
|
},
|
|
data() {
|
return {
|
Authorization: "",
|
loading: false,
|
errUrl: "", //导入失败地址
|
errpostUrl: "", //导入失败请求接口
|
importData: [
|
{
|
name: "实有人口",
|
url: this.$js.api.http + "common/data/population/serve/import",
|
error: "population",
|
},
|
{
|
name: "吸毒人员",
|
url: this.$js.api.http + "common/data/population/serve/importDrug",
|
error: "populationDrug",
|
},
|
{
|
name: "社区矫正人员",
|
url: this.$js.api.http + "common/data/population/serve/importCorrect",
|
},
|
{
|
name: "邪教人员",
|
url: this.$js.api.http + "common/data/population/serve/importCult",
|
},
|
{
|
name: "残疾人",
|
url:
|
this.$js.api.http + "common/data/population/serve/importDisability",
|
},
|
{
|
name: "重点上访人员",
|
url: this.$js.api.http + "common/data/population/serve/importKey",
|
},
|
{
|
name: "低保户",
|
url:
|
this.$js.api.http +
|
"common/data/population/serve/importLowSecurity",
|
},
|
{
|
name: "重精人员",
|
url: this.$js.api.http + "common/data/population/serve/importMajor",
|
},
|
{
|
name: "刑释人员",
|
url:
|
this.$js.api.http +
|
"common/data/population/serve/importRehabilitation",
|
},
|
// {
|
// name:'服刑人员',
|
// url:this.$js.api.http + "common/data/population/serve/importSentence"
|
// },
|
{
|
name: "退役军人",
|
url:
|
this.$js.api.http + "common/data/population/serve/importVeterans",
|
},
|
{
|
name: "高龄老人",
|
url: this.$js.api.http + "common/data/population/serve/importElder",
|
},
|
{
|
name: "养老人员",
|
url: this.$js.api.http + "common/data/population/serve/importPension",
|
},
|
],
|
};
|
},
|
|
created() {
|
this.Authorization = "Bearer " + demo.$session.get("token") || "";
|
},
|
|
// computed: {
|
// syupl() {
|
// return this.$js.api.http + "common/data/population/serve/import";
|
// },
|
// },
|
|
methods: {
|
/** 取消 */
|
onCancel() {
|
this.$emit("change", false);
|
},
|
|
/** 确认 */
|
onOk(formName) {},
|
|
//导入前
|
beforeUpload() {
|
console.log("1111");
|
this.errUrl = "";
|
this.loading = true;
|
this.msg = "导入中,请勿退出系统和关闭网络";
|
},
|
|
success(e, file, fileList) {
|
// console.log(fileList)
|
//导入成功
|
this.loading = false;
|
if (e.msg === "导入数据为空!") {
|
demo.toast("导入模板为空");
|
return;
|
}
|
if (e.code !== 200) {
|
this.errUrl = e.msg;
|
switch (this.errUrl) {
|
case "DRUG_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationDrug";
|
break;
|
|
case "POPULATION_ERROR_LIST_":
|
this.errpostUrl = "population";
|
break;
|
|
case "CORRECT_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationCorrect";
|
break;
|
|
case "CULT_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationCult";
|
break;
|
case "KEY_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationKey";
|
break;
|
|
case "MAJOR_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationMajor";
|
break;
|
case "NumberFormatException":
|
demo.toast("表格中数据格式有误,请修改后重新导入");
|
break;
|
|
case "REHABILITATION_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationRehabilitation";
|
break;
|
|
case "SENTENCE_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationSentence";
|
break;
|
|
case "VETERANS_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationVeterans";
|
break;
|
|
case "DISABILITY_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationDisability";
|
break;
|
|
case "LOWSECURITY_POPULATION_ERROR_LIST_":
|
this.errpostUrl = "populationLowSecurity";
|
break;
|
default:
|
if (this.errUrl.search("ELDER_POPULATION_ERROR_LIST") !== -1) {
|
this.errpostUrl = "populationElder";
|
} else if (
|
this.errUrl.search("PENSION_POPULATION_ERROR_LIST") !== -1
|
) {
|
this.errpostUrl = "populationPension";
|
}
|
// this.errpostUrl = '';
|
break;
|
}
|
this.$emit("success");
|
// demo.toast("导入模板错误");
|
} else {
|
demo.toast("导入成功");
|
this.errUrl = "";
|
this.$emit("success");
|
this.onCancel();
|
}
|
},
|
|
error(err) {
|
this.loading = false;
|
demo.toast("导入失败!请检查内容是否正确");
|
// console.log(err)
|
},
|
|
dowErr() {
|
//下载错误i
|
let data = {
|
key: this.errUrl,
|
};
|
this.$api.post(
|
"common/data/population/download/error/" +
|
this.errpostUrl +
|
"?key=" +
|
this.errUrl,
|
"",
|
(e) => {
|
// console.log(e)
|
location.href = e;
|
}
|
);
|
},
|
},
|
};
|
</script>
|
|
<style lang="less" scoped>
|
/deep/.el-dialog__body {
|
height: 150px;
|
}
|
/deep/.el-button--text {
|
color: #f56c6c;
|
text-decoration: underline;
|
}
|
.loading-box {
|
width: 100%;
|
height: 100%;
|
}
|
.import-btn {
|
float: left;
|
margin-right: 15px;
|
margin-bottom: 15px;
|
}
|
</style>
|