|
|
@ -2,6 +2,7 @@ |
|
|
|
<div class="g-main"> |
|
|
|
<div class="m-table"> |
|
|
|
<div class="u-table-btn1"> |
|
|
|
|
|
|
|
<el-upload |
|
|
|
:headers="$getElUploadHeaders()" |
|
|
|
ref="upload" |
|
|
@ -17,12 +18,21 @@ |
|
|
|
:before-upload="beforeExcelUpload" |
|
|
|
:http-request="uploadHttpRequest" |
|
|
|
> |
|
|
|
<el-button |
|
|
|
<el-dropdown |
|
|
|
size="small" |
|
|
|
class="diy-button--white" |
|
|
|
:loading="importLoading" |
|
|
|
>表格导入</el-button |
|
|
|
type="primary" |
|
|
|
style="margin: 0 10px; height: 30px" |
|
|
|
@command="(command) => handleImportType(command)" |
|
|
|
trigger="hover" |
|
|
|
> |
|
|
|
<el-button type="primary"> |
|
|
|
表格导入<i class="el-icon-arrow-down el-icon--right"></i> |
|
|
|
</el-button> |
|
|
|
|
|
|
|
<el-dropdown-menu slot="dropdown" > |
|
|
|
<el-dropdown-item v-for="(item,index) in resiClass" :key="index" :command="item.value" >{{item.label}}</el-dropdown-item> |
|
|
|
</el-dropdown-menu> |
|
|
|
</el-dropdown> |
|
|
|
</el-upload> |
|
|
|
|
|
|
|
<el-button |
|
|
@ -68,9 +78,7 @@ |
|
|
|
min-width="110" |
|
|
|
> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span v-if="scope.row.exist">{{ |
|
|
|
scope.row.field |
|
|
|
}}</span> |
|
|
|
<span v-if="scope.row.exist">{{ scope.row.field }}</span> |
|
|
|
|
|
|
|
<div v-else> |
|
|
|
<el-select |
|
|
@ -81,9 +89,7 @@ |
|
|
|
> |
|
|
|
<el-option |
|
|
|
v-for="item in groupList" |
|
|
|
@click.native=" |
|
|
|
handleSelGroup(scope.$index, item) |
|
|
|
" |
|
|
|
@click.native="handleSelGroup(scope.$index, item)" |
|
|
|
:key="item.id" |
|
|
|
:label="item.label" |
|
|
|
:value="item.id" |
|
|
@ -142,7 +148,32 @@ export default { |
|
|
|
}, |
|
|
|
// tableHeight: 500, |
|
|
|
search: "", |
|
|
|
dataList: [], |
|
|
|
dataList: [ |
|
|
|
// { |
|
|
|
// index: "key1", |
|
|
|
// srcField: "value1_from_exist", |
|
|
|
// exist: true, |
|
|
|
// field: "value1_from_exist" |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// index: "key2", |
|
|
|
// srcField: "value2_from_exist", |
|
|
|
// exist: true, |
|
|
|
// field: "value2_from_exist" |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// index: "key3", |
|
|
|
// srcField: "value3_from_notExist", |
|
|
|
// exist: false, |
|
|
|
// field: "" |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// index: "key4", |
|
|
|
// srcField: "value4_from_notExist", |
|
|
|
// exist: false, |
|
|
|
// field: "" |
|
|
|
// }, |
|
|
|
], |
|
|
|
|
|
|
|
dataListLoading: false, |
|
|
|
total: 0, |
|
|
@ -163,6 +194,9 @@ export default { |
|
|
|
importOption: { exist: {}, notExist: {} }, |
|
|
|
|
|
|
|
fileData: null, |
|
|
|
resiClass: [], |
|
|
|
|
|
|
|
importType :'' |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
@ -180,6 +214,7 @@ export default { |
|
|
|
async mounted() { |
|
|
|
// await this.loadData(); |
|
|
|
await this.loadPersonGroup(); |
|
|
|
this.getResident() |
|
|
|
|
|
|
|
this.sHeight = this.$refs.divEditBtn.offsetHeight + 300; |
|
|
|
}, |
|
|
@ -236,23 +271,23 @@ export default { |
|
|
|
pageNo: this.pageNo, |
|
|
|
}; |
|
|
|
|
|
|
|
const { data, code, msg } = await requestPost( |
|
|
|
url, |
|
|
|
this.tableParams |
|
|
|
); |
|
|
|
const { data, code, msg } = await requestPost(url, this.tableParams); |
|
|
|
this.dataListLoading = false; |
|
|
|
if (code === 0) { |
|
|
|
this.total = data.total; |
|
|
|
this.dataList = data.list; |
|
|
|
this.dataList.forEach((element) => { |
|
|
|
element.stateShow = |
|
|
|
element.switchStatus === "open" ? true : false; |
|
|
|
element.stateShow = element.switchStatus === "open" ? true : false; |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// this.$message.error(msg ) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleImportType(command){ |
|
|
|
this.importType = command |
|
|
|
// this.$refs.upload.click(); |
|
|
|
this.$refs['upload'].$children[0].$refs.input.click() |
|
|
|
}, |
|
|
|
handleChangeScope(value) { |
|
|
|
// console.log('value', value) |
|
|
|
|
|
|
@ -273,7 +308,16 @@ export default { |
|
|
|
|
|
|
|
console.log("this.scopeList", this.scopeList); |
|
|
|
}, |
|
|
|
|
|
|
|
async getResident() { |
|
|
|
try { |
|
|
|
const { data } = await this.$http.post("sys/dict/data/dictlist", { |
|
|
|
dictType: "resident_category", |
|
|
|
}); |
|
|
|
this.resiClass = data.data; |
|
|
|
} catch (error) { |
|
|
|
console.log(error, "获取居民类别字典"); |
|
|
|
} |
|
|
|
}, |
|
|
|
async handleExportModule() { |
|
|
|
let url = "/actual/base/residentBaseInfo/import/download-template"; |
|
|
|
|
|
|
@ -285,15 +329,15 @@ export default { |
|
|
|
data: params, |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
const url = window.URL.createObjectURL(new Blob([res.data])) |
|
|
|
const aLink = document.createElement('a') |
|
|
|
aLink.style.display = 'none' |
|
|
|
aLink.href = url |
|
|
|
aLink.setAttribute('download', '人员导入模板.zip') |
|
|
|
document.body.appendChild(aLink) |
|
|
|
aLink.click() |
|
|
|
document.body.removeChild(aLink) |
|
|
|
window.URL.revokeObjectURL(url) |
|
|
|
const url = window.URL.createObjectURL(new Blob([res.data])); |
|
|
|
const aLink = document.createElement("a"); |
|
|
|
aLink.style.display = "none"; |
|
|
|
aLink.href = url; |
|
|
|
aLink.setAttribute("download", "人员导入模板.zip"); |
|
|
|
document.body.appendChild(aLink); |
|
|
|
aLink.click(); |
|
|
|
document.body.removeChild(aLink); |
|
|
|
window.URL.revokeObjectURL(url); |
|
|
|
// // this.download(res.data, title + '.xls') |
|
|
|
// if (res.headers["content-disposition"]) { |
|
|
|
// let fileName = window.decodeURI( |
|
|
@ -335,6 +379,8 @@ export default { |
|
|
|
|
|
|
|
beforeExcelUpload(file) { |
|
|
|
console.log("file", file); |
|
|
|
console.log(this.importType); |
|
|
|
|
|
|
|
const isType = file.type === "application/vnd.ms-excel"; |
|
|
|
const isTypeComputer = |
|
|
|
file.type === |
|
|
@ -348,9 +394,14 @@ export default { |
|
|
|
if (!isLt1M) { |
|
|
|
this.$message.error("上传文件大小不能超过 10MB!"); |
|
|
|
} |
|
|
|
|
|
|
|
if(!this.importType){ |
|
|
|
this.$message.error('请选择导入的类别') |
|
|
|
} |
|
|
|
return fileType && isLt1M; |
|
|
|
}, |
|
|
|
async uploadHttpRequest(file) { |
|
|
|
if(!this.importType) return |
|
|
|
this.importLoading = true; |
|
|
|
this.importBtnTitle = "正在上传中..."; |
|
|
|
const formData = new FormData(); //FormData对象,添加参数只能通过append('key', value)的形式添加 |
|
|
@ -363,7 +414,7 @@ export default { |
|
|
|
if (res.data.code == 0 && res.data.msg == "success") { |
|
|
|
console.log(res.data.data); |
|
|
|
const data = res.data.data; |
|
|
|
this.afterSuccess() |
|
|
|
this.afterSuccess(); |
|
|
|
this.dataList = [ |
|
|
|
...Object.keys(data.option.exist).map((k) => { |
|
|
|
return { |
|
|
@ -458,13 +509,14 @@ export default { |
|
|
|
this.$message({ |
|
|
|
showClose: true, |
|
|
|
dangerouslyUseHTMLString: true, |
|
|
|
message: "导入中,请到系统管理-<a id='clickA' style='cursor: pointer;'>导入记录</a>中查看进度", |
|
|
|
duration: 3000 |
|
|
|
message: |
|
|
|
"导入中,请到系统管理-<a id='clickA' style='cursor: pointer;'>导入记录</a>中查看进度", |
|
|
|
duration: 3000, |
|
|
|
}); |
|
|
|
let than = this; |
|
|
|
document.getElementById("clickA").addEventListener("click", function () { |
|
|
|
than.$router.replace("/main/importRecord-index"); |
|
|
|
}); |
|
|
|
let than = this |
|
|
|
document.getElementById('clickA').addEventListener('click',function(){ |
|
|
|
than.$router.replace('/main/importRecord-index'); |
|
|
|
}) |
|
|
|
this.dataList = []; |
|
|
|
this.importOption = {}; |
|
|
|
this.importCode = ""; |
|
|
@ -500,4 +552,9 @@ export default { |
|
|
|
text-align: center; |
|
|
|
color: #aaaaaa; |
|
|
|
} |
|
|
|
::v-deep .upload-btn{ |
|
|
|
.el-button{ |
|
|
|
padding: 7px 20px; |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|