index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <content-wrap>
  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="name">
  12. <el-input
  13. v-model="queryParams.name"
  14. placeholder="请输入表单名"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  22. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  23. <el-button type="primary" plain @click="openForm" v-hasPermi="['bpm:form:create']">
  24. <Icon icon="ep:plus" class="mr-5px" /> 新增
  25. </el-button>
  26. </el-form-item>
  27. </el-form>
  28. </content-wrap>
  29. <!-- 列表 -->
  30. <content-wrap>
  31. <el-table v-loading="loading" :data="list">
  32. <el-table-column label="编号" align="center" prop="id" />
  33. <el-table-column label="表单名" align="center" prop="name" />
  34. <el-table-column label="状态" align="center" prop="status">
  35. <template #default="scope">
  36. <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="备注" align="center" prop="remark" />
  40. <el-table-column
  41. label="创建时间"
  42. align="center"
  43. prop="createTime"
  44. :formatter="dateFormatter"
  45. />
  46. <el-table-column label="操作" align="center">
  47. <template #default="scope">
  48. <el-button
  49. link
  50. type="primary"
  51. @click="openForm(scope.row.id)"
  52. v-hasPermi="['bpm:form:update']"
  53. >
  54. 编辑
  55. </el-button>
  56. <el-button link @click="openDetail(scope.row.id)" v-hasPermi="['bpm:form:query']">
  57. 详情
  58. </el-button>
  59. <el-button
  60. link
  61. type="danger"
  62. @click="handleDelete(scope.row.id)"
  63. v-hasPermi="['bpm:form:delete']"
  64. >
  65. 删除
  66. </el-button>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. <!-- 分页 -->
  71. <Pagination
  72. :total="total"
  73. v-model:page="queryParams.pageNo"
  74. v-model:limit="queryParams.pageSize"
  75. @pagination="getList"
  76. />
  77. </content-wrap>
  78. <!-- 表单详情的弹窗 -->
  79. <Dialog title="表单详情" v-model="detailVisible" width="800">
  80. <form-create :rule="detailData.rule" :option="detailData.option" />
  81. </Dialog>
  82. </template>
  83. <script setup lang="ts" name="Form">
  84. import { DICT_TYPE } from '@/utils/dict'
  85. import { dateFormatter } from '@/utils/formatTime'
  86. import * as FormApi from '@/api/bpm/form'
  87. import { setConfAndFields2 } from '@/utils/formCreate'
  88. const message = useMessage() // 消息弹窗
  89. const { t } = useI18n() // 国际化
  90. const { push } = useRouter() // 路由
  91. const loading = ref(true) // 列表的加载中
  92. const total = ref(0) // 列表的总页数
  93. const list = ref([]) // 列表的数据
  94. const queryParams = reactive({
  95. pageNo: 1,
  96. pageSize: 10,
  97. name: null
  98. })
  99. const queryFormRef = ref() // 搜索的表单
  100. /** 查询列表 */
  101. const getList = async () => {
  102. loading.value = true
  103. try {
  104. const data = await FormApi.getFormPage(queryParams)
  105. list.value = data.list
  106. total.value = data.total
  107. } finally {
  108. loading.value = false
  109. }
  110. }
  111. /** 搜索按钮操作 */
  112. const handleQuery = () => {
  113. queryParams.pageNo = 1
  114. getList()
  115. }
  116. /** 重置按钮操作 */
  117. const resetQuery = () => {
  118. queryFormRef.value.resetFields()
  119. handleQuery()
  120. }
  121. /** 添加/修改操作 */
  122. const openForm = (id?: number) => {
  123. push({
  124. name: 'bpmFormEditor',
  125. query: {
  126. id
  127. }
  128. })
  129. }
  130. /** 删除按钮操作 */
  131. const handleDelete = async (id: number) => {
  132. try {
  133. // 删除的二次确认
  134. await message.delConfirm()
  135. // 发起删除
  136. await FormApi.deleteForm(id)
  137. message.success(t('common.delSuccess'))
  138. // 刷新列表
  139. await getList()
  140. } catch {}
  141. }
  142. /** 详情操作 */
  143. const detailVisible = ref(false)
  144. const detailData = ref({
  145. rule: [],
  146. option: {}
  147. })
  148. const openDetail = async (rowId: number) => {
  149. // 设置表单
  150. const data = await FormApi.getForm(rowId)
  151. setConfAndFields2(detailData, data.conf, data.fields)
  152. // 弹窗打开
  153. detailVisible.value = true
  154. }
  155. /** 初始化 **/
  156. onMounted(() => {
  157. getList()
  158. })
  159. </script>