condition-item.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="condition-item">
  3. <div class="condition-item-body">
  4. <div class="top">
  5. <div class="left">
  6. <slot name="source" :value="item" :index="index"/>
  7. </div>
  8. <div class="_p_split"/>
  9. <selectPopover class="w-[60px]" v-model:value="item.method" :options="item.source.type === 'Number' ? OptionsConditionNumber : OptionsConditionString"/>
  10. </div>
  11. <div class="bottom" :style="{
  12. padding: item.type === ConditionType.Constant ? '2px 6px' : '6px'
  13. }" v-if="![
  14. ConditionString.Empty,
  15. ConditionString.NotEmpty,
  16. ConditionNumber.Empty,
  17. ConditionNumber.NotEmpty,
  18. ].includes(item.method)">
  19. <selectPopover class="w-[50px]" v-model:value="item.type" :options="OptionsConditionType"/>
  20. <div class="_p_split"/>
  21. <div class="target">
  22. <template v-if="item.type === ConditionType.Constant">
  23. <CzrFormColumn
  24. :span="24"
  25. label-width="0px"
  26. :link="item.source.type === 'Number' ? 'number' : 'input'"
  27. v-model:param="item.target"
  28. :transparent="true"
  29. />
  30. </template>
  31. <template v-else-if="item.type === ConditionType.Variable">
  32. <slot name="target" :value="item" :index="index"/>
  33. </template>
  34. </div>
  35. </div>
  36. </div>
  37. <!-- @click="$emit('update:conditions', conditions.filter((_, i) => i !== index))"-->
  38. <div class="condition-item-del __hover" @click="$emit('onDel')">
  39. <SvgIcon name="czr_del" size="14" color="#666666"/>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup lang="ts">
  44. import {getCurrentInstance, reactive, watch} from "vue";
  45. import {
  46. ConditionMode, ConditionNumber, ConditionString, ConditionType,
  47. OptionsConditionNumber,
  48. OptionsConditionString,
  49. OptionsConditionType
  50. } from "@/views/workflow/types";
  51. import selectPopover from '@/views/workflow/instance/component/select-popover/index.vue'
  52. const emits = defineEmits(['onDel'])
  53. const props = defineProps({
  54. item: <any>{},
  55. index: {},
  56. })
  57. const {proxy}: any = getCurrentInstance()
  58. const state: any = reactive({})
  59. watch(() => props.item.source, (n) => {
  60. if (n.type === 'Number') {
  61. props.item.method = ConditionNumber.Equals
  62. } else {
  63. props.item.method = ConditionString.Includes
  64. }
  65. props.item.type = ConditionType.Constant
  66. props.item.target = ''
  67. }, {deep: true})
  68. watch(() => props.item.method, (n) => {
  69. props.item.type = ConditionType.Constant
  70. props.item.target = ''
  71. }, {deep: true})
  72. watch(() => props.item.type, (n) => {
  73. props.item.target = ''
  74. }, {deep: true})
  75. </script>
  76. <style lang="scss" scoped>
  77. @use "@/views/workflow/instance/component/style";
  78. .condition-main {
  79. flex: 1;
  80. display: flex;
  81. .condition-mode {
  82. height: calc(100% - 28px);
  83. margin: 14px 6px 14px 0;
  84. width: 44px;
  85. display: flex;
  86. align-items: center;
  87. justify-content: center;
  88. position: relative;
  89. >div:nth-child(1) {
  90. border: style.$borderStyle;
  91. width: 10px;
  92. height: 100%;
  93. border-radius: 8px 0 0 8px;
  94. border-right: none;
  95. position: absolute;
  96. right: 4px;
  97. }
  98. >div:nth-child(2) {
  99. z-index: 2;
  100. position: absolute;
  101. right: 0;
  102. width: 20px;
  103. height: 30px;
  104. background-color: #ffffff;
  105. }
  106. >div:nth-child(3) {
  107. z-index: 3;
  108. color: var(--czr-main-color);
  109. border: style.$borderStyle;
  110. border-radius: 4px;
  111. display: flex;
  112. align-items: center;
  113. justify-content: center;
  114. width: 32px;
  115. height: 22px;
  116. background-color: #ffffff;
  117. font-size: 12px;
  118. }
  119. }
  120. .condition-list {
  121. flex: 1;
  122. display: flex;
  123. flex-direction: column;
  124. gap: 8px;
  125. .condition-item {
  126. display: flex;
  127. .condition-item-body {
  128. border-radius: 8px;
  129. background-color: style.$inputBg;
  130. flex: 1;
  131. overflow: hidden;
  132. .top {
  133. padding: 6px;
  134. display: flex;
  135. align-items: center;
  136. overflow: hidden;
  137. .left {
  138. flex: 1;
  139. overflow: hidden;
  140. }
  141. .right {
  142. width: 40px;
  143. }
  144. }
  145. .bottom {
  146. border-top: style.$borderStyle;
  147. display: flex;
  148. align-items: center;
  149. .target {
  150. flex: 1;
  151. }
  152. }
  153. }
  154. .condition-item-del {
  155. margin: 10px 0 0 6px;
  156. }
  157. }
  158. }
  159. }
  160. </style>