2025-05-20 16:33:23 +08:00
|
|
|
|
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
|
|
|
|
|
|
var Controller = {
|
|
|
|
|
index: function () {
|
|
|
|
|
// 初始化表格参数配置
|
|
|
|
|
Table.api.init({
|
|
|
|
|
extend: {
|
|
|
|
|
index_url: 'home/news/index' + location.search,
|
|
|
|
|
add_url: 'home/news/add',
|
|
|
|
|
edit_url: 'home/news/edit',
|
|
|
|
|
del_url: 'home/news/del',
|
|
|
|
|
multi_url: 'home/news/multi',
|
|
|
|
|
import_url: 'home/news/import',
|
|
|
|
|
table: 'news',
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var table = $("#table");
|
|
|
|
|
|
|
|
|
|
// 初始化表格
|
|
|
|
|
table.bootstrapTable({
|
|
|
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
|
|
|
pk: 'id',
|
|
|
|
|
sortName: 'weigh',
|
|
|
|
|
fixedColumns: true,
|
|
|
|
|
fixedRightNumber: 1,
|
|
|
|
|
columns: [
|
|
|
|
|
[
|
|
|
|
|
{checkbox: true},
|
|
|
|
|
{field: 'id', title: __('Id')},
|
|
|
|
|
{field: 'cate_id', title: __('Cate_id')},
|
2025-05-21 18:06:43 +08:00
|
|
|
|
{field: 'cate.name', title: __('Cate.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
|
// {field: 'flag', title: __('Flag'), operate: 'LIKE', formatter: Table.api.formatter.flag},
|
2025-05-20 16:33:23 +08:00
|
|
|
|
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
|
{field: 'subtitle', title: __('Subtitle'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
2025-05-21 18:06:43 +08:00
|
|
|
|
|
|
|
|
|
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
|
2025-05-20 16:33:23 +08:00
|
|
|
|
// {field: 'content', title: __('Content')},
|
2025-05-21 18:06:43 +08:00
|
|
|
|
{field: 'file', title: __('File'), operate: false, formatter: Table.api.formatter.file},
|
2025-05-20 16:33:23 +08:00
|
|
|
|
{field: 'recommend', title: __('Recommend'), searchList: {"0":__('Recommend 0'),"1":__('Recommend 1')}, formatter: Table.api.formatter.normal},
|
2025-05-21 18:06:43 +08:00
|
|
|
|
{field: 'hot', title: __('Hot'), searchList: {"0":__('Hot 0'),"1":__('Hot 1')}, formatter: Table.api.formatter.normal},
|
|
|
|
|
{field: 'fine', title: __('Fine'), searchList: {"0":__('Fine 0'),"1":__('Fine 1')}, formatter: Table.api.formatter.normal},
|
2025-05-20 16:33:23 +08:00
|
|
|
|
{field: 'weigh', title: __('Weigh'), operate: false},
|
|
|
|
|
{field: 'release_time', title: __('Release_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
|
|
|
{field: 'views', title: __('Views')},
|
2025-05-21 18:06:43 +08:00
|
|
|
|
{field: 'virtual_views', title: __('Virtual_views')},
|
|
|
|
|
{field: 'source', title: __('Source'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
|
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
|
|
|
|
|
2025-05-20 16:33:23 +08:00
|
|
|
|
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
|
|
|
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
2025-05-21 18:06:43 +08:00
|
|
|
|
|
2025-05-20 16:33:23 +08:00
|
|
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 为表格绑定事件
|
|
|
|
|
Table.api.bindevent(table);
|
|
|
|
|
},
|
|
|
|
|
recyclebin: function () {
|
|
|
|
|
// 初始化表格参数配置
|
|
|
|
|
Table.api.init({
|
|
|
|
|
extend: {
|
|
|
|
|
'dragsort_url': ''
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var table = $("#table");
|
|
|
|
|
|
|
|
|
|
// 初始化表格
|
|
|
|
|
table.bootstrapTable({
|
|
|
|
|
url: 'home/news/recyclebin' + location.search,
|
|
|
|
|
pk: 'id',
|
|
|
|
|
sortName: 'id',
|
|
|
|
|
columns: [
|
|
|
|
|
[
|
|
|
|
|
{checkbox: true},
|
|
|
|
|
{field: 'id', title: __('Id')},
|
|
|
|
|
{field: 'title', title: __('Title'), align: 'left'},
|
|
|
|
|
{
|
|
|
|
|
field: 'deletetime',
|
|
|
|
|
title: __('Deletetime'),
|
|
|
|
|
operate: 'RANGE',
|
|
|
|
|
addclass: 'datetimerange',
|
|
|
|
|
formatter: Table.api.formatter.datetime
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'operate',
|
|
|
|
|
width: '140px',
|
|
|
|
|
title: __('Operate'),
|
|
|
|
|
table: table,
|
|
|
|
|
events: Table.api.events.operate,
|
|
|
|
|
buttons: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Restore',
|
|
|
|
|
text: __('Restore'),
|
|
|
|
|
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
|
|
|
|
|
icon: 'fa fa-rotate-left',
|
|
|
|
|
url: 'home/news/restore',
|
|
|
|
|
refresh: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Destroy',
|
|
|
|
|
text: __('Destroy'),
|
|
|
|
|
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
|
|
|
|
|
icon: 'fa fa-times',
|
|
|
|
|
url: 'home/news/destroy',
|
|
|
|
|
refresh: 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]"));
|
2025-05-21 18:06:43 +08:00
|
|
|
|
generrate.listen();
|
2025-05-20 16:33:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-05-21 18:06:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var generrate = {
|
|
|
|
|
listen:function () {
|
|
|
|
|
this.offlineListen();
|
|
|
|
|
},
|
|
|
|
|
offlineListen:function () {
|
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
|
|
that.setOfflineType($("select[name='row[type]']").val());
|
|
|
|
|
|
|
|
|
|
// console.log($("input:radio[name='row[address_type]']").val())
|
|
|
|
|
// this.setOfflineType($("input:radio[name='row[address_type]']").val());
|
|
|
|
|
// $("input:radio[name='row[address_type]']").change(function (){
|
|
|
|
|
// that.setOfflineType($(this).val());
|
|
|
|
|
// });
|
|
|
|
|
//换成下拉选择监听
|
|
|
|
|
$("select[name='row[type]']").change(function (){
|
|
|
|
|
that.setOfflineType($(this).val());
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
setOfflineType:function (val) {
|
|
|
|
|
//1=富文本,2=PDF
|
|
|
|
|
switch (val) {
|
|
|
|
|
case '1':
|
|
|
|
|
$('.c_content').show();
|
|
|
|
|
$('.c_pdf').hide();
|
|
|
|
|
|
|
|
|
|
//fastadmin框架:清除附件,将附件限制去掉
|
|
|
|
|
|
|
|
|
|
$("#faupload-file").attr('data-mimetype', 'application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,image/svg+xml,application/zip');
|
|
|
|
|
$("#fachoose-file").attr('data-mimetype', 'application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,image/svg+xml,application/zip');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '2':
|
|
|
|
|
$('.c_content').hide();
|
|
|
|
|
$('.c_pdf').show();
|
|
|
|
|
|
|
|
|
|
//fastadmin框架:清除附件,将附件限制调整成pdf
|
|
|
|
|
$("#faupload-file").attr('data-mimetype', 'application/pdf');
|
|
|
|
|
$("#fachoose-file").attr('data-mimetype', 'application/pdf');
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-20 16:33:23 +08:00
|
|
|
|
return Controller;
|
|
|
|
|
});
|