OrderScreen.js
4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
Component({
/**
* 组件的属性列表
*/
properties: {
navBarHeight: String,
show: {
type: Boolean,
observer: function (n, o) {
if (n) {
this.setViewData()
} else {
this.setData({
x: this.data.windowWidth
})
}
}
}
},
/**
* 组件的初始数据
*/
data: {
IMG_URL,
maxDate: new Date().format('yyyy-MM-dd'),
orderTimeList: [{
name: '全部',
active: true
}, {
name: '今日',
createdStartDate: new Date().format('yyyy-MM-dd'),
createdEndDate: new Date().format('yyyy-MM-dd')
}, {
name: '本月',
createdStartDate: new Date(new Date().setDate(1)).format('yyyy-MM-dd'),
createdEndDate: new Date().format('yyyy-MM-dd')
}, {
createdStartDate: '',
createdEndDate: '',
type: 'custom'
}]
},
/**
* 组件的方法列表
*/
methods: {
setViewData() {
let {
navBarHeight
} = this.data
wx.$util.getViewInfo(
'.btn-box',
res => {
console.log(res)
this.setData({
height: navBarHeight,
btnHeight: res.height
})
},
this
)
},
init() {
let {
orderTimeList
} = this.data
this.setData({
['form.orderTimeList']: wx.$util.deepClone(orderTimeList)
})
},
showMore(e) {
let {
type
} = e.currentTarget.dataset
let {
employShowMore,
salesmanShowMore
} = this.data
let prop = type == 1 ? 'employShowMore' : 'salesmanShowMore'
this.setData({
[prop]: type == 1 ? !employShowMore : !salesmanShowMore
})
},
rangeSelect(e) {
let {
index,
name
} = e.currentTarget.dataset
let data = this.data.form[name]
let {
date: {
start,
end
}
} = e.detail
data?.map(i => (i.active = false))
let obj = name == 'orderTimeList' ? {
active: true,
createdStartDate: start,
createdEndDate: end,
type: 'custom'
} : {
active: true,
payStartDate: start,
payEndDate: end,
type: 'custom'
}
data[index] = obj
this.setData({
[`form.${name}`]: data,
isReset: false
})
},
// 日期组件
showCalendar(e) {
let {
target
} = e.currentTarget.dataset
let calendarModule = target == 'showOrder' ? this.selectComponent('#orderCalendar') : this.selectComponent('#payCalendar')
calendarModule.showCalendar && calendarModule.showCalendar(e)
},
choose(e) {
let {
index,
listName
} = e.currentTarget.dataset
let target = this.data.form[listName]
if (target[index].disabled) return
target.forEach(i => {
i.active = false
})
target[index].active = true
this.setData({
[`form.${listName}`]: target,
isReset: false
})
},
reset() {
this.init()
},
confirm() {
let {
form,
userInfo,
isReset
} = this.data
let obj = {}
Object.keys(form).forEach(e => {
form[e]?.map(i => {
if (i.active) {
let {
createdStartDate,
createdEndDate,
} = i
if (createdStartDate && createdEndDate) {
obj.createdStartDate = `${createdStartDate} 00:00:00`
obj.createdEndDate = `${createdEndDate} 23:59:59`
}
}
})
})
if (isReset) obj = {}
this.triggerEvent('confirm', obj)
}
},
attached() {
wx.$util.getSystemInfo(info => {
let {
windowWidth
} = info
this.setData({
x: windowWidth,
windowWidth,
isFullSucreen: wx.$util.isFullSucreen(true)
})
})
this.init()
}
})