fastadmin 自定义按钮和上传图片


自定义按钮

{
     field: 'buttons',
      width: "120px",
      title: __('按钮组'),
      table: table,
      events: Table.api.events.operate,
      buttons: [
          {
              name: 'tongguo',
              text: '通过',
              title: '通过',
              classname: 'btn btn-xs btn-success btn-magic btn-ajax',
              icon: 'fa fa-magic',
              url: 'agent_live_access/qiehuangongsi',
              confirm: '确认通过?',
              refresh:true,
              success: function (data, ret) {
                  table.bootstrapTable('refresh');
                  return false;
              },
              error: function (data, ret) {
              // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
                  Layer.alert(ret.msg);
                  return false;
              }
          },
      ],
      formatter: Table.api.formatter.buttons
  },

public function qiehuangongsi($ids = null)
    {

        $row = $this->model->get($ids);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        $adminIds = $this->getDataLimitAdminIds();
        if (is_array($adminIds)) {
            if (!in_array($row[$this->dataLimitField], $adminIds)) {
                $this->error(__('You have no permission'));
            }
        }
//        if ($row['type']==2){
//            $this->error('该直播间不在线,无法修改');
//        }
        if ($row['isgongsi']==1){
            Db::name('agent_live_access')->where(array('id'=>$ids))->setField('isgongsi',0);
        }else{
            Db::name('agent_live_access')->where(array('id'=>$ids))->setField('isgongsi',1);
        }
        $this->success($ids);
    }

上传图片(需要取消这个接口的登录权限限制)

接口地址:

http://pb.com/index.php/api/common/upload

接口功能:

提交图片数据,返回地址数据


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM