index.vue 8.1 KB

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