jhwxapp/miniprogram/pages/components/pz-screen/index.js

108 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2023-08-10 01:21:29 +08:00
// pages/components/deep-select/index.js
import Toast from '@vant/weapp/toast/toast';
Component({
/**
* 组件的属性列表
*/
properties: {
columns:{
type:Array
},
},
/**数据监听 */
observers: {
columns: function (val) {
if(val.length > 0){
this.setData({
'condition.typeId': val[0].id,
'condition.typeText': val[0].text,
})
}
},
},
lifetimes: {
created: function(){
//在组件实例刚刚被创建时执行,注意此时不能调用 setData
},
attached: function () {
//在组件实例进入页面节点树时执行
},
ready: function () {
// 在组件在视图层布局完成后执行
},
detached: function () {
// 在组件实例被从页面节点树移除时执行
},
},
/**
* 组件的初始数据
*/
data: {
show: false,
startDateData:[],
endDateData:[],
condition:{
typeId:'',
typeText:'',
startDate:'',
endDate:'',
},
},
/**
* 组件的方法列表
*/
methods: {
//打开筛选弹窗
showPopup() {
this.setData({ show: true });
},
//关闭筛选弹窗
onClose() {
this.setData({ show: false });
},
//凭证类型筛选
onSelectChange(event){
this.setData({
'condition.typeId': event.detail.value.id,
'condition.typeText': event.detail.value.text,
})
},
//开始日期
onStartDate(e){
this.setData({
'condition.startDate': e.detail,
})
},
//结束日期
onEndDate(e){
this.setData({
'condition.endDate': e.detail,
})
},
//确认按钮
onConfirm(){
var start = new Date(this.data.condition.startDate)
var end = new Date(this.data.condition.endDate)
if(start > end){
Toast.fail('开始时间不能大于结束时间');
}else{
this.triggerEvent('screen',this.data.condition)
this.setData({ show: false});
}
}
}
})