subProcess.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="node-wrap">
  3. <!-- 节点显示 start -->
  4. <div class="node-wrap-box" :class="[disabled ? 'node-wrap-box--disabled' : '', `node-wrap-box--${nodeConfig.local_status}`]">
  5. <div class="title" style="background: #646cff">
  6. <el-icon class="icon"><Clock /></el-icon>
  7. <span v-show="!isEditTitle" class="title_label" @click="editTitle('box_nodeTitle')"
  8. >{{ nodeConfig.nodeName }}<el-icon v-if="!disabled" class="edit-icon"><edit /></el-icon
  9. ></span>
  10. <el-input
  11. v-show="isEditTitle"
  12. ref="box_nodeTitle"
  13. v-model="nodeConfig.nodeName"
  14. clearable
  15. size="small"
  16. @blur="saveTitle"
  17. @keyup.enter="saveTitle"
  18. ></el-input>
  19. <el-icon v-if="!disabled" class="close" @click.stop="delNode()"><close /></el-icon>
  20. </div>
  21. <div class="content" @click="show">
  22. <span v-if="toText(nodeConfig)">{{ toText(nodeConfig) }}</span>
  23. <span v-else class="placeholder">请选择子流程规则</span>
  24. </div>
  25. </div>
  26. <!-- 节点显示 end -->
  27. <!-- 添加节点 start -->
  28. <add-node v-model="nodeConfig.childNode" :disabled="disabled"></add-node>
  29. <!-- 添加节点 end -->
  30. <!-- 打开侧边弹窗 start -->
  31. <el-drawer v-model="drawer" title="子流程设置" destroy-on-close append-to-body :size="600" class="aDrawer">
  32. <template #header>
  33. <div class="node-wrap-drawer__title">
  34. <label v-show="!isEditTitle" @click="editTitle('nodeTitle')"
  35. >{{ form.nodeName }}<el-icon class="node-wrap-drawer__title-edit"><edit /></el-icon
  36. ></label>
  37. <el-input v-show="isEditTitle" ref="nodeTitle" v-model="form.nodeName" clearable @blur="saveTitle" @keyup.enter="saveTitle"></el-input>
  38. </div>
  39. </template>
  40. <el-container>
  41. <el-main>
  42. <div class="self-radio-group">
  43. <el-radio-group v-model="radio1">
  44. <el-radio-button v-for="v of subProcessType" :key="v.value" :label="v.value">{{ v.label }}</el-radio-button>
  45. </el-radio-group>
  46. </div>
  47. <!-- 设置子流程 -->
  48. <div v-show="radio1 === '1'">
  49. <div class=""><el-text class="mx-1">选择子流程</el-text></div>
  50. <div>
  51. <el-select v-model="subProcessValue" placeholder="选择子流程" style="width: 240px; margin: 10px 20px 10px 0px">
  52. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
  53. </el-select>
  54. <el-link :underline="false"
  55. ><el-icon class="el-icon--right"><View /></el-icon> 预览子流程</el-link
  56. >
  57. </div>
  58. </div>
  59. <!-- 表单设置 -->
  60. <div v-show="radio1 === '2'">
  61. <el-table ref="multipleTableRef" :data="form.extendConfig.formConfig" style="width: 100%" border>
  62. <el-table-column property="label" label="表单字段" align="center" />
  63. <el-table-column align="center">
  64. <template #header>操作权限</template>
  65. <template #default="scope">
  66. <el-radio-group v-model="scope.row.opera">
  67. <el-radio label="0" size="small">只读</el-radio>
  68. <el-radio label="1" size="small">编辑</el-radio>
  69. <el-radio label="2" size="small">隐藏</el-radio>
  70. </el-radio-group>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. </div>
  75. </el-main>
  76. <el-footer>
  77. <el-button type="primary" @click="save">保存</el-button>
  78. <el-button @click="drawer = false">取消</el-button>
  79. </el-footer>
  80. </el-container>
  81. </el-drawer>
  82. <!-- 打开侧边弹窗 end -->
  83. </div>
  84. </template>
  85. <script>
  86. import addNode from './addNode'
  87. import { subProcessType } from './config'
  88. import { ElMessage } from 'element-plus'
  89. import { mapState } from 'pinia'
  90. import useFlowStore from '@/store/modules/flow'
  91. export default {
  92. components: {
  93. addNode
  94. },
  95. props: {
  96. modelValue: { type: Object, default: () => {} },
  97. disabled: {
  98. type: Boolean,
  99. default: false
  100. }
  101. },
  102. data() {
  103. return {
  104. nodeConfig: {},
  105. drawer: false,
  106. isEditTitle: false,
  107. form: {},
  108. radio1: '1',
  109. subProcessType,
  110. subProcessValue: '',
  111. options: []
  112. }
  113. },
  114. watch: {
  115. modelValue() {
  116. this.nodeConfig = this.modelValue
  117. }
  118. },
  119. mounted() {
  120. this.nodeConfig = this.modelValue
  121. },
  122. methods: {
  123. show() {
  124. if (this.disabled) return
  125. this.form = {}
  126. this.form = JSON.parse(JSON.stringify(this.nodeConfig))
  127. const { formStructure } = JSON.parse(this.processForm)
  128. const formConfig = this.form.extendConfig?.formConfig || []
  129. const operateTable = (formStructure?.fields || []).map(item => {
  130. let opera = '1'
  131. formConfig.map(i => {
  132. if (item.id === i.id) {
  133. opera = i.opera
  134. }
  135. })
  136. return { label: item.label, id: item.id, opera: opera }
  137. })
  138. this.form.extendConfig = { formConfig: operateTable }
  139. this.drawer = true
  140. },
  141. editTitle(refName) {
  142. if (this.disabled) return
  143. this.isEditTitle = true
  144. this.$nextTick(() => {
  145. if (this.$refs[refName]) {
  146. this.$refs[refName].focus()
  147. }
  148. })
  149. },
  150. saveTitle() {
  151. this.isEditTitle = false
  152. },
  153. save() {
  154. if (!this.form.extendConfig.trigger) {
  155. return ElMessage.warning('请填写 TaskTrigger 实现 class')
  156. }
  157. if (this.form.triggerType === '2' && this.form.delayType === '1' && !Number(this.fixedDuration)) {
  158. return ElMessage.warning('等待时间数值最小为1')
  159. }
  160. this.form.extendConfig.time =
  161. this.form.triggerType === '2'
  162. ? this.form.delayType === '1'
  163. ? `${this.fixedDuration}:${this.fixedDurationType}`
  164. : `${this.automaticComputed}`
  165. : ''
  166. this.$emit('update:modelValue', this.form)
  167. this.drawer = false
  168. },
  169. delNode() {
  170. this.$emit('update:modelValue', this.nodeConfig.childNode)
  171. },
  172. toText(nodeConfig) {
  173. const { triggerType, delayType } = nodeConfig
  174. if (triggerType === '1') {
  175. return `立即执行`
  176. } else if (triggerType === '2') {
  177. if (delayType === '1') {
  178. return `延迟执行,等待${this.fixedDuration}${mapTip[this.fixedDurationType]}`
  179. } else if (delayType === '2') {
  180. const tip = `延迟执行,至当天`
  181. return !this.automaticComputed ? tip : `${tip}${this.automaticComputed}`
  182. }
  183. } else {
  184. return false
  185. }
  186. }
  187. },
  188. computed: {
  189. ...mapState(useFlowStore, ['processForm']) //映射函数,取出processForm
  190. }
  191. }
  192. </script>
  193. <style></style>