ComponentGoods.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <div class="component-table">
  3. <!-- 筛选结果展示 -->
  4. <div class="search-record">
  5. 筛选后现为您找到以下<span class="red">{{componentGoods.totalElements}}</span>个结果
  6. </div>
  7. <!-- 列表展示 -->
  8. <table class="product-list">
  9. <thead>
  10. <tr style="height: 40px;">
  11. <th width="180">品牌/物料名称/型号/规格</th>
  12. <th width="100">包装</th>
  13. <th width="120">卖家名称</th>
  14. <th width="110">库存</th>
  15. <th width="210">价格梯度(PCS)</th>
  16. <th width="100">交期(天)</th>
  17. <th width="100">操作</th>
  18. </tr>
  19. </thead>
  20. <tbody id="productList-content">
  21. <!--| orderBy : dir + orderType ng-class="{'tr-even' : !compGoods.isOdd}"-->
  22. <tr v-for="compGoods in componentGoods.content">
  23. <!--<td>
  24. &lt;!&ndash;store/{{compGoods.storeId}}#/batchInfo/{{compGoods.batchCode}}&ndash;&gt;
  25. <nuxt-link v-if="compGoods.batchCode" :to="`/store/${compGoods.storeId}/${compGoods.batchCode}`" target="_blank">
  26. <img :src="compGoods.img?compGoods.img:'/images/all/default.png'"/>
  27. </nuxt-link>
  28. <img v-if="!compGoods.batchCode" :src="compGoods.img || '/images/all/default.png'"/>
  29. &lt;!&ndash;store/{{compGoods.storeId}}#/home&ndash;&gt;
  30. <nuxt-link :to="'/store/' + compGoods.storeId" class="contact" :title="compGoods.storeName" target="_blank">{{compGoods.storeName}}</nuxt-link>
  31. </td>-->
  32. <td class="brand-code">
  33. <div class="brand" v-if="compGoods.brand.nameEn"><nuxt-link :to="`/product/brand/${compGoods.brand.uuid}/`" :title="compGoods.brand.nameEn">{{compGoods.brand.nameEn | nameFilter}}</nuxt-link></div>
  34. <div class="brand" v-if="!compGoods.brand.nameEn">—</div>
  35. <div class="list" v-if="compGoods.kind"><nuxt-link :to="`/product/kind/${compGoods.kind.id}`" :title="compGoods.kind.nameCn">{{compGoods.kind.nameCn | listFilter}}</nuxt-link></div>
  36. <div class="list" v-if="!compGoods.kind">—</div>
  37. <div class="code" v-if="compGoods.code"><nuxt-link :to="`/product/component/${compGoods.uuid}/`" :title="compGoods.code">{{compGoods.code | codeFilter}}</nuxt-link></div>
  38. <div class="code" v-if="!compGoods.code">—</div>
  39. <div class="code" :title="compGoods.spec"><span class="text-ellipse inline-block fl" style="width: 160px">{{compGoods.spec || '-'}}</span></div>
  40. </td>
  41. <td>
  42. <div class="package" v-if="compGoods.packaging">{{compGoods.packaging}}</div>
  43. <div class="package" v-else>—</div>
  44. <!--<div v-if="!compGoods.produceDate && !compGoods.packaging">—</div>-->
  45. <!--<div class="date" v-if="compGoods.produceDate">{{compGoods.produceDate}}</div>-->
  46. <!--<div class="date" v-if="!compGoods.produceDate && compGoods.packaging">—</div>-->
  47. </td>
  48. <td class="merchantName">
  49. <div v-if="!compGoods.storeName" style="margin-top: 20px;">—</div>
  50. <!--<div v-for="price in compGoods.prices">
  51. &lt;!&ndash;| number&ndash;&gt;
  52. <span>{{price.start}}</span> +
  53. </div>-->
  54. <div v-if="compGoods.storeName">
  55. <nuxt-link :to="'/store/' + compGoods.storeId" class="contact" :title="compGoods.storeName" target="_blank"><span>{{compGoods.storeName | storeNameFilter}}</span></nuxt-link>
  56. </div>
  57. </td>
  58. <td class="text-left">
  59. <div class="goods" v-if="compGoods.reserve">
  60. 库存:<span>{{compGoods.reserve}}</span>
  61. </div>
  62. <div v-if="!compGoods.reserve" style="text-align: center;margin-left: 0;"><span>—</span></div>
  63. <div class="from" v-if="compGoods.reserve && compGoods.reserve > 0">
  64. 起拍:<span v-if="compGoods.minBuyQty">{{compGoods.minBuyQty}}</span>
  65. </div>
  66. <!--<div class="multiple" v-if="compGoods.reserve > 0">
  67. 倍数:<span>{{compGoods.minPackQty}}</span>
  68. </div>-->
  69. <div class="can-div-sell" v-if="compGoods.reserve" v-text="compGoods.breakUp?'可拆卖':''"></div>
  70. </td>
  71. <td>
  72. <div v-if="!compGoods.prices">
  73. <span>—</span>
  74. </div>
  75. <div class="amount">
  76. <div v-for="price in compGoods.prices"><span>{{price.start}}</span> +</div>
  77. </div>
  78. <!-- <div v-if="(compGoods.currencyName && compGoods.currencyName.indexOf('USD')==-1) || !compGoods.prices">
  79. <span>—</span>
  80. </div>
  81. <div v-for="price in compGoods.prices">
  82. &lt;!&ndash;| formateNumber : 6&ndash;&gt;
  83. <span>{{price.uSDPrice | currency}}</span>
  84. </div>-->
  85. <div class="price">
  86. <!--<div v-if="(compGoods.currencyName && compGoods.currencyName.indexOf('RMB')==-1) || !compGoods.prices">
  87. <span>—</span>
  88. </div>-->
  89. <div v-for="price in compGoods.prices">
  90. <!--formateNumber : 6-->
  91. <span>¥{{price.rMBPrice | currency}}</span>
  92. </div>
  93. </div>
  94. </td>
  95. <td>
  96. <div v-if="!compGoods.b2cMinDelivery">
  97. <span>—</span>
  98. </div>
  99. <div v-if="compGoods.b2cMinDelivery"><span v-if="compGoods.b2cMinDelivery != compGoods.b2cMaxDelivery">{{compGoods.b2cMinDelivery + '-' + compGoods.b2cMaxDelivery}}</span>
  100. <span v-if="compGoods.b2cMinDelivery == compGoods.b2cMaxDelivery">{{compGoods.b2cMinDelivery}}</span>
  101. </div>
  102. </td>
  103. <td>
  104. <div v-show="!compGoods.reserve">
  105. <span>—</span>
  106. </div>
  107. <div v-if="compGoods.reserve > 0">
  108. <buy :item="compGoods" :btnColor="'#3975f4'"></buy>
  109. </div>
  110. </td>
  111. </tr>
  112. <tr v-if="componentGoods.totalElements == 0">
  113. <td colspan="10" class="text-center" style="line-height: 40px; font-size: 20px;">
  114. <i class="fa fa-smile-o fa-lg"></i> 暂无产品信息
  115. </td>
  116. </tr>
  117. </tbody>
  118. </table>
  119. <div style="float: right; margin-bottom: 15px;">
  120. <page :total="componentGoods.totalElements" :page-size="pageParams.count"
  121. :current="pageParams.page" @childEvent="handleCurrentChange"></page>
  122. </div>
  123. </div>
  124. </template>
  125. <script>
  126. import Buy from '~components/common/buyOrCar/buyComponent.vue'
  127. import Page from '~components/common/page/pageComponent.vue'
  128. export default {
  129. layout: 'mian',
  130. props: ['brandid', 'propertyJSON'],
  131. components: {
  132. Buy,
  133. Page
  134. },
  135. data () {
  136. return {
  137. pageParams: {
  138. page: 1,
  139. count: 10,
  140. filter: {
  141. kindid: this.$route.params.id,
  142. brandid: this.brandid,
  143. propertyJSON: this.propertyJSON
  144. }
  145. }
  146. }
  147. },
  148. computed: {
  149. componentGoods () {
  150. let goodsPage = this.$store.state.product.component.componentGoods.data
  151. this.pageParams.page = goodsPage.number
  152. return goodsPage
  153. }
  154. },
  155. filters: {
  156. nameFilter: function (title) {
  157. if (title === '') {
  158. return title
  159. }
  160. let len = 0
  161. let index = 0
  162. for (let i = 0; i < title.length; i++) {
  163. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  164. len = len + 2
  165. } else {
  166. len++
  167. }
  168. if (len > 20) {
  169. index = i
  170. break
  171. }
  172. }
  173. if (index > 0) {
  174. return title.substring(0, index) + '...'
  175. } else {
  176. return title
  177. }
  178. },
  179. codeFilter: function (title) {
  180. if (title === '') {
  181. return title
  182. }
  183. let len = 0
  184. let index = 0
  185. for (let i = 0; i < title.length; i++) {
  186. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  187. len = len + 2
  188. } else {
  189. len++
  190. }
  191. if (len > 20) {
  192. index = i
  193. break
  194. }
  195. }
  196. if (index > 0) {
  197. return title.substring(0, index) + '...'
  198. } else {
  199. return title
  200. }
  201. },
  202. listFilter: function (title) {
  203. if (title === '') {
  204. return title
  205. }
  206. let len = 0
  207. let index = 0
  208. for (let i = 0; i < title.length; i++) {
  209. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  210. len = len + 2
  211. } else {
  212. len++
  213. }
  214. if (len > 20) {
  215. index = i
  216. break
  217. }
  218. }
  219. if (index > 0) {
  220. return title.substring(0, index) + '...'
  221. } else {
  222. return title
  223. }
  224. },
  225. storeNameFilter: function (title) {
  226. if (title === '') {
  227. return title
  228. }
  229. let len = 0
  230. let index = 0
  231. for (let i = 0; i < title.length; i++) {
  232. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  233. len = len + 2
  234. } else {
  235. len++
  236. }
  237. if (len > 20) {
  238. index = i
  239. break
  240. }
  241. }
  242. if (index > 0) {
  243. return title.substring(0, index) + '...'
  244. } else {
  245. return title
  246. }
  247. },
  248. currency: function (num) {
  249. if (typeof num === 'number') {
  250. if (num <= 0.000001) {
  251. num = 0.000001
  252. } else {
  253. if (num.toString().indexOf('.') === -1) {
  254. num += '.00'
  255. } else {
  256. let inputStr = num.toString()
  257. let arr = inputStr.split('.')
  258. let floatNum = arr[1]
  259. if (floatNum.length > 6) {
  260. num = inputStr.substring(0, arr[0].length + 7)
  261. if (Number(floatNum.charAt(6)) > 4) {
  262. num = (Number(num) * 1000000 + 1) / 1000000
  263. }
  264. } else if (floatNum.length === 1) {
  265. num = num + '0'
  266. }
  267. }
  268. }
  269. }
  270. return num
  271. }
  272. },
  273. methods: {
  274. addToCart: function (goods, buyNow) {
  275. return null
  276. },
  277. handlerCurrentNode (data, node) {
  278. this.pageParams.page = 1
  279. this.pageCmpGoods(this.pageParams)
  280. },
  281. async pageCmpGoods (pageParams) {
  282. let params = {}
  283. params.filter = { kindid: pageParams.filter.kindid }
  284. if (pageParams.filter.brandid && pageParams.filter.brandid !== '') {
  285. params.filter.brandid = pageParams.filter.brandid
  286. }
  287. if (pageParams.filter.propertyJSON !== null && Object.getOwnPropertyNames(pageParams.filter.propertyJSON).length > 3) {
  288. params.filter.properties = pageParams.filter.propertyJSON
  289. }
  290. params.page = pageParams.page
  291. params.count = pageParams.count
  292. let { data } = await this.$http.get('/api/product/product/getCompGoodsByKindid', { params })
  293. this.$store.commit('product/component/GET_CMPGOODS_SUCCESS', data)
  294. },
  295. handleCurrentChange (page) {
  296. this.pageParams.page = page
  297. this.pageParams.filter.brandid = this.brandid
  298. this.pageParams.filter.propertyJSON = this.propertyJSON
  299. this.pageParams.filter.kindid = this.$route.params.id
  300. this.pageCmpGoods(this.pageParams)
  301. }
  302. }
  303. }
  304. </script>
  305. <style lang="scss" scoped>
  306. .product-list{
  307. width: 1190px;
  308. margin-bottom: 20px;
  309. }
  310. .product-list thead tr{
  311. color: #333;
  312. background: none;
  313. }
  314. /* 物品列表 */
  315. .product-list .brand-code {
  316. font-size: 14px;
  317. text-align: center;
  318. }
  319. .product-list .brand-code .code,.product-list .brand-code .brand,.product-list .brand-code .list {
  320. width: 80%;
  321. margin: 0 auto;
  322. text-align: center;
  323. a {
  324. color: #333;
  325. &:hover{
  326. font-weight: 600;
  327. color: #3975f4;
  328. }
  329. }
  330. }
  331. .product-list th {
  332. color: rgb(50,50,50);
  333. font-size: 14px;
  334. font-weight: 600;
  335. background-color: #edf3ff;
  336. text-align: center;
  337. height: 46px;
  338. }
  339. .product-list .merchantName{
  340. span {
  341. color: #333;
  342. &:hover{
  343. font-weight: 600;
  344. color: #3975f4;
  345. }
  346. }
  347. }
  348. .product-list tbody>tr {
  349. border: 1px solid #d4e1ff;
  350. background: #fff;
  351. }
  352. .product-list tbody>tr:hover {
  353. background: #f9fbff;
  354. }
  355. .product-list tbody>tr img {
  356. border: 1px solid #e8e8e8;
  357. margin: 10px 0 5px 0;
  358. width: 36px;
  359. height: 36px;
  360. }
  361. .product-list tbody>tr .contact{
  362. font-size: 14px;
  363. color: #5078cb;
  364. width: 90%;
  365. margin: 0 auto;
  366. display: inline-block;
  367. }
  368. .product-list tbody>tr .contact:hover{
  369. color: #d32526;
  370. }
  371. .product-list td {
  372. font-size: 14px;
  373. /*color: #333;*/
  374. text-align: center;
  375. line-height: 20px;
  376. height: 100px;
  377. }
  378. .product-list td a{
  379. color: #337ab7;
  380. max-width: 160px;
  381. overflow: hidden;
  382. text-overflow: ellipsis;
  383. display: block;
  384. }
  385. .product-list td a:hover {
  386. color: #23527c;
  387. }
  388. /* 物品列表按钮 */
  389. .btn-buy-now {
  390. background-color: #3975f4!important;
  391. color: #fff;
  392. width: 80px;
  393. height: 30px;
  394. font-size: 12px;
  395. border: 1px solid #3975f4!important;;
  396. }
  397. .btn-add-cart {
  398. margin-top: 10px;
  399. color: #3975f4!important;
  400. width: 80px;
  401. height: 30px;
  402. font-size: 12px;
  403. background-color: #fff;
  404. border: 1px solid #3975f4!important;
  405. }
  406. .product-list .btn-buy-now:hover{
  407. background: #214797;
  408. }
  409. .product-list .btn-add-cart:hover{
  410. background-color: #3975f4;
  411. color: #fff;
  412. }
  413. .product-list .text-left{
  414. text-align: left;
  415. .goods {
  416. span {
  417. color: #f01010;
  418. }
  419. }
  420. }
  421. .product-list .text-left div{
  422. margin-left: 30px;
  423. }
  424. .product-list tbody tr td{
  425. padding: 10px 0;
  426. }
  427. .product-list tbody tr td .can-div-sell {
  428. color: #333;
  429. }
  430. .product-list tbody tr td .amount {
  431. width: 60%;
  432. float: left;
  433. padding-left: 60px;
  434. text-align: left;
  435. }
  436. .product-list tbody tr td .amount div:last-child, .product-list tbody tr td .price div:last-child{
  437. color: #f01010;
  438. }
  439. .product-list tbody tr td .price {
  440. width: 40%;
  441. float:right;
  442. text-align:left;
  443. }
  444. .search-record{
  445. width: 100%;
  446. height: 40px;
  447. font-size: 16px;
  448. line-height: 40px;
  449. margin: 14px 0px;
  450. background-color: #f1f1f1;
  451. border-bottom: 1px solid #ddd;
  452. border-top: 1px solid #ddd;
  453. padding-left: 10px;
  454. }
  455. .search-record span.red{
  456. color: #ff0909;
  457. }
  458. .el-pagination .el-pager li.active{
  459. background-color: #5078cb;
  460. border-color: #337ab7;
  461. }
  462. /*<!-- 分页 -->*/
  463. .el-pagination .el-pager li.active {
  464. border-color: #5078cb !important;
  465. background-color: #5078cb !important;
  466. }
  467. </style>