|
|
@ -44,7 +44,6 @@ |
|
|
|
>下载模板</el-button |
|
|
|
> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div v-if="dataList.length > 0"> |
|
|
|
<el-table |
|
|
|
ref="ref_table" |
|
|
@ -62,7 +61,6 @@ |
|
|
|
type="index" |
|
|
|
width="100" |
|
|
|
></el-table-column> |
|
|
|
|
|
|
|
<el-table-column |
|
|
|
prop="userTableHeader" |
|
|
|
header-align="center" |
|
|
@ -70,9 +68,13 @@ |
|
|
|
label="表格信息" |
|
|
|
min-width="100" |
|
|
|
> |
|
|
|
<template slot-scope="scope"> |
|
|
|
{{ scope.row.userTableHeader || "--" }} |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<el-table-column |
|
|
|
prop="field" |
|
|
|
prop="itemGroupId" |
|
|
|
header-align="center" |
|
|
|
align="center" |
|
|
|
label="平台对应信息" |
|
|
@ -88,7 +90,7 @@ |
|
|
|
> |
|
|
|
<el-option |
|
|
|
v-for="item in groupList" |
|
|
|
@click.native="handleSelGroup(scope.$index, item,'change')" |
|
|
|
@click.native="handleSelGroup(scope.$index, item, 'change')" |
|
|
|
:key="item.value" |
|
|
|
:label="item.label" |
|
|
|
:value="item.label" |
|
|
@ -126,7 +128,6 @@ |
|
|
|
> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="m-hint" v-else>请先导入表格</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -178,7 +179,7 @@ export default { |
|
|
|
importLoading: false, |
|
|
|
|
|
|
|
groupList: [], |
|
|
|
sHeight: 0, |
|
|
|
sHeight: 100, |
|
|
|
|
|
|
|
importCode: "", |
|
|
|
importOption: { exist: {}, notExist: {} }, |
|
|
@ -243,7 +244,9 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
//选择人员信息第一列下拉框 |
|
|
|
async handleSelGroup(index, item,change) { |
|
|
|
async handleSelGroup(index, item, change) { |
|
|
|
console.log(index, item, change); |
|
|
|
console.log("让我看看返回的什么"); |
|
|
|
const url = "/oper/customize/icformitem/getItemListV2"; |
|
|
|
// const url = 'http://yapi.elinkservice.cn/mock/245/gov/org/isServiceProject/service/serviceScopeTree' |
|
|
|
let params = { |
|
|
@ -254,10 +257,10 @@ export default { |
|
|
|
|
|
|
|
if (code === 0) { |
|
|
|
let oneData = this.dataList[index]; |
|
|
|
if(change == 'change'){ |
|
|
|
this.dataList[index].itemId = '' |
|
|
|
} |
|
|
|
oneData.itemList = data; |
|
|
|
if (change == "change") { |
|
|
|
this.dataList[index].itemId = ""; |
|
|
|
} |
|
|
|
oneData.itemList = data; |
|
|
|
this.$set(this.dataList, index, oneData); |
|
|
|
} else { |
|
|
|
this.$message.error(msg); |
|
|
@ -313,7 +316,9 @@ export default { |
|
|
|
const { data } = await this.$http.post("sys/dict/data/dictlist", { |
|
|
|
dictType: "resident_category", |
|
|
|
}); |
|
|
|
let myObject = { label: "基础信息", value: "BASEINFO" }; |
|
|
|
this.resiClass = data.data; |
|
|
|
this.resiClass.unshift(myObject); |
|
|
|
} catch (error) { |
|
|
|
console.log(error, "获取居民类别字典"); |
|
|
|
} |
|
|
@ -408,30 +413,36 @@ export default { |
|
|
|
this.importBtnTitle = "正在上传中..."; |
|
|
|
const formData = new FormData(); //FormData对象,添加参数只能通过append('key', value)的形式添加 |
|
|
|
formData.append("file", file.file); //添加文件对象 |
|
|
|
formData.append("flieModel", "flieModel"); //添加文件对象 |
|
|
|
formData.append("fileMode", this.importType); //添加文件对象 |
|
|
|
// http://127.0.0.1:4523/mock2/2515967/97869993 |
|
|
|
await this.$http |
|
|
|
.post("/actual/base/residentBaseInfo/importExcel", formData) |
|
|
|
.post("/actual/base/importExcelData/extractExcelHead", formData) |
|
|
|
.then((res) => { |
|
|
|
console.log("res-up", res); |
|
|
|
if (res.data.code == 0 ) { |
|
|
|
const { data: rawData } = res.data.data; |
|
|
|
rawData.forEach((item, index) => { |
|
|
|
const arr = this.groupList.filter(group => group.label === item.itemGroupId); |
|
|
|
this.handleSelGroup(index, arr[0]); |
|
|
|
}); |
|
|
|
if (res.data.code == 0) { |
|
|
|
const { metaListData, fileCode, msg } = res.data.data; |
|
|
|
this.afterSuccess(); |
|
|
|
this.dataList = rawData |
|
|
|
this.importCode = res.data.data.importCode; |
|
|
|
this.dataList = metaListData; |
|
|
|
// 相等于在for循环中写filter过滤,这样写能够以 O(1) 的时间复杂度获取 itemGroupId 匹配的元素。 |
|
|
|
let groupMap = new Map( |
|
|
|
this.groupList.map((item) => [item.label, item]) |
|
|
|
); |
|
|
|
for (let i in this.dataList) { |
|
|
|
this.handleSelGroup( |
|
|
|
i, |
|
|
|
groupMap.get(this.dataList[i].itemGroupId) |
|
|
|
); |
|
|
|
} |
|
|
|
this.importCode = fileCode; |
|
|
|
this.fileData = file; |
|
|
|
} else{ |
|
|
|
this.$message.error(res.rawData.msg); |
|
|
|
} else { |
|
|
|
this.$message.error(msg); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
console.log("失败", err); |
|
|
|
file.onError(); //上传失败的文件会从文件列表中删除 |
|
|
|
this.$message.error('导入失败') |
|
|
|
this.$message.error("导入失败"); |
|
|
|
}); |
|
|
|
this.importLoading = false; |
|
|
|
this.importBtnTitle = "导入"; |
|
|
@ -442,13 +453,17 @@ export default { |
|
|
|
this.importLoading = true; |
|
|
|
this.importBtnTitle = "正在上传中..."; |
|
|
|
const { importOption, importCode, dataList } = this; |
|
|
|
//MOCK http://127.0.0.1:4523/mock2/2515967/97971313 |
|
|
|
let arr = dataList.map(item=>({userTableHeader:item.userTableHeader,itemGroupId:item.itemGroupId,itemId:item.itemId})) |
|
|
|
let obj = dataList.reduce((acc, item) => { |
|
|
|
if (item.userTableHeader) { |
|
|
|
acc[item.userTableHeader] = item.itemId; |
|
|
|
} |
|
|
|
return acc; |
|
|
|
}, {}); |
|
|
|
const formData = new FormData(); |
|
|
|
formData.append("columnMateJson", JSON.stringify(obj)); |
|
|
|
formData.append("fileCode", importCode); |
|
|
|
await this.$http |
|
|
|
.post("/actual/base/residentBaseInfo/import/header", { |
|
|
|
importCode, |
|
|
|
option:arr, |
|
|
|
}) |
|
|
|
.post("/actual/base/importExcelData/importResiHouseExcel", formData) |
|
|
|
.then((res) => { |
|
|
|
console.log("res-up", res); |
|
|
|
if (res.data.code == 0 && res.data.msg == "success") { |
|
|
|