index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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' || disabled">
  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 :disabled="disabled">
  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 :disabled="disabled"
  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. <el-row class="flex a-c">
  38. <template v-if="item.operator == '1' || item.operator == null">
  39. <el-col :span="11">
  40. <el-input-number v-model="item.min" :disabled="disabled" style="width: 100%;"></el-input-number>
  41. </el-col>
  42. <el-col :span="2">
  43. <div class="flex a-c j-c " style="font-size: 14px;color: #333;">至</div>
  44. </el-col>
  45. <el-col :span="11">
  46. <el-input-number v-model="item.max" :disabled="disabled" style="width: 100%;"></el-input-number>
  47. </el-col>
  48. </template>
  49. <template v-if="item.operator == '2'">
  50. <el-col :span="24">
  51. <el-input-number v-model="item.min" :disabled="disabled" style="width: 100%;"></el-input-number>
  52. </el-col>
  53. </template>
  54. <template v-if="item.operator == '3'">
  55. <el-col :span="24">
  56. <el-input-number v-model="item.min" :disabled="disabled" style="width: 100%;"></el-input-number>
  57. </el-col>
  58. </template>
  59. <template v-if="item.operator == '4'">
  60. <el-col :span="24">
  61. <el-input-number v-model="item.max" :disabled="disabled" style="width: 100%;"></el-input-number>
  62. </el-col>
  63. </template>
  64. <template v-if="item.operator == '5'">
  65. <el-col :span="24">
  66. <el-input-number v-model="item.max" :disabled="disabled" style="width: 100%;"></el-input-number>
  67. </el-col>
  68. </template>
  69. </el-row>
  70. </template>
  71. <template v-if="item.attrType == 'select'">
  72. <el-select v-model="item.minArray" placeholder="选择值" clearable filterable multiple :disabled="disabled"
  73. @change="change($event, index)">
  74. <el-option v-for="dictLabalitem in item.dictLabal" :key="dictLabalitem.id" :label="dictLabalitem.name"
  75. :value="item.attrName == '车辆类型' ? dictLabalitem.code : dictLabalitem.name" />
  76. </el-select>
  77. </template>
  78. <template v-if="item.attrType == 'inputTag'">
  79. <el-input-tag v-model="item.minArray" :disabled="disabled" @change="change($event, index)"
  80. placeholder="输入内容后按回车键隔开" />
  81. </template>
  82. <template v-if="item.attrType == 'datetime'">
  83. <el-row class="flex a-c">
  84. <template v-if="item.operator == '1' || item.operator == null">
  85. <el-col :span="11">
  86. <el-date-picker v-model="item.min" :disabled="disabled" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  87. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 100%;">
  88. </el-date-picker>
  89. </el-col>
  90. <el-col :span="2">
  91. <div class="flex a-c j-c " style="font-size: 14px;color: #333;">至</div>
  92. </el-col>
  93. <el-col :span="11">
  94. <el-date-picker v-model="item.max" :disabled="disabled" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  95. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 100%;">
  96. </el-date-picker>
  97. </el-col>
  98. </template>
  99. <template v-if="item.operator == '2'">
  100. <el-col :span="24">
  101. <el-date-picker v-model="item.min" :disabled="disabled" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  102. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 100%;">
  103. </el-date-picker>
  104. </el-col>
  105. </template>
  106. <template v-if="item.operator == '3'">
  107. <el-col :span="24"> <el-date-picker v-model="item.min" :disabled="disabled" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  108. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 100%;">
  109. </el-date-picker></el-col>
  110. </template>
  111. <template v-if="item.operator == '4'">
  112. <el-col :span="24"><el-date-picker v-model="item.max" :disabled="disabled" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  113. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 100%;">
  114. </el-date-picker></el-col>
  115. </template>
  116. <template v-if="item.operator == '5'">
  117. <el-col :span="24"> <el-date-picker v-model="item.max" :disabled="disabled" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  118. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 100%;">
  119. </el-date-picker></el-col>
  120. </template>
  121. </el-row>
  122. </template>
  123. </el-col>
  124. <el-col :span="1">
  125. <el-icon v-if="!disabled" color="#666" size="18" style="margin-left: 10px;" @click="attrDel(index)">
  126. <Delete />
  127. </el-icon>
  128. </el-col>
  129. </el-row>
  130. </div>
  131. </div>
  132. </template>
  133. <!-- 行为区域 -->
  134. <script lang='ts' setup>
  135. import { defineProps, defineEmits } from "vue";
  136. const props = defineProps<{
  137. rulesAttrList: any[],//list集合
  138. disabled?: boolean,
  139. }>();
  140. const emits = defineEmits(["Del", 'save', 'selectChange']);
  141. //右侧删除图标
  142. const attrDel = (index: number) => {
  143. console.log(index)
  144. emits('Del', index)
  145. }
  146. const change = (e: string[] | undefined, index: number) => {
  147. console.log(e)
  148. emits('selectChange', { e, index })
  149. }
  150. onMounted(() => {
  151. console.log('规则数据', props.rulesAttrList)
  152. })
  153. </script>
  154. <!-- 样式区域 -->
  155. <style lang='scss' scoped>
  156. .roleClass {
  157. margin-bottom: 10px;
  158. }
  159. </style>