1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'layui'], function ($, undefined, Backend, Table, Form, Layui) {
- let Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'special/remote/index' + location.search,
- add_url: 'special/remote/add',
- edit_url: 'special/remote/edit',
- del_url: 'special/remote/del',
- multi_url: 'special/remote/multi',
- table: 'special_remote',
- }
- });
- let table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'sort',
- showToggle: false,
- showColumns: false,
- showExport: false,
- columns: [
- [
- {field: 'sort', title: __('Sort'), searchable: false},
- {field: 'name', title: __('Name'), operate: 'LIKE %...%',},
- {field: 'color', title: __('Color'),formatter: function (value) {
- return '<div style="width: 20px; height: 20px; margin-left: 30px; background: '+ value +'"></div>';
- }, searchable: false},
- {field: 'describe', title: __('Describe'), searchable: false},
- {
- field: 'status',
- title: __('Status'),
- formatter: Table.api.formatter.normal,
- custom: {0:'danger',1:'success'},
- searchList: {
- 0: '禁用',
- 1: '启用',
- },
- },
- {
- field: 'check',
- title: __('Check'),
- formatter: Table.api.formatter.label,
- custom: {0: 'default', 1: 'success'},
- searchList: {
- 0: '否',
- 1: '是',
- },
- },
- {field: 'createdAt', title: __('Createdat'), operate:'RANGE', addclass:'datetimerange', searchable: false},
- {field: 'updatedAt', title: __('Updatedat'), operate:'RANGE', addclass:'datetimerange', searchable: false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Layui.use('colorpicker', function(){
- let colorpicker = layui.colorpicker;
- //渲染
- colorpicker.render({
- elem : '#d-color', //绑定元素
- size : 'lg',
- color : $('#c-color').val(),
- change : function(color){
- $('#c-color').val( color );
- }
- });
- });
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|