|
@@ -0,0 +1,432 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="subPage">
|
|
3
|
+ <form class="mainForm">
|
|
4
|
+ <ul>
|
|
5
|
+ <li class="flex-h">
|
|
6
|
+ <span>选择案场:</span>
|
|
7
|
+ <div class="flex-item">
|
|
8
|
+ <div style="width:50%">
|
|
9
|
+ <el-select v-model="cardInfo.CaseId" placeholder="请选择" @change="caseChange">
|
|
10
|
+ <el-option
|
|
11
|
+ v-for="item in cases"
|
|
12
|
+ :key="item.CaseId"
|
|
13
|
+ :label="item.CaseName"
|
|
14
|
+ :value="item.CaseId">
|
|
15
|
+ </el-option>
|
|
16
|
+ </el-select>
|
|
17
|
+ </div>
|
|
18
|
+ </div>
|
|
19
|
+ </li>
|
|
20
|
+ <li class="flex-h">
|
|
21
|
+ <span>卡图片:</span>
|
|
22
|
+ <div class="flex-item">
|
|
23
|
+ <div>
|
|
24
|
+ <el-upload
|
|
25
|
+ class="avatar-uploader"
|
|
26
|
+ :action='$api.file.image.url'
|
|
27
|
+ :show-file-list="false"
|
|
28
|
+ :on-success="handleAvatarSuccess">
|
|
29
|
+ <img v-if="cardInfo.Images" :src="cardInfo.Images[0].CardImageUrl" class="avatar">
|
|
30
|
+ <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
31
|
+ </el-upload>
|
|
32
|
+ </div>
|
|
33
|
+ </div>
|
|
34
|
+ </li>
|
|
35
|
+ <li class="flex-h">
|
|
36
|
+ <span>卡名称:</span>
|
|
37
|
+ <div class="flex-item">
|
|
38
|
+ <div style="width:200px;">
|
|
39
|
+ <el-input
|
|
40
|
+ placeholder="请输入"
|
|
41
|
+ v-model="cardInfo.CardName"
|
|
42
|
+ clearable>
|
|
43
|
+ </el-input>
|
|
44
|
+ </div>
|
|
45
|
+ </div>
|
|
46
|
+ </li>
|
|
47
|
+ <li class="flex-h">
|
|
48
|
+ <span>卡价格:</span>
|
|
49
|
+ <div class="flex-item">
|
|
50
|
+ <div style="width:200px;">
|
|
51
|
+ <el-input
|
|
52
|
+ placeholder="请输入"
|
|
53
|
+ v-model="cardInfo.Price"
|
|
54
|
+ clearable>
|
|
55
|
+ </el-input>
|
|
56
|
+ </div>
|
|
57
|
+ </div>
|
|
58
|
+ </li>
|
|
59
|
+ <li class="flex-h">
|
|
60
|
+ <span>总张数:</span>
|
|
61
|
+ <div class="flex-item">
|
|
62
|
+ <div style="width:200px;">
|
|
63
|
+ <el-input
|
|
64
|
+ placeholder="请输入"
|
|
65
|
+ v-model="cardInfo.TotalCount"
|
|
66
|
+ clearable>
|
|
67
|
+ </el-input>
|
|
68
|
+ </div>
|
|
69
|
+ </div>
|
|
70
|
+ </li>
|
|
71
|
+ <li class="flex-h">
|
|
72
|
+ <span>发送类型:</span>
|
|
73
|
+ <div class="flex-item">
|
|
74
|
+ <div>
|
|
75
|
+ <el-radio v-model="cardInfo.SendType" label="channel">渠道</el-radio>
|
|
76
|
+ <el-radio v-model="cardInfo.SendType" label="case">案场</el-radio>
|
|
77
|
+ <el-radio v-model="cardInfo.SendType" label="system">系统</el-radio>
|
|
78
|
+ </div>
|
|
79
|
+ </div>
|
|
80
|
+ </li>
|
|
81
|
+ <li class="flex-h" v-if="cardInfo.SendType === 'channel'">
|
|
82
|
+ <span>选择渠道:</span>
|
|
83
|
+ <div class="flex-item">
|
|
84
|
+ <div style="width:50%">
|
|
85
|
+ <el-select v-model="cardInfo.ChannelId" placeholder="请选择">
|
|
86
|
+ <el-option
|
|
87
|
+ v-for="item in channelList"
|
|
88
|
+ :key="item.ChannelId"
|
|
89
|
+ :label="item.ChannelName"
|
|
90
|
+ :value="item.ChannelId">
|
|
91
|
+ </el-option>
|
|
92
|
+ </el-select>
|
|
93
|
+ </div>
|
|
94
|
+ </div>
|
|
95
|
+ </li>
|
|
96
|
+ <li class="flex-h">
|
|
97
|
+ <span>目标课程:</span>
|
|
98
|
+ <div class="flex-item">
|
|
99
|
+ <div>
|
|
100
|
+ <el-select v-model="cardInfo.Targets[0].TargetId" placeholder="请选择">
|
|
101
|
+ <el-option
|
|
102
|
+ v-for="item in courseList"
|
|
103
|
+ :key="item.CourseId"
|
|
104
|
+ :label="item.CourseName"
|
|
105
|
+ :value="item.CourseId"
|
|
106
|
+ :disabled="item.Status !== 1">
|
|
107
|
+ </el-option>
|
|
108
|
+ </el-select>
|
|
109
|
+ </div>
|
|
110
|
+ </div>
|
|
111
|
+ </li>
|
|
112
|
+ <li class="flex-h">
|
|
113
|
+ <span>卡有效时间:</span>
|
|
114
|
+ <div class="flex-item">
|
|
115
|
+ <div>
|
|
116
|
+ <div class="addLine flex-h" style="align-item:center;margin-bottom:20px;">
|
|
117
|
+ <!-- <el-date-picker
|
|
118
|
+ v-model="cardInfo.StartDate"
|
|
119
|
+ type="date"
|
|
120
|
+ placeholder="选择起始日期">
|
|
121
|
+ </el-date-picker>
|
|
122
|
+ <span style="line-height:40px;">至</span>
|
|
123
|
+ <el-date-picker
|
|
124
|
+ v-model="cardInfo.EndDate"
|
|
125
|
+ type="date"
|
|
126
|
+ placeholder="选择截止日期">
|
|
127
|
+ </el-date-picker> -->
|
|
128
|
+ <el-date-picker
|
|
129
|
+ v-model="date"
|
|
130
|
+ type="daterange"
|
|
131
|
+ range-separator="至"
|
|
132
|
+ start-placeholder="开始日期"
|
|
133
|
+ end-placeholder="结束日期"
|
|
134
|
+ :picker-options="pickerOptions">
|
|
135
|
+ </el-date-picker>
|
|
136
|
+ </div>
|
|
137
|
+ </div>
|
|
138
|
+ </div>
|
|
139
|
+ </li>
|
|
140
|
+ <li class="flex-h">
|
|
141
|
+ <span>视频:</span>
|
|
142
|
+ <div class="flex-item">
|
|
143
|
+ <div style="vertical-align: middle;">
|
|
144
|
+ <a style="line-height: 40px;" v-if="videoOff" :href="cardInfo.VideoUrl" target="blank">{{cardInfo.VideoUrl}}</a>
|
|
145
|
+ <el-upload
|
|
146
|
+ class="avatar-uploader"
|
|
147
|
+ :action='$api.file.image.url'
|
|
148
|
+ :show-file-list="false"
|
|
149
|
+ :on-success="videoSuccess">
|
|
150
|
+ <a style="line-height: 40px;padding: 0 10px;">{{videoOff ? '更换' : '添加'}}视频</a>
|
|
151
|
+ </el-upload>
|
|
152
|
+ <el-button v-if="videoOff" type="danger" @click="deleteVideo">删除视频</el-button>
|
|
153
|
+ </div>
|
|
154
|
+ </div>
|
|
155
|
+ </li>
|
|
156
|
+ <li class="flex-h">
|
|
157
|
+ <span>分享描述:</span>
|
|
158
|
+ <div class="flex-item">
|
|
159
|
+ <div>
|
|
160
|
+ <el-input
|
|
161
|
+ type="textarea"
|
|
162
|
+ :rows="2"
|
|
163
|
+ placeholder="请输入"
|
|
164
|
+ v-model="cardInfo.Share.CardShareInfo">
|
|
165
|
+ </el-input>
|
|
166
|
+ </div>
|
|
167
|
+ </div>
|
|
168
|
+ </li>
|
|
169
|
+ <li class="flex-h">
|
|
170
|
+ <span>规则描述:</span>
|
|
171
|
+ <div class="flex-item">
|
|
172
|
+ <div>
|
|
173
|
+ <el-input
|
|
174
|
+ type="textarea"
|
|
175
|
+ :rows="2"
|
|
176
|
+ placeholder="请输入"
|
|
177
|
+ v-model="cardInfo.Share.CardUseRule">
|
|
178
|
+ </el-input>
|
|
179
|
+ </div>
|
|
180
|
+ </div>
|
|
181
|
+ </li>
|
|
182
|
+ <li class="flex-h">
|
|
183
|
+ <span>使用说明:</span>
|
|
184
|
+ <div class="flex-item">
|
|
185
|
+ <div>
|
|
186
|
+ <el-input
|
|
187
|
+ type="textarea"
|
|
188
|
+ :rows="2"
|
|
189
|
+ placeholder="请输入"
|
|
190
|
+ v-model="cardInfo.Share.CardUseInstruction">
|
|
191
|
+ </el-input>
|
|
192
|
+ </div>
|
|
193
|
+ </div>
|
|
194
|
+ </li>
|
|
195
|
+ <li style="text-align:center">
|
|
196
|
+ <el-button type="primary" size="mini" @click="submit">保存</el-button>
|
|
197
|
+ <el-button type="danger" size="mini" @click="cancel">取消</el-button>
|
|
198
|
+ </li>
|
|
199
|
+ </ul>
|
|
200
|
+ </form>
|
|
201
|
+ </div>
|
|
202
|
+</template>
|
|
203
|
+
|
|
204
|
+<script>
|
|
205
|
+import { mapState, createNamespacedHelpers } from 'vuex'
|
|
206
|
+const { mapActions: mapCardActions } = createNamespacedHelpers('card')
|
|
207
|
+const { mapState: mapChannelState, mapActions: mapChannelActions } = createNamespacedHelpers('channel')
|
|
208
|
+const { mapActions: mapCourseActions } = createNamespacedHelpers('course')
|
|
209
|
+
|
|
210
|
+export default {
|
|
211
|
+ name: '',
|
|
212
|
+ data () {
|
|
213
|
+ return {
|
|
214
|
+ date: '',
|
|
215
|
+ courseList: [],
|
|
216
|
+ videoOff: false,
|
|
217
|
+ total: 0,
|
|
218
|
+ type: this.$route.query.type,
|
|
219
|
+ isEdit: this.$route.query.id === undefined ? 0 : 1,
|
|
220
|
+ ChannelList: [], // 渠道列表
|
|
221
|
+ TypeList: [], // 类型列表
|
|
222
|
+ GoodsList: [], // 商品列表
|
|
223
|
+ currentList: [{
|
|
224
|
+ Name: 'ccc',
|
|
225
|
+ Type: 'xxx'
|
|
226
|
+ }], // 指定商品数据
|
|
227
|
+ cardInfo: {
|
|
228
|
+ CardName: '',
|
|
229
|
+ SendType: '',
|
|
230
|
+ VideoUrl: '',
|
|
231
|
+ Price: ' ',
|
|
232
|
+ StartDate: '',
|
|
233
|
+ EndDate: '',
|
|
234
|
+ TotalCount: '',
|
|
235
|
+ CaseId: '',
|
|
236
|
+ OrgId: '',
|
|
237
|
+ Share: {
|
|
238
|
+ CardShareInfo: '',
|
|
239
|
+ CardUseRule: '',
|
|
240
|
+ CardUseInstruction: ''
|
|
241
|
+ },
|
|
242
|
+ Images: [{
|
|
243
|
+ CardImageUrl: ''
|
|
244
|
+ }],
|
|
245
|
+ Targets: [{
|
|
246
|
+ TargetType: '',
|
|
247
|
+ TargetId: '',
|
|
248
|
+ TargetName: ''
|
|
249
|
+ }],
|
|
250
|
+ ChannelId: ''
|
|
251
|
+ },
|
|
252
|
+ postData: {
|
|
253
|
+ page: 1,
|
|
254
|
+ pagesize: 10,
|
|
255
|
+ },
|
|
256
|
+ }
|
|
257
|
+ },
|
|
258
|
+ mounted () {
|
|
259
|
+ this.$nextTick(function () {
|
|
260
|
+ this.GetChannelListList({
|
|
261
|
+ caseid: this.defaultCaseId,
|
|
262
|
+ page: 1,
|
|
263
|
+ pagesize: 10000
|
|
264
|
+ }).then(() => {
|
|
265
|
+ this.GetCourseList({
|
|
266
|
+ caseid: this.defaultCaseId,
|
|
267
|
+ page: 1,
|
|
268
|
+ pagesize: 10000
|
|
269
|
+ }).then((res) => {
|
|
270
|
+ this.courseList = res.list
|
|
271
|
+ if (this.$route.query.id) {
|
|
272
|
+ this.getCardById({
|
|
273
|
+ id: this.$route.query.id
|
|
274
|
+ }).then((res) => {
|
|
275
|
+ // console.log(JSON.stringify(res.Card))
|
|
276
|
+ this.cardInfo = res.Card
|
|
277
|
+ if (res.Card.VideoUrl) {
|
|
278
|
+ this.videoOff = true
|
|
279
|
+ }
|
|
280
|
+ if (res.Card.Images === null) {
|
|
281
|
+ this.cardInfo.Images = [{
|
|
282
|
+ CardImageUrl: ''
|
|
283
|
+ }]
|
|
284
|
+ }
|
|
285
|
+ if (res.Card.StartDate) {
|
|
286
|
+ this.date = [res.Card.StartDate, res.Card.EndDate]
|
|
287
|
+ }
|
|
288
|
+ })
|
|
289
|
+ }
|
|
290
|
+ })
|
|
291
|
+ })
|
|
292
|
+ })
|
|
293
|
+ },
|
|
294
|
+ computed: {
|
|
295
|
+ ...mapChannelState({
|
|
296
|
+ channelList: x => x.channelList,
|
|
297
|
+ }),
|
|
298
|
+ ...mapState({
|
|
299
|
+ cases: x => x.app.cases.list,
|
|
300
|
+ defaultCaseId: x => x.app.cases.default,
|
|
301
|
+ OrgId: x => x.app.user.OrgId,
|
|
302
|
+ }),
|
|
303
|
+ pickerOptions () {
|
|
304
|
+ const courseId = this.cardInfo.Targets[0].TargetId
|
|
305
|
+ const couse = (this.courseList || []).filter(x => x.CourseId === courseId)[0] || {}
|
|
306
|
+ const beginDate = new Date(couse.BeginDate).getTime()
|
|
307
|
+ const endDate = new Date(couse.EndDate).getTime()
|
|
308
|
+ return {
|
|
309
|
+ disabledDate (time) {
|
|
310
|
+ return time.getTime() < beginDate || time.getTime() > endDate
|
|
311
|
+ }
|
|
312
|
+ }
|
|
313
|
+ },
|
|
314
|
+ CaseId: {
|
|
315
|
+ get () {
|
|
316
|
+ return this.postData.caseid || this.defaultCaseId
|
|
317
|
+ },
|
|
318
|
+ set (val) {
|
|
319
|
+ this.postData.caseid = val
|
|
320
|
+ }
|
|
321
|
+ }
|
|
322
|
+ },
|
|
323
|
+ methods: {
|
|
324
|
+ ...mapCardActions([
|
|
325
|
+ 'addCard',
|
|
326
|
+ 'getCardById',
|
|
327
|
+ 'editCard',
|
|
328
|
+ ]),
|
|
329
|
+ ...mapCourseActions([
|
|
330
|
+ 'GetCourseList',
|
|
331
|
+ ]),
|
|
332
|
+ ...mapChannelActions([
|
|
333
|
+ 'GetChannelListList',
|
|
334
|
+ ]),
|
|
335
|
+ caseChange () { // 选择案场
|
|
336
|
+ this.GetChannelListList({
|
|
337
|
+ caseid: this.cardInfo.CaseId,
|
|
338
|
+ page: 1,
|
|
339
|
+ pagesize: 10000
|
|
340
|
+ })
|
|
341
|
+ this.GetCourseList({
|
|
342
|
+ caseid: this.cardInfo.CaseId,
|
|
343
|
+ page: 1,
|
|
344
|
+ pagesize: 10000
|
|
345
|
+ }).then((res) => {
|
|
346
|
+ this.courseList = res.list
|
|
347
|
+ })
|
|
348
|
+ this.cardInfo.Targets = [{
|
|
349
|
+ TargetType: '',
|
|
350
|
+ TargetId: '',
|
|
351
|
+ TargetName: ''
|
|
352
|
+ }]
|
|
353
|
+ this.cardInfo.ChannelId = ''
|
|
354
|
+ },
|
|
355
|
+ deleteVideo () { // 删除视频
|
|
356
|
+ this.cardInfo.VideoUrl = ''
|
|
357
|
+ this.videoOff = false
|
|
358
|
+ },
|
|
359
|
+ videoSuccess (res, file) {
|
|
360
|
+ this.videoOff = true
|
|
361
|
+ this.cardInfo.VideoUrl = res.result.url
|
|
362
|
+ },
|
|
363
|
+ addGoods () { // 添加指定商品
|
|
364
|
+ this.centerDialogVisible = true
|
|
365
|
+ },
|
|
366
|
+ submit () { // 保存
|
|
367
|
+ if (this.$route.query.id) {
|
|
368
|
+ if (this.date !== '') {
|
|
369
|
+ this.cardInfo.StartDate = this.date[0]
|
|
370
|
+ this.cardInfo.EndDate = this.date[1]
|
|
371
|
+ }
|
|
372
|
+ for (var x = 0; x < this.courseList.length; x++) {
|
|
373
|
+ if (this.courseList[x].CourseId === this.cardInfo.Targets[0].TargetId) {
|
|
374
|
+ this.cardInfo.Targets[0].TargetType = this.courseList[x].CourseType
|
|
375
|
+ this.cardInfo.Targets[0].TargetName = this.courseList[x].CourseName
|
|
376
|
+ }
|
|
377
|
+ }
|
|
378
|
+ this.cardInfo.TotalCount = this.cardInfo.TotalCount - 0
|
|
379
|
+ console.log(JSON.stringify(this.cardInfo))
|
|
380
|
+ this.editCard(this.cardInfo).then((res) => {
|
|
381
|
+ this.$alert('操作成功', '提示', {
|
|
382
|
+ confirmButtonText: '确定',
|
|
383
|
+ callback: action => {
|
|
384
|
+ this.$router.push({ name: 'cardList' })
|
|
385
|
+ }
|
|
386
|
+ })
|
|
387
|
+ })
|
|
388
|
+ } else {
|
|
389
|
+ this.cardInfo.OrgId = this.OrgId
|
|
390
|
+ if (this.date !== '') {
|
|
391
|
+ this.cardInfo.StartDate = this.date[0]
|
|
392
|
+ this.cardInfo.EndDate = this.date[1]
|
|
393
|
+ }
|
|
394
|
+ for (var n = 0; n < this.courseList.length; n++) {
|
|
395
|
+ if (this.courseList[n].CourseId === this.cardInfo.Targets[0].TargetId) {
|
|
396
|
+ this.cardInfo.Targets[0].TargetType = this.courseList[n].CourseType
|
|
397
|
+ this.cardInfo.Targets[0].TargetName = this.courseList[n].CourseName
|
|
398
|
+ }
|
|
399
|
+ }
|
|
400
|
+ this.cardInfo.TotalCount = this.cardInfo.TotalCount - 0
|
|
401
|
+ console.log(JSON.stringify(this.cardInfo))
|
|
402
|
+ this.addCard(this.cardInfo).then((res) => {
|
|
403
|
+ this.$alert('操作成功', '提示', {
|
|
404
|
+ confirmButtonText: '确定',
|
|
405
|
+ callback: action => {
|
|
406
|
+ this.$router.push({ name: 'cardList' })
|
|
407
|
+ }
|
|
408
|
+ })
|
|
409
|
+ })
|
|
410
|
+ }
|
|
411
|
+ },
|
|
412
|
+ cancel () { // 取消
|
|
413
|
+ this.$router.push({ name: 'couponList' })
|
|
414
|
+ },
|
|
415
|
+ handleAvatarSuccess (res, file) {
|
|
416
|
+ this.cardInfo.Images[0].CardImageUrl = res.result.url
|
|
417
|
+ },
|
|
418
|
+ }
|
|
419
|
+}
|
|
420
|
+</script>
|
|
421
|
+
|
|
422
|
+<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
423
|
+<style lang="scss" scoped>
|
|
424
|
+.addLine {
|
|
425
|
+ > * {
|
|
426
|
+ margin-right: 10px;
|
|
427
|
+ }
|
|
428
|
+}
|
|
429
|
+.mainForm > ul > li > div > div > button {
|
|
430
|
+ margin-top: 0;
|
|
431
|
+}
|
|
432
|
+</style>
|