125 lines
6.2 KiB
JavaScript
125 lines
6.2 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||
|
||
var Controller = {
|
||
index: function () {
|
||
// 初始化表格参数配置
|
||
Table.api.init({
|
||
extend: {
|
||
index_url: 'version/index',
|
||
add_url: 'version/add',
|
||
edit_url: 'version/edit',
|
||
del_url: 'version/del',
|
||
table: 'version',
|
||
dragsort_url: "",
|
||
}
|
||
});
|
||
|
||
var table = $("#table");
|
||
|
||
// 初始化表格
|
||
table.bootstrapTable({
|
||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||
sortName: 'id',
|
||
showExport: false,
|
||
columns: [
|
||
[
|
||
{field: 'state', checkbox: true},
|
||
{field: 'id', title: __('Id')},
|
||
{field: 'version', title: __('Version')},
|
||
{
|
||
field: 'size', title: __('Size'), operate: 'BETWEEN', sortable: true, formatter: function (value, row, index) {
|
||
var size = parseFloat(value);
|
||
var i = Math.floor(Math.log(size) / Math.log(1024));
|
||
return (size / Math.pow(1024, i)).toFixed(i < 2 ? 0 : 2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
|
||
}
|
||
},
|
||
{field: 'sys', title: __('Sys')},
|
||
{field: 'cpu', title: __('Cpu')},
|
||
{field: 'oem', title: __('Oem')},
|
||
{field: 'app', title: __('App')},
|
||
{field: 'dev_type', title: __('Dev_type')},
|
||
{field: 'content', title: __('Content'), operate:false,
|
||
formatter : function(value, row, index, field){
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.content + "'>" + value + "</span>";
|
||
},
|
||
cellStyle : function(value, row, index, field){
|
||
return {
|
||
css: {
|
||
"white-space": "nowrap",
|
||
"text-overflow": "ellipsis",
|
||
"overflow": "hidden",
|
||
"max-width":"150px"
|
||
}
|
||
};
|
||
}
|
||
},
|
||
{field: 'bug', title: 'Bug描述', operate:false,
|
||
formatter : function(value, row, index, field){
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.bug + "'>" + value + "</span>";
|
||
},
|
||
cellStyle : function(value, row, index, field){
|
||
return {
|
||
css: {
|
||
"white-space": "nowrap",
|
||
"text-overflow": "ellipsis",
|
||
"overflow": "hidden",
|
||
"max-width":"150px"
|
||
}
|
||
};
|
||
}
|
||
},
|
||
{field: 'createtime', width: '110', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
|
||
{field: 'updatetime', width: '110', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
|
||
// {field: 'status', title: __('Status'), searchList: {"normal":__('正常'),"hidden":__('作废')}, formatter: Table.api.formatter.status},
|
||
{field: 'operator', title: __('Operator')},
|
||
{
|
||
field: 'operate', title: __('Operate'), table: table,
|
||
events: Table.api.events.operate,
|
||
// buttons: [{
|
||
// name: 'ajax',
|
||
// title: '版本作废',
|
||
// classname: 'btn btn-xs btn-danger btn-remove btn-ajax',
|
||
// icon: 'fa fa-times',
|
||
// confirm: '确认作废该版本吗?作废后将无法恢复。',
|
||
// url: 'version/cancel',
|
||
// success: function (data, ret) {
|
||
// Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
|
||
// //如果需要阻止成功提示,则必须使用return false;
|
||
// //return false;
|
||
// $("#table").bootstrapTable('refresh');
|
||
// },
|
||
// error: function (data, ret) {
|
||
// console.log(data, ret);
|
||
// Layer.alert(ret.msg);
|
||
// return false;
|
||
// }
|
||
// },],
|
||
formatter: Table.api.formatter.operate
|
||
}
|
||
]
|
||
]
|
||
});
|
||
|
||
// 为表格绑定事件
|
||
Table.api.bindevent(table);
|
||
},
|
||
add: function () {
|
||
$("#plupload-downloadurl").data("upload-success", function(data, ret){
|
||
//这里进行后续操作
|
||
console.log(ret.data.size);
|
||
$("#c-size").val(ret.data.size);
|
||
$("#c-md5").val(ret.data.md5);
|
||
});
|
||
Controller.api.bindevent();
|
||
},
|
||
edit: function () {
|
||
Controller.api.bindevent();
|
||
},
|
||
api: {
|
||
bindevent: function () {
|
||
Form.api.bindevent($("form[role=form]"));
|
||
}
|
||
}
|
||
};
|
||
return Controller;
|
||
}); |