define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { function queryParams (data, isPrefix) { isPrefix = isPrefix ? isPrefix : false let prefix = isPrefix ? '?' : '' let _result = [] for (let key in data) { let value = data[key] // 去掉为空的参数 if (['', undefined, null].includes(value)) { continue } if (value.constructor === Array) { value.forEach(_value => { _result.push(encodeURIComponent(key) + '[]=' + encodeURIComponent(_value)) }) } else { _result.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)) } } return _result.length ? prefix + _result.join('&') : '' } var inof = {} var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'training/volunteer/index' + location.search, add_url: 'training/volunteer/add', edit_url: 'training/volunteer/edit', del_url: 'training/volunteer/del', multi_url: 'training/volunteer/multi', import_url: 'training/volunteer/import', table: 'volunteer', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', onClickRow:function(row, $element, field) { console.log($element) info = row console.log(row,'row') }, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'cid', title: __('Cid')}, {field: 'user_id', title: __('User_id')}, {field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'phone', title: __('Phone'), operate: 'LIKE'}, {field: 'sex', title: __('Sex'), searchList: {"0":__('Sex 0'),"1":__('Sex 1')}, formatter: Table.api.formatter.normal}, {field: 'birth', title: __('Birth'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'certificateimage', title: __('Certificateimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'email', title: __('Email'), operate: 'LIKE'}, {field: 'address', title: __('Address'), operate: 'LIKE'}, {field: 'work', title: __('Work'), operate: 'LIKE'}, {field: 'specialty', title: __('Specialty'), operate: 'LIKE'}, {field: 'education', title: __('Education'), operate: 'LIKE'}, {field: 'is_vol', title: __('Is_vol'), searchList: {"0":__('Is_vol 0'),"1":__('Is_vol 1')}, formatter: Table.api.formatter.normal}, {field: 'is_experience', title: __('Is_experience'), searchList: {"0":__('Is_experience 0'),"1":__('Is_experience 1')}, formatter: Table.api.formatter.normal}, {field: 'start_hour', title: __('Start_hour')}, {field: 'end_hour', title: __('End_hour')}, {field: 'work_week', title: __('Work_week'), searchList: {"1":__('Work_week 1'),"2":__('Work_week 2'),"3":__('Work_week 3'),"4":__('Work_week 4'),"5":__('Work_week 5'),"6":__('Work_week 6'),"7":__('Work_week 7')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label}, {field: 'taste', title: __('Taste'), operate: 'LIKE'}, {field: 'taste_title', title: __('Taste_title'), operate: 'LIKE'}, {field: 'speciali', title: __('Speciali'), operate: 'LIKE'}, {field: 'speciali_title', title: __('Speciali_title'), operate: 'LIKE'}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"-1":__('Status -1')}, formatter: Table.api.formatter.status}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons:[{ name: 'daying', title: '打印', text: '打印', icon: 'fa', classname: 'btn btn-xs btn-info daying' // url: 'info' }]} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); $("#table").on("click",".daying",function () { // alert('点击了打印') window.open("http://red.liuniu946.com/dru/zyz.html?" + queryParams(info)) }) }, daying: function () { // alert(JSON.stringify(row)); console.log('点击打印') Controller.api.bindevent(); console.log('点击打印+++') }, add: function () { $("#c-user_id").data("params", function (obj) { return {custom: {cid: $("#c-cid").val()}}; }); Controller.api.bindevent(); }, edit: function () { $("#c-user_id").data("params", function (obj) { return {custom: {cid: $("#c-cid").val()}}; }); Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });