index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <el-row :gutter="20">
  3. <el-col :span="4" :xs="24">
  4. <ContentWrap class="h-1/1" style="border: 0">
  5. <DeptTree @node-click="handleDeptNodeClick" />
  6. </ContentWrap>
  7. </el-col>
  8. <el-col :span="20" :xs="24">
  9. <!-- 统计卡片 -->
  10. <el-row :gutter="18" class="mb-4">
  11. <el-col :span="4">
  12. <div style="background-color: #fff; border-radius: 10px">
  13. <div class="stat-card bg-blue-gradient">
  14. <Icon icon="ep:histogram" :size="40" />
  15. <div class="card-title">工单数量</div>
  16. <div class="card-value pt-5">{{
  17. deviceCount.finished + deviceCount.ignore + deviceCount.todo
  18. }}</div>
  19. </div>
  20. </div>
  21. </el-col>
  22. <el-col :span="4">
  23. <div style="background-color: #fff; border-radius: 10px">
  24. <div class="stat-card bg-green-gradient">
  25. <Icon icon="ep:finished" :size="40" />
  26. <div class="card-title">完成数量</div>
  27. <div class="card-value pt-5">{{ deviceCount.finished }}</div>
  28. </div>
  29. </div>
  30. </el-col>
  31. <el-col :span="4">
  32. <div style="background-color: #fff; border-radius: 10px">
  33. <div class="stat-card bg-orange-gradient">
  34. <Icon icon="ep:more-filled" :size="40" />
  35. <div class="card-title">未完成数量</div>
  36. <div class="card-value pt-5">{{ deviceCount.todo }}</div>
  37. </div>
  38. </div>
  39. </el-col>
  40. <el-col :span="4">
  41. <div style="background-color: #fff; border-radius: 10px">
  42. <div class="stat-card bg-green-gradient">
  43. <Icon icon="ep:hide" :size="40" />
  44. <div class="card-title">已忽略</div>
  45. <div class="card-value pt-5">{{ deviceCount.ignore }}</div>
  46. </div>
  47. </div>
  48. </el-col>
  49. <el-col :span="4">
  50. <div style="background-color: #fff; border-radius: 10px">
  51. <div class="stat-card bg-red-gradient">
  52. <Icon icon="ep:bell" :size="40" />
  53. <div class="card-title">异常设备数量</div>
  54. <div class="card-value pt-5">{{ exceptions?.exceptionNum || 0 }}</div>
  55. </div>
  56. </div>
  57. </el-col>
  58. <el-col :span="4">
  59. <div style="background-color: #fff; border-radius: 10px">
  60. <div class="stat-card bg-warn-gradient">
  61. <Icon icon="ep:info-filled" :size="40" />
  62. <div class="card-title">异常点数量</div>
  63. <div class="card-value pt-5">{{ exceptionPoint.value }}</div>
  64. </div>
  65. </div>
  66. </el-col>
  67. </el-row>
  68. <el-row :gutter="20">
  69. <el-col :span="24">
  70. <el-radio-group v-model="dateType" size="default" fill="#409eff">
  71. <el-radio-button label="年" value="year" />
  72. <el-radio-button label="月" value="month" />
  73. <el-radio-button label="日" value="day" />
  74. </el-radio-group>
  75. </el-col>
  76. </el-row>
  77. <!-- 列表 -->
  78. <ContentWrap style="border: 0; margin-top: 10px">
  79. <el-table
  80. v-loading="loading"
  81. :row-class-name="tableRowClassName"
  82. :data="list"
  83. :show-overflow-tooltip="true"
  84. @row-click="handleRowClick"
  85. height="48vh"
  86. >
  87. <el-table-column :label="t('iotDevice.serial')" width="70" align="center">
  88. <template #default="scope">
  89. {{ scope.$index + 1 }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column
  93. :label="t('bomList.name')"
  94. align="center"
  95. prop="inspectOrderTitle"
  96. min-width="300"
  97. />
  98. <el-table-column label="项目" align="center" prop="project" min-width="110" />
  99. <el-table-column label="公司" align="center" prop="company" min-width="110" />
  100. <el-table-column
  101. :label="t('route.orderType')"
  102. align="center"
  103. prop="type"
  104. min-width="90"
  105. />
  106. <el-table-column
  107. :label="t('operationFill.status')"
  108. align="center"
  109. prop="status"
  110. min-width="95"
  111. >
  112. <template #default="scope">
  113. <dict-tag :type="DICT_TYPE.PMS_INSPECT_ORDER_STATUS" :value="scope.row.status" />
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="设备明细" align="center" prop="deviceInfo" min-width="110" />
  117. <el-table-column
  118. :label="t('iotMaintain.PersonInCharge')"
  119. align="center"
  120. prop="chargeName"
  121. min-width="110"
  122. />
  123. <!--
  124. <el-table-column
  125. :label="t('inspect.generateTime')"
  126. align="center"
  127. prop="createTime"
  128. :formatter="dateFormatter"
  129. min-width="180px"
  130. />
  131. <el-table-column
  132. :label="t('inspect.executeTime')"
  133. align="center"
  134. prop="executeDate"
  135. :formatter="dateFormatter"
  136. min-width="180px"
  137. /> -->
  138. <el-table-column
  139. :label="t('iotMaintain.operation')"
  140. align="center"
  141. min-width="160px"
  142. fixed="right"
  143. >
  144. <template #default="scope">
  145. <el-button link type="primary" @click="openForm(scope.row.id)">
  146. 异常巡检点
  147. </el-button>
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. <!-- 分页 -->
  152. <Pagination
  153. :total="total"
  154. v-model:page="queryParams.pageNo"
  155. v-model:limit="queryParams.pageSize"
  156. @pagination="getList"
  157. />
  158. </ContentWrap>
  159. </el-col>
  160. </el-row>
  161. </template>
  162. <script setup lang="ts">
  163. import { IotInspectOrderApi, IotInspectOrderVO } from '@/api/pms/inspect/order'
  164. import { DICT_TYPE } from '@/utils/dict'
  165. import DeptTree from '@/views/system/user/DeptTree.vue'
  166. import { watch } from 'vue'
  167. const { push } = useRouter()
  168. const { params } = useRoute()
  169. /** 巡检工单 列表 */
  170. defineOptions({ name: 'IotInspectOrder' })
  171. const { t } = useI18n() // 国际化
  172. const loading = ref(true) // 列表的加载中
  173. const list = ref<IotInspectOrderVO[]>([]) // 列表的数据
  174. const deptId = params.deptId
  175. const createTime = params.createTime
  176. const total = ref(0) // 列表的总页数
  177. let dateType = ref('year')
  178. const queryParams = reactive({
  179. pageNo: 1,
  180. pageSize: 10,
  181. inspectOrderTitle: undefined,
  182. inspectOrderCode: undefined,
  183. status: undefined,
  184. remark: undefined,
  185. createTime: [],
  186. deptId: undefined,
  187. deviceIds: undefined
  188. })
  189. const queryFormRef = ref() // 搜索的表单
  190. let exceptions = ref(null)
  191. let exceptionPoint = ref([])
  192. let deviceCount = ref([])
  193. const handleDeptNodeClick = async (row) => {
  194. queryParams.deptId = row.id
  195. await getList()
  196. await getCounts()
  197. }
  198. const tableRowClassName = ({ row }) => {
  199. if (row.exceptionCount > 0) {
  200. return 'exception-row'
  201. }
  202. return ''
  203. }
  204. const handleRowClick = (row, column: any, event: Event) => {
  205. // 只有当行有异常时才允许点击跳转
  206. if (row.exceptionCount > 0) {
  207. // 阻止事件冒泡,避免与按钮点击冲突
  208. event.stopPropagation()
  209. push({
  210. name: 'IotInspectItemStat',
  211. query: { orderName: row.inspectOrderTitle }
  212. })
  213. }
  214. }
  215. /** 查询列表 */
  216. const getList = async () => {
  217. loading.value = true
  218. try {
  219. const data = await IotInspectOrderApi.getIotInspectOrderList(queryParams)
  220. list.value = data.list
  221. total.value = data.total
  222. } finally {
  223. loading.value = false
  224. }
  225. }
  226. watch(
  227. dateType,
  228. () => {
  229. const now = new Date()
  230. let startTime: Date
  231. let endTime: Date
  232. switch (dateType.value) {
  233. case 'year':
  234. // 当年:1月1日 00:00:00 到 12月31日 23:59:59
  235. startTime = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0)
  236. endTime = new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999)
  237. break
  238. case 'month':
  239. // 当月:月初 00:00:00 到 月末 23:59:59
  240. startTime = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0, 0)
  241. // 下个月的第0天就是当月的最后一天
  242. endTime = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999)
  243. break
  244. case 'day':
  245. // 当日:当天 00:00:00 到 23:59:59
  246. const year = now.getFullYear()
  247. const month = now.getMonth()
  248. const date = now.getDate()
  249. startTime = new Date(year, month, date, 0, 0, 0, 0)
  250. endTime = new Date(year, month, date, 23, 59, 59, 999)
  251. break
  252. default:
  253. startTime = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0)
  254. endTime = new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999)
  255. }
  256. // 使用本地时间格式化函数,避免时区转换问题
  257. const formatLocalDateTime = (date: Date): string => {
  258. const year = date.getFullYear()
  259. const month = String(date.getMonth() + 1).padStart(2, '0')
  260. const day = String(date.getDate()).padStart(2, '0')
  261. const hours = String(date.getHours()).padStart(2, '0')
  262. const minutes = String(date.getMinutes()).padStart(2, '0')
  263. const seconds = String(date.getSeconds()).padStart(2, '0')
  264. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  265. }
  266. // 设置查询参数 - 使用本地时间格式化
  267. queryParams.createTime = [formatLocalDateTime(startTime), formatLocalDateTime(endTime)]
  268. // 重新获取数据
  269. getList()
  270. getCounts()
  271. },
  272. {
  273. immediate: true
  274. }
  275. )
  276. /** 搜索按钮操作 */
  277. const handleQuery = () => {
  278. queryParams.pageNo = 1
  279. getList()
  280. }
  281. /** 重置按钮操作 */
  282. const resetQuery = () => {
  283. queryFormRef.value.resetFields()
  284. handleQuery()
  285. }
  286. const reasonFormRef = ref(null)
  287. const form = reactive({
  288. id: undefined,
  289. reason: ''
  290. })
  291. // 重置表单
  292. const resetForm = () => {
  293. reasonFormRef.value?.resetFields()
  294. }
  295. /** 添加/修改操作 */
  296. const formRef = ref()
  297. const openForm = (id?: number) => {
  298. push({ name: 'InspectOrderDetail', params: { id } })
  299. }
  300. async function getCounts() {
  301. exceptions.value = await IotInspectOrderApi.getIotInspectOrderExceptionDeviceCount({
  302. deptId: queryParams.deptId,
  303. createTime: queryParams.createTime
  304. })
  305. exceptionPoint.value = await IotInspectOrderApi.getIotInspectOrderExceptionPointCount({
  306. deptId: queryParams.deptId,
  307. createTime: queryParams.createTime
  308. })
  309. deviceCount.value = await IotInspectOrderApi.getInspectItemStatus({
  310. deptId: queryParams.deptId,
  311. createTime: queryParams.createTime
  312. })
  313. }
  314. /** 初始化 **/
  315. onMounted(() => {
  316. getCounts()
  317. if (params.status) {
  318. queryParams.status = params.status
  319. }
  320. if (deptId != null) {
  321. queryParams.deptId = deptId
  322. }
  323. if (createTime) {
  324. queryParams.createTime = createTime
  325. }
  326. getList()
  327. })
  328. </script>
  329. <style scoped>
  330. /* 添加异常行高亮样式 */
  331. :deep(.exception-row) {
  332. background-color: #f29a90 !important;
  333. }
  334. :deep(.exception-row:hover) {
  335. background-color: #fff0e0 !important;
  336. }
  337. .reason-confirm-container {
  338. margin: 20px;
  339. }
  340. /* 调整文本框样式 */
  341. :deep(.el-textarea__inner) {
  342. font-size: 14px;
  343. }
  344. /* 调整表单项间距 */
  345. :deep(.el-form-item) {
  346. margin-bottom: 15px;
  347. }
  348. .stat-card {
  349. padding: 20px;
  350. border-radius: 10px;
  351. color: white;
  352. text-align: center;
  353. font-size: 14px;
  354. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  355. transition:
  356. transform 0.3s ease,
  357. box-shadow 0.3s ease;
  358. backdrop-filter: blur(12px);
  359. height: 200px;
  360. }
  361. .stat-card::before {
  362. position: absolute;
  363. filter: blur(20px);
  364. z-index: -1;
  365. }
  366. .stat-card:hover {
  367. transform: translateY(-4px);
  368. box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  369. }
  370. .card-title {
  371. margin: 8px 0;
  372. font-size: 16px;
  373. }
  374. .card-value {
  375. font-size: 28px;
  376. font-weight: bold;
  377. margin: 8px 0;
  378. }
  379. .card-trend {
  380. font-size: 12px;
  381. opacity: 0.9;
  382. }
  383. /* 毛玻璃渐变背景 —— 不再使用 background-image */
  384. .bg-blue-gradient {
  385. background: linear-gradient(135deg, rgba(77, 147, 255, 0.5), rgba(75, 132, 254));
  386. }
  387. .bg-green-gradient {
  388. background: linear-gradient(135deg, rgba(101, 226, 136, 0.1), #52d7a2);
  389. background-color: rgba(76, 175, 80, 0.1);
  390. }
  391. .bg-orange-gradient {
  392. background: linear-gradient(135deg, rgba(152, 82, 4, 0.5), rgba(255, 152, 4, 0.6));
  393. }
  394. .bg-red-gradient {
  395. background: linear-gradient(135deg, rgba(232, 65, 51), rgba(252, 242, 236));
  396. }
  397. .bg-warn-gradient {
  398. background: linear-gradient(135deg, rgba(255, 201, 103), rgba(243, 162, 152));
  399. }
  400. /* 确保内容不溢出 */
  401. :deep(.el-row) {
  402. flex-wrap: wrap;
  403. }
  404. .text-truncate {
  405. overflow: hidden;
  406. text-overflow: ellipsis;
  407. white-space: nowrap;
  408. }
  409. ::v-deep .el-table__header-wrapper {
  410. position: sticky !important;
  411. width: 100%;
  412. top: 0px;
  413. z-index: 2000;
  414. }
  415. </style>