index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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="deviceType" style="width: 15vw" >
  12. <el-tree-select
  13. v-model="queryParams.deviceType"
  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('info.faultySystem')" prop="failureSystem">
  23. <el-input
  24. v-model="queryParams.failureSystem"
  25. :placeholder="t('info.faultySystemHolder')"
  26. clearable
  27. @keyup.enter="handleQuery"
  28. class="!w-240px"
  29. />
  30. </el-form-item>
  31. <el-form-item :label="t('info.createTime')" prop="createTime">
  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('info.start')"
  37. :end-placeholder="t('info.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('info.search') }}</el-button>
  45. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" />
  46. {{ t('info.reset') }}</el-button>
  47. <el-button
  48. type="primary"
  49. plain
  50. @click="openForm('create')"
  51. v-hasPermi="['rq:iot-information-db:create']"
  52. >
  53. <Icon icon="ep:plus" class="mr-5px" />
  54. {{ t('info.add') }}
  55. </el-button>
  56. <el-button
  57. type="success"
  58. plain
  59. @click="handleExport"
  60. :loading="exportLoading"
  61. v-hasPermi="['rq:iot-information-db:export']"
  62. >
  63. <Icon icon="ep:download" class="mr-5px" /> 导出
  64. </el-button>
  65. </el-form-item>
  66. </el-form>
  67. </ContentWrap>
  68. <!-- 列表 -->
  69. <ContentWrap>
  70. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  71. <el-table-column :label="t('iotDevice.serial')" width="70" align="center">
  72. <template #default="scope">
  73. {{ scope.$index + 1 }}
  74. </template>
  75. </el-table-column>
  76. <el-table-column :label="t('info.deviceClass')" align="center" prop="className" />
  77. <el-table-column :label="t('faultForm.faultImpact')" align="center" prop="failureInfluence" />
  78. <el-table-column :label="t('iotMaintain.faultySystem')" align="center" prop="failureSystem" />
  79. <el-table-column :label="t('info.description')" align="center" prop="description" />
  80. <el-table-column :label="t('iotMaintain.solution')" align="center" prop="solutions" />
  81. <el-table-column :label="t('iotMaintain.remark')" align="center" prop="remark" />
  82. <el-table-column
  83. :label="t('info.createTime')"
  84. align="center"
  85. prop="createTime"
  86. :formatter="dateFormatter"
  87. width="180px"
  88. />
  89. <!-- <el-table-column label="审核状态" align="center" prop="auditStatus" />-->
  90. <el-table-column :label="t('iotMaintain.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-information-db:update']"
  97. >
  98. {{ t('info.edit') }}
  99. </el-button>
  100. <el-button
  101. link
  102. type="danger"
  103. @click="handleDelete(scope.row.id)"
  104. v-hasPermi="['rq:iot-information-db:delete']"
  105. >
  106. {{ t('info.delete') }}
  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. <IotInformationDbForm ref="formRef" style="width: 60vw" @success="getList" />
  121. </template>
  122. <script setup lang="ts">
  123. import { dateFormatter } from '@/utils/formatTime'
  124. import download from '@/utils/download'
  125. import { IotInformationDbApi, IotInformationDbVO } from '@/api/pms/information'
  126. import IotInformationDbForm from './IotInformationDbForm.vue'
  127. import {defaultProps, handleTree} from "@/utils/tree";
  128. import * as ProductClassifyApi from "@/api/pms/productclassify";
  129. /** 故障知识库 列表 */
  130. defineOptions({ name: 'IotInformationDb' })
  131. const message = useMessage() // 消息弹窗
  132. const { t } = useI18n() // 国际化
  133. const loading = ref(true) // 列表的加载中
  134. const list = ref<IotInformationDbVO[]>([]) // 列表的数据
  135. const productClassifyList = ref<Tree[]>([]) // 树形结构
  136. const total = ref(0) // 列表的总页数
  137. const queryParams = reactive({
  138. pageNo: 1,
  139. pageSize: 10,
  140. deviceType: undefined,
  141. failureInfluence: undefined,
  142. failureSystem: undefined,
  143. description: undefined,
  144. solutions: undefined,
  145. remark: undefined,
  146. createTime: [],
  147. processInstanceId: undefined,
  148. auditStatus: undefined
  149. })
  150. const queryFormRef = ref() // 搜索的表单
  151. const exportLoading = ref(false) // 导出的加载中
  152. /** 查询列表 */
  153. const getList = async () => {
  154. loading.value = true
  155. try {
  156. const data = await IotInformationDbApi.getIotInformationDbPage(queryParams)
  157. list.value = data.list
  158. total.value = data.total
  159. } finally {
  160. loading.value = false
  161. }
  162. }
  163. /** 搜索按钮操作 */
  164. const handleQuery = () => {
  165. queryParams.pageNo = 1
  166. getList()
  167. }
  168. /** 重置按钮操作 */
  169. const resetQuery = () => {
  170. queryFormRef.value.resetFields()
  171. handleQuery()
  172. }
  173. /** 添加/修改操作 */
  174. const formRef = ref()
  175. const openForm = (type: string, id?: number) => {
  176. formRef.value.open(type, id)
  177. }
  178. /** 删除按钮操作 */
  179. const handleDelete = async (id: number) => {
  180. try {
  181. // 删除的二次确认
  182. await message.delConfirm()
  183. // 发起删除
  184. await IotInformationDbApi.deleteIotInformationDb(id)
  185. message.success(t('common.delSuccess'))
  186. // 刷新列表
  187. await getList()
  188. } catch {}
  189. }
  190. /** 导出按钮操作 */
  191. const handleExport = async () => {
  192. try {
  193. // 导出的二次确认
  194. await message.exportConfirm()
  195. // 发起导出
  196. exportLoading.value = true
  197. const data = await IotInformationDbApi.exportIotInformationDb(queryParams)
  198. download.excel(data, '故障知识库.xls')
  199. } catch {
  200. } finally {
  201. exportLoading.value = false
  202. }
  203. }
  204. /** 初始化 **/
  205. onMounted(async () => {
  206. productClassifyList.value = handleTree(
  207. await ProductClassifyApi.IotProductClassifyApi.getSimpleProductClassifyList()
  208. )
  209. await getList()
  210. })
  211. </script>