Browse Source

党员导入

V1.0
mk 2 years ago
parent
commit
fbd0e0ee37
  1. 116
      src/views/modules/communityParty/members/memberList.vue

116
src/views/modules/communityParty/members/memberList.vue

@ -165,7 +165,7 @@
:http-request="uploadHttpRequest"
style="display: inline-block;margin:0px 10px"
>
<el-button type="primary" :loading="importLoading"
<el-button type="primary"
size="small"
class="diy-button--white el-button--default">导入</el-button>
</el-upload>
@ -577,35 +577,26 @@ export default {
})
},
/**
* 更新按钮点击
* @param row
*/
handleExcelSuccess(res) {
this.epmetResultResolver.success((data) => {
this.$message.success('上传完成,正在导入,请到导入记录中查看导入情况。');
}).fail(() => {
this.$message.error('导入失败');
}).parse(res);
},
/**
* 文件上传前的处理
* @param file
* @returns {boolean}
*/
beforeExcelUpload(file) {
// console.log('file', file);
const isXlsx = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
const isLt1M = file.size / 1024 / 1024 < 10;
if (!isXlsx) {
this.$message.error('上传文件只能是xlsx格式!');
}
if (!isLt1M) {
this.$message.error('上传文件大小不能超过 10MB!');
}
return isXlsx && isLt1M;
const isType = file.type === "application/vnd.ms-excel";
const isTypeComputer =
file.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
const fileType = isType || isTypeComputer;
const isLt1M = file.size / 1024 / 1024 < 10;
if (!fileType) {
this.$message.error("上传文件只能是xls/xlsx格式!");
}
if (!isLt1M) {
this.$message.error("上传文件大小不能超过 10MB!");
}
return fileType && isLt1M;
},
/**
@ -613,39 +604,58 @@ export default {
* @param file
* @returns {Promise<void>}
*/
async uploadHttpRequest(file) {
this.importLoading = true;
this.importBtnTitle = '正在上传中...';
// this.$message({
// showClose: true,
// dangerouslyUseHTMLString: true,
// 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');
// });
const formData = new FormData(); //FormDataappend('key', value)
formData.append('file', file.file); //
// formData.append('code', ''); //
await this.$http
.post('/actual/base/party/member/import', formData)
.then(res => {
debugger
this.epmetResultResolver.success((data) => {
this.$message.success('上传成功,正在导入,请到"系统管理-导入记录"中查看导入情况。');
}).parse(res.data);
async uploadHttpRequest(file) {
this.$message({
showClose: true,
dangerouslyUseHTMLString: true,
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");
});
const formData = new FormData(); //FormDataappend('key', value)
formData.append("file", file.file); //
formData.append("fileMode",'PARTYINFO');
await this.$http
.post("/actual/base/importExcelData/extractExcelHead", formData)
.then((res) => {
const { fileCode, msg } = res.data.data;
this.dataList = {"所属网格":"所属网格","所属小区":"所属小区","所属楼栋":"所属楼栋","所属单元":"所属单元","所属房屋":"所属房屋","本地户籍":"本地户籍","居民姓名":"居民姓名","联系电话":"联系电话","国籍":"国籍","证件类型":"证件类型","证件号":"证件号","民族":"民族","备注":"备注","文化程度":"文化程度","户籍地址":"户籍所在地","居住地址":"现居住地址","所属支部":"所属支部","入党时间":"入党时间","转正时间":"转正时间","流动党员":"流动党员","流动党员活动证号":"流动党员活动证号","党组织职务":"党组织职务","是否退休":"是否退休","党员中心户":"党员中心户","入党时所在党支部":"入党时所在党支部","组织关系转入社区时间":"组织关系转入社区时间","免学习":"免学习","工作职责":"职责"};
this.importCode = fileCode;
this.handleComfirmUpload()
})
.catch(err => {
console.log('失败', err);
.catch((err) => {
console.log("失败", err);
file.onError(); //
// this.$message.error('')
});
this.importLoading = false;
this.importBtnTitle = '导入';
this.$refs.upload.clearFiles();
},
},
async handleComfirmUpload () {
this.importLoading = true;
this.importBtnTitle = "正在上传中...";
const { importOption, importCode, dataList } = this;
const formData = new FormData();
formData.append("columnMateJson", JSON.stringify(dataList));
formData.append("fileCode", importCode);
await this.$http
.post("/actual/base/importExcelData/importResiHouseExcel", formData)
.then((res) => {
console.log("res-up", res);
if (res.data.code == 0 && res.data.msg == "success") {
this.getTableData();
} else this.$message.error(res.data.msg);
})
.catch((err) => {
console.log("失败", err);
file.onError(); //
});
this.importLoading = false;
this.importBtnTitle = "导入";
},
/**
* 单个删除

Loading…
Cancel
Save