doum
2025-09-08 55ba702c1df240929e68df3b42fa9cb0607378b8
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
<template>
  <div class="main_app">
    <Breadcrumb />
    <QueryForm v-model="filters" :query-form-config="queryFormConfig" @handleQuery="getList(1)" @clear="clearQueryForm">
    </QueryForm>
    <div class="table_btns">
      <el-button plain type="primary" @click="handleEx">导出</el-button>
      <el-button plain type="danger" @click="openModal('zuofei')">作废</el-button>
      <el-button plain type="primary" @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="套餐票号" min-width="160" show-overflow-tooltip>
        <template v-slot="scope">
          <span class="primaryColor pointer" @click="comboDetail(scope.row)">{{
            scope.row.code
          }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="套餐类型" min-width="80">
        <template v-slot="scope">
          <span v-if="scope.row.type == '0'">期限卡</span>
          <span v-if="scope.row.type == '1'">次卡</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="套餐名称" show-overflow-tooltip min-width="100" prop="name" />
      <el-table-column align="center" label="用户信息" min-width="100" prop="openid" show-overflow-tooltip />
      <el-table-column align="center" label="使用次数" min-width="80" prop="useTimes">
      </el-table-column>
      <el-table-column align="center" label="有效日期" min-width="200" prop="remainCount">
        <template v-slot="scope">
          <span>{{ scope.row.useStartDate }}至{{ scope.row.useEndDate }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="创建时间" min-width="150" prop="createDate" show-overflow-tooltip />
      <el-table-column align="center" label="套餐状态" min-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>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" fixed="right" min-width="150">
        <template v-slot="scope">
          <template>
            <el-button v-if="scope.row.status == '0'" type="text" @click="openCan(scope.row)">作废</el-button>
            <span v-else>-</span>
          </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.flag" label="0">已选{{ selList.length }}条数据</el-radio>
        </div>
        <div style="margin-bottom: 16px;">
          <el-radio v-model="adjustData.flag" label="1">选现有筛选条件下全部的{{ pagination.total }}条数据</el-radio>
        </div>
        <div class="df_ac mb5">
          <span class="key">有效期增加:</span>
          <el-input v-model="adjustData.addNum" 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 type="primary" :loading="subLoading" @click="handleModelEnter">确定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="套餐作废" :visible.sync="isShowCan" width="500px">
      <div class="adjust_modal" style="margin-top: -30px;">
        <div class="red" style="font-size: 16px;">确定作废选中套餐吗?作废后,套餐不可使用</div>
        <div class="df_ac mt10">
          <el-input type="textarea" v-model="remarkCan" placeholder="请按要求输入备注说明,非必填" />
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isShowCan = false">取消</el-button>
        <el-button type="primary" :loading="subLoading" @click="handleCan">确定</el-button>
      </span>
    </el-dialog>
 
    <Refund v-if="isShowRefund" ref="RefundRef" @close="isShowRefund = false" @success="refundSuccess" />
    <Detail v-if="isShowDetail" ref="detailRef" />
    <Detail ref="DetailRef" />
  </div>
</template>
 
<script>
import BasePageTemp from '@/components/base/BasePageTemp'
import Breadcrumb from '@/layouts/Breadcrumb'
import Detail from './components/SaleDetail.vue'
import { Message } from 'element-ui'
import {
  comboSalePage,
  comboSaleEx,
  comboSaleCancel,
  comboSaleAdjust,
} from '@/api/business/combo.js'
export default {
  name: 'SalesRecord',
  extends: BasePageTemp,
  components: { Breadcrumb, Detail },
  data() {
    return {
      exportLoading: false,
      isShowDetail: false,
      isShowRefund: false,
      queryFormConfig: {
        formItems: [{
          filed: 'code',
          type: 'input',
          label: '套餐票号',
          placeholder: '请输入套餐号',
          clearable: true
        }, {
          filed: 'name',
          type: 'input',
          label: '套餐名称',
          placeholder: '请输入套餐名称',
          clearable: true
        }, {
          filed: 'openid',
          type: 'input',
          label: '用户信息',
          clearable: true
        }, {
          filed: 'status',
          type: 'select',
          label: '状态',
          placeholder: '请选择状态',
          clearable: true,
          options: [
            { value: '0', label: '正常' },
            { value: '1', label: '作废' }
          ]
        },{
          filed: 'createDate',
          type: 'daterange',
          label: '创建日期',
          placeholder: '请选择状态',
          clearable: true,
          options: [
            { value: '0', label: '正常' },
            { value: '1', label: '作废' }
          ]
        }],
        online: true
      },
      querys: {
        id: '',
        mealsName: '',
        memberSearchValue: '',
        status: '',
        indate: []
      },
 
      saleRecordList: [],
      saleRecordTotal: 0,
      selList: [],
      saleRecordLoading: false,
      subLoading: false,
 
      isShowCan: false,
      ModalTitle: '',
      ModalText: '',
      ModelRemark: '',
      remarkCan: '',
      // ⬇️adjust调整相关
      isShowAdjust: false,
      canList: [],
      adjustData: {
        flag: 0,
        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()
    },
    handleEx() {
      const { pagination, filters } = this
      let form = JSON.parse(JSON.stringify(filters))
      if (form.createDate && form.createDate.length > 0) {
        form.startCreateDate = form.createDate[0] + ' 00:00:00'
        form.endCreateDate = form.createDate[1] + ' 23:59:59'
        delete form.createDate
      }
      this.$dialog.exportConfirm('确认导出吗?')
        .then(() => {
          this.loading = true
          comboSaleEx({
            page: 1,
            capacity: 1000000,
            model: form
          })
            .then(response => {
              this.download(response)
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
              this.loading = false
            })
        })
        .catch(() => { })
    },
    openCan(row) {
      this.isShowCan = true
      this.canList = [row]
    },
    handleDisable(row) {
      // return row.status == 0
      return true
    },
    // 查询表格数据
    getList(page) {
      const { pagination, filters } = this
      this.loading = true
      if (page) { pagination.page = page }
      let form = JSON.parse(JSON.stringify(filters))
      if (form.createDate && form.createDate.length > 0) {
        form.startCreateDate = form.createDate[0] + ' 00:00:00'
        form.endCreateDate = form.createDate[1] + ' 23:59:59'
        delete form.createDate
      }
      comboSalePage({
        model: {
          ...form
        },
        capacity: pagination.pageSize,
        page: pagination.page,
      }).then(res => {
        this.loading = false
        this.list = res.records || []
        this.pagination.total = res.total || 0
      }, () => {
        this.loading = false
      })
    },
    clearQueryForm() {
      // eslint-disable-next-line no-unused-vars
      this.filters = {}
      this.getList(1)
    },
    // 打开modal 冻结 解冻 作废
    openModal(type) {
      const { selList } = this
      this.ModelRemark = ''
      this.adjustData.addNum = ''
      this.adjustData.addTime = ''
      switch (type) {
        case 'zuofei':
          this.ModalTitle = '套餐作废'
          this.ModalText = '确定作废选中套餐吗?作废后,套餐不可使用'
          break
        case 'tiaozheng':
          this.ModalTitle = '套餐调整'
          break
        default:
          break
      }
      if (selList.length === 0 && type == 'zuofei') {
        return Message.warning(`请先选择要${this.ModalTitle.slice(2)}的套餐`)
      }
      if (this.ModalTitle === '套餐调整') {
        this.isShowAdjust = true
        this.adjustData = {
          flag: '0'
        }
      } else {
        this.isShowCan = true
      }
    },
    // 确定 冻结 解冻 作废
    handleModelEnter() {
      switch (this.ModalTitle) {
        case '套餐作废':
          this.cancellation()
          break
        case '套餐调整':
          this.handleAdjust()
          break
        default:
          break
      }
    },
    // 调整
    async handleAdjust() {
      if (!this.adjustData.addNum && !this.adjustData.addTime) {
        return Message.warning('请输入要调整的有效期天数或者余量次数')
      }
      const data = {
        info: this.ModelRemark,
        addDays: this.adjustData.addNum || 0,
        choseIdList: this.adjustData.flag == 0 ? this.selList.map(i => i.id) : [],
        ...this.filters
      }
 
      this.subLoading = true
      const res = await comboSaleAdjust({ ...data }).catch(() => {
        this.subLoading = false
        this.isShowCan = false
      })
      this.subLoading = false
      this.isShowCan = false
      if (res) {
        Message.success('套餐调整成功')
        this.getList()
        this.isShowAdjust = false
      }
    },
    // 作废
    async cancellation() {
      const data = {
        handleRemake: this.remarkCan,
        choseIdList: this.selList.map(i => i.id)
      }
      this.subLoading = true
      const res = await comboSaleCancel({ ...data }).catch(() => {
        this.subLoading = false
        this.isShowCan = false
      })
      this.subLoading = false
      this.isShowCan = false
      if (res) {
        Message.success('作废成功')
        this.getList()
      }
    },
    async handleCan() {
      const data = {
        handleRemake: this.remarkCan,
        choseIdList: this.canList.map(i => i.id)
      }
      this.subLoading = true
      const res = await comboSaleCancel({ ...data }).catch(() => {
        this.subLoading = false
        this.isShowCan = false
      })
      this.subLoading = false
      this.isShowCan = false
      if (res) {
        Message.success('作废成功')
        this.getList()
      }
    },
    handleSelectionChange(val) {
      this.selList = val
    },
    comboDetail(item) {
      this.$nextTick(() => {
        this.$refs.DetailRef.isShowModal = true
        this.$refs.DetailRef.getDetail(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>