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. 48
      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'})
this.resiClass = data.data
} catch (error) {
console.log(error,'获取配偶情况字典');
console.log(error,'获取居民类别字典');
}
},
computedBirth(age) {

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

@ -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(); //FormDataappend('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>

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

@ -99,7 +99,7 @@
</el-select>
</template>
</el-table-column>
<el-table-column label="对应值" align="center" >
<el-table-column label="对应值" align="center">
<template slot-scope="scope">
<template v-for="item in scope.row.correspondingOpction">
<el-select
@ -186,7 +186,13 @@
</el-select>
</template>
</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">
<!-- <img
src="@/assets/img/icon-del.png"
@ -206,11 +212,15 @@
<el-button
type="danger"
@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"
icon="el-icon-minus"
circle
> </el-button>
>
</el-button>
<!-- <img
src="@/assets/img/icon-add.png"
@click="handleClickAddRow"
@ -258,7 +268,7 @@ export default {
],
},
timeout: null,
tagObj:{},
tagObj: {},
searchList: [],
tableData: [
{
@ -295,14 +305,14 @@ export default {
methods: {
async initForm(type, row) {
this.formType = type;
if(type == 'info'){
if (type == "info") {
await this.getFormEdit(row.tagId);
}else if(type == 'edit'){
} else if (type == "edit") {
await this.getFormEdit(row.tagId);
this.formData.tagName = row.tagName;
}
this.tagId = row.tagId;
this.tagObj = row
this.tagObj = row;
for (let i in this.tableData) {
this.handleChangeSource(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);
}, 300);
}
},
querySearchAsync(val, cb) {
console.log(this.searchList);
@ -319,11 +328,11 @@ export default {
var results = val
? searchList.filter(this.createStateFilter(val))
: searchList;
if(results.length == 0){
this.handleClickAddRow()
this.formType = 'add'
}else{
this.formType = 'info'
if (results.length == 0) {
this.handleClickAddRow();
this.formType = "add";
} else {
this.formType = "info";
}
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
@ -574,7 +583,7 @@ export default {
}
});
} else {
this.$emit("dialogOk",this.tagObj);
this.$emit("dialogOk", this.tagObj);
return this.tagId;
}
},
@ -588,7 +597,7 @@ export default {
rules: this.tableData,
tagId: this.tagId,
};
} else if(this.formType == "add"){
} else if (this.formType == "add") {
url = "/governance/resiSearchTag/addResiSearchTag";
params = {
tagName: this.formData.tagName,
@ -598,7 +607,7 @@ export default {
const { data, msg, code } = await requestPost(url, params);
if (code == 0) {
this.$message.success("操作成功");
this.$emit("dialogOk",{tagId:data.id,tagName:data.tagName});
this.$emit("dialogOk", { tagId: data.id, tagName: data.tagName });
} else if (code >= 8000) {
this.$message.error(msg);
}
@ -689,18 +698,21 @@ export default {
<style lang="scss" scoped>
@import "@/assets/scss/modules/management/list-main.scss";
.imgBtn {
width: 25px;
height: 25px;
margin-top: 3px;
cursor: pointer;
}
.div_btn {
display: flex;
justify-content: flex-end;
margin-top: 10px;
}
.my_form{
.my_form {
padding: 10px 50px 0;
}
</style>

Loading…
Cancel
Save