123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'mobile_upload/index' + location.search,
- add_url: 'mobile_upload/add',
- edit_url: 'mobile_upload/edit',
- del_url: 'mobile_upload/del',
- multi_url: 'mobile_upload/multi',
- import_url: 'mobile_upload/import',
- table: 'mobile_upload',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- searchFormVisible:true,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('编号')},
- {field: 'filename', title: __('Filename')},
- {field: 'rows_total', title: __('Rows_total')},
- {
- field: 'id',
- operate: false,
- title: "执行情况",
- formatter(_,info){
- let a=[]
- a.push(`<span>总记录数:${info.rows_total}</span>`)
- a.push(`<span>成功:${info.rows_succ}</span>`)
- a.push(`<span>失败:${info.rows_fail}</span>`)
- a.push(`<span>用时:${info.run_time}秒</span>`)
- if(info.rows_fail>0){
- a.push(`【<a target="_blank" href="${info.filename_error}">下载错误清单</a>】`)
- }
- return a.join(' ')
- }
- },
- {field: 'status', title: __('状态'),formatter: Table.api.formatter.label,searchList:{0:'待导入',1:'导入中',2:'导入完成'}},
- {field: 'create_time', title: __('Create_time'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
- {
- field: 'buttons',
- title: __('错误信息'),
- events: Table.api.events.operate,
- table: table,
- formatter: Table.api.formatter.buttons,
- operate: false,
- buttons:[
- {
- name: 'detail',
- text: __('查看'),
- title: __('查看'),
- classname: 'btn btn-xs btn-primary btn-dialog',
- icon: 'fa fa-list',
- url: 'mobile_upload/error_log?aaa=1',
- callback: function (data) {
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return table.data('operate-error_log') && row.rows_fail>0;
- }
- },
- {
- name: 'detail',
- text: __('删除'),
- title: __('删除'),
- confirm:"确认删除吗?",
- classname: 'btn btn-xs btn-danger btn-ajax',
- icon: 'fa fa-list',
- url: 'mobile_upload/del',
- callback: function (data) {
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return table.data('operate-del');
- },
- success(){
- $('.btn-refresh').trigger('click')
- }
- }
- ]
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|