ComponentDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <div class="componentDetail">
  3. <div class="container">
  4. <!--<div class="menu">
  5. <component-menu/>
  6. </div>-->
  7. <div class="detail">
  8. <div class="component-img">
  9. <img :src="list.img?list.img:list.brand&&list.brand.logoUrl?list.brand.logoUrl:'/images/component/default.png'"/>
  10. </div>
  11. <div class="component-message">
  12. <div class="message-code">
  13. <span>{{list.code}}</span>
  14. </div>
  15. <div class="hr-grey"></div>
  16. <div class="row">
  17. <div class="message-detail" v-if="list.brand">
  18. <div class="message-item">品牌</div>
  19. <div class="colon">:</div>
  20. <div :title="list.brand.nameCn"><a class="message-body blue" target="_blank" :href="`/product/brand/${list.brand.uuid}`">{{list.brand.nameCn}}</a></div>
  21. </div>
  22. <div class="message-detail">
  23. <div class="message-item">产品生命周期</div>
  24. <div class="colon">:</div>
  25. <div class="message-body">
  26. {{list.lifecycle | lifecycleFilter}}
  27. </div>
  28. </div>
  29. <div class="message-detail">
  30. <div class="message-item">总库存量</div>
  31. <div class="colon">:</div>
  32. <div class="message-body">{{list.reserve || '暂无库存'}}</div>
  33. </div>
  34. <div class="message-detail">
  35. <div class="message-item">产品描述</div>
  36. <div class="colon" style="margin-right: 17px">:</div>
  37. <div class="description"
  38. :class="{'more-description':showMoreDesc}"
  39. v-if="store.description">
  40. {{[store.description, showMoreDesc] | descriptionFilter}}
  41. <span @click="showMoreDesc = !showMoreDesc" v-if="store.description.length > 30">
  42. <img :src="!showMoreDesc?'/images/component/circle-arrow-down.png':'/images/component/circle-arrow-up.png'" alt="">
  43. <!--<i class="iconfont" :class="{'icon-shouqi':showMoreDesc,'icon-shouqi1':!showMoreDesc}"></i>-->
  44. <span v-text="showMoreDesc ? '收起' : '展开'"></span>
  45. </span>
  46. </div>
  47. <div class="description" v-if="!store.description">-</div>
  48. </div>
  49. <div class="message-detail">
  50. <div class="message-item">规格书</div>
  51. <div class="colon">:</div>
  52. <div class="message-body">
  53. <img src="/images/all/pdf.png" alt="" @click="toAttach(list.attach)" v-if="list.attach">
  54. <span v-if="!list.attach">暂无</span>
  55. </div>
  56. </div>
  57. <div class="message-detail"></div>
  58. <div class="form-group">
  59. <button type="text" v-if="!collectList" @click="collect(list.id)" class="btn btn-default btn-store">加入收藏</button>
  60. <button class="btn btn-default btn-store" v-if="collectList" disabled="disabled">已收藏</button>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="product-params">
  66. <p class="product-params-header">产品参数<span>(仅供参考,以实际产品为准)</span>
  67. <span v-if="list.properties && list.properties.length > 6" class="show-more-param" @click="showMoreParam = !showMoreParam"><span>{{showMoreParam?'收起':'更多'}}</span><i class="fa" :class="{'fa fa-angle-down': !showMoreParam,'fa fa-angle-up': showMoreParam }"></i></span>
  68. </p>
  69. <ul v-if="list.properties && (list.properties.length > 1 || (list.properties.length == 1 && list.properties[0].value))">
  70. <li v-for="prop in properties">
  71. <span>{{prop.property.labelCn || '-'}}</span>
  72. <span>{{prop.value || '-'}}</span>
  73. </li>
  74. <li v-if="!isEven(properties.length)">
  75. <span>-</span>
  76. <span>-</span>
  77. </li>
  78. </ul>
  79. <div class="empty-param" v-else>
  80. <img src="/images/all/empty-cart.png" alt="">该产品暂无参数
  81. </div>
  82. </div>
  83. </div>
  84. <!--关注-->
  85. <el-dialog
  86. :visible.sync="dialogVisible"
  87. size="tiny"
  88. >
  89. <h3 class="header-text">收藏成功!</h3>
  90. <div class="focus modal-body">
  91. <button type="button" @click="dialogVisible = false" class="btn" style="margin-left:25px;">关&nbsp;&nbsp;闭</button>
  92. <button type="button" class="focus-btn btn btn btn-info" style="margin-left:35px;">
  93. <a href="/user#/home/componentcol" target="_blank">查看我的产品收藏</a>
  94. </button>
  95. </div>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script>
  100. // import ComponentMenu from '~components/product/component/componentMenu.vue'
  101. export default {
  102. name: 'ComponentDetail',
  103. data () {
  104. return {
  105. dialogVisible: false,
  106. showMoreDesc: false,
  107. showMoreParam: false
  108. }
  109. },
  110. computed: {
  111. lists () {
  112. return this.$store.state.componentDetail.detail
  113. },
  114. list () {
  115. return this.lists.data
  116. },
  117. properties () {
  118. return this.list.properties && this.list.properties.length > 6 ? this.showMoreParam ? this.list.properties : this.list.properties.slice(0, 6) : this.list.properties
  119. },
  120. user () {
  121. return this.$store.state.option.user
  122. },
  123. colList () {
  124. return this.$store.state.product.common.collectList.data
  125. },
  126. collectList () {
  127. let id = this.lists.data.id
  128. let store = this.colList
  129. if (store) {
  130. for (let i = 0; i < store.length; i++) {
  131. if (store[i].componentid === id) {
  132. return true
  133. }
  134. }
  135. } else {
  136. return false
  137. }
  138. },
  139. stores () {
  140. return this.$store.state.componentStore.store.data
  141. },
  142. store () {
  143. return this.stores[0] ? this.stores[0] : []
  144. }
  145. },
  146. // components: {
  147. // ComponentMenu
  148. // },
  149. filters: {
  150. descriptionFilter: function ([str, type]) {
  151. return !type ? str.length > 30 ? str.substring(0, 30) : str : str
  152. },
  153. lifecycleFilter: function (code) {
  154. if (code === 815) {
  155. return '正常'
  156. } else if (code === 816) {
  157. return '即将停产'
  158. } else if (code === 817) {
  159. return '停产'
  160. } else if (code === 818) {
  161. return '新品'
  162. } else {
  163. return '-'
  164. }
  165. }
  166. },
  167. methods: {
  168. isEven: function (num) {
  169. return num % 2 === 0
  170. },
  171. collect (id) {
  172. if (this.user.logged) {
  173. this.dialogVisible = true
  174. let kind = 2
  175. this.$store.dispatch('product/saveEntity', {componentid: id, kind: kind})
  176. // this.collectList = true
  177. } else {
  178. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  179. if (response.data) {
  180. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  181. }
  182. })
  183. }
  184. },
  185. toAttach: function (url) {
  186. if (url === '1') {
  187. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  188. if (response.data) {
  189. window.location.href = response.data.content + '&baseUrl=' + encodeURIComponent(window.location.protocol + '//' + window.location.host + response.data.baseUrl)
  190. }
  191. })
  192. } else {
  193. window.open(url)
  194. }
  195. }
  196. }
  197. }
  198. </script>
  199. <style scoped>
  200. .header-text {
  201. text-align: center;
  202. font-size: 20px;
  203. color: #008B00;
  204. margin-top: 0;
  205. }
  206. .focus button.focus-btn a{
  207. color: #fff;
  208. width: 100%;
  209. height: 100%;
  210. display: inline-block;
  211. }
  212. .focus button.focus-btn{
  213. width: 138px;
  214. height: 36px;
  215. line-height: 36px;
  216. padding: 0;
  217. }
  218. .componentDetail .el-dialog__wrapper .focus-btn a{
  219. color: #fff;
  220. }
  221. .componentDetail .container {
  222. width: 1190px;
  223. padding: 0;
  224. }
  225. .detail{
  226. margin-bottom: 36px;
  227. }
  228. .componentDetail .container .component-img {
  229. width: 260px;
  230. height: 260px;
  231. display: table-cell;
  232. border:1px solid #ccc;
  233. text-align: center;
  234. vertical-align: middle;
  235. }
  236. .componentDetail .container .component-img a {
  237. display: table-cell;
  238. width: 258px;
  239. height: 258px;
  240. text-align: center;
  241. vertical-align: middle;
  242. }
  243. .componentDetail .container .component-img img {
  244. max-width: 258px;
  245. max-height: 258px;
  246. }
  247. .componentDetail .blue {
  248. color: #214797;
  249. }
  250. .componentDetail .container .component-message {
  251. width: 910px;
  252. display: table-cell;
  253. padding-left: 20px;
  254. margin-left: 10px;
  255. }
  256. .componentDetail .container .component-message .message-code {
  257. font-size: 24px;
  258. color: rgb(50,50,50);
  259. font-weight: 700;
  260. line-height: 40px;
  261. }
  262. .componentDetail .container .component-message .hr-grey {
  263. height: 1px;
  264. width: 100%;
  265. background-color: #ccc;
  266. }
  267. .componentDetail .container .component-message .row {
  268. margin: 18px 0 0 0;
  269. position: relative;
  270. }
  271. .componentDetail .container .component-message .message-item {
  272. float:left;
  273. min-width: 60px;
  274. text-align: justify;
  275. text-align-last: justify;
  276. font-size: 14px;
  277. }
  278. .componentDetail .container .component-message .colon {
  279. float:left;
  280. margin: 0 10px;
  281. }
  282. .componentDetail .container .component-message .message-body {
  283. float: left;
  284. font-size: 14px;
  285. overflow: hidden;
  286. text-overflow: ellipsis;
  287. white-space: nowrap;
  288. width: 93px;
  289. }
  290. .componentDetail .container .component-message .message-body >img {
  291. cursor: pointer;
  292. }
  293. .componentDetail .container .component-message .description {
  294. position: relative;
  295. }
  296. .componentDetail .container .component-message .description >span {
  297. cursor: pointer;
  298. display: inline-block;
  299. float: right;
  300. position: relative;
  301. bottom: 2px;
  302. }
  303. .componentDetail .container .component-message .description >span >img {
  304. vertical-align: middle;
  305. }
  306. .componentDetail .container .component-message .description >span >span {
  307. color: #5078cb;
  308. vertical-align: middle;
  309. }
  310. .componentDetail .container .component-message .description.more-description {
  311. padding: 13px 13px 30px 13px;
  312. border: 1px solid #e5e5e5;
  313. border-top: none;
  314. position: absolute;
  315. right: 94px;
  316. width: 508px;
  317. background: #f5f6f8;
  318. z-index: 1;
  319. line-height: 22.7px;
  320. }
  321. .componentDetail .container .component-message .description.more-description >span {
  322. position: absolute;
  323. right: 10px;
  324. bottom: 7px;
  325. }
  326. .componentDetail .container .component-message .message-body a {
  327. color: #337ab7;
  328. }
  329. .componentDetail .container .component-message .message-body:hover a{
  330. color: #23527c;
  331. }
  332. .componentDetail .message-item:first-child {
  333. padding-left: 0;
  334. }
  335. .componentDetail .container .storeIns{
  336. margin-top: 20px;
  337. width: 1190px;
  338. height: 48px;
  339. line-height: 48px;
  340. }
  341. .componentDetail .container .storeIns .sign {
  342. display: table-cell;
  343. vertical-align: middle;
  344. font-size: 14px;
  345. }
  346. .componentDetail .container .storeIns .storeInList {
  347. display: table-cell;
  348. }
  349. .componentDetail .container .storeIn {
  350. width: 98px;
  351. height: 49px;
  352. line-height: 30px;
  353. float: left;
  354. border: 1px solid #ccc;
  355. text-align: center;
  356. vertical-align: middle;
  357. margin-right: 15px;
  358. cursor: pointer;
  359. }
  360. .componentDetail .container .storeIn-active {
  361. width: 98px;
  362. float: left;
  363. border: 1px solid #5078cb;
  364. text-align: center;
  365. vertical-align: middle;
  366. margin-right: 15px;
  367. cursor: pointer;
  368. }
  369. .componentDetail .container .storeIn a,.componentDetail .storeIn-active a {
  370. display: table-cell;
  371. height: 46px;
  372. width: 98px;
  373. text-align: center;
  374. vertical-align: middle;
  375. }
  376. .componentDetail .storeIn a>img,.componentDetail .storeIn-active a>img {
  377. max-width: 95px;
  378. max-height: 46px;
  379. }
  380. .componentDetail .btn-store {
  381. width: 82px;
  382. height: 30px;
  383. color: #fff;
  384. background: #5078cb;
  385. border: 1px solid #5078cb;
  386. position: relative;
  387. top: 27px;
  388. }
  389. .product-params {
  390. width: 100%;
  391. }
  392. .product-params .product-params-header {
  393. height: 34px;
  394. line-height: 34px;
  395. background: #d8e5ff;
  396. }
  397. .product-params p.product-params-header {
  398. margin-bottom: 0;
  399. padding-left: 9px;
  400. font-weight: bold;
  401. }
  402. .product-params p.product-params-header span {
  403. font-size: 12px;
  404. }
  405. .product-params p.product-params-header .show-more-param {
  406. float: right;
  407. font-weight: normal;
  408. font-size: 14px;
  409. margin-right: 16px;
  410. cursor: pointer;
  411. height: 34px;
  412. }
  413. .product-params >ul {
  414. background: #fff;
  415. margin-bottom: 37px;
  416. }
  417. .product-params >ul li {
  418. display: inline-block;
  419. border-bottom: 1px solid #e5e5e5;
  420. float: left;
  421. }
  422. .product-params >ul li span {
  423. display: inline-block;
  424. width: 297.2px;
  425. height: 32px;
  426. line-height: 32px;
  427. text-align: center;
  428. border-right: 1px solid #e5e5e5;
  429. vertical-align: middle;
  430. overflow: hidden;
  431. text-overflow: ellipsis;
  432. white-space: nowrap;
  433. }
  434. .product-params >ul li:nth-child(odd) {
  435. border-left: 1px solid #e5e5e5;
  436. }
  437. .product-params >ul li:nth-child(4n), .product-params >ul li:nth-child(4n-1) {
  438. background: #f5f6f8;
  439. }
  440. .component-message .message-detail {
  441. display: inline-block;
  442. height: 48px;
  443. line-height: 48px;
  444. border-left: 1px solid #e5e5e5;
  445. border-bottom: 1px solid #e5e5e5;
  446. width: 300px;
  447. overflow: hidden;
  448. padding: 0 11px;
  449. vertical-align: middle;
  450. }
  451. .component-message .message-detail:nth-child(even) {
  452. width: 596px;
  453. border-right: 1px solid #e5e5e5;
  454. }
  455. .component-message .message-detail:nth-child(odd) {
  456. width: 200px;
  457. }
  458. .component-message .message-detail:nth-child(1),.component-message .message-detail:nth-child(2) {
  459. border-top: 1px solid #e5e5e5;
  460. }
  461. .component-message .message-detail:nth-child(4n),.component-message .message-detail:nth-child(4n-1) {
  462. background: #f5f6f8;
  463. }
  464. .empty-param {
  465. text-align: center;
  466. padding: 20px 0;
  467. color: #999;
  468. font-size: 12px;
  469. border: 1px solid #ddd;
  470. }
  471. </style>