ComponentDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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="list.description">
  40. {{[list.description, showMoreDesc] | descriptionFilter}}
  41. <span @click="showMoreDesc = !showMoreDesc" v-if="list.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="!list.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 :title="prop.value&&prop.value.length > 25 ? switchParams(prop.value, 0): ''">{{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. switchParams: function (str, index) {
  197. let tmp = ''
  198. if (str.length > index + 25) {
  199. tmp += str.substring(index, index + 25)
  200. tmp += '\n' + this.switchParams(str, index + 25)
  201. } else {
  202. tmp += str.substring(index, str.length - 1)
  203. }
  204. return tmp
  205. }
  206. // getRealLen: function (str) {
  207. // let len = 0
  208. // for (let i = 0; i < str.length; i++) {
  209. // if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
  210. // len += 2
  211. // } else {
  212. // len++
  213. // }
  214. // }
  215. // return len
  216. // }
  217. }
  218. }
  219. </script>
  220. <style scoped>
  221. .header-text {
  222. text-align: center;
  223. font-size: 20px;
  224. color: #008B00;
  225. margin-top: 0;
  226. }
  227. .focus button.focus-btn a{
  228. color: #fff;
  229. width: 100%;
  230. height: 100%;
  231. display: inline-block;
  232. }
  233. .focus button.focus-btn{
  234. width: 138px;
  235. height: 36px;
  236. line-height: 36px;
  237. padding: 0;
  238. }
  239. .componentDetail .el-dialog__wrapper .focus-btn a{
  240. color: #fff;
  241. }
  242. .componentDetail .container {
  243. width: 1190px;
  244. padding: 0;
  245. }
  246. .detail{
  247. margin-bottom: 36px;
  248. }
  249. .componentDetail .container .component-img {
  250. width: 260px;
  251. height: 260px;
  252. display: table-cell;
  253. border:1px solid #ccc;
  254. text-align: center;
  255. vertical-align: middle;
  256. }
  257. .componentDetail .container .component-img a {
  258. display: table-cell;
  259. width: 258px;
  260. height: 258px;
  261. text-align: center;
  262. vertical-align: middle;
  263. }
  264. .componentDetail .container .component-img img {
  265. max-width: 258px;
  266. max-height: 258px;
  267. }
  268. .componentDetail .blue {
  269. color: #214797;
  270. }
  271. .componentDetail .container .component-message {
  272. width: 910px;
  273. display: table-cell;
  274. padding-left: 20px;
  275. margin-left: 10px;
  276. }
  277. .componentDetail .container .component-message .message-code {
  278. font-size: 24px;
  279. color: rgb(50,50,50);
  280. font-weight: 700;
  281. line-height: 40px;
  282. }
  283. .componentDetail .container .component-message .hr-grey {
  284. height: 1px;
  285. width: 100%;
  286. background-color: #ccc;
  287. }
  288. .componentDetail .container .component-message .row {
  289. margin: 18px 0 0 0;
  290. position: relative;
  291. }
  292. .componentDetail .container .component-message .message-item {
  293. float:left;
  294. min-width: 60px;
  295. text-align: justify;
  296. text-align-last: justify;
  297. font-size: 14px;
  298. }
  299. .componentDetail .container .component-message .colon {
  300. float:left;
  301. margin: 0 10px;
  302. }
  303. .componentDetail .container .component-message .message-body {
  304. float: left;
  305. font-size: 14px;
  306. overflow: hidden;
  307. text-overflow: ellipsis;
  308. white-space: nowrap;
  309. width: 93px;
  310. }
  311. .componentDetail .container .component-message .message-body >img {
  312. cursor: pointer;
  313. }
  314. .componentDetail .container .component-message .description {
  315. position: relative;
  316. }
  317. .componentDetail .container .component-message .description >span {
  318. cursor: pointer;
  319. display: inline-block;
  320. float: right;
  321. position: relative;
  322. bottom: 2px;
  323. }
  324. .componentDetail .container .component-message .description >span >img {
  325. vertical-align: middle;
  326. }
  327. .componentDetail .container .component-message .description >span >span {
  328. color: #5078cb;
  329. vertical-align: middle;
  330. }
  331. .componentDetail .container .component-message .description.more-description {
  332. padding: 13px 13px 30px 13px;
  333. border: 1px solid #e5e5e5;
  334. border-top: none;
  335. position: absolute;
  336. right: 94px;
  337. width: 508px;
  338. background: #f5f6f8;
  339. z-index: 1;
  340. line-height: 22.7px;
  341. }
  342. .componentDetail .container .component-message .description.more-description >span {
  343. position: absolute;
  344. right: 10px;
  345. bottom: 7px;
  346. }
  347. .componentDetail .container .component-message .message-body a {
  348. color: #337ab7;
  349. }
  350. .componentDetail .container .component-message .message-body:hover a{
  351. color: #23527c;
  352. }
  353. .componentDetail .message-item:first-child {
  354. padding-left: 0;
  355. }
  356. .componentDetail .container .storeIns{
  357. margin-top: 20px;
  358. width: 1190px;
  359. height: 48px;
  360. line-height: 48px;
  361. }
  362. .componentDetail .container .storeIns .sign {
  363. display: table-cell;
  364. vertical-align: middle;
  365. font-size: 14px;
  366. }
  367. .componentDetail .container .storeIns .storeInList {
  368. display: table-cell;
  369. }
  370. .componentDetail .container .storeIn {
  371. width: 98px;
  372. height: 49px;
  373. line-height: 30px;
  374. float: left;
  375. border: 1px solid #ccc;
  376. text-align: center;
  377. vertical-align: middle;
  378. margin-right: 15px;
  379. cursor: pointer;
  380. }
  381. .componentDetail .container .storeIn-active {
  382. width: 98px;
  383. float: left;
  384. border: 1px solid #5078cb;
  385. text-align: center;
  386. vertical-align: middle;
  387. margin-right: 15px;
  388. cursor: pointer;
  389. }
  390. .componentDetail .container .storeIn a,.componentDetail .storeIn-active a {
  391. display: table-cell;
  392. height: 46px;
  393. width: 98px;
  394. text-align: center;
  395. vertical-align: middle;
  396. }
  397. .componentDetail .storeIn a>img,.componentDetail .storeIn-active a>img {
  398. max-width: 95px;
  399. max-height: 46px;
  400. }
  401. .componentDetail .btn-store {
  402. width: 82px;
  403. height: 30px;
  404. color: #fff;
  405. background: #5078cb;
  406. border: 1px solid #5078cb;
  407. position: relative;
  408. top: 27px;
  409. }
  410. .product-params {
  411. width: 100%;
  412. }
  413. .product-params .product-params-header {
  414. height: 34px;
  415. line-height: 34px;
  416. background: #d8e5ff;
  417. }
  418. .product-params p.product-params-header {
  419. margin-bottom: 0;
  420. padding-left: 9px;
  421. font-weight: bold;
  422. }
  423. .product-params p.product-params-header span {
  424. font-size: 12px;
  425. }
  426. .product-params p.product-params-header .show-more-param {
  427. float: right;
  428. font-weight: normal;
  429. font-size: 14px;
  430. margin-right: 16px;
  431. cursor: pointer;
  432. height: 34px;
  433. }
  434. .product-params >ul {
  435. background: #fff;
  436. margin-bottom: 37px;
  437. }
  438. .product-params >ul li {
  439. display: inline-block;
  440. border-bottom: 1px solid #e5e5e5;
  441. float: left;
  442. }
  443. .product-params >ul li span {
  444. display: inline-block;
  445. width: 297.2px;
  446. height: 32px;
  447. line-height: 32px;
  448. text-align: center;
  449. border-right: 1px solid #e5e5e5;
  450. vertical-align: middle;
  451. overflow: hidden;
  452. text-overflow: ellipsis;
  453. white-space: nowrap;
  454. padding: 0 15px;
  455. float: left;
  456. }
  457. .product-params >ul li span:nth-child(1) {
  458. font-weight: bold;
  459. }
  460. .product-params >ul li:nth-child(odd) {
  461. border-left: 1px solid #e5e5e5;
  462. }
  463. .product-params >ul li:nth-child(4n), .product-params >ul li:nth-child(4n-1) {
  464. background: #f5f6f8;
  465. }
  466. .component-message .message-detail {
  467. display: inline-block;
  468. height: 48px;
  469. line-height: 48px;
  470. border-left: 1px solid #e5e5e5;
  471. border-bottom: 1px solid #e5e5e5;
  472. width: 300px;
  473. overflow: hidden;
  474. padding: 0 11px;
  475. vertical-align: middle;
  476. }
  477. .component-message .message-detail:nth-child(even) {
  478. width: 596px;
  479. border-right: 1px solid #e5e5e5;
  480. }
  481. .component-message .message-detail:nth-child(odd) {
  482. width: 200px;
  483. }
  484. .component-message .message-detail:nth-child(1),.component-message .message-detail:nth-child(2) {
  485. border-top: 1px solid #e5e5e5;
  486. }
  487. .component-message .message-detail:nth-child(4n),.component-message .message-detail:nth-child(4n-1) {
  488. background: #f5f6f8;
  489. }
  490. .empty-param {
  491. text-align: center;
  492. padding: 20px 0;
  493. color: #999;
  494. font-size: 12px;
  495. border: 1px solid #ddd;
  496. }
  497. </style>