index.vue
13.8 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
<!-- 评价管理-->
<template>
<div class="purchase">
<div class="container">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<div class="table-header">
<GLButton type="primary" class="glbtn" size="small" @click="handleCreatePurchase" fn="创建采购">创建采购</GLButton>
<!-- <el-button type="primary" size="small" @click="handleCreatePurchase">创建采购</el-button> -->
<el-button type="primary" class="btn" size="small" @click="exportExcel">导出</el-button>
</div>
<!-- 表格区域 开始 -->
<GLTable ref="orderRef" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
<template slot="deliveryStatus" slot-scope="scope">
<div>
<span :class="[scope.scope.deliveryStatus == 1 ? 'yellowSpot' : 'greenSpot']"></span>
<span>{{ scope.scope.deliveryStatus | deliveryStatus }}</span>
</div>
</template>
<template slot="putStatus" slot-scope="scope">
<div>
<span :class="[scope.scope.putStatus == 1 ? 'yellowSpot' : 'greenSpot']"></span>
<span>{{ scope.scope.putStatus | putStatus }}</span>
</div>
</template>
<template slot="status" slot-scope="scope">
<div>
<span :class="[scope.scope.status == 1 ? 'yellowSpot' : scope.scope.status == 2 ? 'greenSpot' : 'ashSpot']"></span>
<span>{{ scope.scope.status | orderStatus }}</span>
</div>
</template>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleDetail(scope.scope)">查看</el-button>
<GLButton type="text" size="small" v-show="scope.scope.status == 1" @click="handleCancel(scope.scope)" fn="取消">
取消
</GLButton>
<GLButton type="text" size="small" v-show="scope.scope.putStatus == 1 && scope.scope.deliveryStatus == 2" @click="handleWarehousing(scope.scope)" fn="入库">入库</GLButton>
<!-- <el-button type="text" v-show="scope.scope.status == 1" @click="handleCancel(scope.scope)">取消</el-button> -->
</div>
</GLTable>
<!-- 表格区域 end -->
</div>
<orderDeatilDialog :visible.sync="detailVisible" :paramsObj="paramsObj"></orderDeatilDialog>
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import orderDeatilDialog from './components/orderDetailDialog'
import { defaultStatusOptions, defaultDeliveryStatusOptions, defaultPutStatusOptions, tableData } from '@/utils/constants.js'
export default {
name: 'PurchaseOrder',
components: {
orderDeatilDialog
},
data() {
return {
size: 'small',
url: url,
searchForm: {
status: '',
deliveryStatus: '',
putStatus: '',
merchantId: '',
putMerchantId: '',
sortType: 1,
orderTimeStr: [],
putTimeStr: [],
placeOrderTimeStr: [],
warehousingTimeStr: []
},
tableSearchForm: {},
paramsObj: {},
// 查看门店
detailVisible: false,
tableData: tableData,
showFormData: [
{
label: '订单编号',
name: 'orderCode',
type: 'input',
isClear: true
},
{
label: '订单状态',
name: 'status',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'label',
optionsName: 'defaultStatusOptions'
},
{
label: '发货状态',
name: 'deliveryStatus',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'label',
optionsName: 'defaultDeliveryStatusOptions'
},
{
label: '入库状态',
name: 'putStatus',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'label',
optionsName: 'defaultPutStatusOptions'
},
{
label: '下单时间',
name: 'placeOrderTimeStr',
type: 'datePicker',
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
},
{
label: '入库时间',
name: 'warehousingTimeStr',
type: 'datePicker',
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
},
{
label: '下单门店',
name: 'merchantId',
type: 'select',
optionList: [],
optionId: 'merchantNo',
optionLabel: 'merchantName',
optionsName: 'merchantName'
},
{
label: '入库门店',
name: 'putMerchantId',
type: 'select',
optionList: [],
optionId: 'merchantNo',
optionLabel: 'merchantName',
optionsName: 'merchantName'
}
],
// 表格
getListApi: this.$apis.purchaseShopping.getPurchaseOrderList,
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '订单编号',
prop: 'orderCode',
width: '200'
},
{
label: '订单总价',
prop: 'totalPrice',
formatter: cellValue => {
return '¥' + cellValue.totalPrice
},
width: 100
},
{
label: '下单时间',
prop: 'orderTime',
formatter: cellValue => {
return dayjs(cellValue.orderTime).format('YYYY-MM-DD HH:mm:ss')
},
width: 180
},
{
label: '下单门店',
prop: 'merchantName',
minWidth: 150
},
{
label: '发货状态',
prop: 'deliveryStatus',
addHtml: 'deliveryStatus',
width: 120
},
{
label: '承运公司',
prop: 'deliveryCompany',
formatter: cellValue => {
return cellValue.deliveryCompany || '--'
},
minWidth: 120
},
{
label: '承运单号',
prop: 'deliveryNumber',
formatter: cellValue => {
return cellValue.deliveryNumber || '--'
},
width: 120,
line: 1
},
{
label: '入库状态',
prop: 'putStatus',
addHtml: 'putStatus',
width: 120
},
{
label: '入库时间',
prop: 'putTime',
formatter: cellValue => {
return cellValue.putTime ? dayjs(cellValue.putTime).format('YYYY-MM-DD HH:mm:ss') : '--'
},
width: 180
},
{
label: '入库门店',
prop: 'putMerchantName',
line: 1,
width: 150,
formatter: cellValue => {
return cellValue.putMerchantName || '--'
}
},
{
label: '订单状态',
prop: 'status',
addHtml: 'status',
width: 120
},
{
label: '操作',
width: '180px',
addHtml: 'auth-button'
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
// 基本数据
baseData: {
defaultStatusOptions: defaultStatusOptions,
defaultDeliveryStatusOptions: defaultDeliveryStatusOptions,
defaultPutStatusOptions: defaultPutStatusOptions,
merchantName: []
}
}
},
mounted() {
this.$apis.purchaseShopping.getMerchantList({}).then(res => {
this.baseData.merchantName = res
this.getOptionsList('showFormData')
})
},
methods: {
getParams() {
var params = JSON.parse(JSON.stringify(this.searchForm))
console.log(this.searchForm)
if (this.searchForm.placeOrderTimeStr.length) {
params.orderTimeStr[0] = new Date(this.searchForm.placeOrderTimeStr[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.orderTimeStr[1] = new Date(this.searchForm.placeOrderTimeStr[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
if (this.searchForm.warehousingTimeStr.length) {
params.putTimeStr[0] = new Date(this.searchForm.warehousingTimeStr[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.putTimeStr[1] = new Date(this.searchForm.warehousingTimeStr[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
delete params.placeOrderTimeStr
delete params.warehousingTimeStr
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
delete this.tableSearchForm.warehousingTimeStr
delete this.tableSearchForm.placeOrderTimeStr
resolve()
})
},
// 入库
handleWarehousing(row) {
this.$confirm('订单入库后自动更新对应的库存,可在入库管理中查看记录。是否确定入库?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$apis.purchaseShopping
.purchaseOrderPutIn({
orderCode: row.orderCode
})
.then(res => {
this.$notify({
type: 'success',
title: '操作成功'
})
this.$refs.orderRef.refreshTable()
})
.catch(() => {})
})
},
secondConfirm(title, txt, apiModule, apiName, apiParams, fn) {
this.$confirm(txt, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis[apiModule][apiName](apiParams).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
fn && fn()
this.handleSearch()
}
})
}
}
})
},
// 查看详情
handleDetail(row) {
this.paramsObj = {
orderCode: row.orderCode,
merchantName: row.merchantName
}
this.detailVisible = true
},
//取消
handleCancel(row) {
this.secondConfirm('取消', '订单取消后即自动作废该订单,且无法撤回。是否确定取消?', 'purchaseShopping', 'purchaseOrderCancelOrCheck', { orderCode: row.orderCode, operateType: 2 })
},
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = this[formName].find(k => k.name == refreshSigle)
var index = this[formName].findIndex(k => k.name == refreshSigle)
this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
} else {
this[formName].forEach((item, index) => {
if (item.type === 'select' && this.baseData[item.optionsName].length) {
this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
}
})
}
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.orderRef.data.length ? (this.$refs.orderRef.tableHeightValues = '') : this.$refs.orderRef.setTableHeightFun()
},
// 创建采购
handleCreatePurchase() {
this.$router.push('/purchaseOrder/add')
},
exportExcel() {
var params = this.getParams()
this.$apis.purchaseShopping.exportExcel(params).then(res => {
window.location.href = res
})
},
handleSearch() {
this.$refs.orderRef.refreshTable()
},
handleReset() {
this.searchForm = {
status: '',
deliveryStatus: '',
putStatus: '',
merchantId: '',
putMerchantId: '',
sortType: 1,
orderTimeStr: [],
putTimeStr: [],
placeOrderTimeStr: [],
warehousingTimeStr: []
}
this.handleSearch()
}
}
}
</script>
<style scoped lang="scss">
@import '@/assets/css/mixin.scss';
.purchase {
.table-header {
display: flex;
align-items: center;
margin-bottom: 25px;
margin-top: 20px;
h2 {
font-weight: 600;
font-size: 16px;
color: #333;
}
.glbtn {
left: 46px;
position: absolute;
}
.btn {
right: 47px;
position: absolute;
}
}
.greenSpot {
@include dot;
background: $color-green;
}
.yellowSpot {
@include dot;
background: $color-yellow;
}
.ashSpot {
@include dot;
background: $color-gray;
}
.table-btns ::v-deep.el-button--text {
min-width: 0 !important;
padding: 0;
}
}
</style>