index.vue 13 KB

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