Select2.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="border-bottom">
  3. <div>
  4. <ul class="flex-align-center normal-margin-new" >
  5. <!-- <li :class="field_act === ''?'act':''" class="brand-item border-all" @click="clickField({})" >全部领域</li> -->
  6. <li :class="field_act === item.sys_enterprise_tradefieldid?'act':''" class="brand-item" style="margin-left:0" v-for="item in fields" :key="item.sys_enterprise_tradefieldid" @click="clickField(item)">{{item.tradefield}}</li>
  7. </ul>
  8. <ul class="flex-align-center normal-margin-new">
  9. <!-- <li :class="!brand_act?'act':''" class="brand-item border-all" @click="clickBrand('')">全部品牌</li> -->
  10. <li :class="brand_act == item.sa_brandid?'act':''" class="brand-item " style="margin-left:0" v-for="item in brands" :key="item.sa_brandid" @click="clickBrand(item.sa_brandid)">{{item.brandname}}</li>
  11. </ul>
  12. <ul class="flex-align-center normal-margin-new">
  13. <li :class="class_act === ''?'act':''" class="brand-item border-all" @click="clickClass('')">全部分类</li>
  14. <li :class="class_act === item.itemclassnum?'act':''" class="brand-item margin-notAll" v-for="item in itemclass" :key="item.itemclassnum" @click="clickClass(item)">{{item.itemclassname}}</li>
  15. </ul>
  16. <classTree ref="tree" style="padding-left:80px" :data="activeClass.subdep" @onClassChange="change"></classTree>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import classTree from './classTree.vue'
  22. export default {
  23. data () {
  24. return {
  25. value:'',
  26. brands:[],
  27. fields:[],
  28. itemclass:[],
  29. activeClass:{},
  30. field_act:'',
  31. tradefield:'',
  32. brand_act:0,
  33. class_act:''
  34. }
  35. },
  36. provide () {
  37. return {
  38. selectThis:() => this
  39. }
  40. },
  41. inject:['sys_enterpriseid'],
  42. props: {
  43. default: {
  44. type: Boolean,
  45. default:() => false
  46. }
  47. },
  48. components:{
  49. classTree
  50. },
  51. methods:{
  52. async queryAgentiInfo (callback) {
  53. let param = {
  54. "id": 20230418142202,
  55. "content": {
  56. "sys_enterpriseid":this.sys_enterpriseid(),
  57. "where": {
  58. "condition": ""
  59. }
  60. }
  61. }
  62. if (!this.sys_enterpriseid()) delete param.content.sys_enterpriseid
  63. const res1 = await this.$api.requested(param)
  64. this.fields = res1.data
  65. if (this.fields.length) {
  66. this.field_act = res1.data[0].sys_enterprise_tradefieldid
  67. this.tradefield = res1.data[0].tradefield
  68. // this.clickField({sys_enterprise_tradefieldid:this.field_act,tradefield:res1.data[0].tradefield})
  69. } else {
  70. this.field_act = 0
  71. this.tradefield = ''
  72. // this.clickField(false)
  73. }
  74. callback && callback()
  75. },
  76. async queryBrands (callback) {
  77. let param = {
  78. "id": "20220924163702",
  79. "content": {
  80. "pageSize":1000,
  81. "sys_enterpriseid":this.sys_enterpriseid(),
  82. "where":{
  83. "condition":""
  84. }
  85. }
  86. }
  87. if (!this.sys_enterpriseid()) delete param.content.sys_enterpriseid
  88. const res = await this.$api.requested(param)
  89. this.brands = res.data
  90. if (this.brands.length) {
  91. this.brand_act = res.data[0].sa_brandid
  92. // this.clickBrand(res.data[0].sa_brandid)
  93. } else {
  94. this.brand_act = 0
  95. // this.clickBrand(this.brand_act)
  96. }
  97. callback && callback()
  98. },
  99. async queryClass () {
  100. let param = {
  101. "id":"20220922110403","content":{"sa_brandid":this.brand_act,"sys_enterpriseid":this.sys_enterpriseid(),where:{istool:0}}
  102. }
  103. if (!this.sys_enterpriseid()) delete param.content.sys_enterpriseid
  104. const res = await this.$api.requested(param)
  105. console.log(res.data);
  106. this.itemclass = res.data.length ? res.data[0].ttemclass : []
  107. },
  108. clickBrand (id) {
  109. this.brand_act = id ? id : 0
  110. this.queryClass()
  111. this.$emit('brandChange',[this.brand_act])
  112. },
  113. clickField (item) {
  114. this.field_act = item ? item.sys_enterprise_tradefieldid : ''
  115. this.$emit('clickField',item)
  116. },
  117. clickClass (item) {
  118. if (item) {
  119. this.activeClass = item
  120. this.class_act = item.itemclassnum
  121. this.$emit('onClassChange',item)
  122. } else {
  123. this.class_act = ''
  124. this.$refs.tree.class_act = 0
  125. this.$emit('onClassChange',item)
  126. }
  127. },
  128. change(n) {
  129. this.$emit('onClassChange',n)
  130. },
  131. clearSearch() {
  132. this.$emit('clearSearch')
  133. }
  134. },
  135. mounted () {
  136. this.queryClass()
  137. this.queryAgentiInfo()
  138. this.queryBrands()
  139. }
  140. }
  141. </script>
  142. <style>
  143. </style>
  144. <style scoped>
  145. .brand-item{
  146. margin:2px 40px;
  147. color: #333;
  148. cursor: pointer;
  149. transition: .2s all linear;
  150. font-size: 14px;
  151. }
  152. .act{
  153. color:#3874f6;
  154. font-weight: bold;
  155. }
  156. .normal-margin-new{
  157. margin-bottom: 2px !important;
  158. }
  159. .border-bottom{
  160. padding-bottom:16px;
  161. border-bottom: 1px solid #e3e5ea;
  162. }
  163. .border-all{
  164. margin-left: 0px
  165. }
  166. .margin-notAll{
  167. margin-left: -18px
  168. }
  169. </style>