<?php
namespace admin\action;
use \model\pro\pro;
use \model\tgbrand;
class tgbrandAction  extends \action
{
    public function list()
    {
        $req = \mvc::$req;
		\view::set('req',$req);
        \view::put();
    }

    public function getList()
    {
        $req = \mvc::$req;
		$rules = $this->urlRulesToWhere($req);
		$tgbrand = new tgbrand();
		$data = $tgbrand->getList($req, $rules);
		$this->successJson($data);
    }

    public function detail()
    {
        $req = \mvc::$req;
        if($req['tb_id']){
            $tgbrand = new tgbrand();
            $data = $tgbrand->getDetail($req['tb_id']);
        }

        $pro = new pro();
		$pbArr = $pro->getProBrand(['pb_id'=>1]);
		\view::set('pbArr',$pbArr);
        \view::set('item',$data?:[]);
		\view::set('req',$req);
        \view::put(); 
    }

    public function edit()
    {
        $req = \mvc::$req;
        $tgbrand = new tgbrand();
        $id = $tgbrand->saveData($req);
        $this->successJson(['key'=>$id]);
    }

    public function delData()
    {
        $req = \mvc::$req;
        $tgbrand = new tgbrand();
        if(!isset($req['ids'])){
            $this->errorJson('请选择要删除的数据');
        }
        $ids = !is_array($req['ids'])?explode(',',$req['ids']):$req['ids'];
        $data = $tgbrand->delData($ids);
        $this->successJson($data);
    }

    /**
     * @method 未绑定统计
     * @author zhengweihua 
     * @copyright 2025-05-30
     */
    public function unbindStatistics()
    {
        $req = \mvc::$req;
        $tgbrand = new tgbrand();
        $data = $tgbrand->unbindStatistics($req);

        \view::set('item',$data?:[]);
		\view::set('req',$req);
        \view::put(); 
    }
}