title = '运费模板'; $query = $this->_query($this->table)->where('is_deleted',0)->like('name'); $query->order('status desc , sort desc , id desc')->page(); } /** * 数据列表处理 * @auth true * @menu true * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _index_page_filter(&$data) { } /** * 添加运费模板 * @auth true * @menu 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 = '添加运费模板'; $this->city_area = get_city_area(); $this->_form($this->table, 'form'); } /** * 编辑运费模板 * @auth true * @menu 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->city_area = get_city_area(); $this->_form($this->table, 'form'); } /** * 禁用 * @auth true * @menu true * @throws \think\Exception * @throws \think\exception\PDOException */ public function forbidden() { $this->_save($this->table, ['status' => '0']); } /** * 启用 * @auth true * @menu true * @throws \think\Exception * @throws \think\exception\PDOException */ public function enable() { $this->_save($this->table, ['status' => 1]); } /** * 删除 * @auth true * @menu true * @throws \think\Exception * @throws \think\exception\PDOException */ public function del() { $this->_save($this->table, ['is_deleted' => 1]); } /* 表单数据处理 * @auth true * @menu true * @param array $data */ protected function _form_filter(&$data) { // 添加或编辑模板 if ($this->request->isPost()) { $custom_num = count($data['first_num']); $custom_data = []; for ($i= 0;$i < $custom_num;$i++) { $custom_data[$i]['express'] = $data['express'][$i]; $custom_data[$i]['first_num'] = $data['first_num'][$i] > 0 ? intval($data['first_num'][$i]):0; $custom_data[$i]['first_price'] = $data['first_price'][$i]> 0 ? number_format($data['first_price'][$i],2) :0 ; $custom_data[$i]['keep_price'] = $data['keep_price'][$i] > 0 ? number_format($data['keep_price'][$i],2) :0 ; } $data['custom'] = json_encode($custom_data); } } protected function _form_result($id) { $this->success('操作成功', 'javascript:history.back()'); } }