From d6eaf852fc7182c5e5894a83529a7d06c85ab987 Mon Sep 17 00:00:00 2001 From: nizongfeng Date: Tue, 7 Feb 2023 15:47:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/OrderMain.php | 26 +++++- application/admin/dao/FileDao.php | 67 ++++++++++++++ application/admin/dao/ReceiptOrderDao.php | 4 +- application/admin/model/File.php | 20 +++++ application/admin/view/payment_order/index.html | 109 +++++++++++++++++++++- application/admin/view/receipt_order/index.html | 114 +++++++++++++++++++++++- application/common/library/Upload.php | 16 ++-- 7 files changed, 341 insertions(+), 15 deletions(-) create mode 100644 application/admin/dao/FileDao.php create mode 100644 application/admin/model/File.php diff --git a/application/admin/controller/OrderMain.php b/application/admin/controller/OrderMain.php index d6f4c3b..1c9cdb8 100755 --- a/application/admin/controller/OrderMain.php +++ b/application/admin/controller/OrderMain.php @@ -2,6 +2,7 @@ namespace app\admin\controller; +use app\admin\dao\FileDao; use app\admin\dao\GroupDao; use app\admin\dao\OrderMainDao; use app\admin\dao\OrderMemoDao; @@ -20,7 +21,7 @@ use think\Loader; */ class OrderMain extends Backend { - protected $noNeedRight = ['getOrderList',"save","delSubOrder","subOrderSave","getShowInfo","newAdd","insertOrderMain","addMemo","getMemoList","setHotFlag"]; + protected $noNeedRight = ['getOrderList',"save","delSubOrder","subOrderSave","getShowInfo","newAdd","insertOrderMain","addMemo","getMemoList","setHotFlag","addFileInfo","getFileList"]; /** * OrderMain模型对象 * @var \app\admin\model\OrderMain @@ -168,4 +169,27 @@ class OrderMain extends Backend $result = $model->setHotFlag($params["order_id"],$params["val"]); return json($result); } + + /** + * 添加附件记录 + * @return \think\response\Json + */ + public function addFileInfo(){ + $params=$this->request->post(); + $params['create_id']=$this->auth->id; + $model = new FileDao(); + $result = $model->addInfo($params["type"],$params["file"],$params['name'],$params['id'],$params['create_id']); + return json($result); + } + + /** + * 获取附件列表 + * @return \think\response\Json + */ + public function getFileList(){ + $params=$this->request->post(); + $model = new FileDao(); + $result = $model->getList($params["type"],$params['id']); + return json($result); + } } diff --git a/application/admin/dao/FileDao.php b/application/admin/dao/FileDao.php new file mode 100644 index 0000000..95c7be2 --- /dev/null +++ b/application/admin/dao/FileDao.php @@ -0,0 +1,67 @@ +$type, + "file"=>$file, + "name"=>$name, + "obj_id"=>$id, + "create_id"=>$create_id + ]; + if (!empty($create_id)) { + $adminDao = new AdminDao(); + $admin = $adminDao->getInfoById($create_id); + if ($admin["flag"]) { + $data["create_name"] = $admin["data"]["nickname"]; + } + } + $fileModel->insert($data); + return Util::returnArrSu("成功"); + }catch (Exception $e){ + return Util::returnArrEr("失败:".$e->getMessage()); + } + } + + /** + * 获取列表 + * @param $type + * @param $file + * @param $id + * @return array + */ + public function getList($type, $id){ + try{ + $fileModel = new File(); + $where = [ + "type"=>$type, + "obj_id"=>$id + ]; + $list = $fileModel->where($where)->order("id","DESC")->select()->toArray(); + return Util::returnArrSu("成功", $list); + }catch (Exception $e){ + return Util::returnArrEr("失败:".$e->getMessage()); + } + } +} \ No newline at end of file diff --git a/application/admin/dao/ReceiptOrderDao.php b/application/admin/dao/ReceiptOrderDao.php index ecf6b37..b0433d9 100644 --- a/application/admin/dao/ReceiptOrderDao.php +++ b/application/admin/dao/ReceiptOrderDao.php @@ -119,9 +119,9 @@ class ReceiptOrderDao try { $where = ["a.del_flag"=>0,"a.group_id"=>$param['group_id']]; - if (empty($param['order_id'])) { + if (!empty($param['order_id'])) { $orderMainModel = new OrderMain(); - $orderMain = $orderMainModel->where(["id"=>$param['order_id']])->select()->find(); + $orderMain = $orderMainModel->where(["id"=>$param['order_id']])->find(); if ($orderMain == null || empty($orderMain['receipt_order_id'])) { $where["a.id"] = 0; }else{ diff --git a/application/admin/model/File.php b/application/admin/model/File.php new file mode 100644 index 0000000..50b5fab --- /dev/null +++ b/application/admin/model/File.php @@ -0,0 +1,20 @@ +编辑 订单 删除 - 附件 + 附件 @@ -294,6 +294,53 @@ + + + + +
+ +
+
+
+
+ + + +
+
+ +
+ + 点击上传 + +
+
+
+
+ 提交 +
+
+ + + + + + + + + +
+
@@ -403,6 +450,15 @@ } }] }, + showFileFlag:false, + fileData:{ + "id":"", + "name":"", + "file":"", + "type":"pay" + }, + fileTable:[], + fileList:[] } }, created() { @@ -420,6 +476,50 @@ } }, methods: { + handleChange(file, fileList) { + this.fileList = fileList.slice(-3); + }, + showFile(id){ + this.fileData["id"]=id; + this.showFileFlag = true + axios.post("/hotel.php/order_main/getFileList", this.fileData).then((response) => { + let data = response.data; + if (data.flag) { + this.fileTable = data.data + } else { + this.$message.error(response.msg); + } + }).catch(function (error) { + console.log(error); + }); + }, + handleExceed(files, fileList) { + this.$message.warning(`当前限制选择 1 个文件`); + }, + fileSubmit(){ + if (this.fileList.length==0) { + this.$message.error(`请选择文件`); + return false; + } + if (this.fileData["name"]=="") { + this.$message.error(`请输入名称标识`); + return false; + } + let file = this.fileList[0].response.data.url; + this.fileData["file"]=file; + axios.post("/hotel.php/order_main/addFileInfo", this.fileData).then((response) => { + let data = response.data; + if (data.flag) { + this.fileList=[] + this.showFile(this.fileData["id"]) + } else { + this.$message.error(response.msg); + } + }).catch(function (error) { + console.log(error); + }); + + }, getTypeName(info) { for (let i = 0; i < this.type_list.length; i++) { if (this.type_list[i].id == info.hotel_name) { @@ -716,6 +816,13 @@ })