Kind.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <div class="selector" >
  3. <a class="show-filter" @click="show_filter = !show_filter">
  4. <span v-text="show_filter?'收起筛选 ':'展开筛选 '"></span>
  5. <i :class="show_filter?'fa fa-angle-up':'fa fa-angle-down'"></i>
  6. </a>
  7. <div v-show="show_filter">
  8. <div class="sl-wrap" v-if="good_list.total > 0">
  9. <div class="sl-key f14">物料名称(类目):</div>
  10. <div class="sl-value">
  11. <span v-for="(kind_temp, index) in kind_exp_arr">
  12. <div class="sl-filter" @click="click_kind_exp(kind_temp.ki_id, index)">
  13. <a class="text-num" v-text="kind_temp.ki_name_cn"></a>
  14. <span><i class="fa fa-close"></i></span>
  15. </div>
  16. </span>
  17. <ul :class="show_kind">
  18. <li @click="restore('kind')"><a>全部</a></li>
  19. <li v-for="(item, index) in list_kind" v-if="item.ki_name_cn" @click="click_kind(item.ki_id, index)" :title="item.ki_name_cn">
  20. <a v-text="item.ki_name_cn"></a>
  21. </li>
  22. </ul>
  23. </div>
  24. <div class="sl-clear"></div>
  25. <div class="sl-ext">
  26. <a @click="click_kind_more" v-if="list_kind.length>17">
  27. <span v-text="kind_open?'更多':'收起'"></span>
  28. <i class="fa fa-angle-down ng-scope" v-if="kind_open"></i>
  29. <i class="fa fa-angle-up ng-scope" v-if="!kind_open"></i>
  30. </a>
  31. </div>
  32. </div>
  33. <div class="sl-wrap" v-if="good_list.total > 0">
  34. <div class="sl-key f14">品牌:</div>
  35. <div class="sl-value" >
  36. <span v-for="(brand_temp, index) in brand_exp_arr" >
  37. <div class="sl-filter" @click="click_brand_exp(brand_temp.br_id, index)">
  38. <a class="text-num" v-text="brand_temp.br_name_cn"></a>
  39. <span><i class="fa fa-close"></i></span>
  40. </div>
  41. </span>
  42. <ul :class="show_brand">
  43. <li @click="restore('brand')"><a>全部</a></li>
  44. <li v-for="(item, index) in list_brand" v-if="item.br_name_cn" @click="click_brand(item.br_id, index)" :title="item.br_name_cn">
  45. <a v-text="item.br_name_cn"></a>
  46. </li>
  47. </ul>
  48. </div>
  49. <div class="sl-clear"></div>
  50. <div class="sl-ext" v-if="list_brand.length>17">
  51. <a @click="click_brand_more">
  52. <span v-text="brand_open?'更多':'收起'"></span>
  53. <i class="fa fa-angle-down ng-scope" v-if="brand_open"></i>
  54. <i class="fa fa-angle-up ng-scope" v-if="!brand_open"></i>
  55. </a>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. export default {
  63. data () {
  64. return {
  65. show_filter: true,
  66. kind_open: true,
  67. brand_open: true,
  68. show_kind: 'list-inline',
  69. show_brand: 'list-inline',
  70. filter: {},
  71. kind_arr: [],
  72. brand_arr: [],
  73. kind_exp_arr: [],
  74. brand_exp_arr: []
  75. }
  76. },
  77. watch: {
  78. $route: function (val, oldVal) {
  79. this.filter = {}
  80. this.kind_arr = []
  81. this.brand_arr = []
  82. this.kind_exp_arr = []
  83. this.brand_exp_arr = []
  84. }
  85. },
  86. computed: {
  87. list_kinds () {
  88. return this.$store.state.pcb.search.kinds
  89. },
  90. list_kind () {
  91. return this.list_kinds.data
  92. },
  93. list_brands () {
  94. return this.$store.state.pcb.search.brands
  95. },
  96. list_brand () {
  97. return this.list_brands.data
  98. },
  99. good_lists () {
  100. return this.$store.state.pcb.search.list
  101. },
  102. good_list () {
  103. return this.good_lists.data
  104. },
  105. list_data_brands () {
  106. return this.good_list.brands
  107. }
  108. },
  109. methods: {
  110. click_kind_more: function (event) {
  111. if (this.kind_open) {
  112. this.show_kind = 'list-inline2'
  113. } else {
  114. this.show_kind = 'list-inline'
  115. }
  116. this.kind_open = !this.kind_open
  117. },
  118. click_brand_more: function (event) {
  119. if (this.brand_open) {
  120. this.show_brand = 'list-inline2'
  121. } else {
  122. this.show_brand = 'list-inline'
  123. }
  124. this.brand_open = !this.brand_open
  125. },
  126. click_kind: function (id, index) {
  127. this.kind_arr.push(id)
  128. this.$emit('kindFilterEvent', this.kind_arr)
  129. this.kind_exp_arr.push(this.list_kind[index])
  130. this.kind_exp_arr[this.kind_exp_arr.length - 1].index = index
  131. this.list_kind[index] = ''
  132. },
  133. click_brand: function (id, index) {
  134. this.brand_arr.push(id)
  135. this.$emit('brandFilterEvent', this.brand_arr)
  136. this.brand_exp_arr.push(this.list_brand[index])
  137. this.brand_exp_arr[this.brand_exp_arr.length - 1].index = index
  138. this.list_brand[index] = ''
  139. },
  140. click_kind_exp: function (id, index) {
  141. let idx = this.getIndex(this.kind_arr, id)
  142. this.list_kind[this.kind_exp_arr[index].index] = this.kind_exp_arr[index]
  143. this.kind_arr.splice(idx, 1)
  144. this.$emit('kindFilterEvent', this.kind_arr)
  145. this.kind_exp_arr.splice(index, 1)
  146. },
  147. click_brand_exp: function (id, index) {
  148. let idx = this.getIndex(this.brand_arr, id)
  149. this.list_brand[this.brand_exp_arr[index].index] = this.brand_exp_arr[index]
  150. this.brand_arr.splice(idx, 1)
  151. this.$emit('brandFilterEvent', this.brand_arr)
  152. this.brand_exp_arr.splice(index, 1)
  153. },
  154. restore: function (name) {
  155. if (name === 'kind') {
  156. this.list_kind.concat(this.kind_exp_arr)
  157. this.kind_exp_arr = []
  158. this.kind_arr = []
  159. this.$emit('kindFilterEvent', this.kind_arr)
  160. } else if (name === 'brand') {
  161. this.list_brand.concat(this.brand_exp_arr)
  162. this.brand_exp_arr = []
  163. this.brand_arr = []
  164. this.$emit('brandFilterEvent', this.brand_arr)
  165. }
  166. },
  167. getIndex: function (arr, obj) {
  168. for (let i = 0; i < arr.length; i++) {
  169. if (arr[i] === obj) {
  170. return i
  171. }
  172. }
  173. return -1
  174. }
  175. }
  176. }
  177. </script>
  178. <style scoped>
  179. .show-filter{
  180. position: relative;
  181. left: 1100px;
  182. top: -10px;
  183. color: #5078cb;
  184. border: 1px solid #5078cb;
  185. padding: 3px 8px;
  186. background: #fff;
  187. }
  188. #searchResult .selector >div{
  189. margin-bottom: 20px;
  190. border-top: 2px solid #6493ff;
  191. }
  192. #searchResult .selector .sl-wrap {
  193. position: relative;
  194. padding: 10px 15px;
  195. font-size: 12px;
  196. line-height: 30px;
  197. border: 1px solid #d4e1ff;
  198. border-top: none;
  199. border-bottom: 1px dashed #d4e1ff;
  200. }
  201. #searchResult .selector .sl-wrap:last-child {
  202. border-bottom: 1px solid #d4e1ff;
  203. }
  204. #searchResult .selector .sl-wrap .sl-key {
  205. float: left;
  206. }
  207. .f14 {
  208. font-size: 14px;
  209. }
  210. #searchResult .selector .sl-wrap .sl-value {
  211. margin-left: 78px;
  212. margin-right: 50px;
  213. }
  214. #searchResult .selector .sl-wrap .sl-value span >.sl-filter {
  215. display: inline-block;
  216. position: relative;
  217. line-height: 22px;
  218. padding-left: 10px;
  219. padding-right: 30px;
  220. border: 1px solid #5078cb;
  221. color: #5078cb;
  222. cursor: pointer;
  223. height: 22px;
  224. margin-right: 10px;
  225. }
  226. #searchResult .selector .sl-wrap .sl-value span >.sl-filter a{
  227. color: #666;
  228. text-decoration: none;
  229. }
  230. #searchResult .selector .sl-wrap .sl-value span >.sl-filter span{
  231. display: inline-block;
  232. position: absolute;
  233. right: 0;
  234. top: -1px;
  235. width: 20px;
  236. text-align: center;
  237. background: #5078cb;
  238. color: #fff;
  239. }
  240. #searchResult .selector .sl-wrap .sl-value span >.sl-filter:hover {
  241. border: 1px solid #ea1e23;
  242. }
  243. #searchResult .selector .sl-wrap .sl-value span >.sl-filter:hover a{
  244. color: #ea1e23;
  245. }
  246. #searchResult .selector .sl-wrap .sl-value span >.sl-filter:hover span{
  247. background: #ea1e23;
  248. }
  249. #searchResult .selector .sl-wrap .sl-clear {
  250. clear: both;
  251. }
  252. #searchResult .selector .sl-wrap .sl-ext {
  253. width: 40px;
  254. top: 5px;
  255. position: absolute;
  256. right: 0;
  257. }
  258. .list-inline {
  259. max-height: 60px;
  260. overflow: hidden;
  261. margin-bottom: 0;
  262. padding-left: 0;
  263. margin-left: -5px;
  264. list-style: none;
  265. }
  266. .list-inline2 {
  267. height: 100%;
  268. overflow: hidden;
  269. margin-bottom: 0;
  270. padding-left: 0;
  271. margin-left: -5px;
  272. list-style: none;
  273. }
  274. #searchResult .selector .sl-wrap .sl-value li {
  275. display: inline-block;
  276. padding-right: 5px;
  277. padding-left: 5px;
  278. margin-right: 20px;
  279. width: 10%;
  280. height: 23px;
  281. line-height: 23px;
  282. overflow: hidden;
  283. text-overflow: ellipsis;
  284. white-space: nowrap;
  285. cursor: pointer;
  286. border: 1px solid #fff;
  287. }
  288. #searchResult .selector .sl-wrap .sl-value ul a{
  289. color: #666;
  290. }
  291. #searchResult .selector .sl-wrap .sl-value li:hover {
  292. border: 1px solid #5078cb;
  293. color: #5078cb;
  294. }
  295. #searchResult .selector .sl-wrap .sl-value li:hover a {
  296. color: #5078cb;
  297. }
  298. .sl-ext a{
  299. color: black;
  300. }
  301. .sl-ext a:hover{
  302. color: #5078cb;
  303. text-decoration: none;
  304. }
  305. </style>