dongasai 8 months ago
commit
6640efd73b
100 changed files with 5345 additions and 0 deletions
  1. 11 0
      .clinerules-code
  2. 22 0
      .cursor/rules/php.mdc
  3. 3 0
      .cursorignore
  4. 18 0
      .editorconfig
  5. 67 0
      .env.example
  6. 11 0
      .gitattributes
  7. 24 0
      .gitignore
  8. 3 0
      .roo/mcp.json
  9. 43 0
      .roo/rules-code/rules.md
  10. 0 0
      .roo/system-prompt-code
  11. 8 0
      .roomodes
  12. 0 0
      .roorules-boomerang-mode
  13. 2 0
      .roorules-code
  14. 93 0
      Dockerfile
  15. 80 0
      DockerfileDev
  16. 66 0
      README.md
  17. 37 0
      UCore/Command/Command.php
  18. 18 0
      UCore/Command/CommandFace.php
  19. 57 0
      UCore/Command/CommandSecond.php
  20. 17 0
      UCore/Command/CommandSecondFace.php
  21. 22 0
      UCore/Command/CommandTrait.php
  22. 56 0
      UCore/Commands/BuildInfo.php
  23. 16 0
      UCore/Commands/ExampleCommand.php
  24. 228 0
      UCore/Commands/GenerateModelAnnotation.php
  25. 129 0
      UCore/Db/Arr.php
  26. 24 0
      UCore/Db/Helper.php
  27. 57 0
      UCore/Db/Query.php
  28. 16 0
      UCore/DcatAdmin/ActionLog/ActionForm.php
  29. 41 0
      UCore/DcatAdmin/ActionLog/BaseLog.php
  30. 14 0
      UCore/DcatAdmin/ActionLog/Create.php
  31. 14 0
      UCore/DcatAdmin/ActionLog/Edit.php
  32. 36 0
      UCore/DcatAdmin/ActionLog/Exporter.php
  33. 9 0
      UCore/DcatAdmin/ActionLog/InterfaceLog.php
  34. 11 0
      UCore/DcatAdmin/Actions/Action.php
  35. 14 0
      UCore/DcatAdmin/AdminController.php
  36. 228 0
      UCore/DcatAdmin/FilterHelper.php
  37. 23 0
      UCore/DcatAdmin/Form/AbstractTool.php
  38. 309 0
      UCore/DcatAdmin/FormHelper.php
  39. 14 0
      UCore/DcatAdmin/Grid/Actions/Edit.php
  40. 11 0
      UCore/DcatAdmin/Grid/BatchAction.php
  41. 76 0
      UCore/DcatAdmin/Grid/Displayers/LabelCall.php
  42. 58 0
      UCore/DcatAdmin/Grid/Displayers/LineActions.php
  43. 45 0
      UCore/DcatAdmin/Grid/Exporters/ExcelExporter.php
  44. 12 0
      UCore/DcatAdmin/Grid/LazyRenderable.php
  45. 17 0
      UCore/DcatAdmin/Grid/Tool/HrefAbstractTool.php
  46. 82 0
      UCore/DcatAdmin/Grid/Views/GridHeader.php
  47. 35 0
      UCore/DcatAdmin/Grid/Views/GridHeaderButtonEdit.php
  48. 67 0
      UCore/DcatAdmin/Grid/Views/GridHeaderButtonPrivate.php
  49. 36 0
      UCore/DcatAdmin/Grid/Views/GridHeaderButtonPublic.php
  50. 44 0
      UCore/DcatAdmin/Grid/Views/GridHeaderButtonSave.php
  51. 46 0
      UCore/DcatAdmin/Grid/Views/GridHeaderButtonUpdate2.php
  52. 4 0
      UCore/DcatAdmin/Grid/Views/readme.md
  53. 301 0
      UCore/DcatAdmin/GridHelper.php
  54. 8 0
      UCore/DcatAdmin/Herlper.php
  55. 15 0
      UCore/DcatAdmin/Layout/ContentFb.php
  56. 35 0
      UCore/DcatAdmin/Metrics/Box.php
  57. 13 0
      UCore/DcatAdmin/Metrics/Dump.php
  58. 167 0
      UCore/DcatAdmin/Metrics/Examples/DataBar.php
  59. BIN
      UCore/DcatAdmin/Metrics/Examples/DataBar.png
  60. 92 0
      UCore/DcatAdmin/Metrics/Examples/DataLabel.php
  61. BIN
      UCore/DcatAdmin/Metrics/Examples/DataLabel.png
  62. 87 0
      UCore/DcatAdmin/Metrics/Examples/DataLabel2.php
  63. BIN
      UCore/DcatAdmin/Metrics/Examples/DataLabel2.png
  64. 109 0
      UCore/DcatAdmin/Metrics/Examples/DataNumber.php
  65. BIN
      UCore/DcatAdmin/Metrics/Examples/DataNumber.png
  66. 47 0
      UCore/DcatAdmin/Metrics/Examples/Link.php
  67. 96 0
      UCore/DcatAdmin/Metrics/Examples/ListDataColor.php
  68. 100 0
      UCore/DcatAdmin/Metrics/Examples/NewDevices.php
  69. 108 0
      UCore/DcatAdmin/Metrics/Examples/NewUsers.php
  70. 67 0
      UCore/DcatAdmin/Metrics/Examples/Number.php
  71. 66 0
      UCore/DcatAdmin/Metrics/Examples/Number1.php
  72. 70 0
      UCore/DcatAdmin/Metrics/Examples/NumberS.php
  73. BIN
      UCore/DcatAdmin/Metrics/Examples/NumberS.png
  74. 71 0
      UCore/DcatAdmin/Metrics/Examples/NumberS2.php
  75. BIN
      UCore/DcatAdmin/Metrics/Examples/NumberS2.png
  76. 114 0
      UCore/DcatAdmin/Metrics/Examples/ProductOrders.php
  77. 152 0
      UCore/DcatAdmin/Metrics/Examples/Ranking.php
  78. BIN
      UCore/DcatAdmin/Metrics/Examples/Ranking.png
  79. 64 0
      UCore/DcatAdmin/Metrics/Examples/Reload.php
  80. 12 0
      UCore/DcatAdmin/Metrics/Examples/Round.php
  81. BIN
      UCore/DcatAdmin/Metrics/Examples/Round.png
  82. 117 0
      UCore/DcatAdmin/Metrics/Examples/Sessions.php
  83. 116 0
      UCore/DcatAdmin/Metrics/Examples/Tickets.php
  84. BIN
      UCore/DcatAdmin/Metrics/Examples/Tickets.png
  85. 129 0
      UCore/DcatAdmin/Metrics/Examples/TotalUsers.php
  86. 207 0
      UCore/DcatAdmin/Metrics/Examples/TreeMap.php
  87. 85 0
      UCore/DcatAdmin/Metrics/Examples/WaitGo.php
  88. BIN
      UCore/DcatAdmin/Metrics/Examples/img.png
  89. BIN
      UCore/DcatAdmin/Metrics/Examples/img_1.png
  90. 41 0
      UCore/DcatAdmin/Metrics/Examples/readme.md
  91. 35 0
      UCore/DcatAdmin/Metrics/Examples/treemap.json
  92. 37 0
      UCore/DcatAdmin/Metrics/Image.php
  93. 19 0
      UCore/DcatAdmin/Metrics/Sys/JobDui.php
  94. 98 0
      UCore/DcatAdmin/Metrics/Sys/JobDuiChart.php
  95. 99 0
      UCore/DcatAdmin/Metrics/Sys/JobRun.php
  96. 20 0
      UCore/DcatAdmin/Metrics/Sys/JobS3.php
  97. 22 0
      UCore/DcatAdmin/Metrics/Sys/JobS3Jin.php
  98. 22 0
      UCore/DcatAdmin/Metrics/Sys/JobS3Run.php
  99. 113 0
      UCore/DcatAdmin/Metrics/User/NewUsers.php
  100. 17 0
      UCore/DcatAdmin/Metrics/User/Online.php

+ 11 - 0
.clinerules-code

@@ -0,0 +1,11 @@
+你是一名Laravel工程师
+
+- `php artisan thinker`禁止使用
+- `php artisan migrate`禁止使用
+- `php artisan migrate:*`禁止使用
+- 数据库的结构变化不采用迁移文件,数据库的结构变化需要人工执行,提供SQL
+- 不使用 migrate
+- `php artisan db:table 表名`来查看表结构
+- 模块化开发,单元测试要写在模块中,单元测试备注测试内容
+- 单元测试,不使用RefreshDatabase/DatabaseTransactions来处理数据库,不处理测试数据,允许了测试数据留存
+- 不要质疑数据库配置错误

+ 22 - 0
.cursor/rules/php.mdc

@@ -0,0 +1,22 @@
+---
+description: 
+globs: 
+alwaysApply: true
+---
+
+# 其他规则
+- `php artisan thinker`禁止使用
+- `php artisan migrate`禁止使用
+- `php artisan migrate:*`禁止使用
+- 数据库配置是正确的,不要质疑
+- 数据库的结构变化不采用迁移文件,数据库的结构变化需要人工执行,提供SQL
+- 不使用 migrate,不使用 Migration
+- `php artisan db:table 表名`来查看表结构
+- 模块化开发,所有内容都要在模块文件夹内(Handler除外);单元测试要写在模块中,单元测试备注测试内容
+- 单元测试,不使用RefreshDatabase/DatabaseTransactions来处理数据库,不处理测试数据,允许了测试数据留存
+- `Repository`是给后台用的,非后台操作不使用
+- 不要臆测一个文件的存在,使用前进行查证,后使用
+- 工作前,查看环境,了解已有内容(阅读整个模块的现有文件列表,阅读需要了解的文件全文),可用内容,需要补充内容
+- 不要臆想内容,先查证,后使用
+- 遇到不好判断的内容,向用户发起提问,多向用户沟通
+- 验证每一个要用到的类的存在和内容

+ 3 - 0
.cursorignore

@@ -0,0 +1,3 @@
+# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
+
+*.noai.md

+ 18 - 0
.editorconfig

@@ -0,0 +1,18 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.{yml,yaml}]
+indent_size = 2
+
+[docker-compose.yml]
+indent_size = 4

+ 67 - 0
.env.example

@@ -0,0 +1,67 @@
+APP_NAME=Laravel
+APP_ENV=local
+APP_KEY=
+APP_DEBUG=true
+APP_TIMEZONE=UTC
+APP_URL=http://localhost
+UNITTEST_URL=http://localhost:8000
+
+APP_LOCALE=en
+APP_FALLBACK_LOCALE=en
+APP_FAKER_LOCALE=en_US
+
+APP_MAINTENANCE_DRIVER=file
+# APP_MAINTENANCE_STORE=database
+
+PHP_CLI_SERVER_WORKERS=4
+
+BCRYPT_ROUNDS=12
+
+LOG_CHANNEL=stack
+LOG_STACK=single
+LOG_DEPRECATIONS_CHANNEL=null
+LOG_LEVEL=debug
+
+DB_CONNECTION=sqlite
+# DB_HOST=127.0.0.1
+# DB_PORT=3306
+# DB_DATABASE=laravel
+# DB_USERNAME=root
+# DB_PASSWORD=
+
+SESSION_DRIVER=database
+SESSION_LIFETIME=120
+SESSION_ENCRYPT=false
+SESSION_PATH=/
+SESSION_DOMAIN=null
+
+BROADCAST_CONNECTION=log
+FILESYSTEM_DISK=local
+QUEUE_CONNECTION=database
+
+CACHE_STORE=database
+CACHE_PREFIX=
+
+MEMCACHED_HOST=127.0.0.1
+
+REDIS_CLIENT=phpredis
+REDIS_HOST=127.0.0.1
+REDIS_PASSWORD=null
+REDIS_PORT=6379
+
+MAIL_MAILER=log
+MAIL_SCHEME=null
+MAIL_HOST=127.0.0.1
+MAIL_PORT=2525
+MAIL_USERNAME=null
+MAIL_PASSWORD=null
+MAIL_FROM_ADDRESS="hello@example.com"
+MAIL_FROM_NAME="${APP_NAME}"
+
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+AWS_DEFAULT_REGION=us-east-1
+AWS_BUCKET=
+AWS_USE_PATH_STYLE_ENDPOINT=false
+
+VITE_APP_NAME="${APP_NAME}"

+ 11 - 0
.gitattributes

@@ -0,0 +1,11 @@
+* text=auto eol=lf
+
+*.blade.php diff=html
+*.css diff=css
+*.html diff=html
+*.md diff=markdown
+*.php diff=php
+
+/.github export-ignore
+CHANGELOG.md export-ignore
+.styleci.yml export-ignore

+ 24 - 0
.gitignore

@@ -0,0 +1,24 @@
+/.phpunit.cache
+/node_modules
+/public/build
+/public/hot
+/public/storage
+/storage/*.key
+/storage/pail
+.env
+.env.backup
+.env.production
+.phpactor.json
+.phpunit.result.cache
+Homestead.json
+Homestead.yaml
+npm-debug.log
+yarn-error.log
+/auth.json
+/.fleet
+/.idea
+/.nova
+/.vscode
+/.zed
+/proto
+/shejitu

+ 3 - 0
.roo/mcp.json

@@ -0,0 +1,3 @@
+{
+  "mcpServers": {}
+}

+ 43 - 0
.roo/rules-code/rules.md

@@ -0,0 +1,43 @@
+# 开发流程
+1. 理解需求
+2. 阅读已有代码
+2. 提出开发方案,包含以下内容,逐条确认
+    - 在那个模块下进行开发
+    - 梳理基本基本思路
+    - 需要创建和修改的文件
+    - 没有明确需要测试,就不写测试
+3. 用户确认方案
+3. 进行开发
+
+# Handler的开发规则
+- 参考 app/ProtoLogic/Hello/AreYouOkHandler.php (读取最新内容)
+
+
+# 模块开发的规则
+- 模块在项目的app/Module目录下
+- 模块的规则可参考Test模块的README.md(读取最新内容)
+
+# Validation开发规则
+- 阅读文档 @/vendor/inhere/php-validate/README.md 了解Validation开发规则
+
+# 严格遵守的规则
+- 任何操作(增加,删除,修改,执行)执行前都要验证该操作是否符合规则
+- 不要用你以为来进行判断,多阅读现有代码,每涉及一个新类都要去阅读代码了解它
+
+# 其他规则
+- `php artisan thinker`禁止使用
+- `php artisan migrate`禁止使用
+- `php artisan migrate:*`禁止使用
+- 数据库配置是正确的,不要质疑
+- 数据库的结构变化不采用迁移文件,数据库的结构变化需要人工执行,提供SQL
+- 不使用 migrate,不使用 Migration
+- `php artisan db:table 表名`来查看表结构
+- 模块化开发,所有内容都要在模块文件夹内(Handler除外);单元测试要写在模块中,单元测试备注测试内容
+- 单元测试,不使用RefreshDatabase/DatabaseTransactions来处理数据库,不处理测试数据,允许了测试数据留存
+- `Repository`是给后台用的,非后台操作不使用
+- 不要臆测一个文件的存在,使用前进行查证,后使用
+- 工作前,查看环境,了解已有内容(阅读整个模块的现有文件列表,阅读需要了解的文件全文),可用内容,需要补充内容
+- 不要臆想内容,先查证,后使用
+- 遇到不好判断的内容,向用户发起提问,多向用户沟通
+- 验证每一个要用到的类的存在和内容
+- 阅读每一个涉及的类,以了解内容,不要揣测内容

+ 0 - 0
.roo/system-prompt-code


File diff suppressed because it is too large
+ 8 - 0
.roomodes


+ 0 - 0
.roorules-boomerang-mode


+ 2 - 0
.roorules-code

@@ -0,0 +1,2 @@
+- proto文件注意拆分,防止大文件产生
+- 使用phpunit来运行测试

+ 93 - 0
Dockerfile

@@ -0,0 +1,93 @@
+
+FROM docker.m.daocloud.io/php:8.3-apache
+
+ENV REFRESH_DATE=9
+COPY sources.list /etc/apt/sources.list
+RUN rm /etc/apt/sources.list.d/debian.sources
+
+RUN apt-get clean &&  apt-get update
+RUN apt-get install -y wget zip libzip-dev zlib1g-dev autoconf automake libtool vim git iputils-ping
+
+
+WORKDIR /home
+# 安装 oniguruma
+ENV ORIGURUMA_VERSION=6.9.8
+
+RUN wget https://github.com/kkos/oniguruma/archive/v${ORIGURUMA_VERSION}.tar.gz -O oniguruma-${ORIGURUMA_VERSION}.tar.gz \
+    && tar -zxvf oniguruma-${ORIGURUMA_VERSION}.tar.gz \
+    && cd oniguruma-${ORIGURUMA_VERSION} \
+    && ./autogen.sh \
+    && ./configure \
+    && make \
+    && make install
+
+# 安装必要的扩展
+RUN docker-php-ext-install bcmath mbstring zip pdo_mysql
+RUN pecl install redis \
+    && docker-php-ext-enable redis
+
+# protobuf
+RUN pecl install protobuf && docker-php-ext-enable  protobuf
+
+
+# 安装 protoc
+ENV PRPTOTBUF_VERSION=29.1
+RUN wget "https://github.com/protocolbuffers/protobuf/releases/download/v${PRPTOTBUF_VERSION}/protoc-${PRPTOTBUF_VERSION}-linux-x86_64.zip" && \
+     unzip protoc-${PRPTOTBUF_VERSION}-linux-x86_64.zip && ls && cp bin/protoc /usr/bin/ && \
+ protoc --version
+
+
+RUN apt-get install -y zlib1g-dev libz-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
+        && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/  && \
+    docker-php-ext-install gd &&  docker-php-ext-enable  gd
+
+
+# 安装 imagick
+RUN apt-get install -y libmagickwand-dev && pecl install imagick && docker-php-ext-enable  imagick
+
+
+# 加速器
+RUN docker-php-ext-install opcache &&  docker-php-ext-enable  opcache
+
+# 安装composer
+RUN wget https://mirrors.aliyun.com/composer/composer.phar \
+	&& mv composer.phar /usr/local/bin/composer \
+	&& chmod +x /usr/local/bin/composer && composer config -g repo.packagist composer https://packagist.pages.dev/
+RUN a2enmod rewrite;
+
+
+
+# dot 的安装,用于输出workflow
+RUN apt install -y graphviz
+#RUN useradd php
+COPY default.conf /etc/apache2/sites-enabled/000-default.conf
+# RUN mkdir /home/php && chown php /home/php
+# COPY php.ini /usr/local/etc/php/conf.d
+
+WORKDIR /var/www/html
+
+COPY . /var/www/html
+
+RUN chmod 777 -R storage
+# /var/www/html/storage
+# mkdir -p storage/framework/views
+# mkdir -p storage/framework/testing
+# mkdir -p storage/framework/sessions
+# mkdir -p storage/framework/cache
+# mkdir -p storage/app/public
+RUN chmod 777 -R bootstrap
+RUN chown www-data:www-data -R config
+
+# lan 扩展集合  opcache  gd redis bcmath mbstring zip pdo_mysql
+
+USER www-data
+# RUN composer install
+
+WORKDIR /var/www/html
+RUN php artisan  docker:buildinfo
+USER root
+
+
+#RUN sed -i 's/^exec /service cron start \n\n exec /' /usr/local/bin/apache2-foreground
+
+

+ 80 - 0
DockerfileDev

@@ -0,0 +1,80 @@
+
+FROM docker.m.daocloud.io/php:8.3-apache
+
+ENV REFRESH_DATE=9
+COPY sources.list /etc/apt/sources.list
+RUN rm /etc/apt/sources.list.d/debian.sources
+RUN apt-get clean &&  apt-get update
+RUN apt-get install -y wget zip libzip-dev zlib1g-dev autoconf automake libtool vim git iputils-ping libgmp-dev
+# dot 的安装,用于输出workflow
+RUN apt install -y graphviz
+# 安装gd的
+RUN apt-get install -y zlib1g-dev libz-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev
+WORKDIR /home
+# 安装 oniguruma
+ENV ORIGURUMA_VERSION=6.9.8
+
+RUN wget https://github.com/kkos/oniguruma/archive/v${ORIGURUMA_VERSION}.tar.gz -O oniguruma-${ORIGURUMA_VERSION}.tar.gz \
+    && tar -zxvf oniguruma-${ORIGURUMA_VERSION}.tar.gz \
+    && cd oniguruma-${ORIGURUMA_VERSION} \
+    && ./autogen.sh \
+    && ./configure \
+    && make \
+    && make install
+
+# 安装必要的扩展
+RUN docker-php-ext-install bcmath mbstring zip pdo_mysql gmp
+RUN pecl install redis \
+    && docker-php-ext-enable redis
+
+# protobuf
+RUN pecl install protobuf && docker-php-ext-enable  protobuf
+
+
+# 安装gd
+RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/  && \
+    docker-php-ext-install gd &&  docker-php-ext-enable  gd
+
+
+# 安装 imagick
+# RUN apt-get install -y libmagickwand-dev && pecl install imagick && docker-php-ext-enable  imagick
+
+# 安装composer
+RUN wget https://mirrors.aliyun.com/composer/composer.phar \
+	&& mv composer.phar /usr/local/bin/composer \
+	&& chmod +x /usr/local/bin/composer && composer config -g repo.packagist composer https://packagist.pages.dev/
+RUN a2enmod rewrite;
+
+
+# xdebug
+#RUN pecl install xdebug && docker-php-ext-enable  xdebug
+
+# 安装 protoc
+ENV PRPTOTBUF_VERSION=21.10
+RUN wget "https://github.com/protocolbuffers/protobuf/releases/download/v${PRPTOTBUF_VERSION}/protoc-${PRPTOTBUF_VERSION}-linux-x86_64.zip" && \
+     unzip protoc-${PRPTOTBUF_VERSION}-linux-x86_64.zip && ls && cp bin/protoc /usr/bin/ && \
+ protoc --version
+#RUN useradd php
+COPY default.conf /etc/apache2/sites-enabled/000-default.conf
+# RUN mkdir /home/php && chown php /home/php
+# COPY php.ini /usr/local/etc/php/conf.d
+
+WORKDIR /var/www/html
+
+COPY . /var/www/html
+
+# RUN chmod 777 -R storage
+# RUN chmod 777 -R bootstrap
+
+EXPOSE 9000
+
+#USER www-data
+# RUN composer install
+
+WORKDIR /var/www/html
+#RUN php artisan  docker:buildinfo
+
+
+#RUN sed -i 's/^exec /service cron start \n\n exec /' /usr/local/bin/apache2-foreground
+
+

+ 66 - 0
README.md

@@ -0,0 +1,66 @@
+<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
+
+<p align="center">
+<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
+</p>
+
+## About Laravel
+
+Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
+
+- [Simple, fast routing engine](https://laravel.com/docs/routing).
+- [Powerful dependency injection container](https://laravel.com/docs/container).
+- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
+- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
+- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
+- [Robust background job processing](https://laravel.com/docs/queues).
+- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
+
+Laravel is accessible, powerful, and provides tools required for large, robust applications.
+
+## Learning Laravel
+
+Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
+
+You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
+
+If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
+
+## Laravel Sponsors
+
+We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
+
+### Premium Partners
+
+- **[Vehikl](https://vehikl.com/)**
+- **[Tighten Co.](https://tighten.co)**
+- **[WebReinvent](https://webreinvent.com/)**
+- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
+- **[64 Robots](https://64robots.com)**
+- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
+- **[Cyber-Duck](https://cyber-duck.co.uk)**
+- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
+- **[Jump24](https://jump24.co.uk)**
+- **[Redberry](https://redberry.international/laravel/)**
+- **[Active Logic](https://activelogic.com)**
+- **[byte5](https://byte5.de)**
+- **[OP.GG](https://op.gg)**
+
+## Contributing
+
+Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
+
+## Code of Conduct
+
+In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
+
+## Security Vulnerabilities
+
+If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
+
+## License
+
+The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

+ 37 - 0
UCore/Command/Command.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace UCore\Command;
+
+
+use UCore\Queue\Helper;
+
+/**
+ * 命令基类
+ */
+abstract class Command extends \Illuminate\Console\Command implements CommandFace
+{
+
+    use CommandTrait;
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        Helper::add_log('run', 'Console', static::class, []);
+        $start = microtime(true);
+        try {
+            $this->handleRun();
+        } catch (\Exception $exception) {
+            $this->callException($exception);
+            $this->output->error($exception->getMessage());
+        }
+        $diff = microtime(true) - $start;
+        Helper::add_log('run-end', 'Console', static::class, [
+            'runtime' => $diff
+        ],              '', $diff);
+    }
+
+}

+ 18 - 0
UCore/Command/CommandFace.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace UCore\Command;
+
+/**
+ * 命令接口
+ *
+ * 定义命令执行的基本方法
+ */
+interface CommandFace
+{
+    /**
+     * 执行命令的具体逻辑
+     *
+     * @return void
+     */
+    public function handleRun();
+}

+ 57 - 0
UCore/Command/CommandSecond.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace UCore\Command;
+
+use UCore\Helper\Logger;
+use UCore\Helper\Helper;
+use Illuminate\Console\Command;
+
+/**
+ * 按秒执行的命令基类
+ */
+abstract class CommandSecond extends Command implements CommandSecondFace
+{
+    /**
+     * 等待秒数(最后几秒不执行)
+     * @var int $waitSecond
+     */
+    protected $waitSecond = 2;
+
+    /**
+     * 间隔时长
+     * @var int $sleepSecond
+     */
+    protected $sleepSecond = 1;
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        Helper::add_log('run-s' , 'Console', static::class, []);
+
+        foreach (range(1, 60) as $a) {
+            $s = date('s');
+            if ($s >= (60-$this->waitSecond)) {
+                // 最后几秒 不执行
+                break;
+            }
+            try {
+                $this->handleSecond($s);
+            } catch (\Exception $exception) {
+                Logger::exception('CommandSecond'.static::class,$exception);
+                echo $exception->getMessage();
+                echo $exception->getTraceAsString();
+            }
+            sleep($this->sleepSecond);
+        }
+        Helper::add_log('run-s-end' , 'Console', static::class, []);
+
+
+        return Command::SUCCESS;
+    }
+
+
+}

+ 17 - 0
UCore/Command/CommandSecondFace.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace UCore\Command;
+
+/**
+ * 按秒执行的命令接口
+ */
+interface CommandSecondFace
+{
+    /**
+     * 每秒执行的具体逻辑
+     *
+     * @param int $s 当前秒数
+     * @return void
+     */
+    public function handleSecond($s);
+}

+ 22 - 0
UCore/Command/CommandTrait.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace UCore\Command;
+
+use UCore\Helper\Logger;
+
+/**
+ * 命令公共特性
+ */
+trait CommandTrait
+{
+    /**
+     * 处理命令执行过程中的异常
+     *
+     * @param \Exception $exception 捕获到的异常
+     * @return void
+     */
+    public function callException(\Exception $exception)
+    {
+        Logger::exception('error', $exception);
+    }
+}

+ 56 - 0
UCore/Commands/BuildInfo.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace UCore\Commands;
+
+use App\Models\Bt;
+use Illuminate\Console\Command;
+
+/**
+ * 生成打包信息
+ *
+ * php artisan  docker:buildinfo
+ */
+class BuildInfo extends Command
+{
+
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'docker:buildinfo';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '生成打包信息';
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        $config_build = base_path('config/build.php');
+        $systemInfo = php_uname();
+        $SERVER_SOFTWARE = $_SERVER['SERVER_SOFTWARE']??'';
+        $envos = getenv('OS');
+        $unamea = exec('uname -a');
+
+        $build = [
+            'time'       => time(),
+            'systemInfo' => $systemInfo,
+            'SERVER_SOFTWARE' => $SERVER_SOFTWARE,
+            'envos' => $envos,
+            'unamea' => $unamea,
+        ];
+        $string       = var_export($build, true);
+        file_put_contents($config_build, "<?php \r\n return $string ;");
+
+        return Command::SUCCESS;
+    }
+
+}

+ 16 - 0
UCore/Commands/ExampleCommand.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace UCore\Commands;
+
+use Illuminate\Console\Command;
+
+class ExampleCommand extends Command
+{
+    protected $signature = 'ucore:example';
+    protected $description = 'UCore示例命令';
+
+    public function handle()
+    {
+        $this->info('UCore命令执行成功');
+    }
+}

+ 228 - 0
UCore/Commands/GenerateModelAnnotation.php

@@ -0,0 +1,228 @@
+<?php
+
+namespace UCore\Commands;
+
+use Illuminate\Console\Command;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\DB;
+use UCore\ModelCore;
+
+/**
+ * 自动生成Eloquent模型属性注释
+ *
+ * 通过分析数据库表结构,自动生成模型属性的PHPDoc注释,
+ * 并提供fillable字段自动维护功能。
+ *
+ * 功能特性:
+ * 1. 自动识别字段类型并生成对应@property注释
+ * 2. 特殊时间字段自动识别为Carbon类型
+ * 3. 自动维护模型$attrlist属性包含所有字段
+ *
+ * 使用说明:
+ * 1. 在模型中添加标记注释:
+ *    - 属性注释区域标记:在模型文件中添加  field start  和  field end  注释块
+ *    - fillable字段标记:在模型文件中添加  attrlist start  和  attrlist end  注释块
+ *
+ * @package UCore\Commands
+
+ * @example php artisan ucore:generate-model-annotation
+ */
+class GenerateModelAnnotation extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'ucore:generate-model-annotation';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '生成模型property注释,使得IDE有模型属性提示!';
+
+    private $fillable = [];
+
+    /**
+     * 主执行方法
+     *
+     * 扫描指定目录下的模型文件并生成注释
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        // 扫描核心模型目录
+        $this->call1(app_path('../ucore'), '\App\Models\\');
+
+        // 扫描模块下的Models目录
+        $modulesPath = app_path('Module');
+        if (is_dir($modulesPath)) {
+            $modules = scandir($modulesPath);
+            foreach ($modules as $module) {
+                if ($module === '.' || $module === '..') {
+                    continue;
+                }
+
+                $modelsDir = "$modulesPath/$module/Models";
+                if (is_dir($modelsDir)) {
+                    // 添加模块扫描日志
+                    $this->info("扫描模块目录: $modelsDir");
+                    // 修复模块命名空间格式
+                    $namespace = "App\\Module\\$module\\Models\\";
+                    // 统一目录分隔符
+                    $namespace = str_replace('/', '\\', $namespace);
+                    // 添加自动加载提示
+                    $this->warn("请确保已配置composer自动加载: \"App\\Module\\$module\\Models\\\": \"app/Module/$module/Models/\"");
+                    $this->call1($modelsDir, $namespace);
+                }
+            }
+        }
+    }
+
+    // ... 保持原有call1、call2、getAnnotation方法不变 ...
+    /**
+     * 扫描模型目录
+     *
+     * @param string $dir 模型文件目录路径
+     * @param string $ns 模型类命名空间
+     */
+    public function call1($dir, $ns)
+    {
+        $this->info("扫描目录: $dir");
+        $list = scandir($dir);
+        foreach ($list as $item) {
+            if ($item === '.' || $item === '..') {
+                continue;
+            }
+
+            $fullPath = $dir . '/' . $item;
+
+            // 递归处理子目录
+            if (is_dir($fullPath)) {
+                $this->call1($fullPath, $ns . $item . '\\');
+                continue;
+            }
+
+            $p = strpos($item, '.php');
+            if ($p !== false) {
+                $model = substr($item, 0, $p);
+                // 修复命名空间拼接逻辑
+                $modelClass = rtrim($ns, '\\') . '\\' . $model;
+                // 修复文件路径拼接
+                $file = $fullPath;
+                $this->call2($model, $modelClass, $file);
+            }
+        }
+    }
+
+    /**
+     * 处理单个模型文件
+     *
+     * @param string $model 模型类名
+     * @param string $modelClass 完整模型类名
+     * @param string $file 模型文件路径
+     */
+    public function call2($model,$modelClass,$file)
+    {
+        if(class_exists($modelClass)){
+            /**
+             * @var ModelCore $model
+             */
+            $model = new $modelClass();
+            if($model instanceof Model){
+                $co = $model->getConnection();
+                $tTablePrefix = $co->getTablePrefix();
+                $table =$tTablePrefix.$model->getTable();
+                $this->info("table $table ");
+
+                $annotation = $this->getAnnotation($table,$co);
+
+                $pattern = '/field start[\s\S]+field end/';
+                $replacement = "field start ".$annotation." * field end";
+                $string = file_get_contents($file);
+                $result = preg_replace($pattern, $replacement, $string);
+
+                // 过滤系统默认字段
+                $filteredFillable = array_filter($this->fillable, function($field) {
+                    return !in_array($field, ['created_at', 'updated_at', 'deleted_at']);
+                });
+
+                // 格式化数组输出
+                $fillableContent = "    protected \$fillable = [\n";
+                foreach ($filteredFillable as $field) {
+                    $fillableContent .= "        '{$field}',\n";
+                }
+                $fillableContent .= "    ];";
+
+                $pattern2 = '/attrlist start[\s\S]+attrlist end/';
+                $replacement2 = "attrlist start \n{$fillableContent}\n    // attrlist end";
+                $result = preg_replace($pattern2, $replacement2, $result);
+
+                if($result != $string){
+                    $this->output->info(" model $modelClass file :$file annotation 成功 ");
+                    file_put_contents($file,$result);
+                }else{
+                    $this->output->warning(" model $modelClass file :$file table $table - 没有标识符 ");
+                }
+            }else{
+                $this->output->warning(" model $modelClass 不是继承 ModelBase");
+            }
+        }else{
+            $this->output->warning(" model $model 不存在");
+        }
+    }
+
+    /**
+     * 生成属性注释字符串
+     *
+     * @param string $tableName 数据库表名
+     * @param \Illuminate\Database\Connection $con 数据库连接
+     * @return string 生成的注释字符串
+     * @throws \Exception 当数据库查询失败时
+     */
+    public function getAnnotation($tableName,\Illuminate\Database\Connection $con)
+    {
+        $db = $con->getDatabaseName();
+        $fillable = [];
+        $sql = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS
+                WHERE table_name = '{$tableName}' AND TABLE_SCHEMA = '{$db}'
+                ORDER BY ORDINAL_POSITION ASC";
+        $columns = $con->select($sql);
+        $annotation = "";
+
+        foreach ($columns as $column) {
+            $type = $this->getColumnType($column->DATA_TYPE);
+            $columnName = $column->COLUMN_NAME;
+            $fillable[] = $columnName;
+            $type = $this->handleSpecialColumns($columnName, $type);
+            $annotation .= sprintf("\n * @property   %s  \$%s  %s",
+                $type,
+                $columnName,
+                $column->COLUMN_COMMENT);
+        }
+
+        $this->fillable = $fillable;
+        return $annotation."\n";
+    }
+
+    private function getColumnType($dataType)
+    {
+        return match($dataType) {
+            'int', 'tinyint', 'smallint', 'mediumint', 'bigint' => 'int',
+            'float', 'double', 'decimal' => 'float',
+            'json' => 'object|array',
+            default => 'string'
+        };
+    }
+
+    private function handleSpecialColumns($columnName, $type)
+    {
+        if (in_array($columnName, ['created_at', 'updated_at', 'deleted_at'])) {
+            return '\\Carbon\\Carbon';
+        }
+        return $type;
+    }
+}

+ 129 - 0
UCore/Db/Arr.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace UCore\Db;
+
+/**
+ * 数组判断工具
+ *
+ */
+class Arr
+{
+    public array $data;
+    /**
+     * @var \Illuminate\Database\Eloquent\Builder|null
+     */
+    public $query;
+
+    use Query;
+
+    public function __construct($data,$query )
+    {
+        $this->data = $data;
+        $this->query =$query;
+    }
+
+
+
+    /**
+     * 判断数据是否 为null
+     *
+     * @param $index
+     * @return bool
+     */
+    public function isNull($index)
+    {
+        $va = $this->data[$index] ?? null;
+
+        return is_null($va);
+    }
+
+    /**
+     * 不是空
+     * @param $index
+     * @return bool
+     */
+    public function notNull($index)
+    {
+        $va = $this->data[$index] ?? null;
+
+        return !is_null($va);
+    }
+
+    /**
+     * 不为空
+     * @param $index
+     * @return bool
+     */
+    public function notEmpty($index)
+    {
+        $va = $this->data[$index] ?? null;
+
+        return !empty($va);
+
+    }
+    /**
+     * 大于0
+     * @param $index
+     * @return bool
+     */
+    public function gt0($index)
+    {
+        $va = $this->data[$index] ?? null;
+
+        return $va > 0;
+    }
+
+    /**
+     * 判断数据是否为 number(数字或数字字符串)
+     *
+     * @param $index
+     * @return bool
+     */
+    public function isNumber($index)
+    {
+        $va = $this->data[$index] ?? null;
+
+        return is_numeric($va);
+    }
+
+    /**
+     * 是否未字符串
+     * @param $index
+     * @return bool
+     */
+    public function isString($index)
+    {
+        $va = $this->data[$index] ?? null;
+
+        return is_string($va);
+    }
+
+    /**
+     * 获取int 字符串
+     *
+     * @param $index
+     * @return int
+     */
+    public function getNumber($index): int
+    {
+        $va = (integer)$this->data[$index] ?? 0;
+
+        return (string)$va;
+    }
+
+
+    /**
+     * 获取int数据
+     *
+     * @param $index
+     * @return int
+     */
+    public function getInt($index): int
+    {
+        $va = (integer)$this->data[$index] ?? 0;
+
+        return $va;
+    }
+
+
+}

+ 24 - 0
UCore/Db/Helper.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace UCore\Db;
+
+use Illuminate\Support\Facades\DB;
+
+class Helper
+{
+
+    static public function check_tr()
+    {
+        $level = DB::transactionLevel();
+        if($level === 0){
+            // 没有开启事务
+            throw new \LogicException("transaction level is 0");
+        }
+        if($level > 1){
+            // 没有开启事务
+            throw new \LogicException("transaction level > 1");
+        }
+
+    }
+
+}

+ 57 - 0
UCore/Db/Query.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace UCore\Db;
+
+/**
+ * 查询构建特性
+ *
+ * 提供常用的查询条件构建方法
+ */
+trait Query
+{
+    /**
+     * 如果是数字,则进行where条件查询
+     *
+     * @param string $field 字段名
+     * @param string $op 操作符
+     * @param string $fieldSql 自定义SQL字段名
+     * @return $this
+     */
+    public function queryNumber($field, $op = '=', $fieldSql = '')
+    {
+        if(!$fieldSql){
+            $fieldSql=  $field;
+        }
+        if ($this->isNumber($field)) {
+            $this->query = $this->query->where($fieldSql, $op, $this->getNumber($field));
+        }
+
+        return $this;
+    }
+
+    public function queryString($field, $op = '=')
+    {
+        if ($this->isString($field)) {
+            $this->query = $this->query->where($field, $op, $this->getNumber($field));
+        }
+
+        return $this;
+    }
+
+    /**
+     * 存在,且notEmpay
+     * @param $field
+     * @param $op
+     * @return $this
+     */
+    public function queryExist($field, $op = '=')
+    {
+        if ($this->notNull($field) && $this->notEmpty($field)) {
+            $this->query = $this->query->where($field, $op, $this->data[$field]);
+        }
+
+        return $this;
+
+    }
+
+}

+ 16 - 0
UCore/DcatAdmin/ActionLog/ActionForm.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace UCore\DcatAdmin\ActionLog;
+
+
+
+/**
+ * 编辑日志
+ *
+ */
+class ActionForm extends BaseLog
+{
+
+    const TYPE = 'action_form';
+
+}

+ 41 - 0
UCore/DcatAdmin/ActionLog/BaseLog.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace UCore\DcatAdmin\ActionLog;
+
+use App\Module\System\Models\AdminActionlog;
+
+
+abstract class BaseLog implements InterfaceLog
+{
+
+    public $objectClass;
+    public $admin_id;
+    public $before;
+    public $after;
+    public $url;
+    public $unid   = RUN_UNIQID;
+    public $status = 0;
+    public $p1 = null;
+
+    public function __destruct()
+    {
+
+        $model               = new AdminActionlog();
+        $model->object_class = $this->objectClass;
+        $model->admin_id     = $this->admin_id;
+        $model->before       = $this->before??[];
+        if(!$this->after){
+            $this->after = 'is null or empty ';
+        }
+        $model->after        = $this->after;
+        $model->url          = $this->url;
+        $model->unid         = $this->unid;
+        $model->type1        = static::TYPE;
+        $model->status       = $this->status;
+        $model->p1        = serialize($this->p1);
+
+        $model->save();
+
+    }
+
+}

+ 14 - 0
UCore/DcatAdmin/ActionLog/Create.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace UCore\DcatAdmin\ActionLog;
+
+/**
+ * 创建日志
+ *
+ */
+class Create extends BaseLog
+{
+
+    const TYPE = 'create';
+
+}

+ 14 - 0
UCore/DcatAdmin/ActionLog/Edit.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace UCore\DcatAdmin\ActionLog;
+
+/**
+ * 编辑日志
+ *
+ */
+class Edit extends BaseLog
+{
+
+    const TYPE = 'edit';
+
+}

+ 36 - 0
UCore/DcatAdmin/ActionLog/Exporter.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace UCore\DcatAdmin\ActionLog;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Grid\Exporters\ExcelExporter;
+
+/**
+ * 导出日至
+ *
+ */
+class Exporter extends ExcelExporter
+{
+
+    const TYPE = 'exporter';
+
+
+    /**
+     * 创建导出日志
+     *
+     * @param $Repository
+     * @param $input
+     * @return void
+     */
+    static public function create($Repository,$input)
+    {
+        $log = new self();
+        $log->objectClass = get_class($Repository);
+        $log->admin_id = Admin::user()->id;
+        $log->url = \request()->url();
+        $log->after = [];
+        $log->before = $input;
+
+    }
+
+}

+ 9 - 0
UCore/DcatAdmin/ActionLog/InterfaceLog.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace UCore\DcatAdmin\ActionLog;
+
+interface InterfaceLog
+{
+    const TYPE = '';
+
+}

+ 11 - 0
UCore/DcatAdmin/Actions/Action.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace UCore\DcatAdmin\Actions;
+
+use Dcat\Admin\Actions\Action as BaseAction;
+use UCore\DcatAdmin\Traits\ReturnRes;
+
+class Action extends BaseAction
+{
+    use ReturnRes;
+}

+ 14 - 0
UCore/DcatAdmin/AdminController.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace UCore\DcatAdmin;
+
+
+
+
+use UCore\DcatAdmin\Traits\ResController;
+use UCore\DcatAdmin\Traits\ReturnRes;
+
+class AdminController extends \Dcat\Admin\Http\Controllers\AdminController
+{
+    use ResController, ReturnRes;
+}

+ 228 - 0
UCore/DcatAdmin/FilterHelper.php

@@ -0,0 +1,228 @@
+<?php
+
+namespace UCore\DcatAdmin;
+
+use UCore\DcatAdmin\Traits\Options;
+use Dcat\Admin\Grid\Filter;
+use Illuminate\Support\Arr;
+
+class FilterHelper
+{
+
+    use Options;
+
+    /**
+     * @var Filter
+     */
+    public $filter;
+    /**
+     * @var AdminController
+     */
+    public $controller;
+
+    public function __construct($filter, $controller)
+    {
+        $this->filter     = $filter;
+        $this->controller = $controller;
+        // $this->filter->expand();
+        // $this->filter->panel();
+    }
+
+
+    public function equal($field,$label= '')
+    {
+        $this->filter->equal($field, $label);
+    }
+
+    /**
+     * in条件映射
+     * @param $field
+     * @param $field_origin
+     * @param $label
+     * @return Filter\Where
+     */
+    public function inas($field, $field_origin, $label = '')
+    {
+        return $this->filter->where($field, function (\Illuminate\Database\Eloquent\Builder $query) use ($field, $field_origin) {
+
+            $query->whereIn($field_origin, explode(',',$this->input));
+
+        },                          $label);
+    }
+
+
+    /**
+     * gt 条件映射
+     *
+     * @param $field
+     * @param $field_origin
+     * @param $label
+     * @return Filter\Where
+     */
+    public function gtas($field, $field_origin, $label = '')
+    {
+        return $this->filter->where($field, function (\Illuminate\Database\Eloquent\Builder $query) use ($field, $field_origin) {
+
+            $query->where($field_origin,'>', $this->input);
+
+        },                          $label);
+    }
+
+    public function equaljson($field,$field1,$field2,$label= '')
+    {
+        $this->filter->where($field, function ($query) use ($field1,$field2){
+
+            $query->whereRaw(" $field1->\"$.$field2\" = '{$this->input}' ");
+
+        },$label);
+    }
+    public function equaljsonInt($field,$field1,$field2,$label= '')
+    {
+        $this->filter->where($field, function ($query) use ($field1,$field2){
+
+            $query->whereRaw(" $field1->\"$.$field2\" = {$this->input} ");
+
+        },$label);
+    }
+
+
+    /**
+     * 字符串字段不为空
+     *
+     * @param $field
+     * @param $label
+     * @return void
+     */
+    public function columnNotSEmpey($field,$field2,$label= '')
+    {
+        $this->filter->where($field, function ($query) use ($field2){
+
+            $query->whereRaw(" `$field2`  != '' ");
+
+        },$label);
+    }
+
+
+    /**
+     * 使用枚举 选择
+     *
+     * @param $field
+     * @param $enmu
+     * @return void
+     */
+    public function equalSelect($field, array $enmu,$label= '')
+    {
+        $this->filter->equal($field, $label)->select($enmu);
+    }
+
+    public function equalSelectVk($field, array $enmu,$label= '')
+    {
+        $this->filter->equal($field, $label)->select(array_flip($enmu));
+    }
+
+    /**
+     * 等于
+     *
+     * @param $field
+     * @param array $enmu
+     * @return Filter\Presenter\Presenter|Filter\Presenter\Radio
+     */
+    public function equalRadio($field, array $enmu,$label= '')
+    {
+        return $this->filter->equal($field, $label)->radio($enmu);
+    }
+
+    public function equalRadioModelCats($field,$label = '')
+    {
+        $cates = $this->filter->grid()->model()->repository()->model()->getCasts();
+        $enmu = $cates[$field]??"";
+        if($enmu === ''){
+            throw new \Exception("$field is not a model casts");
+        }
+//        dump($cates,$enmu::getValueDescription());
+        $values = $enmu::getValueDescription();
+
+
+        return $this->filter->equal($field, $label)->radio($values);
+    }
+
+    public function equalRadioVk($field, array $enmu,$label= '')
+    {
+        return $this->filter->equal($field, $label)->radio(array_flip($enmu));
+    }
+
+
+    /**
+     * 等于
+     *
+     * @param $field
+     * @param array $enmu
+     * @return Filter\Presenter\Presenter|Filter\Presenter\Radio
+     */
+    public function equalRadioKv($field, array $kv,$label= '')
+    {
+        return $this->filter->equal($field, $label)->radio($kv);
+    }
+
+
+    /**
+     * 多选默认值
+     *
+     * @param $field
+     * @param $option
+     * @param $default
+     * @param $label
+     * @return Filter\Presenter\Checkbox|Filter\Presenter\Presenter
+     */
+    public function checkboxDefault($field,$option,$default,$label= '')
+    {
+        $req = request($field);
+        if(!$req){
+            /**
+             * @var \Illuminate\Routing\Route $router
+             */
+            $router= request()->route();
+            $p = request()->query();
+            $p[$field] = $default;
+
+            $to = route($router->getName(),$p);
+            admin_exit(admin_redirect($to));;
+
+        }
+
+        return $this->filter->where($field, function ($query)use($field){
+
+        },$label)->checkbox($option)->default($default);
+
+    }
+
+
+    /**
+     * 不等于判断
+     *
+     * @param $field
+     * @param array $enmu
+     * @param $th
+     * @return Filter\Presenter\Presenter|Filter\Presenter\Radio
+     */
+    public function notequalRadio($field, array $enmu, $th = 'notEqual',$label= '')
+    {
+        $t = $field . '-' . $th;
+
+        return $this->filter->notEqual($field, $label)->radio($this->useing($t, $enmu));
+    }
+
+
+    /**
+     * 订单ID
+     *
+     * @return void
+     */
+    public function columnOrderId()
+    {
+        $this->filter->column('order_id','订单ID' )->link(function ($value) {
+            return admin_url('order/' . $value);
+        });
+    }
+
+}

+ 23 - 0
UCore/DcatAdmin/Form/AbstractTool.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace UCore\DcatAdmin\Form;
+
+use Dcat\Admin\Grid\Tools\AbstractTool as BaseAbstractTool;
+use UCore\DcatAdmin\Traits\ReturnRes;
+
+/**
+ * 工具基础类
+ *
+ */
+class AbstractTool extends BaseAbstractTool
+{
+    use ReturnRes;
+
+    public function title()
+    {
+        return  $this->title;
+    }
+
+
+
+}

+ 309 - 0
UCore/DcatAdmin/FormHelper.php

@@ -0,0 +1,309 @@
+<?php
+
+namespace UCore\DcatAdmin;
+
+use UCore\DcatAdmin\Traits\Options;
+use UCore\DcatAdmin\Traits\UserID;
+use Dcat\Admin\Form;
+
+
+class FormHelper
+{
+
+    use Options, UserID;
+
+    /**
+     * @var Form
+     */
+    public $form;
+
+    /**
+     * @var AdminController
+     */
+    public $controller;
+
+    public function __construct($form, $controller)
+    {
+
+        $this->form = $form;
+        $this->controller = $controller;
+    }
+
+    public function enableBack(){
+        $this->form->tools(function (Form\Tools $tools){
+            $tools->prepend();
+        });
+    }
+
+    /**
+     * @param $field
+     * @return Form\Field|Form\Field[]|\Illuminate\Support\Collection|null
+     */
+    public function field($field)
+    {
+        return $this->form->field($field);
+    }
+
+
+    /**
+     * 开关
+     *
+     * @param $field
+     * @param $default
+     * @return Form\Field\SwitchField
+     */
+    public function switch($field ,  $label = null)
+    {
+        return $this->form->switch($field, $label);
+    }
+
+    /**
+     * number
+     *
+     * @param $field
+     * @return Form\Field\Number
+     */
+    public function number($field,  $label = null)
+    {
+        return $this->form->number($field, $label);
+    }
+
+    /**
+     * 字符串
+     *
+     * @param $field
+     * @return Form\Field\Text
+     */
+    public function text($field,  $label = null)
+    {
+        return $this->form->text($field, $label);
+    }
+
+    public function hidden($field,  $label = null)
+    {
+        return $this->form->hidden($field, $label);
+    }
+
+    /**
+     * 单select
+     *
+     * @param $field
+     * @return Form\Field\Select
+     */
+    public function select($field,  $label = null)
+    {
+        return $this->form->select($field, $label);
+    }
+
+    /**
+     *  单select 带枚举的
+     *
+     * @param string $field 字段
+     * @param array $enmu 枚举
+     * @return Form\Field\Select|mixed
+     */
+    public function selectOption($field, $enmu,  $label = null)
+    {
+        return $this->form->select($field, $label)->options($this->useing($field, $enmu));
+    }
+
+    /**
+     * 多 select
+     *
+     * @param $field
+     * @return Form\Field\MultipleSelect
+     */
+    public function multipleSelect($field,  $label = null)
+    {
+        return $this->form->multipleSelect($field, $label);
+    }
+
+    /**
+     * 多 select表,选择器
+     *
+     * @param $field
+     * @return Form\Field\MultipleSelectTable
+     */
+    public function multipleSelectTable($field,  $label = null)
+    {
+        return $this->form->multipleSelectTable($field, $label);
+    }
+
+
+    /**
+     * 多 select表,选择器
+     *
+     * @param $field
+     * @return Form\Field\SelectTable
+     */
+    public function selectTable($field,$label = null)
+    {
+        return $this->form->selectTable($field, $label);
+    }
+
+
+    /**
+     * 多选
+     *
+     * @param $field
+     * @return Form\Field\Checkbox
+     */
+    public function checkbox($field,  $label = null)
+    {
+        return $this->form->checkbox($field, $label);
+    }
+
+    /**
+     * 单选
+     *
+     * @param $field
+     * @param array $enmu
+     * @return Form\Field\Radio
+     */
+    public function radio($field, array $enmu,   $label = null )
+    {
+        $lable = $lable ?? $field;
+        return $this->form->radio($field, $label)->options( $enmu);
+    }
+
+
+    /**
+     * 列表
+     *
+     * @param $field
+     *
+     * @return Form\Field\ListField
+     */
+    public function list($field,  $label = null)
+    {
+        return $this->form->list($field, $label);
+    }
+
+    /**
+     * 图片表单
+     *
+     * @param $field
+     * @return $this
+     */
+    public function image($field, $label = null)
+    {
+        $this->form->image($field, $label);
+
+        return $this;
+    }
+
+
+    /**
+     * @param $field
+     * @return $this
+     */
+    public function editor($field,  $label = null)
+    {
+        $this->form->editor($field, $label);
+
+        return $this;
+    }
+
+    public function multipleImage($field,  $label = null)
+    {
+        $this->form->multipleImage($field, $label);
+
+        return $this;
+    }
+
+    /**
+     *  分割线
+     *
+     * @param $title
+     * @return $this
+     */
+    public function divider($title = null)
+    {
+        $this->form->divider($this->controller->_translation('divider-' . $title));
+
+        return $this;
+    }
+
+
+    /**
+     * 展示字段
+     *
+     * @param $field
+     * @return Form\Field\Display
+     */
+    public function display($field,  $label = null)
+    {
+        return $this->form->display($field, $label);
+    }
+
+    /**
+     * @param $field
+     * @return Form\Field\Display
+     */
+    public function displayOptions($field,  $label = null)
+    {
+        $c   = $this->controller;
+        return $this->form->display($field, $label)->with(function($value) use ($field,$c) {
+            return $c->_option($field.'-'.$value);
+
+        });
+    }
+
+    /**
+     * 文本
+     *
+     * @param $field
+     * @return $this
+     *
+     */
+    public function textarea($field,  $label = null)
+    {
+        return $this->form->textarea($field, $label);
+    }
+
+    /**
+     * 增加表格
+     * @param $field
+     * @param $call
+     * @return Form\Field\Table
+     */
+    public function table($field,$call,  $label = null)
+    {
+        return $this->form->table($field, $label,$call);
+    }
+
+    /**
+     * tags
+     *
+     * @param $field
+     * @return Form\Field\Tags
+     */
+    public function tags($field,  $label = null)
+    {
+        return $this->form->tags($field, $label);
+    }
+
+    /**
+     * 关闭所有的 多余
+     * @return void
+     */
+    public function disableAll()
+    {
+        $this->form->disableDeleteButton();
+        $this->form->disableCreatingCheck();
+        $this->form->disableViewButton();
+//        $this->form->disableListButton();
+        $this->form->disableViewCheck();
+        $this->form->disableEditingCheck();
+    }
+
+    public function disableButton4()
+    {
+        $this->form->disableDeleteButton();
+        $this->form->disableViewButton();
+//        $this->form->disableListButton();
+        $this->form->disableViewCheck();
+        $this->form->disableEditingCheck();
+    }
+
+}

+ 14 - 0
UCore/DcatAdmin/Grid/Actions/Edit.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Actions;
+
+use Dcat\Admin\Grid\Actions\Edit as BaseEdit;
+
+class Edit extends BaseEdit
+{
+    public function href()
+    {
+        return parent::href(); // TODO: Change the autogenerated stub
+    }
+
+}

+ 11 - 0
UCore/DcatAdmin/Grid/BatchAction.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid;
+
+use Dcat\Admin\Grid\BatchAction as BaseBatchAction;
+use UCore\DcatAdmin\Traits\ReturnRes;
+
+class BatchAction extends BaseBatchAction
+{
+    use ReturnRes;
+}

+ 76 - 0
UCore/DcatAdmin/Grid/Displayers/LabelCall.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Displayers;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Grid\Column;
+use Dcat\Admin\Grid\Displayers\AbstractDisplayer;
+use Dcat\Admin\Support\Helper;
+
+class LabelCall extends AbstractDisplayer
+{
+
+    protected $baseClass = 'label';
+
+    protected $call;
+
+    public function __construct($value, Grid $grid, Column $column, $row)
+    {
+        parent::__construct($value, $grid, $column, $row);
+        return $this;
+    }
+
+    public function call(callable $call)
+    {
+        $this->call = $call;
+
+        return $this;
+    }
+
+    public function display($style = 'primary', $max = null)
+    {
+        if (!$value = $this->value($max)) {
+            return;
+        }
+
+        $original     = $this->column->getOriginal();
+        $defaultStyle = is_array($style) ? ($style['default'] ?? 'default') : 'default';
+
+        $background = $this->formatStyle(
+            is_array($style) ?
+                (is_scalar($original) ? ($style[$original] ?? $defaultStyle) : current($style))
+                : $style
+        );
+
+        return collect($value)->map(function ($name) use ($background) {
+            return "<span class='{$this->baseClass}' {$background}>$name</span>";
+        })->implode(' ');
+    }
+
+    protected function formatStyle($style)
+    {
+        $background = 'style="background:#d2d6de;color: #555"';
+
+        if ($style !== 'default') {
+            $style = Admin::color()->get($style, $style);
+
+            $background = "style='background:{$style}'";
+        }
+
+        return $background;
+    }
+
+    protected function value($max)
+    {
+        $values = Helper::array($this->value);
+
+        if ($max && count($values) > $max) {
+            $values   = array_slice($values, 0, $max);
+            $values[] = '...';
+        }
+
+        return $values;
+    }
+
+}

+ 58 - 0
UCore/DcatAdmin/Grid/Displayers/LineActions.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Displayers;
+
+
+use Dcat\Admin\Grid\Displayers\Actions;
+
+class LineActions extends Actions
+{
+
+    /**
+     * @return string
+     */
+    protected function getViewLabel()
+    {
+        $label = trans('admin.show');
+
+        return "<i title='{$label}' class=\"feather icon-eye grid-action-icon\">{$label}</i> &nbsp;";
+    }
+
+
+    /**
+     * @return string
+     */
+    protected function getEditLabel()
+    {
+        $label = trans('admin.edit');
+
+        return "<i title='{$label}' class=\"feather icon-edit-1 grid-action-icon\">{$label}</i> &nbsp;";
+    }
+
+
+
+
+    /**
+     * @return string
+     */
+    protected function getQuickEditLabel()
+    {
+        $label = trans('admin.quick_edit');
+
+        return "<i title='{$label}' class=\"feather icon-edit grid-action-icon\">{$label}</i> &nbsp;";
+    }
+
+
+
+
+    /**
+     * @return string
+     */
+    protected function getDeleteLabel()
+    {
+        $label = trans('admin.delete');
+
+        return "<i class=\"feather icon-trash grid-action-icon\" title='{$label}'>{$label}</i> &nbsp;";
+    }
+
+}

+ 45 - 0
UCore/DcatAdmin/Grid/Exporters/ExcelExporter.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Exporters;
+
+use Dcat\Admin\Exception\RuntimeException;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Grid\Exporters\AbstractExporter;
+use Dcat\EasyExcel\Excel;
+
+class ExcelExporter extends AbstractExporter
+{
+
+    public function __construct($titles = [])
+    {
+        parent::__construct($titles);
+
+        if (!class_exists(Excel::class)) {
+            throw new RuntimeException('To use exporter, please install [dcat/easy-excel] first.');
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function export()
+    {
+        $filename = $this->getFilename() . '.' . $this->extension;
+
+        $exporter = Excel::export();
+
+        if ($this->scope === Grid\Exporter::SCOPE_ALL) {
+            $exporter->chunk(function (int $times) {
+                return $this->buildData($times);
+            });
+        } else {
+            $exporter->data($this->buildData() ?: [ [] ]);
+        }
+
+        $exporter->headings($this->titles())->download($filename);
+
+        exit;
+    }
+
+}
+

+ 12 - 0
UCore/DcatAdmin/Grid/LazyRenderable.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid;
+
+use Dcat\Admin\Grid\LazyRenderable as BaseLazyRenderable;
+
+abstract class LazyRenderable extends BaseLazyRenderable
+{
+
+
+
+}

+ 17 - 0
UCore/DcatAdmin/Grid/Tool/HrefAbstractTool.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Tool;
+
+use Dcat\Admin\Grid\Tools\AbstractTool;
+
+class HrefAbstractTool extends AbstractTool
+{
+    public function html()
+    {
+        $this->appendHtmlAttribute('class', $this->style);
+
+        return <<<HTML
+<a {$this->formatHtmlAttributes()}>{$this->title()}</a>
+HTML;    }
+
+}

+ 82 - 0
UCore/DcatAdmin/Grid/Views/GridHeader.php

@@ -0,0 +1,82 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Views;
+
+use App\Module\System\Enums\ViewType;
+use App\Module\System\Models\AdminGridView;
+use Illuminate\Contracts\Support\Renderable;
+use Dcat\Admin\Admin;
+use Illuminate\Support\Facades\Route;
+use Illuminate\Support\Facades\URL;
+use Dcat\Admin\Grid;
+
+class GridHeader
+{
+
+    protected $grid;
+
+    public function __construct(\Dcat\Admin\Grid $grid)
+    {
+        redirect()->setIntendedUrl(URL::full());
+        $this->grid = $grid;
+    }
+
+    public function getBs()
+    {
+        $bs = [];
+
+        $router_name= Route::getCurrentRoute()->getName();
+
+        // 视图按钮
+        $listPublic  = AdminGridView::query()
+            ->where('type1', ViewType::PUBLIC)
+            ->where('router_name', $router_name)
+            ->get();
+        $listPrivate = AdminGridView::query()
+            ->where('type1', ViewType::PRIVATE)
+            ->where('router_name', $router_name)
+
+            ->get();
+        $_viewid     = request('_viewid');
+        $_viewnow    = '';
+        foreach ($listPrivate as $value) {
+            $bs[] = new GridHeaderButtonPrivate($value);
+            if ($_viewid == $value->id) {
+                $bs[] = new GridHeaderButtonUpdate2($value);
+            }
+        }
+        foreach ($listPublic as $value) {
+            $bs[] = new GridHeaderButtonPublic($value);
+            if ($_viewid == $value->id) {
+                $bs[] = new GridHeaderButtonUpdate2($value);
+            }
+        }
+        $bs[] = new GridHeaderButtonSave();
+        if ($_viewid) {
+            $bs[] = new GridHeaderButtonEdit();
+        }
+
+        return $bs;
+    }
+
+
+    static public function gridTools(\Dcat\Admin\Grid $grid)
+    {
+        $new = new static($grid);
+        $grid->tools($new->getBs());
+    }
+
+    static public function gridHeader(\Dcat\Admin\Grid $grid)
+    {
+
+        $new = new static($grid);
+        $s   = ' <br>';
+        $bs  = $new->getBs();
+//        dd($bs);
+        foreach ($bs as $b) {
+            $s .= $b.' ';
+        };
+        $grid->header($s);
+    }
+
+}

+ 35 - 0
UCore/DcatAdmin/Grid/Views/GridHeaderButtonEdit.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Views;
+
+
+
+use Dcat\Admin\Actions\Action;
+use Dcat\Admin\Grid\Tools\AbstractTool;
+use Illuminate\Support\Facades\Route;
+
+/**
+ * 保存为视图按钮
+ */
+class GridHeaderButtonEdit extends AbstractTool
+{
+    public $title = "修改视图";
+
+    public function render(): string
+    {
+
+
+        $url=admin_route('admin_view.edit',
+                         [
+                             'admin_view'=>request('_viewid')
+                         ]
+        );
+//        dump($url);
+        $title = $this->title();
+
+        return "<a href='{$url}' class='btn btn-primary'>
+    <i class='fa fa-edit '></i><span class='d-none d-sm-inline'>&nbsp;&nbsp;{$title}</span>
+</a>";
+
+    }
+}

+ 67 - 0
UCore/DcatAdmin/Grid/Views/GridHeaderButtonPrivate.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Views;
+
+use UCore\DcatAdmin\Form\AbstractTool;
+use App\Module\System\Models\AdminGridView;
+use Illuminate\Support\Facades\Route;
+
+class GridHeaderButtonPrivate extends AbstractTool
+{
+
+    /**
+     * @var AdminGridView $adminGridView
+     */
+    protected $adminGridView;
+
+
+    public function __construct(AdminGridView $adminGridView)
+    {
+        $this->adminGridView = $adminGridView;
+    }
+
+
+    public function render(): string
+    {
+
+
+
+        $title = $this->adminGridView->title;
+        $url = $this->getUrl();
+        $now = $this->getNowIcon();
+
+        return "<a href='{$url}' class='btn btn-success'>
+    <span class=' d-sm-inline'>
+    &nbsp;&nbsp;{$title}
+    </span>
+    $now
+</a>";
+
+    }
+
+
+    public function getNowIcon(): string
+    {
+        $now_viewid = request('_viewid');
+        $now        = '';
+        if ($now_viewid == $this->adminGridView->id) {
+            $now = "<i class='fa  fa-check'></i>";
+        }
+
+        return $now;
+    }
+
+    protected function getUrl()
+    {
+        $p1            = $this->adminGridView->p1;
+        $p1['_viewid'] = $this->adminGridView->id;
+
+        $url = \route($this->adminGridView->router_name,
+                      $p1
+        );
+        return $url;
+
+    }
+
+}
+

+ 36 - 0
UCore/DcatAdmin/Grid/Views/GridHeaderButtonPublic.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Views;
+
+use UCore\DcatAdmin\Form\AbstractTool;
+use App\Module\System\Models\AdminGridView;
+use Illuminate\Support\Facades\Route;
+
+class GridHeaderButtonPublic extends GridHeaderButtonPrivate
+{
+
+
+
+
+
+
+    public function render(): string
+    {
+
+
+
+        $url = $this->getUrl();
+
+        $title =$this->adminGridView->title;
+        // fa-bookmark 实心
+        // fa-bookmark-o 空心
+        $now = $this->getNowIcon();
+        return "<a href='{$url}' class='btn btn-success'>
+    <span class='d-none d-sm-inline'>
+    &nbsp;&nbsp;{$title}
+    </span> $now
+</a>";
+
+    }
+
+}

+ 44 - 0
UCore/DcatAdmin/Grid/Views/GridHeaderButtonSave.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Views;
+
+
+
+use Dcat\Admin\Actions\Action;
+use Dcat\Admin\Grid\Tools\AbstractTool;
+use Illuminate\Support\Facades\Route;
+
+/**
+ * 保存为视图按钮
+ */
+class GridHeaderButtonSave extends AbstractTool
+{
+    public $title = "保存为新视图";
+
+    public function render(): string
+    {
+        $get = request()->query();
+        $filteredArray = array_filter($get,'\UCore\Helper\Helper::not_null');
+        unset($filteredArray['_pjax']);
+        unset($filteredArray['pjax']);
+        unset($filteredArray['_viewid']);
+        if(empty($filteredArray)){
+            return '';
+        }
+
+        $id = $this->getKey();
+        $router= Route::getCurrentRoute();
+
+        $filteredArray['_router_name'] = $router->getName();
+        $url=admin_route('admin_view_add',
+                         $filteredArray
+        );
+
+        $title = $this->title();
+
+        return "<a href='{$url}' class='btn btn-primary'>
+    <i class='feather icon-plus'></i><span class='d-none d-sm-inline'>&nbsp;&nbsp;{$title}</span>
+</a>";
+
+    }
+}

+ 46 - 0
UCore/DcatAdmin/Grid/Views/GridHeaderButtonUpdate2.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace UCore\DcatAdmin\Grid\Views;
+
+
+
+use Dcat\Admin\Actions\Action;
+use Dcat\Admin\Grid\Tools\AbstractTool;
+use Illuminate\Routing\Redirector;
+use Illuminate\Support\Facades\Route;
+
+/**
+ * 保存为视图按钮
+ */
+class GridHeaderButtonUpdate2 extends GridHeaderButtonPrivate
+{
+    public $title = "更新视图";
+
+
+
+    public function render(): string
+    {
+
+
+        $get = request()->query();
+        $filteredArray = array_filter($get,'\UCore\Helper\Helper::not_null');
+        unset($filteredArray['_pjax']);
+        unset($filteredArray['pjax']);
+
+
+        $url = admin_route('admin_view_add',
+                           $filteredArray
+        );
+
+        $title = $this->title();
+//        dump($filteredArray,$this->adminGridView->p1);
+        if($filteredArray == $this->adminGridView->p1){
+            return '';
+        }
+
+        return "<a href='{$url}' class='btn btn-primary'>
+    <i class='fa fa-cloud-upload '></i><span class='d-none d-sm-inline'>&nbsp;&nbsp;{$title}</span>
+</a>";
+
+    }
+}

+ 4 - 0
UCore/DcatAdmin/Grid/Views/readme.md

@@ -0,0 +1,4 @@
+# 列表视图功能
+
+> 预定义少选条件
+

+ 301 - 0
UCore/DcatAdmin/GridHelper.php

@@ -0,0 +1,301 @@
+<?php
+
+namespace UCore\DcatAdmin;
+
+use App\Admin\Business\Order\Traits\OrderId;
+use App\Admin\Business\Order\Traits\VOrderId;
+use UCore\DcatAdmin\Grid\Views\GridHeader;
+use UCore\DcatAdmin\Traits\AdminId;
+use UCore\DcatAdmin\Traits\UserID;
+use UCore\DcatAdmin\Traits\MerchantId;
+use App\Module\File\Img;
+use Carbon\CarbonInterface;
+use Carbon\Traits\Converter;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Widgets\Table;
+use Illuminate\Support\Arr;
+
+
+class GridHelper
+{
+
+    use \UCore\DcatAdmin\Traits\Options, UserID, MerchantId, AdminId;
+
+    /**
+     * @var Grid
+     */
+    public $grid;
+
+    /**
+     * @var AdminController
+     */
+    public $controller;
+
+    public function __construct($grid, $controller)
+    {
+        $this->grid = $grid;
+        $grid->filter(function (Grid\Filter $filter) {
+            // $filter->panel();
+
+            // $filter->expand();
+        });
+        $this->controller = $controller;
+        if (request('in_iframe')) {
+            $grid->model()->setConstraints([ 'in_iframe' => 1 ]);
+
+        }
+        GridHeader::gridHeader($grid);
+
+    }
+
+    public function columnId()
+    {
+        $this->grid->column('id', 'ID')->sortable();
+
+        return $this;
+    }
+
+    public function columnIdDesc()
+    {
+        $this->grid->column('id', 'ID')->sortable();
+        $this->grid->model()->orderByDesc('id');
+
+        return $this;
+    }
+
+    public function disableAll()
+    {
+        $this->grid->disableCreateButton();
+        $this->grid->disableBatchActions();
+        $this->grid->disableDeleteButton();
+        $this->grid->disableEditButton();
+        $this->grid->disableQuickEditButton();
+        $this->grid->disableViewButton();
+
+//        $this->grid->disableBatchActions();
+        return $this;
+    }
+
+
+    /**
+     *
+     * @param $field
+     * @param $view
+     * @return $this
+     */
+    public function columnView($field, $view, $label = '')
+    {
+        $this->grid->column($field, $label)->view($view);
+
+        return $this;
+    }
+
+    public function columnImg($field, $width = 100, $hei = 100, $label = '')
+    {
+        $this->grid->column($field, $label)->display(function ($p2) {
+//            dump($p2);
+            return Img::img2imgurl($p2);
+        })->image('', $width, $hei);
+    }
+
+    public function columnExpand($field, $fields = [], $label = '')
+    {
+        $controller = $this->controller;
+        $this->grid->column($field, $label)->expand(function (Grid\Displayers\Expand $exped) use ($fields, $controller) {
+//            dump(func_get_args());
+            $headers = [
+                'admin.kv.name',
+                'admin.kv.value',
+            ];
+            $data    = [];
+//            $exped->row;
+//            dd($exped);
+            foreach ($fields as $f) {
+                $data[] = [
+                    $controller->_label($f), $exped->row->$f
+                ];
+            }
+
+            return Table::make($headers, $data);
+        });
+    }
+
+
+    /**
+     * 翻译 字段内容
+     *
+     * @param $field
+     * @return void
+     */
+    public function columnTranslation($field, $label = '')
+    {
+        $this->grid->column($field, $label)->display(function ($value, $column, $controller) {
+//            dd(func_get_args());
+            /**
+             * @var AdminController $controller
+             */
+            return $controller->_translation('key.' . $value);
+        }, $this->controller);;
+    }
+
+
+    /**
+     * 展示的时候除以100
+     *
+     * @param string $field
+     * @return void
+     */
+    public function columnc100($field, $label = '')
+    {
+        $this->grid->column($field, $label)->display(function ($p2) {
+            return $p2 / 100;
+        });
+    }
+
+    public function columnc1000($field, $label = '')
+    {
+        return $this->grid->column($field, $label)->display(function ($p2) {
+            return $p2 / 1000;
+        });
+    }
+
+    /**
+     * 展示 时间戳
+     *
+     * @param string $field
+     * @return void
+     */
+    public function columnAt($field, $label = '')
+    {
+        $this->grid->column($field, $label)->display(function ($p2) {
+            return date(\DateTime::W3C, $p2);
+        });
+    }
+
+    public function columnAtd($field, $label = '')
+    {
+        $this->grid->column($field, $label)->display(function (/* \Carbon\Carbon*/ $p2) {
+            if (!$p2) {
+                return null;
+            }
+
+//            dd($p2);
+            return $p2->format(CarbonInterface::DEFAULT_TO_STRING_FORMAT);
+        })->width(105);
+    }
+
+
+    /**
+     * 使用枚举展示
+     *
+     * @param $field
+     * @param $enmu
+     * @return $this
+     */
+    public function columnUseing($field, $enmu, $label = '')
+    {
+        $this->grid->column($field, $label)->use($enmu);
+
+        return $this;
+    }
+
+    public function columnUsingVk($field, $enmu, $label = '')
+    {
+        $res = array_flip($enmu);
+
+//        dd($res);
+        return $this->grid->column($field, $label)->using($res);
+
+    }
+
+    public function columnUsingkv($field, $enmu, $label = '')
+    {
+//        dump($enmu);
+        return $this->grid->column($field, $label)->using($enmu);
+    }
+
+
+    /**
+     * 使用枚举展示.new
+     *
+     * @param $name
+     * @param array $keys
+     * @return Grid\Column
+     */
+    public function fieldUseing($name, array $keys, $label = '')
+    {
+        return $this->grid->column($name, $label)->using($this->useing($name, $keys));
+    }
+
+    /**
+     * 使用lab
+     *
+     * @param $name
+     * @param array $keys
+     * @return Grid\Column
+     */
+    public function fieldLable1($name, $label = '')
+    {
+        $c = $this->controller;
+
+        return $this->grid->column($name, $label)->display(function ($value, Grid\Column $column) use ($c) {
+//            $list = explode(',',$c)
+            $list = [];
+            foreach ($value as $item) {
+//                dd($this);
+                $list[] = $c->_option($column->getName() . '-' . $item);
+            }
+
+            return $list;
+        })->label();
+    }
+
+
+    /**
+     * 模型字段展示-cats
+     *
+     * @param $name
+     * @param $default
+     * @param $label
+     * @return Grid\Column
+     * @throws \Exception
+     */
+    public function columnModelCats($name, $default = null, $label = '', $edit = false)
+    {
+        $cates = $this->grid->model()->repository()->model()->getCasts();
+        $enmu  = $cates[$name] ?? "";
+        if ($enmu === '') {
+            throw new \Exception("$name is not a model casts");
+        }
+        $values  = $enmu::getValueDescription();
+
+        if ($edit) {
+
+            $res = $this->grid->column($name)->display(function ($value) use ($values, $default) {
+                if (is_null($value)) {
+                    return $default;
+                }
+                if ($value instanceof \UnitEnum) {
+                    $value = $value->value();
+                }
+
+                return $value;
+            })->radio($values);
+        } else {
+            $res = $this->grid->column($name, $label)->display(function ($value) use ($values, $default) {
+                if (is_null($value)) {
+                    return $default;
+                }
+                if ($value instanceof \UnitEnum) {
+                    $value = $value->value();
+                }
+
+                return Arr::get($values, $value, $default);
+            });
+        }
+
+        return $res;
+    }
+
+
+}

+ 8 - 0
UCore/DcatAdmin/Herlper.php

@@ -0,0 +1,8 @@
+<?php
+
+namespace UCore\DcatAdmin;
+
+class Herlper
+{
+
+}

+ 15 - 0
UCore/DcatAdmin/Layout/ContentFb.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace UCore\DcatAdmin\Layout;
+
+use Dcat\Admin\Layout\Content;
+
+class ContentFb extends Content
+{
+
+    public function full()
+    {
+        return $this->view('admin_core.layouts.full-contentb');
+    }
+
+}

+ 35 - 0
UCore/DcatAdmin/Metrics/Box.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Admin\Metrics;
+
+use Dcat\Admin\Widgets\Widget;
+
+
+/**
+ * 盒子
+ */
+class Box extends Widget
+{
+
+    protected $view = 'admin_core.widgets.box';
+
+    public $boxHtml = '';
+
+    public function __construct($html)
+    {
+        $this->boxHtml = $html;
+    }
+
+
+    public function defaultVariables()
+    {
+        return [
+            'boxHtml'    => $this->boxHtml,
+            'attributes' => $this->formatHtmlAttributes(),
+            'options'    => $this->options,
+            'class'      => $this->getElementClass(),
+            'selector'   => $this->getElementSelector(),
+        ];
+    }
+
+}

+ 13 - 0
UCore/DcatAdmin/Metrics/Dump.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics;
+
+class Dump
+{
+
+    static public function dumpvar($data)
+    {
+        return view('admin/dump', [ 'dump_var' => $data ]);
+    }
+
+}

+ 167 - 0
UCore/DcatAdmin/Metrics/Examples/DataBar.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Support\JavaScript;
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+
+/**
+ * 横向 条形卡片
+ *
+ */
+class DataBar extends \Dcat\Admin\Widgets\Metrics\RadialBar
+{
+
+    /**
+     * @var array
+     */
+    protected $options = [
+        'icon'     => null,
+        'title'    => null,
+        'header'   => null,
+        'content'  => null,
+        'footer'   => null,
+        'dropdown' => [],
+    ];
+
+    /**
+     * 卡片高度.
+     *
+     * @var int
+     */
+    protected $height = 190;
+
+    /**
+     * 图表高度.
+     *
+     * @var int
+     */
+    protected $chartHeight = 140;
+
+    /**
+     * 内容宽度.
+     *
+     * @var array
+     */
+    protected $contentWidth = [ 5, 7 ];
+
+    /**
+     * 图表上间距.
+     *
+     * @var int
+     */
+    protected $chartMarginTop = 0;
+
+    /**
+     * 图表下间距.
+     *
+     * @var int
+     */
+    protected $chartMarginBottom = -20;
+
+    /**
+     * 图表默认配置.
+     *
+     * @return array
+     */
+    protected function defaultChartOptions()
+    {
+
+        return [
+            'chart' => [
+                'height' => 150,
+                'type'   => 'bar',
+
+            ],
+
+            'series' => [
+
+            ],
+
+            'xaxis'       => [
+            ],
+            'plotOptions' => [
+                'bar' => [
+                    'horizontal' => true
+                ]
+            ]
+        ];
+    }
+
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data 键值对
+     *
+     * @return $this
+     */
+    public function withChart(array $data)
+    {
+
+        $cData = [
+            'series' => [
+                [
+                    'data' => array_values($data)
+                ]
+            ],
+            'xaxis'  => [
+                'categories' => array_keys($data)
+            ],
+        ];
+
+        return $this->chart($cData);
+    }
+
+
+    /**
+     * 卡片内容.
+     *
+     * @param int $finished
+     * @param int $pending
+     * @param int $rejected
+     *
+     * @return $this
+     */
+    public function withContent($count, $in, $out)
+    {
+        return $this->content(
+            <<<HTML
+<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
+    <div class="chart-info d-flex justify-content-between mb-1 mt-2" >
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-primary"></i>
+              <span class="text-bold-600 ml-50">总</span>
+          </div>
+          <div class="product-result">
+              <span>{$count}</span>
+          </div>
+    </div>
+
+    <div class="chart-info d-flex justify-content-between mb-1">
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-warning"></i>
+              <span class="text-bold-600 ml-50">总转入</span>
+          </div>
+          <div class="product-result">
+              <span>{$in}</span>
+          </div>
+    </div>
+      <div class="chart-info d-flex justify-content-between mb-1">
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-danger"></i>
+              <span class="text-bold-600 ml-50">总转出</span>
+          </div>
+          <div class="product-result">
+              <span>{$out}</span>
+          </div>
+    </div>
+
+
+</div>
+HTML
+        );
+    }
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/DataBar.png


+ 92 - 0
UCore/DcatAdmin/Metrics/Examples/DataLabel.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\Line;
+use Illuminate\Http\Request;
+
+/**
+ * 显示数值图表
+ * apex-charts
+ */
+class DataLabel extends Line
+{
+
+    /**
+     * 初始化卡片内容
+     *
+     * @return void
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $this->title('任务运行');
+        $this->height(300);
+        $this->chartHeight(220);
+
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+
+
+        // 图表数据
+        $this->withChart([ 28, 40, 36, 52, 38, 60, 55 ], [ 1, 2, 3, 4, 5, 6, 7 ]);
+
+
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $data, array $categories)
+    {
+        $this->chart([
+                         'chart'      => [
+                             'type'    => 'area',
+                             'toolbar' => [
+                                 'show' => false,
+                             ],
+                         ],
+                         'series'     => [
+                             [
+                                 'name' => $this->title,
+                                 'data' => $data,
+                             ],
+                         ],
+                         'dataLabels' => [
+                             'enabled' => true
+                         ],
+                         'xaxis'      => [
+                             'type'       => 'number',
+                             'categories' => $categories,
+                             'labels'     => [
+                                 'show' => true,
+                             ],
+                             'axisBorder' => [
+                                 'show' => true,
+                             ],
+                         ],
+                         'tooltip'    => [
+                             'x' => [
+                                 'show' => true
+                             ]
+                         ],
+
+                     ]);
+    }
+
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/DataLabel.png


+ 87 - 0
UCore/DcatAdmin/Metrics/Examples/DataLabel2.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\Line;
+use Illuminate\Http\Request;
+
+/**
+ * 显示数值图表
+ * apex-charts
+ */
+class DataLabel2 extends Line
+{
+
+    /**
+     * 初始化卡片内容
+     *
+     * @return void
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $this->title('任务运行');
+        $this->height(300);
+        $this->chartHeight(220);
+
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+
+
+        // 图表数据
+        $this->withChart([ 28, 40, 36, 52, 38, 60, 55 ], [ 1, 2, 3, 4, 5, 6, 7 ]);
+
+
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $series, array $categories)
+    {
+        $this->chart([
+                         'chart'      => [
+                             'type'    => 'area',
+                             'toolbar' => [
+                                 'show' => false,
+                             ],
+                         ],
+                         'series'     => $series,
+                         'dataLabels' => [
+                             'enabled' => true
+                         ],
+                         'xaxis'      => [
+                             'type'       => 'number',
+                             'categories' => $categories,
+                             'labels'     => [
+                                 'show' => true,
+                             ],
+                             'axisBorder' => [
+                                 'show' => true,
+                             ],
+                         ],
+                         'tooltip'    => [
+                             'x' => [
+                                 'show' => true
+                             ]
+                         ],
+
+                     ]);
+    }
+
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/DataLabel2.png


+ 109 - 0
UCore/DcatAdmin/Metrics/Examples/DataNumber.php

@@ -0,0 +1,109 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use App\Module\Order\Enums\Status;
+use App\Module\Order\Model\Order;
+use App\Module\Wallet\Guidance;
+use Carbon\Carbon;
+use Dcat\Admin\Widgets\Metrics\Line;
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+use UCore\Helper\Cache;
+use Illuminate\Http\Request;
+use Illuminate\Support\Str;
+
+/**
+ * 显示多个数值
+ * 两行
+ *
+ */
+class DataNumber extends RadialBar
+{
+
+    protected $contentWidth = [12, 0];
+
+    protected $chartPullRight =true;
+
+    /**
+     * 初始化卡片内容
+     */
+    protected function init()
+    {
+        $this->id('metric-card-'.Str::random(8));
+        $this->class('card');
+        $this->height(220);
+        $this->dropdown([
+                            '1' => '最近 1 天',
+                            '7' => '最近 7 天',
+                            '30' => '最近 30 天',
+                            '90' => '最近 90 天',
+                        ]);
+    }
+
+
+
+    /**
+     * 卡片内容
+     *
+     * @param string $count
+     *
+     * @return $this
+     */
+    public function withContent($dataList)
+    {
+        $string = '';
+        foreach ($dataList as $key => $value){
+
+            $string.= <<<HTML
+<div class="text-center" style="font-weight: 600">
+    <h4>{$key}</h4>
+    <span class="font-md-5" style="min-width: 90px;">{$value}</span>
+</div>
+
+HTML;
+        }
+        return $this->content(
+            <<<HTML
+<div class="d-flex justify-content-between p-1 ">
+$string
+</div>
+
+
+HTML
+        );
+    }
+
+    /**
+     * 卡片底部内容.
+     *
+     * @param string $new
+     * @param string $open
+     * @param string $response
+     *
+     * @return $this
+     */
+    public function withFooter($dataList  )
+    {
+        $string = '';
+        foreach ($dataList as $key => $value) {
+
+            $string .= <<<HTML
+ <div class="text-center">
+        <p>$key</p>
+        <span class="font-md-5">{$value}</span>
+    </div>
+
+HTML;
+        }
+
+        return $this->footer(
+            <<<HTML
+<div class="d-flex justify-content-between p-1" style="padding-top: 0!important;">
+ $string
+</div>
+HTML
+        );
+    }
+
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/DataNumber.png


+ 47 - 0
UCore/DcatAdmin/Metrics/Examples/Link.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Box;
+use Dcat\Admin\Widgets\Metrics\Card;
+use Dcat\Admin\Widgets\Markdown;
+
+class Link extends Box
+{
+
+    private $link;
+    public function __construct($title = '链接', $link = '')
+    {
+        $this->title($title);
+        $this->link =$link;
+        $content = $this->link2content($link);
+
+        parent::__construct($title, $content);
+    }
+
+    public function link2content($link)
+    {
+
+        return "<a href='$link' >{$this->title}</a>";
+    }
+
+    public function newopen()
+    {
+        $link = $this->link;
+        $this->content = "<a href='$link' target=\"_blank\" >{$this->title}</a>";
+        return $this;
+    }
+
+    /**
+     * 设置链接
+     * @param $link
+     * @return $this
+     */
+    public function setLink($link)
+    {
+        $content = $this->link2content($link);
+        $this->content($content);
+
+        return $this;
+    }
+}

+ 96 - 0
UCore/DcatAdmin/Metrics/Examples/ListDataColor.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use App\Module\Transfer\Enums\TStatus;
+use App\Module\Transfer\Enums\TType;
+use App\Module\Transfer\Model\TransferOrder;
+use Carbon\Carbon;
+use UCore\Helper\Cache;
+use UCore\Helper\Bc;
+use Illuminate\Http\Request;
+
+/**
+ * 系统报警
+ * Class Alarm
+ *
+ */
+class ListDataColor extends \UCore\DcatAdmin\Metrics\Examples\Round
+{
+
+    protected $height = 150;
+
+    /**
+     * 内容宽度.
+     *
+     * @var array
+     */
+    protected $contentWidth = [ 12, 0 ];
+
+    const TYPE_ERROR   = 'text-danger';
+
+    const TYPE_WARNING = 'text-warning';
+
+    const TYPE_OK      = 'text-primary';
+
+    /**
+     * 初始化卡片内容
+     */
+    protected function init()
+    {
+        parent::init();
+        $this->chart= null;
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+        $data = $this->getData();
+        // 卡片内容
+        $this->withContent($data);
+    }
+
+
+
+    /**
+     * 卡片内容.
+     *
+     * @param int $finished
+     * @param int $pending
+     * @param int $rejected
+     *
+     * @return $this
+     */
+    public function withContent($data)
+    {
+        $string = '';
+        foreach ($data as $key => $value) {
+
+            $string .= <<<HTML
+<div class="chart-info d-flex justify-content-between mb-1 {$value['type']}" >
+  <div class="series-info d-flex align-items-center">
+      <i class="fa fa-circle-o text-bold-700 "></i>
+      <span class="text-bold-600 ml-50">{$value['title']}</span>
+  </div>
+  <div class="product-result">
+      <span>{$value['value']}</span>
+  </div>
+</div>
+HTML;
+        }
+        return $this->content(
+            <<<HTML
+<div class="col-12 d-flex flex-column flex-wrap text-center" >
+    $string
+</div>
+HTML
+        );
+    }
+
+}

+ 100 - 0
UCore/DcatAdmin/Metrics/Examples/NewDevices.php

@@ -0,0 +1,100 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Widgets\Metrics\Donut;
+
+class NewDevices extends Donut
+{
+    protected $labels = ['Desktop', 'Mobile'];
+
+    /**
+     * 初始化卡片内容
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $color = Admin::color();
+        $colors = [$color->primary(), $color->alpha('blue2', 0.5)];
+
+        $this->title('New Devices');
+        $this->subTitle('Last 30 days');
+        $this->chartLabels($this->labels);
+        // 设置图表颜色
+        $this->chartColors($colors);
+    }
+
+    /**
+     * 渲染模板
+     *
+     * @return string
+     */
+    public function render()
+    {
+        $this->fill();
+
+        return parent::render();
+    }
+
+    /**
+     * 写入数据.
+     *
+     * @return void
+     */
+    public function fill()
+    {
+        $this->withContent(44.9, 28.6);
+
+        // 图表数据
+        $this->withChart([44.9, 28.6]);
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $data)
+    {
+        return $this->chart([
+            'series' => $data
+        ]);
+    }
+
+    /**
+     * 设置卡片头部内容.
+     *
+     * @param mixed $desktop
+     * @param mixed $mobile
+     *
+     * @return $this
+     */
+    protected function withContent($desktop, $mobile)
+    {
+        $blue = Admin::color()->alpha('blue2', 0.5);
+
+        $style = 'margin-bottom: 8px';
+        $labelWidth = 120;
+
+        return $this->content(
+            <<<HTML
+<div class="d-flex pl-1 pr-1 pt-1" style="{$style}">
+    <div style="width: {$labelWidth}px">
+        <i class="fa fa-circle text-primary"></i> {$this->labels[0]}
+    </div>
+    <div>{$desktop}</div>
+</div>
+<div class="d-flex pl-1 pr-1" style="{$style}">
+    <div style="width: {$labelWidth}px">
+        <i class="fa fa-circle" style="color: $blue"></i> {$this->labels[1]}
+    </div>
+    <div>{$mobile}</div>
+</div>
+HTML
+        );
+    }
+}

+ 108 - 0
UCore/DcatAdmin/Metrics/Examples/NewUsers.php

@@ -0,0 +1,108 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\Line;
+use Illuminate\Http\Request;
+
+class NewUsers extends Line
+{
+    /**
+     * 初始化卡片内容
+     *
+     * @return void
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $this->title('New Users');
+        $this->dropdown([
+            '7' => 'Last 7 Days',
+            '28' => 'Last 28 Days',
+            '30' => 'Last Month',
+            '365' => 'Last Year',
+        ]);
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+        $generator = function ($len, $min = 10, $max = 300) {
+            for ($i = 0; $i <= $len; $i++) {
+                yield mt_rand($min, $max);
+            }
+        };
+
+        switch ($request->get('option')) {
+            case '365':
+                // 卡片内容
+                $this->withContent(mt_rand(1000, 5000).'k');
+                // 图表数据
+                $this->withChart(collect($generator(30))->toArray());
+                break;
+            case '30':
+                // 卡片内容
+                $this->withContent(mt_rand(400, 1000).'k');
+                // 图表数据
+                $this->withChart(collect($generator(30))->toArray());
+                break;
+            case '28':
+                // 卡片内容
+                $this->withContent(mt_rand(400, 1000).'k');
+                // 图表数据
+                $this->withChart(collect($generator(28))->toArray());
+                break;
+            case '7':
+            default:
+                // 卡片内容
+                $this->withContent('89.2k');
+                // 图表数据
+                $this->withChart([28, 40, 36, 52, 38, 60, 55,]);
+        }
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $data)
+    {
+        return $this->chart([
+            'series' => [
+                [
+                    'name' => $this->title,
+                    'data' => $data,
+                ],
+            ],
+        ]);
+    }
+
+    /**
+     * 设置卡片内容.
+     *
+     * @param string $content
+     *
+     * @return $this
+     */
+    public function withContent($content)
+    {
+        return $this->content(
+            <<<HTML
+<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
+    <h2 class="ml-1 font-lg-1">{$content}</h2>
+    <span class="mb-0 mr-1 text-80">{$this->title}</span>
+</div>
+HTML
+        );
+    }
+}

+ 67 - 0
UCore/DcatAdmin/Metrics/Examples/Number.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\Card;
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+use Illuminate\Http\Request;
+
+class Number extends Card
+{
+    protected $height = 140;
+    protected $title ='Number';
+    public function __construct($title = null, $icon = null)
+    {
+
+        if($title){
+            $this->title($title);
+        }
+        if($icon){
+            $this->icon($icon);
+        }
+
+
+        if ($options = $this->defaultChartOptions()) {
+            $this->chartOptions = $options;
+        }
+
+        $this->init();
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+
+        $this->withContent(162);
+
+    }
+
+
+
+
+    /**
+     * 卡片内容
+     *
+     * @param string $content
+     *
+     * @return $this
+     */
+    public function withContent($content)
+    {
+        return $this->content(
+            <<<HTML
+<div class="d-flex flex-column flex-wrap text-center">
+    <h1 class="font-lg-2 mt-2 mb-0">{$content}</h1>
+</div>
+HTML
+        );
+    }
+
+
+}

+ 66 - 0
UCore/DcatAdmin/Metrics/Examples/Number1.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\Card;
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+use Illuminate\Http\Request;
+
+class Number1 extends Card
+{
+    protected $height = 140;
+    protected $title ='Number';
+    public function __construct($title=null, $icon = null)
+    {
+        if($title){
+            $this->title($title);
+        }
+        if($icon){
+            $this->icon($icon);
+        }
+
+
+        if ($options = $this->defaultChartOptions()) {
+            $this->chartOptions = $options;
+        }
+
+        $this->init();
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+
+        $this->withContent(162);
+
+    }
+
+
+
+
+    /**
+     * 卡片内容
+     *
+     * @param string $content
+     *
+     * @return $this
+     */
+    public function withContent($content)
+    {
+        return $this->content(
+            <<<HTML
+<div class="d-flex flex-column flex-wrap text-center">
+    <h1 class="font-lg-1 mt-2 mb-0">{$content}</h1>
+</div>
+HTML
+        );
+    }
+
+
+}

+ 70 - 0
UCore/DcatAdmin/Metrics/Examples/NumberS.php

@@ -0,0 +1,70 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\Card;
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+use Illuminate\Http\Request;
+
+/**
+ *
+ * 数据统计,多个数字,竖向
+ */
+class NumberS extends Card
+{
+
+    protected $height = 140;
+
+    protected $title = 'Number';
+
+    public function __construct()
+    {
+
+        if ($options = $this->defaultChartOptions()) {
+            $this->chartOptions = $options;
+        }
+
+        $this->init();
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+
+        $this->withContent(162);
+
+    }
+
+
+    /**
+     * 卡片内容
+     *
+     * @param string $contents 键值对 title=>number
+     *
+     * @return $this
+     */
+    public function withContent(array $contents)
+    {
+        $string = '';
+        foreach ($contents as $title => $number) {
+            $c = new Number($title);
+            $c->withContent($number);
+//            $string .= <<<HTML
+//<div class="d-flex flex-column flex-wrap text-center">
+//    <h1 class="font-lg-2 mt-2 mb-0">{$content}</h1>
+//</div>
+//HTML;
+            $string.= $c->render();
+        }
+
+        return $this->content($string);
+    }
+
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/NumberS.png


+ 71 - 0
UCore/DcatAdmin/Metrics/Examples/NumberS2.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+use Illuminate\Support\Str;
+
+/**
+ * 显示多个数值
+ * 一行
+ */
+class NumberS2 extends RadialBar
+{
+
+    protected $contentWidth = [12, 0];
+
+    protected $chartPullRight =true;
+
+    protected $decimal_places = 2;
+    /**
+     * 初始化卡片内容
+     */
+    protected function init()
+    {
+        $this->id('metric-card-'.Str::random(8));
+        $this->class('card');
+        $this->height(130);
+        $this->dropdown([
+                            '1' => '最近 1 天',
+                            '7' => '最近 7 天',
+                            '30' => '最近 30 天',
+                            '90' => '最近 90 天',
+                        ]);
+    }
+
+    /**
+     * 卡片内容.
+     *
+     * @param string $new
+     * @param string $open
+     * @param string $response
+     *
+     * @return $this
+     */
+    public function withContent($dataList  )
+    {
+        $string = '';
+        foreach ($dataList as $key => $value) {
+            $value = number_format(floatval( $value), $this->decimal_places);
+
+            $string .= <<<HTML
+ <div class="text-center">
+        <p>$key</p>
+        <span class="font-md-5">{$value}</span>
+    </div>
+
+HTML;
+        }
+
+        return $this->content(
+            <<<HTML
+<div class="d-flex justify-content-between p-1" style="padding-top: 15px !important;">
+ $string
+</div>
+HTML
+        );
+    }
+
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/NumberS2.png


+ 114 - 0
UCore/DcatAdmin/Metrics/Examples/ProductOrders.php

@@ -0,0 +1,114 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\Round;
+use Illuminate\Http\Request;
+
+class ProductOrders extends Round
+{
+    /**
+     * 初始化卡片内容
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $this->title('Product Orders');
+        $this->chartLabels(['Finished', 'Pending', 'Rejected']);
+        $this->dropdown([
+            '7' => 'Last 7 Days',
+            '28' => 'Last 28 Days',
+            '30' => 'Last Month',
+            '365' => 'Last Year',
+        ]);
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+        switch ($request->get('option')) {
+            case '365':
+            case '30':
+            case '28':
+            case '7':
+            default:
+                // 卡片内容
+                $this->withContent(23043, 14658, 4758);
+
+                // 图表数据
+                $this->withChart([70, 52, 26]);
+
+                // 总数
+                $this->chartTotal('Total', 344);
+        }
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $data)
+    {
+        return $this->chart([
+            'series' => $data,
+        ]);
+    }
+
+    /**
+     * 卡片内容.
+     *
+     * @param int $finished
+     * @param int $pending
+     * @param int $rejected
+     *
+     * @return $this
+     */
+    public function withContent($finished, $pending, $rejected)
+    {
+        return $this->content(
+            <<<HTML
+<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
+    <div class="chart-info d-flex justify-content-between mb-1 mt-2" >
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-primary"></i>
+              <span class="text-bold-600 ml-50">Finished</span>
+          </div>
+          <div class="product-result">
+              <span>{$finished}</span>
+          </div>
+    </div>
+
+    <div class="chart-info d-flex justify-content-between mb-1">
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-warning"></i>
+              <span class="text-bold-600 ml-50">Pending</span>
+          </div>
+          <div class="product-result">
+              <span>{$pending}</span>
+          </div>
+    </div>
+
+     <div class="chart-info d-flex justify-content-between mb-1">
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-danger"></i>
+              <span class="text-bold-600 ml-50">Rejected</span>
+          </div>
+          <div class="product-result">
+              <span>{$rejected}</span>
+          </div>
+    </div>
+</div>
+HTML
+        );
+    }
+}

+ 152 - 0
UCore/DcatAdmin/Metrics/Examples/Ranking.php

@@ -0,0 +1,152 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+use Illuminate\Http\Request;
+use Illuminate\Support\Str;
+
+
+/**
+ * 排行榜
+ *
+ */
+class Ranking extends RadialBar
+{
+
+    protected $chartPullRight = false;
+
+    protected $contentWidth = [ 11, 0 ];
+
+
+    /**
+     * 排行榜 排名颜色
+     *
+     * @var string[]
+     */
+    protected $rankClass = [
+        'text-primary',
+        'text-warning',
+        'text-danger',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+        'text-secondary',
+    ];
+
+    /**
+     * 初始化卡片内容
+     */
+    protected function init()
+    {
+
+        $this->id('metric-card-' . Str::random(8));
+        $this->class('card');
+
+        // $this->title('订单排行榜');
+        $this->dropdown([
+                            '1'  => '最近 1 天',
+                            '7'  => '最近 7 天',
+                            '14' => '最近 14 天',
+                            '30' => '最近 30 天',
+                            '90' => '最近 90 天'
+
+                        ]);
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+        $data = $this->getData($request->get('option', 1));
+
+        // 卡片内容
+        $this->withContent($data);
+
+    }
+
+
+    /**
+     * 卡片内容.
+     *
+     * @param int $finished
+     * @param int $pending
+     * @param int $rejected
+     *
+     * @return $this
+     */
+    public function withContent($list)
+    {
+
+        $listString = '';
+        foreach ($list as $i => $value) {
+            $rank       = $value['rank'];
+            $color      = $this->rankClass[$i];
+            $name       = $value['title'];
+            $number     = $value['number'];
+            $listString .= <<<HTML
+    <div class="chart-info d-flex justify-content-between mb-1 mr-1" >
+          <div class="series-info d-flex align-items-center">
+              <i class=" $color" style="width: 20px"> {$rank} </i>
+              &nbsp;&nbsp;
+              <span class="text-bold-600 ml-50"> {$name} </span>
+          </div>
+          <div class="product-result">
+              <span>{$number}</span>
+          </div>
+    </div>
+HTML;
+        }
+
+        return $this->content(
+            <<<HTML
+
+<div class="col-12 d-flex flex-column flex-wrap mt-1 text-center" style="padding-left:16px;padding-right:0px;">
+$listString
+</div>
+HTML
+        );
+
+
+    }
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/Ranking.png


+ 64 - 0
UCore/DcatAdmin/Metrics/Examples/Reload.php

@@ -0,0 +1,64 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Widgets\Metrics\Card;
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+use Dcat\Admin\Widgets\Widget;
+use Illuminate\Http\Request;
+
+class Reload extends Widget
+{
+
+    protected $title = 'Reload';
+    protected $view = 'admin_core.metrics.reload';
+
+    /**
+     * 刷新时间
+     * @var int
+     */
+    protected $sRoload = 60 ;
+
+    /**
+     * 弹出提示
+     *
+     * @var bool
+     */
+    public $notice = false;
+
+    public function __construct()
+    {
+        $ms = $this->sRoload * 1000;
+        $script = <<<JS
+// js
+if(typeof reloadindex == 'undefined'){
+    var reloads = {$this->sRoload};
+         var notice  = '{$this->notice}';
+    var reloadindex = setInterval(function(){
+        if(reloads  < 0){
+            window.location.reload();
+        }
+        reloads --;
+        $('.reload_2').html(reloads);
+        console.log('reloads:', reloads)
+    }, 1000);
+    if(notice){
+         Dcat.warning('页面将在 {$this->sRoload} 秒后自动刷新', null, {
+                timeOut: 5000, // 5秒后自动消失
+            });
+    }
+
+}
+
+
+
+JS;
+
+        Admin::script($script);
+    }
+
+
+
+
+}

+ 12 - 0
UCore/DcatAdmin/Metrics/Examples/Round.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+/**
+ * 环形图卡片
+ *
+ */
+class Round extends \Dcat\Admin\Widgets\Metrics\Round
+{
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/Round.png


+ 117 - 0
UCore/DcatAdmin/Metrics/Examples/Sessions.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Widgets\Metrics\Bar;
+use Illuminate\Http\Request;
+
+class Sessions extends Bar
+{
+    /**
+     * 初始化卡片内容
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $color = Admin::color();
+
+        $dark35 = $color->dark35();
+
+        // 卡片内容宽度
+        $this->contentWidth(5, 7);
+        // 标题
+        $this->title('Avg Sessions');
+        // 设置下拉选项
+        $this->dropdown([
+            '7' => 'Last 7 Days',
+            '28' => 'Last 28 Days',
+            '30' => 'Last Month',
+            '365' => 'Last Year',
+        ]);
+        // 设置图表颜色
+        $this->chartColors([
+            $dark35,
+            $dark35,
+            $color->primary(),
+            $dark35,
+            $dark35,
+            $dark35
+        ]);
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+        switch ($request->get('option')) {
+            case '7':
+            default:
+                // 卡片内容
+                $this->withContent('2.7k', '+5.2%');
+
+                // 图表数据
+                $this->withChart([
+                    [
+                        'name' => 'Sessions',
+                        'data' => [75, 125, 225, 175, 125, 75, 25],
+                    ],
+                ]);
+        }
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $data)
+    {
+        return $this->chart([
+            'series' => $data,
+        ]);
+    }
+
+    /**
+     * 设置卡片内容.
+     *
+     * @param string $title
+     * @param string $value
+     * @param string $style
+     *
+     * @return $this
+     */
+    public function withContent($title, $value, $style = 'success')
+    {
+        // 根据选项显示
+        $label = strtolower(
+            $this->dropdown[request()->option] ?? 'last 7 days'
+        );
+
+        $minHeight = '183px';
+
+        return $this->content(
+            <<<HTML
+<div class="d-flex p-1 flex-column justify-content-between" style="padding-top: 0;width: 100%;height: 100%;min-height: {$minHeight}">
+    <div class="text-left">
+        <h1 class="font-lg-2 mt-2 mb-0">{$title}</h1>
+        <h5 class="font-medium-2" style="margin-top: 10px;">
+            <span class="text-{$style}">{$value} </span>
+            <span>vs {$label}</span>
+        </h5>
+    </div>
+
+    <a href="#" class="btn btn-primary shadow waves-effect waves-light">View Details <i class="feather icon-chevrons-right"></i></a>
+</div>
+HTML
+        );
+    }
+}

+ 116 - 0
UCore/DcatAdmin/Metrics/Examples/Tickets.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+use Illuminate\Http\Request;
+
+class Tickets extends RadialBar
+{
+    /**
+     * 初始化卡片内容
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $this->title('Tickets');
+        $this->height(400);
+        $this->chartHeight(300);
+        $this->chartLabels('Completed Tickets');
+        $this->dropdown([
+            '7' => 'Last 7 Days',
+            '28' => 'Last 28 Days',
+            '30' => 'Last Month',
+            '365' => 'Last Year',
+        ]);
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+        switch ($request->get('option')) {
+            case '365':
+            case '30':
+            case '28':
+            case '7':
+            default:
+                // 卡片内容
+                $this->withContent(162);
+                // 卡片底部
+                $this->withFooter(29, 63, '1d');
+                // 图表数据
+                $this->withChart(83);
+        }
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param int $data
+     *
+     * @return $this
+     */
+    public function withChart(int $data)
+    {
+        return $this->chart([
+            'series' => [$data],
+        ]);
+    }
+
+    /**
+     * 卡片内容
+     *
+     * @param string $content
+     *
+     * @return $this
+     */
+    public function withContent($content)
+    {
+        return $this->content(
+            <<<HTML
+<div class="d-flex flex-column flex-wrap text-center">
+    <h1 class="font-lg-2 mt-2 mb-0">{$content}</h1>
+    <small>Tickets</small>
+</div>
+HTML
+        );
+    }
+
+    /**
+     * 卡片底部内容.
+     *
+     * @param string $new
+     * @param string $open
+     * @param string $response
+     *
+     * @return $this
+     */
+    public function withFooter($new, $open, $response)
+    {
+        return $this->footer(
+            <<<HTML
+<div class="d-flex justify-content-between p-1" style="padding-top: 0!important;">
+    <div class="text-center">
+        <p>New Tickets</p>
+        <span class="font-lg-1">{$new}</span>
+    </div>
+    <div class="text-center">
+        <p>Open Tickets</p>
+        <span class="font-lg-1">{$open}</span>
+    </div>
+    <div class="text-center">
+        <p>Response Time</p>
+        <span class="font-lg-1">{$response}</span>
+    </div>
+</div>
+HTML
+        );
+    }
+}

BIN
UCore/DcatAdmin/Metrics/Examples/Tickets.png


+ 129 - 0
UCore/DcatAdmin/Metrics/Examples/TotalUsers.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Widgets\Metrics\Card;
+use Illuminate\Contracts\Support\Renderable;
+use Illuminate\Http\Request;
+
+class TotalUsers extends Card
+{
+    /**
+     * 卡片底部内容.
+     *
+     * @var string|Renderable|\Closure
+     */
+    protected $footer;
+
+    /**
+     * 初始化卡片.
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $this->title('Total Users');
+        $this->dropdown([
+            '7' => 'Last 7 Days',
+            '28' => 'Last 28 Days',
+            '30' => 'Last Month',
+            '365' => 'Last Year',
+        ]);
+    }
+
+    /**
+     * 处理请求.
+     *
+     * @param Request $request
+     *
+     * @return void
+     */
+    public function handle(Request $request)
+    {
+        switch ($request->get('option')) {
+            case '365':
+                $this->content(mt_rand(600, 1500));
+                $this->down(mt_rand(1, 30));
+                break;
+            case '30':
+                $this->content(mt_rand(170, 250));
+                $this->up(mt_rand(12, 50));
+                break;
+            case '28':
+                $this->content(mt_rand(155, 200));
+                $this->up(mt_rand(5, 50));
+                break;
+            case '7':
+            default:
+                $this->content(143);
+                $this->up(15);
+        }
+    }
+
+    /**
+     * @param int $percent
+     *
+     * @return $this
+     */
+    public function up($percent)
+    {
+        return $this->footer(
+            "<i class=\"feather icon-trending-up text-success\"></i> {$percent}% Increase"
+        );
+    }
+
+    /**
+     * @param int $percent
+     *
+     * @return $this
+     */
+    public function down($percent)
+    {
+        return $this->footer(
+            "<i class=\"feather icon-trending-down text-danger\"></i> {$percent}% Decrease"
+        );
+    }
+
+    /**
+     * 设置卡片底部内容.
+     *
+     * @param string|Renderable|\Closure $footer
+     *
+     * @return $this
+     */
+    public function footer($footer)
+    {
+        $this->footer = $footer;
+
+        return $this;
+    }
+
+    /**
+     * 渲染卡片内容.
+     *
+     * @return string
+     */
+    public function renderContent()
+    {
+        $content = parent::renderContent();
+
+        return <<<HTML
+<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
+    <h2 class="ml-1 font-lg-1">{$content}</h2>
+</div>
+<div class="ml-1 mt-1 font-weight-bold text-80">
+    {$this->renderFooter()}
+</div>
+HTML;
+    }
+
+    /**
+     * 渲染卡片底部内容.
+     *
+     * @return string
+     */
+    public function renderFooter()
+    {
+        return $this->toString($this->footer);
+    }
+}

+ 207 - 0
UCore/DcatAdmin/Metrics/Examples/TreeMap.php

@@ -0,0 +1,207 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Support\JavaScript;
+use Dcat\Admin\Widgets\Metrics\RadialBar;
+
+/**
+ * 环形图卡片
+ *
+ */
+class TreeMap extends \Dcat\Admin\Widgets\Metrics\RadialBar
+{
+
+    /**
+     * @var array
+     */
+    protected $options = [
+        'icon'     => null,
+        'title'    => null,
+        'header'   => null,
+        'content'  => null,
+        'footer'   => null,
+        'dropdown' => [],
+    ];
+
+    /**
+     * 卡片高度.
+     *
+     * @var int
+     */
+    protected $height = 250;
+
+    /**
+     * 图表高度.
+     *
+     * @var int
+     */
+    protected $chartHeight = 210;
+
+    /**
+     * 内容宽度.
+     *
+     * @var array
+     */
+    protected $contentWidth = [ 5, 7 ];
+
+    /**
+     * 图表上间距.
+     *
+     * @var int
+     */
+    protected $chartMarginTop = -10;
+
+    /**
+     * 图表下间距.
+     *
+     * @var int
+     */
+    protected $chartMarginBottom = -20;
+
+    /**
+     * 图表默认配置.
+     *
+     * @return array
+     */
+    protected function defaultChartOptions()
+    {
+
+        return [
+            'chart' => [
+                'height' => 200,
+                'type'   => 'treemap',
+            ],
+            'legend'      => [
+                'show' => false,
+            ],
+            'plotOptions' => [
+                'treemap' => [
+                    'distributed'  => true,
+                    'enableShades' => false
+                ]
+            ],
+        ];
+    }
+
+    /**
+     * 设置圆圈宽度.
+     *
+     * @param int $size
+     * @return $this
+     */
+    public function chartRadialBarSize(int $size)
+    {
+        return $this->chartOption('plotOptions.radialBar.size', $size);
+    }
+
+    /**
+     * 设置圆圈间距.
+     *
+     * @param int $margin
+     * @return $this
+     */
+    public function chartRadialBarMargin(int $margin)
+    {
+        return $this->chartOption('plotOptions.radialBar.track.margin', $margin);
+    }
+
+    /**
+     * 设置图表统计总数信息.
+     *
+     * @param string $label
+     * @param int $number
+     * @return $this
+     */
+    public function chartTotal(string $label, int $number)
+    {
+        return $this->chartOption('plotOptions.radialBar.dataLabels.total', [
+            'show'      => true,
+            'label'     => $label,
+            'formatter' => JavaScript::make("function () { return {$number}; }"),
+        ]);
+    }
+
+
+
+
+
+
+
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data 键值对
+     *
+     * @return $this
+     */
+    public function withChart(array $data)
+    {
+        $data2=[];
+        foreach ($data as $k=>$v){
+            $data2[]=[
+                'y'=>$v,
+                'x'=>$k,
+            ];
+        }
+        return $this->chart([
+                                'series' => [
+                                    'data'=>$data2
+                                ],
+                            ]);
+    }
+
+
+
+    /**
+     * 卡片内容.
+     *
+     * @param int $finished
+     * @param int $pending
+     * @param int $rejected
+     *
+     * @return $this
+     */
+    public function withContent($count, $in,$out)
+    {
+        return $this->content(
+            <<<HTML
+<div class="col-12 d-flex flex-column flex-wrap text-center" style="max-width: 220px">
+    <div class="chart-info d-flex justify-content-between mb-1 mt-2" >
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-primary"></i>
+              <span class="text-bold-600 ml-50">总</span>
+          </div>
+          <div class="product-result">
+              <span>{$count}</span>
+          </div>
+    </div>
+
+    <div class="chart-info d-flex justify-content-between mb-1">
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-warning"></i>
+              <span class="text-bold-600 ml-50">总转入</span>
+          </div>
+          <div class="product-result">
+              <span>{$in}</span>
+          </div>
+    </div>
+      <div class="chart-info d-flex justify-content-between mb-1">
+          <div class="series-info d-flex align-items-center">
+              <i class="fa fa-circle-o text-bold-700 text-danger"></i>
+              <span class="text-bold-600 ml-50">总转出</span>
+          </div>
+          <div class="product-result">
+              <span>{$out}</span>
+          </div>
+    </div>
+
+
+</div>
+HTML
+        );
+    }
+
+}

+ 85 - 0
UCore/DcatAdmin/Metrics/Examples/WaitGo.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Examples;
+
+use Dcat\Admin\Admin;
+use Dcat\Admin\Widgets\Widget;
+
+
+/**
+ * 倒计时跳转
+ *
+ */
+class WaitGo extends Widget
+{
+
+    protected $title = 'WaitGo';
+    protected $view  = 'admin_core.metrics.waitgo';
+
+    /**
+     * 等待秒数
+     *
+     * @var int
+     */
+    protected $sWait = 30;
+
+    /**
+     * 目标网址
+     *
+     * @var string
+     */
+    public $go_url = '';
+
+    /**
+     * 弹出提示
+     *
+     * @var bool
+     */
+    public $notice = false;
+
+    public function __construct($go_url = '', $sWait = 30)
+    {
+        if ($go_url) {
+            $this->go_url = $go_url;
+        }
+        if ($sWait) {
+            $this->sWait = $sWait;
+        }
+
+        $this->variables['sWait'] = $this->sWait;
+        $this->variables['notice'] = $this->notice;
+        $this->variables['go_url'] = $this->go_url;
+
+        $script = <<<JS
+// js
+
+if(typeof waitindex == 'undefined'){
+    window.waitindex_waits = {$this->sWait};
+    var go_url = '{$this->go_url}';
+     var notice  = '{$this->notice}';
+    var waitindex = setInterval(function(){
+        if(waitindex_waits  < 0){
+            clearInterval(waitindex);
+            window.location.replace(go_url);
+        }
+        window.waitindex_waits --;
+        $('.wait_go').html(window.waitindex_waits);
+        console.log('waitindex :', window.waitindex_waits,go_url)
+    }, 1000);
+    if(notice){
+        Dcat.warning('页面将在 {$this->sWait} 秒后前往'+go_url, null, {
+        timeOut: 5000 // 5秒后自动消失
+    });
+    }
+
+}
+
+
+
+JS;
+
+        Admin::script($script);
+    }
+
+
+}

BIN
UCore/DcatAdmin/Metrics/Examples/img.png


BIN
UCore/DcatAdmin/Metrics/Examples/img_1.png


+ 41 - 0
UCore/DcatAdmin/Metrics/Examples/readme.md

@@ -0,0 +1,41 @@
+# 演示
+
+## 总览
+
+
+![1729222465849](img.png)
+
+## 多数字数据 DataNumber
+
+![多数字数据](DataNumber.png)
+
+
+## 多数字数据 - 单行 NumberS2
+
+![NumberS2](NumberS2.png)
+
+## 多数字数据 - 单列 NumberS
+
+![NumberS](NumberS.png)
+## 待标签的走势图 DataLabel
+
+![DataLabel](DataLabel.png)
+
+## 待标签的走势图 - 有参数 DataLabel2
+
+![DataLabel2](DataLabel2.png)
+
+## Tickets
+
+![Tickets](Tickets.png)
+
+## 排行榜 Ranking
+
+![Ranking](Ranking.png)
+
+
+## 圆环型卡片 Round
+![Round](Round.png)
+
+## bar卡片 DataBar
+![DataBar](DataBar.png)

+ 35 - 0
UCore/DcatAdmin/Metrics/Examples/treemap.json

@@ -0,0 +1,35 @@
+{
+    series: [
+        {
+            data: [
+                {
+                    x: 'New Delhi',
+                    y: 218
+                },
+                {
+                    x: 'Kolkata',
+                    y: 149
+                }
+            ]
+        }
+    ],
+
+
+
+
+    colors: [
+        '#3B93A5',
+        '#F7B844',
+        '#ADD8C7',
+        '#EC3C65',
+        '#CDD7B6',
+        '#C1F666',
+        '#D43F97',
+        '#1E5D8C',
+        '#421243',
+        '#7F94B0',
+        '#EF6537',
+        '#C0ADDB'
+    ],
+
+}

+ 37 - 0
UCore/DcatAdmin/Metrics/Image.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics;
+
+use Dcat\Admin\Widgets\Widget;
+
+class Image extends Widget
+{
+
+    protected $view   = 'admin_core.widgets.image';
+    public    $src    = '';
+    public    $height = '100px';
+    public    $width  = '100px';
+
+    public function __construct($imgSrc, $height = '100px', $width ="100px")
+    {
+        $this->src    = $imgSrc;
+        $this->height = $height;
+        $this->width  = $width;
+    }
+
+
+    public function defaultVariables()
+    {
+        return [
+            'src'        => $this->src,
+            'width'      => $this->width,
+            'height' => $this->height,
+            'attributes' => $this->formatHtmlAttributes(),
+            'options'    => $this->options,
+            'class'      => $this->getElementClass(),
+            'selector'   => $this->getElementSelector(),
+        ];
+    }
+
+
+}

+ 19 - 0
UCore/DcatAdmin/Metrics/Sys/JobDui.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Sys;
+
+use UCore\DcatAdmin\Metrics\Examples\Number;
+use Illuminate\Http\Request;
+
+class JobDui extends Number
+{
+        protected $title='等待队列';
+
+
+        public function handle(Request $request)
+        {
+            $count = \App\Module\System\Services\Model\Job::query()
+                ->count();
+            $this->withContent($count);
+        }
+}

+ 98 - 0
UCore/DcatAdmin/Metrics/Sys/JobDuiChart.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Sys;
+
+use App\Module\Statistics\Base;
+use Dcat\Admin\Widgets\Metrics\Line;
+use Illuminate\Http\Request;
+
+/**
+ * 队列运行情况
+ * apex-charts
+ */
+class JobDuiChart extends Line
+{
+
+    /**
+     * 初始化卡片内容
+     *
+     * @return void
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $this->title('任务堆积');
+        $this->height(330);
+        $this->chartHeight(320);
+
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+
+        $list = Base::getList('job', 'wait',20);
+
+        $datas =[];
+        $xd = [];
+        foreach ($list as $value){
+            array_unshift($datas, $value->number);
+            array_unshift($xd, $value->pvar);
+        }
+        // 图表数据
+        $this->withChart($datas,$xd);
+
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $data, array $categories)
+    {
+        $this->chart([
+                         'chart'      => [
+                             'type'    => 'area',
+                             'toolbar' => [
+                                 'show' => false,
+                             ],
+                         ],
+                         'series'     => [
+                             [
+                                 'name' => $this->title,
+                                 'data' => $data,
+                             ],
+                         ],
+                         'dataLabels' => [
+                             'enabled' => true
+                         ],
+                         'xaxis'      => [
+                             'type'       => 'number',
+                             'categories' => $categories,
+                             'labels'     => [
+                                 'show' => true,
+                             ],
+                             'axisBorder' => [
+                                 'show' => true,
+                             ],
+                         ],
+                         'tooltip'    => [
+                             'x' => [
+                                 'show' => true
+                             ]
+                         ],
+                     ]);
+    }
+
+
+}

+ 99 - 0
UCore/DcatAdmin/Metrics/Sys/JobRun.php

@@ -0,0 +1,99 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Sys;
+
+use App\Module\Statistics\Base;
+use Dcat\Admin\Widgets\Metrics\Line;
+use Illuminate\Http\Request;
+
+/**
+ * 队列运行情况
+ * apex-charts
+ */
+class JobRun extends Line
+{
+
+    /**
+     * 初始化卡片内容
+     *
+     * @return void
+     */
+    protected function init()
+    {
+        parent::init();
+
+        $this->title('任务运行');
+        $this->height(300);
+        $this->chartHeight(280);
+
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+
+        $list = Base::getList('job', 'run',20);
+
+        $datas = [];
+        $xd    = [];
+        foreach ($list as $value) {
+            array_unshift($datas, $value->number);
+            array_unshift($xd, $value->pvar);
+
+        }
+        // 图表数据
+        $this->withChart($datas, $xd);
+
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $data, array $categories)
+    {
+        $this->chart([
+                         'chart'      => [
+                             'type'    => 'area',
+                             'toolbar' => [
+                                 'show' => false,
+                             ],
+                         ],
+                         'series'     => [
+                             [
+                                 'name' => $this->title,
+                                 'data' => $data,
+                             ],
+                         ],
+                         'dataLabels' => [
+                             'enabled' => true
+                         ],
+                         'xaxis'      => [
+                             'type'       => 'number',
+                             'categories' => $categories,
+                             'labels'     => [
+                                 'show' => true,
+                             ],
+                             'axisBorder' => [
+                                 'show' => true,
+                             ],
+                         ],
+                         'tooltip'    => [
+                             'x' => [
+                                 'show' => true
+                             ]
+                         ],
+                     ]);
+    }
+
+
+}

+ 20 - 0
UCore/DcatAdmin/Metrics/Sys/JobS3.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Sys;
+
+use UCore\DcatAdmin\Metrics\Examples\Number;
+use Illuminate\Http\Request;
+
+class JobS3 extends Number
+{
+        protected $title='三秒排队';
+
+
+        public function handle(Request $request)
+        {
+            $count = \App\Module\System\Services\Model\Job::query()
+                ->where('available_at','<',time()+3)
+                ->count();
+            $this->withContent($count);
+        }
+}

+ 22 - 0
UCore/DcatAdmin/Metrics/Sys/JobS3Jin.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Sys;
+
+use UCore\DcatAdmin\Metrics\Examples\Number;
+use Illuminate\Http\Request;
+
+class JobS3Jin extends Number
+{
+
+    protected $title = '三秒进入';
+
+
+    public function handle(Request $request)
+    {
+        $count = \App\Module\System\Services\Model\Job::query()
+            ->where('created_at', '>', time() - 3)
+            ->count();
+        $this->withContent($count);
+    }
+
+}

+ 22 - 0
UCore/DcatAdmin/Metrics/Sys/JobS3Run.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\Sys;
+
+use UCore\DcatAdmin\Metrics\Examples\Number;
+use Illuminate\Http\Request;
+
+class JobS3Run extends Number
+{
+        protected $title='三秒运行';
+
+
+        public function handle(Request $request)
+        {
+            $count = \App\Module\System\Services\Model\JobRun::query()
+
+                ->where('created_at','>',time()-3)
+                ->where('status','=','handle')
+                ->count();
+            $this->withContent($count);
+        }
+}

+ 113 - 0
UCore/DcatAdmin/Metrics/User/NewUsers.php

@@ -0,0 +1,113 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\User;
+
+use App\Module\User\Model\User;
+use Carbon\Carbon;
+use Dcat\Admin\Widgets\Metrics\Line;
+use UCore\Helper\Cache;
+use Illuminate\Http\Request;
+
+class NewUsers extends Line
+{
+
+    /**
+     * 初始化卡片内容
+     *
+     * @return void
+     */
+    protected function init()
+    {
+        parent::init();
+        $this->height(300);
+        $this->chartHeight(180);
+
+        $this->title('新用户');
+        $this->dropdown([
+                    '7'  => '最近 7 天',
+                            '14' => '最近 14 天',
+                            '28' => '最近 28 天',
+                            '90' => '最近 90 天',
+                        ]);
+    }
+
+    /**
+     * 处理请求
+     *
+     * @param Request $request
+     *
+     * @return mixed|void
+     */
+    public function handle(Request $request)
+    {
+
+        $data = $this->getData($request->get('option', 7));
+        // 卡片内容
+        $this->withContent($data['count']);
+        // 图表数据
+        $this->withChart($data['list']);
+    }
+
+
+    protected function getData($day)
+    {
+        return Cache::cacheCall([ __CLASS__, __FUNCTION__, $day ], function ($day) {
+
+
+            $data = [
+                ];
+            $data['count'] = User::query()
+                ->where('created_at','>',Carbon::now()->subDays($day))
+                ->count();
+            foreach (range($day,1) as $item){
+                $sub = $item - 1;
+                $data['list'][] = User::query()
+                    ->whereBetween('created_at',[
+                        Carbon::now()->subDays($sub)->startOfDay(),
+                        Carbon::now()->subDays($sub)->endOfDay()
+                    ])
+                    ->count();
+            }
+            return $data;
+        },                      [ $day ], 30);
+    }
+
+    /**
+     * 设置图表数据.
+     *
+     * @param array $data
+     *
+     * @return $this
+     */
+    public function withChart(array $data)
+    {
+        return $this->chart([
+                                'series' => [
+                                    [
+                                        'name' => $this->title,
+                                        'data' => $data,
+                                    ],
+                                ],
+                            ]);
+    }
+
+    /**
+     * 设置卡片内容.
+     *
+     * @param string $content
+     *
+     * @return $this
+     */
+    public function withContent($content)
+    {
+        return $this->content(
+            <<<HTML
+<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
+    <h2 class="ml-1 font-lg-1">{$content}</h2>
+    <span class="mb-0 mr-1 text-80">{$this->title}</span>
+</div>
+HTML
+        );
+    }
+
+}

+ 17 - 0
UCore/DcatAdmin/Metrics/User/Online.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace UCore\DcatAdmin\Metrics\User;
+
+use UCore\DcatAdmin\Metrics\Examples\Number;
+use Illuminate\Http\Request;
+
+class Online extends Number
+{
+        protected $title='在线用户';
+
+
+        public function handle(Request $request)
+        {
+            $this->withContent(\App\Module\User\Online::count());
+        }
+}

Some files were not shown because too many files changed in this diff