index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <el-row :gutter="20">
  3. <el-col :span="4" :xs="24">
  4. <ContentWrap class="h-1/1">
  5. <DeptTree @node-click="handleDeptNodeClick" />
  6. </ContentWrap>
  7. </el-col>
  8. <el-col :span="20" :xs="24">
  9. <ContentWrap>
  10. <!-- 搜索工作栏 -->
  11. <el-form
  12. class="-mb-15px"
  13. :model="queryParams"
  14. ref="queryFormRef"
  15. :inline="true"
  16. label-width="68px"
  17. >
  18. <el-form-item :label="t('bomList.name')" prop="inspectOrderTitle">
  19. <el-input
  20. v-model="queryParams.inspectOrderTitle"
  21. :placeholder="t('bomList.nHolder')"
  22. clearable
  23. @keyup.enter="handleQuery"
  24. class="!w-240px"
  25. />
  26. </el-form-item>
  27. <!-- <el-form-item label="工单编码" prop="inspectOrderCode">-->
  28. <!-- <el-input-->
  29. <!-- v-model="queryParams.inspectOrderCode"-->
  30. <!-- placeholder="请输入工单编码"-->
  31. <!-- clearable-->
  32. <!-- @keyup.enter="handleQuery"-->
  33. <!-- class="!w-240px"-->
  34. <!-- />-->
  35. <!-- </el-form-item>-->
  36. <el-form-item :label="t('operationFill.status')" prop="status">
  37. <el-select
  38. v-model="queryParams.status"
  39. :placeholder="t('operationFill.status')"
  40. clearable
  41. class="!w-240px"
  42. >
  43. <el-option
  44. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_INSPECT_ORDER_STATUS)"
  45. :key="dict.value"
  46. :label="dict.label"
  47. :value="dict.value"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="创建时间" prop="createTime">
  52. <el-date-picker
  53. v-model="queryParams.createTime"
  54. value-format="YYYY-MM-DD HH:mm:ss"
  55. type="daterange"
  56. start-placeholder="开始日期"
  57. end-placeholder="结束日期"
  58. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  59. class="!w-220px"
  60. />
  61. </el-form-item>
  62. <el-form-item>
  63. <el-button @click="handleQuery"
  64. ><Icon icon="ep:search" class="mr-5px" /> {{ t('operationFill.search') }}</el-button
  65. >
  66. <el-button @click="resetQuery"
  67. ><Icon icon="ep:refresh" class="mr-5px" /> {{ t('operationFill.reset') }}</el-button
  68. >
  69. <!-- <el-button-->
  70. <!-- type="primary"-->
  71. <!-- plain-->
  72. <!-- @click="openForm('create')"-->
  73. <!-- v-hasPermi="['rq:iot-inspect-order:create']"-->
  74. <!-- >-->
  75. <!-- <Icon icon="ep:plus" class="mr-5px" /> 新增-->
  76. <!-- </el-button>-->
  77. <el-button
  78. type="success"
  79. plain
  80. @click="handleExport"
  81. :loading="exportLoading"
  82. v-hasPermi="['rq:iot-inspect-order:export']"
  83. >
  84. <Icon icon="ep:download" class="mr-5px" /> 导出
  85. </el-button>
  86. </el-form-item>
  87. </el-form>
  88. </ContentWrap>
  89. <!-- 列表 -->
  90. <ContentWrap>
  91. <el-table
  92. v-loading="loading"
  93. :data="list"
  94. :stripe="true"
  95. height="65vh"
  96. :show-overflow-tooltip="true"
  97. >
  98. <el-table-column :label="t('iotDevice.serial')" width="70" align="center">
  99. <template #default="scope">
  100. {{ scope.$index + 1 }}
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. :label="t('bomList.name')"
  105. align="center"
  106. prop="inspectOrderTitle"
  107. min-width="300"
  108. />
  109. <!-- <el-table-column label="工单编码" align="center" prop="inspectOrderCode" />-->
  110. <el-table-column
  111. :label="t('route.orderType')"
  112. align="center"
  113. prop="type"
  114. min-width="90"
  115. />
  116. <el-table-column
  117. :label="t('operationFill.status')"
  118. align="center"
  119. prop="status"
  120. min-width="95"
  121. >
  122. <template #default="scope">
  123. <dict-tag :type="DICT_TYPE.PMS_INSPECT_ORDER_STATUS" :value="scope.row.status" />
  124. </template>
  125. </el-table-column>
  126. <el-table-column
  127. :label="t('iotMaintain.PersonInCharge')"
  128. align="center"
  129. prop="chargeName"
  130. min-width="110"
  131. />
  132. <el-table-column
  133. :label="t('inspect.deviceCount')"
  134. align="center"
  135. prop="deviceCount"
  136. min-width="100"
  137. >
  138. <template #default="scope">
  139. <el-tag type="info"> {{ scope.row.deviceCount }}</el-tag>
  140. </template>
  141. </el-table-column>
  142. <el-table-column
  143. :label="t('inspect.needDevice')"
  144. align="center"
  145. prop="needDevice"
  146. min-width="100"
  147. >
  148. <template #default="scope">
  149. <el-tag type="success"> {{ scope.row.needDevice }}</el-tag>
  150. </template>
  151. </el-table-column>
  152. <el-table-column
  153. :label="t('inspect.exceptionCount')"
  154. align="center"
  155. prop="exceptionCount"
  156. min-width="100"
  157. >
  158. <template #default="scope">
  159. <el-tag type="danger"> {{ scope.row.exceptionCount }}</el-tag>
  160. </template>
  161. </el-table-column>
  162. <!-- <el-table-column label="备注" align="center" prop="remark" />-->
  163. <el-table-column
  164. :label="t('inspect.generateTime')"
  165. align="center"
  166. prop="createTime"
  167. :formatter="dateFormatter"
  168. min-width="180px"
  169. />
  170. <el-table-column
  171. :label="t('inspect.executeTime')"
  172. align="center"
  173. prop="executeDate"
  174. :formatter="dateFormatter"
  175. min-width="180px"
  176. />
  177. <el-table-column
  178. :label="t('iotMaintain.operation')"
  179. align="center"
  180. min-width="160px"
  181. fixed="right"
  182. >
  183. <template #default="scope">
  184. <el-button link type="primary" @click="openForm(scope.row.id)">
  185. {{ t('operationFill.view') }}
  186. </el-button>
  187. <el-button
  188. v-if="scope.row.status === 'todo'"
  189. link
  190. type="primary"
  191. @click="openWrite(scope.row.id)"
  192. v-hasPermi="['rq:iot-inspect-order:update']"
  193. >
  194. {{ t('operationFill.fill') }}
  195. </el-button>
  196. <el-button
  197. link
  198. type="warning"
  199. v-if="scope.row.status === 'todo'"
  200. @click="openDialog(scope.row.id)"
  201. >
  202. {{ t('inspect.ignore') }}
  203. </el-button>
  204. <!-- <el-button link type="primary" @click="openForm(scope.row.id)"> {{ t('inspect.ignore') }} </el-button>-->
  205. </template>
  206. </el-table-column>
  207. </el-table>
  208. <el-dialog
  209. v-model="dialogVisible"
  210. title="忽略理由"
  211. :width="600"
  212. :before-close="handleClose"
  213. append-to-body
  214. :close-on-click-modal="false"
  215. >
  216. <el-form ref="reasonFormRef" :model="form" :rules="rules" label-width="60px">
  217. <el-form-item label="理由" prop="reason">
  218. <el-input
  219. type="textarea"
  220. v-model="form.reason"
  221. placeholder="请输入忽略理由"
  222. :rows="4"
  223. resize="none"
  224. />
  225. </el-form-item>
  226. </el-form>
  227. <template #footer>
  228. <el-button @click="handleCancel">取消</el-button>
  229. <el-button type="primary" @click="handleConfirm">确定</el-button>
  230. </template>
  231. </el-dialog>
  232. <!-- 分页 -->
  233. <Pagination
  234. :total="total"
  235. v-model:page="queryParams.pageNo"
  236. v-model:limit="queryParams.pageSize"
  237. @pagination="getList"
  238. />
  239. </ContentWrap>
  240. </el-col>
  241. </el-row>
  242. <!-- 表单弹窗:添加/修改 -->
  243. <IotInspectOrderForm ref="formRef" @success="getList" />
  244. </template>
  245. <script setup lang="ts">
  246. import { dateFormatter } from '@/utils/formatTime'
  247. import download from '@/utils/download'
  248. import { IotInspectOrderApi, IotInspectOrderVO } from '@/api/pms/inspect/order'
  249. import IotInspectOrderForm from './IotInspectOrderForm.vue'
  250. import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
  251. import DeptTree from '@/views/system/user/DeptTree.vue'
  252. const { push } = useRouter()
  253. const { params } = useRoute()
  254. /** 巡检工单 列表 */
  255. defineOptions({ name: 'IotInspectOrder' })
  256. const message = useMessage() // 消息弹窗
  257. const { t } = useI18n() // 国际化
  258. const loading = ref(true) // 列表的加载中
  259. const list = ref<IotInspectOrderVO[]>([]) // 列表的数据
  260. const status = params.status
  261. const deptId = params.deptId
  262. const createTime = params.createTime
  263. const total = ref(0) // 列表的总页数
  264. const dialogVisible = ref(false)
  265. const queryParams = reactive({
  266. pageNo: 1,
  267. pageSize: 10,
  268. inspectOrderTitle: undefined,
  269. inspectOrderCode: undefined,
  270. status: undefined,
  271. remark: undefined,
  272. createTime: [],
  273. deptId: undefined,
  274. deviceIds: undefined
  275. })
  276. const queryFormRef = ref() // 搜索的表单
  277. const exportLoading = ref(false) // 导出的加载中
  278. const handleDeptNodeClick = async (row) => {
  279. queryParams.deptId = row.id
  280. await getList()
  281. }
  282. /** 查询列表 */
  283. const getList = async () => {
  284. loading.value = true
  285. try {
  286. const data = await IotInspectOrderApi.getIotInspectOrderPage(queryParams)
  287. list.value = data.list
  288. total.value = data.total
  289. } finally {
  290. loading.value = false
  291. }
  292. }
  293. /** 搜索按钮操作 */
  294. const handleQuery = () => {
  295. queryParams.pageNo = 1
  296. getList()
  297. }
  298. /** 重置按钮操作 */
  299. const resetQuery = () => {
  300. queryFormRef.value.resetFields()
  301. handleQuery()
  302. }
  303. const reasonFormRef = ref(null)
  304. const form = reactive({
  305. id: undefined,
  306. reason: ''
  307. })
  308. // 表单验证规则
  309. const rules = {
  310. reason: [
  311. { required: true, message: '请输入忽略理由', trigger: 'blur' },
  312. { min: 2, message: '理由长度不能少于2个字符', trigger: 'blur' }
  313. ]
  314. }
  315. // 打开对话框
  316. const openDialog = (id: number) => {
  317. dialogVisible.value = true
  318. form.id = id
  319. form.reason = ''
  320. }
  321. // 关闭对话框前的回调
  322. const handleClose = () => {
  323. resetForm()
  324. }
  325. // 取消按钮处理
  326. const handleCancel = () => {
  327. dialogVisible.value = false
  328. resetForm()
  329. }
  330. // 确定按钮处理
  331. const handleConfirm = async () => {
  332. // 表单验证
  333. try {
  334. await reasonFormRef.value.validate()
  335. // 验证通过,调用接口
  336. await IotInspectOrderApi.orderReason(form)
  337. ElMessage.success('操作成功')
  338. dialogVisible.value = false
  339. resetForm()
  340. } catch (error) {
  341. return
  342. }
  343. }
  344. // 重置表单
  345. const resetForm = () => {
  346. reasonFormRef.value?.resetFields()
  347. }
  348. /** 添加/修改操作 */
  349. const formRef = ref()
  350. const openForm = (id?: number) => {
  351. push({ name: 'InspectOrderDetail', params: { id } })
  352. }
  353. const openWrite = (id?: number) => {
  354. IotInspectOrderApi.getIotInspectOrder(id).then((res) => {
  355. if (res.status === 'finished') {
  356. message.warning('该工单已执行')
  357. return
  358. }
  359. })
  360. push({ name: 'InspectOrderWrite', params: { id } })
  361. }
  362. /** 删除按钮操作 */
  363. const handleDelete = async (id: number) => {
  364. try {
  365. // 删除的二次确认
  366. await message.delConfirm()
  367. // 发起删除
  368. await IotInspectOrderApi.deleteIotInspectOrder(id)
  369. message.success(t('common.delSuccess'))
  370. // 刷新列表
  371. await getList()
  372. } catch {}
  373. }
  374. /** 导出按钮操作 */
  375. const handleExport = async () => {
  376. try {
  377. // 导出的二次确认
  378. await message.exportConfirm()
  379. // 发起导出
  380. exportLoading.value = true
  381. const data = await IotInspectOrderApi.exportIotInspectOrder(queryParams)
  382. download.excel(data, '巡检工单.xls')
  383. } catch {
  384. } finally {
  385. exportLoading.value = false
  386. }
  387. }
  388. /** 初始化 **/
  389. onMounted(() => {
  390. debugger
  391. if (params.status) {
  392. queryParams.status = params.status
  393. }
  394. if (deptId != null) {
  395. queryParams.deptId = deptId
  396. }
  397. if (createTime) {
  398. queryParams.createTime = createTime
  399. }
  400. getList()
  401. })
  402. </script>
  403. <style scoped scss>
  404. .reason-confirm-container {
  405. margin: 20px;
  406. }
  407. /* 调整文本框样式 */
  408. :deep(.el-textarea__inner) {
  409. font-size: 14px;
  410. }
  411. /* 调整表单项间距 */
  412. :deep(.el-form-item) {
  413. margin-bottom ::v-deep .el-table__header-wrapper {
  414. position: sticky !important;
  415. width: 100%;
  416. top: 0px;
  417. z-index: 2000;
  418. }
  419. :15px;
  420. }
  421. </style>