index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  5. <!-- 操作:新增 -->
  6. <template #toolbar_buttons>
  7. <XButton
  8. type="primary"
  9. preIcon="ep:zoom-in"
  10. :title="t('action.add')"
  11. v-hasPermi="['system:post:create']"
  12. @click="handleCreate()"
  13. />
  14. </template>
  15. <template #actionbtns_default="{ row }">
  16. <!-- 操作:修改 -->
  17. <XTextButton
  18. preIcon="ep:edit"
  19. :title="t('action.edit')"
  20. v-hasPermi="['bpm:form:update']"
  21. @click="handleUpdate(row.id)"
  22. />
  23. <!-- 操作:详情 -->
  24. <XTextButton
  25. preIcon="ep:view"
  26. :title="t('action.detail')"
  27. v-hasPermi="['bpm:form:query']"
  28. @click="handleDetail(row.id)"
  29. />
  30. <!-- 操作:删除 -->
  31. <XTextButton
  32. preIcon="ep:delete"
  33. :title="t('action.del')"
  34. v-hasPermi="['bpm:form:delete']"
  35. @click="deleteData(row.id)"
  36. />
  37. </template>
  38. </XTable>
  39. <!-- 表单详情的弹窗 -->
  40. <XModal v-model="detailOpen" width="800" title="表单详情">
  41. <form-create :rule="detailPreview.rule" :option="detailPreview.option" v-if="detailOpen" />
  42. </XModal>
  43. </ContentWrap>
  44. </template>
  45. <script setup lang="ts" name="BpmForm">
  46. // 业务相关的 import
  47. import * as FormApi from '@/api/bpm/form'
  48. import { allSchemas } from './form.data'
  49. // 表单详情相关的变量和 import
  50. import { setConfAndFields2 } from '@/utils/formCreate'
  51. const { t } = useI18n() // 国际化
  52. const { push } = useRouter() // 路由
  53. // 列表相关的变量
  54. const [registerTable, { deleteData }] = useXTable({
  55. allSchemas: allSchemas,
  56. getListApi: FormApi.getFormPageApi,
  57. deleteApi: FormApi.deleteFormApi
  58. })
  59. // 新增操作
  60. const handleCreate = () => {
  61. push({
  62. name: 'bpmFormEditor'
  63. })
  64. }
  65. // 修改操作
  66. const handleUpdate = async (rowId: number) => {
  67. await push({
  68. name: 'bpmFormEditor',
  69. query: {
  70. id: rowId
  71. }
  72. })
  73. }
  74. // 详情操作
  75. const detailOpen = ref(false)
  76. const detailPreview = ref({
  77. rule: [],
  78. option: {}
  79. })
  80. const handleDetail = async (rowId: number) => {
  81. // 设置表单
  82. const data = await FormApi.getFormApi(rowId)
  83. setConfAndFields2(detailPreview, data.conf, data.fields)
  84. // 弹窗打开
  85. detailOpen.value = true
  86. }
  87. </script>