define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'res/index' + location.search, add_url: 'res/add', edit_url: 'res/edit', // del_url: 'res/del', multi_url: 'res/multi', import_url: 'res/import', reports_url:'res/report', couse_url:'res/couse', table: 'res', } }); 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'),operate: false}, {field: 'entrust_no', title: __('Entrust_no'), operate: false}, {field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'sell_bach', title: '销售批次号', operate: 'LIKE'}, {field: 'bach', title: __('Bach'), operate: 'LIKE'}, {field: 'dis', title: __('Dis'),operate: false}, {field: 'dis_impurity', title: __('Dis_impurity'),operate: false}, {field: 'ben_total', title: __('Ben_total'),operate: false}, {field: 'ben', title: __('Ben'),operate: false}, {field: 'unit', title: __('Unit'),operate: false}, {field: 'judge', title: __('Judge'), operate: 'LIKE',custom: {0 :'red', 1:'green'},searchList: {"0":'不合格',"1":'合格'}, formatter: Table.api.formatter.status, function (value,row,index) { if (value == 1){ value = '合格'; return '' +value+ ''; }else{ value = '不合格'; return '' +value+ ''; } }}, {field: 'sample_info', title: '样品信息',operate: false}, {field: 'send_sample', title: '送样人',operate:false}, {field: 'machine', title: __('Machine'), operate: ''}, {field: 'sample_no', title: __('Sample_no'), operate: 'LIKE'}, // {field: 'standard_id', title: __('Standard_id')}, {field: 'standard_name', title: __('Standard_name'), operate: 'LIKE',searchList: $.getJSON("res/companyselect")}, {field: 'create', title: __('Create'),operate: 'RANGE_DATE', addclass: 'datetimerange', formatter: Table.api.formatter.date,datetimeFormat:'YYYY-MM-DD'}, {field: 'maker', title: __('Maker'),operate: false}, {field: 'remark', title: __('Remark'),operate: false}, {field: 'params', title: __('Params'),operate: false}, // {field: 'userid', title: __('Userid')}, {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status}, // {field: 'delete_time', title: __('Delete_time'), operate: 'LIKE'}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: [ { name: 'data', text: __('检测数据'), title: __('检测数据'), classname: 'btn btn-xs btn-primary btn-dialog', icon: 'fa fa-list', extend:'data-area=["100%","100%"]', url: 'res/data/id/{ids}', callback: function (data) { }, visible: function (row) { //返回true时按钮显示,返回false隐藏 return true; } }, { name: 'data', text: __('导出数据报告'), title: __('导出数据报告'), classname: 'btn btn-xs btn-primary', // classname: 'btn btn-xs btn-primary btn-dialog', icon: 'fa fa-list', extend:'data-area=["100%","100%"]', url: 'res/report/id/{ids}', callback: function (data) { }, visible: function (row) { //返回true时按钮显示,返回false隐藏 return true; } } ], formatter: Table.api.formatter.operate} ] ] }); $(".btn-edit").data("area", ["100%","100%"]); table.on('post-body.bs.table', function (e, settings, json, xhr) { $(".btn-editone").data("area", ["100%", "100%"]); }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, data: function () { $(".print-link").on('click', function() { var printHTML = document.querySelector('#print').innerHTML; // 将打印的区域赋值,进行打印 window.document.body.innerHTML = printHTML; window.print(); window.location.reload(); // 打印完成后重新加载页面 Fast.api.close(); }); Controller.api.bindevent(); }, couse: function (){ $('input[name="row[status]"][value="2"]').change(function () { $('#c-couse').attr('type','text'); }); Controller.api.bindevent(); $('#submit').click(function () { console.log(1111); var id = $('#id').val(); if (id == 0 || id == ''){ layer.confirm('未获取到参数!'); return false; } var status = $('input:radio:checked').val(); if (status == 0 || status == ''){ layer.confirm('未获取到参数!'); return false; } var couse = $('#c-couse').val(); Fast.api.ajax({ url:'res/couses', data:{id:id,status:status,couse:couse} },function (data,ret) { //成功回调 parent.Toastr.success("确认成功"); Fast.api.close(); parent.Fast.api.refreshmenu(); return false; },function (data,ret) { parent.Toastr.error("确认失败"); Fast.api.close(); return false; }); return false; }); }, edit: function () { $('input[name="row[status]"][value="2"]').change(function () { $('#c-couse').attr('type','text'); }); Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });