// subpages/searchResult/pages/resiInfo/resiInfo.js import api from "../../../../utils/api" var http = require('../../../../utils/request.js') const QQMapWX = require('../../../../utils/qqmap-wx-jssdk') const app = getApp() var timerId = null; Page({ /** * 页面的初始数据 */ data: { checkPassword:false, form: {}, resiId: "", punchFlag: null, currentTime: '', address: '', longitude: '', latitude: '', agencyLevel: '', recentTime: '', lastLog: {}, tabList: [], originalExpandList: [{ id: "healthDto", title: "残疾信息", scrollId: "disability", children: [{ label: "残疾类别", itemType: "select1", formName: "disabilityCategoryCode", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "disability_category_code" }, opction: [], }, { label: "残疾等级", itemType: "select1", formName: "disabilityLevel", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "disability_level" }, opction: [], }, { label: "残疾证号", itemType: "input1", formName: "disabilityNum", }, { label: "残疾说明", itemType: "input1", formName: "disabilityDesc", }, { label: "监护人", itemType: "radio1", formName: "guardianFlag", opction: [{ label: "有", formName: "", value: 1 }, { label: "无", formName: "", value: 0 }, ], }, { label: "监护人姓名", itemType: "input1", formName: "guardianName", }, { label: "监护人联系电话", itemType: "input1", formName: "guardianMobile", }, { label: "技能特长", itemType: "radio1", formName: "specialSkillFlag", opction: [{ label: "有", formName: "", value: 1 }, { label: "无", formName: "", value: 0 }, ], }, { label: "劳动能力", itemType: "radio1", formName: "workCapacityFlag", opction: [{ label: "有", formName: "", value: 1 }, { label: "无", formName: "", value: 0 }, ], }, ], }, { id: "seriousIllnessDto", title: "大病信息", scrollId: "serious_illness", children: [{ label: "所患大病", itemType: "checkbox", formName: "illnessCodes", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "illness_code" }, opction: [], }, ], }, { id: "chronicDiseaseDto", title: "慢病信息", scrollId: "chronic_disease", children: [{ label: "所患慢病", itemType: "checkbox", formName: "chronicDiseaseCodes", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "chronic_disease_code" }, opction: [], }, ], }, { id: "deathDto", title: "死亡信息", scrollId: "death", children: [{ label: "死亡时间", itemType: "datepicker1", formName: "deathTime", }, ], }, { id: "oldPeopleDto", title: "老年人信息", scrollId: "old_people", children: [{ label: "老年人分类", itemType: "checkbox", multiple: true, formName: "oldPeopleCategories", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "oldPeople_categories" }, }, { label: "居住情况", itemType: "select1", formName: "resideSituation", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "reside_situation" }, }, { label: "高龄补助", itemType: "inputNum", formName: "oldSubsidy", }, ], }, { id: "subsistenceAllowanceDto", title: "低保信息", scrollId: "subsistence_allowance", children: [{ label: "低保类别", itemType: "select1", formName: "category", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "subsistence_allowance_category" }, }, { label: "低保享受原因", itemType: "checkbox", formName: "reasons", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "subsistence_allowance_reasons" }, opction: [], }, ], }, { id: "parymemberInfoDto", title: "党员信息", scrollId: "party_member", children: [{ label: "入党时间", itemType: "datepicker1", formName: "joinTime", opction: [], }, { label: "转正时间", itemType: "datepicker1", formName: "positiveTime", opction: [], }, { label: "所属党组织", itemType: "cascader1", formName: "partyOrgId", opction: [], }, { label: "流动党员", itemType: "radio1", formName: "flowFlag", opction: [{ label: "是", value: 1 }, { label: "否", value: 0 }, ], }, { label: "流动党员活动证号", itemType: "input1", formName: "flowActNum", }, { label: "职务", itemType: "select1", formName: "partyJob", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "party_job" }, opction: [], }, { label: "工作职责", itemType: "input1", formName: "duty", }, { label: "是否退休", itemType: "radio1", formName: "retiredFlag", opction: [{ label: "是", value: 1 }, { label: "否", value: 0 }, ], }, { label: "党员中心户", itemType: "radio1", formName: "centerFlag", opction: [{ label: "是", value: 1 }, { label: "否", value: 0 }, ], }, { label: "免学习", itemType: "radio1", formName: "studyNotNeed", opction: [{ label: "是", value: 1 }, { label: "否", value: 0 }, ], }, { label: "入党时所在党支部", itemType: "input1", formName: "joinBranchName", }, { label: "组织关系转入社区时间", itemType: "datepicker1", formName: "joinCommunityTime", opction: [], }, ], }, { id: "ensureHouseDto", title: "保障房信息", scrollId: "ensure_house", children: [{ label: "所在社区", itemType: "input1", formName: "liveCommunity", }, { label: "住房性质", itemType: "select1", formName: "housingNature", opctionUrl: "sys/dict/data/house", opctionParams: { formCode: "resi_base_info" }, opction: [], }, ], }, { id: "veteranDto", title: "退役军人信息", scrollId: "veteran", children: [{ label: "入伍时间", itemType: "datepicker1", formName: "joinArmyTime", opction: [], }, { label: "退伍时间", itemType: "datepicker1", formName: "leaveArmyTime", opction: [], }, { label: "服役单位", itemType: "input1", formName: "serviceUnit", }, { label: "接收单位", itemType: "input1", formName: "receiveUnit", }, { label: "待安置补助金", itemType: "inputNum", formName: "settlementAmount", opction: [], }, { label: "培训状况", itemType: "input1", formName: "trainDesc", }, { label: "现就业情况", itemType: "input1", formName: "employmentSituation", }, { label: "是否办理公益性岗位", itemType: "radio1", formName: "pubWelfareJobFlag", opction: [{ label: "是", value: 1 }, { label: "否", value: 0 }, ], }, ], }, { id: "unitedFrontDto", title: "统战人员信息", scrollId: "united_front", children: [{ label: "统战类型", itemType: "input1", formName: "unitedFrontType", }, ], }, { id: "volunteerDto", title: "志愿者信息", children: [{ label: "志愿者类别", itemType: "checkbox", formName: "volunteerCategory", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "VOLUNTEER_CATEGORY" }, opction: [], }, ], }, { id: "specialSupportDto", title: "特扶人员信息", scrollId: "special_support", children: [{ //0 label: "特扶类别", itemType: "select1", formName: "specialSupportType", opction: [{ value: "1", label: "失独", }, { value: "2", label: "伤残", }, ], }, { //1 label: "子女姓名", itemType: "input1", formName: "childName", opction: [], }, { //2 label: "子女性别", itemType: "select1", formName: "childGender", opction: [{ value: "1", label: "男", }, { value: "2", label: "女", }, ], }, { label: "子女死亡日期", itemType: "datepicker1", formName: "childDeathDate", opction: [], }, { label: "子女伤残类别", itemType: "select1", formName: "childDisabilityCategoryCode", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "disability_category_code" }, opction: [], }, { label: "子女伤残等级", itemType: "select1", formName: "childDisabilityLevel", opctionUrl: "sys/dict/data/dictlist", opctionParams: { dictType: "disability_level" }, opction: [], }, ], }, ], expandList: [], activeType: 0, tagList: [], idTypeList: [{ label: '其他', value: 0 }, { label: '身份证', value: 1 }, { label: '护照', value: 2 }, { label: '港澳通行证', value: 3 }, { label: '军人证', value: 4 }, { label: '台胞证', value: 5 } ], dicts:{ careerStatusArr:[], marriageArr:[], householdSituationArr:[], houseHolderRelArr:[] }, password:'' }, /** * 生命周期函数--监听页面加载 */ onLoad:async function(options) { await this.getDicts() if (options.resiId) { this.setData({ resiId: options.resiId, 'form.baseInfoDto.name':options.name, 'form.baseInfoDto.idNum':options.idNum, 'form.baseInfoDto.mobile':options.mobile, }) await this.getResiInfo() } // this.data.qqMapWX = new QQMapWX({ // key: 'CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ' // }) // this.reverseLocation() this.setData({ agencyLevel: app.globalData.user.level }) // this.getLastLogs() }, getDicts:async function() { try { const requests = [ http.post("sys/dict/data/dictlist", { dictType: "career_status", }), http.post("sys/dict/data/dictlist", { dictType: "marriage", }), http.post("sys/dict/data/dictlist", { dictType: "household_situation", }), http.post("sys/dict/data/relationship", { formCode: "resi_base_info", }), ]; const dictKeys = [ "careerStatusArr", "marriageArr", "householdSituationArr", "houseHolderRelArr" ]; // 对应的键名 const results = await Promise.all(requests); results.forEach((result, index) => { if (result.code === 0) { this.setData({ [`dicts.${dictKeys[index]}`]: [...result.data] }) } else { console.log(`获取${dictKeys[index]}失败: ${result.data.msg}`); } }); } catch (error) { console.log("获取字典失败: ", error); } }, getResiInfo: async function () { try { let res = await api.getResiInfo(this.data.resiId); console.log(res) let marriageName = '--' if (res.data.residentCategoryStr) { res.data.baseInfoDto.categoryInfo.categoryNames = res.data.residentCategoryStr.split(',') } if(res.data.familyInfoDto&&res.data.familyInfoDto.marriage){ marriageName = this.data.dicts.marriageArr.filter(item=>item.value == res.data.familyInfoDto.marriage)[0].label } // 处理tab this.setData({ form: res.data, marriageName:marriageName }); await this.updateTabList(res.data.integrityData.integrityQtyMap) } catch (err) { console.log(err); } }, updateTabList: async function (value) { const nameMap = { reside: "居住信息", ext: "拓展信息", united_front: "统战人员信息", party_member: "党员信息", death: "死亡信息", disability: "残疾信息", subsistence_allowance: "低保信息", serious_illness: "大病信息", veteran: "退役军人信息", special_support: "特扶人员信息", old_people: "老年人信息", ensure_house: "保障房信息", chronic_disease: "慢病信息", base: "基本信息", graph:"关系图谱" }; let list = Object.entries( value ) .map(([key, value]) => ({ name: nameMap[key], id: key, filledQty: value.filledQty, totalQty: value.totalQty, })) .reverse(); list.push({ name:'关系图谱', id:"graph" }, ) this.setData({ tabList: list }) let arr = this.data.tabList.filter( (item) => item.filledQty > 0 || ( item.name == "拓展信息" ||item.name == "居住信息" || item.name == "基本信息") ); let arrs = [] arrs = this.data.originalExpandList.filter((itemA) => { return arr.some((itemB) => itemB.name === itemA.title); }); await Promise.all( arrs.map(async (item) => { await Promise.all( item.children.map(async (child) => { const key = child.formName; if (this.data.form[item.id].hasOwnProperty(key)) { child.value = await this.getDictName( child.opctionUrl, child.opctionParams, this.data.form[item.id][ key == "partyOrgId" ? "branchId" : key ], child.itemType, child.opction ); } }) ); }) ); this.setData({ expandList: arrs }) }, clickGraphNode(parm){ if(parm.detail.data.type === 0){ this.setData({ resiId:parm.detail.data.id }) this.getResiInfo() }else{ wx.navigateTo({ url: `/subpages/house/pages/housePortrait/housePortrait?resiId=${parm.detail.data.id}`, }) } }, getDictName: async function (url, params, value, itemType, opction) { try { if (url) { const { data } = await http.post(url, params); if (itemType == "checkbox") { const matchedLabels = value .map((item) => { const matchedItems = data.filter( (obj) => obj.value === item ); if (matchedItems.length > 0) { return matchedItems .map((matchedItem) => matchedItem.label) .join(","); } else { return ""; } }) .join(","); return matchedLabels ? matchedLabels : "--"; } else if (itemType == "select1") { const matchedItem = data.find((item) => item.value === value); return matchedItem ? matchedItem.label : "--"; } } else { if (itemType == "radio1") { const matchedItem = opction.find((item) => item.value === value); return matchedItem ? matchedItem.label : "--"; } else if ( itemType == "input1" || itemType == "datepicker1" || itemType == "cascader1" ) { return value ? value : "--"; } } } catch (error) { console.log(error); } }, handlePunch() { this.setData({ // punchFlag:!this.data.punchFlag, animationClass: 'animate' }) setTimeout(() => { this.setData({ animationClass: '' }); this.clockRecords() }, 1500); }, clockRecords() { let currentDate = new Date().toISOString().split('T')[0]; // 会得到形如 "2023-09-27" 的日期 let obj = { resiId: this.data.resiId, clockTime: currentDate + " " + this.data.currentTime, clockAddress: this.data.address, longitude: this.data.longitude, latitude: this.data.latitude } api.clockRecords(obj).then(res => { wx.showToast({ // title: this.data.punchFlag?'打卡成功':'更新成功', title: '打卡成功', icon: 'none' }) }).catch(err => { console.log(err); }) }, toAddResi() { api.isUpdater(this.data.resiId).then(result => { if (result.code==0) { if (result.data==true) { this.onConfirmassword() } else{ this.setData({ checkPassword:true }) } } }); }, bindPassword(e){ this.setData({ password:e.detail.value }) }, // 关闭 onClosePassword(){ this.setData({ checkPassword:false }) }, // onClickconfirm(){ this.onConfirmassword(this.data.password) }, // onConfirmassword(password){ let parm = { password } api.getResiUserInfo(this.data.resiId,parm).then(res=>{ if(res.code === 0){ wx.navigateTo({ url: `/subpages/addResi/pages/addResi/addResi?type=edit&resiId=${this.data.resiId}&name=${res.data.name}&mobile=${res.data.mobile}&idNum=${res.data.idNum}`, }) this.setData({ password:null }) }else{ this.setData({ password:null }) this.showToast(res.msg) } }).catch(err=>{ console.log(err); }) }, toWebView() { console.log(app.globalData); if (app.globalData.questionnaireUrl) { wx.navigateTo({ url: '/pages/webView/webView?url=' + app.globalData.questionnaireUrl, }) } else { wx.showToast({ icon: "none", title: '未创建满意度调查问卷', }) } }, toEvent() { let obj = { resiId: this.data.resiId, resiMobile: this.data.form.baseInfoDto.mobile, resiName: this.data.form.baseInfoDto.name } wx.setStorageSync('resiDetail', obj) wx.navigateTo({ url: '/subpages/demandCheck/pages/dissatisfied/demandCheck/demandCheck', }) }, reverseLocation() { const _this = this this.data.qqMapWX.reverseGeocoder({ success(res) { _this.setData({ addressContent: res.result.address, address: res.result.address, longitude: res.result.location.lng, latitude: res.result.location.lat, }) }, fail(err) { console.debug(err) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { if (timerId) { clearInterval(timerId); timerId = null; } }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, gotopage(e) { wx.navigateTo({ url: e.currentTarget.dataset.url, }) }, // getLastLogs() { // api.getLastLog({ // resiId: this.data.resiId // }).then(res => { // this.setData({ // lastLog: res.data // }) // }) // }, goResidentPortrait2() { wx.navigateTo({ url: '/subpages/statistics/pages/residentPortrait2/residentPortrait?id=' + this.data.resiId, }) }, handelTopunchCard(){ wx.navigateTo({ url: '/subpages/searchResult/pages/punchCard/punchCard?resiId=' + this.data.resiId, }) }, handelClickTab(e) { wx.pageScrollTo({ selector: `#${e.currentTarget.dataset.item.id}`, duration:300 }); this.setData({ activeType: e.currentTarget.dataset.index }) } })