customSearch.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="customSearch">
  3. <el-container style=" border: 1px solid #eee" :style="{height:height-70+'px'}">
  4. <el-aside v-if="DBType == 'WD'">
  5. <div>
  6. <div class="clearfix">
  7. <span><el-checkbox v-model="checked" @change="change">全部国家地区</el-checkbox></span>
  8. <span style="float: right; padding: 3px 0" type="text">{{ checkList.length }}/{{countryList.length}}</span>
  9. </div>
  10. <div style="overflow-y:auto;overflow-x:hidden;" :style="{height:height-120+'px'}">
  11. <el-checkbox-group v-model="checkList">
  12. <div v-for="item in countryList" :key="item.value" class="item">
  13. <el-checkbox :label="item.value">{{ item.label }}({{ item.value }})</el-checkbox>
  14. </div>
  15. </el-checkbox-group>
  16. </div>
  17. </div>
  18. </el-aside>
  19. <el-main>
  20. <div>
  21. <search :logical="logical" :logicalProps="logicalProps" :operator="operator" :field="field" :searchValue="true" @search="search"></search>
  22. </div>
  23. </el-main>
  24. </el-container>
  25. </div>
  26. </template>
  27. <script>
  28. import search from '@/views/workspace/components/common/search.vue'
  29. export default {
  30. components: {
  31. search
  32. },
  33. props: ['countryList','DBType'],
  34. data() {
  35. return {
  36. height:document.getElementsByClassName('el-main')[0].clientHeight,
  37. checkList:[],
  38. checked:false,
  39. //逻辑符
  40. logical:[
  41. {
  42. name:'并且',
  43. value:'AND'
  44. },
  45. {
  46. name:'或者',
  47. value:'OR'
  48. },
  49. {
  50. name:'非',
  51. value:'NOT'
  52. },
  53. ],
  54. logicalProps:{
  55. label:'name',
  56. value:'value'
  57. },
  58. //运算符
  59. operator:[
  60. {
  61. label:'=',
  62. value:'='
  63. },
  64. // {
  65. // label:'>',
  66. // value:'>'
  67. // },
  68. // {
  69. // label:'<',
  70. // value:'<'
  71. // },
  72. // {
  73. // label:'<=',
  74. // value:'<='
  75. // },
  76. ],
  77. //搜索值
  78. field:JSON.parse(JSON.stringify(this.$constants.searchField)),
  79. };
  80. },
  81. watch: {
  82. 'checkList'(val){
  83. if(val.length == this.countryList.length){
  84. this.checked = true
  85. }else{
  86. this.checked = false
  87. }
  88. },
  89. DBType(){
  90. this.getField()
  91. },
  92. },
  93. computed: {},
  94. created() {},
  95. mounted() {
  96. this.getField()
  97. },
  98. methods: {
  99. getField(){
  100. var a = JSON.parse(JSON.stringify(this.$constants.searchField))
  101. this.field = a.map(item=>{
  102. item.children = item.children.filter(item1 =>{return item1.value!='GJ' && item1.type != (this.DBType != 'WD'?'2':'1')})
  103. return item
  104. })
  105. },
  106. search(val){
  107. if(this.DBType == 'WD' && this.checkList.length>0){
  108. var str = `${val} AND (GJ=${this.checkList})`
  109. this.$emit('search',str)
  110. }else{
  111. this.$emit('search',`${val}`)
  112. }
  113. },
  114. change(val){
  115. if(val){
  116. this.checkList = this.countryList.map(item=>item.value)
  117. }else{
  118. this.checkList = []
  119. }
  120. },
  121. },
  122. };
  123. </script>
  124. <style lang="scss" scoped>
  125. .clearfix {
  126. // padding-left:20px ;
  127. padding:10px 20px ;
  128. border-bottom: 1px solid #eeeeee;
  129. }
  130. .item{
  131. padding:10px 20px;
  132. }
  133. </style>