BrandList.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div class="component-list container">
  3. <nuxt-link to="/product/brand/_code"><div class="type-list">产品列表</div></nuxt-link>
  4. <div class="input-group">
  5. <input type="search" class="input-sm form-control" placeholder="请输入型号" title="code"
  6. v-model="searchCode" @search="goodsSearch(searchCode)"/>
  7. <span class="input-group-btn">
  8. <button class="search btn btn-default" type="button" @click="goodsSearch(searchCode)">搜索</button>
  9. </span>
  10. </div>
  11. <table class="table">
  12. <thead>
  13. <tr class="bgf7">
  14. <th width="330">产品名称</th>
  15. <th width="330">价格</th>
  16. <th width="330">操作</th>
  17. </tr>
  18. </thead>
  19. <tbody>
  20. <tr class="text-center" v-for="item in list.content">
  21. <td><nuxt-link :to="`/pcb/product/${item.productid}/${item.batchCode}`"><span>{{item.code}}</span></nuxt-link></td>
  22. <td>
  23. <div v-if="item.prices" v-text="item.currencyName === 'RMB' ? '¥' + item.prices[0].rMBPrice : '$' + item.prices[0].uSDPrice"></div>
  24. <div v-else>-</div>
  25. </td>
  26. <!--<td><a :href="item.attach" target="_blank"><button class="btn btn-default" :disabled="!item.attach" :class="{'disabledbtn':!item.attach}">Datasheet手册</button></a></td>-->
  27. <td>
  28. <button class="btn btn-default applay" @click="addToCar(item)">加入购物车</button>
  29. </td>
  30. </tr>
  31. <tr v-if="!list.content || list.content.length === 0">
  32. <td colspan="10" class="text-center">
  33. <div class="empty">
  34. <div class="empty-img">
  35. <img src="/images/brandList/empty-cart.png">
  36. </div>
  37. <div class="empty-info">
  38. <p class="grey f16"> 暂无器件信息 </p>
  39. <i class="fa fa-mail-reply fa-xs"></i>&nbsp;<a href="javascript:history.go(-1)">返回上一页</a>
  40. </div>
  41. </div>
  42. </td>
  43. </tr>
  44. </tbody>
  45. </table>
  46. <div style="float: right;">
  47. <page :total="list.totalElements" :page-size="pageParams.count"
  48. :current="pageParams.page" @childEvent="handleCurrentChange"></page>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. import Page from '~components/common/page/pageComponent.vue'
  54. import { buyOrCar } from '~utils/baseUtils'
  55. export default {
  56. name: 'BrandComponent',
  57. data () {
  58. return {
  59. pageParams: {
  60. page: 1,
  61. count: 10,
  62. filter: {}
  63. },
  64. searchCode: ''
  65. }
  66. },
  67. props: ['kindid'],
  68. components: {
  69. Page
  70. },
  71. computed: {
  72. lists () {
  73. return this.$store.state.brandComponent.component
  74. },
  75. list () {
  76. return this.lists.data
  77. },
  78. brand () {
  79. return this.$store.state.brandDetail.detail.data
  80. }
  81. },
  82. methods: {
  83. goodsSearch (keyword) {
  84. this.pageParams.page = 1
  85. this.pageParams.filter.code = keyword
  86. this.pageCmpGoods(this.pageParams)
  87. },
  88. handlerCurrentNode () {
  89. this.searchCode = ''
  90. this.pageParams.page = 1
  91. this.pageCmpGoods(this.pageParams)
  92. },
  93. async pageCmpGoods (params) {
  94. // pageCmpGoods (params) {
  95. // params.filter.brandid = this.brand.id
  96. let param = {
  97. branduuid: this.brand.uuid,
  98. count: this.pageParams.count,
  99. page: this.pageParams.page,
  100. kindid: this.kindid,
  101. keyword: this.searchCode || null
  102. }
  103. let { data } = await this.$http.get('/api/product/goods', {params: param})
  104. this.$store.commit('brandComponent/GET_COMPONENT_SUCCESS', data)
  105. // this.$http.get('/api/product/component/list', { params }).then(response => {
  106. // this.$store.commit('brandComponent/GET_COMPONENT_SUCCESS', response)
  107. // })
  108. },
  109. handleCurrentChange (page) {
  110. this.pageParams.page = page
  111. this.pageParams.filter.brandid = this.brand.id
  112. this.pageCmpGoods(this.pageParams)
  113. },
  114. toAttach: function (url) {
  115. if (url === '1') {
  116. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  117. if (response.data) {
  118. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  119. }
  120. })
  121. } else {
  122. window.open(url)
  123. }
  124. },
  125. addToCar: function (item) {
  126. buyOrCar(false, null, this, item)
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .component-list {
  133. float: left;
  134. margin-left: 20px;
  135. width: 970px;
  136. .type-list{
  137. height: 34px;
  138. width: 150px;
  139. border: 1px solid #3a75f5;
  140. background-color: #3a75f5;
  141. float: left;
  142. color: #fff;
  143. line-height: 34px;
  144. text-align: center;
  145. font-size: 14px;
  146. }
  147. .agency {
  148. height: 34px;
  149. width: 150px;
  150. border: 1px solid #3a75f5;
  151. background-color: #fff;
  152. float: left;
  153. color: #3a75f5;
  154. line-height: 34px;
  155. text-align: center;
  156. font-size: 14px;
  157. }
  158. .input-group {
  159. width: 300px;
  160. float: right;
  161. border-radius: 3px;
  162. .form-control{
  163. border-radius: 3px;
  164. height: 34px;
  165. }
  166. .input-group-btn .search{
  167. background: #3a75f5;
  168. color: #fff;
  169. height: 34px;
  170. border-radius: 3px;
  171. padding: 3px 24px;
  172. }
  173. }
  174. }
  175. .component-list table {
  176. margin-top: 10px;
  177. width: 970px;
  178. border: 1px solid #e8e8e8;
  179. }
  180. .component-list table>thead {
  181. height: 40px;
  182. }
  183. .component-list table>thead>th {
  184. text-align: center;
  185. }
  186. .component-list table tbody tr{
  187. text-align: center;
  188. height: 60px;
  189. }
  190. .component-list table tbody tr:hover{
  191. background-color: #f6f9ff;
  192. }
  193. .component-list .table>tbody>tr>td{
  194. vertical-align: middle;
  195. border-top: #e8e8e8 1px solid;
  196. }
  197. .component-list table tbody tr td a{
  198. color: #333;
  199. font-size: 14px;
  200. &:hover{
  201. color: #5078cb;
  202. }
  203. }
  204. .component-list .btn-default {
  205. color: #214797;
  206. font-size: 12px;
  207. line-height: 12px;
  208. height: 30px;
  209. }
  210. .component-list .disabledbtn {
  211. color: #A0A0A0;
  212. }
  213. .component-list .applay {
  214. color: #3a75f5;
  215. font-size: 12px;
  216. line-height: 12px;
  217. height: 30px;
  218. width: 80px;
  219. padding: 0;
  220. border: 1px solid #3a75f5;
  221. border-radius: 0;
  222. }
  223. .component-list td.text-center{
  224. padding: 30px 0;
  225. font-size: 20px;
  226. line-height: 40px;
  227. }
  228. .bgf7{
  229. height: 40px;
  230. th{
  231. background: #f7f7f7;
  232. border-bottom: none !important;
  233. font-size: 14px;
  234. text-align: center;
  235. color: #333;
  236. vertical-align: middle;
  237. }
  238. }
  239. .component-list .empty{
  240. overflow: hidden;
  241. text-align: center;
  242. margin: 0 auto;
  243. }
  244. .component-list .empty-img{
  245. float: left;
  246. margin-left: 335px;
  247. }
  248. .component-list .empty-info{
  249. float: left;
  250. line-height: 10px;
  251. width: 143px;
  252. margin-top: 30px;
  253. }
  254. .empty-info .grey{
  255. color: #999;
  256. font-size: 14px;
  257. }
  258. .component-list .empty-info a{
  259. font-size: 14px;
  260. color: #5078cb;
  261. }
  262. .component-list .empty-info i{
  263. font-size: 14px;
  264. color: #5078cb;
  265. }
  266. </style>