index.vue
6.48 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
<!-- 带货管理 -->
<template>
<div class="marketing take-good">
<div class="container">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<el-button :size="size" class="default-blue-btn f-right m-b-10" type="default" @click="handleTakeGood()">一键带货</el-button>
<!-- 表格区域 开始 -->
<GLTable ref="takeGoodRef" class="table-img" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
<div slot="goodsImage" slot-scope="scope">
<el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.goods.goodsImage" />
<img class="img-60 pointer" slot="reference" :src="scope.scope.goods.goodsImage" />
</el-popover>
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
<!-- 表格区域 end -->
</div>
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
export default {
name: 'takeGood',
data() {
return {
size: 'small',
url: url,
hideAfter: 100000,
searchForm: {
goodsName: '',
createDate: []
},
tableSearchForm: {},
// 搜索
searchFormData: [
{
label: '商品名称',
name: 'goodsName',
type: 'input',
maxlength: 20
},
{
label: '创建日期',
name: 'createDate',
type: 'datePicker',
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
}
],
// 表格按钮
tableButtonList: [
{
type: 'el-button',
name: '带货',
attrs: {
type: 'text'
},
condition: row => {
return !row.taked
},
listeners: {
click: this.handleSingleTakeGood
}
},
{
type: 'GLButton',
name: '详情',
attrs: {
type: 'text',
fn: '详情'
},
listeners: {
click: this.handleDetail
}
}
],
// 表格
getListApi: this.$apis.takeGood.getListApi,
tableParams: {
listName: 'list',
mutiSelectUniqueKey: 'goodsId',
mutiSelectName: 'takeGood',
checkSelectKey: 'goodsId',
checkSelectVal: [],
tableOption: true,
tableColumns: [
{
label: '商品名称',
prop: 'goodsName',
line: 2,
formatter: cellValue => {
return cellValue.goods.goodsName
}
},
{
label: '缩略图',
prop: 'goodsImage',
addHtml: 'goodsImage'
},
{
label: '供货价',
prop: 'supplyPrice',
formatter: cellValue => {
return (cellValue.goods.supplyPrice / 100).toFixed(2)
}
},
{
label: '创建日期',
prop: 'createdDate',
width: '180',
formatter: cellValue => {
return dayjs(cellValue.goods.createdDate).format('YYYY-MM-DD HH:mm:ss')
}
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' }
}
},
mounted() { },
methods: {
getParams() {
var params = JSON.parse(JSON.stringify(this.searchForm))
if (this.searchForm.createDate.length) {
params.startTime = new Date(this.searchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endTime = new Date(this.searchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
delete params.createDate
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
delete this.tableSearchForm.createDate
resolve()
})
},
setTableFinishFun(table) {
this.tableParams.checkSelectVal = []
table &&
table.forEach(item => {
if (item.taked) {
this.tableParams.checkSelectVal.push(item.goodsId)
}
})
//接收到的数据为空
this.$refs.takeGoodRef.data.length ? (this.$refs.takeGoodRef.tableHeightValues = '') : this.$refs.takeGoodRef.setTableHeightFun()
},
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()
}
})
}
}
})
},
handleSingleTakeGood(row) {
this.secondConfirm('带货', '是否确认带货?', 'takeGood', 'takeGookApi', { takeGoodsIdList: [row.goodsId] })
},
handleTakeGood() {
var selectedList = this.$refs.takeGoodRef.mutiSelectArr[this.tableParams.mutiSelectName]
if (!selectedList.length) {
this.$message({
message: '请勾选要带货的商品',
type: 'error'
})
return true
}
this.secondConfirm('带货', '是否确认带货?', 'takeGood', 'takeGookApi', { takeGoodsIdList: selectedList.map(item => item.goodsId) })
},
handleDetail(row) {
// this.$router.push('/takeGood/takeGoodDetail/' + row.goodsId)
this.$router.push({
path: '/takeGood/takeGoodDetail',
query: {
id: row.goodsId
}
})
},
handleSearch() {
this.$refs.takeGoodRef.refreshTable()
},
handleReset() {
this.searchForm = {
goodsName: '',
createDate: []
}
this.handleSearch()
}
}
}
</script>
<style scoped></style>