index.js
4.71 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
184
185
186
187
188
189
190
191
192
193
// tabWorkOrder/pages/residentManage/components/addStaff/index.js
import api from '../../api'
let toastList = {
staffName: "员工姓名不能为空",
staffPhone: "手机号不能为空",
staffSceneLabel: "所属业务不能为空",
merchantId: "归属门店不能为空",
yqMerchantId: '关联账号不能为空'
};
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
isBusiness: false,
shopMerchantBox: false,
yqMerchartBox: false,
cellHeight: false,
cellStyle: "min-height:52px",
cellBoxStyle: ' border-radius: 0 0 16rpx 16rpx',
requiredList: [],
yqMerchartList: [],
staffObj: {
staffName: '',
staffPhone: '',
staffSceneLabel: '', //所属业务(1.轻改,0.权益+延保
staffSceneLabelText: '',
merchantId: '', //归属门店id
merchantName: '', //归属门店名称
yqMerchantId: '', //园区店id
yqMerchantName: '', //园区店名称
}
},
/**
* 组件的方法列表
*/
methods: {
showPopup(e) {
let {
showName
} = e.currentTarget.dataset, {
staffObj: {
staffSceneLabel,
merchantId,
},
yqMerchartList
} = this.data;
if (showName == 'shopMerchantBox' && staffSceneLabel == '') {
wx.$util.showToast(`请先选择所属业务`);
return
}
if (showName == 'yqMerchartBox' && merchantId == '') {
wx.$util.showToast(`请先选择归属门店`);
return
}
if (showName == 'yqMerchartBox' && yqMerchartList.length <= 1) {
return
}
this.setData({
[showName]: true
});
},
getyqMerchantList() {
let {
staffSceneLabel,
merchantId
} = this.data.staffObj
let params = {
sceneLabel: staffSceneLabel,
merchantId
}
try {
api.getyqMerchantList(params).then(res => {
if (res.code == 0) {
let item = res.data.list.length ? res.data.list[0] : ''
this.setData({
yqMerchartList: res.data.list,
'staffObj.yqMerchantId': item ? item.yqMerchantId : '',
'staffObj.yqMerchantName': item ? item.yqMerchantName : ''
})
}
})
} catch (err) {
}
},
selectChoose(e) {
let {
chooseList,
text,
key
} = e.detail
let textArr = [],
idArr = [];
chooseList.forEach(item => {
textArr.push(item.text)
idArr.push(item.id)
})
this.setData({
[text]: textArr.join(','),
[key]: idArr.join(','),
'staffObj.yqMerchantId': '',
'staffObj.yqMerchantName': '',
'staffObj.merchantId': '',
'staffObj.merchantName': '',
yqMerchartList: []
})
},
async submit(i) {
let _this = this;
let {
staffObj
} = this.data;
let thisPage = wx.$router.getPageInstance()
let key = thisPage.checkRequired(staffObj);
if (key) {
toastList[key] && wx.$util.showToast(toastList[key]);
return;
}
wx.$util.showLoading("加载中...")
let apiName =
"createStaffAccount",
params = {
...staffObj
};
delete params.staffSceneLabelText
api[apiName](params)
.then((res) => {
let {
code,
data,
message
} = res;
if (code == 0) {
wx.hideLoading();
wx.showModal({
title: "温馨提示",
content: "保存成功",
showCancel: false,
confirmText: "知道了",
confirmColor: "#347BFF",
success(_res_) {
if (_res_.confirm) {
// let clearData={
// staffName: '',
// staffPhone: '',
// staffSceneLabel: '',
// staffSceneLabelText: '',
// merchantId: '',
// merchantName: '',
// yqMerchantId: '',
// yqMerchantName: ''
// }
// _this.setData({
// staffObj: clearData
// }
// )
thisPage.setData({
activeIndex: 1
})
}
},
});
} else {
wx.$util.showToast(message);
}
})
},
input(e) {
let {
value
} = e.detail;
let {
name
} = e.currentTarget.dataset;
this.setData({
[`${name}`]: value.trim(),
});
},
}
})