123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, jstree) {
- var Controller = {
- index: function () {
- $(".btn-detail").data("area", ['90%', '90%']);
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'wwh/download/index',
- add_url: 'wwh/download/add',
- edit_url: 'wwh/download/edit',
- del_url: 'wwh/download/del',
- multi_url: 'wwh/download/multi',
- table: 'wwh_download',
- dragsort_url:'',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'download.id',
- height: $(window).height() - 97,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'), },
- {field: 'downloadcategory.name', title: __('Downloadcategory')},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
- {field: 'downloadname', title: __('Downloadname')},
- {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange'},
- {field: 'weigh', title: __('Weigh')},
- {field: 'attachfile', title: __('Attachfile')},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ],
- queryParams: function (params) {
- return params;
- },
- onPostBody: function () {
- $(".btn-detailone").data("area", ['90%', '90%']);
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- require(['jstree'], function () {
- //全选和展开
- $(document).on("click", "#checkall", function () {
- $("#channeltree").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
- });
- $(document).on("click", "#expandall", function () {
- $("#channeltree").jstree($(this).prop("checked") ? "open_all" : "close_all");
- });
- $('#channeltree').on("changed.jstree", function (e, data) {
- console.log(data);
- console.log(data.selected);
- var options = table.bootstrapTable('getOptions');
- options.pageNumber = 1;
- options.queryParams = function (params) {
- params.filter = JSON.stringify(data.selected.length > 0 ? {downloadcategoryid: data.selected.join(",")} : {});
- params.op = JSON.stringify(data.selected.length > 0 ? {downloadcategoryid: 'in'} : {});
- return params;
- };
- table.bootstrapTable('refresh', {});
- return false;
- });
- $('#channeltree').jstree({
- "themes": {
- "stripes": true
- },
- "checkbox": {
- "keep_selected_style": false,
- },
- "types": {
- "channel": {
- "icon": "fa fa-th",
- },
- "list": {
- "icon": "fa fa-list",
- },
- "link": {
- "icon": "fa fa-link",
- },
- "disabled": {
- "check_node": false,
- "uncheck_node": false
- }
- },
- 'plugins': ["types", "checkbox"],
- "core": {
- "multiple": true,
- 'check_callback': true,
- "themes":{
- "icons":false,
- },
- "data": {
- url: "wwh/downloadcategory/getjsTree",
- }
- }
- });
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- },
- };
- return Controller;
- });
|