plan.js
8.8 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
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
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function (params) {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: (params?params.index_url:'facrm/contract/plan/index')+ location.search,
add_url: 'facrm/contract/plan/add',
edit_url: 'facrm/contract/plan/edit',
del_url: 'facrm/contract/plan/del',
multi_url: 'facrm/contract/plan/multi',
import_url: 'facrm/contract/plan/import',
table: 'facrm_contract_plan',
}
});
var table = $("#table");
var plan_time = Backend.api.query('plan_time');
var statusstr = Backend.api.query('status');
//在普通搜索渲染后
table.on('post-common-search.bs.table', function (event, table) {
$("input[name='plan_time']").val(plan_time?plan_time:'');
});
var columnss = [
{checkbox: true},
{field: 'id', title: __('Id'), sortable: true,},
{
field: 'customer_id', title: __('客户'), formatter: function (value, row, index) {
if (!row.customer) return '-';
return '<a href="javascript:void(0);" data-url="facrm/customer/index/detail/ids/' + row.customer.id
+ '" data-area="["98%","98%"]" class="btn-dialog" data-title="' + row.customer.name + '">' + row.customer.name + '(' + row.customer_id + ')' + '</a>';
}
},
{
field: 'contract_id', title: __('合同编号'), align: 'left', formatter: function (value, row, index) {
if (!row.contract) return '-';
return '<a href="javascript:void(0);" data-url="facrm/contract/index/detail/ids/' + row.contract_id
+ '" data-area="["98%","98%"]" class="btn-dialog" data-title="合同详情:' + row.contract.number + '">' + row.contract.number + '</a>';
},
addclass: 'selectpage',
extend: 'data-source="facrm/contract/index/selectpage" data-field="name"'
},
{
field: 'name',
title: __('计划名称'),
operate: 'LIKE',
table: table,
class: 'autocontent',
formatter: Table.api.formatter.content
},
{field: 'money', title: __('Money'), operate: 'BETWEEN', sortable: true,},
{
field: 'status',
title: __('状态'),
sortable: true,
formatter: Table.api.formatter.status,
searchList: Config.status_list, operate: 'in', addClass:'selectpicker', data:"multiple",
},
{
field: 'remarks',
title: __('Remarks'),
operate: 'LIKE',
table: table,
class: 'autocontent',
formatter: Table.api.formatter.content
},
{
field: 'plan_time',
title: __('Plan_time'),
operate: 'RANGE',
addclass: 'datetimerange',
autocomplete: false,
datetimeFormat: "YYYY-MM-DD",
formatter: Table.api.formatter.datetime,
sortable: true,
},
{
field: 'create_time',
title: __('Create_time'),
operate: 'RANGE',
addclass: 'datetimerange',
autocomplete: false,
formatter: Table.api.formatter.datetime, sortable: true,
},
{
field: 'update_time',
title: __('Update_time'),
operate: 'RANGE',
addclass: 'datetimerange',
autocomplete: false,
formatter: Table.api.formatter.datetime
},
{
field: 'account_id',
title: __('收款账户'),
formatter: Table.api.formatter.status,
searchList: Config.account_list
},
{
field: 'admin_id',
title: __('Admin_id'),
addclass: "selectpage",
formatter: function (v, r) {
if (!r.admin) return '-';
return r.admin.nickname;
},
extend: 'data-source="facrm/common/selectpage/model/admin?type=all" data-field="nickname" data-orderBy="id desc"'
},
];
if (params && params.hasOwnProperty('select')) {
//如果是选择
columnss.push({
field: 'operate', title: __('Operate'), events: {
'click .btn-chooseone': function (e, value, row, index) {
Fast.api.close(row);
},
},
formatter: function () {
return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
}
});
} else {
columnss.push({
field: 'operate',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'complete',
text: '回款',
title: __('回款'),
icon: 'fa fa-check-circle',
classname: 'btn btn-xs btn-info btn-dialog',
url:function(row){
return 'facrm/contract/receivables/add/ids/'+row.contract_id+"?plan_id="+row.id;
},
hidden:function (row) {
if (row.status==2) return true;
},
success:function () {
$(".btn-refresh").trigger('click');
}
},
]});
}
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
columns: [
columnss
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
Controller.api.selectcontracts();
},
edit: function () {
Controller.api.bindevent();
},
select: function () {
Controller.index({
select: true,
index_url: 'facrm/contract/plan/select'
});
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
},
selectcontracts: function () {
$("#c-customer_id").bind("change", function () {
$("#select-resources").html("点击请选择");
$("input[name='row[c-contract_id]']").val(0);
});
var refreshkey = function (data) {
console.log(data);
var contracts_id = data.id;
$("input[name='row[contract_id]']").val(data.id).trigger("change");
$("#select-resources").html(data.name);
$('#c-customer_id').val(data.customer_id);
$('#c-customer_id').selectPageRefresh();
};
$(document).on('click', "#select-resources", function () {
var customer_id = $("input[name='row[customer_id]']").val();
parent.Backend.api.open($(this).data("url") + "?customer_id=" + customer_id, __('Select'), {callback: refreshkey});
return false;
});
},
}
};
return Controller;
});