刘帅
2026-09-08 572df690f72ed4a077d934823f261dec39b3cc7d
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
/**
 * 管理初始化
 */
var TPayInfo = {
    id: "TPayInfoTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1,
};
/**
 * 初始化表格的列
 */
TPayInfo.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title: '联系方式', field: 'phone', visible: true, align: 'center', valign: 'middle'},
        {title: '购买时间', field: 'payTime', visible: true, align: 'center', valign: 'middle'},
        {title: '支付流水号', field: 'orderNumber', visible: true, align: 'center', valign: 'middle'},
        {title: '使用状态', field: 'status', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row, index) {
                return {1: "未使用", 2: "已核销"}[value]
            }
        },
        {title: '入园方式', field: 'goType', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row, index) {
                return {1: "手环", 2: "门票核销"}[value] || "-";
            }
        },
    ];
};
TPayInfo.openAddTSite = function () {
    if (TPayInfo.check()) {
        if (TPayInfo.seItem.status === 2) {
            return Feng.error("该门票已核销!");
        }
        // 门票管理页提供独立模板;其他复用该脚本的页面继续使用兼容的默认模板。
        var entryMethodContent = $("#ticketEntryMethodTemplate").html() ||
            '<div class="form-horizontal"><div class="col-sm-11"><div class="col-sm-11"><div class="form-group">' +
            '<label class="col-sm-3 control-label">请选择:</label><div class="col-sm-9" style="margin-top: 5px;">' +
            '<input type="radio" id="areaType1" value="1" name="areaType" checked><label for="areaType1">手环</label>' +
            '<input type="radio" id="areaType2" value="2" name="areaType"><label for="areaType2">门票核销</label>' +
            '</div></div></div></div></div>';
        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
            // 页面模板中集中维护选项文案与 goType 值,避免前后端页面出现两份配置。
            , content: entryMethodContent
 
            , btn: ['确认', '关闭']
            , btnAlign: 'c' //按钮居中
            , shade: 0.5 //不显示遮罩
            , load: 1
            , btn2: function () {
                layer.closeAll();
            },
            yes: function () {
                // 入园方式必须随核销请求提交,后端会保存该次核销所选方式。
                var goType = $("input[name='areaType']:checked").val();
                if (!goType) {
                    return Feng.error("请选择入园方式!");
                }
                var ajax = new $ax(Feng.ctxPath + "/ticket/writeOff", function (data) {
                    TPayInfo.search();
                    Feng.success("核销成功!");
                }, function (data) {
                    Feng.error("核销失败!" + (data.responseJSON ? data.responseJSON.message : ""));
                });
                ajax.set("id", TPayInfo.seItem.id);
                ajax.set("goType", goType);
                ajax.start();
                layer.closeAll();
            }
        });
        this.layerIndex = index;
    }
};
/**
 * 检查是否选中
 */
TPayInfo.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TPayInfo.seItem = selected[0];
        return true;
    }
};
 
 
/**
 * 核销操作
 * @constructor
 */
TPayInfo.WriteOff = function (){
    if (TPayInfo.check()) {
        if (TPayInfo.seItem.status === 2){
            return Feng.error("重复核销!");
        }
        var ajax = new $ax(Feng.ctxPath + "/tGoods/write_off", function (data) {
            Feng.success("核销成功!");
            TPayInfo.table.refresh();
        }, function (data) {
            Feng.error("核销失败!" + data.responseJSON.message + "!");
        });
        ajax.set("id",TPayInfo.seItem.id);
        ajax.start();
    }
}
 
 
/**
 * 关闭此对话框
 */
TPayInfo.close = function() {
    parent.layer.close(window.parent.TPointProducts.layerIndex);
}
 
 
/**
 * 查询列表
 */
TPayInfo.search = function () {
    var queryData = {};
    queryData['name'] = $("#name").val();
    queryData['phone'] = $("#phone").val();
    queryData['status'] = $("#status").val();
    queryData['id'] = $("#id").val();
    TPayInfo.table.refresh({query: queryData});
};
 
 
/**
 * 重置搜索
 */
TPayInfo.resetSearch = function () {
    $("#name").val('');
    $("#phone").val('');
    $("#status").val('');
    TPayInfo.search();
};
 
$(function () {
    let goodsId =  $("#id").val();
    var defaultColunms = TPayInfo.initColumn();
    var table = new BSTable(TPayInfo.id, "/tGoods/payList/"+goodsId, defaultColunms);
    table.setPaginationType("client");
    TPayInfo.table = table.init();
});