DiverseYouthNightSchool/public/assets/js/backend/auth/admin.js

152 lines
6.8 KiB
JavaScript
Raw Normal View History

2024-11-04 10:49:10 +08:00
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'auth/admin/index',
add_url: 'auth/admin/add',
edit_url: 'auth/admin/edit',
del_url: 'auth/admin/del',
multi_url: 'auth/admin/multi',
2025-01-02 18:07:25 +08:00
createshop_url: 'auth/admin/createshop',
2024-11-04 10:49:10 +08:00
}
});
var table = $("#table");
//在表格内容渲染完成后回调的事件
table.on('post-body.bs.table', function (e, json) {
$("tbody tr[data-index]", this).each(function () {
if (parseInt($("td:eq(1)", this).text()) == Config.admin.id) {
$("input[type=checkbox]", this).prop("disabled", true);
}
});
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
2025-01-02 18:07:25 +08:00
fixedColumns: true,
fixedRightNumber: 1,
2024-11-04 10:49:10 +08:00
columns: [
[
{field: 'state', checkbox: true, },
{field: 'id', title: 'ID'},
{field: 'username', title: __('Username')},
{field: 'nickname', title: __('Nickname')},
{field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
{field: 'email', title: __('Email')},
{field: 'mobile', title: __('Mobile')},
2024-12-18 09:37:26 +08:00
{field: 'area_json', title: __('Area_json'), operate:'FIND_IN_SET', searchList: addressCityListJson, formatter: Table.api.formatter.label},
2024-11-04 10:49:10 +08:00
{field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
{field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
2025-01-02 18:07:25 +08:00
{field: 'oper', title: __('其他操作'), table: table , buttons: [
{name: 'createshop',
text: '生成默认机构',
icon: 'fa fa-sign-in',
classname: 'btn btn-xs btn-warning btn-magic btn-ajax',
url: $.fn.bootstrapTable.defaults.extend.createshop_url,
confirm: '确认生成默认机构么请确保账号有区域昵称和手机号生成后需自己去补全缺失的机构信息默认密码为a123456',
success: function (data, ret) {
Layer.alert(ret.msg );
$(".btn-refresh").trigger("click");
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
},
visible: function (row) {
//显示条件 只能待入住订单
if(!row.admin_shop_id){
return true;
}
return false;
}},
{
name: 'manystore',
text: __('我的默认机构'),
title: __('我的默认机构'),
classname: 'btn btn-dialog',
icon: 'fa fa-home',
dropdown : '更多',
url: manystore_url,
callback: function (data) {
},
visible: function (row) {
return row.admin_shop_id;
}
},
], events: Table.api.events.operate, formatter: function (value, row, index) {
2024-11-04 10:49:10 +08:00
if(row.id == Config.admin.id){
return '';
}
return Table.api.formatter.operate.call(this, value, row, index);
2025-01-02 18:07:25 +08:00
}},
// {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
// if(row.id == Config.admin.id){
// return '';
// }
// return Table.api.formatter.operate.call(this, value, row, index);
// }}
2024-11-04 10:49:10 +08:00
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
2024-12-18 09:37:26 +08:00
Controller.api.bindevent();
2024-11-04 10:49:10 +08:00
},
edit: function () {
2024-12-18 09:37:26 +08:00
Controller.api.bindevent();
},
api: {
bindevent: function () {
$(document).on('click', '.btn-changeuser', function (event) {
var url = $(this).attr('data-url');
if(!url) return false;
var title = $(this).attr('title');
var width = $(this).attr('data-width');
var height = $(this).attr('data-height');
// var ids = $(this).attr('data-id');
var area = ['98%','98%'];
var options = {
shadeClose: false,
shade: [0.3, '#393D49'],
area: area,
callback:function(ret){//回调方法需要在本页面Controller中增加方法监听且调用Fast.api.close(ret)传递结果;
Fast.api.close(ret);
}
};
Fast.api.open(url,title,options);
});
Form.api.bindevent($("form[role=form]"));
}
2024-11-04 10:49:10 +08:00
}
};
2025-01-02 18:07:25 +08:00
var manystore_url = function (row,dom) {
return 'manystore/index/index?shop_id='+row.admin_shop_id;
}
2024-11-04 10:49:10 +08:00
return Controller;
});