title = '服务管理'; $query = $this->_query($this->table)->like('trade_name'); $query->order('id desc')->page(); } /** * 数据列表处理 * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _index_page_filter(&$data) { foreach ($data as $k => &$v) { $data[$k]['service_category_id'] = Db::name('release_service_category')->where('id',$v['service_category_id'])->value('service_name'); } } /** * 添加服务 * @auth true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function add() { $this->title = '添加服务'; if(input('reloaded') !=1) { echo ""; } $this->isAddMode = '1'; $this->_form($this->table, 'form'); } /** * 编辑服务 * @auth true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function edit() { $this->title = '编辑服务'; $this->isAddMode = '0'; $id = $this->request->get('id'); $charging_standard = Db::name('release_commodity')->where('id',$id)->value('charging_standard'); $charging_standard_arr = json_decode($charging_standard,true); $this->charging_standard_arr = $charging_standard_arr; $commodity_label = Db::name('release_commodity')->where('id',$id)->value('commodity_label'); $this->commodity_label_arr = explode(',',$commodity_label); $this->_form($this->table, 'form'); } /** * 表单数据处理 * @param array $data * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ protected function _form_filter(&$data) { if ($this->request->isGet()) { $this->service_category = Db::name('release_service_category')->where(['is_deleted' => '0', 'status' => '1'])->order('sort desc,id desc')->select(); }else{ if(isset($data['name'])){ $charging_name_count = count($data['name']); $charging = []; for ($i= 0;$i < $charging_name_count;$i++) { $charging[$i]['name'] = $data['name'][$i]?$data['name'][$i] :'' ; $charging[$i]['price'] = $data['price'][$i]?$data['price'][$i] :'' ; } $data['charging_standard'] = json_encode($charging); $label_count = count($data['label']); $label = ''; for ($i= 0;$i < $label_count;$i++) { if($i == 0){ $label .= $data['label'][$i]; }else{ $label .= ','.$data['label'][$i]; } } $data['commodity_label'] = $label; } } } /** * 表单结果处理 * @param boolean $result */ protected function _form_result($result) { if ($result && $this->request->isPost()) { $this->success('服务编辑成功!', $_SERVER['HTTP_REFERER'].'#/store/goods/index.html?spm=m-73-75-76'); } } /** * 禁用服务 * @auth true * @throws \think\Exception * @throws \think\exception\PDOException */ public function forbid() { $this->_save($this->table, ['status' => '0']); } /** * 启用服务 * @auth true * @throws \think\Exception * @throws \think\exception\PDOException */ public function resume() { $this->_save($this->table, ['status' => '1']); } /** * 删除服务 * @auth true * @throws \think\Exception * @throws \think\exception\PDOException */ public function remove() { $this->_delete($this->table); } }