fc7cb950
wuxw
开发完成采购功能
|
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
|
<template>
<div class="allocation-storehouse-apply-container">
<el-card class="box-card">
<div slot="header" class="flex justify-between">
<span>{{ $t('allocationStorehouseApply.title') }}</span>
<el-button type="primary" size="small" class="float-right" @click="goBack">
<i class="el-icon-close"></i>
{{ $t('allocationStorehouseApply.back') }}
</el-button>
</div>
<el-form label-width="120px">
<el-row :gutter="20">
<el-col :span="24">
<el-form-item :label="$t('allocationStorehouseApply.warehouse')">
<el-select v-model="form.shId" :placeholder="$t('allocationStorehouseApply.warehousePlaceholder')"
@change="computeFlow" style="width:100%">
<el-option v-for="item in storehouses" :key="item.shId" :label="item.shName" :value="item.shId">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item :label="$t('allocationStorehouseApply.remark')">
<el-input type="textarea" v-model="form.remark"
:placeholder="$t('allocationStorehouseApply.remarkPlaceholder')" :rows="3"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card margin-top">
<div slot="header" class="flex justify-between">
<span>{{ $t('allocationStorehouseApply.itemsTitle') }}</span>
<el-button type="primary" size="small" class="float-right" @click="openChooseResourceDialog">
<i class="el-icon-search"></i>
{{ $t('allocationStorehouseApply.selectItems') }}
</el-button>
</div>
|
b4962701
wuxw
测试采购相关功能
|
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
|
<table class="custom-table">
<thead>
<tr>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.itemType') }}
</th>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.itemName') }}
</th>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.itemSpec') }}
</th>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.fixedItem') }}
</th>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.sourceWarehouse') }}
</th>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.referencePrice') }}
</th>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.stock') }}
</th>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.targetWarehouse') }}
</th>
<th style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa;">
{{ $t('allocationStorehouseApply.transferQuantity') }}
</th>
<th
style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5; background-color: #fafafa; width: 150px;">
{{ $t('allocationStorehouseApply.operation') }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in resourceStores" :key="index" style="border-bottom: 1px solid #ebeef5;">
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
{{ item.parentRstName || '-' }} > {{ item.rstName || '-' }}
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
{{ item.resName }}({{ item.resCode }})
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
{{ item.rssName || '-' }}
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
{{ item.isFixedName }}
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
{{ item.shaName }}
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
<select v-model="item.timesId" @change="changeTimesId($event, index)" class="custom-select">
<option value="">{{ $t('allocationStorehouseApply.selectPrice') }}</option>
<option v-for="time in item.times" :key="time.timesId" :value="time.timesId">
{{ time.price }}
</option>
</select>
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
{{ getTimesStock(item) }}{{ item.unitCodeName }}
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
<select v-model="item.shzId" class="custom-select">
<option value="">{{ $t('allocationStorehouseApply.selectTargetWarehouse') }}</option>
<template v-for="storehouse in storehouses">
<option :key="storehouse.shId" :value="storehouse.shId"
v-if="storehouse.shId != item.shId && storehouse.communityId == communityId">
{{ storehouse.shName }}
</option>
</template>
</select>
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
<el-input-number v-model="item.curStock" :min="0" :precision="0"
controls-position="right"></el-input-number>
{{ item.unitCodeName }}
</td>
<td style="text-align: center; padding: 12px 8px; border: 1px solid #ebeef5;">
<el-button type="danger" size="mini" @click="removeItem(item)">
{{ $t('allocationStorehouseApply.cancelTransfer') }}
</el-button>
</td>
</tr>
<tr v-if="resourceStores.length === 0">
<td colspan="10" style="text-align: center; padding: 20px; color: #909399;">
{{ $t('common.noData') }}
</td>
</tr>
</tbody>
</table>
|
fc7cb950
wuxw
开发完成采购功能
|
136
137
138
|
</el-card>
<el-card class="box-card margin-top" v-if="form.audit.assignee === '-2'">
|
19bafb73
wuxw
v1.9 优化采购相关bug
|
139
|
<div slot="header" class="flex justify-between">
|
fc7cb950
wuxw
开发完成采购功能
|
140
141
142
143
144
|
<span>{{ $t('allocationStorehouseApply.approverTitle') }}</span>
</div>
<el-form label-width="120px">
<el-row :gutter="20">
|
19bafb73
wuxw
v1.9 优化采购相关bug
|
145
|
<el-col :span="18">
|
fc7cb950
wuxw
开发完成采购功能
|
146
147
148
|
<el-form-item :label="$t('allocationStorehouseApply.approver')">
<el-input v-model="form.audit.staffName" :placeholder="$t('allocationStorehouseApply.selectApprover')"
disabled></el-input>
|
19bafb73
wuxw
v1.9 优化采购相关bug
|
149
|
|
fc7cb950
wuxw
开发完成采购功能
|
150
151
|
</el-form-item>
</el-col>
|
19bafb73
wuxw
v1.9 优化采购相关bug
|
152
153
154
155
156
157
|
<el-col :span="6" class="text-left">
<el-button type="primary" @click="chooseStaff">
<i class="el-icon-search"></i>
{{ $t('allocationStorehouseApply.select') }}
</el-button>
</el-col>
|
fc7cb950
wuxw
开发完成采购功能
|
158
159
160
161
162
163
164
165
166
167
168
169
|
</el-row>
</el-form>
</el-card>
<div class="submit-wrapper">
<el-button type="primary" @click="submitApply">
{{ $t('allocationStorehouseApply.submit') }}
</el-button>
</div>
<choose-resource-store ref="chooseResourceStore" @choose="handleChooseResource" />
|
19bafb73
wuxw
v1.9 优化采购相关bug
|
170
|
<select-staff ref="selectStaff" @selectStaff="handleSelectStaff" />
|
fc7cb950
wuxw
开发完成采购功能
|
171
172
173
174
175
176
|
</div>
</template>
<script>
import { getCommunityId } from '@/api/community/communityApi'
import ChooseResourceStore from '@/components/resource/chooseResourceStore'
|
19bafb73
wuxw
v1.9 优化采购相关bug
|
177
|
import SelectStaff from '@/components/staff/SelectStaff'
|
fc7cb950
wuxw
开发完成采购功能
|
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
import {
listStorehouses,
saveAllocationStorehouse,
queryFirstAuditStaff
} from '@/api/resource/allocationStorehouseApplyApi'
export default {
name: 'AllocationStorehouseApplyList',
components: {
ChooseResourceStore,
SelectStaff
},
data() {
return {
communityId: '',
form: {
resourceStores: [],
storehouses: [],
remark: '',
communityId: '',
shId: '',
flowId: '',
|
19bafb73
wuxw
v1.9 优化采购相关bug
|
200
|
apply_type: 10000,
|
fc7cb950
wuxw
开发完成采购功能
|
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
277
278
279
|
audit: {
assignee: '',
staffId: '',
staffName: '',
taskId: ''
}
},
storehouses: [],
resourceStores: []
}
},
created() {
this.communityId = getCommunityId()
this.form.communityId = this.communityId
this.loadStorehouses()
},
methods: {
async loadStorehouses() {
try {
const params = {
page: 1,
row: 100,
flag: "1",
communityId: this.communityId
}
const res = await listStorehouses(params)
this.storehouses = res.data
this.form.storehouses = res.data
} catch (error) {
console.error(error)
}
},
openChooseResourceDialog() {
if (!this.form.shId) {
this.$message.error(this.$t('allocationStorehouseApply.selectWarehouseFirst'))
return
}
if (!this.form.remark) {
this.$message.error(this.$t('allocationStorehouseApply.fillRemarkFirst'))
return
}
this.$refs.chooseResourceStore.open({
resOrderType: '20000',
shId: this.form.shId,
isAllocation: true
})
},
handleChooseResource(resources) {
const oldList = this.resourceStores
// 过滤重复选择的商品
const newResources = resources.filter(newItem => {
return !oldList.some(oldItem => oldItem.resId === newItem.resId)
})
// 设置默认值
newResources.forEach(item => {
item.shaName = item.shName
item.shzId = ''
item.curStock = 0
if (item.times && item.times.length > 0) {
item.timesId = item.times[0].timesId
}
})
this.resourceStores = [...newResources, ...oldList]
this.form.resourceStores = this.resourceStores
},
removeItem(item) {
this.resourceStores = this.resourceStores.filter(i => i.resId !== item.resId)
this.form.resourceStores = this.resourceStores
this.$refs.chooseResourceStore.removeSelectedItem(item.resId)
},
changeTimesId(value, index) {
const times = this.resourceStores[index].times
times.forEach(item => {
if (item.timesId === value) {
this.resourceStores[index].selectedStock = item.stock
}
})
|
b4962701
wuxw
测试采购相关功能
|
280
281
282
|
this.$nextTick(() => {
this.$forceUpdate()
})
|
fc7cb950
wuxw
开发完成采购功能
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
},
getTimesStock(item) {
if (!item.timesId) return "-"
let stock = 0
item.times.forEach(time => {
if (time.timesId === item.timesId) {
stock = time.stock
}
})
return stock
},
computeFlow() {
// 清空已选择的商品
this.resourceStores = []
this.form.resourceStores = []
const storehouse = this.storehouses.find(item => item.shId === this.form.shId)
if (!storehouse) return
this.form.flowId = storehouse.allocationFlowId
if (!this.form.flowId) return
this.loadStaffOrg(this.form.flowId)
},
async loadStaffOrg(flowId) {
try {
const params = {
communityId: this.communityId,
flowId: flowId
}
const res = await queryFirstAuditStaff(params)
if (res.code !== 0) return
const data = res.data[0]
Object.assign(this.form.audit, data)
if (!data.assignee.startsWith('-')) {
this.form.audit.staffId = data.assignee
}
} catch (error) {
console.error(error)
}
},
chooseStaff() {
this.$refs.selectStaff.open(this.form.audit)
},
handleSelectStaff(staff) {
|
19bafb73
wuxw
v1.9 优化采购相关bug
|
329
330
|
this.form.audit.staffId = staff.staffId
this.form.audit.staffName = staff.staffName
|
fc7cb950
wuxw
开发完成采购功能
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
},
async submitApply() {
// 验证数据
if (!this.form.remark) {
this.$message.error(this.$t('allocationStorehouseApply.remarkRequired'))
return
}
if (this.resourceStores.length === 0) {
this.$message.error(this.$t('allocationStorehouseApply.selectItemsFirst'))
return
}
if (!this.resourcesFromSameHouse(this.resourceStores)) {
this.$message.error(this.$t('allocationStorehouseApply.sameWarehouseRequired'))
return
}
let isValid = true
this.resourceStores.forEach(item => {
if (!item.timesId) {
this.$message.error(`${item.resName}${this.$t('allocationStorehouseApply.selectPriceFirst')}`)
isValid = false
return
}
item.curStock = parseFloat(item.curStock)
if (item.curStock > parseFloat(item.selectedStock)) {
this.$message.error(`${item.resName}${this.$t('allocationStorehouseApply.stockNotEnough')}`)
isValid = false
return
}
if (!item.shzId) {
this.$message.error(this.$t('allocationStorehouseApply.selectTargetWarehouseFirst'))
isValid = false
return
}
if (item.curStock <= 0) {
this.$message.error(this.$t('allocationStorehouseApply.fillQuantityFirst'))
isValid = false
return
}
})
if (!isValid) return
try {
const res = await saveAllocationStorehouse(this.form)
if (res.code === 0) {
this.$message.success(this.$t('allocationStorehouseApply.submitSuccess'))
this.goBack()
} else {
this.$message.error(res.msg)
}
} catch (error) {
console.error(error)
this.$message.error(this.$t('allocationStorehouseApply.submitFailed'))
}
},
resourcesFromSameHouse(resources) {
if (!resources || resources.length < 2) return true
const firstShId = resources[0].shId
return resources.every(item => item.shId === firstShId)
},
goBack() {
this.$router.go(-1)
}
}
}
</script>
<style lang="scss" scoped>
.allocation-storehouse-apply-container {
padding: 20px;
.box-card {
margin-bottom: 20px;
}
.margin-top {
margin-top: 20px;
}
.float-right {
float: right;
}
.submit-wrapper {
text-align: right;
margin-top: 20px;
}
|
b4962701
wuxw
测试采购相关功能
|
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
.custom-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #ebeef5;
}
.custom-table th {
background-color: #fafafa;
color: #606266;
font-weight: 500;
font-size: 14px;
}
.custom-table td {
color: #606266;
font-size: 14px;
}
.custom-table tr:hover {
background-color: #f5f7fa;
}
.custom-select {
width: 100%;
height: 32px;
line-height: 32px;
border: 1px solid #dcdfe6;
border-radius: 4px;
padding: 0 12px;
font-size: 14px;
color: #606266;
background-color: #fff;
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
}
.custom-select:focus {
outline: none;
border-color: #409eff;
}
.custom-select:hover {
border-color: #c0c4cc;
}
|
fc7cb950
wuxw
开发完成采购功能
|
469
470
|
}
</style>
|