| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, jstree) {
- var Controller = {
- index: function () {
- var datadict_id = 0;
- var table = $("#table");
- $(function () {
- var autoWidth = $(window).width() - 220;
- $('.table-content').css({'width': autoWidth, "position": "absolute", "left": "210px"});
- $("#treeview").jstree({
- "themes": {"stripes": true},
- "core": {
- 'multiple': false,
- 'check_callback': true,
- "data": {
- url: "stock/datadict/getjsTree",
- }
- }
- }).on('select_node.jstree', function (node, selected) {
- datadict_id = selected.node.data.id;
- table.bootstrapTable('refresh', {
- query: {
- datadict_id: datadict_id
- }
- });
- }).on('ready.jstree',function(){
- if($("#treeview ul li:first").length>0){
- $('#treeview').jstree('select_node',$("#treeview ul li:first"));
- }
- });
- });
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'stock/datadictitem/index',
- add_url: 'stock/datadictitem/add',
- edit_url: 'stock/datadictitem/edit',
- del_url: 'stock/datadictitem/del',
- multi_url: 'stock/datadictitem/multi',
- table: 'stock_datadictitem',
- }
- });
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'weigh',
- height: $(window).height() - 137,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'name', title: __('Name')},
- {field: 'value', title: __('Value')},
- {field: 'weigh', title: __('Weigh')},
- {field: 'remark', title: __('Remark')},
- {field: 'enabled', title: __('Enabled'), visible: false, searchList: {"1": __('Enabled 1'), "0": __('Enabled 0')}},
- {field: 'enabled_text', title: __('Enabled'), operate: false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ],
- queryParams: function (params) {
- params.datadict_id = datadict_id;
- return params;
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 刷新按钮事件
- $('.btn-refresh').click(function (event) {
- event.stopPropagation();
- table.bootstrapTable('refresh', {
- query: {
- datadict_id: datadict_id
- }
- });
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|