<template>
    <div class="context">
        <div class="panel">
            <h5>会员管理</h5>
            <div class="panel-body">
                <div class="panel_control">
                    <el-row :gutter="20">
                        <el-col :span="4">
                            <em>姓名:</em>
                            <el-input v-model="panel.name" placeholder="请输入姓名"></el-input>
                        </el-col>
                        <el-col :span="4">
                            <em>手机号:</em>
                            <el-input v-model="panel.phone" placeholder="请输入手机号"></el-input>
                        </el-col>
                        <el-col :span="4">
                            <em>会员类型:</em>
                            <el-select v-model="panel.vipType">
                                <el-option
                                        v-for="item in panel.vipOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                </el-option>
                            </el-select>
                        </el-col>
                        <el-col :span="4">
                            <em>到期日:</em>
                            <el-select v-model="panel.expDay">
                                <el-option
                                        v-for="item in panel.endTypeOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value">
                                </el-option>
                            </el-select>
                        </el-col>
                        <el-col :span="4">
                            <el-button size="" type="primary" @click="query" plain>查询</el-button>
                        </el-col>
                    </el-row>
                </div>
            </div>
        </div>
        <div class="change">
            <el-button @click="addMember">新增会员</el-button>
            <el-button @click="delList">删除会员</el-button>
            <el-button @click="lessonChange">课时调整</el-button>
            <el-button @click="giftChange">赠送课时调整</el-button>
            <el-button @click="ExpTimeChange">有效期调整</el-button>
            <el-button @click="lessonStudenChange">增删课程</el-button>
            <!--            <el-button class="pull-right" icon="el-icon-position">导出</el-button>-->
        </div>
        <div class="table">
            <el-table
                    :data="tableData"
                    border
                    is-horizontal-resize
                    :default-sort="{prop: 'date', order: 'descending'}"
                    element-loading-background="rgba(0, 0, 0, 0.8)"
                    class=""
                    @selection-change="handleSelectionChange"
            >
                <el-table-column
                        type="selection"
                        width="55">
                </el-table-column>
                <el-table-column
                        type="index"
                        label="序号"
                        width="50">
                </el-table-column>
                <el-table-column
                        prop="UserInfo.Name"
                        label="会员名"
                        width="140"
                >
                </el-table-column>
                <el-table-column
                        prop="UserInfo.Phone"
                        label="手机号"
                        sortable
                >
                </el-table-column>
                <el-table-column
                        prop="UserInfo.VipType"
                        label="类型"
                        width="80px"
                        sortable
                >
                    <template slot-scope="scope">
                        <span v-if="scope.row.UserInfo.VipType == 1">年费</span>
                        <span v-if="scope.row.UserInfo.VipType == 2">充值</span>
                    </template>
                </el-table-column>
                <el-table-column
                        prop="UserInfo.ExpTime"
                        label="会员有效期"
                        width="180"
                        :formatter="filterFmtDate"
                        sortable
                >
                </el-table-column>
                <el-table-column
                        prop="UserInfo.RemainNormalhour"
                        label="剩余课时"
                        width="110"
                        sortable
                >
                </el-table-column>
                <el-table-column
                        prop="UserInfo.ConsumeNormalhour"
                        label="累计课时"
                        width="110"
                        sortable
                >
                </el-table-column>
                <el-table-column
                        prop="UserInfo.RemainGifthour"
                        label="赠送"
                        width="110"
                        sortable
                >
                </el-table-column>
                <el-table-column
                        prop="UserInfo.ConsumeGifthour"
                        label="累计赠送"
                        width="110"
                        sortable
                >
                </el-table-column>
                <el-table-column
                        prop="ClassInfo"
                        label="会员课程"
                        width="220px"
                >
                    <template slot-scope="scope">
                        <span class="lessonSpan" :style="{background:lesson.ClassColor}"
                              v-for="lesson in scope.row.ClassInfo">{{lesson.ClassName}}</span>
                    </template>
                </el-table-column>
                <el-table-column
                        prop="UserInfo.Memo"
                        label="备注">
                    <template slot-scope="scope">
                        <el-popover
                                placement="top"
                                title=""
                                width="200"
                                trigger="hover"
                                :content="scope.row.UserInfo.Memo">
                            <span slot="reference"
                                  v-if="scope.row.UserInfo.Memo.length > 6">{{scope.row.UserInfo.Memo.substr(0,6)}} ....</span>
                        </el-popover>
                        <span v-if="scope.row.UserInfo.Memo.length <= 6">{{scope.row.UserInfo.Memo}}</span>
                    </template>
                </el-table-column>
                <el-table-column
                        prop="UserInfo.Status"
                        label="操作"
                        width="160px"
                >
                    <template slot-scope="scope">
                        <el-button class="btn" type="default" size="mini" @click="editMember(scope.row)">编辑</el-button>
                        <el-button class="btn" type="danger" v-if="scope.row.UserInfo.Status == 1" size="mini"
                                   @click="pauseRow(scope.row)">
                            禁用
                        </el-button>
                        <el-button class="btn" type="success" v-if="scope.row.UserInfo.Status == 8" size="mini"
                                   @click="runRow(scope.row)">
                            启用
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <br>
            <el-pagination
                    background
                    :total="pageination.total"
                    :page-size="pageination.pageItem"
                    @current-change="pageChange"
            ></el-pagination>
        </div>

        <el-dialog :title="dialogTitle" :visible.sync="dialogMemberVisible" width="1200px">
            <div class="dialogContent">
                <div :class="['pull-left',{'tabwild':form.btnType == 1},]">
                    <el-form ref="form" :model="form" label-width="160px">
                        <el-form-item label="手机号">
                            <el-input v-model="form.phone"></el-input>
                        </el-form-item>
                        <el-form-item label="会员名">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                        <el-form-item label="会员类型" v-if="form.btnType == 0">
                            <el-select v-model="form.vipType" placeholder="请选择所属门店">
                                <el-option
                                        v-for="item in memberTypes"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="课时" v-if="form.btnType == 0">
                            <el-input-number v-model="form.normalhour " :min="0" :max="99999"
                                             label="（天）"></el-input-number>
                        </el-form-item>
                        <el-form-item label="赠送课时" v-if="form.btnType == 0">
                            <el-input-number v-model="form.gifthour " :min="0" :max="99999"
                                             label="（天）"></el-input-number>
                        </el-form-item>
                        <el-form-item label="备注">
                            <el-input v-model="form.memo"></el-input>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="pull-right" v-if="form.btnType == 0">
                    <el-form ref="form" :model="form" label-width="160px">
                        <el-form-item label="会员课程">
                            <el-transfer filterable v-model="form.classlist" :data="form.dialogdata"
                                         :titles="['全部课程','已选课程']"></el-transfer>
                        </el-form-item>
                    </el-form>
                </div>
            </div>
            <div class="dialogFooter">
                <el-button type="primary" size="small" v-if="form.btnType == 0" @click="confirmMember">确定</el-button>
                <el-button type="primary" size="small" v-if="form.btnType == 1" @click="confirmEditMember">确定
                </el-button>
                <el-button size="small" @click="dialogMemberVisible = false">取消</el-button>
            </div>
        </el-dialog>

        <el-dialog :visible.sync="dialogVisible"  width="650px">
            <div class="dialogTitle">
                <h5>
                    用户：
                    <em class="blue">【 {{form.rowName}}】</em>
                    <br>
                    <br>
                    <span v-if="dialogLesson">当前课时</span>
                    <span v-if="dialogGift">当前赠送课时</span>
                    <span v-if="dialogExpTime">当前到期时间</span>
                    <span v-if="dialogLessonTable">当前会员课程</span>
                </h5>
            </div>
            <div v-if="dialogLesson">
                <el-input-number v-model="form.normalhour" :min="0" :max="9999" label="课时调整"></el-input-number>
            </div>
            <div v-if="dialogGift">
                <el-input-number v-model="form.gifthour" :min="0" :max="9999" label="赠送课时调整"></el-input-number>
            </div>
            <div v-if="dialogExpTime">
                <el-date-picker
                        v-model="form.expTime"
                        type="date"
                        placeholder="选择日期">
                </el-date-picker>
            </div>
            <div v-if="dialogLessonTable">
                <el-transfer filterable v-model="form.dialogValue" :data="form.dialogdata"
                             :titles="['全部课程','已选课程']"></el-transfer>
            </div>
            <div class="dialogFooter">
                <!--课时调整-->
                <el-button type="primary" size="small" @click="confirmLesson" v-if="dialogLesson">确定</el-button>
                <!--赠送课时调整-->
                <el-button type="primary" size="small" @click="confirmGift" v-if="dialogGift">确定</el-button>
                <!--                有效期调整-->
                <el-button type="primary" size="small" @click="confirmExpTime" v-if="dialogExpTime">确定</el-button>
                <!--                课程增删-->
                <el-button type="primary" size="small" @click="confirmLessonTable" v-if="dialogLessonTable">确定
                </el-button>
                <el-button size="small" @click="dialogVisible = false">取消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import Global from '../Global.js'
    import {
        VipUserListQuery,
        ClassListQuery,
        VipUserAdd,
        VipUserStatusEdit,
        VipUserEdit,
        VipUserHourEdit,
        VipUserExpEdit,
        VipUserClassEdit,
        testTable,
        testSelect
    } from "../api/getApiRes";

    let qs = require('qs');
    export default {
        data() {
            return {
                dialogVisible: false,//其他dialog
                dialogMemberVisible: false,//新增会员dialog
                dialogLesson: false,//课时调整
                dialogGift: false,//赠送课时调整
                dialogExpTime: false,//有效期调整
                dialogLessonTable: false,//会员课程
                dialogTitle: '新增会员',
                dialogValue: [],
                // panel 配置项目
                panel: {
                    usercode: '',
                    username: '',
                    compname: '',
                    keyword: '',
                    USERCODE: '',
                    endType: '',
                    taskstatus: 99,
                    draw: 1,
                    start: 0,
                    recordsTotal: 0,
                    tableData: [],
                    allTableData: [],
                    limit: '10',
                    multipleSort: false,
                    loading: false,
                    fileList: [],
                    multipleSelection: [],
                    detectedmac: '',
                    vipType: '',
                    expDay: '',
                    vipOptions: vipOptions(0),
                    endTypeOptions: endTypeOptions(),
                    time1: globalBt(),
                },
                multipleSelection: [],
                pageination: {
                    pageItem: 100,
                    pageoptions: pageOptions(),
                    total: 100,
                    pageIndex: 1,
                },
                form: {
                    phone: '',
                    name: '',
                    userCode: '',
                    shopId: '',
                    Id: '',
                    userId: '',
                    vipType: 1,
                    normalhour: 0,
                    gifthour: 0,
                    btnType: 0,//0新建，1编辑编辑
                    memo: '',
                    expTime: '',
                    classlist: [],
                    dialogdata: [],//穿梭待选
                    dialogValue: [],//穿梭已选
                },
                memberTypes: vipOptions(1),
                tableData: []
            }
        },
        mounted() {
            // 加载课程选项
            this.panelSelect();
            // 读取列表
            this.getTableQuery();
        },
        methods: {
            // 编辑
            editMember(row) {
                let that = this;
                this.clearForm();
                this.form.phone = row.UserInfo.Phone;
                this.form.name = row.UserInfo.Name;
                this.form.memo = row.UserInfo.Memo;
                this.form.btnType = 1;

                this.form.shopId = row.UserInfo.ShopId;
                this.form.Id = row.UserInfo.Id;
                this.dialogMemberVisible = true
                this.dialogTitle = '编辑会员'

            },
            // 禁用
            pauseRow(row) {
                let that = this;
                this.$confirm('是否禁用用户' + row.UserInfo.Name + '？', '禁用操作', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    let param = {
                        token: localStorage.token,
                        userId: row.UserInfo.Id,
                        status: 8,//状态 8：禁用 1：启用 9：删除
                    };
                    let postdata = qs.stringify(param);
                    VipUserStatusEdit(postdata).then(res => {
                        let json = res;
                        if (json.Code == 0) {
                            that.$message({
                                showClose: true,
                                message: row.UserInfo.Name + '禁用成功！',
                                type: 'success'
                            });
                            // table 重载
                            that.getTableQuery();
                        } else {
                            that.$message.error(json.Memo);
                        }
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消禁用'
                    });
                });
            },
            // 启用
            runRow(row) {
                let that = this;
                this.$confirm('是否启用用户' + row.UserInfo.Name + '？', '启用操作', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    let param = {
                        token: localStorage.token,
                        userId: row.UserInfo.Id,
                        status: 1,//状态 8：禁用 1：启用 9：删除
                    };
                    let postdata = qs.stringify(param);
                    VipUserStatusEdit(postdata).then(res => {
                        let json = res;
                        if (json.Code == 0) {
                            that.$message({
                                showClose: true,
                                message: row.UserInfo.Name + '启用成功！',
                                type: 'success'
                            });
                            // table 重载
                            that.getTableQuery();
                        } else {
                            that.$message.error(json.Memo);
                        }
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消启用'
                    });
                });
            },
            // 关闭所有
            allDialogClose() {
                this.dialogVisible = false;
                this.dialogGift = false;
                this.dialogLesson = false;
                this.dialogExpTime = false;
                this.dialogLessonTable = false;
            },
            // 用户禁用 todo
            // 用户启用 todo
            // 有效期调整
            ExpTimeChange() {
                // 仅针对年费用户，使用日期格式
                this.allDialogClose();
                if (!this.multipleSelection.length) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，需要先选中至少一条记录',
                        type: 'error'
                    });
                    return false
                }
                if (this.multipleSelection.length != 1) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，只能选中一条记录',
                        type: 'error'
                    });
                    return false
                }
                let row = this.multipleSelection[0];
                if (parseInt(row.UserInfo.VipType) == 2) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，充值会员不能调整有效期',
                        type: 'error'
                    });
                    return false
                }
                this.form.rowName = row.UserInfo.Name;
                this.form.userId = row.UserInfo.Id;
                this.form.expTime = row.UserInfo.ExpTime
                this.dialogVisible = true;
                this.dialogExpTime = true;
            },
            // 课时调整
            lessonChange() {
                this.allDialogClose();
                if (!this.multipleSelection.length) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，需要先选中至少一条记录',
                        type: 'error'
                    });
                    return false
                }
                if (this.multipleSelection.length != 1) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，只能选中一条记录',
                        type: 'error'
                    });
                    return false
                }
                let row = this.multipleSelection[0];
                this.form.normalhour = row.UserInfo.RemainNormalhour;
                this.form.rowName = row.UserInfo.Name;
                this.form.userId = row.UserInfo.Id;
                this.dialogVisible = true;
                this.dialogLesson = true;

            },
            // 赠送调整
            giftChange() {
                this.allDialogClose();
                if (!this.multipleSelection.length) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，需要先选中至少一条记录',
                        type: 'error'
                    });
                    return false
                }
                if (this.multipleSelection.length != 1) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，只能选中一条记录',
                        type: 'error'
                    });
                    return false
                }
                let row = this.multipleSelection[0];
                this.form.gifthour = row.UserInfo.RemainGifthour;
                this.form.rowName = row.UserInfo.Name;
                this.form.userId = row.UserInfo.Id;
                this.dialogVisible = true;
                this.dialogGift = true;

            },
            // 增删会员课程
            lessonStudenChange() {
                let that = this;
                this.allDialogClose();
                // 重载课程列表选项
                this.panelSelect();
                if (!this.multipleSelection.length) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，需要先选中至少一条记录',
                        type: 'error'
                    });
                    return false
                }
                if (this.multipleSelection.length != 1) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，只能选中一条记录',
                        type: 'error'
                    });
                    return false
                }
                let row = this.multipleSelection[0];
                this.form.rowName = row.UserInfo.Name;
                this.form.userId = row.UserInfo.Id;
                if (row.ClassInfo) {
                    row.ClassInfo.map(function (item) {
                        that.form.dialogValue.push(item.ClassId)
                    })
                }
                console.log(that.form.classlist);
                this.dialogVisible = true;
                this.dialogLessonTable = true;
            },
            // 确认提交新增会员
            confirmMember() {
                let that = this;
                // checkNum
                if (!that.form.phone) {
                    this.$message.error('错了哦，手机号不能为空');
                    return false
                }
                if (!globalCheckPhone(that.form.phone)) {
                    this.$message.error('错了哦，手机号格式不正确');
                    return false
                }
                if (!that.form.name) {
                    this.$message.error('错了哦，会员名不能为空');
                    return false
                }
                if (that.form.name.length > 8) {
                    this.$message.error('错了哦，会员名字数超过8个字');
                    return false
                }
                if (that.form.memo) {
                    if (that.form.memo.length > 200) {
                        this.$message.error('错了哦，备注字数超过200个字');
                        return false
                    }
                }
                // 课程添加使用字符串形式
                let curClasslist = '';
                if (that.form.classlist) {
                    curClasslist = that.form.classlist.toString();
                }

                let param = {
                    token: localStorage.token,
                    shopId: localStorage.shopId,
                    phone: that.form.phone,
                    name: that.form.name,
                    vipType: that.form.vipType,
                    normalhour: that.form.normalhour,
                    gifthour: that.form.gifthour,
                    classlist: curClasslist,
                    memo: that.form.memo,
                };
                let postdata = qs.stringify(param);
                VipUserAdd(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        // 关闭弹窗
                        that.dialogMemberVisible = false;
                        // 重载列表
                        that.getTableQuery();
                        that.$message({
                            showClose: true,
                            message: '会员添加成功！',
                            type: 'success'
                        });
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            confirmEditMember() {
                let that = this;
                // checkNum
                if (!that.form.phone) {
                    this.$message.error('错了哦，手机号不能为空');
                    return false
                }
                if (!globalCheckPhone(that.form.phone)) {
                    this.$message.error('错了哦，手机号格式不正确');
                    return false
                }
                if (!that.form.name) {
                    this.$message.error('错了哦，会员名不能为空');
                    return false
                }
                if (that.form.name.length > 8) {
                    this.$message.error('错了哦，会员名字数超过8个字');
                    return false
                }
                if (that.form.memo) {
                    if (that.form.memo.length > 200) {
                        this.$message.error('错了哦，备注字数超过200个字');
                        return false
                    }
                }
                let param = {
                    token: localStorage.token,
                    userId: that.form.Id,
                    phone: that.form.phone,
                    name: that.form.name,
                    memo: that.form.memo,
                };
                let postdata = qs.stringify(param);
                VipUserEdit(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        // 关闭弹窗
                        that.dialogMemberVisible = false;
                        // 重载列表
                        that.getTableQuery();
                        that.$message({
                            showClose: true,
                            message: '会员信息编辑成功！',
                            type: 'success'
                        });
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // 确认提交课时
            confirmLesson() {
                let that = this;
                // checkNum
                let param = {
                    token: localStorage.token,
                    userId: that.form.userId,
                    chgHour: that.form.normalhour,
                    chgType: 1,//课时类型 1：普通课时 2:赠送课时
                };
                let postdata = qs.stringify(param);
                VipUserHourEdit(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        // 关闭弹窗
                        that.dialogVisible = false;
                        // 重载列表
                        that.getTableQuery();
                        that.$message({
                            showClose: true,
                            message: '课时调整成功！',
                            type: 'success'
                        });
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // 确认提交赠送
            confirmGift() {
                let that = this;
                let param = {
                    token: localStorage.token,
                    userId: that.form.userId,
                    chgHour: that.form.gifthour,
                    chgType: 2,//课时类型 1：普通课时 2:赠送课时
                };
                let postdata = qs.stringify(param);
                VipUserHourEdit(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        // 关闭弹窗
                        that.dialogVisible = false;
                        // 重载列表
                        that.getTableQuery();
                        that.$message({
                            showClose: true,
                            message: '赠送课时调整成功！',
                            type: 'success'
                        });
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // 确认提交有效期
            confirmExpTime() {
                let that = this;
                // checkNum

                let param = {
                    token: localStorage.token,
                    userId: that.form.userId,
                    expTime: nonTfmtDate(that.form.expTime, 16),
                };
                let postdata = qs.stringify(param);
                VipUserExpEdit(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        // 关闭弹窗
                        that.dialogVisible = false;
                        // 重载列表
                        that.getTableQuery();
                        that.$message({
                            showClose: true,
                            message: '赠送课时调整成功！',
                            type: 'success'
                        });
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // 确认提交会员课程
            confirmLessonTable() {
                let that = this;
                // checkNum
                let classList = that.form.dialogValue ? that.form.dialogValue.toString() : '';

                let param = {
                    token: localStorage.token,
                    userId: that.form.userId,
                    classList: classList,
                };
                let postdata = qs.stringify(param);
                VipUserClassEdit(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        // 关闭弹窗
                        that.dialogVisible = false;
                        // 重载列表
                        that.getTableQuery();
                        that.$message({
                            showClose: true,
                            message: '会员课程调整成功！',
                            type: 'success'
                        });
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // 加载课程列表选项
            panelSelect() {
                let that = this;
                let param = {
                    token: localStorage.token,
                    vipType: '',
                    classType: 1,//不显示 午饭类 课程
                    start: 1,
                    expDay: 0,
                    tableMax: 9999,
                };
                let postdata = qs.stringify(param);
                ClassListQuery(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.form.dialogdata = turnClassResToOption(json.Rs);
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // 新增会员
            addMember() {
                this.clearForm();
                this.panelSelect();
                this.dialogMemberVisible = true
                this.btnType = 0;
                this.form.btnType = 0;
                this.dialogTitle = '新增会员'
            },
            // 删除
            delList() {
                let that = this;
                // checkNum
                if (!this.multipleSelection.length) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，需要先选中至少一条记录',
                        type: 'error'
                    });
                    return false
                }
                if (this.multipleSelection.length != 1) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，只能选中一条记录',
                        type: 'error'
                    });
                    return false
                }

                let detectorid = that.multipleSelection[0].UserInfo.Id;

                let param = {
                    token: localStorage.token,
                    userId: detectorid,
                    status: 9,//0禁用1启用9删除
                };
                let postdata = qs.stringify(param);

                this.$confirm('此操作将永久删除该会员, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    VipUserStatusEdit(postdata).then(res => {
                        let json = res;
                        if (json.Code == 0) {
                            that.$message({
                                showClose: true,
                                message: '选中的会员已删除！',
                                type: 'success'
                            });
                            // 重载列表
                            that.getTableQuery();
                        } else {
                            that.$message.error(json.Memo);
                        }
                    });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            // 查询按钮
            query() {
                this.getTableQuery();
                this.$message.success('查询完毕');
            },
            clearForm() {
                // clear
                this.form.name = '';
                this.form.userCode = '';
                this.form.shopId = '';
            },
            // 页面数据查询
            getTableQuery() {
                let that = this;
                that.loading = true;
                let param = {
                    token: localStorage.token,
                    vipType: that.panel.vipType,//
                    phone: that.panel.phone,//
                    name: that.panel.name,//
                    expDay: that.panel.expDay,//
                    start: 1,//
                    tableMax: 9999,//
                };
                let postdata = qs.stringify(param);
                VipUserListQuery(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.loading = false;
                        if (json.Rs) {
                            that.allTableData = json.Rs;
                            that.recordsTotal = json.Rs.length;
                        } else {
                            that.allTableData = [];
                            that.recordsTotal = 0;
                        }

                        // 设置分页数据
                        that.setPaginations();
                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // 设置分页数据
            setPaginations() {
                // 分页属性
                let that = this;
                that.pageination.total = that.recordsTotal;

                // 默认分页
                that.tableData = that.allTableData.filter((item, index) => {
                    return index < that.pageination.pageItem;
                });
            },
            // 每页显示数量
            handleSizeChange() {
                let that = this;
                that.tableData = that.allTableData.filter((item, index) => {
                    return index < that.pageination.pageItem;
                });
                that.draw = that.pageination.pageItem;
                that.getTableQuery();
            },
            // 翻页
            pageChange(pageIndex) {
                let that = this;
                // 获取当前页
                let index = that.pageination.pageItem * (pageIndex - 1);
                // 数据总数
                let nums = that.pageination.pageItem * pageIndex;
                // 容器
                let tables = [];
                for (var i = index; i < nums; i++) {
                    if (that.allTableData[i]) {
                        tables.push(that.allTableData[i])
                    }
                    this.tableData = tables;
                }
                that.start = index * that.draw;
                that.getTableQuery();
            },
            // 过滤时间
            filterFmtDate(value, row, column) {
                let that = this;
                if (column == "0001-01-01T08:05:43+08:05") {
                    return '无有效期';
                } else {
                    return nonTfmtDate(column, 11);
                }
            },
        },
    }
</script>

<style scoped>
    @import "../assets/css/panel.css";

    .context {
        border-radius: 12px;
        height: 770px;
        overflow-y: scroll;
        display: block;
        margin: 0 auto;
        background-color: #fff !important;
        padding: 30px;
        padding-bottom: 30px;
    }

    .panel-body {
        padding: 20px;
        background: #F0F2F5;
    }

    .change {
        width: 100%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .change button {
        float: left;
    }

    .change button.pull-right {
        float: right;
    }

    .dialogTitle {
        width: 100%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
        color: #000000;
        font-size: 18px;
        text-align: center;
    }

    .dialogTitle em {
        float: none;
        font-style: normal;
        color: #3799FF;
        margin: 0;
    }

    /deep/ .el-transfer-panel__item .el-checkbox__input {
        left: 40px;
    }

    .dialogFooter {
        width: 90%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
        margin-top: 10px;
    }

    .dialogFooter button {
        float: right;
        margin-left: 10px;
    }

    .dialogContent {
        width: 100%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
    }

    .dialogContent .pull-left {
        width: 30%;
        float: left;
    }

    .dialogContent .pull-right {
        width: 70%;
        float: right;
    }

    .tabwild {
        width: 100% !important;
        overflow: hidden;
        display: block;
        margin: 0 auto;
    }

    .lessonSpan {
        width: 78px;
        height: 22px;
        border-radius: 11px;
        margin-right: 5px;
        float: left;
        margin-bottom: 3px;
        text-align: center;
        color: #545454;
        font-size: 12px;
    }

    .btn {
        float: left !important;
        margin-right: 5px;
    }
</style>
