44323
2023-10-07 e6ee956618b3c1a6371a6c22dfbb70868dbd3f17
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/**
 * 跨城站点管理管理初始化
 */
var TSite = {
    id: "TSiteTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1,
    picture:"",
    fileUrl:"",
    img:"",
    plan:"",
    goodsPicArray:[],
    validateFields: {
    }
};
/**
 * 初始化表格的列
 */
TSite.initColumn = function () {
    return [
        {field: 'selectItem', checkbox: true},
        {title: '主键ID', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '运营商名称', field: 'name', visible: true, align: 'center', valign: 'middle',width:'20%',
 
        },
        {title: '管理员姓名', field: 'userName', visible: true, align: 'center', valign: 'middle',
        },
        {title: '管理员手机号', field: 'phone', visible: true, align: 'center', valign: 'middle'},
        {title: '管理区域', field: 'type', visible: true, align: 'center', valign: 'middle',
            formatter:function (data) {
                return {1:"全国",2:"指定区域"}[data]
            }
        },
        {title: '商户绑定状态', field: 'status', visible: true, align: 'center', valign: 'middle',
            formatter: function (data,row) {
                var btn = "";
                if(data==1) {
                    var str = '<button class="btn btn-outline btn-primary" onclick="TSite.bindOperator('+row.id+')" >去绑定</button>'
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="" onfocus="TUser.tooltip()">' + str + '</p>']
                }else{
                    var str = '<h3>已绑定</h3>'
                    btn = [str]
                }
                return btn;
            }
        },
        {title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
            formatter:function (data) {
                return {1:"正常",2:"冻结",3:"删除"}[data]
            }
        },
    ];
};
 
/**
 * 检查是否选中
 */
TSite.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TSite.seItem = selected[0];
        return true;
    }
};
TSite.bindOperator = function (e) {
    var index = layer.open({
        type: 2,
        title: "认证",
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/operatorUser/proportion/' + e
    });
    this.layerIndex = index;
 
};
/**
 * 上架
 */
TSite.onShelf = function () {
    if (this.check()){
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        const data1 = {
            ids:[],
            state:null
        };
        selected.forEach(function(obj) {
            console.log("查看选中")
            console.log(obj)
            var id = obj.id;
            data1.ids.push(id);
        });
        data1.state = 1;
 
        $.ajax({
            url: Feng.ctxPath + "/operator/changeState",
            type: "POST",
            contentType: "application/json", // 设置请求头的 Content-Type
            data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
            success: function(response) {
                Feng.success("解冻成功!");
                TSite.search();
            },
            error: function(xhr, status, error) {
                var errorMessage = xhr.responseText ? xhr.responseText : "解冻失败!";
            }
        });
    }
};
 
/**
 * 下架
 */
TSite.offShelf = function () {
    if (this.check()){
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        const data1 = {
            ids:[],
            state:null
        };
        selected.forEach(function(obj) {
            var id = obj.id;
            data1.ids.push(id);
        });
        data1.state = 2;
        $.ajax({
            url: Feng.ctxPath + "/operator/changeState",
            type: "POST",
            contentType: "application/json", // 设置请求头的 Content-Type
            data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
            success: function(response) {
                Feng.success("冻结成功!");
                TSite.search();
            },
            error: function(xhr, status, error) {
                var errorMessage = xhr.responseText ? xhr.responseText : "冻结失败!";
            }
        });
    }
};
 
 
/**
 * 跳转添加运营商页面
 */
TSite.openAddTSite = function () {
 
    var index = layer.open({
        type: 2,
        title: "添加运营商",
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/operator/add'
    });
    this.layerIndex = index;
};
/**
 * 打开场地管理查看详情
 */
TSite.openInfo = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length >1 ){
        Feng.info("只能选择一个问题进行编辑!");
    }else {
        if (this.check()) {
            var index = layer.open({
                type: 2,
                title: "编辑运营商",
                area: ['100%', '100%'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/operator/update/' + TSite.seItem.id
            });
            this.layerIndex = index;
        }
    }
};
TSite.reload = function () {
    if (this.check()) {
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        const data1 = {
            ids:[],
            password:null
        };
        selected.forEach(function(obj) {
            var id = obj.id;
            data1.ids.push(id);
        });
        data1.state = 2;
        var operation = function() {
            $.ajax({
                url: Feng.ctxPath + "/operator/pwd",
                type: "POST",
                contentType: "application/json", // 设置请求头的 Content-Type
                data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
                success: function (response) {
                    TSite.search();
                },
                error: function (xhr, status, error) {
                    var errorMessage = xhr.responseText ? xhr.responseText : "冻结失败!";
                }
            });
        }
 
        Feng.confirm("确认重置密码?重置后密码为:a123456", operation);
    }
};
/**
 * 关闭此对话框
 */
TSite.close = function() {
    parent.layer.close(window.parent.TSite.layerIndex);
};
 
TSite.search = function () {
    var queryData = {};
    queryData['userName']  = $("#name").val();
    queryData['phone'] =$("#phone").val();
    queryData['type'] =$("#type").val();
    TSite.table.refresh({query: queryData});
};
 
TSite.resetSearch = function () {
    $("#name").val("");
    $("#phone").val("");
    $("#type").val("");
    TSite.search();
};
 
$(function () {
    var defaultColunms = TSite.initColumn();
    var table = new BSTable(TSite.id, "/operator/listAll", defaultColunms);
    table.setPaginationType("server");
    TSite.table = table.init();
});