artificerSelectPopup.js
3.42 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
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
// components/subShopMerchant/subShopMerchant.js
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function(n) {
if (n) {
let { copyArtificerList, artificerSelectObj } = this.data
copyArtificerList.map(i => {
i.active = false
if (i.id == artificerSelectObj?.technicianId) {
i.active = true
}
return i
})
this.setData({
artificerList: wx.$util.deepClone(copyArtificerList),
selectedTechnicianId: artificerSelectObj?.technicianId,
searchValue: ''
})
}
}
},
title: String,
orderInfo: Object,
artificerSelectObj: Object,
copyArtificerList: Array
},
/**
* 组件的初始数据
*/
data: {
orderObj: {},
IMG_URL,
artificerList: [],
searchValue: ''
},
/**
* 组件的方法列表
*/
methods: {
search(e) {
let { copyArtificerList } = wx.$util.deepClone(this.data)
let { selectedTechnicianId } = this.data
let { value } = e.detail
if (!value) {
copyArtificerList.map(i => {
i.active = false
if (i.id == selectedTechnicianId) i.active = true
return i
})
this.setData({
artificerList: copyArtificerList
})
} else {
let arr = []
copyArtificerList.map(i => {
i.active = false
if (i.id == selectedTechnicianId) i.active = true
if (i.staffName.indexOf(value) != -1) {
arr.push(i)
}
})
this.setData({
artificerList: arr
})
}
},
changeItem(e) {
let { target } = e.currentTarget.dataset
let { artificerList } = this.data
let { copyArtificerList } = wx.$util.deepClone(this.data)
artificerList.forEach(i => {
if (i.id != target?.id) i.active = false
if (i.id == target?.id) i.active = !i.active
})
copyArtificerList.forEach(i => {
if (i.id != target?.id) i.active = false
if (i.id == target?.id) i.active = !i.active
})
this.setData({
artificerList,
copyArtificerList,
selectedTechnicianId: target.id
})
},
cancel() {
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
artificerSelectPopup: false
})
},
// 打开生意助手小程序
goMiniprogram() {
wx.navigateToMiniProgram({
appId: 'wx2c28337db96364d2'
})
},
async confirm() {
let { copyArtificerList, orderInfo, artificerSelectObj, selectedTechnicianId } = this.data
let arr = copyArtificerList?.filter(v => v.active) || []
if (!arr.length) {
// return wx.$util.showToast('请选择技师')
// 未选技师 将selectedTechnicianId清除
this.setData({
selectedTechnicianId: ''
})
}
let obj = {
...artificerSelectObj,
technicianUuid: arr[0]?.uuid || '',
technicianId: arr[0]?.id || '',
technicianName: arr[0]?.staffName || ''
}
// orderInfo.technicianUuid = arr[0]?.uuid || ''
// orderInfo.technicianId = arr[0]?.id || ''
// orderInfo.technicianName = arr[0]?.staffName || ''
this.triggerEvent('confirm', obj)
}
}
})