BrandList.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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="`/store/productDetail/${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. export default {
  55. name: 'BrandComponent',
  56. data () {
  57. return {
  58. pageParams: {
  59. page: 1,
  60. count: 10,
  61. filter: {}
  62. },
  63. searchCode: ''
  64. }
  65. },
  66. props: ['kindid'],
  67. components: {
  68. Page
  69. },
  70. computed: {
  71. lists () {
  72. return this.$store.state.brandComponent.component
  73. },
  74. list () {
  75. return this.lists.data
  76. },
  77. brand () {
  78. return this.$store.state.brandDetail.detail.data
  79. }
  80. },
  81. methods: {
  82. goodsSearch (keyword) {
  83. this.pageParams.page = 1
  84. this.pageParams.filter.code = keyword
  85. this.pageCmpGoods(this.pageParams)
  86. },
  87. handlerCurrentNode () {
  88. this.searchCode = ''
  89. this.pageParams.page = 1
  90. this.pageCmpGoods(this.pageParams)
  91. },
  92. async pageCmpGoods (params) {
  93. // pageCmpGoods (params) {
  94. // params.filter.brandid = this.brand.id
  95. let param = {
  96. branduuid: this.brand.uuid,
  97. count: this.pageParams.count,
  98. page: this.pageParams.page,
  99. kindid: this.kindid,
  100. keyword: this.searchCode || null
  101. }
  102. let { data } = await this.$http.get('/api/product/goods', {params: param})
  103. this.$store.commit('brandComponent/GET_COMPONENT_SUCCESS', data)
  104. // this.$http.get('/api/product/component/list', { params }).then(response => {
  105. // this.$store.commit('brandComponent/GET_COMPONENT_SUCCESS', response)
  106. // })
  107. },
  108. handleCurrentChange (page) {
  109. this.pageParams.page = page
  110. this.pageParams.filter.brandid = this.brand.id
  111. this.pageCmpGoods(this.pageParams)
  112. },
  113. toAttach: function (url) {
  114. if (url === '1') {
  115. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  116. if (response.data) {
  117. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  118. }
  119. })
  120. } else {
  121. window.open(url)
  122. }
  123. },
  124. addToCar: function (item) {
  125. this.baseUtils.buyOrCar(false, null, this, item)
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .component-list {
  132. float: left;
  133. margin-left: 20px;
  134. width: 970px;
  135. .type-list{
  136. height: 34px;
  137. width: 150px;
  138. border: 1px solid #3a75f5;
  139. background-color: #3a75f5;
  140. float: left;
  141. color: #fff;
  142. line-height: 34px;
  143. text-align: center;
  144. font-size: 14px;
  145. }
  146. .agency {
  147. height: 34px;
  148. width: 150px;
  149. border: 1px solid #3a75f5;
  150. background-color: #fff;
  151. float: left;
  152. color: #3a75f5;
  153. line-height: 34px;
  154. text-align: center;
  155. font-size: 14px;
  156. }
  157. .input-group {
  158. width: 300px;
  159. float: right;
  160. border-radius: 3px;
  161. .form-control{
  162. border-radius: 3px;
  163. height: 34px;
  164. }
  165. .input-group-btn .search{
  166. background: #3a75f5;
  167. color: #fff;
  168. height: 34px;
  169. border-radius: 3px;
  170. padding: 3px 24px;
  171. }
  172. }
  173. }
  174. .component-list table {
  175. margin-top: 10px;
  176. width: 970px;
  177. border: 1px solid #e8e8e8;
  178. }
  179. .component-list table>thead {
  180. height: 40px;
  181. }
  182. .component-list table>thead>th {
  183. text-align: center;
  184. }
  185. .component-list table tbody tr{
  186. text-align: center;
  187. height: 60px;
  188. }
  189. .component-list table tbody tr:hover{
  190. background-color: #f6f9ff;
  191. }
  192. .component-list .table>tbody>tr>td{
  193. vertical-align: middle;
  194. border-top: #e8e8e8 1px solid;
  195. }
  196. .component-list table tbody tr td a{
  197. color: #333;
  198. font-size: 14px;
  199. &:hover{
  200. color: #5078cb;
  201. }
  202. }
  203. .component-list .btn-default {
  204. color: #214797;
  205. font-size: 12px;
  206. line-height: 12px;
  207. height: 30px;
  208. }
  209. .component-list .disabledbtn {
  210. color: #A0A0A0;
  211. }
  212. .component-list .applay {
  213. color: #3a75f5;
  214. font-size: 12px;
  215. line-height: 12px;
  216. height: 30px;
  217. width: 80px;
  218. padding: 0;
  219. border: 1px solid #3a75f5;
  220. border-radius: 0;
  221. }
  222. .component-list td.text-center{
  223. padding: 30px 0;
  224. font-size: 20px;
  225. line-height: 40px;
  226. }
  227. .bgf7{
  228. height: 40px;
  229. th{
  230. background: #f7f7f7;
  231. border-bottom: none !important;
  232. font-size: 14px;
  233. text-align: center;
  234. color: #333;
  235. vertical-align: middle;
  236. }
  237. }
  238. .component-list .empty{
  239. overflow: hidden;
  240. text-align: center;
  241. margin: 0 auto;
  242. }
  243. .component-list .empty-img{
  244. float: left;
  245. margin-left: 335px;
  246. }
  247. .component-list .empty-info{
  248. float: left;
  249. line-height: 10px;
  250. width: 143px;
  251. margin-top: 30px;
  252. }
  253. .empty-info .grey{
  254. color: #999;
  255. font-size: 14px;
  256. }
  257. .component-list .empty-info a{
  258. font-size: 14px;
  259. color: #5078cb;
  260. }
  261. .component-list .empty-info i{
  262. font-size: 14px;
  263. color: #5078cb;
  264. }
  265. </style>