CommodityList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <template>
  2. <div id="goods-list-fragment">
  3. <div class="container" style="width: 1190px; padding: 0;">
  4. <div class="title-area">
  5. <div class="category-title">
  6. <span style="line-height: 34px;">产品分类</span>
  7. </div>
  8. <div class="category-content">
  9. <el-tree :data="kinds" :props="defaultProps" :default-expanded-keys="[0]" node-key="level" accordion :highlight-current="true" @current-change="handlerCurrentNode"></el-tree>
  10. </div>
  11. </div>
  12. <!-- 产品列表 -->
  13. <div class="goods-area">
  14. <div class="row" style="margin: 0;width: 970px;">
  15. <div class="col-md-3 btn-group btn-group-sm" style="padding: 0;">
  16. <a type="button" class="btn btn-default btn-line btn-info">产品列表</a>
  17. </div>
  18. <div class="col-md-4 col-md-offset-5" style="padding: 0;">
  19. <div class="input-group">
  20. <input type="search" class="form-control" id="search_input" title="code" placeholder="请输入要筛选的原厂型号"
  21. v-model="searchCode" @search="goodsSearch(searchCode)"/>
  22. <span class="input-group-btn">
  23. <button type="button" class="btn" id="search_btn" @click="goodsSearch(searchCode)">&nbsp;筛&nbsp;选&nbsp;</button>
  24. </span>
  25. </div>
  26. </div>
  27. </div>
  28. <!-- 列表展示 -->
  29. <table class="goodslist" style="width: 970px">
  30. <thead>
  31. <tr style="height: 40px;">
  32. <!--<th width="90"></th>-->
  33. <th width="150">品牌/型号</th>
  34. <th width="100">包装/生产日期</th>
  35. <th width="90">库存(PCS)</th>
  36. <th width="90">数量</th>
  37. <!--<th width="90">香港交货<span style="font-size: 12px;">($)</span></th>-->
  38. <!--<th width="100">大陆交货<span style="font-size: 12px;">(¥)</span></th>-->
  39. <th width="100">单价</th>
  40. <th width="100">交期(天)</th>
  41. <th width="100">规格书</th>
  42. <th width="100">操作</th>
  43. </tr>
  44. </thead>
  45. <tbody id="goodslist-content">
  46. <tr v-for="commodity in commodities.content" @click="goBatchDetail(storeInfo.uuid, commodity.batchCode)">
  47. <td class="brand-code">
  48. <img class="sellout-store-commodity" v-if="commodity.status === 602" src="/images/search/sellout-search.png" alt="">
  49. <div class="brand" v-if="commodity.brandNameEn || commodity.brandEn">
  50. <a v-if="commodity.brandNameEn" @click="goBrandDetail('/product/brand/' + commodity.branduuid, $event)" v-text="commodity.brandNameEn"></a>
  51. <span v-if="commodity.brandEn">{{commodity.brandEn}}</span>
  52. </div>
  53. <div class="brand" v-if="!commodity.brandNameEn && !commodity.brandEn">—</div>
  54. <div class="code" v-if="commodity.code" v-text="commodity.code"></div>
  55. <div class="code" v-if="!commodity.code">—</div>
  56. </td>
  57. <td>
  58. <div class="package" v-if="commodity.packaging" v-text="commodity.packaging"></div>
  59. <div class="package" v-if="!commodity.packaging && !commodity.produceDate">—</div>
  60. <div class="date" v-if='commodity.produceDate' v-text="commodity.produceDate">2016-12-01</div>
  61. </td>
  62. <td style="text-align: left;vertical-align: middle;">
  63. <div class="goods" v-if="commodity.reserve || commodity.status === 602">
  64. 库存:<span v-text="commodity.reserve"></span>
  65. </div>
  66. <div v-if="!commodity.reserve && commodity.status !== 602" style="text-align: center;margin-left: 0;"><span>—</span></div>
  67. <div class="from" v-if="commodity.reserve && commodity.reserve>0 || commodity.status === 602">
  68. 起拍:<span v-if="commodity.minBuyQty" v-text="commodity.minBuyQty">300</span>
  69. </div>
  70. <!--<div class="multiple">
  71. 倍数:<span>1</span>
  72. </div>-->
  73. <div class="can-div-sell" v-if="commodity.reserve || commodity.status === 602" v-text="commodity.breakUp?'可拆卖':'不可拆卖'"></div>
  74. </td>
  75. <td>
  76. <div v-for="price in commodity.prices" v-text="price.start + '+'"></div>
  77. </td>
  78. <!--<td>-->
  79. <!--<div v-show="commodity.currencyName.indexOf('USD')==-1 || !commodity.prices">-->
  80. <!--<span>—</span>-->
  81. <!--</div>-->
  82. <!--<div v-for="price in commodity.prices">{{price.uSDPrice | currency}}</div>-->
  83. <!--</td>-->
  84. <!--<td>-->
  85. <!--<div v-show="commodity.currencyName.indexOf('RMB')==-1 || !commodity.prices">-->
  86. <!--<span>—</span>-->
  87. <!--</div>-->
  88. <!--<div v-for="price in commodity.prices" >{{price.rMBPrice | currency}}</div>-->
  89. <!--</td>-->
  90. <td>
  91. <div v-for="price in commodity.prices">{{commodity.currencyName.indexOf('USD')!=-1?'$':'¥'}}{{commodity.currencyName.indexOf('USD')!=-1?price.uSDPrice:price.rMBPrice | currency}}</div>
  92. <div v-if="commodity.currencyName.indexOf('RMB')==-1 || !commodity.prices && commodity.currencyName.indexOf('USD')==-1 || !commodity.prices"></div>
  93. </td>
  94. <td>
  95. <div v-if="commodity.b2cMinDelivery">交期:
  96. <!--{{commodity.b2cMinDelivery || 0}}-{{commodity.b2cMaxDelivery || 0}}天-->
  97. <span v-if="commodity.b2cMinDelivery != commodity.b2cMaxDelivery" v-text="commodity.b2cMinDelivery + '-' + commodity.b2cMaxDelivery"></span>
  98. <span v-if="commodity.b2cMinDelivery == commodity.b2cMaxDelivery" v-text="commodity.b2cMinDelivery"></span>
  99. </div>
  100. <div v-if="!commodity.b2cMinDelivery"><span>—</span></div>
  101. </td>
  102. <td>
  103. <div v-if="commodity.attach">
  104. <a :href="commodity.attach && commodity.attach !== '1'" target="_blank"><img src="/images/store/common/pdf.png" alt=""/></a>
  105. </div>
  106. <div v-show="!commodity.attach || commodity.attach == '1'">—</div>
  107. </td>
  108. <td>
  109. <buy :item="commodity" :disabledFlag="commodity.status === 602"></buy>
  110. </td>
  111. </tr>
  112. <tr v-if="!commodities.content || commodities.content.length == 0">
  113. <td colspan="10">
  114. <div class="text-center">
  115. <div class="col-xs-offset-3 col-xs-2">
  116. <img src="/images/all/empty-cart.png">
  117. </div>
  118. <div class="col-xs-4 txt-info">
  119. <p class="grey f16">暂无器件信息</p>
  120. <a href="/">马上去逛一逛</a>
  121. </div>
  122. </div>
  123. </td>
  124. </tr>
  125. </tbody>
  126. </table>
  127. <div style="float: right;">
  128. <page :total="commodities.totalElements" :page-size="pageParams.count"
  129. :current="pageParams.page" @childEvent="handleCurrentChange"></page>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </template>
  135. <script>
  136. function getAllLeafIds (kind) {
  137. if (!kind) {
  138. return null
  139. }
  140. if (kind.isLeaf === 1) {
  141. if (kind.nameCn === '其他') {
  142. return '其他'
  143. }
  144. return kind.id
  145. } else {
  146. if (!kind.children || kind.children.length === 0) {
  147. return null
  148. }
  149. let ids = []
  150. for (let i = 0; i < kind.children.length; i++) {
  151. ids.push(getAllLeafIds(kind.children[i]))
  152. }
  153. return ids.join(',')
  154. }
  155. }
  156. import Buy from '~components/common/buyOrCar/buyComponent.vue'
  157. import Page from '~components/common/page/pageComponent.vue'
  158. export default {
  159. name: 'commodity-list',
  160. props: ['kinds'],
  161. components: {
  162. Buy,
  163. Page
  164. },
  165. data () {
  166. return {
  167. defaultProps: {
  168. children: 'children',
  169. label: 'nameCn'
  170. },
  171. pageParams: {
  172. page: 1,
  173. count: 6
  174. },
  175. searchCode: '',
  176. parentKindId: 0,
  177. ids: null
  178. }
  179. },
  180. filters: {
  181. currency: function (num) {
  182. if (typeof num === 'number') {
  183. if (num <= 0.000001) {
  184. num = 0.000001
  185. } else {
  186. if (num.toString().indexOf('.') === -1) {
  187. num += '.00'
  188. } else {
  189. let inputStr = num.toString()
  190. let arr = inputStr.split('.')
  191. let floatNum = arr[1]
  192. if (floatNum.length > 6) {
  193. num = inputStr.substring(0, arr[0].length + 7)
  194. if (Number(floatNum.charAt(6)) > 4) {
  195. num = (Number(num) * 1000000 + 1) / 1000000
  196. }
  197. } else if (floatNum.length === 1) {
  198. num = num + '0'
  199. }
  200. }
  201. }
  202. }
  203. return num
  204. }
  205. },
  206. computed: {
  207. commodities () {
  208. return this.$store.state.shop.storeInfo.storeCommodity.data
  209. },
  210. storeInfo () {
  211. return this.$store.state.shop.storeInfo.store.data
  212. }
  213. },
  214. methods: {
  215. handlerCurrentNode (data, node) {
  216. this.searchCode = ''
  217. if (this.parentKindId === data.id) {
  218. this.parentKindId = 0
  219. this.ids = null
  220. } else {
  221. if (data.level === 1) {
  222. this.parentKindId = data.id
  223. }
  224. this.ids = getAllLeafIds(data)
  225. }
  226. this.pageParams.page = 1
  227. this.pageCommodity(this.pageParams, this.ids)
  228. },
  229. goodsSearch (keyword) {
  230. this.pageParams.page = 1
  231. this.pageCommodity(this.pageParams, this.ids, keyword)
  232. },
  233. async pageCommodity (pageParams, kindId, keyword) {
  234. // pageCommodity (pageParams, kindId, keyword) {
  235. let params = { storeid: this.$route.params.uuid, origin: 'store', kindUuid: kindId, code: keyword }
  236. params.page = pageParams.page
  237. params.count = pageParams.count
  238. try {
  239. let { data } = await this.$http.get('/api/commodity/commodities', { params })
  240. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_SUCCESS', data)
  241. } catch (err) {
  242. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_FAILURE', err)
  243. }
  244. // this.$http.get('/api/commodity/commodities', { params }).then(response => {
  245. // this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_SUCCESS', response)
  246. // }, err => {
  247. // this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_FAILURE', err)
  248. // })
  249. },
  250. handleCurrentChange (page) {
  251. this.pageParams.page = page
  252. this.pageCommodity(this.pageParams, this.ids, this.searchCode)
  253. },
  254. goBatchDetail (storeId, batchCode) {
  255. this.$router.push('/store/' + storeId + '/' + batchCode)
  256. },
  257. goBrandDetail (url, event) {
  258. event.stopPropagation()
  259. this.$router.push(url)
  260. }
  261. // goBack () {
  262. // this.$router.back(-1)
  263. // }
  264. }
  265. }
  266. </script>
  267. <style>
  268. /* 产品分类调整*/
  269. .category-content .el-tree{
  270. border: none;
  271. }
  272. .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content,.el-tree-node:hover{
  273. background: none !important;
  274. }
  275. .el-tree-node__content:hover{
  276. background: none !important;
  277. }
  278. .el-tree-node__content:hover span{
  279. color: #5078cb;
  280. }
  281. .el-pagination .el-pager li.active{
  282. background-color: #5078cb;
  283. border-color: #337ab7;
  284. }
  285. .el-tree-node__expand-icon{
  286. font-family: "iconfont" !important;
  287. font-size: 14px;
  288. font-style: normal;
  289. -webkit-font-smoothing: antialiased;
  290. width: inherit;
  291. height: inherit;
  292. border: inherit;
  293. font-weight: bold;
  294. text-shadow: -1px 0px 0 #333;
  295. margin-right: 3px !important;
  296. }
  297. .el-tree-node__content{
  298. line-height: 30px;
  299. height: 30px;
  300. }
  301. .el-tree-node__expand-icon.is-leaf{
  302. visibility: hidden;
  303. }
  304. .el-tree-node__expand-icon:before{
  305. content: "\E621";
  306. }
  307. #goods-list-fragment .category-title {
  308. height: 34px;
  309. background-color: #5078cb;
  310. font-size: 14px;
  311. color: rgb(255,255,255);
  312. font-weight: 600;
  313. text-align: center;
  314. }
  315. #goods-list-fragment .category-content li {
  316. line-height: 33px;
  317. font-size: 14px;
  318. color: #333;
  319. float: left;
  320. width: 100%;
  321. padding-left: 10px;
  322. }
  323. #goods-list-fragment .category-content li a {
  324. display: block;
  325. padding-left: 15px;
  326. text-decoration: none;
  327. color: #333;
  328. /* background:url("static/img/store/default/openblackR.png") no-repeat left; */
  329. }
  330. #goods-list-fragment .category-content li a:hover{
  331. color: #5078cb;
  332. cursor: pointer;
  333. }
  334. #goods-list-fragment .category-content ul.list-body {
  335. display: none;
  336. color: #666;
  337. }
  338. #goods-list-fragment .category-content ul.list-body.active {
  339. display: block;
  340. }
  341. #goods-list-fragment .category-content ul.list-body li {
  342. float: none;
  343. background-image: none;
  344. min-height: 26px;
  345. line-height: 26px;
  346. font-size: 12px;
  347. }
  348. #goods-list-fragment .category-content ul.list-body li a {
  349. padding-left: 15px;
  350. display: block;
  351. color: rgb(50,50,50);
  352. background: none;
  353. }
  354. #goods-list-fragment .category-content ul.list-body li a:hover {
  355. color: #5078cb;
  356. cursor: pointer;
  357. }
  358. #goods-list-fragment .category-content ul.list-body li a.cur {
  359. text-decoration: none;
  360. font-size: 14px;
  361. /* background:url("static/img/store/default/openblackR.png") no-repeat left; */
  362. }
  363. #goods-list-fragment .title-area {
  364. margin-bottom: 30px;
  365. width: 200px;
  366. float: left;
  367. }
  368. #goods-list-fragment .category-content{
  369. border: 1px solid #e8e8e8;
  370. }
  371. /* goods-area */
  372. #goods-list-fragment .goods-area {
  373. margin-left: 20px;
  374. float: left;
  375. margin-bottom: 30px;
  376. }
  377. #goods-list-fragment .goods-area .btn-line {
  378. border-radius: 0;
  379. }
  380. #goods-list-fragment .btn-info.btn-line {
  381. background-color: #5078CB;
  382. color: #fff;
  383. font-weight: 600;
  384. }
  385. #goods-list-fragment .btn-line {
  386. height: 34px;
  387. width: 150px;
  388. border: 1px solid #5078cb;
  389. background-color: #fff;
  390. color: rgb(80,120,203);
  391. font-weight: 600;
  392. }
  393. #goods-list-fragment .btn-line:hover {
  394. background-color: #5078CB;
  395. color: #fff;
  396. }
  397. /* 物品列表 */
  398. #goods-list-fragment .goodslist .brand-code {
  399. font-size: 14px;
  400. text-align: center;
  401. position: relative;
  402. }
  403. #goods-list-fragment #search_btn {
  404. background: #5078CB;
  405. color: #FFFFFF;
  406. }
  407. #goods-list-fragment #search_input {
  408. font-size: 14px;
  409. }
  410. #goods-list-fragment .brand-code .code {
  411. font-weight: 600;
  412. }
  413. #goods-list-fragment .brand-code .brand a:hover {
  414. color: #f39801;
  415. }
  416. #goods-list-fragment .goodslist th {
  417. color: rgb(50,50,50);
  418. font-size: 14px;
  419. font-weight: 600;
  420. background-color: #f7f7f7;
  421. text-align: center;
  422. }
  423. #goods-list-fragment .category-content a.selected-node,
  424. #goods-list-fragment .category-content ul.list-body li a.selected-node {
  425. color: #5078cb;
  426. }
  427. #goods-list-fragment .category-content a.selected-parent-node,
  428. #goods-list-fragment .category-content ul.list-body li a.selected-parent-node {
  429. /* background:url("static/img/store/default/openblack.png") no-repeat left; */
  430. }
  431. #goods-list-fragment .goodslist tbody>tr {
  432. border: 1px solid #e8e8e8;
  433. cursor: pointer;
  434. }
  435. #goods-list-fragment .goodslist tbody>tr:hover{
  436. background: #ecf2fd;
  437. }
  438. #goods-list-fragment .goodslist tbody>tr td.commodity-icon {
  439. position: relative;
  440. }
  441. #goods-list-fragment .goodslist tbody>tr td.commodity-icon .img{
  442. border: 1px solid #e8e8e8;
  443. margin: 10px;
  444. width: 80px;
  445. height: 80px;
  446. overflow: hidden;
  447. line-height: 75px;
  448. }
  449. #goods-list-fragment .goodslist tbody>tr td.commodity-icon .img>img {
  450. width: 80px;
  451. height: 80px;
  452. }
  453. #goods-list-fragment .goodslist tbody>tr td.brand-code .sellout-store-commodity {
  454. position: absolute;
  455. right: 0;
  456. bottom: 0;
  457. }
  458. #goods-list-fragment .goodslist td {
  459. font-size: 12px;
  460. color: #333;
  461. text-align: center;
  462. line-height: 20px;
  463. }
  464. #goods-list-fragment .goodslist tbody>tr td .can-div-sell {
  465. color: #333;
  466. }
  467. /* 物品列表按钮 */
  468. #goods-list-fragment .btn-buy-now {
  469. margin: 5px 0;
  470. background-color: #5078CB;
  471. color: #fff;
  472. width: 80px;
  473. height: 30px;
  474. font-size: 12px;
  475. border: 1px solid #5078cb;
  476. }
  477. #goods-list-fragment .btn-add-cart {
  478. margin: 10px 0 5px 0;
  479. color: #214797;
  480. width: 80px;
  481. height: 30px;
  482. font-size: 12px;
  483. background-color: #fff;
  484. border: 1px solid #e8e8e8;
  485. }
  486. #goods-list-fragment .btn-buy-now:hover{
  487. background: #214797;
  488. }
  489. #goods-list-fragment .btn-add-cart:hover{
  490. background-color: #5078CB;
  491. color: #fff;
  492. }
  493. .category-content{
  494. /*min-height: 243px;*/
  495. }
  496. .no-record{
  497. font-size: 14px;
  498. color: #999;
  499. text-align: center;
  500. line-height: 200px;
  501. }
  502. .no-record i{
  503. margin-right: 5px;
  504. }
  505. .text-center{
  506. text-align: center;
  507. margin-top: 30px;
  508. }
  509. .text-center .col-xs-2 img{
  510. margin: 50px 0 50px 95px;
  511. vertical-align: middle;
  512. }
  513. .text-center .txt-info{
  514. font-size: 14px;
  515. margin-top: 70px;
  516. }
  517. .text-center .col-xs-4 p{
  518. color: #999;
  519. margin-top: 3px;
  520. margin-bottom: 2px;
  521. }
  522. .text-center .txt-info a{
  523. font-size: 14px;
  524. display: block;
  525. color: #5078cb;
  526. background: url('/images/all/icon_nianxian.jpg')no-repeat 105px center;
  527. padding-left: 50px;
  528. }
  529. .text-center .col-xs-4 i{
  530. color: #5078cb;
  531. font-size: 14px;
  532. }
  533. .goodslist{
  534. margin-bottom: 16px;
  535. }
  536. @font-face {
  537. font-family: 'iconfont'; /* project id 357960 */
  538. src: url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.eot');
  539. src: url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.eot?#iefix') format('embedded-opentype'),
  540. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.woff') format('woff'),
  541. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.ttf') format('truetype'),
  542. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.svg#iconfont') format('svg');
  543. }
  544. <!-- 分页 -->
  545. #goods-list-fragment .el-pagination .el-pager li.active {
  546. border-color: #5078cb !important;
  547. background-color: #5078cb !important;
  548. }
  549. </style>