index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div class="create-approval">
  3. <div class="create-approval-header flex flex_align-center">
  4. <div class="create-approval-header-back" v-if="false">
  5. <el-icon :size="18"><ArrowLeft /></el-icon>
  6. </div>
  7. <div class="create-approval-header-left-zh">
  8. <div class="create-approval-header-name">{{ flowName }}</div>
  9. <div class="create-approval-header-time" v-if="false">最近保存:6 分钟前</div>
  10. </div>
  11. <div class="create-approval-header-tab-list">
  12. <div
  13. v-for="(item, idx) in componentsArr"
  14. :key="idx"
  15. class="create-approval-header-tab-item"
  16. :class="[item.label === activeName ? 'active' : '']"
  17. @click="activeComponent(item)"
  18. >
  19. <span class="create-approval-header-tab-counter">{{ idx + 1 }}</span>
  20. <span>{{ item.label }}</span>
  21. </div>
  22. </div>
  23. <div class="create-approval-header-right">
  24. <el-button type="primary" @click="submitHandler">发布</el-button>
  25. </div>
  26. </div>
  27. <div class="create-approval-main">
  28. <component :is="currentComponent" ref="dyncComponent" />
  29. </div>
  30. </div>
  31. </template>
  32. <script setup name="flow_create">
  33. import { computed, ref } from 'vue'
  34. import { storeToRefs } from 'pinia'
  35. import useFlowStore from '@/store/modules/flow'
  36. import BasicInfoTab from './components/BasicInfo.vue'
  37. import ExtendSetTab from './components/ExtendSet.vue'
  38. import FlowDesignTab from './components/FlowDesign.vue'
  39. import FormDesignTab from './components/FormDesign.vue'
  40. import { ElMessage } from 'element-plus'
  41. import { useRoute } from 'vue-router'
  42. const route = useRoute()
  43. const flowStore = useFlowStore()
  44. const { flowName, flowProcessId } = storeToRefs(flowStore)
  45. const dyncComponent = ref() // 实例化子组件
  46. const componentsArr = [
  47. {
  48. component: BasicInfoTab,
  49. label: '基础信息',
  50. name: '基础信息'
  51. // ref: 'basicInfoRef'
  52. },
  53. {
  54. component: FormDesignTab,
  55. label: '表单设计',
  56. name: '表单设计'
  57. // ref: 'formDesignRef'
  58. },
  59. {
  60. component: FlowDesignTab,
  61. label: '流程设计',
  62. name: '流程设计'
  63. // ref: 'flowDesignRef'
  64. },
  65. {
  66. component: ExtendSetTab,
  67. label: '扩展设置',
  68. name: '扩展设置'
  69. // ref: 'extendSetRef'
  70. }
  71. ]
  72. const activeName = ref('基础信息')
  73. const submitHandler = () => {
  74. // 基础信息
  75. // 表单设计
  76. // 流程设计
  77. if (activeName.value === '流程设计') {
  78. dyncComponent.value.validate().then(res => {
  79. dyncComponent.value.saveDesign(res)
  80. })
  81. }
  82. // 扩展设置
  83. }
  84. const activeComponent = item => {
  85. if (!flowProcessId.value && JSON.stringify(queryObj.value) === '{}') {
  86. return ElMessage({
  87. message: '请先保存基础信息',
  88. type: 'error'
  89. })
  90. }
  91. activeName.value = item.label
  92. }
  93. const currentComponent = computed(() => {
  94. return componentsArr.find(item => item.label === activeName.value)?.component
  95. })
  96. const queryObj = computed(() => route.query)
  97. </script>
  98. <style scoped lang="scss">
  99. .create-approval {
  100. height: 100%;
  101. min-width: 1200px;
  102. min-height: 600px;
  103. overflow: auto;
  104. &-header {
  105. justify-content: flex-start;
  106. height: 64px;
  107. z-index: 12;
  108. position: relative;
  109. box-shadow: 0 1px 6px 0 rgba(0, 0, 0, 0.06);
  110. padding-left: 16px;
  111. padding-right: 20px;
  112. &-back {
  113. display: flex;
  114. justify-content: flex-start;
  115. align-items: center;
  116. height: 100%;
  117. margin-right: 15px;
  118. }
  119. &-left-zh {
  120. width: calc(50% - 316.5px);
  121. min-width: 248px;
  122. }
  123. &-name {
  124. font-weight: 500;
  125. font-size: 16px;
  126. white-space: nowrap;
  127. cursor: pointer;
  128. width: -webkit-fit-content;
  129. width: -moz-fit-content;
  130. width: fit-content;
  131. max-width: 100%;
  132. height: 24px;
  133. overflow: hidden;
  134. text-overflow: ellipsis;
  135. }
  136. &-time {
  137. width: 100%;
  138. height: 20px;
  139. line-height: 20px;
  140. font-size: 12px;
  141. color: #8f959e;
  142. overflow: hidden;
  143. white-space: nowrap;
  144. text-overflow: ellipsis;
  145. }
  146. &-tab-list {
  147. margin-left: 10px;
  148. flex-shrink: 0;
  149. display: flex;
  150. justify-content: center;
  151. }
  152. &-tab-item {
  153. font-family: PingFang SC, Microsoft YaHei;
  154. font-size: 18px;
  155. line-height: 28px;
  156. color: #646a73;
  157. margin-right: 42px;
  158. padding: 18px 0;
  159. border-bottom: 2px solid transparent;
  160. cursor: pointer;
  161. &.active {
  162. // var(--el-color-primary);
  163. border-bottom-color: var(--el-color-primary);
  164. color: var(--el-color-primary);
  165. font-weight: 500;
  166. .create-approval-header-tab-counter {
  167. border-color: var(--el-color-primary);
  168. background-color: var(--el-color-primary);
  169. color: var(--el-color-white);
  170. font-weight: 400;
  171. }
  172. }
  173. }
  174. &-tab-counter {
  175. display: inline-block;
  176. margin-right: 6px;
  177. width: 24px;
  178. height: 24px;
  179. border-radius: 50%;
  180. border: 1px solid #646a73;
  181. font-size: 16px;
  182. line-height: 22px;
  183. text-align: center;
  184. }
  185. &-right {
  186. flex: 1 1;
  187. flex-shrink: 0;
  188. display: flex;
  189. justify-content: flex-end;
  190. align-items: center;
  191. position: relative;
  192. height: 100%;
  193. width: -webkit-fit-content;
  194. width: -moz-fit-content;
  195. width: fit-content;
  196. }
  197. }
  198. &-main {
  199. height: calc(100% - 64px);
  200. }
  201. }
  202. </style>