index.vue 5.6 KB

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