|
@@ -19,8 +19,8 @@ |
|
@@ -19,8 +19,8 @@ |
|
19
|
</uni-list-item>
|
19
|
</uni-list-item>
|
|
20
|
|
20
|
|
|
21
|
<!-- 客户名称 关联页选择 -->
|
21
|
<!-- 客户名称 关联页选择 -->
|
|
22
|
- <uni-list-item class="select-item" :class="form.customerId ? 'is-filled' : 'is-empty'" clickable @click="openRelate('customerId')" :rightText="form.customerIdName || '请选择客户名称'"
|
|
|
|
23
|
- showArrow>
|
22
|
+ <uni-list-item class="select-item" :class="form.customerId ? 'is-filled' : 'is-empty'" clickable
|
|
|
|
23
|
+ @click="openRelate('customerId')" :rightText="form.customerIdName || '请选择客户名称'" showArrow>
|
|
24
|
<template v-slot:body>
|
24
|
<template v-slot:body>
|
|
25
|
<view class="item-title"><text class="required">*</text><text>客户名称</text></view>
|
25
|
<view class="item-title"><text class="required">*</text><text>客户名称</text></view>
|
|
26
|
</template>
|
26
|
</template>
|
|
@@ -98,7 +98,8 @@ |
|
@@ -98,7 +98,8 @@ |
|
98
|
</uni-list-item>
|
98
|
</uni-list-item>
|
|
99
|
<!-- 责任人 关联页选择 -->
|
99
|
<!-- 责任人 关联页选择 -->
|
|
100
|
<uni-list-item class="select-item" :class="form.chargeUserIdName ? 'is-filled' : 'is-empty'" title="责任人"
|
100
|
<uni-list-item class="select-item" :class="form.chargeUserIdName ? 'is-filled' : 'is-empty'" title="责任人"
|
|
101
|
- clickable @click="openRelate('chargeUserId')" :rightText="form.chargeUserIdName || '请选择责任人'" showArrow />
|
101
|
+ clickable @click="openRelate('chargeUserId')" :rightText="form.chargeUserIdName || '请选择责任人'"
|
|
|
|
102
|
+ showArrow />
|
|
102
|
</uni-list>
|
103
|
</uni-list>
|
|
103
|
|
104
|
|
|
104
|
</scroll-view>
|
105
|
</scroll-view>
|
|
@@ -114,435 +115,441 @@ |
|
@@ -114,435 +115,441 @@ |
|
114
|
<!-- 关联选择弹框:客户名称、责任人 -->
|
115
|
<!-- 关联选择弹框:客户名称、责任人 -->
|
|
115
|
<RelateSelectSheet :visible.sync="relate.visible" :title="relate.title" :source="relate.source"
|
116
|
<RelateSelectSheet :visible.sync="relate.visible" :title="relate.title" :source="relate.source"
|
|
116
|
:display-fields="relate.display" :multiple="relate.multiple" :row-key="relate.rowKey"
|
117
|
:display-fields="relate.display" :multiple="relate.multiple" :row-key="relate.rowKey"
|
|
117
|
- :selectedKeys.sync="relate.selectedKeys" :source-extra="{ source: 'CUSTOMER_DEVELOP' }" @confirm="onRelateConfirm" />
|
118
|
+ :selectedKeys.sync="relate.selectedKeys" :source-extra="{ source: 'CUSTOMER_DEVELOP' }"
|
|
|
|
119
|
+ @confirm="onRelateConfirm" />
|
|
118
|
</view>
|
120
|
</view>
|
|
119
|
</template>
|
121
|
</template>
|
|
120
|
|
122
|
|
|
121
|
<script>
|
123
|
<script>
|
|
122
|
- import SingleSelectSheet from '@/components/single-select/index.vue'
|
|
|
|
123
|
- import RelateSelectSheet from '@/components/relate-select/index.vue'
|
|
|
|
124
|
- import constant from '@/utils/constant'
|
|
|
|
125
|
- import storage from '@/utils/storage'
|
|
|
|
126
|
- import {
|
|
|
|
127
|
- createApi,
|
|
|
|
128
|
- officeQueryApi,
|
|
|
|
129
|
- productVarietyQueryApi,
|
|
|
|
130
|
- workshopQueryApi
|
|
|
|
131
|
- } from '@/api/devManage.js'
|
|
|
|
132
|
- import {
|
|
|
|
133
|
- getDicByCodeApi
|
|
|
|
134
|
- } from '@/api/base.js'
|
124
|
+import SingleSelectSheet from '@/components/single-select/index.vue'
|
|
|
|
125
|
+import RelateSelectSheet from '@/components/relate-select/index.vue'
|
|
|
|
126
|
+import constant from '@/utils/constant'
|
|
|
|
127
|
+import storage from '@/utils/storage'
|
|
|
|
128
|
+import {
|
|
|
|
129
|
+ createApi,
|
|
|
|
130
|
+ officeQueryApi,
|
|
|
|
131
|
+ productVarietyQueryApi,
|
|
|
|
132
|
+ workshopQueryApi
|
|
|
|
133
|
+} from '@/api/devManage.js'
|
|
|
|
134
|
+import {
|
|
|
|
135
|
+ getDicByCodeApi
|
|
|
|
136
|
+} from '@/api/base.js'
|
|
135
|
|
137
|
|
|
136
|
- export default {
|
|
|
|
137
|
- name: 'DevManageAdd',
|
|
|
|
138
|
- components: {
|
|
|
|
139
|
- SingleSelectSheet,
|
|
|
|
140
|
- RelateSelectSheet
|
|
|
|
141
|
- },
|
|
|
|
142
|
- data() {
|
|
|
|
143
|
- return {
|
|
|
|
144
|
- form: {
|
|
|
|
145
|
- workshopIdName: '',
|
|
|
|
146
|
- workshopId: '',
|
|
|
|
147
|
- officeIdName: '',
|
|
|
|
148
|
- officeId: '',
|
|
|
|
149
|
- customerIdName: '',
|
|
|
|
150
|
- customerId: '',
|
|
|
|
151
|
- customerType: '',
|
|
|
|
152
|
- customerTypeName: '',
|
|
|
|
153
|
- chargeUserId: '',
|
|
|
|
154
|
- chargeUserIdName: '',
|
|
|
|
155
|
- productVarietyId: '',
|
|
|
|
156
|
- productVarietyIdName: '',
|
|
|
|
157
|
- monthlyUsage: '',
|
|
|
|
158
|
- targetQuantity: '',
|
|
|
|
159
|
- industry: '',
|
|
|
|
160
|
- mark: '',
|
|
|
|
161
|
- thickness: '',
|
|
|
|
162
|
- width: '',
|
|
|
|
163
|
- materialRequire: '',
|
|
|
|
164
|
- qualityRequire: '',
|
|
|
|
165
|
- peer: '',
|
|
|
|
166
|
- pricingMode: '',
|
|
|
|
167
|
- settleDays: '',
|
|
|
|
168
|
- },
|
|
|
|
169
|
- sheet: {
|
|
|
|
170
|
- visible: false,
|
|
|
|
171
|
- title: '请选择',
|
|
|
|
172
|
- field: '',
|
|
|
|
173
|
- options: [],
|
|
|
|
174
|
- value: ''
|
|
|
|
175
|
- },
|
|
|
|
176
|
- relate: {
|
|
|
|
177
|
- visible: false,
|
|
|
|
178
|
- title: '选择',
|
|
|
|
179
|
- source: '',
|
|
|
|
180
|
- display: [],
|
|
|
|
181
|
- multiple: false,
|
|
|
|
182
|
- rowKey: 'id',
|
|
|
|
183
|
- selectedKeys: []
|
|
|
|
184
|
- },
|
|
|
|
185
|
- officeOptions: [],
|
|
|
|
186
|
- customerTypeOptions: [],
|
|
|
|
187
|
- productVarietyIdOptions: []
|
|
|
|
188
|
- }
|
|
|
|
189
|
- },
|
|
|
|
190
|
- created() {
|
|
|
|
191
|
- // 责任人默认使用当前用户昵称/用户名
|
|
|
|
192
|
- const user = storage.get(constant.name);
|
|
|
|
193
|
- const userId = storage.get(constant.id);
|
|
|
|
194
|
- this.form.chargeUserIdName = user || '';
|
|
|
|
195
|
- this.form.chargeUserId = userId || '';
|
|
|
|
196
|
- // 科办
|
|
|
|
197
|
- this.loadOfficeOptions()
|
|
|
|
198
|
- // 客户类型
|
|
|
|
199
|
- this.loadCustomerTypeOptions()
|
|
|
|
200
|
- // 生产厂
|
|
|
|
201
|
- this.loadproductVarietyIdOptions()
|
|
|
|
202
|
- },
|
|
|
|
203
|
- methods: {
|
|
|
|
204
|
- // 校验必填项:生产厂、科办、客户名称、客户类型、产品品种
|
|
|
|
205
|
- validateRequired() {
|
|
|
|
206
|
- const checks = [{
|
|
|
|
207
|
- key: 'workshopId',
|
|
|
|
208
|
- label: '生产厂'
|
|
|
|
209
|
- },
|
|
|
|
210
|
- {
|
|
|
|
211
|
- key: 'officeId',
|
|
|
|
212
|
- label: '科办'
|
|
|
|
213
|
- },
|
|
|
|
214
|
- {
|
|
|
|
215
|
- key: 'customerId',
|
|
|
|
216
|
- label: '客户名称'
|
|
|
|
217
|
- },
|
|
|
|
218
|
- {
|
|
|
|
219
|
- key: 'customerType',
|
|
|
|
220
|
- label: '客户类型'
|
|
|
|
221
|
- },
|
|
|
|
222
|
- {
|
|
|
|
223
|
- key: 'productVarietyId',
|
|
|
|
224
|
- label: '产品品种'
|
|
|
|
225
|
- }
|
|
|
|
226
|
- ]
|
|
|
|
227
|
- for (const it of checks) {
|
|
|
|
228
|
- const val = this.form[it.key]
|
|
|
|
229
|
- if (val === undefined || val === null || String(val).trim() === '') {
|
|
|
|
230
|
- uni.showToast({
|
|
|
|
231
|
- title: `请先选择${it.label}`,
|
|
|
|
232
|
- icon: 'none'
|
|
|
|
233
|
- })
|
|
|
|
234
|
- return false
|
|
|
|
235
|
- }
|
|
|
|
236
|
- }
|
|
|
|
237
|
- return true
|
138
|
+export default {
|
|
|
|
139
|
+ name: 'DevManageAdd',
|
|
|
|
140
|
+ components: {
|
|
|
|
141
|
+ SingleSelectSheet,
|
|
|
|
142
|
+ RelateSelectSheet
|
|
|
|
143
|
+ },
|
|
|
|
144
|
+ data() {
|
|
|
|
145
|
+ return {
|
|
|
|
146
|
+ form: {
|
|
|
|
147
|
+ workshopIdName: '',
|
|
|
|
148
|
+ workshopId: '',
|
|
|
|
149
|
+ officeIdName: '',
|
|
|
|
150
|
+ officeId: '',
|
|
|
|
151
|
+ customerIdName: '',
|
|
|
|
152
|
+ customerId: '',
|
|
|
|
153
|
+ customerType: '',
|
|
|
|
154
|
+ customerTypeName: '',
|
|
|
|
155
|
+ chargeUserId: '',
|
|
|
|
156
|
+ chargeUserIdName: '',
|
|
|
|
157
|
+ productVarietyId: '',
|
|
|
|
158
|
+ productVarietyIdName: '',
|
|
|
|
159
|
+ monthlyUsage: '',
|
|
|
|
160
|
+ targetQuantity: '',
|
|
|
|
161
|
+ industry: '',
|
|
|
|
162
|
+ mark: '',
|
|
|
|
163
|
+ thickness: '',
|
|
|
|
164
|
+ width: '',
|
|
|
|
165
|
+ materialRequire: '',
|
|
|
|
166
|
+ qualityRequire: '',
|
|
|
|
167
|
+ peer: '',
|
|
|
|
168
|
+ pricingMode: '',
|
|
|
|
169
|
+ settleDays: '',
|
|
238
|
},
|
170
|
},
|
|
239
|
- async loadOfficeOptions() {
|
|
|
|
240
|
- try {
|
|
|
|
241
|
- const res = await officeQueryApi({
|
|
|
|
242
|
- pageIndex: 1,
|
|
|
|
243
|
- pageSize: 9999
|
|
|
|
244
|
- })
|
|
|
|
245
|
- const _data = res.data || {}
|
|
|
|
246
|
- const list = _data.datas || []
|
|
|
|
247
|
- this.officeOptions = (list || []).map(it => ({
|
|
|
|
248
|
- label: it.name || it.text || it.officeName || it.label,
|
|
|
|
249
|
- value: it.id || it.code || it.value
|
|
|
|
250
|
- }))
|
|
|
|
251
|
- } catch (e) {
|
|
|
|
252
|
- this.officeOptions = []
|
|
|
|
253
|
- }
|
171
|
+ sheet: {
|
|
|
|
172
|
+ visible: false,
|
|
|
|
173
|
+ title: '请选择',
|
|
|
|
174
|
+ field: '',
|
|
|
|
175
|
+ options: [],
|
|
|
|
176
|
+ value: ''
|
|
254
|
},
|
177
|
},
|
|
255
|
- displayLabel(field) {
|
|
|
|
256
|
- const m = this.form
|
|
|
|
257
|
- const map = {
|
|
|
|
258
|
- workshopIdName: '请选择生产厂',
|
|
|
|
259
|
- officeIdName: '请选择科办',
|
|
|
|
260
|
- customerTypeName: '请选择客户类型',
|
|
|
|
261
|
- productVarietyIdName: '请选择产品品种'
|
|
|
|
262
|
- }
|
|
|
|
263
|
- const val = m[field]
|
|
|
|
264
|
- return val ? String(val) : map[field]
|
178
|
+ relate: {
|
|
|
|
179
|
+ visible: false,
|
|
|
|
180
|
+ title: '选择',
|
|
|
|
181
|
+ source: '',
|
|
|
|
182
|
+ display: [],
|
|
|
|
183
|
+ multiple: false,
|
|
|
|
184
|
+ rowKey: 'id',
|
|
|
|
185
|
+ selectedKeys: []
|
|
265
|
},
|
186
|
},
|
|
266
|
- async openSheet(field) {
|
|
|
|
267
|
- const setSheet = (title, options) => {
|
|
|
|
268
|
- const current = this.form[field]
|
|
|
|
269
|
- const match = (options || []).find(o => String(o.label) === String(current) || String(o.value) === String(current))
|
|
|
|
270
|
- this.sheet = {
|
|
|
|
271
|
- ...this.sheet,
|
|
|
|
272
|
- visible: true,
|
|
|
|
273
|
- title,
|
|
|
|
274
|
- options,
|
|
|
|
275
|
- field,
|
|
|
|
276
|
- value: match ? match.value : ''
|
|
|
|
277
|
- }
|
|
|
|
278
|
- }
|
|
|
|
279
|
- if (field === 'workshopId') {
|
|
|
|
280
|
- const res = await workshopQueryApi({ pageIndex: 1, pageSize: 9999 })
|
|
|
|
281
|
- const _data = res.data || {}
|
|
|
|
282
|
- const list = _data.datas || (Array.isArray(_data) ? _data : [])
|
|
|
|
283
|
- const opts = (list || []).map(it => ({
|
|
|
|
284
|
- label: it.name ,
|
|
|
|
285
|
- value: it.id
|
|
|
|
286
|
- }))
|
|
|
|
287
|
- setSheet('生产厂', opts)
|
|
|
|
288
|
- } else if (field === 'officeId') {
|
|
|
|
289
|
- setSheet('科办', this.officeOptions)
|
|
|
|
290
|
- } else if (field === 'customerType') {
|
|
|
|
291
|
- const opts = this.customerTypeOptions || [];
|
|
|
|
292
|
- setSheet('客户类型', opts)
|
|
|
|
293
|
- } else if (field === 'productVarietyId') {
|
|
|
|
294
|
- const opts = this.productVarietyIdOptions;
|
|
|
|
295
|
- setSheet('产品品种', opts)
|
|
|
|
296
|
- }
|
|
|
|
297
|
- },
|
|
|
|
298
|
- onSheetConfirm({
|
|
|
|
299
|
- value,
|
|
|
|
300
|
- label
|
|
|
|
301
|
- }) {
|
|
|
|
302
|
- const field = this.sheet.field
|
|
|
|
303
|
- if (!field) return
|
|
|
|
304
|
- this.form[field] = value || '';
|
|
|
|
305
|
- this.form[field + 'Name'] = label || ''
|
|
|
|
306
|
- this.sheet.visible = false
|
|
|
|
307
|
- },
|
|
|
|
308
|
- openRelate(fieldKey) {
|
|
|
|
309
|
- let config = {};
|
|
|
|
310
|
- switch(fieldKey) {
|
|
|
|
311
|
- case 'customerId':
|
|
|
|
312
|
- config = {
|
|
|
|
313
|
- title: '客户名称',
|
|
|
|
314
|
- source: 'customer',
|
|
|
|
315
|
- rowKey: 'id',
|
|
|
|
316
|
- multiple: false,
|
|
|
|
317
|
- display: [{
|
|
|
|
318
|
- label: '名称',
|
|
|
|
319
|
- field: 'name'
|
|
|
|
320
|
- },
|
|
|
|
321
|
- {
|
|
|
|
322
|
- label: '编号',
|
|
|
|
323
|
- field: 'code'
|
|
|
|
324
|
- },
|
|
|
|
325
|
- {
|
|
|
|
326
|
- label: '状态',
|
|
|
|
327
|
- field: 'available',
|
|
|
|
328
|
- format: v => (v ? '启用' : '停用')
|
|
|
|
329
|
- }
|
|
|
|
330
|
- ]
|
|
|
|
331
|
- }
|
|
|
|
332
|
- break
|
|
|
|
333
|
- case 'chargeUserId':
|
|
|
|
334
|
- config = {
|
|
|
|
335
|
- title: '责任人',
|
|
|
|
336
|
- source: 'user',
|
|
|
|
337
|
- rowKey: 'id',
|
|
|
|
338
|
- multiple: false,
|
|
|
|
339
|
- display: [{
|
|
|
|
340
|
- label: '姓名',
|
|
|
|
341
|
- field: 'name'
|
|
|
|
342
|
- },
|
|
|
|
343
|
- {
|
|
|
|
344
|
- label: '编号',
|
|
|
|
345
|
- field: 'code'
|
|
|
|
346
|
- },
|
|
|
|
347
|
- {
|
|
|
|
348
|
- label: '状态',
|
|
|
|
349
|
- field: 'available',
|
|
|
|
350
|
- format: v => (v ? '启用' : '停用')
|
|
|
|
351
|
- }
|
|
|
|
352
|
- ]};
|
|
|
|
353
|
- break
|
|
|
|
354
|
- }
|
|
|
|
355
|
- const selectedKeys = this.form[fieldKey] ? [this.form[fieldKey]] : [];
|
|
|
|
356
|
- // 逐一赋值,避免整体替换对象导致子组件 prop 更新不及时
|
|
|
|
357
|
- this.sheet.visible = false
|
|
|
|
358
|
- this.relate.title = config.title
|
|
|
|
359
|
- this.relate.source = config.source
|
|
|
|
360
|
- this.relate.display = config.display
|
|
|
|
361
|
- this.relate.multiple = config.multiple
|
|
|
|
362
|
- this.relate.rowKey = config.rowKey
|
|
|
|
363
|
- this.relate.selectedKeys = selectedKeys
|
|
|
|
364
|
- this.relate.fieldKey = fieldKey;
|
|
|
|
365
|
- // 最后再打开弹框,确保选中键已传入
|
|
|
|
366
|
- this.$nextTick(() => {
|
|
|
|
367
|
- this.relate.visible = true
|
|
|
|
368
|
- })
|
187
|
+ officeOptions: [],
|
|
|
|
188
|
+ customerTypeOptions: [],
|
|
|
|
189
|
+ productVarietyIdOptions: []
|
|
|
|
190
|
+ }
|
|
|
|
191
|
+ },
|
|
|
|
192
|
+ created() {
|
|
|
|
193
|
+ // 责任人默认使用当前用户昵称/用户名
|
|
|
|
194
|
+ const user = storage.get(constant.name);
|
|
|
|
195
|
+ const userId = storage.get(constant.id);
|
|
|
|
196
|
+ this.form.chargeUserIdName = user || '';
|
|
|
|
197
|
+ this.form.chargeUserId = userId || '';
|
|
|
|
198
|
+ // 科办
|
|
|
|
199
|
+ this.loadOfficeOptions()
|
|
|
|
200
|
+ // 客户类型
|
|
|
|
201
|
+ this.loadCustomerTypeOptions()
|
|
|
|
202
|
+ // 生产厂
|
|
|
|
203
|
+ this.loadproductVarietyIdOptions()
|
|
|
|
204
|
+ },
|
|
|
|
205
|
+ methods: {
|
|
|
|
206
|
+ // 校验必填项:生产厂、科办、客户名称、客户类型、产品品种
|
|
|
|
207
|
+ validateRequired() {
|
|
|
|
208
|
+ const checks = [{
|
|
|
|
209
|
+ key: 'workshopId',
|
|
|
|
210
|
+ label: '生产厂'
|
|
369
|
},
|
211
|
},
|
|
370
|
- onRelateConfirm({
|
|
|
|
371
|
- items
|
|
|
|
372
|
- }) {
|
|
|
|
373
|
- console.log('onRelateConfirm__item', items)
|
|
|
|
374
|
- const _fieldKey = this.relate.fieldKey;
|
|
|
|
375
|
- console.log('onRelateConfirm__fieldKey', _fieldKey)
|
|
|
|
376
|
- const first = (items && items.length > 0) ? items[0] : null
|
|
|
|
377
|
- // 若无选中项,确认时清空之前的值
|
|
|
|
378
|
- this.form[_fieldKey] = first.id || '';
|
|
|
|
379
|
- this.form[_fieldKey + 'Name'] = first.name || '';
|
212
|
+ {
|
|
|
|
213
|
+ key: 'officeId',
|
|
|
|
214
|
+ label: '科办'
|
|
380
|
},
|
215
|
},
|
|
381
|
- async loadCustomerTypeOptions() {
|
|
|
|
382
|
- try {
|
|
|
|
383
|
- const res = await getDicByCodeApi('ENTERPRISE_TYPE');
|
|
|
|
384
|
- const list = res.data || [];
|
|
|
|
385
|
- this.customerTypeOptions = (list || []).map(it => ({
|
|
|
|
386
|
- label: it.name || '',
|
|
|
|
387
|
- value: it.code || ''
|
|
|
|
388
|
- }))
|
|
|
|
389
|
- } catch (e) {
|
|
|
|
390
|
- this.customerTypeOptions = []
|
|
|
|
391
|
- }
|
216
|
+ {
|
|
|
|
217
|
+ key: 'customerId',
|
|
|
|
218
|
+ label: '客户名称'
|
|
392
|
},
|
219
|
},
|
|
393
|
-
|
|
|
|
394
|
- async loadproductVarietyIdOptions() {
|
|
|
|
395
|
- try {
|
|
|
|
396
|
- const res = await productVarietyQueryApi({ pageIndex: 1, pageSize: 9999 })
|
|
|
|
397
|
- const _data = res.data || {}
|
|
|
|
398
|
- const list = _data.datas || (Array.isArray(_data) ? _data : [])
|
|
|
|
399
|
- this.productVarietyIdOptions = (list || []).map(it => ({
|
|
|
|
400
|
- label: it.name || it.text || it.label,
|
|
|
|
401
|
- value: it.id || it.code || it.value
|
|
|
|
402
|
- }))
|
|
|
|
403
|
- } catch (e) {
|
|
|
|
404
|
- this.productVarietyIdOptions = []
|
|
|
|
405
|
- }
|
220
|
+ {
|
|
|
|
221
|
+ key: 'customerType',
|
|
|
|
222
|
+ label: '客户类型'
|
|
406
|
},
|
223
|
},
|
|
407
|
- async onSubmit() {
|
|
|
|
408
|
- // 必填校验
|
|
|
|
409
|
- if (!this.validateRequired()) return
|
|
|
|
410
|
- const payload = {
|
|
|
|
411
|
- ...this.form
|
|
|
|
412
|
- }
|
|
|
|
413
|
- delete payload.workshopIdName
|
|
|
|
414
|
- delete payload.officeIdName
|
|
|
|
415
|
- delete payload.customerTypeName
|
|
|
|
416
|
- delete payload.customerIdName
|
|
|
|
417
|
- delete payload.productVarietyIdName
|
|
|
|
418
|
- delete payload.chargeUserIdName
|
|
|
|
419
|
- createApi(payload).then(res => {
|
|
|
|
420
|
- uni.showToast({
|
|
|
|
421
|
- title: '提交成功',
|
|
|
|
422
|
- icon: 'success'
|
|
|
|
423
|
- })
|
|
|
|
424
|
- setTimeout(() => uni.navigateBack(), 600)
|
|
|
|
425
|
- }).catch(e => {
|
|
|
|
426
|
- console.log('createApi__e', e)
|
224
|
+ {
|
|
|
|
225
|
+ key: 'productVarietyId',
|
|
|
|
226
|
+ label: '产品品种'
|
|
|
|
227
|
+ }
|
|
|
|
228
|
+ ]
|
|
|
|
229
|
+ for (const it of checks) {
|
|
|
|
230
|
+ const val = this.form[it.key]
|
|
|
|
231
|
+ if (val === undefined || val === null || String(val).trim() === '') {
|
|
427
|
uni.showToast({
|
232
|
uni.showToast({
|
|
428
|
- title: e.msg || '提交失败',
|
233
|
+ title: `请先选择${it.label}`,
|
|
429
|
icon: 'none'
|
234
|
icon: 'none'
|
|
430
|
})
|
235
|
})
|
|
|
|
236
|
+ return false
|
|
|
|
237
|
+ }
|
|
|
|
238
|
+ }
|
|
|
|
239
|
+ return true
|
|
|
|
240
|
+ },
|
|
|
|
241
|
+ async loadOfficeOptions() {
|
|
|
|
242
|
+ try {
|
|
|
|
243
|
+ const res = await officeQueryApi({
|
|
|
|
244
|
+ pageIndex: 1,
|
|
|
|
245
|
+ pageSize: 9999
|
|
431
|
})
|
246
|
})
|
|
|
|
247
|
+ const _data = res.data || {}
|
|
|
|
248
|
+ const list = _data.datas || []
|
|
|
|
249
|
+ this.officeOptions = (list || []).map(it => ({
|
|
|
|
250
|
+ label: it.name || it.text || it.officeName || it.label,
|
|
|
|
251
|
+ value: it.id || it.code || it.value
|
|
|
|
252
|
+ }))
|
|
|
|
253
|
+ } catch (e) {
|
|
|
|
254
|
+ this.officeOptions = []
|
|
|
|
255
|
+ }
|
|
|
|
256
|
+ },
|
|
|
|
257
|
+ displayLabel(field) {
|
|
|
|
258
|
+ const m = this.form
|
|
|
|
259
|
+ const map = {
|
|
|
|
260
|
+ workshopIdName: '请选择生产厂',
|
|
|
|
261
|
+ officeIdName: '请选择科办',
|
|
|
|
262
|
+ customerTypeName: '请选择客户类型',
|
|
|
|
263
|
+ productVarietyIdName: '请选择产品品种'
|
|
|
|
264
|
+ }
|
|
|
|
265
|
+ const val = m[field]
|
|
|
|
266
|
+ return val ? String(val) : map[field]
|
|
|
|
267
|
+ },
|
|
|
|
268
|
+ async openSheet(field) {
|
|
|
|
269
|
+ const setSheet = (title, options) => {
|
|
|
|
270
|
+ const current = this.form[field]
|
|
|
|
271
|
+ const match = (options || []).find(o => String(o.label) === String(current) || String(o.value) === String(current))
|
|
|
|
272
|
+ this.sheet = {
|
|
|
|
273
|
+ ...this.sheet,
|
|
|
|
274
|
+ visible: true,
|
|
|
|
275
|
+ title,
|
|
|
|
276
|
+ options,
|
|
|
|
277
|
+ field,
|
|
|
|
278
|
+ value: match ? match.value : ''
|
|
|
|
279
|
+ }
|
|
|
|
280
|
+ }
|
|
|
|
281
|
+ if (field === 'workshopId') {
|
|
|
|
282
|
+ const res = await workshopQueryApi({ pageIndex: 1, pageSize: 9999 })
|
|
|
|
283
|
+ const _data = res.data || {}
|
|
|
|
284
|
+ const list = _data.datas || (Array.isArray(_data) ? _data : [])
|
|
|
|
285
|
+ const opts = (list || []).map(it => ({
|
|
|
|
286
|
+ label: it.name,
|
|
|
|
287
|
+ value: it.id
|
|
|
|
288
|
+ }))
|
|
|
|
289
|
+ setSheet('生产厂', opts)
|
|
|
|
290
|
+ } else if (field === 'officeId') {
|
|
|
|
291
|
+ setSheet('科办', this.officeOptions)
|
|
|
|
292
|
+ } else if (field === 'customerType') {
|
|
|
|
293
|
+ const opts = this.customerTypeOptions || [];
|
|
|
|
294
|
+ setSheet('客户类型', opts)
|
|
|
|
295
|
+ } else if (field === 'productVarietyId') {
|
|
|
|
296
|
+ const opts = this.productVarietyIdOptions;
|
|
|
|
297
|
+ setSheet('产品品种', opts)
|
|
|
|
298
|
+ }
|
|
|
|
299
|
+ },
|
|
|
|
300
|
+ onSheetConfirm({
|
|
|
|
301
|
+ value,
|
|
|
|
302
|
+ label
|
|
|
|
303
|
+ }) {
|
|
|
|
304
|
+ const field = this.sheet.field
|
|
|
|
305
|
+ if (!field) return
|
|
|
|
306
|
+ this.form[field] = value || '';
|
|
|
|
307
|
+ this.form[field + 'Name'] = label || ''
|
|
|
|
308
|
+ this.sheet.visible = false
|
|
|
|
309
|
+ },
|
|
|
|
310
|
+ openRelate(fieldKey) {
|
|
|
|
311
|
+ let config = {};
|
|
|
|
312
|
+ switch (fieldKey) {
|
|
|
|
313
|
+ case 'customerId':
|
|
|
|
314
|
+ config = {
|
|
|
|
315
|
+ title: '客户名称',
|
|
|
|
316
|
+ source: 'customer',
|
|
|
|
317
|
+ rowKey: 'id',
|
|
|
|
318
|
+ multiple: false,
|
|
|
|
319
|
+ display: [{
|
|
|
|
320
|
+ label: '名称',
|
|
|
|
321
|
+ field: 'name'
|
|
|
|
322
|
+ },
|
|
|
|
323
|
+ {
|
|
|
|
324
|
+ label: '编号',
|
|
|
|
325
|
+ field: 'code'
|
|
|
|
326
|
+ },
|
|
|
|
327
|
+ {
|
|
|
|
328
|
+ label: '状态',
|
|
|
|
329
|
+ field: 'available',
|
|
|
|
330
|
+ format: v => (v ? '启用' : '停用')
|
|
|
|
331
|
+ }
|
|
|
|
332
|
+ ]
|
|
|
|
333
|
+ }
|
|
|
|
334
|
+ break
|
|
|
|
335
|
+ case 'chargeUserId':
|
|
|
|
336
|
+ config = {
|
|
|
|
337
|
+ title: '责任人',
|
|
|
|
338
|
+ source: 'user',
|
|
|
|
339
|
+ rowKey: 'id',
|
|
|
|
340
|
+ multiple: false,
|
|
|
|
341
|
+ display: [{
|
|
|
|
342
|
+ label: '姓名',
|
|
|
|
343
|
+ field: 'name'
|
|
|
|
344
|
+ },
|
|
|
|
345
|
+ {
|
|
|
|
346
|
+ label: '编号',
|
|
|
|
347
|
+ field: 'code'
|
|
|
|
348
|
+ },
|
|
|
|
349
|
+ {
|
|
|
|
350
|
+ label: '状态',
|
|
|
|
351
|
+ field: 'available',
|
|
|
|
352
|
+ format: v => (v ? '启用' : '停用')
|
|
|
|
353
|
+ }
|
|
|
|
354
|
+ ]
|
|
|
|
355
|
+ };
|
|
|
|
356
|
+ break
|
|
|
|
357
|
+ }
|
|
|
|
358
|
+ const selectedKeys = this.form[fieldKey] ? [this.form[fieldKey]] : [];
|
|
|
|
359
|
+ // 逐一赋值,避免整体替换对象导致子组件 prop 更新不及时
|
|
|
|
360
|
+ this.sheet.visible = false
|
|
|
|
361
|
+ this.relate.title = config.title
|
|
|
|
362
|
+ this.relate.source = config.source
|
|
|
|
363
|
+ this.relate.display = config.display
|
|
|
|
364
|
+ this.relate.multiple = config.multiple
|
|
|
|
365
|
+ this.relate.rowKey = config.rowKey
|
|
|
|
366
|
+ this.relate.selectedKeys = selectedKeys
|
|
|
|
367
|
+ this.relate.fieldKey = fieldKey;
|
|
|
|
368
|
+ // 最后再打开弹框,确保选中键已传入
|
|
|
|
369
|
+ this.$nextTick(() => {
|
|
|
|
370
|
+ this.relate.visible = true
|
|
|
|
371
|
+ })
|
|
|
|
372
|
+ },
|
|
|
|
373
|
+ onRelateConfirm({
|
|
|
|
374
|
+ items
|
|
|
|
375
|
+ }) {
|
|
|
|
376
|
+ console.log('onRelateConfirm__item', items)
|
|
|
|
377
|
+ const _fieldKey = this.relate.fieldKey;
|
|
|
|
378
|
+ console.log('onRelateConfirm__fieldKey', _fieldKey)
|
|
|
|
379
|
+ const first = (items && items.length > 0) ? items[0] : null
|
|
|
|
380
|
+ // 若无选中项,确认时清空之前的值
|
|
|
|
381
|
+ this.form[_fieldKey] = first.id || '';
|
|
|
|
382
|
+ this.form[_fieldKey + 'Name'] = first.name || '';
|
|
|
|
383
|
+ },
|
|
|
|
384
|
+ async loadCustomerTypeOptions() {
|
|
|
|
385
|
+ try {
|
|
|
|
386
|
+ const res = await getDicByCodeApi('ENTERPRISE_TYPE');
|
|
|
|
387
|
+ const list = res.data || [];
|
|
|
|
388
|
+ this.customerTypeOptions = (list || []).map(it => ({
|
|
|
|
389
|
+ label: it.name || '',
|
|
|
|
390
|
+ value: it.code || ''
|
|
|
|
391
|
+ }))
|
|
|
|
392
|
+ } catch (e) {
|
|
|
|
393
|
+ this.customerTypeOptions = []
|
|
|
|
394
|
+ }
|
|
|
|
395
|
+ },
|
|
|
|
396
|
+
|
|
|
|
397
|
+ async loadproductVarietyIdOptions() {
|
|
|
|
398
|
+ try {
|
|
|
|
399
|
+ const res = await productVarietyQueryApi({ pageIndex: 1, pageSize: 9999 })
|
|
|
|
400
|
+ const _data = res.data || {}
|
|
|
|
401
|
+ const list = _data.datas || (Array.isArray(_data) ? _data : [])
|
|
|
|
402
|
+ this.productVarietyIdOptions = (list || []).map(it => ({
|
|
|
|
403
|
+ label: it.name || it.text || it.label,
|
|
|
|
404
|
+ value: it.id || it.code || it.value
|
|
|
|
405
|
+ }))
|
|
|
|
406
|
+ } catch (e) {
|
|
|
|
407
|
+ this.productVarietyIdOptions = []
|
|
|
|
408
|
+ }
|
|
|
|
409
|
+ },
|
|
|
|
410
|
+ async onSubmit() {
|
|
|
|
411
|
+ // 必填校验
|
|
|
|
412
|
+ if (!this.validateRequired()) return
|
|
|
|
413
|
+ const payload = {
|
|
|
|
414
|
+ ...this.form
|
|
432
|
}
|
415
|
}
|
|
|
|
416
|
+ delete payload.workshopIdName
|
|
|
|
417
|
+ delete payload.officeIdName
|
|
|
|
418
|
+ delete payload.customerTypeName
|
|
|
|
419
|
+ delete payload.customerIdName
|
|
|
|
420
|
+ delete payload.productVarietyIdName
|
|
|
|
421
|
+ delete payload.chargeUserIdName
|
|
|
|
422
|
+ createApi(payload).then(res => {
|
|
|
|
423
|
+ uni.showToast({
|
|
|
|
424
|
+ title: '提交成功',
|
|
|
|
425
|
+ icon: 'success'
|
|
|
|
426
|
+ })
|
|
|
|
427
|
+ setTimeout(() => { uni.redirectTo({ url: '/pages/dev_manage/index' }) }, 300)
|
|
|
|
428
|
+ }).catch(e => {
|
|
|
|
429
|
+ console.log('createApi__e', e)
|
|
|
|
430
|
+ uni.showToast({
|
|
|
|
431
|
+ title: e.msg || '提交失败',
|
|
|
|
432
|
+ icon: 'none'
|
|
|
|
433
|
+ })
|
|
|
|
434
|
+ })
|
|
433
|
}
|
435
|
}
|
|
434
|
}
|
436
|
}
|
|
|
|
437
|
+}
|
|
435
|
</script>
|
438
|
</script>
|
|
436
|
|
439
|
|
|
437
|
<style lang="scss" scoped>
|
440
|
<style lang="scss" scoped>
|
|
438
|
- .page {
|
|
|
|
439
|
- display: flex;
|
|
|
|
440
|
- flex-direction: column;
|
|
|
|
441
|
- height: 100%;
|
441
|
+.page {
|
|
|
|
442
|
+ display: flex;
|
|
|
|
443
|
+ flex-direction: column;
|
|
|
|
444
|
+ height: 100%;
|
|
|
|
445
|
+}
|
|
|
|
446
|
+
|
|
|
|
447
|
+.scroll {
|
|
|
|
448
|
+ flex: 1;
|
|
|
|
449
|
+ padding: 12rpx 0 160rpx;
|
|
|
|
450
|
+}
|
|
|
|
451
|
+
|
|
|
|
452
|
+.footer {
|
|
|
|
453
|
+ position: fixed;
|
|
|
|
454
|
+ left: 0;
|
|
|
|
455
|
+ right: 0;
|
|
|
|
456
|
+ bottom: 0;
|
|
|
|
457
|
+ padding: 32rpx;
|
|
|
|
458
|
+ padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
|
|
|
|
459
|
+ background: #fff;
|
|
|
|
460
|
+ box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
|
|
|
|
461
|
+ z-index: 10;
|
|
|
|
462
|
+
|
|
|
|
463
|
+ .btn {
|
|
|
|
464
|
+ height: 80rpx;
|
|
|
|
465
|
+ line-height: 80rpx;
|
|
|
|
466
|
+ border-radius: 12rpx;
|
|
|
|
467
|
+ font-size: 32rpx;
|
|
442
|
}
|
468
|
}
|
|
443
|
|
469
|
|
|
444
|
- .scroll {
|
|
|
|
445
|
- flex: 1;
|
|
|
|
446
|
- padding: 12rpx 0 160rpx;
|
470
|
+ .submit {
|
|
|
|
471
|
+ background: $theme-primary;
|
|
|
|
472
|
+ color: #fff;
|
|
447
|
}
|
473
|
}
|
|
|
|
474
|
+}
|
|
448
|
|
475
|
|
|
449
|
- .footer {
|
|
|
|
450
|
- position: fixed;
|
|
|
|
451
|
- left: 0;
|
|
|
|
452
|
- right: 0;
|
|
|
|
453
|
- bottom: 0;
|
|
|
|
454
|
- padding: 32rpx;
|
|
|
|
455
|
- padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
|
|
|
|
456
|
- background: #fff;
|
|
|
|
457
|
- box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
|
|
|
|
458
|
- z-index: 10;
|
476
|
+::v-deep .uni-list {
|
|
|
|
477
|
+ background: transparent;
|
|
459
|
|
478
|
|
|
460
|
- .btn {
|
|
|
|
461
|
- height: 80rpx;
|
|
|
|
462
|
- line-height: 80rpx;
|
|
|
|
463
|
- border-radius: 12rpx;
|
479
|
+ &-item {
|
|
|
|
480
|
+ &__extra-text {
|
|
464
|
font-size: 32rpx;
|
481
|
font-size: 32rpx;
|
|
465
|
}
|
482
|
}
|
|
466
|
|
483
|
|
|
467
|
- .submit {
|
|
|
|
468
|
- background: $theme-primary;
|
|
|
|
469
|
- color: #fff;
|
484
|
+ &__content-title {
|
|
|
|
485
|
+ font-size: 32rpx;
|
|
|
|
486
|
+ color: rgba(0, 0, 0, 0.9);
|
|
470
|
}
|
487
|
}
|
|
471
|
- }
|
|
|
|
472
|
|
488
|
|
|
473
|
- ::v-deep .uni-list {
|
|
|
|
474
|
- background: transparent;
|
|
|
|
475
|
- &-item {
|
|
|
|
476
|
- &__extra-text {
|
|
|
|
477
|
- font-size: 32rpx;
|
|
|
|
478
|
- }
|
|
|
|
479
|
- &__content-title {
|
|
|
|
480
|
- font-size: 32rpx;
|
|
|
|
481
|
- color: rgba(0, 0, 0, 0.9);
|
|
|
|
482
|
- }
|
489
|
+ &__container {
|
|
|
|
490
|
+ padding: 32rpx;
|
|
|
|
491
|
+
|
|
|
|
492
|
+ .uni-easyinput {
|
|
|
|
493
|
+ &__placeholder-class {
|
|
|
|
494
|
+ font-size: 32rpx;
|
|
|
|
495
|
+ color: rgba(0, 0, 0, 0.4);
|
|
|
|
496
|
+ }
|
|
483
|
|
497
|
|
|
484
|
- &__container {
|
|
|
|
485
|
- padding: 32rpx;
|
498
|
+ &__content {
|
|
|
|
499
|
+ border: none;
|
|
486
|
|
500
|
|
|
487
|
- .uni-easyinput {
|
|
|
|
488
|
- &__placeholder-class {
|
501
|
+ &-input {
|
|
|
|
502
|
+ padding-left: 0 !important;
|
|
|
|
503
|
+ height: 48rpx;
|
|
|
|
504
|
+ line-height: 48rpx;
|
|
489
|
font-size: 32rpx;
|
505
|
font-size: 32rpx;
|
|
490
|
- color: rgba(0, 0, 0, 0.4);
|
|
|
|
491
|
}
|
506
|
}
|
|
492
|
|
507
|
|
|
493
|
- &__content {
|
|
|
|
494
|
- border: none;
|
|
|
|
495
|
-
|
|
|
|
496
|
- &-input {
|
|
|
|
497
|
- padding-left: 0 !important;
|
|
|
|
498
|
- height: 48rpx;
|
|
|
|
499
|
- line-height: 48rpx;
|
|
|
|
500
|
- font-size: 32rpx;
|
|
|
|
501
|
- }
|
|
|
|
502
|
-
|
|
|
|
503
|
- .content-clear-icon {
|
|
|
|
504
|
- font-size: 44rpx !important;
|
|
|
|
505
|
- }
|
508
|
+ .content-clear-icon {
|
|
|
|
509
|
+ font-size: 44rpx !important;
|
|
506
|
}
|
510
|
}
|
|
507
|
}
|
511
|
}
|
|
|
|
512
|
+ }
|
|
508
|
|
513
|
|
|
509
|
- .item-title,
|
|
|
|
510
|
- .uni-list-item__content {
|
|
|
|
511
|
- flex: none;
|
|
|
|
512
|
- min-height: 48rpx;
|
|
|
|
513
|
- line-height: 48rpx;
|
|
|
|
514
|
- font-size: 32rpx;
|
|
|
|
515
|
- position: relative;
|
|
|
|
516
|
- width: 210rpx;
|
|
|
|
517
|
- margin-right: 32rpx;
|
|
|
|
518
|
- color: rgba(0, 0, 0, 0.9);
|
514
|
+ .item-title,
|
|
|
|
515
|
+ .uni-list-item__content {
|
|
|
|
516
|
+ flex: none;
|
|
|
|
517
|
+ min-height: 48rpx;
|
|
|
|
518
|
+ line-height: 48rpx;
|
|
|
|
519
|
+ font-size: 32rpx;
|
|
|
|
520
|
+ position: relative;
|
|
|
|
521
|
+ width: 210rpx;
|
|
|
|
522
|
+ margin-right: 32rpx;
|
|
|
|
523
|
+ color: rgba(0, 0, 0, 0.9);
|
|
519
|
|
524
|
|
|
520
|
- .required {
|
|
|
|
521
|
- color: red;
|
|
|
|
522
|
- position: absolute;
|
|
|
|
523
|
- top: 50%;
|
|
|
|
524
|
- transform: translateY(-50%);
|
|
|
|
525
|
- left: -16rpx;
|
|
|
|
526
|
- }
|
525
|
+ .required {
|
|
|
|
526
|
+ color: red;
|
|
|
|
527
|
+ position: absolute;
|
|
|
|
528
|
+ top: 50%;
|
|
|
|
529
|
+ transform: translateY(-50%);
|
|
|
|
530
|
+ left: -16rpx;
|
|
527
|
}
|
531
|
}
|
|
528
|
-
|
|
|
|
529
|
}
|
532
|
}
|
|
530
|
- &.select-item {
|
|
|
|
531
|
- &.is-empty {
|
|
|
|
532
|
- .uni-list-item__extra-text {
|
|
|
|
533
|
- color: rgba(0, 0, 0, 0.4) !important;
|
|
|
|
534
|
- }
|
|
|
|
535
|
- }
|
|
|
|
536
|
- &.is-filled {
|
|
|
|
537
|
- .uni-list-item__extra-text {
|
|
|
|
538
|
- color: rgba(0, 0, 0, 0.9) !important;
|
|
|
|
539
|
- }
|
533
|
+
|
|
|
|
534
|
+ }
|
|
|
|
535
|
+
|
|
|
|
536
|
+ &.select-item {
|
|
|
|
537
|
+ &.is-empty {
|
|
|
|
538
|
+ .uni-list-item__extra-text {
|
|
|
|
539
|
+ color: rgba(0, 0, 0, 0.4) !important;
|
|
540
|
}
|
540
|
}
|
|
541
|
}
|
541
|
}
|
|
542
|
- &.mgb10 {
|
|
|
|
543
|
- margin-bottom: 20rpx;
|
542
|
+
|
|
|
|
543
|
+ &.is-filled {
|
|
|
|
544
|
+ .uni-list-item__extra-text {
|
|
|
|
545
|
+ color: rgba(0, 0, 0, 0.9) !important;
|
|
|
|
546
|
+ }
|
|
544
|
}
|
547
|
}
|
|
545
|
}
|
548
|
}
|
|
546
|
- }
|
|
|
|
547
|
|
549
|
|
|
|
|
550
|
+ &.mgb10 {
|
|
|
|
551
|
+ margin-bottom: 20rpx;
|
|
|
|
552
|
+ }
|
|
|
|
553
|
+ }
|
|
|
|
554
|
+}
|
|
548
|
</style> |
555
|
</style> |