CommodityList.vue 16 KB

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