ll
liukangdong
2025-02-18 031d0f428f58b008f7a59476fcf3e6ba86d10048
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<template>
  <div class="main_app">
    <Breadcrumb />
    <QueryForm v-model="querys" :query-form-config="queryFormConfig" @handleQuery="getList(1)" @clear="clearQueryForm">
      <template #btns>
        <el-button v-if="meta.indexOf('MealsUseDetailExport') > -1" type="primary"
          @click="comboRecordExport">导出</el-button>
      </template>
      <template #indate>
        <el-date-picker v-model="querys.indate" type="datetimerange" range-separator="至" start-placeholder="开始日期"
          end-placeholder="结束日期" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" class="w400"
          :picker-options="pickerOptions" />
      </template>
    </QueryForm>
    <div class="table_btns">
      <el-button v-preventReClick plain type="primary" @click="handleEx">导出</el-button>
      <el-button v-preventReClick plain type="danger" @click="openModal('zuofei')">作废</el-button>
      <el-button v-preventReClick plain @click="openModal('tiaozheng')">套餐调整</el-button>
    </div>
    <el-table v-loading="loading" :data="list" stripe border @selection-change="handleSelectionChange">
      <el-table-column fixed="left" align="center" type="selection" :selectable="handleDisable" width="55" />
      <el-table-column align="center" label="套餐票号" width="300" show-overflow-tooltip>
        <template v-slot="scope">
          <span class="primaryColor pointer" @click="comboDetail(scope.row)">{{
            scope.row.id
            }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="套餐类型" width="120">
        <template v-slot="scope">
          <span v-if="scope.row.mealsType === '0'">门票次卡</span>
          <span v-if="scope.row.mealsType === '1'">门票期限卡</span>
          <span v-if="scope.row.mealsType === '2'">预定次卡</span>
          <span v-if="scope.row.mealsType === '3'">课程预约次卡</span>
          <span v-if="scope.row.mealsType === '4'">课程期限卡</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="套餐名称" show-overflow-tooltip width="160" prop="mealsName" />
      <el-table-column align="center" label="用户信息" min-width="240" prop="memberInfo" show-overflow-tooltip />
      <el-table-column align="center" label="使用次数" width="80" prop="useCount">
        <template v-slot="scope">
          <span v-if="scope.row.mealsType === '1'">-</span>
          <span v-else>{{ scope.row.useCount }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="有效日期" width="80" prop="remainCount">
        <template v-slot="scope">
          <span v-if="scope.row.mealsType === '1'">-</span>
          <span v-else>{{ scope.row.remainCount }}</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" align="center" label="套餐状态" width="80">
        <template v-slot="scope">
          <span v-if="scope.row.status === '0'" class="text_success">正常</span>
          <span v-if="scope.row.status === '1'" class="text_warning">冻结</span>
          <span v-if="scope.row.status === '2'" class="text-danger">作废</span>
          <span v-if="scope.row.status === '3'" class="text-danger">失效</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="有效日期" width="120" prop="validTime" />
      <el-table-column align="center" label="操作" fixed="right" width="150">
        <template v-slot="scope">
          <template>
            <el-button v-if="
              meta.indexOf('MealsMemberPartRefund') > -1 &&
              (scope.row.status == '0' || scope.row.status == '1')
            " type="text" @click="rowClickRefund(scope.row)">退款</el-button>
            <el-button v-if="scope.row.status == '0'" type="text"
              @click="getServiceChargePriceBtn('2', scope.row.id)">冻结</el-button>
          </template>
        </template>
      </el-table-column>
    </el-table>
    <div class="table_btns">
      <Pagination @size-change="handleSizeChange" @current-change="getList" :pagination="pagination" />
    </div>
 
    <el-dialog title="套餐调整" :visible.sync="isShowAdjust" width="500px">
      <div class="adjust_modal">
        <div style="margin-top: -30px; margin-bottom: 10px;">
          <el-radio v-model="adjustData.aa" label="1">已选当前2条数据</el-radio>
        </div>
        <div style="margin-bottom: 16px;">
          <el-radio v-model="adjustData.aa" label="1">已选现有筛选条件下全部的11条数据</el-radio>
        </div>
        <div class="df_ac mb5">
          <span class="key">有效期增加:</span>
          <el-input v-model="adjustData.addTime" oninput="value=value.replace(/[^\d]/g,'')" class="flex1 mr10" />
          <span>天</span>
        </div>
        <div class="df_ac mb20">
          <span class="key" />
          <span class="text_warning">修改后套餐有效期增加以上天数</span>
        </div>
        <div class="df_ac mt20">
          <span class="key">调整备注:</span>
          <el-input v-model="ModelRemark" style="width: 356px" placeholder="请按要求输入备注说明,非必填" />
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isShowAdjust = false">取消</el-button>
        <el-button v-preventReClick type="primary" :loading="subLoading" @click="handleModelEnter">确定</el-button>
      </span>
    </el-dialog>
 
    <Refund v-if="isShowRefund" ref="RefundRef" @close="isShowRefund = false" @success="refundSuccess" />
    <Detail v-if="isShowDetail" ref="detailRef" />
    <orderDialog ref="child" @orderSuccess="getList()" />
  </div>
</template>
 
<script>
import { pickerOptions } from './components/config'
import BasePageTemp from '@/components/base/BasePageTemp'
import Breadcrumb from '@/layouts/Breadcrumb'
// import Detail from '../comboDetail'
// import Refund from './refund.vue'
export default {
  name: 'SalesRecord',
  extends: BasePageTemp,
  components: { Breadcrumb },
  data() {
    return {
      exportLoading: false,
      isShowDetail: false,
      isShowRefund: false,
      queryFormConfig: {
        formItems: [{
          filed: 'id',
          type: 'input',
          label: '套餐票号',
          placeholder: '请输入套餐号',
          clearable: true
        }, {
          filed: 'mealsName',
          type: 'input',
          label: '套餐名称',
          placeholder: '请输入套餐名称',
          clearable: true
        }, {
          filed: 'memberSearchValue',
          type: 'input',
          label: '用户信息',
          clearable: true
        }, {
          filed: 'status',
          type: 'select',
          label: '状态',
          placeholder: '请选择状态',
          clearable: true,
          options: [
            { value: '0', label: '正常' },
            { value: '1', label: '冻结' },
            { value: '2', label: '作废' },
            { value: '3', label: '失效' }]
        }],
        online: true
      },
      pickerOptions,
      querys: {
        id: '',
        mealsName: '',
        memberSearchValue: '',
        status: '',
        indate: []
      },
 
      saleRecordList: [],
      saleRecordTotal: 0,
      selectSalesList: [],
      saleRecordLoading: false,
      subLoading: false,
 
      isShowModal: false,
      ModalTitle: '',
      ModalText: '',
      ModelRemark: '',
      // ⬇️adjust调整相关
      isShowAdjust: false,
      adjustData: {
        addNum: '',
        addTime: ''
      },
      serviceChargePrice: '',
      serviceChargeId: ''
    }
  },
  created() {
    // this.meta = this.$route.meta.buttons || []
    // this.getList(1)
  },
  methods: {
    rowClickRefund(row) {
      this.isShowRefund = true
      this.$nextTick(() => {
        this.$refs.RefundRef.getPrice(row)
        this.$refs.RefundRef.isShow = true
      })
    },
    refundSuccess() {
      this.isShowRefund = false
      this.getList()
    },
    getServiceChargePriceBtn(type, mealsMemberId) {
      this.serviceChargeId = mealsMemberId
      getServiceChargePrice({
        param: {
          type,
          mealsMemberId
        }
      }).then((res) => {
        if (res.errorCode === '000000') {
          this.serviceChargePrice = res.record.price
          this.openModal('dongjie')
        }
      })
        .catch(() => { })
    },
    handleEx() {
      const { querys } = this
      this.exportLoading = true
      recordExport({
        param: {
          ...querys
        }
      }).then((res) => {
        this.exportLoading = false
        if (res.errorCode === '000000') {
          const a = document.createElement('a') // 创建一个a标签元素
          a.style.display = 'none' // 设置元素不可见
          a.href = res.record.showUrl // 设置下载地址
          document.body.appendChild(a) // 加入
          a.click() // 触发点击,下载
          document.body.removeChild(a) //
          this.$message.success('导出成功')
        }
      })
        .catch(() => {
          this.exportLoading = false
        })
    },
    handleDisable(row, index) {
      if (row.status === '2') {
        return false
      } else {
        return true
      }
    },
    // 查询表格数据
    getList(page) {
      const { querys, pagination } = this
      if (page) {
        pagination.page = page
        this.pagination.page = Number(page)
      }
      if (querys.indate && querys.indate.length > 0) {
        querys.startTime = querys.indate[0]
        querys.endTime = querys.indate[1]
      } else {
        querys.startTime = null
        querys.endTime = null
      }
      pagination.firstQueryTime = parseTime(new Date())
      this.saleRecordLoading = true
      comboSalesRecordPost({
        pagination, param: {
          ...querys,
          venueId: sessionStorage.getItem('venueId')
        }
      }).then(res => {
        this.saleRecordLoading = false
        if (res.errorCode === '000000') {
          this.saleRecordLoading = false
          this.saleRecordTotal = res.totalCount
          this.saleRecordList = res.recordList
          if (res.totalCount && res.recordList.length === 0 && pagination.page > 1) {
            this.getList(Math.ceil(res.totalCount / pagination.rows))
          }
        }
      }).catch(() => {
        this.saleRecordLoading = false
      })
    },
    clearQueryForm() {
      // eslint-disable-next-line no-unused-vars
      this.querys = {}
      this.getList(1)
    },
    // 打开modal 冻结 解冻 作废
    openModal(type) {
      const { selectSalesList } = this
      this.ModelRemark = ''
      this.adjustData.addNum = ''
      this.adjustData.addTime = ''
      switch (type) {
        case 'dongjie':
          this.ModalTitle = '套餐冻结'
          this.ModalText = '确定冻结选中套餐吗?冻结后,套餐将无法使用'
          break
        case 'jiedong':
          this.ModalTitle = '套餐解冻'
          this.ModalText = '确定解冻选中套餐吗?解冻后,套餐可立即生效使用'
          break
        case 'zuofei':
          this.ModalTitle = '套餐作废'
          this.ModalText = '确定作废选中套餐吗?作废后,套餐不可使用'
          break
        case 'tiaozheng':
          this.ModalTitle = '套餐调整'
          break
        default:
          break
      }
      if (selectSalesList.length === 0 && type !== 'dongjie') {
        return this.$message.warning(`请先选择要${this.ModalTitle.slice(2)}的套餐`)
      }
      if (this.ModalTitle === '套餐调整') {
        this.isShowAdjust = true
      } else {
        this.isShowModal = true
      }
    },
    // 确定 冻结 解冻 作废
    handleModelEnter() {
      // if (!this.ModelRemark) {
      //   this.$message.warning('操作备注必填')
      //   return
      // }
      switch (this.ModalTitle) {
        case '套餐冻结':
          this.Freeze()
          break
        case '套餐解冻':
          this.Unfreeze()
          break
        case '套餐作废':
          this.cancellation()
          break
        case '套餐调整':
          this.handleAdjust()
          break
        default:
          break
      }
    },
    // 冻结
    Freeze() {
      const that = this
      const data = {
        type: '1',
        handleRemake: this.ModelRemark,
        isCreateOrder: '1',
        id: this.serviceChargeId
      }
      this.subLoading = true
      handleComboSalesPost({ param: { ...data } }).then(res => {
        this.subLoading = false
        this.isShowModal = false
        if (res.errorCode === '000000') {
          const obj = res.record
          if (obj && obj.price) {
            obj.goodsInfos = obj.serviceChargeOrderInfo
            obj.allPrice = obj.price
            this.$refs.child.continuePay(obj, 'handlingFees')
          } else {
            this.$message.success('冻结成功')
            this.getList()
          }
          //
        } else if (res.errorCode === '200001') {
          this.$confirm('存在未处理订单, 是否跳转?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            callback: () => { },
            beforeClose: (action, ctx, close) => {
              if (action !== 'confirm') {
                close()
                return
              }
              ctx.confirmButtonLoading = true
              that.$router.push({ name: 'HandlingFees' })
            }
          }).finally(() => {
            this.subLoading = false
            this.isShowModal = false
          })
        }
      })
    },
    // 解冻
    async Unfreeze() {
      const data = {
        type: '2',
        handleRemake: this.ModelRemark,
        id: this.selectSalesList.map(i => i.id).join(',')
      }
      this.subLoading = true
      const res = await handleComboSalesPost({ param: { ...data } }).catch(() => {
        this.subLoading = false
        this.isShowModal = false
      })
      this.subLoading = false
      this.isShowModal = false
      if (res && res.errorCode === '000000') {
        this.$message.success('解冻成功')
        this.getList()
      }
    },
    // 调整
    async handleAdjust() {
      if (!this.adjustData.addNum && !this.adjustData.addTime) {
        return this.$message.warning('请输入要调整的有效期天数或者余量次数')
      }
      const data = {
        type: '3',
        handleRemake: this.ModelRemark,
        addNum: this.adjustData.addNum || 0,
        addTime: this.adjustData.addTime || 0,
        id: this.selectSalesList.map(i => i.id).join(',')
      }
 
      this.subLoading = true
      const res = await handleComboSalesPost({ param: { ...data } }).catch(() => {
        this.subLoading = false
        this.isShowModal = false
      })
      this.subLoading = false
      this.isShowModal = false
      if (res && res.errorCode === '000000') {
        this.$message.success('套餐调整成功')
        this.getList()
        this.isShowAdjust = false
      }
    },
    // 作废
    async cancellation() {
      const data = {
        type: '4',
        handleRemake: this.ModelRemark,
        id: this.selectSalesList.map(i => i.id).join(',')
      }
      this.subLoading = true
      const res = await handleComboSalesPost({ param: { ...data } }).catch(() => {
        this.subLoading = false
        this.isShowModal = false
      })
      this.subLoading = false
      this.isShowModal = false
      if (res && res.errorCode === '000000') {
        this.$message.success('作废成功')
        this.getList()
      }
    },
    handleSelectionChange(val) {
      this.selectSalesList = val
    },
    comboDetail(item) {
      this.isShowDetail = true
      this.$nextTick(() => {
        this.$refs.detailRef.isShowModal = true
        this.$refs.detailRef.comboDetail(item)
      })
 
      // this.$router.push({
      //   name: 'comboDetail',
      //   query: item
      // })
    },
    pageSizeChange(val) {
      this.pagination.rows = val
      this.getList(1)
    }
 
  }
}
</script>
 
<style lang="scss" scoped>
.adjust_modal {
  .df_ac {
    .key {
      width: 92px;
      text-align: right;
    }
  }
  .el-dialog__body{
    
  }
  .text_warning {
    color: #e89e42;
  }
}
</style>