purchaseAndDelivery.vue
20.9 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
277
278
279
280
281
282
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
329
330
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
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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
<!-- 采购发货 -->
<template>
<d2-container class="container">
<div class="header" slot="header">
<d2-search
ref="showSearch"
class="show-search"
:search-form="searchForm"
:form-data="showFormData"
>
</d2-search>
<div class="up-btns">
<el-button :id="tableParams.btnId" size="small" type="primary" handle>
查询
</el-button>
<el-button size="small" @click="handleReset"> 重置 </el-button>
</div>
</div>
<div class="d2-container-content">
<d2-table-header>
<!-- <span slot="left"> -->
<!-- <auth-button category="Button" /> -->
<!-- <auth-button category="Button" />
</span> -->
<span>
<!-- <el-button type="primary" size="mini" @click="handleExport">
导出
</el-button> -->
<auth-button category="Button" :show-btn-ids="['9090405']" />
</span>
</d2-table-header>
<d2-table
ref="purchaseAndDeliveryTable"
:search-form="tableSearchForm"
:table-params="tableParams"
:table-data="tableData"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn"
>
<div slot="auth-button" slot-scope="scope" width="400">
<!-- 查看 -->
<span style="margin-right: 10px">
<auth-button :data="scope.scope" :show-btn-ids="['9090401']" />
</span>
<!-- 确认发货 -->
<span
v-show="scope.scope.deliveryStatus != 2"
style="margin-right: 10px"
>
<auth-button :data="scope.scope" :show-btn-ids="['9090402']" />
</span>
<!-- 分配 -->
<span
v-show="
scope.scope.deliveryStatus != 2 && scope.scope.deliveryStatus != 4
"
style="margin-right: 10px"
>
<!-- <el-button :data="scope.scope" type="text" @click="handleAllocat(scope.scope)">分配</el-button> -->
<auth-button :data="scope.scope" :show-btn-ids="['9090404']" />
</span>
<!-- 驳回 -->
<span
v-show="scope.scope.deliveryStatus == 1 && scope.scope.status == 5"
>
<auth-button :data="scope.scope" :show-btn-ids="['9090403']" />
</span>
<!-- 结束 -->
<span v-show="scope.scope.deliveryStatus == 3">
<auth-button :data="scope.scope" :show-btn-ids="['9090406']" />
</span>
</div>
</d2-table>
</div>
<orderDeatilDialog
:visible.sync="detailVisible"
v-if="detailVisible"
:params-obj="paramsObj"
></orderDeatilDialog>
<EditOrderDialog
v-if="editVisible"
:is-empty-edit="true"
:visible.sync="editVisible"
:params-obj="dialogData"
@editClose="editClose"
>
</EditOrderDialog>
<AllocateDialog
v-if="allocateVisible"
:visible.sync="allocateVisible"
:params-obj="allocateData"
@editClose="allocateClose"
>
</AllocateDialog>
<!-- :config="rejectConfig.setting" :dialog-config="rejectConfig.config" :config="rejectConfig.setting"-->
<baseDialog
:is-show.sync="rejectVisible"
:dialog-config="rejectConfig.config"
@handleClick="handleRejectConfirm"
>
<!-- <d2-dialog v-if="rejectVisible" :is-visible="rejectVisible" title="驳回提2" @confirmDialog="handleRejectConfirm"
@closeDialog="handleRejectClose"> -->
<div class="reject-dialog">
<el-form
:rules="rejectRules"
:model="rejectData"
label-width="150px"
ref="delivery-dialog-form"
>
<el-form-item label="驳回原因:" prop="rejectCause">
<el-input
type="textarea"
placeholder="请输入驳回原因"
maxlength="50"
:rows="3"
show-word-limit
v-model.trim="rejectData.rejectCause"
class="dis-in-block reject-input"
/>
</el-form-item>
</el-form>
</div>
<!-- <div class="footer">
<el-button @click="handleRejectClose">取消</el-button>
<el-button @click="handleRejectConfirm" type="primary" v-preventReClick
:loading="$store.state.d2admin.loading.value">确认</el-button>
</div> -->
<!-- </d2-dialog> -->
</baseDialog>
<baseDialog
:is-show.sync="endVisible"
:dialog-config="endConfig.config"
@handleClick="handleEndConfirm"
>
<!-- <d2-dialog v-if="rejectVisible" :is-visible="rejectVisible" title="驳回提2" @confirmDialog="handleRejectConfirm"
@closeDialog="handleRejectClose"> -->
<div class="reject-dialog">
<el-form
:model="terminateDelivery"
label-width="150px"
ref="delivery-dialog-form"
>
<el-form-item label="备注:" prop="rejectCause">
<el-input
type="textarea"
placeholder="请输入备注信息"
maxlength="200"
:rows="3"
show-word-limit
v-model.trim="terminateDelivery.terminateDeliveryInstruction"
class="dis-in-block reject-input"
/>
</el-form-item>
</el-form>
<p style="margin-left: 150px">
说明:结束发货后,订单发货完结,无法再重新进行发货操作。是否确定结束发货
</p>
</div>
<!-- <div class="footer">
<el-button @click="handleRejectClose">取消</el-button>
<el-button @click="handleRejectConfirm" type="primary" v-preventReClick
:loading="$store.state.d2admin.loading.value">确认</el-button>
</div> -->
<!-- </d2-dialog> -->
</baseDialog>
</d2-container>
</template>
<script>
import { Util, deepClone } from "@/common/util"
import {
defaultStatusOptionsForTable,
defaultDeliveryStatusOptions,
defaultPutStatusOptions,
purchasingPatternOptions
} from "./constant"
import { mapActions, mapState } from "vuex"
import {
getPurchaseOrderShipmentList,
getMerchantList,
purchaseOrderReject,
shipmentTerminate
} from "@/api/purchaseShopping.js"
import orderDeatilDialog from "./components/orderDetailDialog"
import EditOrderDialog from "./components/EditOrderDialog"
import AllocateDialog from "./components/AllocateDialog"
// import { limitPrice } from '@/common/format'
export default {
name: "PurchaseOrder",
components: {
orderDeatilDialog,
EditOrderDialog,
AllocateDialog
},
data() {
return {
editVisible: false,
allocateVisible: false,
reg: {
priceReg: /^\d[\d\.]*$/
},
// 驳回
rejectConfig: {
setting: {
showClose: true,
// appendToBody: true,
isShowFooter: true
// btnList: [
// ]
},
config: {
title: "驳回提示",
width: "750px"
}
},
// 驳回
endConfig: {
setting: {
showClose: true,
// appendToBody: true,
isShowFooter: true
// btnList: [
// ]
},
config: {
title: "结束发货",
width: "750px"
}
},
rejectVisible: false,
endVisible: false,
rejectData: {},
terminateDelivery: {},
rejectRules: {
rejectCause: [
{ required: true, message: "请输入驳回原因", trigger: "blur" }
]
},
endRules: {
terminateDeliveryInstruction: [
{ required: true, message: "请输入备注信息", trigger: "blur" }
]
},
// 搜索
searchForm: {
// status: '',
deliveryStatus: "",
putStatus: "",
merchantName: "",
sortType: 1,
orderTimeStr: [],
purchasingPattern: ""
},
tableSearchForm: {},
tableData: [],
showFormData: [
{
label: "订单编号",
name: "orderCode",
type: "input",
isClear: true,
maxlength: 20
},
{
label: "下单时间",
name: "placeOrderTimeStr",
type: "datePicker",
isClear: true,
pickerOptions: "rangePickerOptions"
},
{
label: "下单商户",
name: "merchantName",
type: "input",
isClear: true,
maxlength: 50
},
{
label: "发货状态",
name: "deliveryStatus",
type: "select",
optionList: [],
optionId: "id",
optionLabel: "label",
optionsName: "defaultDeliveryStatusOptions"
},
// {
// label: '订单状态',
// name: 'status',
// type: 'select',
// optionList: [],
// optionId: 'id',
// optionLabel: 'label',
// optionsName: 'defaultStatusOptions'
// },
{
label: "采购模式",
name: "purchasingPattern",
type: "select",
optionList: [],
optionId: "id",
optionLabel: "label",
optionsName: "purchasingPatternOptions"
},
{
label: "发货主体",
name: "sendOutMerchantName",
type: "input",
isClear: true,
maxlength: 50
},
{
label: "审核时间",
name: "reviewedTimeStr",
type: "datePicker",
isClear: true,
pickerOptions: "rangePickerOptions"
}
],
getListApi: getPurchaseOrderShipmentList,
// getListApi: getPurchaseOrderList,
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: "list",
tableOption: true,
tableColumns: [
{
label: "订单编号",
prop: "orderCode"
},
{
label: "订单总价/元",
prop: "totalPrice",
formatter: (cellValue) => {
return "¥" + cellValue.totalPrice
}
},
{
label: "下单时间",
prop: "orderTime",
formatter: (cellValue) => {
return cellValue.orderTime
? Util.dateFormate(cellValue.orderTime, "YYYY-MM-DD HH:mm:ss")
: "--"
},
width: 150
},
{
label: "下单商户",
prop: "merchantName"
},
{
label: "收货人",
prop: "contactName"
},
{
label: "收货人电话",
prop: "contactPhone"
},
{
label: "收货地址",
prop: "contactAddress"
},
{
label: "采购模式",
prop: "purchasingPattern",
formatter: (cellValue) => {
return (
purchasingPatternOptions.find(
(item) => item.id == cellValue.purchasingPattern
)?.label || "-"
)
}
},
{
label: "发货主体",
prop: "sendOutMerchantName",
formatter: (cellValue) => {
return cellValue.sendOutMerchantName
? cellValue.sendOutMerchantName
: "-"
}
},
{
label: "发货状态",
prop: "deliveryStatus",
formatter: (cellValue) => {
// 1:未发货,2全部发货,3部分发货,4结束发货
return (
defaultDeliveryStatusOptions.find(
(item) => item.id == cellValue.deliveryStatus
)?.label || "-"
)
},
className: (cellValue) => {
return {
1: "ashSpot",
2: "greenSpot",
3: "yellowSpot",
4: "redSpot"
}[cellValue.deliveryStatus]
}
},
{
label: "订单状态",
prop: "status",
formatter: (cellValue) => {
// 1.待审核,2运营已审核,3.已取消,4.运营已驳回,5.商务已审核,6.商务已驳回,7.发货已驳回
return (
defaultStatusOptionsForTable.find(
(item) => item.id == cellValue.status
)?.label || "-"
)
},
className: (cellValue) => {
return {
1: "yellowSpot",
2: "yellowSpot",
3: "ashSpot",
4: "redSpot",
5: "greenSpot",
6: "redSpot",
7: "redSpot"
}[cellValue.status]
}
},
{
label: "审核人",
prop: "reviewedBy",
formatter: (cellValue) => {
return cellValue.auditDetail.reviewedBy || "--"
}
},
{
label: "审核时间",
prop: "reviewedDate",
width: 150,
formatter: (cellValue) => {
return cellValue.auditDetail.reviewedDate
? Util.dateFormate(
cellValue.auditDetail.reviewedDate,
"YYYY-MM-DD HH:mm:ss"
)
: "--"
}
}
]
},
// 查看门店
detailVisible: false,
// 基本数据
baseData: {
// defaultStatusOptions: [],
defaultDeliveryStatusOptions: [],
defaultPutStatusOptions: [],
defaultStatusOptionsForTable: []
},
paramsObj: {},
dialogData: {
orderCode: "",
deliveryCompany: "",
deliveryNumber: ""
},
allocateData: {}
}
},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList
})
},
mounted() {
getMerchantList({}).then((res) => {
const opt = {
merchantNo: "",
merchantName: "全部"
}
res.unshift(opt)
this.getBaseData(res)
})
},
methods: {
...mapActions("d2admin/user", ["actionSetDownloadList"]),
getBaseData(res) {
const allOpt = {
id: "",
label: "全部"
}
this.baseData = {
// defaultStatusOptions: deepClone(defaultStatusOptions),
defaultDeliveryStatusOptions: deepClone(defaultDeliveryStatusOptions),
defaultPutStatusOptions: deepClone(defaultPutStatusOptions),
purchasingPatternOptions: deepClone(purchasingPatternOptions),
defaultStatusOptionsForTable: deepClone(defaultStatusOptionsForTable)
}
this.showFormData.forEach((item, index) => {
if (item.type === "select" && this.baseData[item.optionsName]) {
this.baseData[item.optionsName].unshift(allOpt)
this.$set(
this.showFormData[index],
"optionList",
this.baseData[item.optionsName]
)
}
})
},
deliveryNumberInput(event, index) {
// if (!this.reg.priceReg.test(event)) {
// event = ''
// }
// var oldValue = event
// this.$set(this.dialogData, 'deliveryNumber', limitPrice(event, oldValue, 50, 0, 0))
// 数字和字母输入
this.$set(
this.dialogData,
"deliveryNumber",
event.replace(/[^a-zA-Z0-9]/g, "")
)
},
beforeSearchFn() {
return new Promise((resolve) => {
this.filterSearchTime()
resolve()
})
},
filterSearchTime() {
this.tableSearchForm = deepClone(this.searchForm)
if (this.tableSearchForm.placeOrderTimeStr) {
this.tableSearchForm.orderTimeStr[0] =
new Date(this.tableSearchForm.placeOrderTimeStr[0])
.toLocaleDateString()
.replace(/\//g, "-") + " 00:00:00"
this.tableSearchForm.orderTimeStr[1] =
new Date(this.tableSearchForm.placeOrderTimeStr[1])
.toLocaleDateString()
.replace(/\//g, "-") + " 23:59:59"
delete this.tableSearchForm.placeOrderTimeStr
}
if (this.tableSearchForm.reviewedTimeStr) {
this.tableSearchForm.reviewedStartDateStr =
new Date(this.tableSearchForm.reviewedTimeStr[0])
.toLocaleDateString()
.replace(/\//g, "-") + " 00:00:00"
this.tableSearchForm.reviewedEndDateStr =
new Date(this.tableSearchForm.reviewedTimeStr[1])
.toLocaleDateString()
.replace(/\//g, "-") + " 23:59:59"
delete this.tableSearchForm.reviewedTimeStr
}
},
handleReset() {
for (const key in this.searchForm) {
this.searchForm[key] = ""
}
this.searchForm.sortType = 1
this.searchForm.orderTimeStr = []
this.$refs.purchaseAndDeliveryTable.refreshTable()
},
handleExport() {
this.filterSearchTime()
var params = this.tableSearchForm
delete params.placeOrderTimeStr
delete params.reviewedTimeStr
// 处理查询条件时间
for (const key in params) {
if (key == "orderTimeStr") {
params[key].forEach((v, index) => {
params[`${key}[${index}]`] = v
})
delete params[key]
}
}
// params.method = 'dj.api.smarcarlife.purchaseOrder.export.async'
params.method = "dj.api.smarcarlife.purchaseOrder.shipment.export.async"
params.sortType = 3
const list = [
...this.dowloadList,
{
name: "采购发货",
exportParam: JSON.stringify(params),
status: "waiting",
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: "dowloadList" })
},
editClose(isRefresh) {
this.handleDetailClose()
isRefresh && this.$refs.purchaseAndDeliveryTable.refreshTable()
},
handleDetailClose() {
this.editVisible = !this.editVisible
},
// 驳回
handleRejectClose() {
this.rejectVisible = !this.rejectVisible
},
handleReject(row) {
this.rejectData.orderCode = row.orderCode
this.handleRejectClose()
},
handleRejectConfirm() {
this.$refs["delivery-dialog-form"].validate((valid) => {
if (valid) {
// console.log(valid)
// return
purchaseOrderReject({ ...this.rejectData })
.then((res) => {
this.handleRejectClose()
this.notice.okTips()
this.$refs.purchaseAndDeliveryTable.refreshTable()
})
.catch(() => {
this.handleRejectClose()
})
}
})
},
// 分配
handleAllocat(row) {
this.allocateVisible = true
this.allocateData.orderCode = row.orderCode
this.allocateData.merchantName = row.merchantName
this.allocateData.merchantId = row.merchantId
},
allocateClose(isRefresh) {
this.handleAllocateClose()
isRefresh && this.$refs.purchaseAndDeliveryTable.refreshTable()
},
handleAllocateClose() {
this.allocateVisible = !this.allocateVisible
},
// 确认发货
handleDelivery(row) {
this.editVisible = true
this.dialogData.orderCode = row.orderCode
this.dialogData.merchantName = row.merchantName
},
// 查看详情
handleDetail(row) {
this.paramsObj = {
orderCode: row.orderCode,
merchantName: row.merchantName,
purchaseType: row.purchaseType
}
this.detailVisible = true
},
handleEndConfirm() {
shipmentTerminate({
orderCode: this.dialogData.orderCode,
terminateDeliveryInstruction:
this.terminateDelivery.terminateDeliveryInstruction
}).then((res) => {
this.notice.okTips()
// this.handleEndClose()
this.endVisible = false
this.terminateDelivery.terminateDeliveryInstruction = ""
this.$refs.purchaseAndDeliveryTable.refreshTable()
})
},
// 结束发货
handleEnd(row) {
this.endVisible = true
this.dialogData.orderCode = row.orderCode
// this.$confirm('结束发货后,订单发货完结,无法再重新进行发货操作。是否确定结束发货?', '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning',
// closeOnClickModal: false
// }).then(() => {
// shipmentTerminate({ orderCode: row.orderCode }).then(res => {
// this.notice.okTips()
// this.$refs.purchaseAndDeliveryTable.refreshTable()
// })
// }).catch(err => {
// console.log(err)
// })
}
}
}
</script>
<style lang="scss" scoped>
.reject-dialog {
margin: 65px 0;
.reject-input {
color: red;
::v-deep .el-textarea__inner{
height: 79px;
width: 432px !important;
}
}
::v-deep .el-textarea .el-input__count {
right: 90px;
bottom: -10px;
font-size: 12px;
color: #999999;
}
.tips {
color: #999999;
}
}
.footer {
display: flex;
justify-content: flex-end;
}
</style>