From 54dc61fe4b94f119ef0721b03713247b24da5a2b Mon Sep 17 00:00:00 2001
From: lemon <15040771@qq.com>
Date: Fri, 24 Sep 2021 19:48:21 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=BA=A2=E7=82=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Admin/Controllers/ProductController.php | 15 ++++
app/Admin/bootstrap.php | 2 +
app/Admin/routes.php | 2 +
public/js/product.js | 84 +++++++++++++++++++++
4 files changed, 103 insertions(+)
create mode 100755 public/js/product.js
diff --git a/app/Admin/Controllers/ProductController.php b/app/Admin/Controllers/ProductController.php
index c03d528..2fd83d6 100644
--- a/app/Admin/Controllers/ProductController.php
+++ b/app/Admin/Controllers/ProductController.php
@@ -151,4 +151,19 @@ class ProductController extends AdminController
}
});
}
+
+ public function audit()
+ {
+ $cloud = \App\Models\Product::query()->where('status',ProductStatus::UNAUDITED)->count();
+ $industry = \App\Models\IndustryProduct::query()->where('status',ProductStatus::UNAUDITED)->count();
+ $demand = \App\Models\DemandProduct::query()->where('status',ProductStatus::UNAUDITED)->count();
+ $total = $cloud + $industry + $demand;
+ $arr = [
+ 'cloud' => $cloud ?? 0,
+ 'industry' => $industry ?? 0,
+ 'demand' => $demand ?? 0,
+ 'total' => $total ?? 0,
+ ];
+ return json_encode($arr);
+ }
}
diff --git a/app/Admin/bootstrap.php b/app/Admin/bootstrap.php
index 4f4db16..4a27b86 100644
--- a/app/Admin/bootstrap.php
+++ b/app/Admin/bootstrap.php
@@ -25,3 +25,5 @@ use Dcat\Admin\Show;
*
*/
app('view')->prependNamespace('admin', resource_path('views/admin'));
+
+Admin::js('/js/product.js');
diff --git a/app/Admin/routes.php b/app/Admin/routes.php
index 186a57c..07b275f 100644
--- a/app/Admin/routes.php
+++ b/app/Admin/routes.php
@@ -50,4 +50,6 @@ Route::group([
$router->resource('system', 'SystemSettingController');
$router->resource('deposit', 'DepositController');
$router->resource('setting_single', 'ServicePersonsSettingController');
+
+ $router->any('product_audit','ProductController@audit');
});
diff --git a/public/js/product.js b/public/js/product.js
new file mode 100755
index 0000000..f9cfdd6
--- /dev/null
+++ b/public/js/product.js
@@ -0,0 +1,84 @@
+function workorderNotice()
+{
+ $('.product_badge').remove();
+ $.ajax({
+ url: '/'+window.location.pathname.split('/')[1]+'/product_audit',
+ type: 'POST',
+ data: {},
+ dataType: 'json',
+ success: function (res) {
+
+ let total = res.total ? res.total : '';
+ let cloud = res.cloud ? res.cloud : '';
+ let industry = res.industry ? res.industry : '';
+ let demand = res.demand ? res.demand : '';
+ if (total > 0) {
+ $('a[href*="product/audit"] p').parent().parent().parent().parent().parent().parent().children("a").append(''+total+'');
+ }
+
+
+ if (cloud > 0) {
+ $('a[href*="product/audit"] p').parent().parent().parent().parent().parent().parent().children("ul").children(":first-child").children("ul").children("li:eq(1)").children(":first-child").append(''+cloud+'');
+ }
+
+ if (industry > 0) {
+ $('a[href*="product/audit"] p').parent().parent().parent().parent().parent().parent().children("ul").children(":eq(1)").children("ul").children("li:eq(1)").children(":first-child").append(''+industry+'');
+ }
+
+ if (demand > 0) {
+ $('a[href*="product/audit"] p').parent().parent().parent().parent().parent().parent().children("ul").children(":eq(2)").children(':first-child').append(''+demand+'');
+ }
+ },
+ error: function (error) {
+
+ }
+ });
+}
+
+$(document).ready(function () {
+ workorderNotice();
+});
+
+// const workordertimer = setInterval(function () {
+// workorderNotice()
+// }, 5000);