ComponentDetail.vue 16 KB

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