index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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="设备id" prop="deviceId">
  12. <el-input
  13. v-model="queryParams.deviceId"
  14. placeholder="请输入设备id"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="设备修改前状态" prop="oldStatus">
  21. <el-select
  22. v-model="queryParams.oldStatus"
  23. placeholder="请选择设备修改前状态"
  24. clearable
  25. class="!w-240px"
  26. >
  27. <el-option label="请选择字典生成" value="" />
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="设备修改后状态" prop="newStatus">
  31. <el-select
  32. v-model="queryParams.newStatus"
  33. placeholder="请选择设备修改后状态"
  34. clearable
  35. class="!w-240px"
  36. >
  37. <el-option label="请选择字典生成" value="" />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="设备状态调整原因" prop="reason">
  41. <el-input
  42. v-model="queryParams.reason"
  43. placeholder="请输入设备状态调整原因"
  44. clearable
  45. @keyup.enter="handleQuery"
  46. class="!w-240px"
  47. />
  48. </el-form-item>
  49. <el-form-item label="备注" prop="remark">
  50. <el-input
  51. v-model="queryParams.remark"
  52. placeholder="请输入备注"
  53. clearable
  54. @keyup.enter="handleQuery"
  55. class="!w-240px"
  56. />
  57. </el-form-item>
  58. <el-form-item label="创建时间" prop="createTime">
  59. <el-date-picker
  60. v-model="queryParams.createTime"
  61. value-format="YYYY-MM-DD HH:mm:ss"
  62. type="daterange"
  63. start-placeholder="开始日期"
  64. end-placeholder="结束日期"
  65. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  66. class="!w-220px"
  67. />
  68. </el-form-item>
  69. <el-form-item>
  70. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  71. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  72. <el-button
  73. type="primary"
  74. plain
  75. @click="openForm('create')"
  76. v-hasPermi="['pms:iot-device-status-log:create']"
  77. >
  78. <Icon icon="ep:plus" class="mr-5px" /> 新增
  79. </el-button>
  80. <el-button
  81. type="success"
  82. plain
  83. @click="handleExport"
  84. :loading="exportLoading"
  85. v-hasPermi="['pms:iot-device-status-log:export']"
  86. >
  87. <Icon icon="ep:download" class="mr-5px" /> 导出
  88. </el-button>
  89. </el-form-item>
  90. </el-form>
  91. </ContentWrap>
  92. <!-- 列表 -->
  93. <ContentWrap>
  94. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  95. <el-table-column label="主键id" align="center" prop="id" />
  96. <el-table-column label="设备id" align="center" prop="deviceId" />
  97. <el-table-column label="设备修改前状态" align="center" prop="oldStatus" />
  98. <el-table-column label="设备修改后状态" align="center" prop="newStatus" />
  99. <el-table-column label="设备状态调整原因" align="center" prop="reason" />
  100. <el-table-column label="备注" align="center" prop="remark" />
  101. <el-table-column
  102. label="创建时间"
  103. align="center"
  104. prop="createTime"
  105. :formatter="dateFormatter"
  106. width="180px"
  107. />
  108. <el-table-column label="操作" align="center" min-width="120px">
  109. <template #default="scope">
  110. <el-button
  111. link
  112. type="primary"
  113. @click="openForm('update', scope.row.id)"
  114. v-hasPermi="['pms:iot-device-status-log:update']"
  115. >
  116. 编辑
  117. </el-button>
  118. <el-button
  119. link
  120. type="danger"
  121. @click="handleDelete(scope.row.id)"
  122. v-hasPermi="['pms:iot-device-status-log:delete']"
  123. >
  124. 删除
  125. </el-button>
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. <!-- 分页 -->
  130. <Pagination
  131. :total="total"
  132. v-model:page="queryParams.pageNo"
  133. v-model:limit="queryParams.pageSize"
  134. @pagination="getList"
  135. />
  136. </ContentWrap>
  137. <!-- 表单弹窗:添加/修改 -->
  138. <IotDeviceStatusLogForm ref="formRef" @success="getList" />
  139. </template>
  140. <script setup lang="ts">
  141. import { dateFormatter } from '@/utils/formatTime'
  142. import download from '@/utils/download'
  143. import { IotDeviceStatusLogApi, IotDeviceStatusLogVO } from '@/api/pms/iotdevicestatuslog'
  144. import IotDeviceStatusLogForm from './IotDeviceStatusLogForm.vue'
  145. /** 设备状态调整日志 列表 */
  146. defineOptions({ name: 'IotDeviceStatusLog' })
  147. const message = useMessage() // 消息弹窗
  148. const { t } = useI18n() // 国际化
  149. const loading = ref(true) // 列表的加载中
  150. const list = ref<IotDeviceStatusLogVO[]>([]) // 列表的数据
  151. const total = ref(0) // 列表的总页数
  152. const queryParams = reactive({
  153. pageNo: 1,
  154. pageSize: 10,
  155. deviceId: undefined,
  156. oldStatus: undefined,
  157. newStatus: undefined,
  158. reason: undefined,
  159. remark: undefined,
  160. createTime: [],
  161. })
  162. const queryFormRef = ref() // 搜索的表单
  163. const exportLoading = ref(false) // 导出的加载中
  164. /** 查询列表 */
  165. const getList = async () => {
  166. loading.value = true
  167. try {
  168. const data = await IotDeviceStatusLogApi.getIotDeviceStatusLogPage(queryParams)
  169. list.value = data.list
  170. total.value = data.total
  171. } finally {
  172. loading.value = false
  173. }
  174. }
  175. /** 搜索按钮操作 */
  176. const handleQuery = () => {
  177. queryParams.pageNo = 1
  178. getList()
  179. }
  180. /** 重置按钮操作 */
  181. const resetQuery = () => {
  182. queryFormRef.value.resetFields()
  183. handleQuery()
  184. }
  185. /** 添加/修改操作 */
  186. const formRef = ref()
  187. const openForm = (type: string, id?: number) => {
  188. formRef.value.open(type, id)
  189. }
  190. /** 删除按钮操作 */
  191. const handleDelete = async (id: number) => {
  192. try {
  193. // 删除的二次确认
  194. await message.delConfirm()
  195. // 发起删除
  196. await IotDeviceStatusLogApi.deleteIotDeviceStatusLog(id)
  197. message.success(t('common.delSuccess'))
  198. // 刷新列表
  199. await getList()
  200. } catch {}
  201. }
  202. /** 导出按钮操作 */
  203. const handleExport = async () => {
  204. try {
  205. // 导出的二次确认
  206. await message.exportConfirm()
  207. // 发起导出
  208. exportLoading.value = true
  209. const data = await IotDeviceStatusLogApi.exportIotDeviceStatusLog(queryParams)
  210. download.excel(data, '设备状态调整日志.xls')
  211. } catch {
  212. } finally {
  213. exportLoading.value = false
  214. }
  215. }
  216. /** 初始化 **/
  217. onMounted(() => {
  218. getList()
  219. })
  220. </script>