puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
/**
 * 管理初始化
 */
var TCouponExamine = {
    id: "TCouponExamineTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
TCouponExamine.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '所属账号', field: 'account', visible: true, align: 'center', valign: 'middle'},
        {title: '优惠券名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title: '适用范围', field: 'useScope', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row, index) {
                return {1: "全国", 2: "指定城市", 3: "指定门店"}[value]
            }
        },
        {title: '优惠券类型', field: 'type', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row, index) {
                return {1: "满减券", 2: "代金券", 3: "体验券"}[value]
            }},
        {title: '发放方式', field: 'distributionMethod', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row, index) {
                return {1: "积分购买", 2: "注册赠送", 3: "自动发券",4:"课包赠送"}[value]
            }},
        {title: '有效期', field: 'timeValue', visible: true, align: 'center', valign: 'middle'},
        {title: '用户人群', field: 'userPopulation', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row, index) {
                return {1: "全部用户", 2: "年度会员", 3: "已有学员用户"}[value]
            }},
        {title: '发放数量', field: 'quantityIssued', visible: true, align: 'center', valign: 'middle'},
        {title: '限领数量', field: 'pickUpQuantity', visible: true, align: 'center', valign: 'middle'},
        {title: '审核状态', field: 'auditStatus', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row, index) {
                return {1: "待审核", 3: "未通过"}[value]
            }}
    ];
};
 
/**
 * 检查是否选中
 */
TCouponExamine.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TCouponExamine.seItem = selected[0];
        return true;
    }
};
 
 
/**
 * 打开查看详情
 */
TCouponExamine.openDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '详情',
            area: ['95%', '95%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tCouponExamine/couponOfDetail/' + TCouponExamine.seItem.id
        });
        this.layerIndex = index;
    }
};
 
TCouponExamine.openExamine = function () {
    if (this.check()) {
        var auditStatus= TCouponExamine.seItem.auditStatus;
        if (auditStatus == 3){
            Feng.error("当前状态不可再次审核!");
            return ;
        }
        var index = layer.load(1,{
            type: 1
            , title: '优惠券审核'
            , area: ['50%', '50%']
            , offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
            , id: 'layerDemo' //防止重复弹出cge
            , content: '<div class="form-horizontal">' +
                '                    <div class="col-sm-11" >' +
                '                    <div class="col-sm-11">' +
                '                        <div class="form-group">\n' +
                '                            <label class="col-sm-3 control-label">审核状态:</label>\n' +
                '                            <div class="col-sm-9">\n' +
                '                     <input type="radio" name="r1" value="2" checked> 通过   <input type="radio" name="r1" value="3" > 拒绝     '+
                '                            </div>\n' +
                '                        </div>\n' +
                '                        <div class="form-group">\n' +
                '                            <label class="col-sm-3 control-label">拒绝理由:</label>\n' +
                '                            <div class="col-sm-9">\n' +
                '                     <textarea id="text" style="width: 460px; height: 138px;"></textarea>  '+
                '                            </div>\n' +
                '                        </div>\n' +
                '                       </div>' +
                '                   </div>' +
                '</div>'
            , btn: ['关闭', '保存']
            , btnAlign: 'c' //按钮居中
            , shade:  0.5 //不显示遮罩
            ,load:1
            , yes: function () {
                layer.closeAll();
            },
            btn2:function () {
 
                var id = TCouponExamine.seItem.id;
                let audit = document.querySelector('input[name="r1"]:checked').value;
                let text = $("#text").val()
                if(audit==3){
                    if(text==''){
                        Feng.info("请输入拒绝理由")
                        return false;
                    }
                }
 
                var ajax = new $ax(Feng.ctxPath + "/tCouponExamine/examine", function (data) {
                    if (data.code == 200) {
                        Feng.success("操作成功!");
                        window.location.reload();
                        window.parent.layer.closeAll();
                    } else if(data=="repeat"){
                        window.location.reload();
                        window.parent.layer.closeAll();
                        Feng.error("请勿重复操作");
                    }else {
                        return  Feng.error(data.msg);
                    }
                }, function (data) {
                    Feng.error("操作失败!")
                    window.location.reload();
                    window.parent.layer.closeAll();
                    return   Feng.error("操作失败!");
                });
 
                ajax.set("id", id);
                ajax.set("state", audit);
                ajax.set("remark", text);
                ajax.start();
                layer.closeAll();
            }
        });
 
        this.layerIndex = index;
    }
};
 
 
/**
 * 查询列表
 */
TCouponExamine.search = function () {
    var queryData = {};
    queryData['name'] = $("#name").val();
    queryData['type'] = $("#type").val();
    queryData['distributionMethod'] = $("#distributionMethod").val();
    queryData['userPopulation'] = $("#userPopulation").val();
    queryData['auditStatus'] = $("#auditStatus").val();
    TCouponExamine.table.refresh({query: queryData});
};
 
 
/**
 * 重置搜索
 */
TCouponExamine.resetSearch = function () {
    $("#name").val('');
    $("#type").val('');
    $("#distributionMethod").val('');
    $("#userPopulation").val('');
    $("#auditStatus").val('');
    TCouponExamine.search();
};
 
$(function () {
    var defaultColunms = TCouponExamine.initColumn();
    var table = new BSTable(TCouponExamine.id, "/tCouponExamine/list", defaultColunms);
    table.setPaginationType("client");
    TCouponExamine.table = table.init();
});