diff --git a/application/admin/controller/ReceiptOrder.php b/application/admin/controller/ReceiptOrder.php
index 9539a19..c4376ed 100755
--- a/application/admin/controller/ReceiptOrder.php
+++ b/application/admin/controller/ReceiptOrder.php
@@ -256,4 +256,14 @@ class ReceiptOrder extends Backend
return json($result);
}
+ /**
+ * 删除采购单
+ */
+ public function delAll(){
+ $params=$this->request->post();
+ $service = new ReceiptOrderService();
+ $result = $service->delAll($params['id']);
+ return json($result);
+ }
+
}
diff --git a/application/admin/service/OrderMainDao.php b/application/admin/service/OrderMainDao.php
index 9c7949a..d973184 100644
--- a/application/admin/service/OrderMainDao.php
+++ b/application/admin/service/OrderMainDao.php
@@ -216,4 +216,22 @@ class OrderMainDao
return Util::returnArrSu("", ["total" => 0, "list" => []]);
}
}
+
+ /**
+ * 删除采购单
+ * @param $id
+ * @return array
+ */
+ public function delReceiptOrder($id){
+ try{
+ $data = [
+ "del_flag"=>1
+ ];
+ $model = new OrderMain();
+ $model->save($data,["receipt_order_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/ReceiptOrderDao.php b/application/admin/service/ReceiptOrderDao.php
index 7fcef8c..cc61898 100644
--- a/application/admin/service/ReceiptOrderDao.php
+++ b/application/admin/service/ReceiptOrderDao.php
@@ -88,7 +88,7 @@ class ReceiptOrderDao
public function getList($param)
{
try {
- $where = [];
+ $where = ["a.del_flag"=>0];
if (!empty($param['name'])) {
$where['a.name'] = ["like","%".$param['name']."%"];
}
@@ -118,4 +118,20 @@ class ReceiptOrderDao
return Util::returnArrSu("", ["total" => 0, "list" => []]);
}
}
+
+ /**
+ * 删除
+ * @param $id
+ * @return array
+ */
+ public function del($id){
+ try {
+ //设置收购单状态
+ $receiptOrder = new ReceiptOrder();
+ $receiptOrder->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/ReceiptOrderService.php b/application/admin/service/ReceiptOrderService.php
index a442839..6e0528d 100644
--- a/application/admin/service/ReceiptOrderService.php
+++ b/application/admin/service/ReceiptOrderService.php
@@ -121,12 +121,36 @@ class ReceiptOrderService
if (!empty($param['commissioner_id'])) {
$where['commissioner_id'] = $param['commissioner_id'];
}
+ if (!empty($param['user_name'])) {
+ $where['user_name'] = ["like","%".$param['user_name']."%"];
+ }
+ if (!empty($param['user_phone'])) {
+ $where['user_phone'] = $param['user_phone'];
+ }
if (!empty($param['create_id'])) {
$where['create_id'] = $param['create_id'];
}
+ //金额区间查询
+ if (!empty($param['startMoney'])&& empty($param['endMoney'])) {
+ $where['total_amount'] = [">=",$param['startMoney']];
+ }
+ if (!empty($param['endMoney']) && empty($param['startMoney'])) {
+ $where['total_amount'] = ["<=",$param['endMoney']];
+ }
+ if (!empty($param['endMoney']) && !empty($param['startMoney'])) {
+ $where['total_amount'] = ["between",[$param['startMoney'],$param['endMoney']]];
+ }
+ //时间区间查询
+ if (!empty($param['startTime']) && empty($param['endTime'])) {
+ $where['create_time'] = [">=",$param['startTime']." 00:00:00"];
+ }
+ if (!empty($param['endTime'])&& empty($param['startTime'])) {
+ $where['create_time'] = ["<=",$param['endTime']." 23:59:59"];
+ }
+ if(!empty($param['endTime'])&& !empty($param['startTime'])){
+ $where['create_time'] = ["between",[$param['startTime']." 00:00:00",$param['endTime']." 23:59:59"]];
+ }
switch ($param['inReceipt']) {
- case 0:
- break;
case 1:
$where["receipt_order_id"] = $param['receipt_order_id'];
break;
@@ -138,4 +162,29 @@ class ReceiptOrderService
}
return $orderMainDao->getOrderListByWhere($where,$param);
}
+
+ /**
+ * 删除采购单
+ * @param $id
+ * @return array
+ */
+ public function delAll($id){
+ Db::startTrans();
+ //1.删除采购单下的主订单
+ $orderMainDao = new OrderMainDao();
+ $delReceipt = $orderMainDao->delReceiptOrder($id);
+ if (!$delReceipt['flag']) {
+ Db::rollback();
+ return $delReceipt;
+ }
+ //2.删除采购单
+ $model = new ReceiptOrderDao();
+ $delRe = $model->del($id);
+ if (!$delRe['flag']) {
+ Db::rollback();
+ return $delRe;
+ }
+ Db::commit();
+ return Util::returnArrSu();
+ }
}
\ No newline at end of file
diff --git a/application/admin/view/receipt_order/index.html b/application/admin/view/receipt_order/index.html
index bfccf9e..bade57c 100755
--- a/application/admin/view/receipt_order/index.html
+++ b/application/admin/view/receipt_order/index.html
@@ -47,7 +47,7 @@
编辑
订单
- 删除
+ 删除
@@ -99,7 +99,7 @@
-
+
@@ -121,7 +121,7 @@
订单ID:
订单状态:
-
+
-
-
+
-
+
+
+
+
@@ -192,6 +218,9 @@
+
+ 添加到采购单
+
{
console.log(response)
@@ -457,6 +501,18 @@
console.log(error);
});
},
+ addOrderAll(){
+ let orderId = "";
+ let length = this.multipleSelection.length;
+ for (var k = 0; k < length; k++) {
+ if (orderId == "") {
+ orderId = this.multipleSelection[k].id;
+ continue;
+ }
+ orderId =orderId+","+this.multipleSelection[k].id;
+ }
+ this.addOrderMain(orderId);
+ },
removeOrderMain(order_id){
let param = {
order_id:order_id,
@@ -476,6 +532,36 @@
}).catch(function (error) {
console.log(error);
});
+ },
+ delAll(id){
+ let param = {
+ id:id
+ }
+ this.$confirm('确定删除采购单?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }).then(() => {
+ axios.post("/hotel.php/receipt_order/delAll", param).then((response) => {
+ let data = response.data;
+ if (data.flag) {
+ this.$message({
+ message: '移除成功!',
+ type: 'success'
+ });
+ this.getData(this.search.pageNum)
+ } else {
+ this.$message.error(response.msg);
+ }
+ }).catch(function (error) {
+ console.log(error);
+ });
+ }).catch(() => {
+ this.$message({
+ type: 'info',
+ message: '已取消'
+ });
+ });
}
}
@@ -501,5 +587,8 @@
margin-top: 12px;
background-color: white;
}
+ .el-form-item{
+ margin-bottom: 5px !important;
+ }