CommodityList.vue 16 KB

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