CommodityList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. } else {
  172. if (data.level === 1) {
  173. this.parentKindId = data.id
  174. }
  175. this.ids = getAllLeafIds(data)
  176. }
  177. this.pageParams.page = 1
  178. this.pageCommodity(this.pageParams, this.ids)
  179. },
  180. goodsSearch (keyword) {
  181. this.pageParams.page = 1
  182. this.pageCommodity(this.pageParams, this.ids, keyword)
  183. },
  184. async pageCommodity (pageParams, kindId, keyword) {
  185. let params = { storeid: this.$route.params.uuid, origin: 'store', kindUuid: kindId, code: keyword }
  186. params.page = pageParams.page
  187. params.count = pageParams.count
  188. try {
  189. let { data } = await this.$http.get('/api/commodity/commodities', { params })
  190. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_SUCCESS', data)
  191. } catch (err) {
  192. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_FAILURE', err)
  193. }
  194. },
  195. handleCurrentChange (page) {
  196. this.pageParams.page = page
  197. this.pageCommodity(this.pageParams, this.ids, this.searchCode)
  198. }
  199. }
  200. }
  201. </script>
  202. <style>
  203. /* 产品分类调整*/
  204. .category-content .el-tree{
  205. border: none;
  206. }
  207. .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content,.el-tree-node:hover{
  208. background: none !important;
  209. }
  210. .el-tree-node__content:hover{
  211. background: none !important;
  212. }
  213. .el-tree-node__content:hover span{
  214. color: #5078cb;
  215. }
  216. .el-pagination .el-pager li.active{
  217. background-color: #5078cb;
  218. border-color: #337ab7;
  219. }
  220. .el-tree-node__expand-icon{
  221. font-family: "iconfont" !important;
  222. font-size: 14px;
  223. font-style: normal;
  224. -webkit-font-smoothing: antialiased;
  225. width: inherit;
  226. height: inherit;
  227. border: inherit;
  228. font-weight: bold;
  229. text-shadow: -1px 0px 0 #333;
  230. margin-right: 3px !important;
  231. }
  232. .el-tree-node__content{
  233. line-height: 30px;
  234. height: 30px;
  235. }
  236. .el-tree-node__expand-icon.is-leaf{
  237. visibility: hidden;
  238. }
  239. .el-tree-node__expand-icon:before{
  240. content: "\E621";
  241. }
  242. #goods-list-fragment{
  243. font-family: "Microsoft Yahei", "微软雅黑";
  244. }
  245. #goods-list-fragment .category-title {
  246. height: 34px;
  247. background-color: #5078cb;
  248. font-size: 14px;
  249. color: rgb(255,255,255);
  250. font-weight: 600;
  251. text-align: center;
  252. }
  253. #goods-list-fragment .category-content li {
  254. line-height: 33px;
  255. font-size: 14px;
  256. color: #333;
  257. float: left;
  258. width: 100%;
  259. padding-left: 10px;
  260. }
  261. #goods-list-fragment .category-content li a {
  262. display: block;
  263. padding-left: 15px;
  264. text-decoration: none;
  265. color: #333;
  266. /* background:url("static/img/store/default/openblackR.png") no-repeat left; */
  267. }
  268. #goods-list-fragment .category-content li a:hover{
  269. color: #5078cb;
  270. cursor: pointer;
  271. }
  272. #goods-list-fragment .category-content ul.list-body {
  273. display: none;
  274. color: #666;
  275. }
  276. #goods-list-fragment .category-content ul.list-body.active {
  277. display: block;
  278. }
  279. #goods-list-fragment .category-content ul.list-body li {
  280. float: none;
  281. background-image: none;
  282. min-height: 26px;
  283. line-height: 26px;
  284. font-size: 12px;
  285. }
  286. #goods-list-fragment .category-content ul.list-body li a {
  287. padding-left: 15px;
  288. display: block;
  289. color: rgb(50,50,50);
  290. background: none;
  291. }
  292. #goods-list-fragment .category-content ul.list-body li a:hover {
  293. color: #5078cb;
  294. cursor: pointer;
  295. }
  296. #goods-list-fragment .category-content ul.list-body li a.cur {
  297. text-decoration: none;
  298. font-size: 14px;
  299. /* background:url("static/img/store/default/openblackR.png") no-repeat left; */
  300. }
  301. #goods-list-fragment .title-area {
  302. margin-bottom: 30px;
  303. width: 200px;
  304. float: left;
  305. }
  306. #goods-list-fragment .category-content{
  307. border: 1px solid #e8e8e8;
  308. }
  309. /* goods-area */
  310. #goods-list-fragment .goods-area {
  311. margin-left: 20px;
  312. float: left;
  313. margin-bottom: 30px;
  314. }
  315. #goods-list-fragment .goods-area .btn-line {
  316. border-radius: 0;
  317. }
  318. #goods-list-fragment .btn-info.btn-line {
  319. background-color: #5078CB;
  320. color: #fff;
  321. font-weight: 600;
  322. }
  323. #goods-list-fragment .btn-line {
  324. height: 34px;
  325. width: 150px;
  326. border: 1px solid #5078cb;
  327. background-color: #fff;
  328. color: rgb(80,120,203);
  329. font-weight: 600;
  330. }
  331. #goods-list-fragment .btn-line:hover {
  332. background-color: #5078CB;
  333. color: #fff;
  334. }
  335. /* 物品列表 */
  336. #goods-list-fragment .goodslist .brand-code {
  337. font-size: 14px;
  338. text-align: center;
  339. }
  340. #goods-list-fragment #search_btn {
  341. background: #5078CB;
  342. color: #FFFFFF;
  343. }
  344. #goods-list-fragment #search_input {
  345. font-size: 14px;
  346. }
  347. #goods-list-fragment .brand-code .code {
  348. font-weight: 600;
  349. }
  350. #goods-list-fragment .goodslist th {
  351. color: rgb(50,50,50);
  352. font-size: 14px;
  353. font-weight: 600;
  354. background-color: #f7f7f7;
  355. text-align: center;
  356. }
  357. #goods-list-fragment .category-content a.selected-node,
  358. #goods-list-fragment .category-content ul.list-body li a.selected-node {
  359. color: #5078cb;
  360. }
  361. #goods-list-fragment .category-content a.selected-parent-node,
  362. #goods-list-fragment .category-content ul.list-body li a.selected-parent-node {
  363. /* background:url("static/img/store/default/openblack.png") no-repeat left; */
  364. }
  365. #goods-list-fragment .goodslist tbody>tr {
  366. border: 1px solid #e8e8e8;
  367. }
  368. #goods-list-fragment .goodslist tbody>tr td.commodity-icon .img{
  369. border: 1px solid #e8e8e8;
  370. margin: 10px;
  371. width: 80px;
  372. height: 80px;
  373. overflow: hidden;
  374. line-height: 75px;
  375. }
  376. #goods-list-fragment .goodslist tbody>tr td.commodity-icon .img>img {
  377. width: 80px;
  378. height: 80px;
  379. }
  380. #goods-list-fragment .goodslist td {
  381. font-size: 12px;
  382. color: #333;
  383. text-align: center;
  384. line-height: 20px;
  385. }
  386. /* 物品列表按钮 */
  387. #goods-list-fragment .btn-buy-now {
  388. background-color: #5078CB;
  389. color: #fff;
  390. width: 80px;
  391. height: 30px;
  392. font-size: 12px;
  393. border: 1px solid #5078cb;
  394. }
  395. #goods-list-fragment .btn-add-cart {
  396. margin-top: 10px;
  397. color: #214797;
  398. width: 80px;
  399. height: 30px;
  400. font-size: 12px;
  401. background-color: #fff;
  402. border: 1px solid #e8e8e8;
  403. }
  404. #goods-list-fragment .btn-buy-now:hover{
  405. background: #214797;
  406. }
  407. #goods-list-fragment .btn-add-cart:hover{
  408. background-color: #5078CB;
  409. color: #fff;
  410. }
  411. .category-content{
  412. min-height: 243px;
  413. }
  414. .no-record{
  415. font-size: 14px;
  416. color: #999;
  417. text-align: center;
  418. line-height: 200px;
  419. }
  420. .no-record i{
  421. margin-right: 5px;
  422. }
  423. .text-center{
  424. text-align: center;
  425. margin-top: 30px;
  426. }
  427. .text-center .col-xs-2 img{
  428. margin: 50px 0 50px 95px;
  429. vertical-align: middle;
  430. }
  431. .text-center .txt-info{
  432. font-size: 14px;
  433. margin-top: 70px;
  434. }
  435. .text-center .col-xs-4 p{
  436. color: #999;
  437. margin-top: 3px;
  438. margin-bottom: 2px;
  439. }
  440. .text-center .txt-info a{
  441. font-size: 14px;
  442. }
  443. .text-center .col-xs-4 i{
  444. color: #5078cb;
  445. font-size: 14px;
  446. }
  447. .goodslist{
  448. margin-bottom: 16px;
  449. }
  450. @font-face {
  451. font-family: 'iconfont'; /* project id 357960 */
  452. src: url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.eot');
  453. src: url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.eot?#iefix') format('embedded-opentype'),
  454. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.woff') format('woff'),
  455. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.ttf') format('truetype'),
  456. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.svg#iconfont') format('svg');
  457. }
  458. <!-- 分页 -->
  459. #goods-list-fragment .el-pagination .el-pager li.active {
  460. border-color: #5078cb !important;
  461. background-color: #5078cb !important;
  462. }
  463. </style>