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.
135 lines
3.4 KiB
135 lines
3.4 KiB
import { getStreetList } from '../../../../api/basic'
|
|
var utils = require('../../../../utils/util');
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
streetVisible: false,
|
|
timeVisible: false,
|
|
streetList: [
|
|
{
|
|
select: true,
|
|
title: '全部',
|
|
id: '',
|
|
}
|
|
],
|
|
choosedStreet: {
|
|
title: '全部',
|
|
// @ts-ignore
|
|
id: ''
|
|
},
|
|
date: (utils.formatTimestamp(new Date())).substr(0, 10),
|
|
timeList: [
|
|
{ title: (utils.formatTimestamp(new Date())).substr(0, 10), id: '0', select: true },
|
|
{ title: '最近1个月', id: '1', select: false },
|
|
{ title: '最近3个月', id: '2', select: false },
|
|
{ title: '最近半年', id: '3', select: false },
|
|
{ title: '最近一年', id: '4', select: false }
|
|
],//1:最近1个月,2:最近3个月,3:最近半年,4:最近一年 ,""不填默认全部
|
|
choosedTime: {
|
|
title: (utils.formatTimestamp(new Date())).substr(0, 10),
|
|
id: '1'
|
|
}
|
|
},
|
|
lifetimes: {
|
|
async attached() {
|
|
this.getStreetList()
|
|
// @ts-ignore
|
|
// this.triggerEvent('chooseTimeId', '0')
|
|
}
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
// 获得街道机构列表
|
|
async getStreetList() {
|
|
// @ts-ignore
|
|
let streetList = [];
|
|
try {
|
|
let res: any = await getStreetList()
|
|
res.data.forEach((item: any, index: any) => {
|
|
this.data.streetList.push({
|
|
select: false,
|
|
title: item.deptName,
|
|
id: item.deptId,
|
|
})
|
|
})
|
|
this.setData({
|
|
// @ts-ignore
|
|
streetList: this.data.streetList,
|
|
})
|
|
// @ts-ignore
|
|
// this.triggerEvent('chooseStreetId', '')
|
|
} catch (error) {
|
|
console.log(error)
|
|
}
|
|
},
|
|
// 显示街道下拉框
|
|
showStreet() {
|
|
this.setData({
|
|
timeVisible: false,
|
|
streetVisible: !this.data.streetVisible
|
|
})
|
|
},
|
|
// 改变查询项-街道
|
|
onChnageStreet(e: AnyObject) {
|
|
const list = this.data.streetList
|
|
list.forEach(item => {
|
|
// @ts-ignore
|
|
if (item.id === e.currentTarget.dataset.id) {
|
|
// @ts-ignore
|
|
item.select = true
|
|
this.setData({
|
|
// @ts-ignore
|
|
'choosedStreet.title': item.title,
|
|
// @ts-ignore
|
|
'choosedStreet.id': item.id
|
|
})
|
|
} else {
|
|
// @ts-ignore
|
|
item.select = false
|
|
}
|
|
})
|
|
this.setData({
|
|
streetList: list,
|
|
streetVisible: true,
|
|
})
|
|
this.triggerEvent('chooseStreetId', e.currentTarget.dataset.id)
|
|
},
|
|
// 显示时间下拉框
|
|
showTime() {
|
|
this.setData({
|
|
streetVisible: false,
|
|
timeVisible: !this.data.timeVisible
|
|
})
|
|
},
|
|
// 改变查询项-时间
|
|
onChnageTime(e: AnyObject) {
|
|
const list = this.data.timeList
|
|
list.forEach(item => {
|
|
if (item.id === e.currentTarget.dataset.id) {
|
|
item.select = true
|
|
this.setData({
|
|
'choosedTime.title': item.title,
|
|
'choosedTime.id': item.id
|
|
})
|
|
} else {
|
|
item.select = false
|
|
}
|
|
})
|
|
this.setData({
|
|
timeList: list,
|
|
timeVisible: true,
|
|
})
|
|
this.triggerEvent('chooseTimeId', e.currentTarget.dataset.id)
|
|
},
|
|
}
|
|
})
|