epmet 工作端 小程序
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.

262 lines
6.2 KiB

// subpages/resnoinformation/pages/resnoinformation/resnoinformation.js
import api, {
getAllOrgCategoryCount,
getResidentBaseInfo,
getTopTree,
getNextTree,
houseSearch,
allOrgHouseInfo,
getCommunityHouse,
getAgencygridtree,
} from "../../../../utils/api"
var http = require('../../../../utils/request.js')
var fly = require('../../../../utils/request')
Page({
/**
* 页面的初始数据
*/
data: {
level: 'district',
dicts: {
attentioncrowdList: [], // 注意群体列表
},
selectedAttentionCrowd: '', // 用户选择的注意群体
cascaderValue:'',
dictType:[],
showResident:false,
cascaderName:null,
showStreet:false,
searchOrgIdPath:'',
angencyList:[],
fieldName: {
text: 'label',
value: 'id',
children: 'children'
},
maxLength:10,
fieldNames1:{
text: 'lable1',
value: 'value',
children: 'children'
},
params: {
agencyId: '',
orgId: '',
level: 'district',
orgInfo:''
},
params1: {
"searchKey": "",
"pageSize": 50,
"pageNo": 1,
"searchOrgIdPath": "7b6f9a9f9f38d5f9fa7ce94a93d6eb28",
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getAgencygridtree();
this.getDicts()
this.getTopTreeData()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
onShowPoint(){
this.setData({
showStreet:true
})
},
getTopTreeData() {
getTopTree().then(res => {
console.log("222220",res)
const arr = res.data.children.map(item => {
return {
...item,
children: []
}
})
this.setData({
angencyList: [{ ...res.data, children: arr }],
})
})
},
getTreeFun(id, arr, data) {
return arr.map(item => {
if (id == item.id) {
return {
...item,
children: data,
}
}
if (item.children && item.children.length > 0) {
return {
...item,
children: this.getTreeFun(id, item.children, data),
}
}
return item
})
},
onChange(e) {
const { value, tabIndex, selectedOptions } = e.detail;
console.log("12344",e.detail)
if (tabIndex > 0 && selectedOptions[selectedOptions.length - 1].level != 'building') {
const level = selectedOptions[selectedOptions.length - 1].level
api.getNextTree({ level, id: value }).then(res => {
console.log("123",res)
if (res.data.length > 0) {
const data = res.data.map(item => {
console.log('111126210',item)
if (item.level != 'building') {
return {
...item,
children: []
}
}
return {
...item,
children: null
}
});
const arr = this.getTreeFun(value, this.data.angencyList, data);
this.setData({
angencyList: arr,
})
} else {
const arr = this.getTreeFun(value, this.data.angencyList, null);
this.setData({
angencyList: arr,
})
}
})
}
},
onClose() {
this.setData({
showStreet: false,
});
},
getAgencygridtree() {
api.getAgencygridtree().then(res => {
this.setData({
angencyList: [res.data]
});
}).catch(err => {
console.log,(err);
})
},
onclickResident(){
this.setData({
showResident:true,
})
},
async getDicts() {
try {
const requests = [
http.post("sys/dict/data/dictlist", {
dictType: "attention_crowd",
}),
];
const result = await http.post("sys/dict/data/dictlist", { dictType: "attention_crowd" });
if (result.code === 0) {
this.setData({
"dicts.attentioncrowdList": result.data
})
} else {
console.log("获取注意群体失败: ", result.data.msg);
}
} catch (error) {
console.log("获取字典失败: ", error);
}
},
onAttentionCrowdChange(event) {
const index = event.detail.value; // 用户选择的注意群体在字典数据数组中的索引
const selectedAttentionCrowd = this.data.dicts.attentioncrowdList[index]; // 根据索引获取选择的注意群体
this.setData({
selectedAttentionCrowd: selectedAttentionCrowd.label // 更新选择的注意群体
});
},
onFinish(e) {
const { selectedOptions, value } = e.detail;
// const fieldNameFw = selectedOptions
// .map((option) => option.text || option.name)
// .join('/');
const level = selectedOptions[selectedOptions.length - 1].level
this.setData({
cascaderName: e.detail.selectedOptions.map(item => item.label).join(' '),
showStreet: false,
cascaderValue: value,
params: {
...this.data.params,
orgId: value,
level,
},
params1: {
...this.data.params1,
searchOrgIdPath: value,
orgId: value,
level,
},
});
this.getTableData()
},
})