diff --git a/application/admin/controller/CfItem.php b/application/admin/controller/CfItem.php index fcb0753..c668c07 100755 --- a/application/admin/controller/CfItem.php +++ b/application/admin/controller/CfItem.php @@ -3,6 +3,7 @@ namespace app\admin\controller; use app\admin\model\Area; +use app\admin\service\CfItemService; use app\common\controller\Backend; use think\Db; use think\exception\PDOException; @@ -237,4 +238,36 @@ class CfItem extends Backend return json(['list' => $result]); } + /**=================================================**/ + /** + * 获取列表 + * @return \think\response\Json + */ + public function list(){ + $params=$this->request->post(); + $service = new CfItemService(); + return json($service->getList($params)); + } + + /** + * 保存记录 + * @return \think\response\Json + */ + public function save(){ + $params=$this->request->post(); + $params['create_id']=$this->auth->id; + $params['group_id']=$this->auth->getGroupId(); + $service = new CfItemService(); + return json($service->save($params)); + } + + /** + * 删除 + * @return \think\response\Json + */ + public function delAll(){ + $params=$this->request->post(); + $service = new CfItemService(); + return json($service->del($params)); + } } diff --git a/application/admin/dao/CfHotelInfoDao.php b/application/admin/dao/CfHotelInfoDao.php index bf8bf0c..93bfa90 100644 --- a/application/admin/dao/CfHotelInfoDao.php +++ b/application/admin/dao/CfHotelInfoDao.php @@ -33,14 +33,14 @@ class CfHotelInfoDao 'city_name' => $param['city_name'], 'detail_address' => $param['detail_address'] ]; - $receiptOrder = new CfHotelInfo(); + $model = new CfHotelInfo(); if (empty($param['id'])) { $data['create_id'] = $param['create_id']; $data['group_id'] = $param['group_id']; - $id = $receiptOrder->insertGetId($data); + $id = $model->insertGetId($data); return Util::returnArrSu("", $id); } else { - $receiptOrder->save($data, ['id' => $param['id']]); + $model->save($data, ['id' => $param['id']]); return Util::returnArrSu("", $param['id']); } } catch (\Exception $e) { @@ -93,8 +93,8 @@ class CfHotelInfoDao public function del($id){ try { //设置收购单状态 - $receiptOrder = new CfHotelInfo(); - $receiptOrder->save(['del_flag' => 1], ['id' => $id]); + $model = new CfHotelInfo(); + $model->save(['del_flag' => 1], ['id' => $id]); return Util::returnArrSu(); } catch (\Exception $e) { return Util::returnArrEr("修改状态失败" . $e->getMessage()); diff --git a/application/admin/dao/CfItemDao.php b/application/admin/dao/CfItemDao.php new file mode 100644 index 0000000..0ee7d9f --- /dev/null +++ b/application/admin/dao/CfItemDao.php @@ -0,0 +1,106 @@ + $param['item_type'], + 'item_name' => $param['item_name'], + 'item_unit' => $param['item_unit'], + 'item_memo' => $param['item_memo'], + 'area' => $param['area'], + 'area_name' => $param['area_name'], + 'province' => $param['province'], + 'province_name' => $param['province_name'], + 'city' => $param['city'], + 'city_name' => $param['city_name'], + 'detail_address' => $param['detail_address'], + 'purchase_user_id'=>$param['purchase_user_id'] + ]; + $model = new CfItem(); + if (empty($param['id'])) { + $data['create_id'] = $param['create_id']; + $data['group_id'] = $param['group_id']; + $id = $model->insertGetId($data); + return Util::returnArrSu("", $id); + } else { + $model->save($data, ['id' => $param['id']]); + return Util::returnArrSu("", $param['id']); + } + } catch (\Exception $e) { + return Util::returnArrEr("更新记录失败:" . $e->getMessage()); + } + } + + /** + * 获取列表 + * @param $param + * @return array + */ + public function getList($param) + { + try { + $where = ["del_flag"=>0]; + if (!empty($param['item_name'])) { + $where['item_name'] = ["like","%".$param['item_name']."%"]; + } + if (!empty($param['item_type'])) { + $where["item_type"] = $param['item_type']; + } + if (!empty($param['area'])) { + $where["area"] = $param['area']; + } + if (!empty($param['province'])) { + $where["province"] = $param['province']; + } + if (!empty($param['city'])) { + $where["city"] = $param['city']; + } + $offset = ($param['pageNum'] - 1) * $param['pageSize']; + $model = new CfItem(); + $total = $model->where($where)->count(); + $list = $model->where($where) + ->limit($offset, $param['pageSize']) + ->order("id","DESC")->select(); + $data = ["total" => $total, "list" => $list->toArray()]; + return Util::returnArrSu("", $data); + } catch (\Exception $e) { + return Util::returnArrSu("", ["total" => 0, "list" => []]); + } + } + + /** + * 删除 + * @param $id + * @return array + */ + public function del($id){ + try { + //设置收购单状态 + $model = new CfItem(); + $model->save(['del_flag' => 1], ['id' => $id]); + return Util::returnArrSu(); + } catch (\Exception $e) { + return Util::returnArrEr("修改状态失败" . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/application/admin/service/CfItemService.php b/application/admin/service/CfItemService.php new file mode 100644 index 0000000..97045a8 --- /dev/null +++ b/application/admin/service/CfItemService.php @@ -0,0 +1,45 @@ +getList($param); + } + + /** + * 保存记录 + * @param $param + * @return array + */ + public function save($param){ + $dao = new CfItemDao(); + return $dao->save($param); + } + + /** + * 删除记录 + * @param $param + * @return array + */ + public function del($param){ + $dao = new CfItemDao(); + return $dao->del($param['id']); + } +} \ No newline at end of file diff --git a/application/admin/view/cf_hotel_info/index.html b/application/admin/view/cf_hotel_info/index.html index 558477b..8ffc858 100755 --- a/application/admin/view/cf_hotel_info/index.html +++ b/application/admin/view/cf_hotel_info/index.html @@ -83,7 +83,7 @@
- +
diff --git a/application/admin/view/cf_item/index.html b/application/admin/view/cf_item/index.html index 0ab2137..9ff5abc 100755 --- a/application/admin/view/cf_item/index.html +++ b/application/admin/view/cf_item/index.html @@ -1,35 +1,527 @@ -
- {:build_heading()} - -
-
- - + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + +
+ + + + + +
+ +
+
+
+
+ + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + + + +
+
+ + + +
+
+ 保存 +
+
+
+
+ + + + + + + + +