分享
  • 收藏
  • 举报
    X
    分享一个查看详细信息的方法,自动填充$this->form_items
    464
    5

    后台查看该条信息的详细内容,根据数据表字段自动展现

    /*
    *右侧按钮
    */
    $this->tab_ext['right_button'] = [
        ['type' => 'delete'],
        ['type' => 'edit'],
        [
            'title' => '查看详细',
            'url' => auto_url('viewdetail', ['id' => '__id__']),
            'icon' => 'fa fa-fw fa-clock-o',
            'class' => '',
        ]
    ];
    /*
       * 查看详细信息方法
       */
    public function viewdetail($id = '')
    {
        $info = $this->model->get($id);
        $table = $this->model->getTable();
        $this->form_items = Ocrblicense::tablefields($table);//假设你把Ocrblicense方法放在了模型Ocrblicense中
        $this->tab_ext = [
            'page_title' => '查看' . get_user($info['uid'])['truename'] . '的银行卡信息',
        ];
        return $this->getAdminShow($info);
    }
    /*
     * 根据数据表信息填充$this->form_items
     * 可以放在公共方法中
     */
    public static function tablefields($table){
        $sql = "show full columns from {$table}";
        $f_array = Db::query($sql);
        foreach($f_array AS $k=>$v){
            $type = $v['Type'];$comment = $v['Comment'];
            if(in_array($v['Field'],['up_image','up_image_back']) ){
                $type = 'image';
            }
            if($v['Field'] === 'id'){
                $comment = 'ID';
            }
            $t = [$type,$v['Field'],$comment,'','',$v['Default']];
            $items_arr[] = $t;
        }
        return $items_arr;
    }

    示例:

    5
    赏礼
    赏钱
    收藏
    点击回复
        全部留言
    • 5
    • Array 消费:15元 2021-11-03 11:07 11:076楼
      不错。确实很详细。
    0 赏钱 赏礼回复
    • Szup.com乐刷朱弟 实战运营者 消费:4824.58元 2021-11-03 08:25 08:25
      iPhone
      6楼
      我也想被隔离
    1 赏钱 赏礼回复
    • 银杏114在线 实战运营者 消费:3609.79元 2021-11-02 20:31 20:316楼
      点赞
    0 赏钱 赏礼回复
    • 袁冬 普通粉丝 消费:160.85元 2021-11-02 13:36 13:366楼
      打卡 点赞
    0 赏钱 赏礼回复
    更多回复
        你可能感兴趣的主题
    恢复多功能编辑器
  • 3 1
  • 推荐内容
    扫一扫访问手机版
    请选择要切换的马甲:

     
    网页即时交流
    QQ咨询
    咨询热线
    020-28998648