123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: async function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'user/guest/index',
- add_url: 'user/guest/add',
- edit_url: 'user/guest/edit',
- del_url: 'user/guest/del',
- multi_url: 'user/guest/multi',
- table: 'user',
- }
- });
- var table = $("#table");
- let levels = await $.getJSON('user/user/levels')
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'user.id',
- searchFormVisible:true,
- columns: [
- [
- //{checkbox: true},
- {field: 'id', title: __('Id'), sortable: true},
- //{field: 'group.name', title: __('Group')},
- {field: 'username', title: __('Username'), operate: 'LIKE'},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'mobile', title: __('手机号'), operate: 'LIKE'},
- {field: 'mob_brand', title: __('手机品牌'), operate: 'LIKE'},
- {field: 'mob_model', title: __('手机型号'), operate: 'LIKE'},
- {
- field: 'avatar',
- title: __('头像'),
- events: Table.api.events.image,
- formatter: Table.api.formatter.image,
- operate: false
- },
- {
- field: 'gender',
- title: __('性别'),
- searchList: {1: __('男'), 0: __('Female')},
- formatter: Table.api.formatter.label
- },
- {
- field: 'age',
- title: __('年龄'),
- },
- {
- field: 'city_name',
- title: __('城市'),
- searchList: function (column) {
- return Template('sourcetpl', {})
- }
- },
- {
- field: 'userinfo',
- title: '自定义',
- formatter(info){
- if(!info || !info.custom){
- return ''
- }
- let str=[]
- info.custom.forEach(item=>{
- str.push(`<div>${item.title}:${item.value}</div>`)
- })
- return str.join('')
- }
- },
- //{field: 'money', title: __('余额'), operate: 'BETWEEN', sortable: true},
- /* {
- field: 'successions',
- title: __('Successions'),
- visible: false,
- operate: 'BETWEEN',
- sortable: true
- },
- {
- field: 'maxsuccessions',
- title: __('Maxsuccessions'),
- visible: false,
- operate: 'BETWEEN',
- sortable: true
- },*/
- //{field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
- //{field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
- {
- field: 'jointime',
- title: __('注册时间'),
- formatter: Table.api.formatter.datetime,
- operate: 'RANGE',
- addclass: 'datetimerange',
- sortable: true
- },
- //{field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
- {
- field: 'status',
- title: __('Status'),
- formatter: Table.api.formatter.status,
- searchList: {normal: __('Normal'), hidden: __('Hidden')}
- },
- /*{
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate
- }*/
- ]
- ],
- onLoadSuccess(){
- $(".btn-editone").data("area", ["800px","90%"]);
- }
- });
- // 为表格绑定事件
- 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;
- });
|