From 6f3314f92cee0f1e2a0e70c2c14faf7cd51231b0 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 6 Dec 2023 10:26:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=A7=E5=93=81=E7=BB=91?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/views/product/edit.vue | 1 - app/adminapi/logic/land/ProductLogic.php | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/admin/src/views/product/edit.vue b/admin/src/views/product/edit.vue index 8c4e9d17..f4554c43 100644 --- a/admin/src/views/product/edit.vue +++ b/admin/src/views/product/edit.vue @@ -153,7 +153,6 @@ const queryUser = async (query: string) => { } const selectedUser = (value: any) => { - console.log(value) queryLand(value) } diff --git a/app/adminapi/logic/land/ProductLogic.php b/app/adminapi/logic/land/ProductLogic.php index bec1ea07..9503cd01 100644 --- a/app/adminapi/logic/land/ProductLogic.php +++ b/app/adminapi/logic/land/ProductLogic.php @@ -38,12 +38,21 @@ class ProductLogic extends BaseLogic */ public static function add(array $params): bool { + $root = (request()->adminInfo)['root']; $userId = (request()->adminInfo)['user_id']; $status = 1; + if ($root && !empty($params['user_id'])) { + $userId = $params['user_id']; + } if (!empty($params['land_id'])) { - $userId = Db::name('land')->where('id', $params['land_id'])->value('user_id'); + $res = Db::name('land_product')->where('land_id', $params['land_id'])->find(); + if ($res) { + self::setError('该土地已绑定产品'); + return false; + } $status = 2; } + Db::startTrans(); try { $product = Product::create([ @@ -79,10 +88,18 @@ class ProductLogic extends BaseLogic */ public static function edit(array $params): bool { + $root = (request()->adminInfo)['root']; $userId = (request()->adminInfo)['user_id']; $status = 1; + if ($root && !empty($params['user_id'])) { + $userId = $params['user_id']; + } if (!empty($params['land_id'])) { - $userId = Db::name('land')->where('id', $params['land_id'])->value('user_id'); + $res = Db::name('land_product')->where('land_id', $params['land_id'])->where('product_id', '<>' ,$params['id'])->find(); + if ($res) { + self::setError('该土地已绑定产品'); + return false; + } $status = 2; } Db::startTrans();