```
~~~
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;
});
~~~
```
- 空白目錄
- thinkphp5
- tools-常用類庫
- redis類庫
- Excel類庫
- File文件操作類庫
- Http請求類庫
- Maile郵件發送
- Hooks行為鉤子
- 七牛云
- 隨機數和字符串生成
- 字符串處理
- 時間類處理
- tree型轉換
- 工具類庫
- 文件打包下載
- 常用功能
- 文件上傳
- php生成word文檔
- elasticsearch 基本搜索
- 使用jwt開發API接口
- 安裝模及搭建
- ApiCheck.php
- ApiCheckLogin.php
- common.php
- Login.php
- Comment.php
- 漢字轉拼音
- 安裝使用
- Pinyin類
- elasticsearch操作
- 常用方法
- 數據源生成layui-select
- 獲取自定義配置項
- 百度編輯器
- 格式化文件大小
- 多語言設置
- hook監聽
- 域名綁定到模塊
- thinkphp6
- 文件上傳
- tp5totp6
- 創建路徑
- 獲取類所有方法
- password_hash加密驗證
- 生成 qrcode
- 郵件發送
- 獲取QQ信息
- GoogleAuthenticator
- redis限流
- redis 加鎖
- 百度翻譯
- QueryList爬取數據
- 獲取時間類
- 命令
- Git常用命令
- easyswoole
- pix_qrcode
- 驗證 cpf,cnpj
- php常用方法
- 日志
- 卡通頭像
- 兩位小數
- 圖片轉base64
- auth加密解密
- phpoffice/phpspreadsheet導入導出
- fastadmin
- 樹結構
- 單選框
- 復選框
- 二級搜索
- select選擇框
- selectpage選中回調事件
- 標簽添加
- 修改where條件
- 表格列表中添加input框
- selectpage事件
- fieldlist
- js操作
- test_js
- 多表格
- template模板