index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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="创建时间" prop="createTime">
  12. <el-date-picker
  13. v-model="queryParams.createTime"
  14. value-format="YYYY-MM-DD HH:mm:ss"
  15. type="daterange"
  16. start-placeholder="开始日期"
  17. end-placeholder="结束日期"
  18. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  19. class="!w-220px"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  24. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  25. <el-button
  26. type="primary"
  27. plain
  28. @click="openForm('create')"
  29. >
  30. <Icon icon="ep:plus" class="mr-5px" /> 新增
  31. </el-button>
  32. </el-form-item>
  33. </el-form>
  34. </ContentWrap>
  35. <!-- 列表 -->
  36. <ContentWrap>
  37. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  38. <el-table-column label="app版本号" align="center" prop="appVersion" />
  39. <el-table-column label="app包名称" align="center" prop="appName" />
  40. <el-table-column label="app的apk路径" align="center" prop="url" />
  41. <el-table-column label="备注" align="center" prop="remark" />
  42. <el-table-column
  43. label="创建时间"
  44. align="center"
  45. prop="createTime"
  46. :formatter="dateFormatter"
  47. width="180px"
  48. />
  49. </el-table>
  50. <!-- 分页 -->
  51. <Pagination
  52. :total="total"
  53. v-model:page="queryParams.pageNo"
  54. v-model:limit="queryParams.pageSize"
  55. @pagination="getList"
  56. />
  57. </ContentWrap>
  58. <!-- 表单弹窗:添加/修改 -->
  59. <IotAppForm ref="formRef" @success="getList" />
  60. </template>
  61. <script setup lang="ts">
  62. import { dateFormatter } from '@/utils/formatTime'
  63. import download from '@/utils/download'
  64. import { IotAppApi, IotAppVO } from '@/api/pms/app'
  65. import IotAppForm from './IotAppForm.vue'
  66. /** app版本更新 列表 */
  67. defineOptions({ name: 'IotApp' })
  68. const message = useMessage() // 消息弹窗
  69. const { t } = useI18n() // 国际化
  70. const loading = ref(true) // 列表的加载中
  71. const list = ref<IotAppVO[]>([]) // 列表的数据
  72. const total = ref(0) // 列表的总页数
  73. const queryParams = reactive({
  74. pageNo: 1,
  75. pageSize: 10,
  76. appVersion: undefined,
  77. url: undefined,
  78. remark: undefined,
  79. createTime: [],
  80. appName: undefined,
  81. })
  82. const queryFormRef = ref() // 搜索的表单
  83. const exportLoading = ref(false) // 导出的加载中
  84. /** 查询列表 */
  85. const getList = async () => {
  86. loading.value = true
  87. try {
  88. const data = await IotAppApi.getIotAppPage(queryParams)
  89. list.value = data.list
  90. total.value = data.total
  91. } finally {
  92. loading.value = false
  93. }
  94. }
  95. /** 搜索按钮操作 */
  96. const handleQuery = () => {
  97. queryParams.pageNo = 1
  98. getList()
  99. }
  100. /** 重置按钮操作 */
  101. const resetQuery = () => {
  102. queryFormRef.value.resetFields()
  103. handleQuery()
  104. }
  105. /** 添加/修改操作 */
  106. const formRef = ref()
  107. const openForm = (type: string, id?: number) => {
  108. formRef.value.open(type, id)
  109. }
  110. /** 删除按钮操作 */
  111. const handleDelete = async (id: number) => {
  112. try {
  113. // 删除的二次确认
  114. await message.delConfirm()
  115. // 发起删除
  116. await IotAppApi.deleteIotApp(id)
  117. message.success(t('common.delSuccess'))
  118. // 刷新列表
  119. await getList()
  120. } catch {}
  121. }
  122. /** 导出按钮操作 */
  123. const handleExport = async () => {
  124. try {
  125. // 导出的二次确认
  126. await message.exportConfirm()
  127. // 发起导出
  128. exportLoading.value = true
  129. const data = await IotAppApi.exportIotApp(queryParams)
  130. download.excel(data, 'app版本更新.xls')
  131. } catch {
  132. } finally {
  133. exportLoading.value = false
  134. }
  135. }
  136. /** 初始化 **/
  137. onMounted(() => {
  138. getList()
  139. })
  140. </script>