model = new ShopListModel(); $this->assign('customerList', Customer::where('status', 1)->column('name','id')); $this->assign('platformList', site_config('addonsd.platform_list')); $this->assign('userList', User::where('status',Customer::STATUS_NORMAL)->column('nickname','id')); $this->assign('fieldList', StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title','id')); $this->relationField=['customer','staff']; } #[Route('GET,POST','specs')] public function specs() { if($this->request->isAjax()){ $ids = $this->request->post('ids/d', 0); $params = $this->request->post(''); if(empty($params['variety']) || empty($ids) || empty($params['type_box'])) return resp_json(0, '参数错误'); $this->model->where('id', $ids)->save([ 'variety' => json_encode($params['variety'], JSON_UNESCAPED_UNICODE), 'type_spec' => json_encode($params['type_box'], JSON_UNESCAPED_UNICODE), ]); return resp_json(200,'操作成功'); }else{ $ids = $this->request->get('ids/d', 0); $rows = $this->model::find($ids); $rows->variety = $rows->variety? json_decode($rows->variety, true) : []; $rows->type_spec = $rows->type_spec? json_decode($rows->type_spec, true) : []; $this->assign('row', $rows); return $this->fetch(); } } #[Route('GET','get_box')] public function get_box() { if($this->request->isAjax()){ $result = []; $customer_id = $this->request->get('customer_id/d', 0); $type_id = $this->request->get('type_id/d', 0); if(empty($type_id) || empty($customer_id)) return resp_json(0, '参数错误'); $rows = CustomerSpecBack::where('customer_id', $customer_id)->order('sort desc')->find(); if($rows->specs){ $specs = json_decode($rows->specs, true); $result = SpecService::getSpecsList($type_id, $specs); } return json($result, 200); } } }