parentIndex.vue
10.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
<template>
<div class="container">
<div class="find_wrap">
<GLCombiForm ref="showSearch" :formObj="searchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
</div>
<div class="table_wrapper">
<div class="operate_wrap">
<span class="table_title">合同列表</span>
<div class="operate_btn">
<el-button type="primary" plain :size="size" @click="handleExport">导出</el-button>
</div>
</div>
<GLTable ref="equityRef" :getListApi="getListApi" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<div slot="serviceContent" slot-scope="scope">
<div v-html="scope.scope.serviceContent"></div>
</div>
<span slot="auth-button" slot-scope="scope" :data="scope.scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</span>
</GLTable>
</div>
<pdf-dialog :isVisible="isPdfVisible" title="合同" :pdfUrl="pdfUrl" @closeDialog="handlePdfClose"></pdf-dialog>
<changeContractDialog v-if="changeContractObj.visible" @closeDialog="closeTmplDialog" :changeContractObj="changeContractObj"></changeContractDialog>
<GLDialog :visible.sync="tipObj.visible" :close-on-click-modal="false" mode="small" title="提示" @onOk="toInitTmpl" @onCancel="closeTipDialog" :before-close="closeTipDialog">
<div class="tip-body">
<i class="el-icon-warning icon"></i>
<p class="title">是否确认初始化?</p>
<p class="content">选中的商品合同模板将初始化,读取后台的最新配置</p>
</div>
</GLDialog>
</div>
</template>
<script>
const throttle = function (fn, time) {
let timer = null
time = time || 1000
return function (...args) {
if (timer) {
return
}
const _this = this
timer = setTimeout(() => {
timer = null
}, time)
fn.apply(_this, args)
}
}
import * as dayjs from 'dayjs'
import utils from '../../util/util'
import pdfDialog from '@/views/beforeSale/pdfDialog'
import changeContractDialog from './components/changeContractDialog'
export default {
name: 'goodIndex',
components: {
pdfDialog,
changeContractDialog
},
data() {
return {
size: 'small',
tipObj: {
visible: false,
ids: []
},
isPdfVisible: false,
changeContractObj: {
visible: false,
id: '',
isParent: true
},
buttonList: [
{
type: 'el-button',
name: row => {
return '打印'
},
attrs: {
type: 'text'
},
listeners: {
click: row => this.handlePdf(row.scope)
}
},
{
type: 'el-button',
name: row => {
return '编辑'
},
attrs: {
type: 'text'
},
listeners: {
click: row => this.editContract(row.scope)
}
},
{
type: 'el-button',
name: row => {
return '更换合同'
},
attrs: {
type: 'text',
fn: '更换模板'
},
listeners: {
click: row => this.changeContractTMPL(row.scope)
}
},
{
type: 'el-button',
name: row => {
return '模板初始化'
},
attrs: {
type: 'text',
fn: '模板初始化'
},
listeners: {
click: row => this.initTmpl(row.scope)
}
},
{
type: 'el-button',
name: row => {
return '套餐详情'
},
attrs: {
type: 'text',
fn: '套餐详情'
},
listeners: {
click: row => this.parentDetail(row.scope)
}
}
],
searchForm: {
parentId: '',
parentName: '',
createdDate: '',
updatedDate: ''
},
tableSearchForm: {},
searchFormData: [
{
label: '套餐ID',
name: 'parentId',
type: 'input',
isClear: true
},
{
label: '套餐名称',
name: 'parentName',
type: 'input',
isClear: true
},
{
label: '创建时间',
name: 'createdDate',
type: 'datePicker',
labelWidth: 95,
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
},
{
label: '更新时间',
name: 'updatedDate',
type: 'datePicker',
labelWidth: 95,
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
}
],
// 表格
getListApi: this.$apis.contractManager.getProdPackageListApi,
tableParams: {
listName: 'list',
// mutiSelectName: 'tmplIndex',
// mutiSelectUniqueKey: 'id',
tableOption: true,
tableColumns: [
{
label: '套餐ID',
prop: 'parentId',
width: 220
},
{
label: '套餐名称',
prop: 'parentName',
width: 200
},
{
label: '套餐合同编号',
prop: 'id',
width: 180
},
{
label: '上架门店',
prop: 'merchantName',
width: 216,
line: 1
},
{
label: '权益商品',
prop: 'packageName',
width: 260,
line: 1
},
{
label: '创建时间',
prop: 'createdDate',
formatter: cellValue => {
return cellValue.createdDate ? dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss') : '--'
},
width: 180
},
{
label: '更新时间',
prop: 'updatedDate',
formatter: cellValue => {
return cellValue.updatedDate ? dayjs(cellValue.updatedDate).format('YYYY-MM-DD HH:mm:ss') : '--'
},
width: 180
},
{
label: '操作人',
prop: 'updatedBy',
width: 140
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
routerInfo: {}
}
},
mounted() {},
methods: {
closeTmplDialog() {
this.changeContractObj.visible = false
this.handleSearch()
},
initTmpl(row) {
this.tipObj = {
visible: true,
ids: [row.id]
}
},
toInitTmpl() {
const params = {
templateIds: this.tipObj.ids,
baseFlag: 2
}
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
this.$apis.contractManager
.initProdPackageApi(params)
.then(res => {
if (res) {
this.$message.success('初始化模板成功')
this.closeTipDialog()
}
})
.finally(end => {
loading.close()
})
},
closeTipDialog() {
this.tipObj = {
visible: false,
ids: []
}
this.handleSearch()
},
changeContractTMPL(row) {
this.changeContractObj = {
visible: true,
id: row.id,
isParent: true // 是套餐合同
}
},
getParams() {
let params = JSON.parse(JSON.stringify(this.searchForm))
if (this.searchForm?.createdDate?.length) {
params.beginCreateDate = new Date(this.searchForm.createdDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endCreateDate = new Date(this.searchForm.createdDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
if (this.searchForm?.updatedDate?.length) {
params.beginUpdateDate = new Date(this.searchForm.updatedDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endUpdateDate = new Date(this.searchForm.updatedDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
delete params.createdDate
delete params.updatedDate
return { ...params }
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
handlePdfClose() {
this.isPdfVisible = !this.isPdfVisible
},
// 打印
handlePdf(row) {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
this.$apis.contractManager.printContractApi({ packageCode: row.parentId, merchantId: row.merchantId, baseFlag: 2 }).then(res => {
this.pdfUrl = res
this.handlePdfClose()
loading.close()
})
},
// 导出
handleExport: throttle(function () {
var params = this.getParams()
this.$apis.contractManager.exportProdPackageApi(params).then(res => {
// window.open(res)
let tempaa = utils.getExplorer()
if (tempaa == 'QQ') {
window.open(res)
} else {
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = res
document.body.appendChild(iframe)
}
})
}, 1000),
handleSearch() {
this.$refs.equityRef.refreshTable()
},
handleReset() {
this.searchForm = {
parentId: '',
parentName: '',
createdDate: '',
updatedDate: ''
}
this.handleSearch()
},
editContract(row) {
const { id } = row || {}
let query = {
id,
isParent: true
}
const queryStr = encodeURIComponent(JSON.stringify(query))
this.$router.push('/ContractManager/addTmpl/' + queryStr)
},
// 套餐详情
parentDetail(row) {
const { parentId } = row || {}
let query = {
parentId
}
const queryStr = encodeURIComponent(JSON.stringify(query))
this.$router.push({ path: '/ContractManager/parentDetail/' + queryStr })
}
}
}
</script>
<style lang="scss" scoped>
.find_wrap {
background: #ffffff;
padding: 20px 20px 2px 20px;
.resetBtn {
background: #ffffff;
color: #2a58ad;
border: 1px solid #2a58ad;
}
.m-r-l-20 {
margin: 0 20px;
}
}
.table_wrapper {
background: #ffffff;
padding: 0 20px 20px;
}
.tip-body {
width: 100%;
text-align: center;
.icon {
font-size: 48px;
color: #2a58ad;
margin-top: 18px;
}
.title {
font-weight: 400;
font-size: 16px;
color: #333333;
text-align: center;
margin: 12px 0 8px;
}
.content {
font-weight: 400;
font-size: 14px;
color: #666666;
text-align: center;
}
}
</style>