index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <!-- <doc-alert title="工作流手册" url="https://doc.iocoder.cn/bpm/" /> -->
  3. <ContentWrap>
  4. <!-- 搜索工作栏 -->
  5. <el-form
  6. class="-mb-15px"
  7. :model="queryParams"
  8. ref="queryFormRef"
  9. :inline="true"
  10. label-width="68px"
  11. >
  12. <el-form-item label="分类名" prop="name">
  13. <el-input
  14. v-model="queryParams.name"
  15. placeholder="请输入分类名"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. class="!w-240px"
  19. />
  20. </el-form-item>
  21. <el-form-item label="分类标志" prop="code">
  22. <el-input
  23. v-model="queryParams.code"
  24. placeholder="请输入分类标志"
  25. clearable
  26. @keyup.enter="handleQuery"
  27. class="!w-240px"
  28. />
  29. </el-form-item>
  30. <el-form-item label="分类状态" prop="status">
  31. <el-select
  32. v-model="queryParams.status"
  33. placeholder="请选择分类状态"
  34. clearable
  35. class="!w-240px"
  36. >
  37. <el-option
  38. v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
  39. :key="dict.value"
  40. :label="dict.label"
  41. :value="dict.value"
  42. />
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="创建时间" prop="createTime">
  46. <el-date-picker
  47. v-model="queryParams.createTime"
  48. value-format="YYYY-MM-DD HH:mm:ss"
  49. type="daterange"
  50. start-placeholder="开始日期"
  51. end-placeholder="结束日期"
  52. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  53. class="!w-240px"
  54. />
  55. </el-form-item>
  56. <el-form-item>
  57. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  58. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  59. <el-button
  60. type="primary"
  61. plain
  62. @click="openForm('create')"
  63. v-hasPermi="['bpm:category:create']"
  64. >
  65. <Icon icon="ep:plus" class="mr-5px" /> 新增
  66. </el-button>
  67. </el-form-item>
  68. </el-form>
  69. </ContentWrap>
  70. <!-- 列表 -->
  71. <ContentWrap>
  72. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  73. <el-table-column label="分类编号" align="center" prop="id" />
  74. <el-table-column label="分类名" align="center" prop="name" />
  75. <el-table-column label="分类标志" align="center" prop="code" />
  76. <el-table-column label="分类描述" align="center" prop="description" />
  77. <el-table-column label="分类状态" align="center" prop="status">
  78. <template #default="scope">
  79. <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="分类排序" align="center" prop="sort" />
  83. <el-table-column
  84. label="创建时间"
  85. align="center"
  86. prop="createTime"
  87. :formatter="dateFormatter"
  88. width="180px"
  89. />
  90. <el-table-column label="操作" align="center">
  91. <template #default="scope">
  92. <el-button
  93. link
  94. type="primary"
  95. @click="openForm('update', scope.row.id)"
  96. v-hasPermi="['bpm:category:update']"
  97. >
  98. 编辑
  99. </el-button>
  100. <el-button
  101. link
  102. type="danger"
  103. @click="handleDelete(scope.row.id)"
  104. v-hasPermi="['bpm:category:delete']"
  105. >
  106. 删除
  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. <CategoryForm ref="formRef" @success="getList" />
  121. </template>
  122. <script setup lang="ts">
  123. import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
  124. import { dateFormatter } from '@/utils/formatTime'
  125. import { CategoryApi, CategoryVO } from '@/api/bpm/category'
  126. import CategoryForm from './CategoryForm.vue'
  127. /** BPM 流程分类 列表 */
  128. defineOptions({ name: 'BpmCategory' })
  129. const message = useMessage() // 消息弹窗
  130. const { t } = useI18n() // 国际化
  131. const loading = ref(true) // 列表的加载中
  132. const list = ref<CategoryVO[]>([]) // 列表的数据
  133. const total = ref(0) // 列表的总页数
  134. const queryParams = reactive({
  135. pageNo: 1,
  136. pageSize: 10,
  137. name: undefined,
  138. code: undefined,
  139. status: undefined,
  140. createTime: []
  141. })
  142. const queryFormRef = ref() // 搜索的表单
  143. const exportLoading = ref(false) // 导出的加载中
  144. /** 查询列表 */
  145. const getList = async () => {
  146. loading.value = true
  147. try {
  148. const data = await CategoryApi.getCategoryPage(queryParams)
  149. list.value = data.list
  150. total.value = data.total
  151. } finally {
  152. loading.value = false
  153. }
  154. }
  155. /** 搜索按钮操作 */
  156. const handleQuery = () => {
  157. queryParams.pageNo = 1
  158. getList()
  159. }
  160. /** 重置按钮操作 */
  161. const resetQuery = () => {
  162. queryFormRef.value.resetFields()
  163. handleQuery()
  164. }
  165. /** 添加/修改操作 */
  166. const formRef = ref()
  167. const openForm = (type: string, id?: number) => {
  168. formRef.value.open(type, id)
  169. }
  170. /** 删除按钮操作 */
  171. const handleDelete = async (id: number) => {
  172. try {
  173. // 删除的二次确认
  174. await message.delConfirm()
  175. // 发起删除
  176. await CategoryApi.deleteCategory(id)
  177. message.success(t('common.delSuccess'))
  178. // 刷新列表
  179. await getList()
  180. } catch {}
  181. }
  182. /** 初始化 **/
  183. onMounted(() => {
  184. getList()
  185. })
  186. </script>