index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="panel-block" v-if="state.nodeData">
  3. <div class="_p-title">
  4. <div class="text-sm">输入字段</div>
  5. <CzrButton type="add" title="添加参数" @click="onAddVars" />
  6. </div>
  7. <div class="vars">
  8. <template v-for="(item, index) in state.nodeData.__outVars">
  9. <div class="item">
  10. <varsItem
  11. :item="item"
  12. :edit="true"
  13. :del="true"
  14. @onEdit="onEditVars(item, index)"
  15. @onDel="onDelVars(item, index)"
  16. />
  17. </div>
  18. </template>
  19. </div>
  20. <div class="my-2 h-[1px] w-full bg-[#1018281f]" />
  21. <div class="vars">
  22. <template v-for="item in state.nodeData.__sysVars">
  23. <div class="item">
  24. <varsItem :item="item" />
  25. </div>
  26. </template>
  27. </div>
  28. </div>
  29. <varsDetail
  30. v-model:show="state.vars.show"
  31. :transfer="state.vars.transfer"
  32. @refresh="(val) => setVars(val)"
  33. />
  34. </template>
  35. <script setup lang="ts">
  36. import { getCurrentInstance, reactive, ref, watch } from 'vue'
  37. import varsItem from '@/views/workflow/instance/component/vars/vars-item.vue'
  38. import varsDetail from '@/views/workflow/instance/component/vars/vars-detail.vue'
  39. const emit = defineEmits([])
  40. const props = defineProps({
  41. node: <any>{},
  42. })
  43. const { proxy }: any = getCurrentInstance()
  44. const state: any = reactive({
  45. nodeData: null,
  46. vars: {
  47. show: false,
  48. transfer: {},
  49. },
  50. })
  51. watch(
  52. () => props.node,
  53. (n) => {
  54. if (n) {
  55. state.nodeData = n.data.workflowData
  56. }
  57. },
  58. { immediate: true },
  59. )
  60. const onAddVars = () => {
  61. state.vars.transfer = {
  62. mode: 'add',
  63. }
  64. state.vars.show = true
  65. }
  66. const onEditVars = (row, index) => {
  67. state.vars.transfer = {
  68. mode: 'edit',
  69. row: JSON.parse(JSON.stringify(row)),
  70. index: index,
  71. }
  72. state.vars.show = true
  73. }
  74. const onDelVars = (row, index) => {
  75. state.nodeData.__outVars.splice(index, 1)
  76. }
  77. const setVars = (val) => {
  78. if (state.vars.transfer.mode === 'add') {
  79. state.nodeData.__outVars.push(val)
  80. } else {
  81. state.nodeData.__outVars[state.vars.transfer.index] = val
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. @use '@/views/workflow/instance/component/style';
  87. .panel-block {
  88. .vars {
  89. display: flex;
  90. flex-direction: column;
  91. gap: 6px;
  92. .item {
  93. padding: 6px 10px;
  94. border: style.$borderStyle;
  95. border-radius: 8px;
  96. }
  97. }
  98. }
  99. </style>