From 892f507b4c7e3ffa74800dffa84f7d1fd61fcdfa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=88=98=E7=AB=8B=E6=A0=87?= <2658037827@qq.com>
Date: Thu, 21 Dec 2023 10:05:41 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=B1=85=E6=B0=91=E7=B1=BB?=
=?UTF-8?q?=E5=88=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/DynamicForms/DynamicForms.js | 151 ++
components/DynamicForms/DynamicForms.json | 12 +
components/DynamicForms/DynamicForms.wxml | 103 ++
components/DynamicForms/DynamicForms.wxss | 38 +
components/ResourceInfo/ResourceInfo.js | 11 +-
components/ResourceInfo/ResourceInfo.wxml | 4 +-
subpages/addResi/pages/addResi/addResi.js | 1641 +++++++++++++------
subpages/addResi/pages/addResi/addResi.json | 3 +-
subpages/addResi/pages/addResi/addResi.wxml | 259 +--
subpages/addResi/pages/addResi/addResi.wxss | 6 +-
utils/statisticsApi.js | 54 +
11 files changed, 1624 insertions(+), 658 deletions(-)
create mode 100644 components/DynamicForms/DynamicForms.js
create mode 100644 components/DynamicForms/DynamicForms.json
create mode 100644 components/DynamicForms/DynamicForms.wxml
create mode 100644 components/DynamicForms/DynamicForms.wxss
diff --git a/components/DynamicForms/DynamicForms.js b/components/DynamicForms/DynamicForms.js
new file mode 100644
index 0000000..946f2d0
--- /dev/null
+++ b/components/DynamicForms/DynamicForms.js
@@ -0,0 +1,151 @@
+Component({
+ properties: {
+ show: {
+ type: Boolean,
+ value: false
+ },
+ title: {
+ type: String,
+ value: ' '
+ },
+ formController: {
+ type: Object,
+ value: () => {
+ },
+ observer(val) {
+ this.setData({
+ formControllers: val
+ })
+ }
+ },
+ },
+ data: {
+ showDate: false,
+ dateKey: "",
+ defaultDate: "",
+ dateIndex: "",
+ formControllers: {},
+ showCheckbox: false,
+ checkboxTitle: '',
+ checkboxResult: [],
+ checkboxOptions: [],
+ checkboxIndex: ''
+ },
+ methods: {
+ onClose() {
+ this.triggerEvent('close')
+ },
+ onCloseCheckbox() {
+ this.setData({
+ showCheckbox: false
+ })
+ },
+ sureCheckbox() {
+ let formControllers = this.data.formControllers;
+ let checkboxResult = this.data.checkboxResult
+ let label = []
+ formControllers[this.data.checkboxIndex].value = checkboxResult.join(',');
+ checkboxResult.forEach(item => {
+ formControllers[this.data.checkboxIndex].options.forEach(option => {
+ if (option.value == item) {
+ label.push(option.label)
+ }
+ })
+ })
+ formControllers[this.data.checkboxIndex].selected = label.join(',');
+ this.setData({
+ formControllers,
+ showCheckbox: false
+ })
+ },
+ toggle(event) {
+ console.log(event)
+ const {index} = event.currentTarget.dataset;
+ const checkbox = this.selectComponent(`.checkboxes-${index}`);
+ console.log(checkbox)
+ checkbox.toggle();
+ },
+ onChangeCheckbox(event) {
+ this.setData({
+ checkboxResult: event.detail,
+ });
+ },
+ onShowCheckbox(e) {
+ let {options, value, label, index} = e.currentTarget.dataset
+ this.setData({
+ showCheckbox: true,
+ checkboxTitle: '选择' + label,
+ checkboxResult: value.split(','),
+ checkboxOptions: options,
+ checkboxIndex: index
+ })
+ },
+ onShowDate(e) {
+ let {key, value, index} = e.currentTarget.dataset
+ console.log(e.currentTarget.dataset)
+ this.setData({
+ showDate: true,
+ dateKey: key,
+ defaultDate: value,
+ dateIndex: index
+ })
+ },
+ onCloseDate(e) {
+ this.setData({
+ showDate: false
+ })
+ },
+ formatDate(date) {
+ date = new Date(date);
+ return `${date.getFullYear()}-${date.getMonth() + 1 > 10 ? date.getMonth() + 1 : '0' + (date.getMonth() + 1)}-${date.getDate() > 10 ? date.getDate() : '0' + date.getDate()}`;
+ },
+ onConfirmDate(e) {
+ let formControllers = this.data.formControllers;
+ formControllers[this.data.dateIndex].value = this.formatDate(e.detail)
+ this.setData({
+ showDate: false,
+ formControllers
+ });
+ console.log(this.data.formControllers)
+
+ },
+ setVal(e) {
+ let formControllers = this.data.formControllers;
+ console.log(e)
+ formControllers[e.currentTarget.dataset.index].value = e.detail
+ this.setData({
+ showDate: false,
+ formControllers
+ });
+ console.log(this.data.formControllers)
+ },
+ pickerChange(e) {
+ let {valuekey, options, currentindex, key} = e.currentTarget.dataset
+ let index = e.detail.value
+ console.log(key, 'key')
+ let formControllers = this.data.formControllers;
+ let selected = options[index]
+ formControllers[currentindex].value = selected[valuekey]
+ formControllers[currentindex].valueIndex = e.detail.value
+ if (selected.masterControl) {
+ formControllers.forEach(item => {
+ if (item.showFlag) {
+ if (item.showFlag === selected[valuekey]) {
+ item.hide = false
+ } else {
+ item.hide = true
+ }
+ }
+ })
+ }
+ this.setData({
+ formControllers
+ })
+ },
+ sure() {
+ console.log('ok', this.data.formControllers)
+ this.triggerEvent('ok', this.data.formControllers)
+ this.onClose();
+ }
+ },
+});
diff --git a/components/DynamicForms/DynamicForms.json b/components/DynamicForms/DynamicForms.json
new file mode 100644
index 0000000..717310c
--- /dev/null
+++ b/components/DynamicForms/DynamicForms.json
@@ -0,0 +1,12 @@
+{
+ "component": true,
+ "usingComponents": {
+ "van-action-sheet": "@vant/weapp/action-sheet/index",
+ "van-field": "@vant/weapp/field/index",
+ "van-cell": "@vant/weapp/cell/index",
+ "van-cell-group": "@vant/weapp/cell-group/index",
+ "van-calendar": "@vant/weapp/calendar/index",
+ "van-checkbox-group": "@vant/weapp/checkbox-group/index",
+ "van-checkbox": "@vant/weapp/checkbox/index"
+ }
+}
\ No newline at end of file
diff --git a/components/DynamicForms/DynamicForms.wxml b/components/DynamicForms/DynamicForms.wxml
new file mode 100644
index 0000000..63a7092
--- /dev/null
+++ b/components/DynamicForms/DynamicForms.wxml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 确定
+
+
+
+
+
+
+
+
+
+
+ {{item.label}}
+
+
+
+
+
+ 取消
+ 确定
+
+
diff --git a/components/DynamicForms/DynamicForms.wxss b/components/DynamicForms/DynamicForms.wxss
new file mode 100644
index 0000000..97486c0
--- /dev/null
+++ b/components/DynamicForms/DynamicForms.wxss
@@ -0,0 +1,38 @@
+
+.btn {
+ width: 240rpx;
+ height: 76rpx;
+ border-radius: 38rpx;
+ color: #fff;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ font-size: 32rpx;
+ font-weight: bold;
+}
+.btn-blue {
+ background: linear-gradient(87deg, #81B5FB 0%, #3E92FF 100%);
+}
+.btn-gray {
+ background: #D9D9D9;
+}
+
+.bottom-btn {
+ background: none;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 20rpx 99rpx 20rpx;
+ /*padding-bottom: calc(env(safe-area-inset-bottom) + 10rpx);*/
+ width: 100%;
+ box-sizing: border-box;
+ z-index: 999;
+ position: static;
+}
+.checkbox-item {
+ display: flex;
+ align-items: center;
+ padding: 30rpx 40rpx;
+ border-bottom: 1px solid #f2f2f2;
+}
\ No newline at end of file
diff --git a/components/ResourceInfo/ResourceInfo.js b/components/ResourceInfo/ResourceInfo.js
index 01da3a9..38dea4d 100644
--- a/components/ResourceInfo/ResourceInfo.js
+++ b/components/ResourceInfo/ResourceInfo.js
@@ -1,5 +1,5 @@
import {
- communitySelfOrgDetail,
+ communitySelfOrgDetail, getServiceTypeRelationByHobbyCode,
icpartyunitDetail,
residentEduInfo,
residentHobbyInfo,
@@ -74,12 +74,13 @@ Component({
if (monthDiff < 0 || (monthDiff === 0 && dayDiff < 0)) {
yearDiff--;
}
+ console.log(yearDiff, 'yearDiff')
return yearDiff;
},
// 志愿者 公益岗
getVolunteer() {
volunteerDetail(this.data.id).then(({data}) => {
- data.birthday = data.birthday ? this.getAgeByDateOfBirth(new Date(data.birthday)) : '未知'
+ data.age = data.birthday ? this.getAgeByDateOfBirth(new Date(data.birthday)) : '未知'
this.setData({
detail: data || {}
})
@@ -91,9 +92,9 @@ Component({
})
residentHobbyInfo(this.data.id).then(({data}) => {
- this.setData({
- hobby: data || {}
- })
+ this.setData({
+ hobby: data || {}
+ })
})
},
diff --git a/components/ResourceInfo/ResourceInfo.wxml b/components/ResourceInfo/ResourceInfo.wxml
index e9c77b0..c23ebd2 100644
--- a/components/ResourceInfo/ResourceInfo.wxml
+++ b/components/ResourceInfo/ResourceInfo.wxml
@@ -117,11 +117,11 @@
所在位置:
- {{ detail.houseInfo ? detail.houseInfo.homeName : '' }}
+ {{ detail&&detail.houseInfo&&detail.houseInfo.homeName ? detail.houseInfo.homeName : '' }}
兴趣爱好:
- {{ hobby ? hobby.hobbyRemark : '' }}
+ {{ hobby&&hobby.hobbyRemark ? hobby.hobbyRemark : '' }}
diff --git a/subpages/addResi/pages/addResi/addResi.js b/subpages/addResi/pages/addResi/addResi.js
index fd2b93d..e033749 100644
--- a/subpages/addResi/pages/addResi/addResi.js
+++ b/subpages/addResi/pages/addResi/addResi.js
@@ -1,14 +1,359 @@
// subpages/addResi/pages/addResi/addResi.js
import api from "../../../../utils/api"
-import { $wuxSelect } from '../../../../components/dist/index'
+import {$wuxSelect} from '../../../../components/dist/index'
+import {
+ dictlist,
+ getHouseType, getOldPeopleDetailById,
+ getVeteranDetailById, getVolunteerDetailById, publicWelfarePost,
+ residentEnsureHouse, residentSpecial, residentTenant,
+ residentUnemployed, residentUnitedFront, specialSupport
+} from "../../../../utils/statisticsApi";
+
const app = getApp()
Page({
data: {
- nation:[],
- education:[],
- marriageList:[],
- marriageName:'',
- form:{
+ formController: [],
+ ensureHouseFlagOpen: false,
+ unemployedFlagOpen: false,
+ veteranFlagOpen: false,
+ unitedFrontFlagOpen: false,
+ volunteerFlagOpen: false,
+ specialSupportFlagOpen: false,
+ tenantFlagOpen: false,
+ specialCrowdFlagOpen: false,
+ oldPeopleFlagOpen: false,
+ publicWelfareFlagOpen: false,
+ residentTypeForm: {
+ ensureHouseFlag: [
+ {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '住房性质',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [], // 字典获取
+ key: 'housingNature'
+ }, {
+ type: 'input',
+ value: '',
+ label: '保障类型',
+ key: 'securityType'
+ }, {
+ type: 'date',
+ value: "",
+ label: '发证日期',
+ key: 'certificateDate'
+ }, {
+ type: 'input',
+ value: '',
+ label: '补贴编号',
+ key: 'subsidyNum'
+ }, {
+ type: 'input',
+ value: '',
+ label: '补贴金额',
+ afterText: "元",
+ key: 'subsidyAmount'
+ }, {
+ type: 'input',
+ value: '',
+ label: '房东姓名',
+ key: 'landlordName'
+ }, {
+ type: 'input',
+ value: '',
+ label: '房东证件号',
+ key: 'landlordIdNum'
+ }, {
+ type: 'date',
+ value: "",
+ label: '通知书领取日期',
+ key: 'notificationRcvDate'
+ },
+ ],
+ unemployedFlag: [
+ {
+ type: 'input',
+ value: '',
+ label: '原工作单位',
+ key: 'originWorkUnit'
+ }, {
+ type: 'date',
+ value: '',
+ label: '失业时间',
+ key: 'unemploymentTime'
+ }, {
+ type: 'input',
+ value: '',
+ label: '失业证号',
+ key: 'unemploymentNum'
+ }, {
+ type: 'input',
+ value: '',
+ label: '再就业优惠证号',
+ key: 'employmentNum'
+ }, {
+ type: 'input',
+ value: '',
+ label: '技术特长',
+ key: 'specialSkill'
+ }, {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '失业原因',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [], // 字典获取
+ key: 'unemploymentReason'
+ }, {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '是否就业困难对象',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [{
+ value: 1,
+ label: '是'
+ }, {
+ value: 0,
+ label: '否'
+ }],
+ key: 'employmentHardFlag'
+ }, {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '劳动能力就业愿望',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [], // 字典获取
+ key: 'employmentWish'
+ },
+ ],
+ veteranFlag: [
+ {
+ type: 'date',
+ value: '',
+ label: '入伍时间',
+ key: 'joinArmyTime'
+ }, {
+ type: 'date',
+ value: '',
+ label: '退伍时间',
+ key: 'leaveArmyTime'
+ }, {
+ type: 'input',
+ value: '',
+ label: '服役单位',
+ key: 'serviceUnit'
+ }, {
+ type: 'input',
+ value: '',
+ label: '接收单位',
+ key: 'receiveUnit'
+ }, {
+ type: 'input',
+ value: '',
+ label: '待安置补助金',
+ afterText: '元',
+ key: 'settlementAmount'
+ }, {
+ type: 'input',
+ value: '',
+ label: '培训状况',
+ key: 'trainDesc'
+ }, {
+ type: 'input',
+ value: '',
+ label: '现就业情况',
+ key: 'employmentSituation'
+ }, {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '是否办理公益性岗位',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [{
+ value: 1,
+ label: '是'
+ }, {
+ value: 0,
+ label: '否'
+ }],
+ key: 'pubWelfareJobFlag'
+ },
+ ],
+ unitedFrontFlag: [
+ {
+ type: 'input',
+ value: '',
+ label: '职务',
+ key: 'duty'
+ }, {
+ type: 'input',
+ value: '',
+ label: '探亲情况',
+ key: 'visitation'
+ }
+ ],
+ volunteerFlag: [
+ {
+ type: 'checkbox',
+ value: '',
+ label: '志愿者类别',
+ key: 'volunteerCategory'
+ }, {
+ type: 'textarea',
+ value: '',
+ maxlength: 120,
+ label: '备注',
+ key: 'volunteerRemark'
+ },
+ ],
+ specialSupportFlag: [
+ {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '特扶类别',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [
+ {
+ value: '1',
+ label: '失独'
+ },
+ {
+ value: '2',
+ label: '伤残'
+ }
+ ], // 字典
+ key: 'specialSupportType',
+ masterControl: true
+ }, {
+ type: 'input',
+ value: "",
+ label: '子女姓名',
+ key: 'childName',
+ showFlag: '2',
+ hide: true
+ }, {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '子女性别',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [
+ {
+ value: '1',
+ label: '男'
+ },
+ {
+ value: '2',
+ label: '女'
+ }
+ ], // 字典
+ key: 'childGender'
+ }, {
+ type: 'date',
+ value: "",
+ label: '子女死亡日期',
+ key: 'childDeathDate',
+ showFlag: '1',
+ hide: true
+ }, {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '伤残类别',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [], // 字典
+ key: 'childDisabilityCategoryCode',
+ showFlag: '2',
+ hide: true
+ }, {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '伤残等级',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [], // 字典
+ key: 'childDisabilityLevel',
+ showFlag: '2',
+ hide: true
+ }, {
+ type: 'textarea',
+ value: '',
+ maxlength: 120,
+ label: '备注',
+ key: 'remark'
+ },
+ ],
+ tenantFlag: [
+ {
+ type: 'date',
+ value: "",
+ label: '合同开始时间',
+ key: 'contractStartDate'
+ }, {
+ type: 'date',
+ value: "",
+ label: '合同结束时间',
+ key: 'contractEndDate'
+ },],
+ specialCrowdFlag: [
+ {
+ type: 'select',
+ value: "",
+ valueIndex: -1,
+ label: '人群类别',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [], // 字典
+ key: 'specialCategoryCode'
+ }],
+ oldPeopleFlag: [
+ {
+ type: 'input',
+ value: '',
+ label: '高龄补助',
+ afterText: '元',
+ key: 'oldSubsidy'
+ }],
+ publicWelfareFlag: [
+ {
+ type: 'date',
+ value: "",
+ label: '入职时间',
+ key: 'hireData'
+ }, {
+ type: 'checkbox',
+ value: "",
+ valueIndex: -1,
+ label: '岗位类型',
+ optionsKey: 'label',
+ valueKey: 'value',
+ options: [], // 字典
+ key: 'postTypes'
+ }, {
+ type: '',
+ value: "",
+ key: 'userId'
+ }],
+ },
+ residentTypeFormCell: [],
+ nation: [],
+ education: [],
+ marriageList: [],
+ marriageName: '',
+ form: {
agencyName: "",
agencyId: "",
resiId: "",
@@ -37,7 +382,7 @@ Page({
unitedFrontFlag: 0,
petitionOfficerFlag: "",
volunteerFlag: 0,
- bereavedPersonFlag: 0,
+ specialSupportFlag: 0,
tenantFlag: 0,
floatingFlag: 0,
specialCrowdFlag: 0,
@@ -65,295 +410,304 @@ Page({
religion: ""
}
},
- isFirstLoadGrid:true,
+ 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:'',
+ 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' }
+ {title: '党员', value: 'partyFlag'},
+ {title: '低保人员', value: 'subsistenceAllowanceFlag'},
+ {title: '保障房人员', value: 'ensureHouseFlag', isForm: true},
+ {title: '失业人员', value: 'unemployedFlag', isForm: true},
+ {title: '育龄妇女', value: 'fertileWomanFlag'},
+ {title: '退役军人', value: 'veteranFlag', isForm: true},
+ {title: '统战人员', value: 'unitedFrontFlag', isForm: true},
+ {title: '信访人员', value: 'petitionOfficerFlag'},
+ {title: '志愿者', value: 'volunteerFlag', isForm: true},
+ {title: '特扶人员', value: 'specialSupportFlag', isForm: true},
+ {title: '租户', value: 'tenantFlag', isForm: true},
+ {title: '流动人口', value: 'floatingFlag'},
+ {title: '特殊人群', value: 'specialCrowdFlag', isForm: true},
+ {title: '老年人', value: 'oldPeopleFlag', isForm: true},
+ {title: '空巢老人', value: 'emptyNesterFlag'},
+ {title: '独居老人', value: 'liveAloneFlag'},
+ {title: '失能老人', value: 'disabledFlag'},
+ {title: '失智老人', value: 'dementedFlag'},
+ {title: '残疾', value: 'disabilityFlag'},
+ {title: '大病', value: 'seriousIllnessFlag'},
+ {title: '慢病', value: 'chronicDiseaseFlag'},
+ {title: '公益岗人员', value: 'publicWelfareFlag', isForm: true}
],
- residentCategorySty:'',
- categoryInfo:''
+ residentCategorySty: '',
+ categoryInfo: '',
+ isShowDynamicForms: false,
+ dynamicTitle: " ",
},
/**
* 生命周期函数--监听页面加载
*/
- 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
+ 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.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{
- if(options.idCard){
- this.setData({
- 'form.name':options.name,
- 'form.idNum':options.idCard,
- 'form.gender':options.gender == '男'?'1':"2",
- genderName:options.gender,
- 'form.birthday':options.birth,
- })
- }
+ await this.getResiDetail()
+ await this.getResidentResideInfo()
+ await this.getResidentReligion()
+ await this.getResidentEduInfo()
+ setTimeout(() => {
+ this.getFamilyInfoDetailById()
+ }, 500)
+ } else {
+ if (options.idCard) {
this.setData({
- isFirstLoadGrid:false,
- isFirstLoadVillage: false,
- isFirstLoadBuilding:false,
- isFirstLoadUnit:false,
- isFirstLoadHouse:false,
+ 'form.name': options.name,
+ 'form.idNum': options.idCard,
+ 'form.gender': options.gender == '男' ? '1' : "2",
+ genderName: options.gender,
+ 'form.birthday': options.birth,
})
}
- },
- getResiDetail: async function() {
- try {
- let res = await api.getResiDetail(this.data.resiId);
- const {
- birthday,
- gender,
- idNum,
- mobile,
- name,
- nation,
- houseInfo = {}, // 为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);
-
- wx.showLoading({
- title: '加载中...',
- });
-
- 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,
- });
- await this.delay(1000)
- await this.bindPickerChangeGrid();
- await this.delay(400)
- await this.bindPickerChangevillageId();
- await this.delay(400)
- await this.bindPickerChangebuilding();
- await this.delay(400)
- await this.bindPickerChangeUnit();
- await this.delay(400)
- await this.bindPickerChangeHouse();
- wx.hideLoading();
- } catch (err) {
- console.log(err);
+ 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 = {}, // 为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);
+ this.setDynamicForm(result)
+
+ wx.showLoading({
+ title: '加载中...',
+ });
+ let form = this.data.form
+ for (let i in categoryInfoArr) {
+ form[categoryInfoArr[i]] = 1
}
- },
- setDataAsync: function(data) {
- return new Promise((resolve) => {
- this.setData(data, resolve);
+ this.setData({
+ form
+ })
+ 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,
});
- },
- delay(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- },
- // 居住信息详情
- getResidentResideInfo(){
- api.getResidentResideInfo(this.data.resiId).then(res=>{
- this.setData({
- 'form.resideInfoDto':res.data,
- })
- }).catch(err=>{
- console.log(err);
+ await this.delay(1000)
+ await this.bindPickerChangeGrid();
+ await this.delay(400)
+ await this.bindPickerChangevillageId();
+ await this.delay(400)
+ await this.bindPickerChangebuilding();
+ await this.delay(400)
+ await this.bindPickerChangeUnit();
+ await this.delay(400)
+ await this.bindPickerChangeHouse();
+ wx.hideLoading();
+ } catch (err) {
+ console.log(err);
+ }
+ },
+ setDataAsync: function (data) {
+ return new Promise((resolve) => {
+ this.setData(data, resolve);
+ });
+ },
+ delay(ms) {
+ return new Promise(resolve => setTimeout(resolve, ms));
+ },
+ // 居住信息详情
+ getResidentResideInfo() {
+ api.getResidentResideInfo(this.data.resiId).then(res => {
+ this.setData({
+ 'form.resideInfoDto': res.data,
})
- },
- // 宗教信仰详情
- getResidentReligion(){
- api.getResidentReligion(this.data.resiId).then(res=>{
- this.setData({
- 'form.religionDto':res.data
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ // 宗教信仰详情
+ getResidentReligion() {
+ api.getResidentReligion(this.data.resiId).then(res => {
+ this.setData({
+ 'form.religionDto': res.data
})
- },
- // 获取教育信息详情
- getResidentEduInfo(){
- api.getResidentEduInfo(this.data.resiId).then(res=>{
- this.setData({
- 'form.eduInfoDto':res.data
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ // 获取教育信息详情
+ getResidentEduInfo() {
+ api.getResidentEduInfo(this.data.resiId).then(res => {
+ this.setData({
+ 'form.eduInfoDto': res.data
})
- },
- // 获取婚姻信息
- 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);
+ }).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);
+ getNationDictList() {
+ api.getNationDictList().then(res => {
+ this.setData({
+ nation: res.data
})
- },
- getEducationDictList(){
- api.getEducationDictList().then(res=>{
- this.setData({
- education:res.data
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ getEducationDictList() {
+ api.getEducationDictList().then(res => {
+ this.setData({
+ education: res.data
})
- },
- getGridoptionDict(){
- let parm ={
- agencyId:this.data.agencyId,
- purpose:'addorupdate'
- }
- api.getGridoptionDict(parm).then(res=>{
- this.setData({
- gridList:res.data,
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ getGridoptionDict() {
+ let parm = {
+ agencyId: this.data.agencyId,
+ purpose: 'addorupdate'
+ }
+ api.getGridoptionDict(parm).then(res => {
+ this.setData({
+ gridList: res.data,
})
- },
- getmarriageDict(){
- api.getDictList('marriage').then(res=>{
- this.setData({
- marriageList:res.data
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ getmarriageDict() {
+ api.getDictList('marriage').then(res => {
+ this.setData({
+ marriageList: res.data
})
- },
- // 获取小区列表
- getQuartersOptions(gridId){
- let parm = {
- gridId,
- agencyId:this.data.agecyId
- }
- api.getQuartersOptions(parm).then(res=>{
- this.setData({
- villageList:res.data
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ // 获取小区列表
+ getQuartersOptions(gridId) {
+ let parm = {
+ gridId,
+ agencyId: this.data.agecyId
+ }
+ api.getQuartersOptions(parm).then(res => {
+ this.setData({
+ villageList: res.data
})
- },
- // 获取楼栋列表
- getBuildingoption(villageId){
- api.getBuildingoption(villageId).then(res=>{
- this.setData({
- buildingList:res.data
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ // 获取楼栋列表
+ getBuildingoption(villageId) {
+ api.getBuildingoption(villageId).then(res => {
+ this.setData({
+ buildingList: res.data
})
- },
- // 获取单元列表
- getUnitoption(buildingId){
- api.getUnitoption(buildingId).then(res=>{
- this.setData({
- unitList:res.data
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ // 获取单元列表
+ getUnitoption(buildingId) {
+ api.getUnitoption(buildingId).then(res => {
+ this.setData({
+ unitList: res.data
})
- },
- // 获取房屋列表
- getHouseoption(unitId){
- api.getHouseoption(unitId).then(res=>{
- this.setData({
- houseList:res.data
- })
- }).catch(err=>{
- console.log(err);
+ }).catch(err => {
+ console.log(err);
+ })
+ },
+ // 获取房屋列表
+ getHouseoption(unitId) {
+ api.getHouseoption(unitId).then(res => {
+ this.setData({
+ houseList: res.data
})
- },
+ }).catch(err => {
+ console.log(err);
+ })
+ },
/**
* 生命周期函数--监听页面初次渲染完成
*/
@@ -404,16 +758,16 @@ Page({
// 获取网格列表
async bindPickerChangeGrid() {
return new Promise(async (resolve, reject) => {
- if (this.data.isFirstLoadGrid) {
+ if (this.data.isFirstLoadGrid) {
// 编辑回填逻辑
const id = this.data.form.gridId;
const temp = this.data.gridList.filter(item => item.value == id);
let gridName = ''
- if(temp.length != 0){
+ if (temp.length != 0) {
gridName = temp[0].label
- }else{
- this.showToast('网格信息有误')
- return
+ } else {
+ this.showToast('网格信息有误')
+ return
}
this.setData({
'form.gridName': gridName,
@@ -430,20 +784,20 @@ Page({
this.setData({
'form.gridName': selectedVillage.label,
"form.gridId": selectedVillage.value,
- 'form.villageId':'',
- 'form.buildId':'',
- 'form.unitId':'',
- 'form.homeId':'',
- villageName:'',
- villageList:[],
- buildingName:'',
- buildingList:[],
- unitName:'',
- unitList:[],
- houseName:'',
- houseList:[],
+ 'form.villageId': '',
+ 'form.buildId': '',
+ 'form.unitId': '',
+ 'form.homeId': '',
+ villageName: '',
+ villageList: [],
+ buildingName: '',
+ buildingList: [],
+ unitName: '',
+ unitList: [],
+ houseName: '',
+ houseList: [],
});
-
+
this.getQuartersOptions(selectedVillage.value);
}
resolve();
@@ -452,360 +806,563 @@ Page({
bindPickerChangevillageId(e) {
return new Promise((resolve, reject) => {
if (this.data.isFirstLoadVillage) {
- // 编辑回填逻辑
- const id = this.data.form.villageId;
- const temp = this.data.villageList.filter(item => item.value == id);
- let villageName = ''
- if(temp.length != 0){
- villageName = temp[0].label
- }else{
- this.showToast('小区信息有误')
- return
- }
- this.setData({
- villageName: villageName,
- "form.villageId": id
- });
- this.getBuildingoption(id);
- this.setData({
- isFirstLoadVillage: false
- });
- console.log(this.data.villageList,'小区');
- } else {
- // 正常修改逻辑
- const selectedIndex = e.detail.value;
- const selectedVillage = this.data.villageList[selectedIndex];
-
- this.setData({
- villageName: selectedVillage.label,
- "form.villageId": selectedVillage.value,
- 'form.buildId':'',
- 'form.unitId':'',
- 'form.homeId':'',
- buildingName:'',
- buildingList:[],
- unitName:'',
- unitList:[],
- houseName:'',
- houseList:[],
- });
-
- this.getBuildingoption(selectedVillage.value);
- }
- resolve();
- });
- },
-
- bindPickerChangebuilding(e){
+ // 编辑回填逻辑
+ const id = this.data.form.villageId;
+ const temp = this.data.villageList.filter(item => item.value == id);
+ let villageName = ''
+ if (temp.length != 0) {
+ villageName = temp[0].label
+ } else {
+ this.showToast('小区信息有误')
+ return
+ }
+ this.setData({
+ villageName: villageName,
+ "form.villageId": id
+ });
+ this.getBuildingoption(id);
+ this.setData({
+ isFirstLoadVillage: false
+ });
+ console.log(this.data.villageList, '小区');
+ } else {
+ // 正常修改逻辑
+ const selectedIndex = e.detail.value;
+ const selectedVillage = this.data.villageList[selectedIndex];
+
+ this.setData({
+ villageName: selectedVillage.label,
+ "form.villageId": selectedVillage.value,
+ 'form.buildId': '',
+ 'form.unitId': '',
+ 'form.homeId': '',
+ buildingName: '',
+ buildingList: [],
+ unitName: '',
+ unitList: [],
+ houseName: '',
+ houseList: [],
+ });
+
+ this.getBuildingoption(selectedVillage.value);
+ }
+ resolve();
+ });
+ },
+
+ bindPickerChangebuilding(e) {
return new Promise((resolve, reject) => {
if (this.data.isFirstLoadBuilding) {
- const id = this.data.form.buildId;
- const temp = this.data.buildingList.filter(item => item.value == id);
- let buildingName = ''
- if(temp.length != 0){
- buildingName = temp[0].label
- }else{
- this.showToast('小区信息有误')
- return
- }
- 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,
- 'form.unitId':'',
- 'form.homeId':'',
- unitName:'',
- unitList:[],
- houseName:'',
- houseList:[],
- });
- this.getUnitoption(selectedVillage.value);
- }
- resolve();
- });
- },
- bindPickerChangeUnit(e){
+ const id = this.data.form.buildId;
+ const temp = this.data.buildingList.filter(item => item.value == id);
+ let buildingName = ''
+ if (temp.length != 0) {
+ buildingName = temp[0].label
+ } else {
+ this.showToast('小区信息有误')
+ return
+ }
+ 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,
+ 'form.unitId': '',
+ 'form.homeId': '',
+ unitName: '',
+ unitList: [],
+ houseName: '',
+ houseList: [],
+ });
+ this.getUnitoption(selectedVillage.value);
+ }
+ resolve();
+ });
+ },
+ bindPickerChangeUnit(e) {
return new Promise((resolve, reject) => {
if (this.data.isFirstLoadUnit) {
- const id = this.data.form.unitId;
- const temp = this.data.unitList.filter(item => item.value == id);
- let unitName = ''
- if(temp.length != 0){
- unitName = temp[0].label
- }else{
- this.showToast('楼栋信息有误')
- return
- }
- 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,
- 'form.homeId':'',
- houseName:'',
- houseList:[],
- });
- this.getHouseoption(selectedVillage.value);
- }
- resolve();
- });
- },
- bindPickerChangeHouse(e){
+ const id = this.data.form.unitId;
+ const temp = this.data.unitList.filter(item => item.value == id);
+ let unitName = ''
+ if (temp.length != 0) {
+ unitName = temp[0].label
+ } else {
+ this.showToast('楼栋信息有误')
+ return
+ }
+ 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,
+ 'form.homeId': '',
+ houseName: '',
+ houseList: [],
+ });
+ this.getHouseoption(selectedVillage.value);
+ }
+ resolve();
+ });
+ },
+ bindPickerChangeHouse(e) {
return new Promise((resolve, reject) => {
if (this.data.isFirstLoadHouse) {
- const id = this.data.form.homeId;
- const temp = this.data.houseList.filter(item => item.value == id);
- let houseName = ''
- if(temp.length != 0){
- houseName = temp[0].label
- }else{
- this.showToast('房屋信息有误')
- return
+ const id = this.data.form.homeId;
+ const temp = this.data.houseList.filter(item => item.value == id);
+ let houseName = ''
+ if (temp.length != 0) {
+ houseName = temp[0].label
+ } else {
+ this.showToast('房屋信息有误')
+ return
+ }
+ 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
+ });
}
- 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
- });
- }
resolve();
- });
+ });
},
- bindNameInput(e){
+ bindNameInput(e) {
this.setData({
'form.name': e.detail.value
})
console.log(this.data.form)
},
- bindPickerChangeGender(e){
+ bindPickerChangeGender(e) {
this.setData({
- genderName:this.data.genderList[e.detail.value].label,
- "form.gender" :this.data.genderList[e.detail.value].value
+ genderName: this.data.genderList[e.detail.value].label,
+ "form.gender": this.data.genderList[e.detail.value].value
})
},
- bindDateChange(e){
+ bindDateChange(e) {
this.setData({
'form.birthday': e.detail.value
- })
+ })
},
- bindidNumInput(e){
+ bindidNumInput(e) {
this.setData({
'form.idNum': e.detail.value
})
console.log(this.data.form)
},
- bindMobileInput(e){
+ bindMobileInput(e) {
this.setData({
'form.mobile': e.detail.value
})
console.log(this.data.form)
},
- bindPlaceOfDomicileInput(e){
+ bindPlaceOfDomicileInput(e) {
this.setData({
'form.resideInfoDto.placeOfDomicile': e.detail.value
})
console.log(this.data.form)
},
- bindCurrentResidenceInput(e){
+ bindCurrentResidenceInput(e) {
this.setData({
'form.resideInfoDto.currentResidence': e.detail.value
})
console.log(this.data.form)
},
- bindPickerChangeNation(e){
+ bindPickerChangeNation(e) {
this.setData({
- "form.nation" :this.data.nation[e.detail.value].value
+ "form.nation": this.data.nation[e.detail.value].value
})
},
- bindNativePlaceInput(e){
+ bindNativePlaceInput(e) {
this.setData({
'form.resideInfoDto.nativePlace': e.detail.value
})
},
- bindPickerChangeEducation(e){
+ bindPickerChangeEducation(e) {
this.setData({
- "form.eduInfoDto.cultureLevel" :this.data.education[e.detail.value].value
+ "form.eduInfoDto.cultureLevel": this.data.education[e.detail.value].value
})
},
- bindPickerChangemarriage(e){
+ bindPickerChangemarriage(e) {
this.setData({
- "form.familyInfoDto.marriage" :this.data.marriageList[e.detail.value].value,
- marriageName:this.data.marriageList[e.detail.value].label,
+ "form.familyInfoDto.marriage": this.data.marriageList[e.detail.value].value,
+ marriageName: this.data.marriageList[e.detail.value].label,
})
},
- bindReligionInput(e){
+ bindReligionInput(e) {
this.setData({
- "form.religionDto.religion" :e.detail.value
- })
+ "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);
- },
+ 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
+ })
+ let residentTypeFormCell = []
+ index.forEach(item => {
+ residentTypeFormCell.push(this.data.residentCategory[item])
+ })
+ this.setDynamicForm(residentTypeFormCell)
+ console.log(this.data.form);
+ },
})
},
- showToast(title){
+ showToast(title) {
wx.showToast({
title: title,
- duration:2000,
- icon:'none'
+ duration: 2000,
+ icon: 'none'
})
},
- submit: async function() {
- if(!this.data.form.gridId){
+ submit: async function () {
+ if (!this.data.form.gridId) {
this.showToast('请选择所在网格')
- return
+ return
}
- if(!this.data.form.villageId){
+ if (!this.data.form.villageId) {
this.showToast('请选择所在小区')
- return
+ return
}
- if(!this.data.form.buildId){
+ if (!this.data.form.buildId) {
this.showToast('请选择所在楼栋')
- return
+ return
}
- if(!this.data.form.unitId){
+ if (!this.data.form.unitId) {
this.showToast('请选择所在单元')
- return
+ return
}
- if(!this.data.form.homeId){
+ if (!this.data.form.homeId) {
this.showToast('请选择所在房屋')
- return
+ return
}
- if(!this.data.form.name){
+ if (!this.data.form.name) {
this.showToast('请填写姓名')
- return
+ return
}
- if(!this.data.form.gender){
+ if (!this.data.form.gender) {
this.showToast('请选择性别')
- return
+ return
}
- if(!this.data.form.birthday){
+ if (!this.data.form.birthday) {
this.showToast('请选择出生日期')
- return
+ return
}
- if(!this.data.form.idNum){
+ if (!this.data.form.idNum) {
this.showToast('请填写证件号')
- return
+ return
}
- if(!this.data.form.mobile){
+ if (!this.data.form.mobile) {
this.showToast('请填写联系电话')
- return
+ return
+ }
+ const parm = {
+ ...this.data.form,
+ ensureHouseDto: this.data.ensureHouseFlagOpen ? this.getValue(this.data.residentTypeForm.ensureHouseFlag) : undefined,
+ unemployedDto: this.data.unemployedFlagOpen ? this.getValue(this.data.residentTypeForm.unemployedFlag) : undefined,
+ veteranDto: this.data.veteranFlagOpen ? this.getValue(this.data.residentTypeForm.veteranFlag) : undefined,
+ unitedFrontDto: this.data.unitedFrontFlagOpen ? this.getValue(this.data.residentTypeForm.unitedFrontFlag) : undefined,
+ volunteerDto: this.data.volunteerFlagOpen ? this.getValue(this.data.residentTypeForm.volunteerFlag) : undefined,
+ specialSupportDto: this.data.specialSupportFlagOpen ? this.getValue(this.data.residentTypeForm.specialSupportFlag) : undefined,
+ tenantDto: this.data.tenantFlagOpen ? this.getValue(this.data.residentTypeForm.tenantFlag) : undefined,
+ specialDto: this.data.specialCrowdFlagOpen ? this.getValue(this.data.residentTypeForm.specialCrowdFlag) : undefined,
+ oldPeopleDto: this.data.oldPeopleFlagOpen ? this.getValue(this.data.residentTypeForm.oldPeopleFlag) : undefined,
+ postDto: this.data.publicWelfareFlagOpen ? this.getValue(this.data.residentTypeForm.publicWelfareFlag) : undefined,
}
- const parm = {...this.data.form}
console.log(this.data.formType);
- if(this.data.formType == 'edit'){
+ if (this.data.formType == 'edit') {
parm.resiId = this.data.resiId
try {
const res = await api.resiEdit(parm)
- if(res.code === 0){
+ if (res.code === 0) {
wx.showToast({
- title: '编辑成功',
- duration:3000,
- success:function(){
- setTimeout(()=>{
- wx.navigateBack({
- delta: 1
- })
- },3000)
- }
+ title: '编辑成功',
+ duration: 3000,
+ success: function () {
+ setTimeout(() => {
+ wx.navigateBack({
+ delta: 1
+ })
+ }, 3000)
+ }
})
}
- }catch(err) {
+ } catch (err) {
console.log(err);
}
- }else{
- try {
- const res = await api.resiAdd(parm)
- if(res.code === 0){
- wx.showToast({
- title: '新增成功',
- duration:3000,
- success:function(){
- setTimeout(()=>{
- wx.navigateBack({
- delta: 1
- })
- },3000)
- }
- })
+ } else {
+ try {
+ const res = await api.resiAdd(parm)
+ if (res.code === 0) {
+ wx.showToast({
+ title: '新增成功',
+ duration: 3000,
+ success: function () {
+ setTimeout(() => {
+ wx.navigateBack({
+ delta: 1
+ })
+ }, 3000)
+ }
+ })
+ }
+ } catch (err) {
+ console.log(err);
}
- }catch(err) {
- console.log(err);
}
- }
},
back() {
- //返回上一级,关闭当前页面
- wx.navigateBack({
- delta: 1
- })
+ //返回上一级,关闭当前页面
+ wx.navigateBack({
+ delta: 1
+ })
},
- handelJump(){
+ handelJump() {
wx.navigateTo({
- url: '/subpages/addhouse/pages/addhouse/addhouse',
+ url: '/subpages/addhouse/pages/addhouse/addhouse',
+ })
+ },
+ closeDynamicForms() {
+ this.setData({
+ isShowDynamicForms: false
+ })
+ },
+ okDynamicForms(e) {
+ console.log(e)
+ let residentTypeForm = this.data.residentTypeForm
+ residentTypeForm[this.data.currentFormController] = e.detail
+ this.setData({
+ residentTypeForm
})
- }
+ },
+ setDynamicForm(data) {
+ let residentTypeFormCell = data.filter(item => item.isForm)
+ let values = residentTypeFormCell.map(item => item.value)
+ // 保障房人员
+ if (values.includes('ensureHouseFlag')) {
+ this.getHouseTypes()
+ }
+ // 失业人员
+ if (values.includes('unemployedFlag')) {
+ // 失业原因
+ this.getDictData('unemployment_reason', 'unemploymentReason')
+ // 愿望
+ this.getDictData('career_goals', 'employmentWish')
+ }
+ // 志愿者
+ if (values.includes('volunteerFlag')) {
+ // 志愿者类别
+ this.getDictData('VOLUNTEER_CATEGORY', 'volunteerCategory')
+ }
+ // 特扶
+ if (values.includes('specialSupportFlag')) {
+ //获取伤残类别字典
+ this.getDictData('disability_category_code', 'childDisabilityCategoryCode')
+ // 获取伤残等级字典
+ this.getDictData('disability_level', 'childDisabilityLevel')
+ }
+
+ // 特殊人群
+ if (values.includes('specialCrowdFlag')) {
+ //人群类别
+ this.getDictData('special_resident_category', 'specialCategoryCode')
+ }
+ // 公益岗人员
+ if (values.includes('specialCrowdFlag')) {
+ //岗位类型
+ this.getDictData('public_welfare_post_type', 'postTypes')
+ }
+
+
+ this.setData({residentTypeFormCell})
+ // residentTypeForm
+ },
+ async openDynamicForms(e) {
+ var data = {}
+ let formtype = e.currentTarget.dataset.formtype
+ let id = this.data.resiId
+ if (formtype === 'ensureHouseFlag') {
+ let res = await residentEnsureHouse(id)
+ data = res.data
+ }
+ if (formtype === 'unemployedFlag') {
+ let res = await residentUnemployed(id)
+ data = res.data
+ }
+ if (formtype === 'veteranFlag') {
+ let res = await getVeteranDetailById(id)
+ data = res.data
+ }
+ if (formtype === 'unitedFrontFlag') {
+ let res = await residentUnitedFront(id)
+ data = res.data
+ }
+ if (formtype === 'volunteerFlag') {
+ let res = await getVolunteerDetailById(id)
+ data = res.data
+ }
+ if (formtype === 'specialSupportFlag') {
+ let res = await specialSupport(id)
+ data = res.data
+ }
+ if (formtype === 'tenantFlag') {
+ let res = await residentTenant(id)
+ data = res.data
+ }
+ if (formtype === 'specialCrowdFlag') {
+ let res = await residentSpecial(id)
+ data = res.data
+ }
+ if (formtype === 'oldPeopleFlag') {
+ let res = await getOldPeopleDetailById(id)
+ data = res.data
+ }
+ if (formtype === 'publicWelfareFlag') {
+ let res = await publicWelfarePost(id)
+ data = res.data
+ }
+ let residentTypeForm = this.data.residentTypeForm
+ residentTypeForm[formtype].forEach(item => {
+ if(item.key === 'userId') {
+ item.value = id
+ }
+ for (let i in data) {
+ if (item.key === i) {
+ item.value = data[item.key]
+ if (data[item.key]) {
+ console.log(data[item.key], 'data[item.key]')
+ if (item.type === 'date') {
+ item.value = data[item.key].split(' ')[0]
+ }
+ if (item.type === 'checkbox') {
+ let arr = []
+ let value = data[item.key].split(',')
+ value.forEach(item2 => {
+ arr.push(...item.options.filter(item3 => item3.value === item2))
+ })
+ item.selected = arr.map(item => item.label).join(',')
+ }
+ if (item.type === 'select') {
+ let options = item.options.map(item2 => item2[item.valueKey])
+ item.valueIndex = options.indexOf(item.value)
+ if (item.masterControl) {
+ residentTypeForm[formtype].forEach(item3 => {
+ if (item3.showFlag) {
+ if (item3.showFlag === item.value) {
+ item3.hide = false
+ } else {
+ item3.hide = true
+ }
+ }
+ })
+ }
+ } else {
+ item.valueIndex = -1
+ }
+ }
+ }
+ }
+ })
+ this.setData({
+ residentTypeForm,
+ [formtype + 'Open']: true,
+ dynamicFormsTitle: '填写' + e.currentTarget.dataset.title,
+ currentFormController: formtype,
+ formController: this.data.residentTypeForm[e.currentTarget.dataset.formtype],
+ isShowDynamicForms: true
+ })
+ console.log(this.data)
+ },
+ // 获取住房性质
+ getHouseTypes() {
+ getHouseType({formCode: "resi_base_info"}).then(res => {
+ console.log(res.data)
+ this.setPickerOptions('housingNature', res.data)
+ })
+ },
+
+ getDictData(dictType, formName) {
+ dictlist({'dictType': dictType}).then(res => {
+ this.setPickerOptions(formName, res.data)
+ });
+ },
+ setPickerOptions(key, options) {
+ let residentTypeForm = this.data.residentTypeForm
+ for (let item in residentTypeForm) {
+ residentTypeForm[item].forEach(item2 => {
+ if (item2.key === key) {
+ item2.options = options
+ }
+ })
+ }
+ this.setData({residentTypeForm})
+ },
+ getValue(arry) {
+ let obj = {}
+ arry.forEach(item => {
+ if (item.type === 'date' && item.value != '') {
+ item.value = item.value + ' 00:00:00'
+ }
+ obj[item.key] = item.value
+ })
+ return obj
+ },
})
\ No newline at end of file
diff --git a/subpages/addResi/pages/addResi/addResi.json b/subpages/addResi/pages/addResi/addResi.json
index ef839c2..387fc74 100644
--- a/subpages/addResi/pages/addResi/addResi.json
+++ b/subpages/addResi/pages/addResi/addResi.json
@@ -1,6 +1,7 @@
{
"usingComponents": {
- "wux-select": "../../../../components/dist/select"
+ "wux-select": "../../../../components/dist/select",
+ "DynamicForms": "../../../../components/DynamicForms/DynamicForms"
},
"navigationStyle": "custom"
}
\ No newline at end of file
diff --git a/subpages/addResi/pages/addResi/addResi.wxml b/subpages/addResi/pages/addResi/addResi.wxml
index f7aad6a..83a07cb 100644
--- a/subpages/addResi/pages/addResi/addResi.wxml
+++ b/subpages/addResi/pages/addResi/addResi.wxml
@@ -1,234 +1,279 @@