service.vue
10.4 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
<template>
<div class="live-room">
<!-- //提示面板组件 -->
<tip-panel panelWidth="616px" panelMinHeight="60px" :panelContent="panelContent" v-if="isFirstShow" @closePanel="closePanel"></tip-panel>
<div class="live-room container">
<el-form :inline="true" style="width: 100%" :model="searchForm" label-width="70px" label-position="right">
<el-row>
<!-- <el-form-item size="small"> -->
<!-- <el-button :size="size" type="primary" icon="el-icon-plus" @click="handleCreate">创建服务</el-button>display="disabled" -->
<GLButton type="primary" @click="handleCreate" style="margin-right: 30px" size="small" icon="el-icon-plus" fn="创建服务" mode="el-button">创建服务</GLButton>
<!-- </el-form-item> -->
<el-form-item size="small" label="服务名称">
<el-input :size="size" v-model="searchForm.couponName" placeholder="请输入服务名称" clearable></el-input>
</el-form-item>
<el-form-item size="small" class="fr-mr0">
<el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
<el-button :size="size" @click="handleReset">重置</el-button>
</el-form-item>
</el-row>
</el-form>
<GLTable v-if="isReload" ref="memberServiceRef" :noDataImg="url" @setTableFinishFun="setTableFinishFun" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<span slot="effectiveType" slot-scope="scope">
<span>{{ toLabelText(scope.scope) }}</span>
</span>
<span slot="useType" slot-scope="scope">
<span>{{ toRestrictLabelText(scope.scope) }}</span>
</span>
<span class="table-btns" slot="auth-button" slot-scope="scope" :data="scope.scope">
<template v-if="scope.scope.status == 2">
<!-- <el-button type="text" @click="handleLossOption(scope.scope)">失效</el-button>
<el-button type="text" @click="handleLook(scope.scope)">查看</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button> -->
<GLButton type="text" @click="handleLossOption(scope.scope)" fn="失效">失效</GLButton>
<GLButton type="text" @click="handleLook(scope.scope)" fn="查看服务">查看</GLButton>
<GLButton type="text" @click="handleDelete(scope.scope)" fn="删除">删除</GLButton>
</template>
<template v-else-if="scope.scope.status == 3">
<!-- <el-button type="text" @click="handleLook(scope.scope)">查看</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button> -->
<GLButton type="text" @click="handleLook(scope.scope)" fn="查看服务">查看</GLButton>
<GLButton type="text" @click="handleDelete(scope.scope)" fn="删除">删除</GLButton>
</template>
<template v-else>
<!-- <el-button type="text" @click="handleTakeOption(scope.scope)">生效</el-button>
<el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button> -->
<GLButton type="text" @click="handleTakeOption(scope.scope)" fn="生效">生效</GLButton>
<GLButton type="text" @click="handleEdit(scope.scope)" fn="编辑服务">编辑</GLButton>
<GLButton type="text" @click="handleDelete(scope.scope)" fn="删除">删除</GLButton>
</template>
</span>
</GLTable>
</div>
</div>
</template>
<script>
import { getServiceListApi, effectiveService, deleteService, getLoginCount } from '@/api/modules/service'
import url from '@/assets/empty.png'
import { serviceStatusList } from '@/common/constant'
import tipPanel from '@/components/tipPanel/index.vue'
export default {
components: {
tipPanel
},
data() {
return {
url: url,
isReload: true,
isFirstShow: false,
panelContent: '会员服务:是由门店根据自店服务项目创建的线上服务券,如“一年十二次洗车券”、“陶瓷镀膜”等,客户购买后可到店出示服务券享受服务,门店扫码进行次数核销。',
size: 'small',
getListApi: getServiceListApi,
searchForm: {
couponName: '',
merchantId: 44184606,
discountType: 7 //6:商品折扣券,7:会员服务
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
// 行数据的key
// mutiSelectUniqueKey: 'id',
// 多选ref的名称
// mutiSelectName: 'list',
tableOption: true,
tableColumns: [
{
label: '服务名称',
prop: 'couponName',
width: '180'
},
{
label: '会员价(元)',
prop: 'vipPrice',
line: 1
},
{
label: '预估成本/元',
prop: 'anticipatedCost ',
formatter: cellValue => {
return cellValue.anticipatedCost / 100
}
},
{
label: '有效期',
prop: 'effectiveType',
addHtml: 'effectiveType'
},
{
label: '使用限制',
prop: 'useType',
addHtml: 'useType'
},
{
label: '剩余库存',
prop: 'residueAmount',
line: 1
// addHtml: 'activeTime'
},
{
label: '状态',
prop: 'status',
// width: '80',
formatter: cellValue => {
return this.baseDataList.serviceStatusList.find(item => item.confId == cellValue.status).confName
}
},
{
label: '创建时间',
prop: 'createdDate',
width: 95
}
]
},
baseDataList: {
serviceStatusList: serviceStatusList
},
merchantId: 44184606
}
},
created() {
if (window.__POWERED_BY_QIANKUN__) {
//运行在qiankun容器中
this.merchantId = this.$globalState.session.merchantId
this.searchForm.merchantId = this.merchantId
}
this.getLoginCountFun()
},
mounted() {},
methods: {
getLoginCountFun() {
//loginType:4是查会员服务浏览次数
getLoginCount({ loginType: 4 }).then(res => {
//获取是否第一次点击该页面
this.isFirstShow = res
})
},
closePanel() {
this.isFirstShow = false
},
toLabelText(row) {
switch (row.effectiveType) {
case 3:
return '永久有效'
case 2:
return row.effectiveStartTime ? row.effectiveStartTime.split(' ')[0] + '-' + row.effectiveEndTime.split(' ')[0] : ''
case 1:
return row.effectiveDays + '天'
}
},
toRestrictLabelText(row) {
switch (row.useType) {
case 0:
return '无限制'
case 1:
return '有效期内可使用' + row.useAmount + '次'
case 2:
return '每' + row.useLimitDays + '天可以使用' + row.useAmount + '次'
}
},
handleReset() {
this.isReload = false
this.searchForm = { couponName: '', merchantId: this.merchantId, discountType: 7 }
// this.handleSearch()
this.$nextTick(() => {
this.isReload = true
})
},
handleSearch() {
this.$refs.memberServiceRef.refreshTable()
},
setTableFinishFun(content) {
// console.log(content, this.$refs.memberServiceRef.data.length, '获取数据')
//接收到的数据为空
// if (!this.$refs.memberServiceRef.data.length) {
// this.$refs.memberServiceRef.setTableHeightFun()
// }
this.$refs.memberServiceRef.data.length ? (this.$refs.memberServiceRef.tableHeightValues = '') : this.$refs.memberServiceRef.setTableHeightFun()
},
//创建服务
handleCreate() {
this.$router.push({
path: '/memberCenter/serviceAddUpdateLook',
query: {
$title: encodeURI('创建服务')
}
})
},
//失效
handleLossOption(row) {
this.$messageBox.confirm('是否失效该服务?', '失效', {
confirmButtonText: '确定',
cancelButtonText: '取消',
// type: 'error',
callback: action => {
if (action == 'confirm') {
effectiveService({ couponId: row.id, status: 3 }).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleSearch()
}
})
}
}
})
},
//生效
handleTakeOption(row) {
effectiveService({ couponId: row.id, status: 2 }).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/serviceAddUpdateLook',
query: {
couponId: row.id,
title: '编辑',
$title: encodeURI('编辑服务')
}
})
},
handleLook(row) {
this.$router.push({
path: '/memberCenter/serviceAddUpdateLook',
query: {
couponId: row.id,
title: '查看',
$title: encodeURI('查看服务')
}
})
},
handleDelete(row) {
this.$messageBox.confirm('是否删除该服务?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
// type: 'error',
callback: action => {
if (action == 'confirm') {
deleteService({ couponId: row.id, merchantId: this.merchantId }).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>
/deep/.el-input--small .el-input__inner {
width: 215px;
}
</style>