Browse Source

,内容暂时用居民信息字智能导入下拉选中上传实现典占位

V1.0
mk 2 years ago
parent
commit
a099dd8af5
  1. 2
      src/views/components/resiSearch.vue
  2. 127
      src/views/modules/base/smartImport.vue
  3. 32
      src/views/modules/communityService/labelConfig/addForm.vue

2
src/views/components/resiSearch.vue

@ -902,7 +902,7 @@ export default {
const { data } = await this.$http.post('sys/dict/data/dictlist', {'dictType':'resident_category'}) const { data } = await this.$http.post('sys/dict/data/dictlist', {'dictType':'resident_category'})
this.resiClass = data.data this.resiClass = data.data
} catch (error) { } catch (error) {
console.log(error,'获取配偶情况字典'); console.log(error,'获取居民类别字典');
} }
}, },
computedBirth(age) { computedBirth(age) {

127
src/views/modules/base/smartImport.vue

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

32
src/views/modules/communityService/labelConfig/addForm.vue

@ -186,7 +186,13 @@
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column fixed="right" label="操作" align="center" width="120" v-if="formType!='info'"> <el-table-column
fixed="right"
label="操作"
align="center"
width="120"
v-if="formType != 'info'"
>
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <img <!-- <img
src="@/assets/img/icon-del.png" src="@/assets/img/icon-del.png"
@ -206,11 +212,15 @@
<el-button <el-button
type="danger" type="danger"
@click="handleClickDelete(scope.$index)" @click="handleClickDelete(scope.$index)"
v-if="scope.$index != tableData.length - 1||(tableData.length - 1>=1&&scope.$index !='0' )" v-if="
scope.$index != tableData.length - 1 ||
(tableData.length - 1 >= 1 && scope.$index != '0')
"
size="small" size="small"
icon="el-icon-minus" icon="el-icon-minus"
circle circle
> </el-button> >
</el-button>
<!-- <img <!-- <img
src="@/assets/img/icon-add.png" src="@/assets/img/icon-add.png"
@click="handleClickAddRow" @click="handleClickAddRow"
@ -295,14 +305,14 @@ export default {
methods: { methods: {
async initForm(type, row) { async initForm(type, row) {
this.formType = type; this.formType = type;
if(type == 'info'){ if (type == "info") {
await this.getFormEdit(row.tagId); await this.getFormEdit(row.tagId);
}else if(type == 'edit'){ } else if (type == "edit") {
await this.getFormEdit(row.tagId); await this.getFormEdit(row.tagId);
this.formData.tagName = row.tagName; this.formData.tagName = row.tagName;
} }
this.tagId = row.tagId; this.tagId = row.tagId;
this.tagObj = row this.tagObj = row;
for (let i in this.tableData) { for (let i in this.tableData) {
this.handleChangeSource(this.tableData[i], [i], type); this.handleChangeSource(this.tableData[i], [i], type);
this.handleChangeFieldsType(this.tableData[i], [i], type); this.handleChangeFieldsType(this.tableData[i], [i], type);
@ -310,7 +320,6 @@ export default {
this.handleChangeFieldsName(this.tableData[i], [i], type); this.handleChangeFieldsName(this.tableData[i], [i], type);
}, 300); }, 300);
} }
}, },
querySearchAsync(val, cb) { querySearchAsync(val, cb) {
console.log(this.searchList); console.log(this.searchList);
@ -320,10 +329,10 @@ export default {
? searchList.filter(this.createStateFilter(val)) ? searchList.filter(this.createStateFilter(val))
: searchList; : searchList;
if (results.length == 0) { if (results.length == 0) {
this.handleClickAddRow() this.handleClickAddRow();
this.formType = 'add' this.formType = "add";
} else { } else {
this.formType = 'info' this.formType = "info";
} }
clearTimeout(this.timeout); clearTimeout(this.timeout);
this.timeout = setTimeout(() => { this.timeout = setTimeout(() => {
@ -689,17 +698,20 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
@import "@/assets/scss/modules/management/list-main.scss"; @import "@/assets/scss/modules/management/list-main.scss";
.imgBtn { .imgBtn {
width: 25px; width: 25px;
height: 25px; height: 25px;
margin-top: 3px; margin-top: 3px;
cursor: pointer; cursor: pointer;
} }
.div_btn { .div_btn {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
margin-top: 10px; margin-top: 10px;
} }
.my_form { .my_form {
padding: 10px 50px 0; padding: 10px 50px 0;
} }

Loading…
Cancel
Save