index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!-- 模板区域 -->
  2. <template>
  3. <div>
  4. <div class="flex f-c a-start m-top-20" style="width: 100%;">
  5. <el-row v-for="(item, index) in props.rulesAttrList" :key="index" class="roleClass flex a-c" style="width: 100%;">
  6. <el-col :span="5">
  7. <el-input v-model="item.attrName" disabled />
  8. </el-col>
  9. <el-col :span="3">
  10. <el-select v-model="item.operator" placeholder="运算符" style="width: 100px; margin: 0 10px;"
  11. :disabled="item.attrType !== 'inputNumber' && item.attrType !== 'datetime' && item.attrType !== 'inputTag'">
  12. <template v-if="item.attrType == 'inputTag'">
  13. <el-option label="包含" value="1"></el-option>
  14. <el-option label="不包含" value="2"></el-option>
  15. </template>
  16. <template v-else>
  17. <el-option v-for="(rulesDictitem, rulesDictindex) in item.rulesDict" :key="rulesDictindex"
  18. :label="rulesDictitem.label" :value="rulesDictitem.value" />
  19. </template>
  20. </el-select>
  21. </el-col>
  22. <el-col :span="15">
  23. <template v-if="item.attrType == 'radio'">
  24. <el-select v-model="item.min" placeholder="选择值" clearable filterable>
  25. <el-option v-for="dictLabalitem in item.dictLabal" :key="dictLabalitem.id" :label="dictLabalitem.name"
  26. :value="dictLabalitem.code" />
  27. </el-select>
  28. </template>
  29. <template v-if="item.attrType == 'checkbox'">
  30. <el-select v-model="item.minArray" placeholder="选择值" clearable filterable multiple
  31. @change="change($event, index)">
  32. <el-option v-for="dictLabalitem in item.dictLabal" :key="dictLabalitem.id" :label="dictLabalitem.name"
  33. :value="dictLabalitem.name" />
  34. </el-select>
  35. </template>
  36. <template v-if="item.attrType == 'inputNumber'">
  37. <template v-if="item.operator == '1' || item.operator == null">
  38. <el-input-number v-model="item.min"></el-input-number>
  39. <span style="margin: 0 10px ;">-</span>
  40. <el-input-number v-model="item.max"></el-input-number>
  41. </template>
  42. <template v-if="item.operator == '2'">
  43. <span><</span>
  44. <el-input-number v-model="item.min"></el-input-number>
  45. </template>
  46. <template v-if="item.operator == '3'">
  47. <span>≤</span>
  48. <el-input-number v-model="item.min"></el-input-number>
  49. </template>
  50. <template v-if="item.operator == '4'">
  51. <span>></span>
  52. <el-input-number v-model="item.max"></el-input-number>
  53. </template>
  54. <template v-if="item.operator == '5'">
  55. <span>≥</span>
  56. <el-input-number v-model="item.max"></el-input-number>
  57. </template>
  58. </template>
  59. <template v-if="item.attrType == 'select'">
  60. <el-select v-model="item.minArray" placeholder="选择值" clearable filterable multiple
  61. @change="change($event, index)">
  62. <el-option v-for="dictLabalitem in item.dictLabal" :key="dictLabalitem.id" :label="dictLabalitem.name"
  63. :value="item.attrName == '车辆类型' ? dictLabalitem.code : dictLabalitem.name" />
  64. </el-select>
  65. </template>
  66. <template v-if="item.attrType == 'inputTag'">
  67. <el-input-tag v-model="item.minArray" @change="change($event, index)" placeholder="输入内容后按回车键隔开" />
  68. </template>
  69. <template v-if="item.attrType == 'datetime'">
  70. <template v-if="item.operator == '1' || item.operator == null">
  71. <el-date-picker v-model="item.min" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  72. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 250px;">
  73. </el-date-picker>
  74. <span>~</span>
  75. <el-date-picker v-model="item.max" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  76. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 250px;">
  77. </el-date-picker>
  78. </template>
  79. <template v-if="item.operator == '2'">
  80. <span><</span>
  81. <el-date-picker v-model="item.min" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  82. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 170px;">
  83. </el-date-picker>
  84. </template>
  85. <template v-if="item.operator == '3'">
  86. <span>≤</span>
  87. <el-date-picker v-model="item.min" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  88. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 170px;">
  89. </el-date-picker>
  90. </template>
  91. <template v-if="item.operator == '4'">
  92. <span>></span>
  93. <el-date-picker v-model="item.max" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  94. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 170px;">
  95. </el-date-picker>
  96. </template>
  97. <template v-if="item.operator == '5'">
  98. <span>≥</span>
  99. <el-date-picker v-model="item.max" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  100. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 170px;">
  101. </el-date-picker>
  102. </template>
  103. </template>
  104. </el-col>
  105. <el-col :span="1">
  106. <el-icon color="#666" size="20" style="margin-left: 10px;" @click="attrDel(index)">
  107. <CircleCloseFilled />
  108. </el-icon>
  109. </el-col>
  110. </el-row>
  111. </div>
  112. </div>
  113. </template>
  114. <!-- 行为区域 -->
  115. <script lang='ts' setup>
  116. import { defineProps, defineEmits } from "vue";
  117. const props = defineProps<{
  118. rulesAttrList: any[],//list集合
  119. }>();
  120. const emits = defineEmits(["Del", 'save', 'selectChange']);
  121. //右侧删除图标
  122. const attrDel = (index: number) => {
  123. console.log(index)
  124. emits('Del', index)
  125. }
  126. const change = (e: string[] | undefined, index: number) => {
  127. console.log(e)
  128. emits('selectChange', { e, index })
  129. }
  130. </script>
  131. <!-- 样式区域 -->
  132. <style lang='scss' scoped>
  133. .roleClass {
  134. margin-bottom: 10px;
  135. }
  136. </style>