Data.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <?php
  2. namespace App\Support;
  3. use App\Admin\Repositories\ConsumableRecord;
  4. use App\Admin\Repositories\DeviceRecord;
  5. use App\Admin\Repositories\PartRecord;
  6. use App\Admin\Repositories\ServiceRecord;
  7. use App\Admin\Repositories\SoftwareRecord;
  8. use App\Models\ConsumableCategory;
  9. use App\Models\Department;
  10. use App\Models\DeviceCategory;
  11. use App\Models\PartCategory;
  12. use App\Models\SoftwareCategory;
  13. use App\Models\User;
  14. use Dcat\Admin\Admin;
  15. use Dcat\Admin\Widgets\Alert;
  16. use JetBrains\PhpStorm\ArrayShape;
  17. class Data
  18. {
  19. /**
  20. * 发行方式.
  21. *
  22. * @return string[]
  23. */
  24. #[ArrayShape(['u' => "string", 'o' => "string", 'f' => "string", 'b' => "string"])]
  25. public static function distribution(): array
  26. {
  27. return [
  28. 'u' => '未知',
  29. 'o' => '开源',
  30. 'f' => '免费',
  31. 'b' => '商业授权',
  32. ];
  33. }
  34. /**
  35. * 性别.
  36. *
  37. * @return string[]
  38. */
  39. #[ArrayShape(['无' => "string", '男' => "string", '女' => "string"])]
  40. public static function genders(): array
  41. {
  42. return [
  43. '无' => '无',
  44. '男' => '男',
  45. '女' => '女',
  46. ];
  47. }
  48. /**
  49. * 物件.
  50. *
  51. * @return string[]
  52. */
  53. #[ArrayShape(['DeviceRecord' => "string", 'PartRecord' => "string", 'SoftwareRecord' => "string"])]
  54. public static function items(): array
  55. {
  56. return [
  57. get_class(new \App\Models\DeviceRecord()) => '设备',
  58. get_class(new \App\Models\PartRecord()) => '配件',
  59. get_class(new \App\Models\SoftwareRecord()) => '软件',
  60. ];
  61. }
  62. /**
  63. * 盘点任务状态
  64. *
  65. * @return string[]
  66. */
  67. public static function checkRecordStatus(): array
  68. {
  69. return [
  70. 0 => '进行',
  71. 1 => '完成',
  72. 2 => '中止',
  73. ];
  74. }
  75. /**
  76. * 维修状态
  77. *
  78. * @return string[]
  79. */
  80. public static function maintenanceStatus(): array
  81. {
  82. return [
  83. 0 => '等待处理',
  84. 1 => '处理完毕',
  85. 2 => '取消',
  86. ];
  87. }
  88. /**
  89. * 盘点追踪状态
  90. *
  91. * @return string[]
  92. */
  93. public static function checkTrackStatus(): array
  94. {
  95. return [
  96. 0 => '未盘点',
  97. 1 => '盘到',
  98. 2 => '未盘到',
  99. ];
  100. }
  101. /**
  102. * 服务异常状态
  103. *
  104. * @return string[]
  105. */
  106. public static function serviceIssueStatus(): array
  107. {
  108. return [
  109. 0 => '正常',
  110. 1 => '故障',
  111. 2 => '恢复',
  112. 3 => '暂停',
  113. ];
  114. }
  115. /**
  116. * 软件标签.
  117. *
  118. * @return array
  119. */
  120. #[ArrayShape(['windows' => "string[]", 'macos' => "string[]", 'linux' => "string[]", 'android' => "string[]", 'ios' => "string[]"])]
  121. public static function softwareTags(): array
  122. {
  123. return [
  124. 'windows' => [
  125. 'windows',
  126. 'win10',
  127. 'win8',
  128. 'win7',
  129. ],
  130. 'macos' => [
  131. 'mac',
  132. 'cheetah',
  133. 'puma',
  134. 'jaguar',
  135. 'panther',
  136. 'tiger',
  137. 'leopard',
  138. 'lion',
  139. 'mavericks',
  140. 'yosemite',
  141. 'capitan',
  142. 'sierra',
  143. 'mojave',
  144. 'catalina',
  145. 'bigsur',
  146. ],
  147. 'linux' => [
  148. 'linux',
  149. 'centos',
  150. 'ubuntu',
  151. 'kali',
  152. 'debian',
  153. 'arch',
  154. 'deepin',
  155. ],
  156. 'android' => [
  157. 'cupcake',
  158. 'donut',
  159. 'eclair',
  160. 'froyo',
  161. 'gingerbread',
  162. 'honeycomb',
  163. 'icecreamsandwich',
  164. 'jellybean',
  165. 'kitkat',
  166. 'lollipop',
  167. 'marshmallow',
  168. 'nougat',
  169. 'oreo',
  170. 'pie',
  171. ],
  172. 'ios' => [
  173. 'ios',
  174. ],
  175. ];
  176. }
  177. /**
  178. * 返回不支持操作的错误信息 warning.
  179. *
  180. * @return Alert
  181. */
  182. public static function unsupportedOperationWarning(): Alert
  183. {
  184. $alert = Alert::make('此功能不允许通过此操作实现。', '未提供的操作');
  185. $alert->warning();
  186. $alert->icon('feather icon-alert-triangle');
  187. return $alert;
  188. }
  189. /**
  190. * 返回控制器图标.
  191. *
  192. * @param $string
  193. *
  194. * @return string
  195. */
  196. public static function icon($string): string
  197. {
  198. $array = [
  199. 'record' => '<i class="fa feather icon-list"></i> ',
  200. 'category' => '<i class="fa feather icon-pie-chart"></i> ',
  201. 'track' => '<i class="fa feather icon-archive"></i> ',
  202. 'issue' => '<i class="fa feather icon-alert-triangle"></i> ',
  203. 'user' => '<i class="fa feather icon-users"></i> ',
  204. 'department' => '<i class="fa feather icon-copy"></i> ',
  205. 'role' => '<i class="fa feather icon-users"></i> ',
  206. 'permission' => '<i class="fa feather icon-lock"></i> ',
  207. 'statistics' => '<i class="fa feather icon-bar-chart-2"></i> ',
  208. 'column' => '<i class="fa feather icon-edit-2"></i> ',
  209. 'history' => '<i class="fa feather icon-clock"></i> ',
  210. ];
  211. return $array[$string];
  212. }
  213. /**
  214. * 保固状态
  215. *
  216. * @return string[]
  217. */
  218. #[ArrayShape(['one day' => "string", 'three day' => "string", 'one week' => "string", 'one month' => "string", 'normal' => "string", 'none' => "string", 'default' => "string"])]
  219. public static function expiredStatus(): array
  220. {
  221. return [
  222. 'one day' => '一天内过期',
  223. 'three day' => '三天内过期',
  224. 'one week' => '一周内过期',
  225. 'one month' => '一月内过期',
  226. 'normal' => '正常',
  227. 'none' => '无效的设备',
  228. 'default' => '错误',
  229. ];
  230. }
  231. /**
  232. * 保固状态颜色.
  233. *
  234. * @return array
  235. */
  236. #[ArrayShape(['one day' => "string", 'three day' => "string", 'one week' => "string", 'one month' => "string", 'normal' => "string", 'none' => "string", 'default' => "string"])]
  237. public static function expiredStatusColors(): array
  238. {
  239. return [
  240. 'one day' => 'danger',
  241. 'three day' => 'danger',
  242. 'one week' => 'warning',
  243. 'one month' => 'warning',
  244. 'normal' => 'success',
  245. 'none' => 'primary',
  246. 'default' => Admin::color()->gray(),
  247. ];
  248. }
  249. /**
  250. * 返回时间尺度.
  251. *
  252. * @return string[]
  253. */
  254. #[ArrayShape(['day' => "string", 'month' => "string", 'year' => "string"])]
  255. public static function timeScales(): array
  256. {
  257. return [
  258. 'day' => '天',
  259. 'month' => '月',
  260. 'year' => '年',
  261. ];
  262. }
  263. /**
  264. * 返回emoji.
  265. *
  266. * @return string[]
  267. */
  268. #[ArrayShape(['happy' => "string", 'normal' => "string", 'sad' => "string"])]
  269. public static function emoji(): array
  270. {
  271. return [
  272. 'happy' => '😀 愉快',
  273. 'normal' => '😐 一般',
  274. 'sad' => '😟 悲伤',
  275. ];
  276. }
  277. /**
  278. * 返回优先级的键值对.
  279. *
  280. * @return string[]
  281. */
  282. #[ArrayShape(['high' => "string", 'normal' => "string", 'low' => "string"])]
  283. public static function priority(): array
  284. {
  285. return [
  286. 'high' => '高',
  287. 'normal' => '普通',
  288. 'low' => '低',
  289. ];
  290. }
  291. /**
  292. * 返回自定义字段的类型.
  293. *
  294. * @return string[]
  295. */
  296. #[ArrayShape(['string' => "string", 'date' => "string", 'dateTime' => "string", 'integer' => "string", 'float' => "string", 'double' => "string", 'longText' => "string", 'select' => "string"])]
  297. public static function customColumnTypes(): array
  298. {
  299. return [
  300. 'string' => '字符串',
  301. 'date' => '日期',
  302. 'dateTime' => '日期时间',
  303. 'integer' => '整数',
  304. 'float' => '浮点',
  305. 'double' => '双精度',
  306. 'longText' => '长文本',
  307. 'select' => '选项',
  308. ];
  309. }
  310. /**
  311. * 表名返回资产名.
  312. *
  313. * @return string[]
  314. */
  315. public static function itemNameByTableName(): array
  316. {
  317. return [
  318. (new DeviceRecord())->getTable() => trans('main.device'),
  319. (new PartRecord())->getTable() => trans('main.part'),
  320. (new SoftwareRecord())->getTable() => trans('main.software'),
  321. (new ConsumableRecord())->getTable() => trans('main.consumable'),
  322. (new ServiceRecord())->getTable() => trans('main.service'),
  323. ];
  324. }
  325. /**
  326. * 模型返回资产名.
  327. *
  328. * @return array
  329. */
  330. public static function itemNameByModel(): array
  331. {
  332. return [
  333. get_class(new \App\Models\DeviceRecord()) => trans('main.device'),
  334. get_class(new \App\Models\PartRecord()) => trans('main.part'),
  335. get_class(new \App\Models\SoftwareRecord()) => trans('main.software'),
  336. get_class(new \App\Models\ConsumableRecord()) => trans('main.consumable'),
  337. get_class(new \App\Models\ServiceRecord()) => trans('main.service'),
  338. get_class(new Department()) => trans('main.department'),
  339. get_class(new User()) => trans('main.user'),
  340. get_class(new DeviceCategory()) => trans('main.device_category'),
  341. get_class(new PartCategory()) => trans('main.part_category'),
  342. get_class(new SoftwareCategory()) => trans('main.software_category'),
  343. get_class(new ConsumableCategory()) => trans('main.consumable_category'),
  344. ];
  345. }
  346. /**
  347. * 成功或失败.
  348. *
  349. * @return string[]
  350. */
  351. public static function successOrFail(): array
  352. {
  353. return ['失败', '成功'];
  354. }
  355. }