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