浅念`

导航

fastadmin框架使用整理

1.弹出窗口全屏
 buttons[
  {
    name:'ids',
    text:'查看详情',
    title:'详情',
    icon:'',
    classname:'btn btn-xs btn-click btn-primary btn-dialog',
    extend: 'data-area= \'["100%", "100%"]\'',//输入框全屏属性
    url:'',
    click:function(data){
    
    }
  }
]
2.表格重载
$('#table').bootstrapTable('load', dataList)//dataList是表格数据数组
3.自定义按钮弹框
/*
*html
*/
//goods/type_list按钮调用的接口
//data-url点击按钮打开的弹框html
//data-title弹出框的title
<div style="height: 35px;margin-top: 20px;margin-bottom:20px; ">
  <a href="javascript:;" class="spec_add_btn btn btn-primary  {:$auth->check('goods/type_list')?'':'hide'}"
  data-url="production/recyclebin" data-title="自定义弹框">自定义按钮</a>
</div>
/*
*js
*/
//自定义弹框
$(document).on('click', '.spec_add_btn', function (event) {
  var url = $(this).attr('data-url');
  if (!url) return false;
  var msg = $(this).attr('data-title');
  var width = $(this).attr('data-width');
  var height = $(this).attr('data-height');
  var area = [$(window).width() > 800 ? (width ? width : '800px') : '95%', $(window).height() > 600 ? (height ? height : '600px') : '95%'];//全屏
  var options={
    shadeClose: false,
    shade: [0.3, '#393d49'],
    area: area,
    callback:function(value){
      //回调
      console.log(value)
    }
  }
 Fast.api.open(url, msg, options)  
})
4.editable内联输入框
{
  {
    field:'num',title:'数量',editable:{
       type:'text',
       validate:function(v){
        var number = /^\d*$/;//数字正则
        if (!v) {
          return '数量不能为空';
        }
        if (!number.test(v)) {
          return '请输入数字';
        }
        let index = $(this).closest('tr').index();
        let row = table.bootstrapTable('getData')[index];
        row['num'] = v;
        table.bootstrapTable('updateRow', {//更新table中row的数据
          index,
          row
        }); 
      }
    }
  }
}
5.给选中行添加行内颜色
rowStyle:function(row,index){
  /*
  *indexColor当前点击的这一行
  */
  if(row == indexColor){
    var style = {css:{'background':'#e4f6d4'}};
    return style;
  }else{
    var style = {css:{'background':'#fff'}};
    return style;
  }
}
6.计算金额
//要计算的那个字段
{field:'total_cost_price',title:'成本金额',operate:false,align:'center',formatter:constPrice}
//两个表格之间计算
function constPrice(value,row,index){
  row.total_cost_price = 0;//默认显示金额为0
  if(row.matching_list != undefined){//判断另一个表格中数据是否存在
    for(var i=0;i<row.matching_list.length;i++){//遍历另一个表格
      row.total_cost_price += row.matching_list[i].sum_num * row.matching_list[i].cost_price;//计算
    }
  }
  return row.total_cost_price;
}
//单表格内容计算
{field:'sum_num',title:'总数',formatter:sumNum}
function sumNum(value,row,index){
  row['sum_num'] = row['matching_num'] * row['production_num'];
  return row['sum_num'];
}
fastadmin表格方法
onLoadSuccess:function(row){
  //数据加载完成执行
}
onCheckAll:function(row){
  //全选时执行
}
onUncheckAll:function(row){
  //反全选时执行
}
onCheck:function(row){
  //单选某一行时执行
}
onUncheck:function(row){
  //反选某一行时执行
}
fastadmin隐藏默认功能
 commonSearch: false,
 showToggle: false,
 showColumns: false,
 showExport: false,
 search: false,
 clickToSelect: false, //是否启用点击选中
 dblClickToEdit: false, //是否启用双击编辑

posted on 2021-05-30 11:11  浅念`  阅读(226)  评论(0编辑  收藏  举报