xuhy
2023-03-06 3bcf6a65dfb9813dff2986c9cc03b638742ce64e
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
/**
 * 管理初始化
 */
var TBranchOffice = {
    id: "TBranchOfficeTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
TBranchOffice.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '主键', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '代理商id', field: 'agentId', visible: false, align: 'center', valign: 'middle'},
        {title: '添加时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
        {title: '分公司名称', field: 'branchOfficeName', visible: true, align: 'center', valign: 'middle'},
        {title: '负责人姓名', field: 'principal', visible: true, align: 'center', valign: 'middle'},
        {title: '负责人电话', field: 'principalPhone', visible: true, align: 'center', valign: 'middle'},
        {title: '邮箱', field: 'email', visible: false, align: 'center', valign: 'middle'},
        {title: '代理区域省编号', field: 'provinceCode', visible: false, align: 'center', valign: 'middle'},
        {title: '代理区域省名称', field: 'provinceName', visible: false, align: 'center', valign: 'middle'},
        {title: '代理区域市编号', field: 'cityCode', visible: false, align: 'center', valign: 'middle'},
        {title: '代理区域市名称', field: 'cityName', visible: false, align: 'center', valign: 'middle'},
        {title: '代理区域区编号', field: 'districtCode', visible: false, align: 'center', valign: 'middle'},
        {title: '代理区域区名称', field: 'districtName', visible: false, align: 'center', valign: 'middle'},
 
        {title: '订单数量', field: 'principalPhone', visible: true, align: 'center', valign: 'middle'},
        {title: '有效订单', field: 'principalPhone', visible: true, align: 'center', valign: 'middle'},
        {title: '已发放优惠券', field: 'principalPhone', visible: true, align: 'center', valign: 'middle'},
        {title: '已使用优惠券', field: 'principalPhone', visible: true, align: 'center', valign: 'middle'},
        {title: '累计优惠券金额', field: 'principalPhone', visible: true, align: 'center', valign: 'middle'},
 
        {title: '经营业务', field: 'operatingBusiness', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                if (row.operatingBusiness === 1){
                    return '<span>司机代驾</span>'
                }
            }
        },
 
        {title: '司机数', field: 'driverCount', visible: true, align: 'center', valign: 'middle'},
        {title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                if (row.status === 1){
                    return '<span>正常</span>'
                }else if(row.status === 2){
                    return '<span>冻结</span>'
                }else if (row.status === 3){
                    return '<span>已删除</span>'
                }
            }
        },
        {title: '操作', visible: true, align: 'center', valign: 'middle',width:150,
            formatter: function (value, row) {
                return '<a href="#" onclick="TBranchOffice.searchTBranchOfficeDetail('+row.id+')" style="color:blue">详情</a>' +'&nbsp;' +
                    '<a href="#" onclick="TBranchOffice.delete('+row.id+')" style="color:red">删除</a>'
            }
        }
    ];
};
 
/**
 * 检查是否选中
 */
TBranchOffice.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TBranchOffice.seItem = selected[0];
        return true;
    }
};
 
/**
 * 点击添加
 */
TBranchOffice.openAddTBranchOffice = function () {
    var index = layer.open({
        type: 2,
        title: '添加',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tBranchOffice/tBranchOffice_add'
    });
    this.layerIndex = index;
};
 
/**
 * 打开查看详情
 */
TBranchOffice.openTBranchOfficeDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tBranchOffice/tBranchOffice_update/' + TBranchOffice.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 打开查看详情(使用中)
 */
TBranchOffice.searchTBranchOfficeDetail = function (id) {
    var index = layer.open({
        type: 2,
        title: '详情',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tBranchOffice/tBranchOfficeDetail?tBranchOfficeId=' + id
    });
    this.layerIndex = index;
};
 
/**
 * 删除
 */
TBranchOffice.delete = function (id) {
    var ajax = new $ax(Feng.ctxPath + "/tBranchOffice/delete", function (data) {
        Feng.success("删除成功!");
        TBranchOffice.table.refresh();
    }, function (data) {
        Feng.error("删除失败!" + data.responseJSON.message + "!");
    });
    ajax.set("tBranchOfficeId",id);
    ajax.start();
};
 
/**
 * 提交冻结
 */
TBranchOffice.stop = function () {
    if(this.check()){
        if(2 == this.seItem.status){
            Feng.error("该条数据已冻结!");
            return;
        }
        var ajax = new $ax(Feng.ctxPath + "/tBranchOffice/stop?id="+this.seItem.id, function (data) {
            if(500 == data.code){
                Feng.error(data.message);
                return;
            }else {
                Feng.success("冻结成功!");
                TBranchOffice.table.refresh();
            }
        }, function (data) {
            Feng.error("冻结失败!" + data.message + "!");
        });
        ajax.start();
    }
};
 
/**
 * 提交启用
 */
TBranchOffice.start = function () {
    if(this.check()){
        if(1 == this.seItem.status){
            Feng.error("该条数据已启用!");
            return;
        }
        var ajax = new $ax(Feng.ctxPath + "/tBranchOffice/start?id="+this.seItem.id, function (data) {
            if(500 == data.code){
                Feng.error(data.message);
                return;
            }else {
                Feng.success("启用成功!");
                TBranchOffice.table.refresh();
            }
        }, function (data) {
            Feng.error("启用失败!" + data.message + "!");
        });
        ajax.start();
    }
};
 
/**
 * 查询列表
 */
TBranchOffice.search = function () {
    var queryData = {};
    queryData['branchOfficeName'] = $("#branchOfficeName").val();
    queryData['principal'] = $("#principal").val();
    queryData['principalPhone'] = $("#principalPhone").val();
    queryData['operatingBusiness'] = $("#operatingBusiness").val();
    queryData['status'] = $("#status").val();
    TBranchOffice.table.refresh({query: queryData});
};
 
/**
 * 重置
 */
TBranchOffice.resetSearch = function (){
    $("#branchOfficeName").val('');
    $("#principal").val('');
    $("#principalPhone").val('');
    $("#operatingBusiness").val('');
    $("#status").val('');
    TBranchOffice.search();
}
 
$(function () {
    var defaultColunms = TBranchOffice.initColumn();
    var table = new BSTable(TBranchOffice.id, "/tBranchOffice/list", defaultColunms);
    table.setPaginationType("client");
    TBranchOffice.table = table.init();
});