| | |
| | | |
| | | namespace app\shop\controller\supplier; |
| | | |
| | | use app\shop\model\user\UserAddress; |
| | | use app\common\enum\supplier\SupplierType; |
| | | use app\shop\controller\Controller; |
| | | use app\shop\model\supplier\Supplier as SupplierModel; |
| | |
| | | */ |
| | | public function index() |
| | | { |
| | | $typeList = SupplierType::getTypeName(); |
| | | $typeList = SupplierType::getTypeName();// 获取请求的供应商类型参数 |
| | | //获取该角色管理的区域 by yj 2023.12.20 |
| | | $shop_supplier_ids = SupplierModel::getSupplierIdsByUser($this->store['user']); |
| | | // 供应商列表 |
| | |
| | | if(!empty($shop_supplier_ids)){ |
| | | $postData["shop_supplier_ids"] = $shop_supplier_ids; |
| | | } |
| | | $supplier_type=$postData['supplier_type']??SupplierType::PHYSICAL; |
| | | // 根据供应商类型获取对应的分类 |
| | | $category = CategoryModel::getALL(['category_type'=>$supplier_type]); |
| | | $list = $model->getList($postData); |
| | | return $this->renderSuccess('', compact('list','typeList')); |
| | | return $this->renderSuccess('', compact('list','typeList','category')); |
| | | } |
| | | |
| | | /** |
| | |
| | | if($this->request->isGet()){ |
| | | return $this->renderSuccess('', compact('category','region','typeList')); |
| | | } |
| | | $data = $this->postData(); |
| | | // 新增记录 |
| | | if ($model->add($this->postData())) { |
| | | if ($model->add($data)) { |
| | | return $this->renderSuccess('', '添加成功'); |
| | | } |
| | | return $this->renderError($model->getError() ?: '添加失败'); |
| | |
| | | if($this->request->isGet()){ |
| | | return $this->renderSuccess('', compact('model','category','region','areaList')); |
| | | } |
| | | if ($model->edit($this->postData())) { |
| | | $data = $this->postData(); |
| | | if ($model->edit($data)) { |
| | | return $this->renderSuccess('', '更新成功'); |
| | | } |
| | | return $this->renderError($model->getError() ?: '更新失败'); |