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.
606 lines
18 KiB
606 lines
18 KiB
const App = getApp()
|
|
import api, {
|
|
getAllOrgCategoryCount,
|
|
getResidentBaseInfo,
|
|
getTopTree,
|
|
getNextTree,
|
|
houseSearch,
|
|
allOrgHouseInfo,
|
|
getCommunityHouse,
|
|
} from "../../utils/api"
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
activeType: 0,
|
|
tabList: [],
|
|
tableData: [],
|
|
tableFwData: [],
|
|
resiList: [{
|
|
name: '',
|
|
resiTags: [''],
|
|
nationalityName: '',
|
|
nationName: '',
|
|
mobile: '',
|
|
idNum: '',
|
|
agencyName: '',
|
|
homeName: '',
|
|
updatedTime: ''
|
|
}
|
|
|
|
],
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
lowerThreshold: '10',
|
|
loadMoreVisible: true,
|
|
loadFwMoreVisible: false,
|
|
loadMoreType: "none",
|
|
loadFwMoreType: "none",
|
|
nodata: false,
|
|
nodatafw: false,
|
|
selectVale: 'resi',
|
|
keyWord: '',
|
|
angencyId: null,
|
|
category: null,
|
|
searchOrgIdPath: '',
|
|
cascaderFwValue: '',
|
|
angencyList: [], //组织树
|
|
angencyFwList: [], //房屋组织树
|
|
showAngenCascader: false,
|
|
agencyName: '',
|
|
fieldName: {
|
|
text: 'label',
|
|
value: 'id',
|
|
children: 'children'
|
|
},
|
|
|
|
cascaderNameFw: null,
|
|
showFw: false,
|
|
params: {
|
|
agencyId: '',
|
|
orgId: '',
|
|
level: 'district',
|
|
orgInfo:''
|
|
},
|
|
params1: {
|
|
"searchKey": "",
|
|
"pageSize": 50,
|
|
"pageNo": 1,
|
|
"searchOrgIdPath": "",
|
|
},
|
|
activeFwType: 0,
|
|
fwTypes: [
|
|
{ name: '房屋', num: 0, value: '' },
|
|
{ name: '自住', num: 0, value: '0' },
|
|
{ name: '出租', num: 0, value: '1' },
|
|
{ name: '闲置', num: 0, value: '2' },
|
|
{ name: '未出售', num: 0, value: '3' },
|
|
],
|
|
tempList:[],
|
|
angencyJmList:[],
|
|
houseListSearchFlag:false
|
|
},
|
|
handelClickedit(e){
|
|
console.log(e);
|
|
wx.navigateTo({
|
|
url: `/subpages/house/pages/housePortrait/housePortrait?resiId=${e.currentTarget.dataset.item.id}`,
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.setData({
|
|
searchOrgIdPath: App.globalData.user.agencyId,
|
|
cascaderName: App.globalData.user.agencyName,
|
|
cascaderNameFw: App.globalData.user.agencyName,
|
|
agencyName: App.globalData.user.agencyName,
|
|
params: {
|
|
...this.data.params,
|
|
agencyId:App.globalData.user.agencyId,
|
|
orgId:App.globalData.user.agencyId
|
|
},
|
|
params1: {
|
|
...this.data.params1,
|
|
// searchOrgIdPath:App.globalData.user.agencyId,
|
|
},
|
|
statusHeight: App.globalData.deviceInfo.statusHeight,
|
|
navigationHeight: App.globalData.deviceInfo.navigationHeight,
|
|
})
|
|
this.getAllOrgCategoryCount()
|
|
this.getTableData()
|
|
this.getTopTreeData()
|
|
},
|
|
//
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
this.getIntelligentMessage()
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
},
|
|
getUnitoption(val){
|
|
getNextTree({ level:val[0].level, id: val[0].id ||val[0].agencyId}).then(res => {
|
|
if (res.data.length > 0) {
|
|
if(res.data[0].level!='unit' || res.data[0].level=='unit' ){
|
|
this.setData({
|
|
tempList:this.data.tempList.concat([res.data[0]])
|
|
})
|
|
this.getUnitoption(res.data)
|
|
}
|
|
let unitId = this.data.tempList.filter(item=>item.level == 'unit')[0]?.id
|
|
this.setData({
|
|
cascaderNameFw:this.data.tempList.map(item=>item.label).splice(0,this.data.tempList.length-1).join(','),
|
|
'params1.searchOrgIdPath':unitId,
|
|
'params.orgId':unitId
|
|
})
|
|
const data = res.data.map(item => {
|
|
if (item.level != 'unit') {
|
|
return {
|
|
...item,
|
|
children: []
|
|
}
|
|
}
|
|
return {
|
|
...item,
|
|
children: null
|
|
}
|
|
});
|
|
const arr = this.getTreeFun(val[0].agencyId, this.data.angencyFwList, data);
|
|
this.setData({
|
|
angencyFwList: arr,
|
|
})
|
|
} else {
|
|
const arr = this.getTreeFun(val[0].agencyId, this.data.angencyFwList, null);
|
|
this.setData({
|
|
angencyFwList: arr,
|
|
})
|
|
this.getTableFwData()
|
|
}
|
|
})
|
|
},
|
|
toOCRCard() {
|
|
wx.navigateTo({
|
|
url: '/subpages/OCRCard/pages/index/index',
|
|
})
|
|
},
|
|
handelClickTab(e) {
|
|
this.setData({
|
|
activeType: e.currentTarget.dataset.index,
|
|
category: e.currentTarget.dataset.category,
|
|
tableData: []
|
|
})
|
|
this.getTableData()
|
|
},
|
|
handelClickTabFw(e) {
|
|
this.setData({
|
|
activeFwType: e.currentTarget.dataset.index,
|
|
// category: e.currentTarget.dataset.category,
|
|
loadFwMoreVisible: true,
|
|
tableFwData: [],
|
|
params1: {
|
|
...this.data.params1,
|
|
pageNo: 1,
|
|
"category": e.currentTarget.dataset.category,
|
|
},
|
|
})
|
|
this.getTableFwData()
|
|
},
|
|
handelBlurKeyWord(e) {
|
|
this.setData({
|
|
keyWord: e.detail.value
|
|
})
|
|
},
|
|
getTopTreeData() {
|
|
getTopTree().then(res => {
|
|
const arr = res.data.children.map(item => {
|
|
return {
|
|
...item,
|
|
children: []
|
|
}
|
|
})
|
|
this.setData({
|
|
angencyFwList: [{ ...res.data, children: arr }],
|
|
angencyJmList:[{ ...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
|
|
})
|
|
},
|
|
onChangeJm(e) {
|
|
const { value, tabIndex, selectedOptions } = e.detail;
|
|
if (tabIndex > 0 ) {
|
|
const level = selectedOptions[selectedOptions.length - 1].level;
|
|
const orgId = selectedOptions[selectedOptions.length - 1].id;
|
|
const cascaderName = selectedOptions.map(item=>item.label).join('');
|
|
this.setData({
|
|
searchOrgIdPath:orgId,
|
|
cascaderName,
|
|
tableData:[],
|
|
pageNo: 1,
|
|
})
|
|
getNextTree({ level, id: value }).then(res => {
|
|
if (res.data.length > 0) {
|
|
const data = res.data.map(item => {
|
|
if (item.level != 'house') {
|
|
return {
|
|
...item,
|
|
children: []
|
|
}
|
|
}
|
|
return {
|
|
...item,
|
|
children: null
|
|
}
|
|
});
|
|
const arr = this.getTreeFun(value, this.data.angencyJmList, data);
|
|
this.setData({
|
|
angencyJmList: arr,
|
|
})
|
|
} else {
|
|
const arr = this.getTreeFun(value, this.data.angencyJmList, null);
|
|
this.setData({
|
|
angencyJmList: arr,
|
|
})
|
|
}
|
|
})
|
|
}
|
|
this.getTableData()
|
|
this.getAllOrgCategoryCount()
|
|
},
|
|
onFinishJm(e) {
|
|
this.setData({
|
|
pageNo: 1,
|
|
searchOrgIdPath: e.detail.selectedOptions[e.detail.selectedOptions.length - 1].id,
|
|
cascaderName: e.detail.selectedOptions.map(item => item.label).join(','),
|
|
tableData: []
|
|
})
|
|
this.getTableData()
|
|
this.getAllOrgCategoryCount()
|
|
},
|
|
onChangeFw(e) {
|
|
const { value, tabIndex, selectedOptions } = e.detail;
|
|
if (tabIndex > 0 && selectedOptions[selectedOptions.length - 1].level != 'unit') {
|
|
const level = selectedOptions[selectedOptions.length - 1].level
|
|
getNextTree({ level, id: value }).then(res => {
|
|
if (res.data.length > 0) {
|
|
const data = res.data.map(item => {
|
|
if (item.level != 'unit') {
|
|
return {
|
|
...item,
|
|
children: []
|
|
}
|
|
}
|
|
return {
|
|
...item,
|
|
children: null
|
|
}
|
|
});
|
|
const arr = this.getTreeFun(value, this.data.angencyFwList, data);
|
|
this.setData({
|
|
angencyFwList: arr,
|
|
})
|
|
} else {
|
|
const arr = this.getTreeFun(value, this.data.angencyFwList, null);
|
|
this.setData({
|
|
angencyFwList: arr,
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
onCloseFw() {
|
|
this.setData({
|
|
showFw: false,
|
|
});
|
|
},
|
|
|
|
onFinishFw(e) {
|
|
const { selectedOptions, value } = e.detail;
|
|
const level = selectedOptions[selectedOptions.length - 1].level
|
|
this.setData({
|
|
cascaderNameFw: e.detail.selectedOptions.map(item => item.label).join(' '),
|
|
showFw: false,
|
|
cascaderFwValue: value,
|
|
params: {
|
|
...this.data.params,
|
|
orgId: value,
|
|
level:level == 'grid'?'grid':'agency',
|
|
agencyId:App.globalData.user.agencyId
|
|
},
|
|
params1: {
|
|
pageNo: 1,
|
|
...this.data.params1,
|
|
searchOrgIdPath: value,
|
|
// orgId: value,
|
|
level,
|
|
},
|
|
tableFwData:[]
|
|
});
|
|
this.getTableFwData()
|
|
},
|
|
handelClickSearchType(e) {
|
|
this.setData({
|
|
selectVale: e.currentTarget.dataset.type
|
|
})
|
|
if(e.currentTarget.dataset.type === 'resi'){
|
|
this.setData({
|
|
pageNo: 1,
|
|
tableData: []
|
|
})
|
|
this.getTableData()
|
|
this.getAllOrgCategoryCount()
|
|
}else if(e.currentTarget.dataset.type === 'house'){
|
|
this.setData({
|
|
pageNo: 1,
|
|
tableFwData: []
|
|
})
|
|
this.getUnitoption(this.data.angencyFwList)
|
|
}
|
|
},
|
|
handelClickShowTree() {
|
|
this.setData({
|
|
showAngenCascader: true
|
|
})
|
|
},
|
|
handelClickShowTreeFw() {
|
|
this.setData({
|
|
showFw: true
|
|
})
|
|
},
|
|
|
|
async handelClickSearch() {
|
|
if (this.data.selectVale === 'resi') {
|
|
this.setData({
|
|
pageNo: 1,
|
|
tableData: []
|
|
})
|
|
this.getTableData()
|
|
this.getAllOrgCategoryCount()
|
|
}else{
|
|
if(this.data.keyWord){
|
|
this.setData({
|
|
houseListSearchFlag:true,
|
|
'params1.searchOrgIdPath':App.globalData.user.agencyId
|
|
})
|
|
}else{
|
|
this.setData({
|
|
houseListSearchFlag:false
|
|
})
|
|
}
|
|
this.setData({
|
|
pageNo: 1,
|
|
tableFwData: []
|
|
})
|
|
this.getTableFwData()
|
|
}
|
|
},
|
|
handelClickToOcr() {
|
|
wx.navigateTo({
|
|
url: '/subpages/OCRCard/pages/index/index',
|
|
})
|
|
},
|
|
// 获取居民概览
|
|
getAllOrgCategoryCount() {
|
|
let parm = {
|
|
residentInfo: this.data.keyWord,
|
|
agencyId: App.globalData.user.agencyId,
|
|
orgId: this.data.searchOrgIdPath,
|
|
level: 'agency'
|
|
}
|
|
api.getAllOrgCategoryCount(parm).then(res => {
|
|
if (res.code == 0) {
|
|
res.data.forEach(item => {
|
|
if (item.categoryName === '党员') {
|
|
item.category = 'party'
|
|
} else if (item.categoryName === '关注人群') {
|
|
item.category = 'attention'
|
|
} else if (item.categoryName === '特殊人群') {
|
|
item.category = 'special'
|
|
} else if (item.categoryName === '非健康人群') {
|
|
item.category = 'health'
|
|
}
|
|
})
|
|
this.setData({
|
|
tabList: res.data.filter(item => item.categoryName == '党员' || item.categoryName == '关注人群' || item.categoryName == '特殊人群' || item.categoryName == '非健康人群' || item.categoryName == '居民').reverse()
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err);
|
|
})
|
|
},
|
|
toResiDetail(e) {
|
|
wx.navigateTo({
|
|
url: `/subpages/searchResult/pages/resiInfo/resiInfo?resiId=${e.currentTarget.dataset.resiid}`,
|
|
})
|
|
},
|
|
onClickJump(e) {
|
|
console.log(e)
|
|
wx.navigateTo({
|
|
url: `/subpages/house/pages/housePortrait/housePortrait?resiId=${e.currentTarget.dataset.resiid}`,
|
|
})
|
|
},
|
|
|
|
onClose() {
|
|
this.setData({
|
|
showAngenCascader: false
|
|
})
|
|
},
|
|
|
|
onScrollToLower(e) {
|
|
if (this.data.loadMoreType === 'more') {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
})
|
|
this.data.pageNo += 1
|
|
this.getTableData()
|
|
}
|
|
},
|
|
onScrollFwToLower(e) {
|
|
if (this.data.loadFwMoreType === 'more') {
|
|
this.setData({
|
|
loadFwMoreVisible: true,
|
|
})
|
|
this.data.params1.pageNo += 1
|
|
this.getTableFwData()
|
|
}
|
|
},
|
|
getTableData: async function () {
|
|
try {
|
|
this.setData({
|
|
loadMoreVisible: true,
|
|
nodata: false,
|
|
loadMoreType: "more",
|
|
})
|
|
let parm = {
|
|
searchKey: this.data.keyWord,
|
|
pageSize: this.data.pageSize,
|
|
pageNo: this.data.pageNo,
|
|
category: this.data.category,
|
|
searchOrgIdPath: this.data.searchOrgIdPath
|
|
}
|
|
let {
|
|
data,
|
|
code,
|
|
msg
|
|
} = await getResidentBaseInfo(parm)
|
|
if (code == 0) {
|
|
|
|
this.setData({
|
|
loadMoreType: data.list.length === this.data.pageSize ? 'more' : 'none',
|
|
tableData: this.data.tableData.concat(data.list.map(item=>({...item,categoryNameStr:item.categoryNameStr?item.categoryNameStr.split(','):null}))),
|
|
})
|
|
if (this.data.tableData.length == 0) {
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
nodata: true
|
|
})
|
|
}
|
|
} else {
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
nodata: true,
|
|
loadMoreType: 'none'
|
|
})
|
|
}
|
|
} catch (err) {
|
|
console.log(err);
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
nodata: true,
|
|
loadMoreType: 'none'
|
|
})
|
|
}
|
|
|
|
},
|
|
toAddResi(){
|
|
wx.navigateTo({
|
|
url: `/subpages/addResi/pages/addResi/addResi`,
|
|
})
|
|
},
|
|
getTableFwData: async function () {
|
|
this.setData({
|
|
loadFwMoreVisible: true,
|
|
nodatafw: false,
|
|
loadMoreType: "more",
|
|
})
|
|
await allOrgHouseInfo({ ...this.data.params }).then(res => {
|
|
const data = [];
|
|
let num = 0;
|
|
res.data.forEach((item, index) => {
|
|
if (index < 4) {
|
|
let value = item.name == '自住' ? '0' : item.name == '出租' ? '1' : item.name == '闲置' ? '2' : item.name == '未出售' ? '3' : '';
|
|
data.push({ ...item, value });
|
|
num = num + parseInt(item.num);
|
|
}
|
|
|
|
})
|
|
const arr = [{ name: '房屋', num, value: '' }, ...data];
|
|
this.setData({
|
|
fwTypes: arr
|
|
})
|
|
})
|
|
|
|
await houseSearch({ ...this.data.params1, searchKey: this.data.keyWord }).then(res => {
|
|
const { code, data } = res;
|
|
if (code == 0) {
|
|
this.setData({
|
|
loadFwMoreType: data.list.length === this.data.params1.pageSize ? 'more' : 'none',
|
|
tableFwData: this.data.tableFwData.concat(data.list),
|
|
})
|
|
if (this.data.tableFwData.length == 0) {
|
|
this.setData({
|
|
loadFwMoreVisible: true,
|
|
loadFwMoreType: 'none',
|
|
nodatafw: true
|
|
})
|
|
}
|
|
} else {
|
|
this.setData({
|
|
loadMoreVisible: false,
|
|
loadFwMoreVisible: false,
|
|
nodatafw: true,
|
|
loadFwMoreType: 'none'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|