123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'user/user/index',
- add_url: 'user/user/add',
- edit_url: 'user/user/edit',
- del_url: 'user/user/del',
- multi_url: 'user/user/multi',
- table: 'user',
- }
- });
- var table = $("#table");
- var c_remarks = Config.c_remarks;
- var b_remarks = Config.b_remarks;
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'user.id',
- fixedColumns: true,
- fixedRightNumber: 1,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'), sortable: true},
- {field: 'username', title: __('Username'), operate: 'LIKE'},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
- {
- field: 'avatar',
- title: __('Avatar'),
- events: Table.api.events.image,
- formatter: Table.api.formatter.image,
- operate: false
- },
- {
- field: 'level',
- title: __('Level'),
- searchList: {"1": __('Level 1'), "2": __('Level 2'), "3": __('Level 3')},
- formatter: Table.api.formatter.normal
- },
- {field: 'joinremarks1.value', title: __('Remarks1'),visible:c_remarks},
- {field: 'joinremarks2.value', title: __('Remarks2'),visible:c_remarks},
- {field: 'joinremarks3.value', title: __('Remarks3'),visible:c_remarks},
- {
- field: 'type_remarks',
- title: __('TypeRemarks'),
- formatter: Table.api.formatter.normal,
- searchList: {"1": __('TypeRemarks 1'), "2": __('TypeRemarks 2'), "3": __('TypeRemarks 3')},visible:b_remarks
- },
- {field: 'bindremarks.value', title: __('BindRemarks'), operate: false,visible:b_remarks},
- {field: 'score', title: __('Score'), operate: 'LIKE'},
- {
- field: 'logintime',
- title: __('Logintime'),
- formatter: Table.api.formatter.datetime,
- operate: 'RANGE',
- addclass: 'datetimerange',
- sortable: true
- },
- {
- field: 'status',
- title: __('Status'),
- formatter: Table.api.formatter.status,
- searchList: {normal: __('Normal'), hidden: __('Hidden')}
- },
- {
- field: 'cancel_shop',
- title: __('Cancelshop'),
- formatter: Table.api.formatter.normal,
- searchList: {"0": __('Cancelshop 0'), "1": __('Cancelshop 1')}
- },
- {field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
- {
- field: 'jointime',
- title: __('Jointime'),
- formatter: Table.api.formatter.datetime,
- operate: 'RANGE',
- addclass: 'datetimerange',
- sortable: true
- },
- {field: 'city', title: __('City'), operate: 'LIKE'},
- {field: 'address', title: __('Address'), operate: 'LIKE'},
- {field: 'remarks', title: __('Remarks'), operate: 'LIKE'},
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate,
- buttons: [{
- name: 'ajax',
- text: __('Reset Password'),
- icon: 'fa fa-wrench',
- classname: 'btn btn-xs btn-success btn-magic btn-ajax',
- confirm: '确认重置密码?重置后密码:123456',
- url: 'user/user/reset_password?ids={id}',
- // visible: function (row) {
- // if ((row.status == 1) || (row.status == 5)) {
- // return true;
- // } else {
- // return false;
- // }
- // //返回true时按钮显示,返回false隐藏
- // },
- success: function (data, ret) {
- //Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
- //如果需要阻止成功提示,则必须使用return false;
- Layer.alert(ret.msg);
- table.bootstrapTable('refresh', {});
- return false;
- },
- error: function (data, ret) {
- console.log(data, ret);
- Layer.alert(ret.msg);
- table.bootstrapTable('refresh', {});
- return false;
- }
- }],
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- $(document).on("change", "#c-level", function () {
- //变更后的回调事件
- let checkValue = $("#c-level").val();
- if (checkValue == 1) {
- $("#div_c-c_user_id").addClass("hidden");
- $("#div_c_remarks").removeClass("hidden");
- } else {
- $("#div_c-c_user_id").removeClass("hidden");
- $("#div_c_remarks").addClass("hidden");
- }
- });
- $(document).on("change", "#c-type_remarks", function () {
- //变更后的回调事件
- let checkValue = $("#c-type_remarks").val();
- Fast.api.ajax({
- url: 'user/user_common/remarks_list',
- type: 'post',
- data: {
- type_remarks: checkValue,
- }
- }, function (data, ret) {
- var op = '<option value="">--请选择备注--</option>';
- for (var i in data.list) {
- op += '<option value="' + data.list[i]['id'] + '">' + data.list[i]['value'] + '</option>'
- }
- $("#c-bind_remarks").html(op);
- $("#c-bind_remarks").selectpicker("refresh");
- }, function (data, ret) {
- console.log("type_remarks-error")
- });
- });
- },
- edit: function () {
- Controller.api.bindevent();
- $(document).on("change", "#c-type_remarks", function () {
- //变更后的回调事件
- let checkValue = $("#c-type_remarks").val();
- Fast.api.ajax({
- url: 'user/user_common/remarks_list',
- type: 'post',
- data: {
- type_remarks: checkValue,
- }
- }, function (data, ret) {
- var op = '<option value="">--请选择备注--</option>';
- for (var i in data.list) {
- op += '<option value="' + data.list[i]['id'] + '">' + data.list[i]['value'] + '</option>'
- }
- $("#c-bind_remarks").html(op);
- $("#c-bind_remarks").selectpicker("refresh");
- }, function (data, ret) {
- console.log("type_remarks-error")
- });
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|