You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
641 lines
20 KiB
641 lines
20 KiB
// subpages/addResi/pages/addResi/addResi.js
|
|
import api from "../../../../utils/api"
|
|
import { $wuxSelect } from '../../../../components/dist/index'
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
nation:[],
|
|
education:[],
|
|
marriageList:[],
|
|
marriageName:'',
|
|
form:{
|
|
agencyName: "",
|
|
agencyId: "",
|
|
resiId: "",
|
|
houseMergeId: "",
|
|
categoryId: "",
|
|
gridName: "",
|
|
gridId: "",
|
|
villageId: "",
|
|
buildId: "",
|
|
unitId: "",
|
|
homeId: "",
|
|
name: "",
|
|
nation: "",
|
|
remark: "",
|
|
localResidenceFlag: "",
|
|
birthday: "",
|
|
idNum: "",
|
|
gender: "",
|
|
mobile: "",
|
|
partyFlag: 0,
|
|
subsistenceAllowanceFlag: 0,
|
|
ensureHouseFlag: 0,
|
|
unemployedFlag: 0,
|
|
fertileWomanFlag: 0,
|
|
veteranFlag: 0,
|
|
unitedFrontFlag: 0,
|
|
petitionOfficerFlag: "",
|
|
volunteerFlag: 0,
|
|
bereavedPersonFlag: 0,
|
|
tenantFlag: 0,
|
|
floatingFlag: 0,
|
|
specialCrowdFlag: 0,
|
|
oldPeopleFlag: 0,
|
|
emptyNesterFlag: 0,
|
|
liveAloneFlag: 0,
|
|
disabledFlag: 0,
|
|
dementedFlag: 0,
|
|
disabilityFlag: 0,
|
|
seriousIllnessFlag: 0,
|
|
chronicDiseaseFlag: 0,
|
|
publicWelfareFlag: 0,
|
|
resideInfoDto: {
|
|
placeOfDomicile: "",
|
|
currentResidence: "",
|
|
nativePlace: ""
|
|
},
|
|
eduInfoDto: {
|
|
cultureLevel: ""
|
|
},
|
|
familyInfoDto: {
|
|
marriage: ""
|
|
},
|
|
religionDto: {
|
|
religion: ""
|
|
}
|
|
},
|
|
isFirstLoadGrid:true,
|
|
isFirstLoadVillage: true,
|
|
isFirstLoadBuilding:true,
|
|
isFirstLoadUnit:true,
|
|
isFirstLoadHouse:true,
|
|
agencyId:'',
|
|
gridList:[],
|
|
villageList:[],
|
|
villageName:'',
|
|
buildingList:[],
|
|
buildingName:'',
|
|
unitList:[],
|
|
unitName:'',
|
|
houseList:[],
|
|
houseName:'',
|
|
genderList:[{label:'男',value:'1'},{label:'女',value:'2'}],
|
|
genderName:'',
|
|
day:'',
|
|
value3: [],
|
|
residentCategory: [
|
|
{ title: '党员', value: 'partyFlag'},
|
|
{ title: '低保人员', value: 'subsistenceAllowanceFlag' },
|
|
{ title: '保障房人员', value: 'ensureHouseFlag'},
|
|
{ title: '失业人员', value: 'unemployedFlag'},
|
|
{ title: '育龄妇女', value: 'fertileWomanFlag'},
|
|
{ title: '退役军人', value: 'veteranFlag'},
|
|
{ title: '统战人员', value: 'unitedFrontFlag'},
|
|
{ title: '信访人员', value: 'petitionOfficerFlag' },
|
|
{ title: '志愿者', value: 'volunteerFlag' },
|
|
{ title: '特扶人员', value: 'bereavedPersonFlag' },
|
|
{ title: '租户', value: 'tenantFlag'},
|
|
{ title: '流动人口', value: 'floatingFlag' },
|
|
{ title: '特殊人群', value: 'specialCrowdFlag' },
|
|
{ title: '老年人', value: 'oldPeopleFlag'},
|
|
{ title: '空巢老人', value: 'emptyNesterFlag'},
|
|
{ title: '独居老人', value: 'liveAloneFlag' },
|
|
{ title: '失能老人', value: 'disabledFlag'},
|
|
{ title: '失智老人', value: 'dementedFlag'},
|
|
{ title: '残疾', value: 'disabilityFlag' },
|
|
{ title: '大病', value: 'seriousIllnessFlag'},
|
|
{ title: '慢病', value: 'chronicDiseaseFlag'},
|
|
{ title: '公益岗人员', value: 'publicWelfareFlag' }
|
|
],
|
|
residentCategorySty:'',
|
|
categoryInfo:''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: async function (options) {
|
|
var nowDate = new Date();
|
|
var year = nowDate.getFullYear();
|
|
var month = nowDate.getMonth() + 1;
|
|
var day = nowDate.getDate();
|
|
this.setData({
|
|
statusHeight: app.globalData.deviceInfo.statusHeight,
|
|
navigationHeight: app.globalData.deviceInfo.navigationHeight,
|
|
agencyId:app.globalData.user.agencyId,
|
|
'form.agencyId':app.globalData.user.agencyId,
|
|
'form.agencyName':app.globalData.user.agencyName,
|
|
day:`${year}-${month}-${day}`,
|
|
formType:options.type,
|
|
resiId:options.resiId
|
|
})
|
|
await this.getNationDictList()
|
|
await this.getGridoptionDict()
|
|
await this.getEducationDictList()
|
|
await this.getmarriageDict()
|
|
if(options.resiId){
|
|
wx.setNavigationBarTitle({
|
|
title: '修改人口信息',
|
|
})
|
|
await this.getResiDetail()
|
|
await this.getResidentResideInfo()
|
|
await this.getResidentReligion()
|
|
await this.getResidentEduInfo()
|
|
setTimeout(()=>{
|
|
this.getFamilyInfoDetailById()
|
|
},500)
|
|
}else{
|
|
this.setData({
|
|
isFirstLoadGrid:false,
|
|
isFirstLoadVillage: false,
|
|
isFirstLoadBuilding:false,
|
|
isFirstLoadUnit:false,
|
|
isFirstLoadHouse:false,
|
|
})
|
|
}
|
|
},
|
|
getResiDetail: async function() {
|
|
try {
|
|
let res = await api.getResiDetail(this.data.resiId);
|
|
const {birthday,gender,idNum,mobile,name,nation,houseInfo,categoryInfo,genderName} = res.data;
|
|
let result = this.data.residentCategory.filter(item => categoryInfo[item.value] === 1)
|
|
let residentCategorySty = result.map(item => item.title);
|
|
let categoryInfoArr = result.map(item => item.value);
|
|
await this.setDataAsync({
|
|
'form.name':name,
|
|
'form.birthday':birthday,
|
|
'form.gender':gender,
|
|
'form.idNum':idNum,
|
|
'form.mobile':mobile,
|
|
'form.nation':nation,
|
|
'form.gridId' :houseInfo.gridId,
|
|
'form.gridName' :houseInfo.gridName,
|
|
'form.villageId' :houseInfo.villageId,
|
|
'form.buildId' :houseInfo.buildId,
|
|
'form.unitId' :houseInfo.unitId,
|
|
'form.homeId' :houseInfo.homeId,
|
|
'form.houseMergeId':houseInfo.mergeId,
|
|
genderName,
|
|
categoryInfo:categoryInfoArr,
|
|
residentCategorySty,
|
|
});
|
|
setTimeout(()=>{
|
|
this.bindPickerChangeGrid();
|
|
},500)
|
|
setTimeout(()=>{
|
|
this.bindPickerChangevillageId();
|
|
},1000)
|
|
setTimeout(()=>{
|
|
this.bindPickerChangebuilding()
|
|
},2000)
|
|
setTimeout(()=>{
|
|
this.bindPickerChangeUnit()
|
|
},3000)
|
|
setTimeout(()=>{
|
|
this.bindPickerChangeHouse()
|
|
},4000)
|
|
} catch(err) {
|
|
console.log(err);
|
|
}
|
|
},
|
|
setDataAsync: function(data) {
|
|
return new Promise((resolve) => {
|
|
this.setData(data, resolve);
|
|
});
|
|
},
|
|
// 居住信息详情
|
|
getResidentResideInfo(){
|
|
api.getResidentResideInfo(this.data.resiId).then(res=>{
|
|
this.setData({
|
|
'form.resideInfoDto':res.data,
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
// 宗教信仰详情
|
|
getResidentReligion(){
|
|
api.getResidentReligion(this.data.resiId).then(res=>{
|
|
this.setData({
|
|
'form.religionDto':res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
// 获取教育信息详情
|
|
getResidentEduInfo(){
|
|
api.getResidentEduInfo(this.data.resiId).then(res=>{
|
|
this.setData({
|
|
'form.eduInfoDto':res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
getFamilyInfoDetailById(){
|
|
api.getFamilyInfoDetailById(this.data.resiId).then(res=>{
|
|
this.setData({
|
|
'form.familyInfoDto':res.data,
|
|
marriageName:this.data.marriageList.filter(item=>item.value ==res.data.marriage)[0].label
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
|
|
getNationDictList(){
|
|
api.getNationDictList().then(res=>{
|
|
this.setData({
|
|
nation:res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
getEducationDictList(){
|
|
api.getEducationDictList().then(res=>{
|
|
this.setData({
|
|
education:res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
getGridoptionDict(){
|
|
let parm ={
|
|
agencyId:this.data.agencyId,
|
|
purpose:'addorupdate'
|
|
}
|
|
api.getGridoptionDict(parm).then(res=>{
|
|
this.setData({
|
|
gridList:res.data,
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
getmarriageDict(){
|
|
api.getDictList('marriage').then(res=>{
|
|
this.setData({
|
|
marriageList:res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
// 获取小区列表
|
|
getQuartersOptions(gridId){
|
|
let parm = {
|
|
gridId,
|
|
agencyId:this.data.agecyId
|
|
}
|
|
api.getQuartersOptions(parm).then(res=>{
|
|
this.setData({
|
|
villageList:res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
// 获取楼栋列表
|
|
getBuildingoption(villageId){
|
|
api.getBuildingoption(villageId).then(res=>{
|
|
this.setData({
|
|
buildingList:res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
// 获取单元列表
|
|
getUnitoption(buildingId){
|
|
api.getUnitoption(buildingId).then(res=>{
|
|
this.setData({
|
|
unitList:res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
// 获取房屋列表
|
|
getHouseoption(unitId){
|
|
api.getHouseoption(unitId).then(res=>{
|
|
this.setData({
|
|
houseList:res.data
|
|
})
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
},
|
|
// 获取网格列表
|
|
bindPickerChangeGrid(e){
|
|
if (this.data.isFirstLoadGrid) {
|
|
// 编辑回填逻辑
|
|
const id = this.data.form.gridId;
|
|
const gridName = this.data.gridList.filter(item => item.value == id)[0].label;
|
|
this.setData({
|
|
'form.gridName': gridName,
|
|
"form.gridId": id
|
|
});
|
|
this.getQuartersOptions(id);
|
|
this.setData({
|
|
isFirstLoadGrid: false
|
|
});
|
|
} else {
|
|
// 正常修改逻辑
|
|
const selectedIndex = e.detail.value;
|
|
const selectedVillage = this.data.gridList[selectedIndex];
|
|
this.setData({
|
|
'form.gridName': selectedVillage.label,
|
|
"form.gridId": selectedVillage.value,
|
|
villageName:'',
|
|
villageList:[],
|
|
buildingName:'',
|
|
buildingList:[],
|
|
unitName:'',
|
|
unitList:[],
|
|
houseName:'',
|
|
houseList:[],
|
|
});
|
|
|
|
this.getQuartersOptions(selectedVillage.value);
|
|
}
|
|
},
|
|
bindPickerChangevillageId(e) {
|
|
if (this.data.isFirstLoadVillage) {
|
|
// 编辑回填逻辑
|
|
const id = this.data.form.villageId;
|
|
const villageName = this.data.villageList.filter(item => item.value == id)[0].label;
|
|
this.setData({
|
|
villageName: villageName,
|
|
"form.villageId": id
|
|
});
|
|
this.getBuildingoption(id);
|
|
this.setData({
|
|
isFirstLoadVillage: false
|
|
});
|
|
} else {
|
|
// 正常修改逻辑
|
|
const selectedIndex = e.detail.value;
|
|
const selectedVillage = this.data.villageList[selectedIndex];
|
|
|
|
this.setData({
|
|
villageName: selectedVillage.label,
|
|
"form.villageId": selectedVillage.value
|
|
});
|
|
|
|
this.getBuildingoption(selectedVillage.value);
|
|
}
|
|
},
|
|
|
|
bindPickerChangebuilding(e){
|
|
if (this.data.isFirstLoadBuilding) {
|
|
const id = this.data.form.buildId;
|
|
const buildingName = this.data.buildingList.filter(item => item.value == id)[0].label;
|
|
this.setData({
|
|
buildingName: buildingName,
|
|
"form.buildId": id
|
|
});
|
|
this.getUnitoption(id);
|
|
this.setData({
|
|
isFirstLoadBuilding: false
|
|
});
|
|
} else {
|
|
const selectedIndex = e.detail.value;
|
|
const selectedVillage = this.data.buildingList[selectedIndex];
|
|
this.setData({
|
|
buildingName: selectedVillage.label,
|
|
"form.buildId": selectedVillage.value
|
|
});
|
|
this.getUnitoption(selectedVillage.value);
|
|
}
|
|
},
|
|
bindPickerChangeUnit(e){
|
|
if (this.data.isFirstLoadUnit) {
|
|
const id = this.data.form.unitId;
|
|
const unitName = this.data.unitList.filter(item => item.value == id)[0].label;
|
|
this.setData({
|
|
unitName: unitName,
|
|
"form.unitId": id
|
|
});
|
|
this.getHouseoption(id);
|
|
this.setData({
|
|
isFirstLoadunit: false
|
|
});
|
|
} else {
|
|
const selectedIndex = e.detail.value;
|
|
const selectedVillage = this.data.unitList[selectedIndex];
|
|
this.setData({
|
|
unitName: selectedVillage.label,
|
|
"form.unitId": selectedVillage.value
|
|
});
|
|
this.getHouseoption(selectedVillage.value);
|
|
}
|
|
// this.setData({
|
|
// unitName:this.data.unitList[e.detail.value].label,
|
|
// "form.unitId" :this.data.unitList[e.detail.value].value
|
|
// })
|
|
// this.getHouseoption(this.data.unitList[e.detail.value].value)
|
|
},
|
|
bindPickerChangeHouse(e){
|
|
if (this.data.isFirstLoadHouse) {
|
|
const id = this.data.form.homeId;
|
|
const houseName = this.data.houseList.filter(item => item.value == id)[0].label;
|
|
this.setData({
|
|
houseName: houseName,
|
|
"form.homeId": id
|
|
});
|
|
this.setData({
|
|
isFirstLoadHouse: false
|
|
});
|
|
} else {
|
|
const selectedIndex = e.detail.value;
|
|
const selectedVillage = this.data.houseList[selectedIndex];
|
|
this.setData({
|
|
houseName: selectedVillage.label,
|
|
"form.homeId": selectedVillage.value
|
|
});
|
|
}
|
|
},
|
|
bindNameInput(e){
|
|
this.setData({
|
|
'form.name': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
bindPickerChangeGender(e){
|
|
this.setData({
|
|
genderName:this.data.genderList[e.detail.value].label,
|
|
"form.gender" :this.data.genderList[e.detail.value].value
|
|
})
|
|
},
|
|
bindDateChange(e){
|
|
this.setData({
|
|
'form.birthday': e.detail.value
|
|
})
|
|
},
|
|
bindidNumInput(e){
|
|
this.setData({
|
|
'form.idNum': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
bindMobileInput(e){
|
|
this.setData({
|
|
'form.mobile': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
bindPlaceOfDomicileInput(e){
|
|
this.setData({
|
|
'form.resideInfoDto.placeOfDomicile': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
bindCurrentResidenceInput(e){
|
|
this.setData({
|
|
'form.resideInfoDto.currentResidence': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
bindPickerChangeNation(e){
|
|
this.setData({
|
|
"form.nation" :this.data.nation[e.detail.value].value
|
|
})
|
|
},
|
|
bindNativePlaceInput(e){
|
|
this.setData({
|
|
'form.resideInfoDto.nativePlace': e.detail.value
|
|
})
|
|
},
|
|
bindPickerChangeEducation(e){
|
|
this.setData({
|
|
"form.eduInfoDto.cultureLevel" :this.data.education[e.detail.value].value
|
|
})
|
|
},
|
|
bindPickerChangemarriage(e){
|
|
this.setData({
|
|
"form.familyInfoDto.marriage" :this.data.marriageList[e.detail.value].value,
|
|
marriageName:this.data.marriageList[e.detail.value].label,
|
|
})
|
|
},
|
|
bindReligionInput(e){
|
|
this.setData({
|
|
"form.religionDto.religion" :e.detail.value
|
|
})
|
|
},
|
|
onClick3() {
|
|
const than = this
|
|
$wuxSelect('#wux-select3').open({
|
|
value:this.data.categoryInfo,
|
|
multiple: true,
|
|
toolbar: {
|
|
title: '居民类别',
|
|
confirmText: '确定',
|
|
},
|
|
options: than.data.residentCategory,
|
|
onChange: (value, index, options) => {
|
|
console.log('onChange', value, index, options)
|
|
const matchingLabels = value.map(valueToFind => {
|
|
const matchedItem = than.data.residentCategory.find(item => item.value === valueToFind);
|
|
return matchedItem ? matchedItem.title : null;
|
|
}).filter(Boolean);
|
|
this.setData({
|
|
value3: value,
|
|
residentCategorySty: matchingLabels.join(','),
|
|
})
|
|
},
|
|
onConfirm: (value, index, options) => {
|
|
console.log('onConfirm', value, index, options)
|
|
let updatedForm = {...this.data.form};
|
|
than.data.residentCategory.forEach(option => {
|
|
if (value.includes(option.value)) {
|
|
updatedForm[option.value] = 1;
|
|
}else if (updatedForm[option.value] === 1) {
|
|
updatedForm[option.value] = 0;
|
|
}
|
|
});
|
|
this.setData({
|
|
value3: value,
|
|
title3: index.map((n) => options[n].title),
|
|
form:updatedForm
|
|
})
|
|
console.log(this.data.form);
|
|
},
|
|
})
|
|
},
|
|
submit(){
|
|
const parm = {...this.data.form}
|
|
console.log(this.data.formType);
|
|
if(this.data.formType == 'edit'){
|
|
parm.resiId = this.data.resiId
|
|
console.log(parm);
|
|
api.resiEdit(parm).then(res=>{
|
|
console.log(res);
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
}else{
|
|
api.resiAdd(parm).then(res=>{
|
|
console.log(res);
|
|
}).catch(err=>{
|
|
console.log(err);
|
|
})
|
|
}
|
|
},
|
|
back() {
|
|
//返回上一级,关闭当前页面
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
},
|
|
})
|