CommodityList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. function getAllLeafIds (kind) {
  117. if (!kind) {
  118. return null
  119. }
  120. if (kind.isLeaf === 1) {
  121. return kind.id
  122. } else {
  123. if (!kind.children || kind.children.length === 0) {
  124. return null
  125. }
  126. let ids = []
  127. for (let i = 0; i < kind.children.length; i++) {
  128. ids.push(getAllLeafIds(kind.children[i]))
  129. }
  130. return ids.join('-')
  131. }
  132. }
  133. export default {
  134. name: 'commodity-list',
  135. props: ['kinds'],
  136. data () {
  137. return {
  138. defaultProps: {
  139. children: 'children',
  140. label: 'nameCn'
  141. },
  142. pageParams: {
  143. page: 1,
  144. count: 6
  145. },
  146. searchCode: '',
  147. parentKindId: 0,
  148. ids: null
  149. }
  150. },
  151. computed: {
  152. commodities () {
  153. return this.$store.state.shop.storeInfo.storeCommodity.data
  154. }
  155. },
  156. methods: {
  157. handlerCurrentNode (data, node) {
  158. this.searchCode = ''
  159. if (this.parentKindId === data.id) {
  160. this.parentKindId = 0
  161. this.ids = null
  162. console.log('取消选中状态')
  163. } else {
  164. if (data.level === 1) {
  165. this.parentKindId = data.id
  166. }
  167. this.ids = getAllLeafIds(data)
  168. }
  169. console.log('data', data.id + '-' + data.nameCn)
  170. this.pageParams.page = 1
  171. this.pageCommodity(this.pageParams, this.ids)
  172. },
  173. goodsSearch (keyword) {
  174. console.log(keyword)
  175. this.pageParams.page = 1
  176. this.pageCommodity(this.pageParams, this.ids, keyword)
  177. },
  178. async pageCommodity (pageParams, kindId, keyword) {
  179. let params = { storeid: this.$route.params.uuid, origin: 'store', kindUuid: kindId, code: keyword }
  180. params.page = pageParams.page
  181. params.count = pageParams.count
  182. let { data } = await this.$http.get('/api/commodity/commodities', { params })
  183. this.$store.commit('shop/storeInfo/GET_STORE_COMMODITY_SUCCESS', data)
  184. }
  185. }
  186. }
  187. </script>
  188. <style scoped>
  189. #goods-list-fragment{
  190. font-family: "Microsoft Yahei", "微软雅黑";
  191. }
  192. #goods-list-fragment .category-title {
  193. height: 34px;
  194. background-color: #5078cb;
  195. font-size: 14px;
  196. color: rgb(255,255,255);
  197. font-weight: 600;
  198. text-align: center;
  199. }
  200. #goods-list-fragment .category-content li {
  201. line-height: 33px;
  202. font-size: 14px;
  203. color: #333;
  204. float: left;
  205. width: 100%;
  206. padding-left: 10px;
  207. }
  208. #goods-list-fragment .category-content li a {
  209. display: block;
  210. padding-left: 15px;
  211. text-decoration: none;
  212. color: #333;
  213. /* background:url("static/img/store/default/openblackR.png") no-repeat left; */
  214. }
  215. #goods-list-fragment .category-content li a:hover{
  216. color: #5078cb;
  217. cursor: pointer;
  218. }
  219. #goods-list-fragment .category-content ul.list-body {
  220. display: none;
  221. color: #666;
  222. }
  223. #goods-list-fragment .category-content ul.list-body.active {
  224. display: block;
  225. }
  226. #goods-list-fragment .category-content ul.list-body li {
  227. float: none;
  228. background-image: none;
  229. min-height: 26px;
  230. line-height: 26px;
  231. font-size: 12px;
  232. }
  233. #goods-list-fragment .category-content ul.list-body li a {
  234. padding-left: 15px;
  235. display: block;
  236. color: rgb(50,50,50);
  237. background: none;
  238. }
  239. #goods-list-fragment .category-content ul.list-body li a:hover {
  240. color: #5078cb;
  241. cursor: pointer;
  242. }
  243. #goods-list-fragment .category-content ul.list-body li a.cur {
  244. text-decoration: none;
  245. font-size: 14px;
  246. /* background:url("static/img/store/default/openblackR.png") no-repeat left; */
  247. }
  248. #goods-list-fragment .title-area {
  249. margin-bottom: 30px;
  250. width: 200px;
  251. float: left;
  252. }
  253. #goods-list-fragment .category-content{
  254. border: 1px solid #e8e8e8;
  255. }
  256. /* goods-area */
  257. #goods-list-fragment .goods-area {
  258. margin-left: 20px;
  259. float: left;
  260. margin-bottom: 30px;
  261. }
  262. #goods-list-fragment .goods-area .btn-line {
  263. border-radius: 0;
  264. }
  265. #goods-list-fragment .btn-info.btn-line {
  266. background-color: #5078CB;
  267. color: #fff;
  268. font-weight: 600;
  269. }
  270. #goods-list-fragment .btn-line {
  271. height: 34px;
  272. width: 150px;
  273. border: 1px solid #5078cb;
  274. background-color: #fff;
  275. color: rgb(80,120,203);
  276. font-weight: 600;
  277. }
  278. #goods-list-fragment .btn-line:hover {
  279. background-color: #5078CB;
  280. color: #fff;
  281. }
  282. /* 物品列表 */
  283. #goods-list-fragment .goodslist .brand-code {
  284. font-size: 14px;
  285. text-align: center;
  286. }
  287. #goods-list-fragment #search_btn {
  288. background: #5078CB;
  289. color: #FFFFFF;
  290. }
  291. #goods-list-fragment #search_input {
  292. font-size: 14px;
  293. }
  294. #goods-list-fragment .brand-code .code {
  295. font-weight: 600;
  296. }
  297. #goods-list-fragment .goodslist th {
  298. color: rgb(50,50,50);
  299. font-size: 14px;
  300. font-weight: 600;
  301. background-color: #f7f7f7;
  302. text-align: center;
  303. }
  304. #goods-list-fragment .category-content a.selected-node,
  305. #goods-list-fragment .category-content ul.list-body li a.selected-node {
  306. color: #5078cb;
  307. }
  308. #goods-list-fragment .category-content a.selected-parent-node,
  309. #goods-list-fragment .category-content ul.list-body li a.selected-parent-node {
  310. /* background:url("static/img/store/default/openblack.png") no-repeat left; */
  311. }
  312. #goods-list-fragment .goodslist tbody>tr {
  313. border: 1px solid #e8e8e8;
  314. }
  315. #goods-list-fragment .goodslist tbody>tr td.commodity-icon .img{
  316. border: 1px solid #e8e8e8;
  317. margin: 10px;
  318. width: 80px;
  319. height: 80px;
  320. overflow: hidden;
  321. line-height: 75px;
  322. }
  323. #goods-list-fragment .goodslist tbody>tr td.commodity-icon .img>img {
  324. width: 80px;
  325. height: 80px;
  326. }
  327. #goods-list-fragment .goodslist td {
  328. font-size: 12px;
  329. color: #333;
  330. text-align: center;
  331. line-height: 20px;
  332. }
  333. /* 物品列表按钮 */
  334. #goods-list-fragment .btn-buy-now {
  335. background-color: #5078CB;
  336. color: #fff;
  337. width: 80px;
  338. height: 30px;
  339. font-size: 12px;
  340. border: 1px solid #5078cb;
  341. }
  342. #goods-list-fragment .btn-add-cart {
  343. margin-top: 10px;
  344. color: #214797;
  345. width: 80px;
  346. height: 30px;
  347. font-size: 12px;
  348. background-color: #fff;
  349. border: 1px solid #e8e8e8;
  350. }
  351. #goods-list-fragment .btn-buy-now:hover{
  352. background: #214797;
  353. }
  354. #goods-list-fragment .btn-add-cart:hover{
  355. background-color: #5078CB;
  356. color: #fff;
  357. }
  358. .category-content{
  359. min-height: 243px;
  360. }
  361. .no-record{
  362. font-size: 14px;
  363. color: #999;
  364. text-align: center;
  365. line-height: 200px;
  366. }
  367. .no-record i{
  368. margin-right: 5px;
  369. }
  370. .text-center{
  371. text-align: center;
  372. margin-top: 30px;
  373. }
  374. .text-center .col-xs-2 img{
  375. margin: 50px 0 50px 95px;
  376. vertical-align: middle;
  377. }
  378. .text-center .txt-info{
  379. font-size: 14px;
  380. margin-top: 70px;
  381. }
  382. .text-center .col-xs-4 p{
  383. color: #999;
  384. margin-top: 3px;
  385. margin-bottom: 2px;
  386. }
  387. .text-center .txt-info a{
  388. font-size: 14px;
  389. }
  390. .text-center .col-xs-4 i{
  391. color: #5078cb;
  392. font-size: 14px;
  393. }
  394. .goodslist{
  395. margin-bottom: 16px;
  396. }
  397. @font-face {
  398. font-family: 'iconfont'; /* project id 357960 */
  399. src: url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.eot');
  400. src: url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.eot?#iefix') format('embedded-opentype'),
  401. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.woff') format('woff'),
  402. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.ttf') format('truetype'),
  403. url('//at.alicdn.com/t/font_27kjyd082ezpk3xr.svg#iconfont') format('svg');
  404. }
  405. </style>