index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item :label="t('deviceForm.category')" prop="deviceClassify" style="width: 15vw" >
  12. <el-tree-select
  13. v-model="queryParams.deviceClassify"
  14. :data="productClassifyList"
  15. :props="defaultProps"
  16. check-strictly
  17. node-key="id"
  18. :placeholder="t('deviceForm.categoryHolder')"
  19. filterable
  20. />
  21. </el-form-item>
  22. <el-form-item :label="t('inspect.InspectionItems')" prop="item" style="margin-left: 30px">
  23. <el-input
  24. v-model="queryParams.item"
  25. :placeholder="t('inspect.itemHolder')"
  26. clearable
  27. @keyup.enter="handleQuery"
  28. class="!w-240px"
  29. />
  30. </el-form-item>
  31. <el-form-item :label="t('common.createTime')" prop="createTime" label-width="100px">
  32. <el-date-picker
  33. v-model="queryParams.createTime"
  34. value-format="YYYY-MM-DD HH:mm:ss"
  35. type="daterange"
  36. :start-placeholder="t('operationFill.start')"
  37. :end-placeholder="t('operationFill.end')"
  38. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  39. class="!w-220px"
  40. />
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" />
  44. {{ t('operationFill.search') }}</el-button>
  45. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> {{ t('operationFill.reset') }}</el-button>
  46. <el-button
  47. type="primary"
  48. plain
  49. @click="openForm('create')"
  50. v-hasPermi="['rq:iot-inspect-item:create']"
  51. >
  52. <Icon icon="ep:plus" class="mr-5px" /> {{ t('operationFill.add') }}
  53. </el-button>
  54. <el-button
  55. type="success"
  56. plain
  57. @click="handleExport"
  58. :loading="exportLoading"
  59. v-hasPermi="['rq:iot-inspect-item:export']"
  60. >
  61. <Icon icon="ep:download" class="mr-5px" /> 导出
  62. </el-button>
  63. </el-form-item>
  64. </el-form>
  65. </ContentWrap>
  66. <!-- 列表 -->
  67. <ContentWrap>
  68. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  69. <!-- <el-table-column label="主键id" align="center" prop="id" />-->
  70. <el-table-column :label="t('iotDevice.serial')" width="70" align="center">
  71. <template #default="scope">
  72. {{ scope.$index + 1 }}
  73. </template>
  74. </el-table-column>
  75. <el-table-column :label="t('monitor.category')" align="center" prop="deviceClassifyName" />
  76. <el-table-column :label="t('iotDevice.code')" align="center" prop="deviceCode" />
  77. <el-table-column :label="t('monitor.deviceName')" align="center" prop="deviceName" />
  78. <el-table-column :label="t('inspect.InspectionItems')" align="center" prop="item" />
  79. <el-table-column :label="t('inspect.InspectionStandards')" align="center" prop="standard" />
  80. <el-table-column :label="t('common.sort')" align="center" prop="sort" />
  81. <el-table-column :label="t('form.remark')" align="center" prop="remark" />
  82. <el-table-column
  83. :label="t('common.createTime')"
  84. align="center"
  85. prop="createTime"
  86. :formatter="dateFormatter"
  87. width="180px"
  88. />
  89. <!-- <el-table-column label="部门id" align="center" prop="deptId" />-->
  90. <el-table-column :label="t('operationFill.operation')" align="center" min-width="120px">
  91. <template #default="scope">
  92. <el-button
  93. link
  94. type="primary"
  95. @click="openForm('update', scope.row.id)"
  96. v-hasPermi="['rq:iot-inspect-item:update']"
  97. >
  98. {{ t('fault.edit') }}
  99. </el-button>
  100. <el-button
  101. link
  102. type="danger"
  103. @click="handleDelete(scope.row.id)"
  104. v-hasPermi="['rq:iot-inspect-item:delete']"
  105. >
  106. {{ t('fault.del') }}
  107. </el-button>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. <!-- 分页 -->
  112. <Pagination
  113. :total="total"
  114. v-model:page="queryParams.pageNo"
  115. v-model:limit="queryParams.pageSize"
  116. @pagination="getList"
  117. />
  118. </ContentWrap>
  119. <!-- 表单弹窗:添加/修改 -->
  120. <IotInspectItemForm ref="formRef" @success="getList" />
  121. </template>
  122. <script setup lang="ts">
  123. import { dateFormatter } from '@/utils/formatTime'
  124. import download from '@/utils/download'
  125. import { IotInspectItemApi, IotInspectItemVO } from '@/api/pms/inspect/item'
  126. import IotInspectItemForm from './IotInspectItemForm.vue'
  127. import {defaultProps, handleTree} from "@/utils/tree";
  128. import * as ProductClassifyApi from "@/api/pms/productclassify";
  129. /** 巡检项 列表 */
  130. defineOptions({ name: 'IotInspectItem' })
  131. const message = useMessage() // 消息弹窗
  132. const { t } = useI18n() // 国际化
  133. const loading = ref(true) // 列表的加载中
  134. const list = ref<IotInspectItemVO[]>([]) // 列表的数据
  135. const total = ref(0) // 列表的总页数
  136. const queryParams = reactive({
  137. pageNo: 1,
  138. pageSize: 10,
  139. item: undefined,
  140. deviceClassify: undefined,
  141. standard: undefined,
  142. sort: undefined,
  143. remark: undefined,
  144. createTime: [],
  145. deptId: undefined,
  146. })
  147. const productClassifyList = ref<Tree[]>([]) // 树形结构
  148. const queryFormRef = ref() // 搜索的表单
  149. const exportLoading = ref(false) // 导出的加载中
  150. /** 查询列表 */
  151. const getList = async () => {
  152. loading.value = true
  153. try {
  154. const data = await IotInspectItemApi.getIotInspectItemPage(queryParams)
  155. list.value = data.list
  156. total.value = data.total
  157. } finally {
  158. loading.value = false
  159. }
  160. }
  161. /** 搜索按钮操作 */
  162. const handleQuery = () => {
  163. queryParams.pageNo = 1
  164. getList()
  165. }
  166. /** 重置按钮操作 */
  167. const resetQuery = () => {
  168. queryFormRef.value.resetFields()
  169. handleQuery()
  170. }
  171. /** 添加/修改操作 */
  172. const formRef = ref()
  173. const openForm = (type: string, id?: number) => {
  174. formRef.value.open(type, id)
  175. }
  176. /** 删除按钮操作 */
  177. const handleDelete = async (id: number) => {
  178. try {
  179. // 删除的二次确认
  180. await message.delConfirm()
  181. // 发起删除
  182. await IotInspectItemApi.deleteIotInspectItem(id)
  183. message.success(t('common.delSuccess'))
  184. // 刷新列表
  185. await getList()
  186. } catch {}
  187. }
  188. /** 导出按钮操作 */
  189. const handleExport = async () => {
  190. try {
  191. // 导出的二次确认
  192. await message.exportConfirm()
  193. // 发起导出
  194. exportLoading.value = true
  195. const data = await IotInspectItemApi.exportIotInspectItem(queryParams)
  196. download.excel(data, '巡检项.xls')
  197. } catch {
  198. } finally {
  199. exportLoading.value = false
  200. }
  201. }
  202. /** 初始化 **/
  203. onMounted(async () => {
  204. productClassifyList.value = handleTree(
  205. await ProductClassifyApi.IotProductClassifyApi.getSimpleProductClassifyList()
  206. )
  207. await getList()
  208. })
  209. </script>