企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` ~~~ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'clipboard', 'template','common/jszip',"common/filesaver"], function ($, undefined, Backend, Table, Form,ClipboardJS,Template, Jszip, Filesaver) { 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', } }); 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.on('load-success.bs.table', function (e, data) { //这里可以获取从服务端获取的JSON数据 // console.log(data); //这里我们手动设置底部的值 $("#all").text(data.extend.total); }); //打包命令 php think min -m all -r all //,events: Controller.api.events.copy, formatter: Controller.api.formatter.copy //,sortable:true ,visible:false , operate:'LIKE %...%' ,custom:{'0':'success','1':'danger'} //,operate: 'FIND_IN_SET' ,placeholder: '关键字,模糊搜索' // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pagination: false, search: false, commonSearch: false, sortName: 'weigh DESC,id DESC', searchFormVisible: Fast.api.query("model_id") ? true : false, fixedColumns: true, fixedRightNumber: 1, singleSelect: true, //启用单选 dblClickToEdit: false, //是否启用双击编辑 clickToSelect: false, //是否启用点击选中 columns: [ [ {checkbox: true,formatter:function(value, row, index){ if (row.id==20){ return {disabled: true}; } else if (row.id==19){ return {disabled: true,checked:true}; } }}, /*data-params='{"custom[status]":"1"}'*/ /*, defaultValue:Moment().startOf('week').format('YYYY-MM-DD') + ' - ' + Moment().endOf('week').format('YYYY-MM-DD')*/ { field: 'state', checkbox: true, formatter: function (value, row, index) { if (row.state === false) { return { disabled: true, } } else { return { disabled: false, } } } }, { field: 'user_id', title: __('User_id'), visible: false, addclass: 'selectpage', extend: 'data-source="user/user/index" data-field="nickname"', operate: '=', formatter: Table.api.formatter.search }, { field: 'model_id', title: __('Model'), visible: false, align: 'left', addclass: "selectpage", extend: "data-source='cms/modelx/index' data-field='name'" }, { field: 'title', title: __('Title'), align: 'left', customField: 'flag', formatter: function (value, row, index) { return '<div class="archives-title"><a href="' + row.url + '" target="_blank"><span style="color:' + (row.style_color ? row.style_color : 'inherit') + ';font-weight:' + (row.style_bold ? 'bold' : 'normal') + '">' + value + '</span></a></div>' + '<div class="archives-label">' + Table.api.formatter.flag.call(this, row['flag'], row, index) + '</div>'; } }, { field: 'iscontribute', visible: ['channel', 'page', 'special'].indexOf(Config.source) < 0, title: __('Iscontribute'), searchList: {"1": __('Yes'), "0": __('No')}, formatter: function (value, row, index) { return row.issystem && ["channel_ids", "image", "images", "tags", "content", "keywords", "description"].indexOf(row.name) === -1 ? "-" : Table.api.formatter.toggle.call(this, value, row, index); } }, { field: 'status', title: __('Status'), formatter: function (value, row, index) { return row.issystem ? "-" : Table.api.formatter.status.call(this, value, row, index); } }, {field: 'fee', title: __('手续费'), operate:false,formatter:function (value,row) { var arr = ['7','8']; ///// 状态:1=充值,2=盈利,3=亏损,4=团队收益,5=充值返利,6=下级充值返利,7=提现,8=提现驳回 var index = $.inArray(row.status, arr); if(index >=0){ return '<strong style="color: #3498db">'+value+'</strong>'; }else { return '-'; } }}, {field: 'username', title: __('Username'),events: Controller.api.events.copy,formatter: Controller.api.formatter.copy}, {field: 'score', title: __('Score'), operate:false,formatter:function (value) { return '<strong style="color: blue">+'+value+'</strong>'; }}, { field: 'operate', title: __('Operate'), table: table, events: { 'click .btn-paidan': function (e, value, row) { var m='确定进入排单池?'; Layer.confirm(m,function (index) { Layer.close(index); Fast.api.ajax({ url: "user/user/paidan", data: {id: row.id}, }, function (data, ret) { table.bootstrapTable('refresh'); },function (data,ret) { table.bootstrapTable('refresh'); }); }) return false; }, }, buttons: [ { name: 'content', text: __('抢单记录'), classname: 'btn btn-xs btn-success btn-dialog', title: __('查看会员抢单记录'), extend: 'data-area=\'["80%","85%"]\' data-toggle="tooltip"', url: 'pay/payall/index?pid={ids}' }, { name: 'shang', text: __('赛程上架'), icon: 'fa fa-long-arrow-up', classname: 'btn btn-xs btn-primary btn-addtabs', url: 'major/chapter/index/subject_id/{ids}', }, { name: 'indssssex', text: __('排单'), classname: 'btn btn-xs btn-danger btn-paidan', // icon:'fa fa-cancer', title:__('进入排单池'), visible: function (row) { if (row.grab_status=='1'){ return true; } return false; }, }, ], formatter: function (value, row, index) { //隐藏自定义的视频按钮 var that = $.extend({}, this); var table = $(that.table).clone(true); //权限判断 if(Config.chapter != true){ //通过Config.chapter 获取后台存的chapter console.log('没有视频权限'); $(table).data("operate-video", null); that.table = table; }else{ console.log('有视频权限'); } return Table.api.formatter.operate.call(that, value, row, index); } }, {field: 'description', title: __('Msg'), operate: 'LIKE %...%', formatter : function(value, row, index, field){ return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' data-toggle='tooltip' data-original-title='" + row.msg + "'>" + value + "</span>"; }, cellStyle : function(value, row, index, field){ return { css: { "white-space": "nowrap", "text-overflow": "ellipsis", "overflow": "hidden", "cursor":"pointer", "max-width":"200px" } }; } }, {field: 'Enabled', title: __('状态'), table: table1, searchList: {"1":__('启用'),"0":__('禁用')}, confirm: function (value) { return value=='0'?'确定【启用】该活动吗?':'确定【禁用】该活动吗?'; }, formatter: Table.api.formatter.toggle}, { field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, buttons: [ { name: 'log', title: '日志列表', text: '日志列表', icon: 'fa fa-list', classname: 'btn btn-primary btn-xs btn-click', click: function (e, data) { $("#myTabContent2 .form-commonsearch input[name='username']").val(data.username); $("#myTabContent2 .btn-refresh").trigger("click"); } } ], formatter: Table.api.formatter.operate }, {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); }}, { field: 'operate', title: __('Operate'), table: table,operate: false, events: { 'click .btn-false': function (e, value, row) { var m='确认该笔充值已失败吗?'; Layer.confirm(m,function (index) { Layer.close(index); Fast.api.ajax({ url: "finance/charger_check/falsed", data: {id: row.id}, }, function (data, ret) { table.bootstrapTable('refresh'); },function (data,ret) { table.bootstrapTable('refresh'); }); }); return false; }, 'click .btn-daozhang': function (e, value, row) { var m='<font color="green">若未充值相对应金额</font><br><font color="green">则在点击确认后减少到账积分!</font><br>需充值金额:'+row.money+' U<br>'+'应该到账积分:'+row.score+'<br>或需充值卢比:'+row.lubi+'<br>'; var ji=row.score; Layer.confirm(m,{title:'确认该笔充值已到账吗?'},function (index) { Layer.close(index); layer.prompt({title: '到账积分!',value:ji,formType: 3, btn: ["确认","取消"]}, function(value, indexx){ Layer.close(indexx); Fast.api.ajax({ url: "finance/charger_check/daozhang", data: {id: row.id,score:value}, }, function (data, ret) { table.bootstrapTable('refresh'); },function (data,ret) { table.bootstrapTable('refresh'); }); }); }); return false; } }, buttons: [ { name: 'index', text: __('到账'), classname: 'btn btn-xs btn-info btn-daozhang', icon:'fa fa-check', title:__('确认该笔充值已到账'), visible: function (row) { if (row.state == 1) return true; return false; }, }, { name: 'bai', text: __('失败'), classname: 'btn btn-xs btn-danger btn-false', icon:"fa fa-times", title:__('该笔转账失败'), visible: function (row) { if (row.state == 1) return true; return false; }, }, { name: 'index', text: __('团队'), classname: 'btn btn-xs btn-info btn-dialog', extend: 'data-area=\'["80%","85%"]\' ', title: __('查看当前会员的团队'), url: 'user/user_relation/index?uid={ids}' }, ], formatter: Table.api.formatter.buttons }, ] ] }); // 为表格绑定事件 Table.api.bindevent(table); //单选按钮 $('input:radio[name="row[type]"]').click(function(){ var checkValue = $('input:radio[name="row[type]"]:checked').val(); if (checkValue==0){ $(".per_1").hide(0); $(".per_3").show(0); }else{ $(".per_3").hide(0); $(".per_1").show(0); } }); //批量下载图片 $("#downloaderweima").on("click",function(res){ var zip = new Jszip(); var img = zip.folder("images"); // 生成图片文件夹 var all = table.bootstrapTable('getSelections'); // 获取表格全部选中的数据 if(all.length < 1){ Layer.msg("请选择要下载的二维码"); return false; } for(var i=0; i< all.length ;i++) { var img_arr = all[i].qrcode.split(','); //分割开数据 img.file(all[i].id+".png", img_arr[1], {base64:true});//图片批量写入文件 } zip.generateAsync({type:"blob"}).then(function(content) { // see FileSaver.js saveAs(content, "example.zip"); }); }); // 踢下线 $(document).on("click", ".btn-xia", function () { var ids = Table.api.selectedids(table); var m = '确定强制下线选择的用户吗?'; Layer.confirm(m, function (index) { Layer.close(index); Fast.api.ajax({ url: "user/user/pause", data: {ids: ids}, }, function (data, ret) { table.bootstrapTable('refresh'); }); }); return false; // alert(ids) // Table.api.multi("changestatus", ids.join(","), table, this); }); }, add: function () { //事件监听 $("#c-code").data("eSelect", function(row){ //后续操作 $("#c-s_name").val(row.c_name); }); //自定义行模板 $("#c-code").data("format-item", function(row){ return row.c_name + " - " + row.code; }); Form.api.bindevent($("form[role=form]")); }, edit: function () { Form.api.bindevent($("form[role=form]")); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); }, content: function (value, row, index) { var width = this.width != undefined ? (this.width.match(/^\d+$/) ? this.width + "px" : this.width) : "250px"; return "<div style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + ";' title='" + value + "' data-toggle='tooltip' data-placement='right'>" + value + "</div>"; }, formatter:{ copy:function (value,row,index) { var width = this.width != undefined ? (this.width.match(/^\d+$/) ? this.width + "px" : this.width) : "250px"; return '<button class="btn btn-copy btn-xs bg-success" data-clipboard-text="'+value+'" data-original-title="点击复制" data-toggle="tooltip">' + '<div style="white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:"'+ width +'";>'+ value +' </div>' + '</button>'; } }, events:{ copy:{ 'click .btn-copy':function (e,value,row,index) { var clipboard=new ClipboardJS(".btn"); Toastr.info("复制成功"); } } } } }; return Controller; }); ~~~ ```