shortAllocation.vue
9.04 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<!-- 短课程配课 -->
<template>
<div class="short-dialog">
<baseDialog class="accountDailog"
:config="config"
:dialog-config="dialogConfig"
:is-show.sync="visible"
@closeDialog="handleClose"
@handleClick="handleConfirm">
<div class="dialog-content">
<el-form ref="formRef"
:model="configData"
:rules="rules">
<el-form-item label="开启课程:" label-width="100px">
<el-switch v-model="configData.openFlag"
active-value="Y"
inactive-value="N">
</el-switch>
</el-form-item>
<h4 class="group-title">
学习条件
</h4>
<div class="rule-item">
<el-form-item label="本周门店渗透率 <"
prop="storePenetrationWeekly">
<el-input v-model="configData.storePenetrationWeekly"
placeholder="请输入"
style="width: 120px"
@blur="validateNumber('storePenetrationWeekly', 30, 90)">
<template #append>
%
</template>
</el-input>
</el-form-item>
<el-form-item label=",且驻店人员上月渗透率 ≤"
prop="storePenetrationMonthly">
<el-input v-model="configData.storePenetrationMonthly"
placeholder="请输入"
style="width: 120px"
@blur="validateNumber('storePenetrationMonthly', 30, 90)">
<template #append>
%
</template>
</el-input>
</el-form-item>
</div>
<div class="rule-item">
<el-form-item label="本周驻店接待记录为战败,且质检分低于"
prop="inspectionScore">
<el-input v-model="configData.inspectionScore"
placeholder="请输入"
style="width: 80px"
@blur="validateNumber('inspectionScore', 30, 100)">
</el-input>
<span class="unit-text">分时,开展为期7天短课程学习</span>
</el-form-item>
</div>
<h4 class="group-title">
学习要求
</h4>
<div class="rule-item">
<el-form-item label="短课程学习需要在课程发布后" prop="finishTime">
<el-input v-model="configData.finishTime"
placeholder="请输入"
style="width: 80px"
@blur="validateNumber('finishTime', 24, 168)">
</el-input>
<span class="unit-text">小时内完成</span>
</el-form-item>
</div>
<div class="rule-item">
<el-form-item label="如果在限时内未完成则">
<el-select v-model="configData.punishType" placeholder="请选择">
<el-option v-for="item in punishTypeOpt"
:key="item.confId"
:label="item.confValue"
:value="item.confId">
</el-option>
</el-select>
</el-form-item>
</div>
<div class="rule-item">
<el-form-item label="生效时间为">
<el-select v-model="configData.effectiveType"
placeholder="请选择">
<el-option v-for="item in effectiveTypeOpt"
:key="item.confId"
:label="item.confValue"
:value="item.confId">
</el-option>
</el-select>
</el-form-item>
</div>
</el-form>
</div>
</baseDialog>
</div>
</template>
<script>
import { getSopConfig, updateSopConfig } from "@api/serviceCentre";
import { effectiveTypeOpt, punishTypeOpt } from "@/common/constants.js";
import { filterSpecsStr } from "../../../goods/filterOption";
export default {
props: {
shortVisible: {
type: Boolean,
default: false,
},
},
data() {
return {
dialogConfig: {
title: "短课程配课",
width: "720px",
},
config: {
showClose: true,
appendToBody: false, // 是否将自身插入至 body 元素,有嵌套的弹窗时一定要设置
isShowFooter: true,
cancel_name: "取 消",
confirm_name: "提 交",
},
punishTypeOpt,
effectiveTypeOpt,
rules: {
storePenetrationWeekly: [
{ required: true, message: "请输入本周门店渗透率", trigger: "blur" },
],
storePenetrationMonthly: [
{ required: true, message: "请输入上月渗透率", trigger: "blur" },
],
inspectionScore: [
{ required: true, message: "请输入质检分", trigger: "blur" },
],
finishTime: [
{ required: true, message: "请输入短课程学习时间", trigger: "blur" },
],
},
configData: {
effectiveType: "",
storePenetrationMonthly: "",
storePenetrationWeekly: "",
punishType: "",
effectiveType: "",
inspectionScore: "",
finishTime: "",
openFlag: "",
},
};
},
computed: {
visible: {
get() {
return this.shortVisible;
},
set(newVal) {
this.$emit("dialogClose", {
flag: newVal,
attrName: "shortVisible",
});
},
},
},
created() {
this.getSopConfigData();
},
methods: {
validateNumber(field, min, max) {
let value = this.configData[field];
value = Number.parseInt(value);
if (isNaN(value))
value = "";
// 限制最大值
if (Number.parseInt(value) > max) {
value = "";
this.$message.warning(`输入值不能超过 ${max}`);
}
if (Number.parseInt(value) < min) {
value = "";
this.$message.warning(`输入值不能小于${min}`);
}
this.$set(this.configData, field, value);
},
getSopConfigData() {
getSopConfig({})
.then((res) => {
console.log(res, "getSopConfig");
this.configData = res;
this.configData.openFlag = this.configData.openFlag == 1 ? "Y" : "N";
})
.catch((err) => {
new Error(err);
});
},
// 提交
handleConfirm() {
this.$refs.formRef.validate((valid, invalidFields) => {
if (valid) {
let params = {
storePenetrationWeekly: this.configData.storePenetrationWeekly,
storePenetrationMonthly: this.configData.storePenetrationMonthly,
inspectionScore: this.configData.inspectionScore,
studyDay: this.configData.studyDay,
punishType: this.configData.punishType,
finishTime: this.configData.finishTime,
effectiveType: this.configData.effectiveType,
openFlag: this.configData.openFlag == "Y" ? 1 : 0,
};
updateSopConfig(params)
.then((res) => {
console.log(res, "updateSopConfig");
this.$message.success("修改成功");
this.handleClose();
})
.catch((err) => {
new Error(err);
});
}
});
},
handleClose() {
this.visible = false;
},
},
};
</script>
<style scoped lang="scss">
.short-dialog {
::v-deep .el-dialog__headerbtn .el-dialog__close {
color: #333333;
font-weight: 600;
font-size: 20px;
}
::v-deep .el-form-item__label {
color: #333333;
font-size: 16px;
}
::v-deep .el-form-item__content {
display: flex;
}
::v-deep .el-divider--horizontal {
margin: 16px 0;
}
::v-deep .el-switch {
margin-top: 8px;
}
::v-deep .el-input-group__append {
padding: 0 10px;
}
.group-title {
color: #111111;
font-size: 16px;
font-weight: 500;
padding: 10px 0;
border-bottom: 1px solid #e5e5e5;
}
.rule-item {
display: flex;
align-items: center;
}
.unit-text {
margin-left: 12px;
font-size: 16px;
}
::v-deep .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label:before {
color: #f5f7fa;
}
::v-deep .el-switch__label,
.el-switch__label.is-active {
color: #333;
}
}
</style>