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