index.vue
10.7 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
<template>
<div class="task-contentbox">
<div>
<el-form :inline="true" :model="searchForm">
<el-form-item label="业务场景:">
<el-select v-model="searchForm.businessScene" size="small">
<el-option
v-for="(item, index) in sceneOption"
:key="index"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="商户:">
<el-input
v-model="searchForm.merchantName"
size="small"
placeholder="请输入商户名称"
></el-input>
</el-form-item>
<el-form-item label="活动/产品:">
<el-input
v-model="searchForm.activityName"
size="small"
placeholder="请输入活动/产品名称"
></el-input>
</el-form-item>
<el-form-item label="状态:">
<el-select v-model="searchForm.activityStatus" size="small">
<el-option
v-for="(item, index) in taskStatus"
:key="index"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="handleSearch"
>查询
</el-button>
<el-button plain size="small" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</div>
<div class="table-top">
<div class="table-title">订单列表</div>
<el-button type="primary" size="small" @click="handleEdit()"
>添加任务</el-button
>
</div>
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane
:label="'全部' + '(' + listCount.totalCount + ')'"
name="first"
></el-tab-pane>
<el-tab-pane
:label="'未发布' + '(' + listCount.draftCount + ')'"
:name="statusNum.UNPUBLISH"
></el-tab-pane>
<el-tab-pane
:label="'已发布' + '(' + listCount.upCount + ')'"
:name="statusNum.PUBLISHED"
></el-tab-pane>
<el-tab-pane
:label="'已结束' + '(' + listCount.downCount + ')'"
:name="statusNum.FINISHIED"
></el-tab-pane>
</el-tabs>
<div>
<d2-table
ref="taskTable"
:searchForm="searchForm"
:getListApi="getListApi"
:tableParams="tableParams"
:pageConf="pageConf"
>
<div slot="businessScene" slot-scope="scope">
<span v-if="scope.scope.businessScene == 0">1.0车损升级</span>
<span v-if="scope.scope.businessScene == 1">1.1精品升级</span>
<span v-if="scope.scope.businessScene == 2">1.2膨胀金活动</span>
<span v-if="scope.scope.businessScene == 3">1.3众筹活动</span>
</div>
<div slot="activityStatus" slot-scope="scope">
<span v-if="scope.scope.activityStatus == statusNum.UNPUBLISH"
>未发布</span
>
<span v-if="scope.scope.activityStatus == statusNum.PUBLISHED"
>已发布</span
>
<span v-if="scope.scope.activityStatus == statusNum.FINISHIED"
>已结束</span
>
</div>
<template slot="auth-button" slot-scope="scope">
<el-button
type="text"
v-if="scope.scope.activityStatus != statusNum.FINISHIED"
@click="handleEdit(scope.scope, 1)"
>编辑</el-button
>
<el-button
type="text"
v-if="scope.scope.activityStatus != statusNum.UNPUBLISH"
@click="handleAnalyze(scope.scope)"
>任务分析</el-button
>
<el-button
type="text"
v-if="scope.scope.activityStatus == statusNum.UNPUBLISH"
@click="handleDelete(scope.scope)"
style="color: red"
>删除</el-button
>
<el-button
type="text"
v-if="scope.scope.activityStatus == statusNum.UNPUBLISH"
@click="handleActive(scope.scope)"
>发布</el-button
>
<el-button
type="text"
v-if="scope.scope.activityStatus == statusNum.PUBLISHED"
@click="handleInactive(scope.scope)"
>结束</el-button
>
<el-button type="text" @click="handleClone(scope.scope)"
>复制</el-button
>
<el-button
type="text"
v-if="scope.scope.activityStatus != statusNum.UNPUBLISH"
@click="handleViewDetail(scope.scope)"
>查看</el-button
>
</template>
</d2-table>
</div>
</div>
</template>
<script>
const sceneOption = [
{
label: '全部',
value: '',
},
{
label: '1.0车损升级',
value: '0',
},
{
label: '1.1精品升级',
value: '1',
},
{
label: '1.2膨胀金活动',
value: '2',
},
{
label: '1.3众筹活动',
value: '3',
},
]
const statusNum = {
ALL: '',
UNPUBLISH: '1',
PUBLISHED: '2',
FINISHIED: '3',
}
const taskStatus = [
{
label: '全部',
value: '',
},
{
label: '未发布',
value: statusNum.UNPUBLISH,
},
{
label: '已发布',
value: statusNum.PUBLISHED,
},
{
label: '已结束',
value: statusNum.FINISHIED,
},
]
import { taskApi } from '../../../api/task'
export default {
data() {
return {
// 业务场景选项
sceneOption,
// 状态选项
taskStatus,
statusNum,
searchForm: {
businessScene: '',
merchantName: '',
activityName: '',
activityStatus: '',
},
listCount: {},
// 表格参数
tableParams: {
// btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'data.data',
tableOption: true,
tableColumns: [
{
label: '业务场景',
prop: 'businessScene',
addHtml: 'businessScene',
width: 150,
},
{
label: '商户',
prop: 'merchantName',
width: 150,
},
{
label: '活动/产品',
prop: 'activityName',
width: 200,
},
{
label: '任务数',
prop: 'missionCount',
},
{
label: '创建人',
prop: 'createdBy',
},
{
label: '创建时间',
prop: 'createdTime',
width: 150,
},
{
label: '状态',
prop: 'activityStatus',
addHtml: 'activityStatus',
},
],
},
pageConf: {
pageSize: 'pageSize',
pageNum: 'pageNum',
totalCount: 'data.count',
},
// 活动开始/结束时间
startTime: '',
endTime: '',
// 获取订单列表
getListApi: taskApi.findMissionList,
status: false,
activeName: 'first',
}
},
mounted() {
this.handleSearchTaskNum()
},
methods: {
// 查询任务状态数量
handleSearchTaskNum() {
console.log(222)
taskApi.getStaticMission({}).then((res) => {
console.log(res)
this.listCount = res.data
})
},
// 搜索框搜索
handleSearch() {
this.$refs.taskTable.refreshTable()
},
// 重置搜索框搜索
handleReset() {
this.searchForm = {
businessScene: '',
merchantName: '',
activityName: '',
activityStatus: '',
}
this.$nextTick(() => {
this.$refs.taskTable.refreshTable()
this.activeName = 'first'
})
},
// tab切换
handleTabClick(tab, event) {
this.searchForm.activityStatus = tab.name == 'first' ? '' : tab.name
this.$nextTick(() => {
this.$refs.taskTable.refreshTable(true, true)
})
},
// 编辑
handleEdit(item, type) {
this.status = true
const para = {
task: item,
type,
}
this.$root.to(
['任务中心', '任务平台', '任务管理', '任务模板管理', '*添加任务模板'],
para
)
this.$root.close('任务管理列表')
},
// 删除
handleDelete(scope) {
this.secondConfirm(
'提示',
'任务计划删除后,无法恢复。是否确定删除?',
4,
scope.id
)
},
// 发布
handleActive(scope) {
this.secondConfirm(
'提示',
'任务计划发布后,任务会自动下发给对应的员工。是否确定发布?',
2,
scope.id
)
},
// 结束
handleInactive(scope) {
this.secondConfirm(
'提示',
'任务计划结束后,整个任务计划将无法再使用。是否确定结束?',
3,
scope.id
)
},
// 克隆
handleClone(scope) {
this.$root.to(
['任务中心', '任务平台', '任务管理', '任务模板管理', '*添加任务模板'],
scope
)
this.$root.close('任务管理列表')
},
// 跳转查看详情
handleViewDetail(scope) {
this.$root.to(
['任务中心', '任务平台', '任务管理', '任务模板管理', '*查看任务'],
{ taskId: scope.id }
)
},
// 任务分析
handleAnalyze(scope) {
this.$root.to(
['任务中心', '任务平台', '任务管理', '任务模板管理', '*任务分析'],
{ taskId: scope.id }
)
},
// 二次确认
secondConfirm(title, txt, apiParams, apiId, fn) {
var params = { id: apiId, activityStatus: apiParams }
this.$confirm(txt, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: (action) => {
if (action == 'confirm') {
taskApi.updateStatusMission(params).then((res) => {
console.log(res)
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error',
})
if (res.code == '0') {
this.$nextTick(() => {
this.$refs.taskTable.refreshTable()
})
}
})
}
},
})
},
},
}
</script>
<style lang="scss" scoped>
.task-contentbox {
padding: 20px;
}
.table-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.table-title {
font-size: 16px;
font-weight: 600;
color: rgb(51, 51, 51);
line-height: 16px;
}
/deep/ .el-table .cell {
line-height: 20px;
}
</style>