ComponentDetail.vue 15 KB

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