|
|
@@ -249,15 +249,51 @@ class Judge extends Backend
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 删除 判断标准数据和子项目
|
|
|
+ * 软删除 判断标准数据
|
|
|
*/
|
|
|
-// public function del($ids = null){
|
|
|
-// $id = $this->request->post('ids');
|
|
|
-// $item_judge = Db::name('item_judge')->where('id',$id)->delete();
|
|
|
-// $item_judge_detail = Db::name('item_judge_detail')->where('pid',$item_judge['id'])->select();
|
|
|
-// foreach ($item_judge_detail as $k => $v){
|
|
|
-// Db::name('item_judge_detail')->where('pid',$item_judge['id'])->delete($v['id']);
|
|
|
-// }
|
|
|
+ public function del($ids = null){
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
+ $this->error(__("Invalid parameters"));
|
|
|
+ }
|
|
|
+ $ids = $ids ?: $this->request->post("ids");
|
|
|
+ if (empty($ids)) {
|
|
|
+ $this->error(__('Parameter %s can not be empty', 'ids'));
|
|
|
+ }
|
|
|
+ $result = true;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ $id = explode(',', $ids);
|
|
|
+ $item_judge = \app\admin\model\item\Judge::destroy($id);
|
|
|
+ if (!$item_judge){
|
|
|
+ $result = false;
|
|
|
+ }
|
|
|
+ $data =Db::name('item_judge_detail')
|
|
|
+ ->whereIn('pid',$id)
|
|
|
+ ->update(['deletetime'=>date('Y-m-d H:i:s')]);
|
|
|
+ if (!$data){
|
|
|
+ $result = false;
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if (false === $result) {
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 回收站
|
|
|
+ */
|
|
|
+// public function restore($ids = null){
|
|
|
+// $item_judge = Db::name('item_judge')->select();
|
|
|
+// echo "<pre>";
|
|
|
+// print_r($item_judge);
|
|
|
+// echo "</pre>";
|
|
|
+// return $this->view->fetch();
|
|
|
// }
|
|
|
|
|
|
}
|