Kind.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div class="selector">
  3. <div class="sl-wrap" v-if="good_list.total > 0">
  4. <div class="sl-key f14">类目:</div>
  5. <div class="sl-value">
  6. <span v-for="(kind_temp, index) in kind_exp_arr">
  7. <div class="sl-filter" @click="click_kind_exp(kind_temp.ki_id, index)">
  8. <a class="text-num" v-text="kind_temp.ki_name_cn"></a>
  9. <span><i class="fa fa-close"></i></span>
  10. </div>
  11. </span>
  12. <ul :class="show_kind">
  13. <li><a class="f14" @click="restore('kind')">全部</a></li>
  14. <li v-for="(item, index) in list_kind">
  15. <a v-text="item.ki_name_cn" class="f14" @click="click_kind(item.ki_id, index)"></a>
  16. </li>
  17. </ul>
  18. </div>
  19. <div class="sl-clear"></div>
  20. <div class="sl-ext">
  21. <a @click="click_kind_more" v-if="list_kind.length>17">
  22. <span v-text="kind_open?'更多':'收起'"></span>
  23. <i class="fa fa-angle-down ng-scope" v-if="kind_open"></i>
  24. <i class="fa fa-angle-up ng-scope" v-if="!kind_open"></i>
  25. </a>
  26. </div>
  27. </div>
  28. <div class="sl-wrap" v-if="good_list.total > 0">
  29. <div class="sl-key f14">品牌:</div>
  30. <div class="sl-value">
  31. <span v-for="(brand_temp, index) in brand_exp_arr">
  32. <div class="sl-filter">
  33. <a class="text-num" v-text="brand_temp.br_name_cn" @click="click_brand_exp(brand_temp.br_id, index)"></a>
  34. <span><i class="fa fa-close"></i></span>
  35. </div>
  36. </span>
  37. <ul :class="show_brand">
  38. <li><a class="f14" @click="restore('brand')">全部</a></li>
  39. <li v-for="(item, index) in list_brand">
  40. <a v-text="item.br_name_cn" class="f14" @click="click_brand(item.br_id, index)"></a>
  41. </li>
  42. </ul>
  43. </div>
  44. <div class="sl-clear"></div>
  45. <div class="sl-ext" v-if="list_brand.length>17">
  46. <a @click="click_brand_more">
  47. <span v-text="brand_open?'更多':'收起'"></span>
  48. <i class="fa fa-angle-down ng-scope" v-if="brand_open"></i>
  49. <i class="fa fa-angle-up ng-scope" v-if="!brand_open"></i>
  50. </a>
  51. </div>
  52. </div>
  53. <div class="sl-wrap" v-if="list_store_type.length != 'undefined' && list_store_type.length > 0" style="height: 40px">
  54. <div class="sl-key f14">货源:</div>
  55. <div class="sl-value">
  56. <ul class="list-inline" >
  57. <li><a class="f14" @click="restore('store')">全部</a></li>
  58. <li>
  59. <div class="f14" style="color: #999;" v-if="!getType(list_store_type,store_type_co)&&!co_click_flag">寄售</div>
  60. <a class="f14" v-if="getType(list_store_type,store_type_co)&&!co_click_flag" @click="click_store_type('CONSIGNMENT')">寄售</a>
  61. <span v-if="co_click_flag" @click="cancel_store_type('CONSIGNMENT')">
  62. <div class="sl-filter">
  63. <a class="text-num" >寄售</a>
  64. <span><i class="fa fa-close"></i></span>
  65. </div>
  66. </span>
  67. </li>
  68. <li>
  69. <div class="f14" style="color: #999;" v-if="!getType(list_store_type,store_type_di)&&!di_click_flag">经销</div>
  70. <a class="f14" v-if="getType(list_store_type,store_type_di)&&!di_click_flag" @click="click_store_type('DISTRIBUTION')">经销</a>
  71. <span v-if="di_click_flag" @click="cancel_store_type('DISTRIBUTION')">
  72. <div class="sl-filter">
  73. <a class="text-num" >经销</a>
  74. <span><i class="fa fa-close"></i></span>
  75. </div>
  76. </span>
  77. </li>
  78. <li>
  79. <div class="f14" style="color: #999;" v-if="!getType(list_store_type,store_type_or)&&!or_click_flag">原厂</div>
  80. <a class="f14" v-if="getType(list_store_type,store_type_or)&&!or_click_flag" @click="click_store_type('ORIGINAL_FACTORY')">原厂</a>
  81. <span v-if="or_click_flag" @click="cancel_store_type('ORIGINAL_FACTORY')">
  82. <div class="sl-filter">
  83. <a class="text-num" >原厂</a>
  84. <span><i class="fa fa-close"></i></span>
  85. </div>
  86. </span>
  87. </li>
  88. <li>
  89. <div class="f14" style="color: #999;" v-if="!getType(list_store_type,store_type_ag)&&!ag_click_flag">代理</div>
  90. <a class="f14" v-if="getType(list_store_type,store_type_ag)&&!ag_click_flag" @click="click_store_type('AGENCY')">代理</a>
  91. <span v-if="ag_click_flag" @click="cancel_store_type('AGENCY')">
  92. <div class="sl-filter" >
  93. <a class="text-num" >代理</a>
  94. <span><i class="fa fa-close"></i></span>
  95. </div>
  96. </span>
  97. </li>
  98. </ul>
  99. </div>
  100. </div>
  101. <div class="sl-wrap" v-if="list_crname.length != 'undefined' && list_crname.length > 0" style="height: 40px">
  102. <div class="sl-key f14">仓库:</div>
  103. <div class="sl-value">
  104. <ul class="list-inline" >
  105. <li><a class="f14" @click="restore('crname')">全部</a></li>
  106. <li v-for="cr in list_crname_temp">
  107. <a v-if="cr.cr_name=='RMB'?!crname_click_flag.rmb_click_flag:!crname_click_flag.usd_click_flag" v-text="cr.cr_name=='RMB'?'大陆':'香港'" class="f14" @click="click_crname(cr.cr_name)"></a>
  108. <span v-if="cr.cr_name=='RMB'?crname_click_flag.rmb_click_flag:crname_click_flag.usd_click_flag" @click="cancel_crname(cr.cr_name)">
  109. <div class="sl-filter">
  110. <a class="text-num" v-text="cr.cr_name=='RMB'?'大陆':'香港'"></a>
  111. <span><i class="fa fa-close"></i></span>
  112. </div>
  113. </span>
  114. </li>
  115. </ul>
  116. </div>
  117. </div>
  118. <div class="sl-wrap" v-if="list_crname.length != 'undefined' && list_crname.length > 0" style="height: 40px">
  119. <div class="sl-key f14">货币:</div>
  120. <div class="sl-value">
  121. <ul class="list-inline" >
  122. <li><a class="f14" @click="restore('crname')">全部</a></li>
  123. <li v-for="cr in list_crname_temp">
  124. <a v-if="cr.cr_name=='RMB'?!crname_click_flag.rmb_click_flag:!crname_click_flag.usd_click_flag" v-text="cr.cr_name=='RMB'?'人民币':'美元'" class="f14" @click="click_crname(cr.cr_name)"></a>
  125. <span v-if="cr.cr_name=='RMB'?crname_click_flag.rmb_click_flag:crname_click_flag.usd_click_flag" @click="cancel_crname(cr.cr_name)">
  126. <div class="sl-filter">
  127. <a class="text-num" v-text="cr.cr_name=='RMB'?'人民币':'美元'"></a>
  128. <span><i class="fa fa-close"></i></span>
  129. </div>
  130. </span>
  131. </li>
  132. </ul>
  133. </div>
  134. </div>
  135. </div>
  136. </template>
  137. <script>
  138. export default {
  139. data () {
  140. return {
  141. kind_open: true,
  142. brand_open: true,
  143. show_kind: 'list-inline',
  144. show_brand: 'list-inline',
  145. store_type_co: {store_type: 'CONSIGNMENT'},
  146. store_type_ag: {store_type: 'AGENCY'},
  147. store_type_di: {store_type: 'DISTRIBUTION'},
  148. store_type_or: {store_type: 'ORIGINAL_FACTORY'},
  149. filter: {},
  150. kind_arr: [],
  151. brand_arr: [],
  152. type_arr: [],
  153. crname_arr: [],
  154. kind_exp_arr: [],
  155. brand_exp_arr: [],
  156. co_click_flag: false,
  157. ag_click_flag: false,
  158. di_click_flag: false,
  159. or_click_flag: false,
  160. crname_click_flag: {
  161. rmb_click_flag: false,
  162. usd_click_flag: false
  163. }
  164. }
  165. },
  166. computed: {
  167. list_kinds () {
  168. return this.$store.state.searchData.searchKinds.kinds
  169. },
  170. list_kind () {
  171. return this.list_kinds.data
  172. },
  173. list_brands () {
  174. return this.$store.state.searchData.searchBrands.brands
  175. },
  176. list_brand () {
  177. return this.list_brands.data
  178. },
  179. list_store_types () {
  180. return this.$store.state.searchData.searchStoreType.store_type
  181. },
  182. list_store_type () {
  183. return this.list_store_types.data
  184. },
  185. list_crnames () {
  186. return this.$store.state.searchData.searchCrname.crname
  187. },
  188. list_crname () {
  189. return this.list_crnames.data
  190. },
  191. list_crname_temp () {
  192. let arr = this.list_crnames.data
  193. if (!(JSON.stringify(arr).indexOf(JSON.stringify({cr_name: 'RMB-USD'})) === -1)) {
  194. return [{cr_name: 'RMB'}, {cr_name: 'USD'}]
  195. } else {
  196. return arr
  197. }
  198. },
  199. good_lists () {
  200. return this.$store.state.searchData.searchList.lists
  201. },
  202. good_list () {
  203. return this.good_lists.data
  204. }
  205. },
  206. methods: {
  207. click_kind_more: function (event) {
  208. if (this.kind_open) {
  209. this.show_kind = 'list-inline2'
  210. } else {
  211. this.show_kind = 'list-inline'
  212. }
  213. this.kind_open = !this.kind_open
  214. },
  215. click_brand_more: function (event) {
  216. if (this.brand_open) {
  217. this.show_brand = 'list-inline2'
  218. } else {
  219. this.show_brand = 'list-inline'
  220. }
  221. this.brand_open = !this.brand_open
  222. },
  223. getType: function (arr, obj) {
  224. return !(JSON.stringify(arr).indexOf(JSON.stringify(obj)) === -1)
  225. },
  226. click_kind: function (id, index) {
  227. this.kind_arr.push(id)
  228. this.$emit('kindFilterEvent', this.kind_arr)
  229. this.kind_exp_arr.push(this.list_kind[index])
  230. this.list_kind.splice(index, index + 1)
  231. },
  232. click_brand: function (id, index) {
  233. this.brand_arr.push(id)
  234. this.$emit('brandFilterEvent', this.brand_arr)
  235. this.brand_exp_arr.push(this.list_brand[index])
  236. this.list_brand.splice(index, index + 1)
  237. },
  238. click_store_type: function (type) {
  239. this.type_arr.push(type)
  240. this.$emit('typeFilterEvent', this.type_arr)
  241. if (type === 'CONSIGNMENT') {
  242. this.co_click_flag = true
  243. } else if (type === 'AGENCY') {
  244. this.ag_click_flag = true
  245. } else if (type === 'DISTRIBUTION') {
  246. this.di_click_flag = true
  247. } else if (type === 'ORIGINAL_FACTORY') {
  248. this.or_click_flag = true
  249. }
  250. },
  251. cancel_store_type: function (type) {
  252. if (type === 'CONSIGNMENT') {
  253. this.co_click_flag = false
  254. } else if (type === 'AGENCY') {
  255. this.ag_click_flag = false
  256. } else if (type === 'DISTRIBUTION') {
  257. this.di_click_flag = false
  258. } else if (type === 'ORIGINAL_FACTORY') {
  259. this.or_click_flag = false
  260. }
  261. let idx = this.getIndex(this.type_arr, type)
  262. this.type_arr.splice(idx, idx + 1)
  263. this.$emit('typeFilterEvent', this.type_arr)
  264. },
  265. click_crname: function (name) {
  266. this.crname_arr.push(name)
  267. if (this.getIndex(this.crname_arr, 'RMB-USD') === -1) {
  268. this.crname_arr.push('RMB-USD')
  269. }
  270. if (name === 'RMB') {
  271. this.crname_click_flag.rmb_click_flag = true
  272. } else if (name === 'USD') {
  273. this.crname_click_flag.usd_click_flag = true
  274. }
  275. this.$emit('crnameFilterEvent', this.crname_arr)
  276. this.$emit('crnameFlagEvent', this.crname_click_flag)
  277. },
  278. cancel_crname: function (name) {
  279. let idx = this.getIndex(this.crname_arr, name)
  280. this.crname_arr.splice(idx, idx + 1)
  281. if (this.crname_arr.length === 1) {
  282. this.crname_arr = []
  283. }
  284. if (name === 'RMB') {
  285. this.crname_click_flag.rmb_click_flag = false
  286. } else if (name === 'USD') {
  287. this.crname_click_flag.usd_click_flag = false
  288. }
  289. this.$emit('crnameFilterEvent', this.crname_arr)
  290. this.$emit('crnameFlagEvent', this.crname_click_flag)
  291. },
  292. click_kind_exp: function (id, index) {
  293. let idx = this.getIndex(this.kind_arr, id)
  294. this.kind_arr.splice(idx, idx + 1)
  295. this.$emit('kindFilterEvent', this.kind_arr)
  296. this.kind_exp_arr.splice(index, index + 1)
  297. },
  298. click_brand_exp: function (id, index) {
  299. let idx = this.getIndex(this.brand_arr, id)
  300. this.brand_arr.splice(idx, idx + 1)
  301. this.$emit('brandFilterEvent', this.brand_arr)
  302. this.brand_exp_arr.splice(index, index + 1)
  303. },
  304. restore: function (name) {
  305. if (name === 'kind') {
  306. this.list_kind.concat(this.kind_exp_arr)
  307. this.kind_exp_arr = []
  308. this.kind_arr = []
  309. this.$emit('kindFilterEvent', this.kind_arr)
  310. } else if (name === 'brand') {
  311. this.list_brand.concat(this.brand_exp_arr)
  312. this.brand_exp_arr = []
  313. this.brand_arr = []
  314. this.$emit('brandFilterEvent', this.brand_arr)
  315. } else if (name === 'store') {
  316. this.list_store_type.concat(this.type_arr)
  317. this.type_arr = []
  318. this.$emit('typeFilterEvent', this.type_arr)
  319. this.co_click_flag = false
  320. this.ag_click_flag = false
  321. this.di_click_flag = false
  322. this.or_click_flag = false
  323. } else if (name === 'crname') {
  324. this.list_crname.concat(this.crname_arr)
  325. this.crname_arr = []
  326. this.$emit('crnameFilterEvent', this.crname_arr)
  327. this.rmb_click_flag = false
  328. this.usd_click_flag = false
  329. }
  330. },
  331. getIndex: function (arr, obj) {
  332. for (let i = 0; i < arr.length; i++) {
  333. if (arr[i] === obj) {
  334. return i
  335. }
  336. }
  337. return -1
  338. }
  339. }
  340. }
  341. </script>
  342. <style scoped>
  343. #searchResult .selector .sl-wrap {
  344. position: relative;
  345. padding: 5px 5px;
  346. font-size: 12px;
  347. line-height: 30px;
  348. border-bottom: 1px solid #e5e5e5;
  349. }
  350. #searchResult .selector .sl-wrap .sl-key {
  351. float: left;
  352. width: 100px;
  353. }
  354. .f14 {
  355. font-size: 14px;
  356. }
  357. #searchResult .selector .sl-wrap .sl-value {
  358. margin-left: 110px;
  359. margin-right: 50px;
  360. }
  361. #searchResult .selector .sl-wrap .sl-value span >.sl-filter {
  362. display: inline-block;
  363. position: relative;
  364. line-height: 22px;
  365. padding-left: 10px;
  366. padding-right: 30px;
  367. border: 1px solid #ccc;
  368. cursor: pointer;
  369. height: 22px;
  370. margin-right: 10px;
  371. }
  372. #searchResult .selector .sl-wrap .sl-value span >.sl-filter a{
  373. color: #666;
  374. text-decoration: none;
  375. }
  376. #searchResult .selector .sl-wrap .sl-value span >.sl-filter span{
  377. display: inline-block;
  378. position: absolute;
  379. right: 0;
  380. top: 0;
  381. height: 100%;
  382. width: 20px;
  383. text-align: center;
  384. background: #ccc;
  385. color: #fff;
  386. }
  387. #searchResult .selector .sl-wrap .sl-value span >.sl-filter:hover {
  388. border: 1px solid #f50;
  389. }
  390. #searchResult .selector .sl-wrap .sl-value span >.sl-filter:hover a{
  391. color: #f50;
  392. }
  393. #searchResult .selector .sl-wrap .sl-value span >.sl-filter:hover span{
  394. background: #f50;
  395. }
  396. #searchResult .selector .sl-wrap .sl-clear {
  397. clear: both;
  398. }
  399. #searchResult .selector .sl-wrap .sl-ext {
  400. width: 40px;
  401. top: 5px;
  402. position: absolute;
  403. right: 0;
  404. }
  405. .list-inline {
  406. height: 60px;
  407. overflow: hidden;
  408. margin-bottom: 0;
  409. padding-left: 0;
  410. margin-left: -5px;
  411. list-style: none;
  412. }
  413. .list-inline2 {
  414. height: 100%;
  415. overflow: hidden;
  416. margin-bottom: 0;
  417. padding-left: 0;
  418. margin-left: -5px;
  419. list-style: none;
  420. }
  421. #searchResult .selector .sl-wrap .sl-value ul >li {
  422. display: inline-block;
  423. padding-right: 5px;
  424. padding-left: 5px;
  425. margin-right: 20px;
  426. width: 10%;
  427. height: 23px;
  428. line-height: 23px;
  429. overflow: hidden;
  430. text-overflow: ellipsis;
  431. white-space: nowrap;
  432. }
  433. #searchResult .selector .sl-wrap .sl-value ul a{
  434. color: #1162a4;
  435. }
  436. #searchResult .selector .sl-wrap .sl-value ul a:hover{
  437. text-decoration: none;
  438. color: #f50;
  439. }
  440. .sl-ext a{
  441. color: black;
  442. }
  443. .sl-ext a:hover{
  444. color: #5078cb;
  445. text-decoration: none;
  446. }
  447. </style>