diff --git a/app/adminapi/logic/supervision_work/SupervisionAcceptLogic.php b/app/adminapi/logic/supervision_work/SupervisionAcceptLogic.php index 9ae2570ca..a93eb654a 100644 --- a/app/adminapi/logic/supervision_work/SupervisionAcceptLogic.php +++ b/app/adminapi/logic/supervision_work/SupervisionAcceptLogic.php @@ -104,6 +104,7 @@ class SupervisionAcceptLogic extends BaseLogic */ public static function edit(array $params,$admin_id): bool { + $data = SupervisionAccept::field('check_item_detail_ids')->where('id',$params['id'])->findOrEmpty(); Db::startTrans(); try { SupervisionAccept::where('id', $params['id'])->update([ @@ -120,6 +121,10 @@ class SupervisionAcceptLogic extends BaseLogic 'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'update_time' => time(), ]); + if(json_encode($data['check_item_detail_ids']) != json_encode($params['check_item_detail_ids'])){ + $accept_check_result_result_ids = SupervisionAcceptResult::where('accept_id',$params['id'])->column('id'); + SupervisionAcceptResult::destroy($accept_check_result_result_ids); + } if(!empty($params['accept_check_result'])){ foreach($params['accept_check_result'] as $v){ if(!empty($v['id'])){ diff --git a/app/adminapi/logic/supervision_work/SupervisionSideStationLogic.php b/app/adminapi/logic/supervision_work/SupervisionSideStationLogic.php index 199ded7f6..32c860aeb 100644 --- a/app/adminapi/logic/supervision_work/SupervisionSideStationLogic.php +++ b/app/adminapi/logic/supervision_work/SupervisionSideStationLogic.php @@ -106,6 +106,7 @@ class SupervisionSideStationLogic extends BaseLogic */ public static function edit(array $params,$admin_id): bool { + $data = SupervisionSideStation::field('check_item_detail_ids')->where('id',$params['id'])->findOrEmpty(); Db::startTrans(); try { SupervisionSideStation::where('id', $params['id'])->update([ @@ -125,6 +126,10 @@ class SupervisionSideStationLogic extends BaseLogic 'annex' => $params['annex'] ? json_encode($params['annex']) : null, 'update_time' => time(), ]); + if(json_encode($data['check_item_detail_ids']) != json_encode($params['check_item_detail_ids'])){ + $side_result_ids = SupervisionSideStationResult::where('side_station_id',$params['id'])->column('id'); + SupervisionSideStationResult::destroy($side_result_ids); + } if(!empty($params['side_result'])){ foreach($params['side_result'] as $v){ if(!empty($v['id'])){