123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form','upload'], function ($, undefined, Backend, Table, Form,Upload) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'auth/special/index',
- add_url: 'auth/special/add',
- edit_url: 'auth/special/edit',
- del_url: 'auth/special/del',
- multi_url: 'auth/special/multi',
- do_choose: 'auth/special/operate',
- select_url: 'referral/vipreferral/selectchannel',
- import_url: 'auth/special/import',
- },
- showToggle: false,
- showColumns: false,
- visible: false,
- commonSearch: false,
- showExport: false
- });
- var table = $("#table");
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- columns: [
- [
- {field: 'id', title: '菜单ID'},
- {field: 'title', title: __('菜单名称')},
- {
- field: 'id',
- operate:false,
- title: __('关联账号'),
- formatter: Controller.api.formatter.fm_associate_channels
- },
- {
- field: 'id',
- operate:false,
- title: __('一键清除'),
- formatter: function (index, row, value) {
- return "<a href='javascript:;' class='qd-associate-all' data-rule_id='" + index + "' data-channel_id='"+ row.channel_id+"'>清除所有账号</a>";
- }
- }
- ]
- ]
- });
- //一键清除
- $(document).on('click', '.qd-associate-all', function () {
- var rule_id = $(this).data("rule_id");
- Layer.confirm(
- '确定要清理所有账号吗',
- {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
- function (index) {
- $.post('/admin/auth/special/operate',
- {
- 'auth_rule_id': rule_id,
- 'channel_ids': "*",
- 'method': 'remove'
- },
- function (result) {
- Toastr.success('操作成功');
- //刷新页面
- table.bootstrapTable('refresh');
- });
- Layer.close(index);
- }
- );
- });
- // 列表关联
- $(document).on('click', '.qd-associate', function () {
- var rule_id = $(this).data("rule_id");
- var group_id = $(this).data("group-id");
- var channel_ids = $(this).data("channel_id");
- if (channel_ids == 'undefined') {
- channel_ids = '';
- }
- Fast.api.open('/admin/auth/admin/select?operate=add&channel_ids=' + channel_ids +'&group_ids='+group_id, "关联账号", {callback: function (data) {
- $.post('/admin/auth/special/operate',
- {
- 'auth_rule_id': rule_id,
- 'channel_ids': data,
- 'method': 'add'
- },
- function (result) {
- Toastr.success('操作成功');
- //刷新页面
- table.bootstrapTable('refresh');
- });
- }
- });
- });
- // 列表 查看
- $(document).on('click', '.qd-view', function () {
- var rule_id = $(this).data("rule_id");
- var channel_ids = $(this).data("channel_id");
- if (channel_ids == 'undefined') {
- channel_ids = '';
- }
- Fast.api.open('/admin/auth/admin/select?operate=remove&channel_ids=' + channel_ids, "查看关联", {callback: function (data) {
- $.post('/admin/auth/special/operate',
- {
- 'auth_rule_id': rule_id,
- 'channel_ids': data,
- 'method': 'remove'
- },
- function (result) {
- Toastr.success('操作成功');
- //刷新页面
- table.bootstrapTable('refresh');
- });
- }
- });
- });
- //上传
- $(document).on('click', '.qd-upload', function () {
- var rule_id = $(this).data("rule_id");
- var channel_ids = $(this).data("channel_id");
- if (channel_ids == 'undefined') {
- channel_ids = '';
- }
- Fast.api.open('/admin/auth/special/import?ids='+channel_ids+'&rule_id='+rule_id, "上传文件", $(this).data() || {});
- });
- $(document).on("click", ".qd-edit", function () {
- var rule_id = $(this).data("rule_id");
- var channel_ids = $(this).data("channel_id");
- if (channel_ids == 'undefined') {
- channel_ids = '';
- }
- layer.open({
- type: 1,
- title: '批量关联',
- maxmin: true,
- area: ['60%', '80%'],
- btn: ['确定', '取消'],
- shadeClose: true, //点击遮罩关闭层
- content: $("#qd_multi_edit"),
- yes: function (data) {
- var channel_ids = $("#c-channel_id").val();
- $("#c-channel_id").val("");
- $.post('/admin/auth/special/operate',
- {
- 'auth_rule_id': rule_id,
- 'channel_ids': channel_ids,
- 'method': 'add'
- },
- function (result) {
- Toastr.success('操作成功');
- //刷新页面
- table.bootstrapTable('refresh');
- });
- layer.closeAll();
- }
- });
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- edit: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- import: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- api: {
- formatter: {
- fm_associate_channels:function (value, row, index) {
- html = '';
- if(row.channel_id == '*'){
- html += "已关联所有账号";
- }else{
- html += "<a href='javascript:;' class='qd-associate' data-rule_id='" + value + "' data-channel_id='"+ row.channel_id+"' data-group-id='"+row.group_id+"'>关联账号</a> ";
- html += "<a href='javascript:;' class='qd-view' data-rule_id='" + value + "' data-channel_id='"+ row.channel_id+"' data-group-id='"+row.group_id+"'>查看</a> ";
- /*html += "<a href='javascript:;' class='qd-upload' data-rule_id='" + value + "' data-channel_id='"+ row.channel_id+"'><i class=\"fa fa-upload\"></i>上传文件关联</a>";*/
- html += "<a href='javascript:;' class='qd-edit' data-rule_id='" + value + "' data-channel_id='"+ row.channel_id+"'>批量关联</a>";
- }
- return html;
- }
- },
- }
- };
- return Controller;
- });
|