index.vue
5.18 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
<template>
<div class="channel-wrap">
<div class="container">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<GLTable ref="channelRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
<div slot="publicityImg" class="table-image" slot-scope="scope">
<el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.publicityImg" />
<img class="img-36 pointer" slot="reference" :src="scope.scope.publicityImg" />
</el-popover>
</div>
<template slot="activityLink" slot-scope="scope">
<span class="relink">{{ scope.scope.activityName }}</span>
</template>
<template slot="moveCarCodeCount" slot-scope="scope">
<span class="moveCarCodeCount" @click="opneMoveMessage(scope.scope)">{{ scope.scope.moveCarCodeCount }}</span>
</template>
<template slot="switch" slot-scope="scope">
<el-switch v-model="scope.scope.isOpen" @change="updateState(scope.scope)"></el-switch>
</template>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button>
</div>
</GLTable>
</div>
</div>
</template>
<script>
import url from '@/assets/empty.png'
import * as dayjs from 'dayjs'
export default {
name: 'App',
data() {
return {
tableSearchForm: {
channelName: '',
createDate: []
},
searchForm: {},
url: url,
searchFormData: [
{
label: '频道名称',
name: 'channelName',
type: 'input'
},
{
label: '创建时间',
name: 'createDate',
type: 'datePicker',
isClear: true,
customPickerOptions: {
disabledDate(date) {
const yesterday = new Date(new Date().setDate(new Date().getDate()))
if (date > yesterday) {
return true
}
return false
}
}
}
],
getListApi: this.$apis.channel.getChannelListApi,
tableParams: {
listName: 'list',
// tableOption: true,
tableColumns: [
{
label: '频道名称',
prop: 'channelName',
formatter: cellValue => {
return cellValue.channelName || '--'
}
},
{
label: '频道子名称',
width: 180,
prop: 'channelChildName'
},
{
label: '频道宣传语',
prop: 'promotion',
width: 300,
line: 1,
formatter: cellValue => {
return cellValue.promotion || '--'
}
},
{
label: '宣传图',
prop: 'publicityImg',
addHtml: 'publicityImg'
},
{
label: '关联门店',
width: 100,
prop: 'linkMerchantCnt',
formatter: cellValue => {
return cellValue.linkMerchantCnt || '--'
}
},
{
label: '创建日期',
width: 220,
prop: 'createdDate',
formatter: cellValue => {
return dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss')
}
},
{
label: '操作',
addHtml: 'auth-button',
fixed: 'right',
width: 100
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }
}
},
created() {},
mounted() {},
methods: {
getParams() {
var params = JSON.parse(JSON.stringify(this.tableSearchForm))
if (this.tableSearchForm.createDate.length) {
params.createdDateStrat = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.createdDateEnd = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchForm = this.getParams()
delete this.searchForm.createDate
resolve()
})
},
handleSearch() {
this.$refs.channelRef.refreshTable()
},
handleReset() {
this.tableSearchForm = {
channelName: '',
createDate: []
}
this.searchForm = {}
this.handleSearch()
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.channelRef.data.length ? (this.$refs.channelRef.tableHeightValues = '') : this.$refs.channelRef.setTableHeightFun()
},
handleEdit(val) {
this.$router.push({
path: `/channel/add?id=${val.id}&channelType=${val.channelType}&$title=频道设置`
})
}
}
}
</script>
<style scoped lang="scss">
.channel-wrap {
}
</style>