123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'workorder/fields/index' + location.search,
- add_url: 'workorder/fields/add',
- edit_url: 'workorder/fields/edit',
- del_url: 'workorder/fields/del',
- multi_url: 'workorder/fields/multi',
- import_url: 'workorder/fields/import',
- table: 'workorder_fields',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'weigh',
- exportTypes: ['excel'],
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {
- field: 'position',
- title: __('Position'),
- searchList: {
- "0": __('Position 0'),
- },
- formatter: Table.api.formatter.status
- },
- {field: 'name', title: __('Name')},
- {field: 'title', title: __('Title')},
- {
- field: 'type_list',
- title: __('Type_list'),
- searchList: {
- "string": __('Type_list string'),
- "textarea": __('Type_list textarea'),
- "text": __('Type_list text'),
- "editor": __('Type_list editor'),
- "number": __('Type_list number'),
- "date": __('Type_list date'),
- "time": __('Type_list time'),
- "datetime": __('Type_list datetime'),
- "select": __('Type_list select'),
- "selects": __('Type_list selects'),
- "image": __('Type_list image'),
- "images": __('Type_list images'),
- "file": __('Type_list file'),
- "files": __('Type_list files'),
- "switch": __('Type_list switch'),
- "checkbox": __('Type_list checkbox'),
- "radio": __('Type_list radio'),
- "city": __('Type_list city')
- },
- formatter: Table.api.formatter.normal
- },
- // {field: 'default', title: __('Default')},
- // {field: 'rule', title: __('Rule')},
- // {field: 'errormsg', title: __('Errormsg')},
- {field: 'notice', title: __('Notice')},
- {field: 'field_length', title: __('Field_length')},
- {
- field: 'isfilter',
- title: __('Isfilter'),
- searchList: {"1": __('Yes'), "0": __('No')},
- formatter: Controller.api.formatter.toggle
- },
- // {field: 'extend', title: __('Extend')},
- {
- field: 'isbasicinfo',
- title: __('Isbasicinfo'),
- searchList: {"0": __('Isbasicinfo 0'), "1": __('Isbasicinfo 1')},
- formatter: Controller.api.formatter.status
- },
- {
- field: 'status',
- title: __('Status'),
- searchList: {"0": __('Status 0'), "1": __('Status 1')},
- formatter: Table.api.formatter.status
- },
- {field: 'weigh', title: __('Weigh')},
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: function (value, row, index) {
- var ban_del = ['title', 'describe'];
- if (ban_del.includes(row.name)) {
- var that = $.extend({}, this);
- var table = $(that.table).clone(true);
- $(table).data("operate-del", null);
- that.table = table;
- return Table.api.formatter.operate.call(that, value, row, index);
- }
- return Table.api.formatter.operate.call(this, value, row, index);
- }
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- $("form#add-form").data("validator-options", {ignore: ':hidden'});
- $(document).on("change", "#c-type_list", function () {
- let typeList = $(this).val();
- $(".tf").addClass("hidden");
- $(".tf.tf-" + typeList).removeClass("hidden");
- if (typeList == 'switch') {
- let defaultEl = $('#c-default');
- defaultEl.val(defaultEl.val() ? defaultEl.val():'0')
- }
- });
- $(document).on("change", '#c-position', function () {
- $(".pp").addClass("hidden");
- $(".pp.position-" + $(this).val()).removeClass("hidden");
- })
- Form.api.bindevent($("form[role=form]"));
- $("#c-type_list").trigger("change");
- $("#c-position").trigger("change");
- },
- formatter: {
- toggle: function (value, row, index) {
- // if (row.position == 0) {
- var that = $.extend({}, this);
- var table = $(that.table).clone(true);
- that.table = table;
- return Table.api.formatter.toggle.call(that, value, row, index);
- // } else {
- // return '-';
- // }
- },
- status: function (value, row, index) {
- if (row.position == 0) {
- var that = $.extend({}, this);
- var table = $(that.table).clone(true);
- that.table = table;
- return Table.api.formatter.status.call(that, value, row, index);
- } else {
- return '-';
- }
- }
- }
- }
- };
- return Controller;
- });
|