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 info = {} var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'user/apply/index' + location.search, add_url: 'user/apply/add', edit_url: 'user/apply/edit', del_url: 'user/apply/del', multi_url: 'user/apply/multi', import_url: 'user/apply/import', table: 'user_apply', } }); 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: 'full_name', title: __('Full_name'), operate: 'LIKE'}, {field: 'vocation', title: __('Vocation'), operate: 'LIKE'}, {field: 'position', title: __('Position'), operate: 'LIKE'}, {field: 'education', title: __('Education'), searchList: {"0":__('Education 0'),"1":__('Education 1'),"2":__('Education 2'),"3":__('Education 3'),"4":__('Education 4'),"5":__('Education 5'),"6":__('Education 6'),"7":__('Education 7'),"8":__('Education 8'),"9":__('Education 9')}, formatter: Table.api.formatter.normal}, {field: 'tel', title: __('Tel'), operate: 'LIKE'}, {field: 'address', title: __('Address'), operate: 'LIKE'}, {field: 'company_name', title: __('Company_name'), operate: 'LIKE'}, {field: 'nature', title: __('Nature'), operate: 'LIKE'}, {field: 'legal_person', title: __('Legal_person'), operate: 'LIKE'}, {field: 'zip_code', title: __('Zip_code'), operate: 'LIKE'}, {field: 'compnay_address', title: __('Compnay_address'), operate: 'LIKE'}, {field: 'company_email', title: __('Company_email'), operate: 'LIKE'}, {field: 'certificateimage', title: __('Certificateimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'id_card', title: __('Id_card'), operate: 'LIKE'}, {field: 'nation', title: __('Nation'), operate: 'LIKE'}, {field: 'birthday', title: __('Birthday'), operate: 'LIKE'}, {field: 'user_type', title: __('User_type'), searchList: {"0":__('User_type 0'),"1":__('User_type 1'),"2":__('User_type 2')}, formatter: Table.api.formatter.normal}, {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, {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('点击了打印') if(info.user_type == 2) { window.open("http://red.liuniu946.com/dru/group.html?" + queryParams(info)) }else { window.open("http://red.liuniu946.com/dru/personal.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; });