fastadmin 常用知识点

2019-12-25 Frank PHP

[TOC]

时间搜索

{field: 'xieche_time', title: __('Xieche_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},

搜索中不显示:operate:false

{field: 'addtime', title: __('Addtime'), operate:false},

between 搜索

{field: 'gai_yunfei', title: __('Gai_yunfei'), operate:'BETWEEN'},

列表中隐藏

visible: false;

selectpage 表单传递参数

data-params='{"custom[is_del]":"0"}'

点击添加或者编辑按钮的时候弹窗的大小

在 js 中设置

$(".btn-edit,.btn-add,.btn-editone").data("area", ["100%", "100%"]);

模糊搜索

operate: 'LIKE %...%', placeholder: '关键字,模糊搜索'

//禁用默认搜索

search: false,

//启用普通表单搜索

commonSearch: true,

//可以控制是否默认显示搜索单表,false则隐藏,默认为false

searchFormVisible: false,

唯一搜索设置字段

$searchFields = ['chehao','id'];

list($where, $sort, $order, $offset, $limit) = $this->buildparams($searchFields);

修改搜索条件

if (isset($filter['aa.bb']) && $filter['aa.bb'] == 0) {
  $op = $this->request->get("op");
  $op = json_decode($op, true);
  $op['aa.bb'] = 'IS NULL';
  $this->request->get(["op" => json_encode($op)]);
}

关联查询一对一

# model
public function bb()
{
  return $this->hasOne('bb', 'id', 'bb_id', [], 'LEFT')->field('id')->setEagerlyType(0);
}
# controller
$this->relationSearch = true;
$list = $this->model
  ->with("bb")
  ->where($where)
  ->order($sort, $order)
  ->select();

搜索里面添加 selectpage

var table = $("#table");

// table.on('common-search.bs.table', function (event, table, params, query) {

// //这里可以对params值进行修改,从而影响搜索条件

// });

//在普通搜索渲染后

table.on("post-common-search.bs.table", function(event, table) {
  $("input[name='shifa_id']")
    .addClass("selectpage")
    .data("source", "kuangdian/index");
  $("input[name='xie_addr_id']")
    .addClass("selectpage")
    .data("source", "xiehuodian/index");
  $("input[name='xianlu']")
    .addClass("selectpage")
    .data("source", "xianlu/index");
  $("input[name='depart_id']")
    .addClass("selectpage")
    .data("source", "depart/index")
    .attr("data-field", "depart_name");
  Form.events.cxselect($("form", table.$commonsearch));
  Form.events.selectpage($("form", table.$commonsearch));
});

下拉框搜索

{field: 'from_id', title: '数据来源', searchList: {"0":'调度结算',"1":'无磅单数据',"2": '司机宝导入', "3": '货速运导入'}, operate: 'FIND_IN_SET', formatter: Table.api.formatter.normal,visible:false},

批量操作

$(".btn-qiyong").on("click", function(e) {
  var url = $(this).data("url");

  var temp = table.bootstrapTable("getSelections");

  var arr = [];

  $.each(temp, function(i, v) {
    arr.push(v.USERID);
  });
  Layer.confirm(
    "确定吗?",
    {
      icon: 3,
      title: "提示"
    },
    function(index) {
      Fast.api.ajax(
        {
          type: "POST",

          url: url,

          data: { ids: arr, dis: 0 }
        },
        function(data, ret) {
          $(".btn-refresh").click();
        }
      );
    }
  );
});

自定义字段显示样式

{
field: 'DISABLE', title: __('Disable'), align: 'left', formatter: function (value, row, index) {
  // console.log(row);return;
  var str = '';
  if (row.DISABLE == 0){
    str = '<div class="tdtitle">启用</div>';;
  }
  if (row.DISABLE == 1){
    str = '<div class="tdtitle" style="color: red;">已禁用</div>';;
  }
  return str;
  // return '<div class="tdtitle"><a href="' + row.url + '">' + value + '</a></div>';

}

},

用户名少于 3 个字符不能登陆,这个如何 修改 ,如果是 2 个汉字,也就是不能登陆

字符应该按字母算吧,ab 是 2 个字符,汉字最少 2 个汉子。
这个问题怎么调整解决

修改 user.php

$rule = [ 'username' => 'require|length:3,30', 'password' => 'require|length:6,30', 'email' => 'require|email', 'mobile' => 'regex:/^1\d{10}$/', 'captcha' => 'require|captcha', '__token__' => 'token', ];

bootstrap-table 选中行样式修改

<style>
  .fixed-table-container tbody .selected .bg-table-td-selected {
    background-color: #31b0d5;
  }
</style>
onClickRow: function(row, $element, field) {
    $(".bg-table-td-selected").removeClass("bg-table-td-selected");
    $($element)
    .find("td")
    .addClass("bg-table-td-selected");
},
onCheck: function(row, $element) {
    $($element)
    .parents("tr")
    .find("td")
    .addClass("bg-table-td-selected");
},
onUncheck: function(row, $element) {
    $($element)
    .parents("tr")
    .find("td")
    .removeClass("bg-table-td-selected");
}

参考:

发表评论 登录

Top