index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <!-- 搜索工作栏 -->
  3. <content-wrap>
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="90px"
  10. >
  11. <el-form-item label="错误码类型" prop="type">
  12. <el-select v-model="queryParams.type" placeholder="请选择错误码类型" clearable>
  13. <el-option
  14. v-for="dict in getDictOptions(DICT_TYPE.SYSTEM_ERROR_CODE_TYPE)"
  15. :key="dict.value"
  16. :label="dict.label"
  17. :value="dict.value"
  18. class="!w-240px"
  19. />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="应用名" prop="applicationName">
  23. <el-input
  24. v-model="queryParams.applicationName"
  25. placeholder="请输入应用名"
  26. clearable
  27. @keyup.enter="handleQuery"
  28. class="!w-240px"
  29. />
  30. </el-form-item>
  31. <el-form-item label="错误码编码" prop="code">
  32. <el-input
  33. v-model="queryParams.code"
  34. placeholder="请输入错误码编码"
  35. clearable
  36. @keyup.enter="handleQuery"
  37. />
  38. </el-form-item>
  39. <el-form-item label="错误码提示" prop="message">
  40. <el-input
  41. v-model="queryParams.message"
  42. placeholder="请输入错误码提示"
  43. clearable
  44. @keyup.enter="handleQuery"
  45. class="!w-240px"
  46. />
  47. </el-form-item>
  48. <el-form-item label="创建时间" prop="createTime">
  49. <el-date-picker
  50. v-model="queryParams.createTime"
  51. value-format="YYYY-MM-DD HH:mm:ss"
  52. type="daterange"
  53. start-placeholder="开始日期"
  54. end-placeholder="结束日期"
  55. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  56. class="!w-240px"
  57. />
  58. </el-form-item>
  59. <el-form-item>
  60. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  61. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  62. <el-button
  63. type="primary"
  64. plain
  65. @click="openModal('create')"
  66. v-hasPermi="['system:error-code:create']"
  67. >
  68. <Icon icon="ep:plus" class="mr-5px" /> 新增
  69. </el-button>
  70. <el-button
  71. type="success"
  72. plain
  73. @click="handleExport"
  74. :loading="exportLoading"
  75. v-hasPermi="['system:error-code:export']"
  76. >
  77. <Icon icon="ep:download" class="mr-5px" /> 导出
  78. </el-button>
  79. </el-form-item>
  80. </el-form>
  81. </content-wrap>
  82. <!-- 列表 -->
  83. <content-wrap>
  84. <el-table v-loading="loading" :data="list">
  85. <el-table-column label="编号" align="center" prop="id" />
  86. <el-table-column label="类型" align="center" prop="type" width="80">
  87. <template #default="scope">
  88. <dict-tag :type="DICT_TYPE.SYSTEM_ERROR_CODE_TYPE" :value="scope.row.type" />
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="应用名" align="center" prop="applicationName" width="200" />
  92. <el-table-column label="错误码编码" align="center" prop="code" width="120" />
  93. <el-table-column label="错误码提示" align="center" prop="message" width="300" />
  94. <el-table-column label="备注" align="center" prop="memo" width="200" />
  95. <el-table-column
  96. label="创建时间"
  97. align="center"
  98. prop="createTime"
  99. width="180"
  100. :formatter="dateFormatter"
  101. />
  102. <el-table-column label="操作" align="center" class-name="small-paddingfixed-width">
  103. <template #default="scope">
  104. <el-button
  105. link
  106. type="primary"
  107. @click="openModal('update', scope.row.id)"
  108. v-hasPermi="['system:error-code:update']"
  109. >
  110. 编辑
  111. </el-button>
  112. <el-button
  113. link
  114. type="danger"
  115. @click="handleDelete(scope.row.id)"
  116. v-hasPermi="['system:error-code:delete']"
  117. >
  118. 删除
  119. </el-button>
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. <!-- 分页组件 -->
  124. <Pagination
  125. :total="total"
  126. v-model:page="queryParams.pageNo"
  127. v-model:limit="queryParams.pageSize"
  128. @pagination="getList"
  129. />
  130. </content-wrap>
  131. <!-- 表单弹窗:添加/修改 -->
  132. <error-code-form ref="modalRef" @success="getList" />
  133. </template>
  134. <script setup lang="ts" name="ErrorCode">
  135. import * as ErrorCodeApi from '@/api/system/errorCode'
  136. import { DICT_TYPE, getDictOptions } from '@/utils/dict'
  137. import { dateFormatter } from '@/utils/formatTime'
  138. import ErrorCodeForm from './form.vue'
  139. import download from '@/utils/download'
  140. const message = useMessage() // 消息弹窗
  141. const { t } = useI18n() // 国际化
  142. // 遮罩层
  143. const loading = ref(true)
  144. // 导出遮罩层
  145. const exportLoading = ref(false)
  146. // 总条数
  147. const total = ref(0)
  148. // 错误码列表
  149. const list = ref([])
  150. // 查询参数
  151. const queryParams = reactive({
  152. pageNo: 1,
  153. pageSize: 10,
  154. type: undefined,
  155. applicationName: undefined,
  156. code: undefined,
  157. message: undefined,
  158. createTime: []
  159. })
  160. // 搜索的表单
  161. const queryFormRef = ref()
  162. /** 查询列表 */
  163. const getList = async () => {
  164. loading.value = true
  165. // 执行查询
  166. try {
  167. const data = await ErrorCodeApi.getErrorCodePageApi(queryParams)
  168. list.value = data.list
  169. total.value = data.total
  170. } finally {
  171. loading.value = false
  172. }
  173. }
  174. /** 搜索按钮操作 */
  175. const handleQuery = () => {
  176. queryParams.pageNo = 1
  177. getList()
  178. }
  179. /** 重置按钮操作 */
  180. const resetQuery = () => {
  181. queryFormRef.value.resetFields()
  182. handleQuery()
  183. }
  184. /** 添加/修改操作 */
  185. const modalRef = ref()
  186. const openModal = (type: string, id?: number) => {
  187. modalRef.value.openModal(type, id)
  188. }
  189. /** 删除按钮操作 */
  190. const handleDelete = async (id: number) => {
  191. try {
  192. // 删除的二次确认
  193. await message.delConfirm()
  194. await ErrorCodeApi.deleteErrorCodeApi(id)
  195. message.success(t('common.delSuccess'))
  196. // 刷新列表
  197. await getList()
  198. } catch {}
  199. }
  200. /** 导出按钮操作 */
  201. const handleExport = async () => {
  202. try {
  203. // 导出的二次确认
  204. await message.exportConfirm()
  205. // 发起导出
  206. exportLoading.value = true
  207. const data = await ErrorCodeApi.excelErrorCodeApi(queryParams)
  208. download.excel(data, '错误码.xls')
  209. } catch {
  210. } finally {
  211. exportLoading.value = false
  212. }
  213. }
  214. /** 初始化 **/
  215. onMounted(() => {
  216. getList()
  217. })
  218. </script>