setmeal.vue
10.3 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
<template>
<div class="live-room">
<tip-panel panelWidth="616px" panelMinHeight="40px" :panelContent="panelContent" v-if="isFirstShow" @closePanel="closePanel"></tip-panel>
<div class="live-room container">
<div class="btnWrap">
<!-- <el-button :size="size" type="primary" @click="handleCreate" icon="el-icon-plus">创建套餐</el-button> -->
<GLButton type="primary" @click="handleCreate" size="small" icon="el-icon-plus" fn="创建套餐" mode="el-button">创建套餐</GLButton>
<el-button :size="size" @click="showViewer=true">查看示例效果</el-button>
<el-image-viewer v-if="showViewer" :on-close="()=>{showViewer=false}" :url-list="srcList" style="padding:4%;"/>
</div>
<GLTable ref="memberSetMealRef" :noDataImg="url" @setTableFinishFun="setTableFinishFun" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<span slot="list" slot-scope="scope">
<div v-for="(item, index) in scope.scope.list" :key="index">{{ item.couponName }}×{{ item.serviceQuantity }}</div>
</span>
<span class="table-btns" slot="optionsFun" slot-scope="scope" :data="scope.scope">
<template v-if="scope.scope.state === 0">
<!-- <el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button>
<el-button type="text" @click="handleUpOption(scope.scope)">上架</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button> -->
<GLButton type="text" @click="handleEdit(scope.scope)" fn="编辑套餐">编辑</GLButton>
<GLButton type="text" @click="handleUpOption(scope.scope)" fn="上架">上架</GLButton>
<GLButton type="text" @click="handleDelete(scope.scope)" fn="删除">删除</GLButton>
</template>
<template v-else-if="scope.scope.state === 1">
<!-- <el-button type="text" @click="handleDownOption(scope.scope)">下架</el-button>
<el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button> -->
<GLButton type="text" @click="handleDownOption(scope.scope)" fn="下架">下架</GLButton>
<GLButton type="text" @click="handleEdit(scope.scope)" fn="编辑套餐">编辑</GLButton>
</template>
<template v-else>
<!-- <el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button>
<el-button type="text" @click="handleUpOption(scope.scope)">上架</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button> -->
<GLButton type="text" @click="handleEdit(scope.scope)" fn="编辑套餐">编辑</GLButton>
<GLButton type="text" @click="handleUpOption(scope.scope)" fn="上架">上架</GLButton>
<GLButton type="text" @click="handleDelete(scope.scope)" fn="删除">删除</GLButton>
</template>
</span>
</GLTable>
</div>
<!-- btnCancelLabel="关闭" -->
<glsx-dialog title="示例效果" width="1142px" :hasScroll="false" :noBtnOk="true" :noCancel="true" :noClose="false" typeName="primary" btnSize="small" :isVisible="isDialogVisible" :showClose="false" @closeDialog="handleClose" @confirmDialog="handleClose">
<div class="content-body">
<div class="content-item col1">
<div class="subTitle">1、管理后台先创建套餐</div>
<div class="imageWrap">
<img src="@/assets/table.png" alt="" />
</div>
</div>
<div class="content-item col2">
<div class="subTitle">2、小程序端进行展示</div>
<div class="twoImageWrap">
<img src="@/assets/card1.png" alt="" />
<img src="@/assets/card2.png" alt="" />
</div>
</div>
</div>
</glsx-dialog>
</div>
</template>
<script>
import glsxDialog from '@/components/glsx-dialog'
import url from '@/assets/empty.png'
import { getSetMealListApi, deleteSetMeal, upDownPackage } from '@/api/modules/setmeal'
import { getLoginCount } from '@/api/modules/service'
import { stateList } from '@/common/constant'
import tipPanel from '@/components/tipPanel/index.vue'
export default {
components: {
tipPanel,
glsxDialog,
'el-image-viewer':()=>import('element-ui/packages/image/src/image-viewer')
},
data() {
return {
showViewer:false,
url: url,
surl: 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/memberCase.png',
srcList: ['https://img01.glsx.com.cn/weapp/resource/saas/scrm/memberCase.png'],
isFirstShow: false,
panelContent: '会员套餐:将已经创建好的会员服务打包成一个套餐售卖给客户。',
size: 'small',
getListApi: getSetMealListApi,
searchForm: {
merchantId: 44184606
// merchantName
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
// tableOption: true,
tableColumns: [
{
label: '套餐名称',
prop: 'packageName',
width: '180'
},
{
label: '套餐售价',
prop: 'packagePrice',
line: 1
},
{
label: '套餐总价',
prop: 'referencePrice'
},
{
label: '套餐内容',
prop: 'list',
addHtml: 'list'
},
{
label: '说明',
prop: 'notes',
width:160,
line: 4
},
{
label: '状态',
prop: 'state',
width: '80',
formatter: cellValue => {
return this.baseDataList.stateList.find(item => item.confId == cellValue.state).confName
}
},
{
label: '操作',
prop: 'optionsFun',
addHtml: 'optionsFun',
width: 160
}
]
},
baseDataList: {
stateList: stateList
},
//查看示例 --弹窗
isDialogVisible: false
}
},
created() {
this.getLoginCountFun()
},
mounted() {},
methods: {
previewPic() {
this.$refs.previewImg.showViewer = true
},
getLoginCountFun() {
//loginType:5是查会员套餐浏览次数
getLoginCount({ loginType: 5 }).then(res => {
//获取是否第一次点击该页面
this.isFirstShow = res
})
},
closePanel() {
this.isFirstShow = false
},
handleReset() {
this.searchForm = {
merchantId: 44184606
}
this.handleSearch()
},
handleSearch() {
this.$refs.memberSetMealRef.refreshTable()
},
setTableFinishFun() {
//接收到的数据为空
if (!this.$refs.memberSetMealRef.data.length) {
this.$refs.memberSetMealRef.setTableHeightFun()
}
},
//创建套餐
handleCreate() {
this.$router.push({
path: '/memberCenter/setmealAddUpdate',
query: {
$title: encodeURI('创建套餐')
}
})
},
handleClose() {
this.isDialogVisible = !this.isDialogVisible
},
//上架
handleUpOption(row) {
var params = {}
params.id = row.id
params.state = 1
upDownPackage(params).then(res => {
this.$message({
message: res.code == '0' ? '上架成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleSearch()
}
})
},
handleDownOption(row) {
var params = {}
params.id = row.id
params.state = 2
this.$messageBox.confirm('下架后将隐藏且客户不能购买该套餐,已经购买的客户仍继续享有该套餐的服务?', '下架', {
confirmButtonText: '确定',
cancelButtonText: '取消',
// type: 'error',
callback: action => {
if (action == 'confirm') {
upDownPackage(params).then(res => {
this.$message({
message: res.code == '0' ? '下架成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleSearch()
}
})
}
}
})
},
handleEdit(row) {
this.$router.push({ path: '/memberCenter/setmealAddUpdate', query: { id: row.id, $title: encodeURI('编辑套餐') } })
},
// 查看示例效果
handleLook(row) {},
handleDelete(row) {
this.$messageBox.confirm('是否删除该套餐?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
// type: 'error',
callback: action => {
if (action == 'confirm') {
deleteSetMeal({ id: row.id }).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleSearch()
}
})
}
}
})
}
}
}
</script>
<style lang="scss" scoped>
.btnWrap {
margin-bottom: 20px;
}
/deep/ .el-dialog__header {
.main-title {
font-size: 16px;
font-weight: 700;
color: #000000;
}
}
/deep/ .el-dialog__body {
border-top: 1px solid #e6e6e6;
border-bottom: 1px solid #e6e6e6;
padding: 20px 25px;
.content-body {
display: flex;
.col2 {
margin-left: 40px;
}
.content-item {
.subTitle {
margin-bottom: 20px;
font-size: 18px;
font-weight: 700;
color: #000000;
}
.imageWrap,
.twoImageWrap {
margin-left: 25px;
img {
border: 1.5px solid rgba(0, 0, 0, 0.03);
box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.03);
}
img + img {
margin-left: 22px;
}
}
}
}
}
/deep/ .el-dialog__footer {
text-align: center;
padding: 20px;
}
/* 大图预览的关闭图标 改为大一点的白色 */
/deep/.el-image-viewer__btn.el-image-viewer__close {
color: #5850ff;
opacity: unset;
top: 50px;
right: 50px;
width: 40px;
height: 40px;
font-size: 40px;
}
</style>