index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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, item)">
  73. <template #header>
  74. <el-checkbox v-model="item.checkAll" :indeterminate="item.indeterminate" :disabled="disabled"
  75. @change="(val) => handleCheckAll(item, index, val)">
  76. 全选
  77. </el-checkbox>
  78. </template>
  79. <el-option v-for="dictLabalitem in item.dictLabal" :key="dictLabalitem.id" :label="dictLabalitem.name"
  80. :value="item.attrName == '车辆类型' ? dictLabalitem.code : dictLabalitem.name" />
  81. </el-select>
  82. </template>
  83. <template v-if="item.attrType == 'inputTag'">
  84. <el-input-tag v-model="item.minArray" :disabled="disabled" @change="change($event, index)"
  85. placeholder="输入内容后按回车键隔开" />
  86. </template>
  87. <template v-if="item.attrType == 'datetime'">
  88. <el-row class="flex a-c">
  89. <template v-if="item.operator == '1' || item.operator == null">
  90. <el-col :span="11">
  91. <el-date-picker v-model="item.min" :disabled="disabled" type="datetime" format="YYYY-MM-DD HH:mm:ss"
  92. value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss" placeholder="选择日期时间" style="width: 100%;">
  93. </el-date-picker>
  94. </el-col>
  95. <el-col :span="2">
  96. <div class="flex a-c j-c " style="font-size: 14px;color: #333;">至</div>
  97. </el-col>
  98. <el-col :span="11">
  99. <el-date-picker v-model="item.max" :disabled="disabled" 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: 100%;">
  101. </el-date-picker>
  102. </el-col>
  103. </template>
  104. <template v-if="item.operator == '2'">
  105. <el-col :span="24">
  106. <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>
  109. </el-col>
  110. </template>
  111. <template v-if="item.operator == '3'">
  112. <el-col :span="24"> <el-date-picker v-model="item.min" :disabled="disabled" type="datetime"
  113. format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss"
  114. placeholder="选择日期时间" style="width: 100%;">
  115. </el-date-picker></el-col>
  116. </template>
  117. <template v-if="item.operator == '4'">
  118. <el-col :span="24"><el-date-picker v-model="item.max" :disabled="disabled" type="datetime"
  119. format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss"
  120. placeholder="选择日期时间" style="width: 100%;">
  121. </el-date-picker></el-col>
  122. </template>
  123. <template v-if="item.operator == '5'">
  124. <el-col :span="24"> <el-date-picker v-model="item.max" :disabled="disabled" type="datetime"
  125. format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm:ss"
  126. placeholder="选择日期时间" style="width: 100%;">
  127. </el-date-picker></el-col>
  128. </template>
  129. </el-row>
  130. </template>
  131. </el-col>
  132. <el-col :span="1">
  133. <el-icon v-if="!disabled" color="#666" size="18" style="margin-left: 10px;" @click="attrDel(index)">
  134. <Delete />
  135. </el-icon>
  136. </el-col>
  137. <el-col :span="2">
  138. <el-checkbox v-if="item.attrName === '车牌号'" :disabled="disabled" @change="licenseNoSelect($event, item)">全选</el-checkbox>
  139. </el-col>
  140. </el-row>
  141. </div>
  142. </div>
  143. </template>
  144. <!-- 行为区域 -->
  145. <script lang='ts' setup>
  146. import type { CheckboxValueType } from 'element-plus'
  147. const props = defineProps<{
  148. rulesAttrList: any[],//list集合
  149. disabled?: boolean,
  150. }>();
  151. const emits = defineEmits(["Del", 'save', 'selectChange']);
  152. //右侧删除图标
  153. const attrDel = (index: number) => {
  154. emits('Del', index)
  155. }
  156. const change = (e: string[] | undefined, index: number, item: any) => {
  157. if (item?.attrType == 'select') {
  158. if (item.minArray.length === 0) {
  159. item.checkAll = false
  160. item.indeterminate = false
  161. } else if (item.minArray.length === item.dictLabal.length) {
  162. item.checkAll = true
  163. item.indeterminate = false
  164. } else {
  165. item.indeterminate = true
  166. }
  167. }
  168. emits('selectChange', { e, index })
  169. }
  170. const licenseNoSelect = (e, item) => {
  171. if (e) {
  172. item.minArray = item.dictLabal.map(a => {
  173. return a.name
  174. })
  175. } else {
  176. item.minArray = []
  177. }
  178. }
  179. const handleCheckAll = (item, index: number, val: boolean) => {
  180. item.indeterminate = false
  181. if (val) {
  182. item.minArray = item.dictLabal.map((_) => _.attrName == '车辆类型' ? _.code : _.name)
  183. } else {
  184. item.minArray = []
  185. }
  186. }
  187. onMounted(() => {
  188. console.log('规则数据', props.rulesAttrList)
  189. })
  190. </script>
  191. <!-- 样式区域 -->
  192. <style lang='scss' scoped>
  193. .roleClass {
  194. margin-bottom: 10px;
  195. }
  196. </style>