CommodityList.vue 14 KB

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