CommodityList.vue 13 KB

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