dataImportMixin.js 6.33 KB
// dataImportMixin.js
import * as dayjs from 'dayjs';
import url from '@/assets/empty.png'

export default {
    data() {
        return {
            url,
            pageConf: {pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total'},
            searchForm: {
            },
            searchFormData: [
                {
                    label: '微信昵称',
                    name: 'wechatName',
                    type: 'input',
                    maxlength: 100
                },
                {
                    label: '手机号',
                    name: 'userPhone',
                    type: 'input',
                    maxlength: 100
                },
                {
                    label: '活动名称',
                    name: 'activityName',
                    type: 'input',
                    maxlength: 100
                },
                {
                    label: '核销类型',
                    name: 'exchangeType',
                    type: 'select',
                    optionList: [
                        { text: '全部', id: '' },
                        { text: '快递到家', id: '0' },
                        { text: '到店核销', id: '1' }
                    ],
                    optionId: 'id',
                    optionLabel: 'text'
                },
                {
                    label: '核销状态',
                    name: 'exchangeStatus',
                    type: 'select',
                    optionList: [
                        { text: '全部', id: '' },
                        { text: '待发货', id: '0' },
                        { text: '已发货', id: '1' },
                        { text: '待核销', id: '2' },
                        { text: '已核销', id: '3' }
                    ],
                    optionId: 'id',
                    optionLabel: 'text'
                },
                {
                    label: '奖品名称',
                    name: 'prizeName',
                    type: 'input',
                    maxlength: 11
                },
                {
                    label: '核销时间',
                    name: 'exchangeTime',
                    type: 'datePicker',
                    valueFormat: 'yyyy-MM-dd',
                    isClear: true,
                    customPickerOptions: {
                        disabledDate(date) {
                            const yesterday = new Date(new Date().setDate(new Date().getDate()))
                            if (date > yesterday) {
                                return true
                            }
                            return false
                        }
                    }
                }
            ],
            getListApi: this.$apis.redenvelope.winningGoodsApi,
            tableParams: {
                listName: 'list',
                tableOption: true,
                tableColumns: [
                    {
                        label: '手机号',
                        prop: 'userPhone',
                        minWidth: 100
                    },
                    {
                        label: '微信昵称',
                        prop: 'wechatName',
                        minWidth: 100
                    },
                    {
                        label: '红包链接',
                        prop: 'link',
                        minWidth: 100
                    },
                    {
                        label: '活动名称',
                        minWidth: 100,
                        prop: 'activityName',
                    },
                    {
                        label: '奖品名称',
                        minWidth: 100,
                        prop: 'activityName',
                    },
                    {
                        label: '核销类型',
                        minWidth: 150,
                        formatter: cell => {
                            return {0: '快递到家', 1: '到店核销'}[cell.exchangeType]
                        }
                    },
                    {
                        label: '核销状态',
                        minWidth: 150,
                        prop:'statusStr'
                    },
                    {
                        label: '核销时间',
                        prop: 'operateTime',
                        minWidth: 100
                    },
                ]
            },
            // 表格按钮
            tableButtonList: [
                {
                    type: 'el-button',
                    name: '发货',
                    attrs: {
                        type: 'text',
                    },
                    condition: row => row.statusStr == '待发货',
                    listeners: {
                        click: row => this.handleDeliverGoods(row)
                    }
                },
                {
                    type: 'el-button',
                    name: '核销',
                    attrs: {
                        type: 'text',
                    },
                    condition: row => row.statusStr == '待核销',
                    listeners: {
                        click: row => this.cancelAfterVerification(row)
                    }
                }
            ],
            tableSearchForm: {}
        }
    },
    methods: {
        // 更新发货/核销展示的数据
        updateInfoSections(row, title) {
            let sectionIndex = this.infoSections.findIndex(item => item.title === title);
            if (sectionIndex !== -1) {
                this.infoSections[sectionIndex].items = this.infoSections[sectionIndex].items.map(item => ({
                    ...item,
                    value: item.key && row.hasOwnProperty(item.key) ? row[item.key] : '-'
                }));
            }
            return sectionIndex
        },
        // 列表发货处理
        handleDeliverGoods(row) {
            this.updateInfoSections(row, '基本信息');
            this.isDrawerVisible = true;
        },

        // 列表核销处理
        cancelAfterVerification(row){
            let basicInfoIndex = this.updateInfoSections(row, '基本信息');
            this.cancelObj = {
                show: true,
                title: '核销',
                id: row.id || '',
                infoSections:[this.infoSections[basicInfoIndex]]
            }
        }
    },

};