|
|
@@ -0,0 +1,158 @@
|
|
|
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
+
|
|
|
+ var Controller = {
|
|
|
+ index: function () {
|
|
|
+ // 初始化表格参数配置
|
|
|
+ Table.api.init({
|
|
|
+ extend: {
|
|
|
+ index_url: 'item/check/index' + location.search,
|
|
|
+ add_url: 'item/check/add',
|
|
|
+ edit_url: 'item/check/edit',
|
|
|
+ del_url: 'item/check/del',
|
|
|
+ multi_url: 'item/check/multi',
|
|
|
+ import_url: 'item/check/import',
|
|
|
+ table: 'item_check',
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ var table = $("#table");
|
|
|
+
|
|
|
+ // 初始化表格
|
|
|
+ table.bootstrapTable({
|
|
|
+ url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
|
+ pk: 'id',
|
|
|
+ sortName: 'id',
|
|
|
+ fixedColumns: true,
|
|
|
+ fixedRightNumber: 1,
|
|
|
+ columns: [
|
|
|
+ [
|
|
|
+ {checkbox: true},
|
|
|
+ {field: 'id', title: __('Id')},
|
|
|
+ {field: 'name', title: __('Name'), operate: 'LIKE'},
|
|
|
+ {field: 'check_no', title: __('Check_no'), operate: 'LIKE'},
|
|
|
+ {field: 'check_name', title: __('Check_name'), operate: 'LIKE'},
|
|
|
+ {field: 'unit', title: __('Unit'), operate: 'LIKE'},
|
|
|
+ {field: 'check_max', title: __('Check_max'), operate: 'LIKE'},
|
|
|
+ {field: 'check_min', title: __('Check_min'), operate: 'LIKE'},
|
|
|
+ {field: 'class', title: __('Class'), operate: 'LIKE'},
|
|
|
+ {field: 'scope', title: __('Scope'), operate: 'LIKE'},
|
|
|
+ {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
|
|
|
+ {field: 'remark', title: __('Remark'), operate: 'LIKE'},
|
|
|
+ {field: 'is_child', title: __('Is_child'), searchList: {"0":__('Is_child 0'),"1":__('Is_child 1')}, formatter: Table.api.formatter.normal},
|
|
|
+ {field: 'create', title: __('Create'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
|
+ // {field: 'update', title: __('Update'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
|
+ {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ $(".btn-add").data("area", ["100%","100%"]);
|
|
|
+
|
|
|
+ // 为表格绑定事件
|
|
|
+ Table.api.bindevent(table);
|
|
|
+ },
|
|
|
+ recyclebin: function () {
|
|
|
+ // 初始化表格参数配置
|
|
|
+ Table.api.init({
|
|
|
+ extend: {
|
|
|
+ 'dragsort_url': ''
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ var table = $("#table");
|
|
|
+
|
|
|
+ // 初始化表格
|
|
|
+ table.bootstrapTable({
|
|
|
+ url: 'item/check/recyclebin' + location.search,
|
|
|
+ pk: 'id',
|
|
|
+ sortName: 'id',
|
|
|
+ columns: [
|
|
|
+ [
|
|
|
+ {checkbox: true},
|
|
|
+ {field: 'id', title: __('Id')},
|
|
|
+ {field: 'name', title: __('Name'), 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: 'item/check/restore',
|
|
|
+ refresh: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'Destroy',
|
|
|
+ text: __('Destroy'),
|
|
|
+ classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
|
|
|
+ icon: 'fa fa-times',
|
|
|
+ url: 'item/check/destroy',
|
|
|
+ refresh: true
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ formatter: Table.api.formatter.operate
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
+ // 为表格绑定事件
|
|
|
+ Table.api.bindevent(table);
|
|
|
+ },
|
|
|
+
|
|
|
+ add: function () {
|
|
|
+ $('#c-is_child').change(function () {
|
|
|
+ var is_child = $('#c-is_child option:selected').val();
|
|
|
+ console.log(is_child)
|
|
|
+ if (is_child == 1){
|
|
|
+ document.getElementById("detail").style.display="block";//显示
|
|
|
+ }else{
|
|
|
+ document.getElementById("detail").style.display="none";//隐藏
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //增加一行
|
|
|
+ $(document).on('click','.add',function () {
|
|
|
+ var html = '';
|
|
|
+ html += '<tr><td><input class="form-control p_name" name="row[remark]" type="text"></td>';
|
|
|
+ html += '<td><input class="form-control name" name="row[remark]" type="text"></td>';
|
|
|
+ html += '<td><input class="form-control unit" name="row[remark]" type="text"></td>';
|
|
|
+ html += '<td><input class="form-control check_max" name="row[remark]" type="text"></td>';
|
|
|
+ html += '<td><input class="form-control check_min" name="row[remark]" type="text"></td>';
|
|
|
+ html += '<td style="text-align: center"> <button type="button" class="btn btn-success add">添加</button> <button type="button" class="btn btn-danger del">删除</button></td>';
|
|
|
+ html += '</tr>'
|
|
|
+ $('#check_child').append(html);
|
|
|
+ })
|
|
|
+ //删除一行
|
|
|
+ $(document).on('click','.del',function () {
|
|
|
+ var num = document.getElementById("check_child").getElementsByTagName("tr").length;
|
|
|
+ console.log(num)
|
|
|
+ if (num <= 2){
|
|
|
+ layer.confirm('已经是最后一行了');
|
|
|
+ }else{
|
|
|
+ $(this).parent().parent().remove();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Controller.api.bindevent();
|
|
|
+ },
|
|
|
+ edit: function () {
|
|
|
+ Controller.api.bindevent();
|
|
|
+ },
|
|
|
+ api: {
|
|
|
+ bindevent: function () {
|
|
|
+ Form.api.bindevent($("form[role=form]"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return Controller;
|
|
|
+});
|