index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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('monitor.deviceName')" align="center" prop="deviceName" />
  77. <el-table-column :label="t('inspect.InspectionItems')" align="center" prop="item" />
  78. <el-table-column :label="t('inspect.InspectionStandards')" align="center" prop="standard" />
  79. <el-table-column :label="t('common.sort')" align="center" prop="sort" />
  80. <el-table-column :label="t('form.remark')" align="center" prop="remark" />
  81. <el-table-column
  82. :label="t('common.createTime')"
  83. align="center"
  84. prop="createTime"
  85. :formatter="dateFormatter"
  86. width="180px"
  87. />
  88. <!-- <el-table-column label="部门id" align="center" prop="deptId" />-->
  89. <el-table-column :label="t('operationFill.operation')" align="center" min-width="120px">
  90. <template #default="scope">
  91. <el-button
  92. link
  93. type="primary"
  94. @click="openForm('update', scope.row.id)"
  95. v-hasPermi="['rq:iot-inspect-item:update']"
  96. >
  97. {{ t('fault.edit') }}
  98. </el-button>
  99. <el-button
  100. link
  101. type="danger"
  102. @click="handleDelete(scope.row.id)"
  103. v-hasPermi="['rq:iot-inspect-item:delete']"
  104. >
  105. {{ t('fault.del') }}
  106. </el-button>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <!-- 分页 -->
  111. <Pagination
  112. :total="total"
  113. v-model:page="queryParams.pageNo"
  114. v-model:limit="queryParams.pageSize"
  115. @pagination="getList"
  116. />
  117. </ContentWrap>
  118. <!-- 表单弹窗:添加/修改 -->
  119. <IotInspectItemForm ref="formRef" @success="getList" />
  120. </template>
  121. <script setup lang="ts">
  122. import { dateFormatter } from '@/utils/formatTime'
  123. import download from '@/utils/download'
  124. import { IotInspectItemApi, IotInspectItemVO } from '@/api/pms/inspect/item'
  125. import IotInspectItemForm from './IotInspectItemForm.vue'
  126. import {defaultProps, handleTree} from "@/utils/tree";
  127. import * as ProductClassifyApi from "@/api/pms/productclassify";
  128. /** 巡检项 列表 */
  129. defineOptions({ name: 'IotInspectItem' })
  130. const message = useMessage() // 消息弹窗
  131. const { t } = useI18n() // 国际化
  132. const loading = ref(true) // 列表的加载中
  133. const list = ref<IotInspectItemVO[]>([]) // 列表的数据
  134. const total = ref(0) // 列表的总页数
  135. const queryParams = reactive({
  136. pageNo: 1,
  137. pageSize: 10,
  138. item: undefined,
  139. deviceClassify: undefined,
  140. standard: undefined,
  141. sort: undefined,
  142. remark: undefined,
  143. createTime: [],
  144. deptId: undefined,
  145. })
  146. const productClassifyList = ref<Tree[]>([]) // 树形结构
  147. const queryFormRef = ref() // 搜索的表单
  148. const exportLoading = ref(false) // 导出的加载中
  149. /** 查询列表 */
  150. const getList = async () => {
  151. loading.value = true
  152. try {
  153. const data = await IotInspectItemApi.getIotInspectItemPage(queryParams)
  154. list.value = data.list
  155. total.value = data.total
  156. } finally {
  157. loading.value = false
  158. }
  159. }
  160. /** 搜索按钮操作 */
  161. const handleQuery = () => {
  162. queryParams.pageNo = 1
  163. getList()
  164. }
  165. /** 重置按钮操作 */
  166. const resetQuery = () => {
  167. queryFormRef.value.resetFields()
  168. handleQuery()
  169. }
  170. /** 添加/修改操作 */
  171. const formRef = ref()
  172. const openForm = (type: string, id?: number) => {
  173. formRef.value.open(type, id)
  174. }
  175. /** 删除按钮操作 */
  176. const handleDelete = async (id: number) => {
  177. try {
  178. // 删除的二次确认
  179. await message.delConfirm()
  180. // 发起删除
  181. await IotInspectItemApi.deleteIotInspectItem(id)
  182. message.success(t('common.delSuccess'))
  183. // 刷新列表
  184. await getList()
  185. } catch {}
  186. }
  187. /** 导出按钮操作 */
  188. const handleExport = async () => {
  189. try {
  190. // 导出的二次确认
  191. await message.exportConfirm()
  192. // 发起导出
  193. exportLoading.value = true
  194. const data = await IotInspectItemApi.exportIotInspectItem(queryParams)
  195. download.excel(data, '巡检项.xls')
  196. } catch {
  197. } finally {
  198. exportLoading.value = false
  199. }
  200. }
  201. /** 初始化 **/
  202. onMounted(async () => {
  203. productClassifyList.value = handleTree(
  204. await ProductClassifyApi.IotProductClassifyApi.getSimpleProductClassifyList()
  205. )
  206. await getList()
  207. })
  208. </script>