user_house.js
3.0 KB
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
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user_house/index' + '/ids/' + Config.ids + location.search,
table: 'user_house',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
search:false,
showToggle: false,
showColumns: false,
showExport: false,
commonSearch: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'), operate:false},
{field: 'user.nickname', title: __('用户昵称'), operate:false},
{field: 'user.id', title: __('用户ID'), operate:false},
{field: 'name', title: __('电话名称'), operate:false},
{field: 'phone', title: __('电话')},
{field: 'status', title: __('绑定状态'), searchList: {'1':'申请中','2':'已绑定','3':'已拒绝'}, formatter: Table.api.formatter.normal},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons:
[
{
name: '同意',
text: function (row) {
if(row.status == 2){
return '已同意';
}else{
return '同意申请';
}
},
title: function (row) {
if(row.status == 2){
return '已同意';
}else{
return '同意申请';
}
},
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
icon: 'fa fa-magic',
url: 'user_house/agree',
confirm: '确认发送',
success: function (data, ret) {
Layer.alert(ret.msg);
//如果需要阻止成功提示,则必须使用return false;
//return false;
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
},
disable: function (row) {
//返回true时按钮显示,返回false隐藏
if(row.status == 2){
return true;
}
}
},
], formatter: Table.api.formatter.operate,
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});