index_new.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <ContentWrap>
  3. <div class="flex justify-between pl-20px items-center">
  4. <h3 class="font-extrabold">流程模型</h3>
  5. <!-- 搜索工作栏 -->
  6. <el-form
  7. v-if="!isCategorySorting"
  8. class="-mb-15px flex"
  9. :model="queryParams"
  10. ref="queryFormRef"
  11. :inline="true"
  12. label-width="68px"
  13. >
  14. <el-form-item align="right" prop="key" class="ml-auto">
  15. <el-input
  16. v-model="queryParams.key"
  17. placeholder="搜索流程"
  18. clearable
  19. @keyup.enter="handleQuery"
  20. class="!w-240px"
  21. >
  22. <template #prefix>
  23. <Icon icon="ep:search" class="mx-10px" />
  24. </template>
  25. </el-input>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" @click="openForm('create')" v-hasPermi="['bpm:model:create']">
  29. <Icon icon="ep:plus" class="mr-5px" /> 新建模型
  30. </el-button>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-dropdown @command="(command) => handleCommand(command)" placement="bottom-end">
  34. <el-button class="w-30px" plain>
  35. <Icon icon="ep:setting" />
  36. </el-button>
  37. <template #dropdown>
  38. <el-dropdown-menu>
  39. <el-dropdown-item command="handleAddCategory">
  40. <Icon icon="ep:circle-plus" :size="13" class="mr-5px" />
  41. 新建分类
  42. </el-dropdown-item>
  43. <el-dropdown-item command="handleSort">
  44. <Icon icon="fa:sort-amount-desc" :size="13" class="mr-5px" />
  45. 分类排序
  46. </el-dropdown-item>
  47. </el-dropdown-menu>
  48. </template>
  49. </el-dropdown>
  50. </el-form-item>
  51. </el-form>
  52. <template v-else>
  53. <el-button type="primary" @click="cancelSort"> 取 消 </el-button>
  54. <el-button type="primary" @click="saveSort"> 保存排序 </el-button>
  55. </template>
  56. </div>
  57. <el-divider />
  58. <!-- 分类卡片组 -->
  59. <div class="px-15px">
  60. <ContentWrap
  61. v-loading="loading"
  62. :body-style="{ padding: 0 }"
  63. v-for="(list, title) in categoryGroup"
  64. :key="title"
  65. >
  66. <CategoryDraggableModel
  67. ref="draggableModelRef"
  68. :isCategorySorting="isCategorySorting"
  69. :dataList="list"
  70. :title="title"
  71. @success="getList"
  72. />
  73. </ContentWrap>
  74. </div>
  75. </ContentWrap>
  76. <!-- 表单弹窗:添加/修改流程 -->
  77. <ModelForm ref="formRef" @success="getList" />
  78. <!-- 弹窗:表单详情 -->
  79. <Dialog title="表单详情" v-model="formDetailVisible" width="800">
  80. <form-create :rule="formDetailPreview.rule" :option="formDetailPreview.option" />
  81. </Dialog>
  82. </template>
  83. <script lang="ts" setup>
  84. import * as ModelApi from '@/api/bpm/model'
  85. import ModelForm from './ModelForm.vue'
  86. import { groupBy } from 'lodash-es'
  87. import { mockData } from './mock'
  88. import CategoryDraggableModel from './CategoryDraggableModel.vue'
  89. defineOptions({ name: 'BpmModel' })
  90. const draggableModelRef = ref()
  91. const loading = ref(true) // 列表的加载中
  92. const isCategorySorting = ref(false) // 是否正处于排序状态
  93. const queryParams = reactive({
  94. pageNo: 1,
  95. pageSize: 10,
  96. key: undefined,
  97. name: undefined,
  98. category: undefined
  99. })
  100. const queryFormRef = ref() // 搜索的表单
  101. const categoryGroup = ref<any>({}) // 按照category分组的数据
  102. /** 查询列表 */
  103. const getList = async () => {
  104. loading.value = true
  105. try {
  106. // TODO 芋艿:这里需要一个不分页查全部的流程模型接口,并且每条数据都应包含categoryId字段,用于重命名/删除分类。
  107. const data = await ModelApi.getModelPage(queryParams)
  108. data.list = mockData
  109. categoryGroup.value = groupBy(data.list, 'categoryName')
  110. draggableModelRef.value?.updateTableData()
  111. } finally {
  112. loading.value = false
  113. }
  114. }
  115. /** 搜索按钮操作 */
  116. const handleQuery = () => {
  117. queryParams.pageNo = 1
  118. getList()
  119. }
  120. /** 添加/修改操作 */
  121. const formRef = ref()
  122. const openForm = (type: string, id?: number) => {
  123. formRef.value.open(type, id)
  124. }
  125. /** 流程表单的详情按钮操作 */
  126. const formDetailVisible = ref(false)
  127. const formDetailPreview = ref({
  128. rule: [],
  129. option: {}
  130. })
  131. /** 右上角设置按钮 */
  132. const handleCommand = (command: string) => {
  133. switch (command) {
  134. case 'handleAddCategory':
  135. handleAddCategory()
  136. break
  137. case 'handleSort':
  138. handleSort()
  139. break
  140. default:
  141. break
  142. }
  143. }
  144. // 新建分类
  145. const handleAddCategory = () => {}
  146. // 分类排序
  147. const handleSort = () => {
  148. isCategorySorting.value = true
  149. }
  150. // 取消排序
  151. const cancelSort = () => {
  152. isCategorySorting.value = false
  153. }
  154. // 保存排序
  155. const saveSort = () => {}
  156. /** 初始化 **/
  157. onMounted(async () => {
  158. await getList()
  159. })
  160. </script>
  161. <style lang="scss" scoped>
  162. :deep() {
  163. .el-card {
  164. border-radius: 8px;
  165. }
  166. }
  167. </style>