|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="app-container">
|
|
|
3
|
+ <el-card shadow="never" v-loading="loading">
|
|
|
4
|
+ <div slot="header" class="clearfix">
|
|
|
5
|
+ <span>{{ tsT("pageTitle") }}</span>
|
|
|
6
|
+ </div>
|
|
|
7
|
+ <el-form ref="form" :model="form" label-width="140px" class="tsp-form" size="small">
|
|
|
8
|
+ <div class="tsp-section-title">{{ tsT("sectionEnvoy") }}</div>
|
|
|
9
|
+ <el-form-item prop="envoyMaleCount" :rules="countRule">
|
|
|
10
|
+ <template slot="label">{{ tsT("formEnvoyMale") }}</template>
|
|
|
11
|
+ <div class="dm-input-with-unit">
|
|
|
12
|
+ <el-input-number
|
|
|
13
|
+ v-model="form.envoyMaleCount"
|
|
|
14
|
+ :min="0"
|
|
|
15
|
+ :precision="0"
|
|
|
16
|
+ controls-position="right"
|
|
|
17
|
+ class="dm-input-with-unit__input"
|
|
|
18
|
+ />
|
|
|
19
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
20
|
+ </div>
|
|
|
21
|
+ </el-form-item>
|
|
|
22
|
+ <el-form-item prop="envoyFemaleCount" :rules="countRule">
|
|
|
23
|
+ <template slot="label">{{ tsT("formEnvoyFemale") }}</template>
|
|
|
24
|
+ <div class="dm-input-with-unit">
|
|
|
25
|
+ <el-input-number
|
|
|
26
|
+ v-model="form.envoyFemaleCount"
|
|
|
27
|
+ :min="0"
|
|
|
28
|
+ :precision="0"
|
|
|
29
|
+ controls-position="right"
|
|
|
30
|
+ class="dm-input-with-unit__input"
|
|
|
31
|
+ />
|
|
|
32
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
33
|
+ </div>
|
|
|
34
|
+ </el-form-item>
|
|
|
35
|
+ <el-form-item prop="envoyPartyMemberCount" :rules="countRule">
|
|
|
36
|
+ <template slot="label">{{ tsT("formEnvoyParty") }}</template>
|
|
|
37
|
+ <div class="dm-input-with-unit">
|
|
|
38
|
+ <el-input-number
|
|
|
39
|
+ v-model="form.envoyPartyMemberCount"
|
|
|
40
|
+ :min="0"
|
|
|
41
|
+ :precision="0"
|
|
|
42
|
+ controls-position="right"
|
|
|
43
|
+ class="dm-input-with-unit__input"
|
|
|
44
|
+ />
|
|
|
45
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
46
|
+ </div>
|
|
|
47
|
+ </el-form-item>
|
|
|
48
|
+ <el-form-item>
|
|
|
49
|
+ <template slot="label">{{ tsT("formEnvoyTotal") }}</template>
|
|
|
50
|
+ <div class="dm-input-with-unit">
|
|
|
51
|
+ <el-input :value="envoyTotalDisplay" disabled class="dm-input-with-unit__input" />
|
|
|
52
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
53
|
+ </div>
|
|
|
54
|
+ </el-form-item>
|
|
|
55
|
+
|
|
|
56
|
+ <div class="tsp-section-title">{{ tsT("sectionAgri") }}</div>
|
|
|
57
|
+ <el-form-item prop="agriJuniorCount" :rules="countRule">
|
|
|
58
|
+ <template slot="label">{{ tsT("formAgriJunior") }}</template>
|
|
|
59
|
+ <div class="dm-input-with-unit">
|
|
|
60
|
+ <el-input-number
|
|
|
61
|
+ v-model="form.agriJuniorCount"
|
|
|
62
|
+ :min="0"
|
|
|
63
|
+ :precision="0"
|
|
|
64
|
+ controls-position="right"
|
|
|
65
|
+ class="dm-input-with-unit__input"
|
|
|
66
|
+ />
|
|
|
67
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
68
|
+ </div>
|
|
|
69
|
+ </el-form-item>
|
|
|
70
|
+ <el-form-item prop="agriClerkCount" :rules="countRule">
|
|
|
71
|
+ <template slot="label">{{ tsT("formAgriClerk") }}</template>
|
|
|
72
|
+ <div class="dm-input-with-unit">
|
|
|
73
|
+ <el-input-number
|
|
|
74
|
+ v-model="form.agriClerkCount"
|
|
|
75
|
+ :min="0"
|
|
|
76
|
+ :precision="0"
|
|
|
77
|
+ controls-position="right"
|
|
|
78
|
+ class="dm-input-with-unit__input"
|
|
|
79
|
+ />
|
|
|
80
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
81
|
+ </div>
|
|
|
82
|
+ </el-form-item>
|
|
|
83
|
+ <el-form-item prop="agriIntermediateCount" :rules="countRule">
|
|
|
84
|
+ <template slot="label">{{ tsT("formAgriIntermediate") }}</template>
|
|
|
85
|
+ <div class="dm-input-with-unit">
|
|
|
86
|
+ <el-input-number
|
|
|
87
|
+ v-model="form.agriIntermediateCount"
|
|
|
88
|
+ :min="0"
|
|
|
89
|
+ :precision="0"
|
|
|
90
|
+ controls-position="right"
|
|
|
91
|
+ class="dm-input-with-unit__input"
|
|
|
92
|
+ />
|
|
|
93
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
94
|
+ </div>
|
|
|
95
|
+ </el-form-item>
|
|
|
96
|
+ <el-form-item prop="agriAssociateSeniorCount" :rules="countRule">
|
|
|
97
|
+ <template slot="label">{{ tsT("formAgriAssociateSenior") }}</template>
|
|
|
98
|
+ <div class="dm-input-with-unit">
|
|
|
99
|
+ <el-input-number
|
|
|
100
|
+ v-model="form.agriAssociateSeniorCount"
|
|
|
101
|
+ :min="0"
|
|
|
102
|
+ :precision="0"
|
|
|
103
|
+ controls-position="right"
|
|
|
104
|
+ class="dm-input-with-unit__input"
|
|
|
105
|
+ />
|
|
|
106
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
107
|
+ </div>
|
|
|
108
|
+ </el-form-item>
|
|
|
109
|
+ <el-form-item prop="agriManagementCount" :rules="countRule">
|
|
|
110
|
+ <template slot="label">{{ tsT("formAgriManagement") }}</template>
|
|
|
111
|
+ <div class="dm-input-with-unit">
|
|
|
112
|
+ <el-input-number
|
|
|
113
|
+ v-model="form.agriManagementCount"
|
|
|
114
|
+ :min="0"
|
|
|
115
|
+ :precision="0"
|
|
|
116
|
+ controls-position="right"
|
|
|
117
|
+ class="dm-input-with-unit__input"
|
|
|
118
|
+ />
|
|
|
119
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
120
|
+ </div>
|
|
|
121
|
+ </el-form-item>
|
|
|
122
|
+ <el-form-item>
|
|
|
123
|
+ <template slot="label">{{ tsT("formAgriTotal") }}</template>
|
|
|
124
|
+ <div class="dm-input-with-unit">
|
|
|
125
|
+ <el-input :value="agriTotalDisplay" disabled class="dm-input-with-unit__input" />
|
|
|
126
|
+ <span class="dm-input-with-unit__suffix">{{ tsT("unitPerson") }}</span>
|
|
|
127
|
+ </div>
|
|
|
128
|
+ </el-form-item>
|
|
|
129
|
+
|
|
|
130
|
+ <el-form-item v-if="meta.updateTime">
|
|
|
131
|
+ <span class="tsp-meta">{{ tsT("viewUpdateBy") }}:{{ meta.updateBy || dash }}</span>
|
|
|
132
|
+ <span class="tsp-meta">{{ tsT("viewUpdateTime") }}:{{ meta.updateTime ? parseTime(meta.updateTime) : dash }}</span>
|
|
|
133
|
+ </el-form-item>
|
|
|
134
|
+ <el-form-item>
|
|
|
135
|
+ <el-button
|
|
|
136
|
+ v-hasPermi="['techService:techServicePersonnel:edit']"
|
|
|
137
|
+ type="primary"
|
|
|
138
|
+ @click="submitForm"
|
|
|
139
|
+ >{{ tsT("btnSave") }}</el-button>
|
|
|
140
|
+ </el-form-item>
|
|
|
141
|
+ </el-form>
|
|
|
142
|
+ </el-card>
|
|
|
143
|
+ </div>
|
|
|
144
|
+</template>
|
|
|
145
|
+
|
|
|
146
|
+<script>
|
|
|
147
|
+import techServiceLocaleMixin from "@/mixins/techServiceLocaleMixin"
|
|
|
148
|
+import { getTechServicePersonnel, updateTechServicePersonnel } from "@/api/techService/techServicePersonnel"
|
|
|
149
|
+
|
|
|
150
|
+const ENVOY_SUM_KEYS = ["envoyMaleCount", "envoyFemaleCount"]
|
|
|
151
|
+const AGRI_SUM_KEYS = [
|
|
|
152
|
+ "agriJuniorCount",
|
|
|
153
|
+ "agriClerkCount",
|
|
|
154
|
+ "agriIntermediateCount",
|
|
|
155
|
+ "agriAssociateSeniorCount",
|
|
|
156
|
+ "agriManagementCount"
|
|
|
157
|
+]
|
|
|
158
|
+const EDITABLE_KEYS = [
|
|
|
159
|
+ "envoyMaleCount",
|
|
|
160
|
+ "envoyFemaleCount",
|
|
|
161
|
+ "envoyPartyMemberCount",
|
|
|
162
|
+ "agriJuniorCount",
|
|
|
163
|
+ "agriClerkCount",
|
|
|
164
|
+ "agriIntermediateCount",
|
|
|
165
|
+ "agriAssociateSeniorCount",
|
|
|
166
|
+ "agriManagementCount"
|
|
|
167
|
+]
|
|
|
168
|
+
|
|
|
169
|
+function sumNullable(values) {
|
|
|
170
|
+ let any = false
|
|
|
171
|
+ let sum = 0
|
|
|
172
|
+ values.forEach((v) => {
|
|
|
173
|
+ if (v != null && v !== "") {
|
|
|
174
|
+ const n = Number(v)
|
|
|
175
|
+ if (Number.isFinite(n)) {
|
|
|
176
|
+ any = true
|
|
|
177
|
+ sum += n
|
|
|
178
|
+ }
|
|
|
179
|
+ }
|
|
|
180
|
+ })
|
|
|
181
|
+ return any ? sum : null
|
|
|
182
|
+}
|
|
|
183
|
+
|
|
|
184
|
+export default {
|
|
|
185
|
+ name: "TechServicePersonnel",
|
|
|
186
|
+ mixins: [techServiceLocaleMixin],
|
|
|
187
|
+ data() {
|
|
|
188
|
+ return {
|
|
|
189
|
+ tsNs: "techServicePersonnel",
|
|
|
190
|
+ loading: false,
|
|
|
191
|
+ meta: {
|
|
|
192
|
+ updateBy: undefined,
|
|
|
193
|
+ updateTime: undefined
|
|
|
194
|
+ },
|
|
|
195
|
+ form: this.defaultForm()
|
|
|
196
|
+ }
|
|
|
197
|
+ },
|
|
|
198
|
+ computed: {
|
|
|
199
|
+ dash() {
|
|
|
200
|
+ return this.$t("techService.status.dash")
|
|
|
201
|
+ },
|
|
|
202
|
+ countRule() {
|
|
|
203
|
+ return [{ validator: this.validateOptionalCount, trigger: "change" }]
|
|
|
204
|
+ },
|
|
|
205
|
+ envoyTotalDisplay() {
|
|
|
206
|
+ const sum = sumNullable(ENVOY_SUM_KEYS.map((k) => this.form[k]))
|
|
|
207
|
+ return sum == null ? this.dash : String(sum)
|
|
|
208
|
+ },
|
|
|
209
|
+ agriTotalDisplay() {
|
|
|
210
|
+ const sum = sumNullable(AGRI_SUM_KEYS.map((k) => this.form[k]))
|
|
|
211
|
+ return sum == null ? this.dash : String(sum)
|
|
|
212
|
+ }
|
|
|
213
|
+ },
|
|
|
214
|
+ created() {
|
|
|
215
|
+ this.loadConfig()
|
|
|
216
|
+ },
|
|
|
217
|
+ methods: {
|
|
|
218
|
+ defaultForm() {
|
|
|
219
|
+ const form = {}
|
|
|
220
|
+ EDITABLE_KEYS.forEach((key) => {
|
|
|
221
|
+ form[key] = undefined
|
|
|
222
|
+ })
|
|
|
223
|
+ return form
|
|
|
224
|
+ },
|
|
|
225
|
+ validateOptionalCount(rule, value, callback) {
|
|
|
226
|
+ if (value == null || value === "") {
|
|
|
227
|
+ callback()
|
|
|
228
|
+ return
|
|
|
229
|
+ }
|
|
|
230
|
+ if (typeof value !== "number" || Number.isNaN(value) || value < 0 || !Number.isInteger(value)) {
|
|
|
231
|
+ callback(new Error(this.tsT("ruleCountNonNegative")))
|
|
|
232
|
+ return
|
|
|
233
|
+ }
|
|
|
234
|
+ callback()
|
|
|
235
|
+ },
|
|
|
236
|
+ normalizeCount(val) {
|
|
|
237
|
+ if (val == null || val === "") {
|
|
|
238
|
+ return undefined
|
|
|
239
|
+ }
|
|
|
240
|
+ const n = Number(val)
|
|
|
241
|
+ return Number.isFinite(n) ? n : undefined
|
|
|
242
|
+ },
|
|
|
243
|
+ applyData(data) {
|
|
|
244
|
+ if (!data) {
|
|
|
245
|
+ this.form = this.defaultForm()
|
|
|
246
|
+ this.meta = { updateBy: undefined, updateTime: undefined }
|
|
|
247
|
+ return
|
|
|
248
|
+ }
|
|
|
249
|
+ const form = this.defaultForm()
|
|
|
250
|
+ EDITABLE_KEYS.forEach((key) => {
|
|
|
251
|
+ form[key] = this.normalizeCount(data[key])
|
|
|
252
|
+ })
|
|
|
253
|
+ this.form = form
|
|
|
254
|
+ this.meta = {
|
|
|
255
|
+ updateBy: data.updateBy,
|
|
|
256
|
+ updateTime: data.updateTime
|
|
|
257
|
+ }
|
|
|
258
|
+ },
|
|
|
259
|
+ loadConfig() {
|
|
|
260
|
+ this.loading = true
|
|
|
261
|
+ getTechServicePersonnel()
|
|
|
262
|
+ .then((res) => {
|
|
|
263
|
+ this.applyData(res.data)
|
|
|
264
|
+ })
|
|
|
265
|
+ .catch(() => {
|
|
|
266
|
+ this.applyData(null)
|
|
|
267
|
+ })
|
|
|
268
|
+ .finally(() => {
|
|
|
269
|
+ this.loading = false
|
|
|
270
|
+ })
|
|
|
271
|
+ },
|
|
|
272
|
+ buildPayload() {
|
|
|
273
|
+ const payload = {}
|
|
|
274
|
+ EDITABLE_KEYS.forEach((key) => {
|
|
|
275
|
+ const val = this.form[key]
|
|
|
276
|
+ payload[key] = val == null || val === "" ? null : val
|
|
|
277
|
+ })
|
|
|
278
|
+ return payload
|
|
|
279
|
+ },
|
|
|
280
|
+ submitForm() {
|
|
|
281
|
+ this.$refs.form.validate((valid) => {
|
|
|
282
|
+ if (!valid) {
|
|
|
283
|
+ return
|
|
|
284
|
+ }
|
|
|
285
|
+ updateTechServicePersonnel(this.buildPayload()).then(() => {
|
|
|
286
|
+ this.$modal.msgSuccess(this.tsCommon("msgModOk"))
|
|
|
287
|
+ this.loadConfig()
|
|
|
288
|
+ })
|
|
|
289
|
+ })
|
|
|
290
|
+ }
|
|
|
291
|
+ }
|
|
|
292
|
+}
|
|
|
293
|
+</script>
|
|
|
294
|
+
|
|
|
295
|
+<style scoped>
|
|
|
296
|
+.tsp-form {
|
|
|
297
|
+ max-width: 560px;
|
|
|
298
|
+}
|
|
|
299
|
+.tsp-section-title {
|
|
|
300
|
+ margin: 4px 0 16px;
|
|
|
301
|
+ font-weight: 600;
|
|
|
302
|
+ color: #303133;
|
|
|
303
|
+}
|
|
|
304
|
+.tsp-meta {
|
|
|
305
|
+ display: block;
|
|
|
306
|
+ color: #909399;
|
|
|
307
|
+ font-size: 13px;
|
|
|
308
|
+ line-height: 1.8;
|
|
|
309
|
+}
|
|
|
310
|
+.dm-input-with-unit {
|
|
|
311
|
+ display: flex;
|
|
|
312
|
+ align-items: center;
|
|
|
313
|
+ width: 100%;
|
|
|
314
|
+ max-width: 320px;
|
|
|
315
|
+}
|
|
|
316
|
+.dm-input-with-unit__input {
|
|
|
317
|
+ flex: 1;
|
|
|
318
|
+ width: 100%;
|
|
|
319
|
+}
|
|
|
320
|
+.dm-input-with-unit__suffix {
|
|
|
321
|
+ margin-left: 8px;
|
|
|
322
|
+ color: #909399;
|
|
|
323
|
+ white-space: nowrap;
|
|
|
324
|
+}
|
|
|
325
|
+.dm-input-with-unit >>> .el-input-number {
|
|
|
326
|
+ width: 100%;
|
|
|
327
|
+}
|
|
|
328
|
+</style>
|