index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. @click="openModal('create')"
  65. v-hasPermi="['system:error-code:create']"
  66. >
  67. <Icon icon="ep:plus" class="mr-5px" /> 新增
  68. </el-button>
  69. <el-button
  70. type="success"
  71. plain
  72. @click="handleExport"
  73. :loading="exportLoading"
  74. v-hasPermi="['system:error-code:export']"
  75. >
  76. <Icon icon="ep:download" class="mr-5px" /> 导出
  77. </el-button>
  78. </el-form-item>
  79. </el-form>
  80. </content-wrap>
  81. <!-- 列表 -->
  82. <content-wrap>
  83. <el-table v-loading="loading" :data="list">
  84. <el-table-column label="编号" align="center" prop="id" />
  85. <el-table-column label="类型" align="center" prop="type" width="80">
  86. <template #default="scope">
  87. <dict-tag :type="DICT_TYPE.SYSTEM_ERROR_CODE_TYPE" :value="scope.row.type" />
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="应用名" align="center" prop="applicationName" width="200" />
  91. <el-table-column label="错误码编码" align="center" prop="code" width="120" />
  92. <el-table-column label="错误码提示" align="center" prop="message" width="300" />
  93. <el-table-column label="备注" align="center" prop="memo" width="200" />
  94. <el-table-column
  95. label="创建时间"
  96. align="center"
  97. prop="createTime"
  98. width="180"
  99. :formatter="dateFormatter"
  100. />
  101. <el-table-column label="操作" align="center" class-name="small-paddingfixed-width">
  102. <template #default="scope">
  103. <el-button
  104. link
  105. type="primary"
  106. @click="openModal('update', scope.row.id)"
  107. v-hasPermi="['system:error-code:update']"
  108. >
  109. 编辑
  110. </el-button>
  111. <el-button
  112. link
  113. type="danger"
  114. @click="handleDelete(scope.row.id)"
  115. v-hasPermi="['system:error-code:delete']"
  116. >
  117. 删除
  118. </el-button>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <!-- 分页组件 -->
  123. <Pagination
  124. :total="total"
  125. v-model:page="queryParams.pageNo"
  126. v-model:limit="queryParams.pageSize"
  127. @pagination="getList"
  128. />
  129. </content-wrap>
  130. <!-- 表单弹窗:添加/修改 -->
  131. <error-code-form ref="modalRef" @success="getList" />
  132. </template>
  133. <script setup lang="ts" name="ErrorCode">
  134. import * as ErrorCodeApi from '@/api/system/errorCode'
  135. import { DICT_TYPE, getDictOptions } from '@/utils/dict'
  136. import { dateFormatter } from '@/utils/formatTime'
  137. import ErrorCodeForm from './form.vue'
  138. import download from '@/utils/download'
  139. const message = useMessage() // 消息弹窗
  140. const { t } = useI18n() // 国际化
  141. // 遮罩层
  142. const loading = ref(true)
  143. // 导出遮罩层
  144. const exportLoading = ref(false)
  145. // 总条数
  146. const total = ref(0)
  147. // 错误码列表
  148. const list = ref([])
  149. // 查询参数
  150. const queryParams = reactive({
  151. pageNo: 1,
  152. pageSize: 10,
  153. type: undefined,
  154. applicationName: undefined,
  155. code: undefined,
  156. message: undefined,
  157. createTime: []
  158. })
  159. // 搜索的表单
  160. const queryFormRef = ref()
  161. /** 查询列表 */
  162. const getList = async () => {
  163. loading.value = true
  164. // 执行查询
  165. try {
  166. const data = await ErrorCodeApi.getErrorCodePageApi(queryParams)
  167. list.value = data.list
  168. total.value = data.total
  169. } finally {
  170. loading.value = false
  171. }
  172. }
  173. /** 搜索按钮操作 */
  174. const handleQuery = () => {
  175. queryParams.pageNo = 1
  176. getList()
  177. }
  178. /** 重置按钮操作 */
  179. const resetQuery = () => {
  180. queryFormRef.value.resetFields()
  181. handleQuery()
  182. }
  183. /** 添加/修改操作 */
  184. const modalRef = ref()
  185. const openModal = (type: string, id?: number) => {
  186. modalRef.value.openModal(type, id)
  187. }
  188. /** 删除按钮操作 */
  189. const handleDelete = async (id: number) => {
  190. try {
  191. // 删除的二次确认
  192. await message.delConfirm()
  193. await ErrorCodeApi.deleteErrorCodeApi(id)
  194. message.success(t('common.delSuccess'))
  195. // 刷新列表
  196. await getList()
  197. } catch {}
  198. }
  199. /** 导出按钮操作 */
  200. const handleExport = async () => {
  201. try {
  202. // 导出的二次确认
  203. await message.exportConfirm()
  204. // 发起导出
  205. exportLoading.value = true
  206. const data = await ErrorCodeApi.excelErrorCodeApi(queryParams)
  207. download.excel(data, '错误码.xls')
  208. } catch {
  209. } finally {
  210. exportLoading.value = false
  211. }
  212. }
  213. /** 初始化 **/
  214. onMounted(() => {
  215. getList()
  216. })
  217. </script>