condition.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <div>
  3. <div v-for="(item, index) in condition" :key="index">
  4. <div v-if="index > 0"><el-divider>或满足以下条件</el-divider></div>
  5. <div class="type-item">
  6. <div class="flex-warp item_list">
  7. <div v-for="(vo, i) in item.list" :key="i">
  8. <div class="items">
  9. <el-button
  10. style="background: #fff; color: #000;border: 1px solid #d9cde3;margin-left: 10px;margin-right: 10px;"
  11. v-if="i > 0">并且</el-button>
  12. <el-popover placement="bottom" trigger="click">
  13. <template #reference>
  14. <el-button style="background: #9adbff4d; color: #00a4fe;border: 1px solid #00a4fe4d;">{{ vo.param ||
  15. '请选择参数' }}</el-button>
  16. </template>
  17. <div class="popover-content">
  18. <ul>
  19. <li v-for="option in options" :key="option.value" @click="vo.param = option.value;">{{ option.label }}
  20. </li>
  21. </ul>
  22. </div>
  23. </el-popover>
  24. <el-popover placement="bottom" trigger="click">
  25. <template #reference>
  26. <el-button style="background: #a3caff4d; color: #2f54eb;border: 1px solid #2f54eb4d;">{{ vo.operator ||
  27. '操作符' }}</el-button>
  28. </template>
  29. <div class="popover-content">
  30. <ul>
  31. <li v-for="option in options" :key="option.value" @click="vo.operator = option.value;">{{ option.label
  32. }}</li>
  33. </ul>
  34. </div>
  35. </el-popover>
  36. <el-popover placement="bottom" trigger="click">
  37. <template #reference>
  38. <el-button style="background: #bc7dee1a; color: #692ca7;border: 1px solid #bc7dee80;">{{ vo.value ||
  39. '参数值' }}</el-button>
  40. </template>
  41. <div class="popover-content">
  42. <ul>
  43. <li v-for="option in options" :key="option.value" @click="vo.value = option.value;">{{ option.label }}
  44. </li>
  45. </ul>
  46. </div>
  47. </el-popover>
  48. <el-icon size="16" v-if="i > 0" @click="DelSceneItem(index)" style="position: relative;top: -13px;">
  49. <CircleClose />
  50. </el-icon>
  51. </div>
  52. </div>
  53. <div style=" padding-top: 12px;" @click="addSceneItem(index)">
  54. <el-icon size="18" style=" font-size: 24px;">
  55. <CirclePlus size="18"/>
  56. </el-icon>
  57. </div>
  58. </div>
  59. <el-icon size="26" @click="delScene(index)" v-if="index > 0"
  60. style="top: -69px;position: relative;font-size: 26px;right: 15px;">
  61. <CircleClose />
  62. </el-icon>
  63. </div>
  64. </div>
  65. <div class="mt15"><el-button @click="addScene()">增加触发条件</el-button></div>
  66. </div>
  67. </template>
  68. <script lang="ts" setup>
  69. import { PropType, ref } from 'vue'
  70. import { CirclePlus, CircleClose, Right } from '@element-plus/icons-vue';
  71. const options = [
  72. { label: '选项一', value: 'option1' },
  73. { label: '选项二', value: 'option2' },
  74. { label: '选项三', value: 'option3' },
  75. ];
  76. interface IConditionItem {
  77. param?: string;
  78. operator?: string;
  79. value?: string;
  80. }
  81. interface IValueType {
  82. list: IConditionItem[] ;
  83. }
  84. const props = defineProps({
  85. condition: {
  86. type: Array as PropType<IValueType[]> | undefined,
  87. default: () => []
  88. },
  89. operate_index: {
  90. type: Number,
  91. default: () => 0
  92. }
  93. })
  94. const addSceneItem = (index: any | number) => {
  95. props.condition[index].list.push({
  96. 'param': '',
  97. 'operator': '',
  98. 'value': ''
  99. })
  100. }
  101. const DelSceneItem = (index: any | number) => {
  102. props.condition[index].list.splice(index, 1);
  103. }
  104. const addScene = () => {
  105. props.condition.push({
  106. 'list': [{
  107. 'param': '',
  108. 'operator': '',
  109. 'value': ''
  110. }],
  111. });
  112. };
  113. const delScene = (index: number) => {
  114. props.condition.splice(index, 1);
  115. }
  116. </script>
  117. <style scoped lang="scss">
  118. ::v-deep .el-divider__text {
  119. background: #f6f6f6 !important;
  120. }
  121. //先保留
  122. // ::v-deep .condition_value{
  123. // .el-input__wrapper {
  124. // width: 120px;
  125. // background: #9adbff4d !important;
  126. // box-shadow:0px !important;
  127. // .el-input__inner{
  128. // color: #00a4fe;
  129. // text-align: center;
  130. // }
  131. // .el-input__wrapper .is-focus{
  132. // box-shadow:0px !important;
  133. // }
  134. // .el-input__inner::placeholder{
  135. // color: #00a4fe;
  136. // }
  137. // }
  138. // }
  139. .popover-content {
  140. padding: 0px;
  141. }
  142. .popover-content ul {
  143. list-style-type: none;
  144. padding: 0;
  145. }
  146. .popover-content li {
  147. cursor: pointer;
  148. padding: 5px;
  149. }
  150. .popover-content li:hover {
  151. background-color: #e6f7ff;
  152. }
  153. .type-item {
  154. margin-top: 15px;
  155. .conicon {
  156. cursor: pointer;
  157. }
  158. .item_list {
  159. background: #fff;
  160. border: 1px dashed #959596;
  161. .items {
  162. padding: 10px;
  163. .el-select {
  164. width: 99px;
  165. }
  166. .el-select--default {
  167. --el-select-border-color-hover: var(--el-border-color-hover);
  168. --el-select-disabled-border: var(--el-disabled-border-color);
  169. --el-select-font-size: var(--el-font-size-base);
  170. --el-select-close-hover-color: var(--el-text-color-secondary);
  171. --el-select-input-color: var(--el-text-color-placeholder);
  172. --el-select-multiple-input-color: var(--el-text-color-regular);
  173. --el-select-input-focus-border-color: var(--el-color-primary);
  174. --el-select-input-font-size: 14px;
  175. }
  176. }
  177. }
  178. .title {
  179. height: 40px;
  180. .icon {
  181. margin-left: 2px;
  182. margin-right: 10px;
  183. width: 5px;
  184. height: 20px;
  185. background-color: #315efb;
  186. }
  187. }
  188. .product {
  189. .el-form-item {
  190. margin-left: 30px;
  191. margin-bottom: 10px;
  192. margin-top: 10px;
  193. }
  194. }
  195. }
  196. </style>