details.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <div class="details_info">
  3. <div class="container">
  4. <div class="crumbs">
  5. <div class="container">
  6. <div class="menu-com row">
  7. <div class="menu-title col-md-12">
  8. <a href="/">首页 ></a>
  9. <a href="/supplier">供应商资源 ></a>
  10. <a :href="'/supplier/' + uuid">供应商物料库 ></a>
  11. <span>物料详情</span>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="top">
  17. <div class="img">
  18. <img :src="detail.cmpImg || '/images/store/common/default.png'">
  19. </div>
  20. <div class="right">
  21. <h4 v-text="detail.cmpCode">3</h4>
  22. <ul class="list-unstyled">
  23. <li class="item">
  24. <span>类目(名称)</span>
  25. <p v-if="detail.standard === 1" v-text="detail.kind ? spliceString(detail.kind, 135) : '暂无信息'">1</p>
  26. <p v-if="detail.standard !== 1" v-text="detail.prodName ? spliceString(detail.prodName, 135) : '暂无信息'">1</p>
  27. </li>
  28. <li class="item">
  29. <span>品牌</span>
  30. <p v-text="detail.standard !== 1 ? detail.brand : detail.pbranden">2</p>
  31. </li>
  32. <li class="item">
  33. <span>单位</span>
  34. <p v-text="detail.unit ? detail.unit : 'PCS'">32</p>
  35. </li>
  36. <li class="item">
  37. <span>规格</span>
  38. <p v-text="detail.spec ? detail.spec : '暂无信息'">32</p>
  39. </li>
  40. </ul>
  41. <a @click="immediatelyClick">立即询价</a>
  42. </div>
  43. </div>
  44. <div class="detail">
  45. <div class="info_title">
  46. <p>产品参数<span>(仅供参考,以实际产品为准)</span></p> <a v-if="detail.cmpUuId && cmpInfo.properties && cmpInfo.properties.length > 6" @click="hasDown = !hasDown">{{hasDown ? '更多' : '收起'}} <i class="el-icon-arrow-down" v-if="hasDown"></i> <i v-if="!hasDown" class="el-icon-arrow-up"></i></a>
  47. </div>
  48. <div class="empty" v-if="!detail.cmpUuId || (cmpInfo.properties && cmpInfo.properties.length === 0)">
  49. <img src="/images/supplier/icon/empty.png">
  50. <div class="info">
  51. <p>产品暂无参数</p>
  52. <a href="javascript:history.go(-1)"><i class="fa fa-reply" style="margin-right:5px;"></i>返回上一页</a>
  53. </div>
  54. </div>
  55. <ul class="list-unstyled" :style="hasDown ? height300 : heightAuto">
  56. <li v-if="detail.cmpUuId" v-for="item in cmpInfo.properties"><span v-text="item.property.labelCn"></span><span v-text="item.value ? item.value : '-'"></span></li>
  57. </ul>
  58. </div>
  59. </div>
  60. <el-dialog
  61. title="我要询价"
  62. :visible.sync="hasDialog ">
  63. <div class="form_dialog">
  64. <ul class="list-inline">
  65. <li class="form-item">
  66. <span>型号:</span>
  67. <p v-text="detail.cmpCode ? spliceString(detail.cmpCode, 90) : '-'">3</p>
  68. </li>
  69. <li class="form-item">
  70. <span>类目:</span>
  71. <p v-if="detail.standard === 1" v-text="detail.kind ? spliceString(detail.kind, 90) : '-'">1</p>
  72. <p v-if="detail.standard !== 1" v-text="detail.prodName ? spliceString(detail.prodName, 90) : '-'">1</p>
  73. </li>
  74. <li class="form-item">
  75. <span>品牌:</span>
  76. <p v-text="detail.standard !== 1 ? spliceString(detail.brand, 90) : spliceString(detail.pbranden, 90)">2</p>
  77. </li>
  78. <li class="form-item">
  79. <span>规格:</span>
  80. <p v-text="detail.spec ? spliceString(detail.spec, 90) : '-'">3</p>
  81. </li>
  82. <li class="form-item">
  83. <span><i>*</i>截止日期:</span>
  84. <el-date-picker
  85. :class="{'error': !validObj.deadline}"
  86. v-model="applyObj.deadline"
  87. type="date"
  88. :picker-options="pickerOptions"
  89. @change="setDeadLineValid"
  90. :editable="false"
  91. :clearable="true"
  92. size="mini">
  93. </el-date-picker>
  94. </li>
  95. <li class="form-item">
  96. <span>封装:</span>
  97. <input type="text" class="form-control" v-model="applyObj.encapsulation"/>
  98. </li>
  99. <li class="form-item">
  100. <span>单价预算:</span>
  101. <select v-model="applyObj.currency" class="form-control" style="width:40px;">
  102. <option value="RMB">¥</option>
  103. <option value="USD">$</option>
  104. </select>
  105. <input type="number" v-model="applyObj.unitPrice" class="form-control" :class="{'error': !validObj.unitPrice}"/>
  106. </li>
  107. <li class="form-item">
  108. <span>生产日期:</span>
  109. <input type="text" class="form-control" v-model="applyObj.produceDate"/>
  110. </li>
  111. <li class="form-item">
  112. <span>采购数量:</span>
  113. <input type="number" class="form-control" v-model="applyObj.amount" :class="{'error': !validObj.amount}"/>
  114. </li>
  115. </ul>
  116. </div>
  117. <span slot="footer" class="dialog-footer">
  118. <button @click="goPublish" :disabled="isClick">询价提交</button>
  119. </span>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script>
  124. import {spliceStr, formatDate} from '~utils/baseUtils.js'
  125. export default {
  126. name: 'DetailsView',
  127. data () {
  128. return {
  129. uuid: this.$route.params.uuid,
  130. isClick: false,
  131. hasDown: true,
  132. height300: {
  133. maxHeight: '204px'
  134. },
  135. heightAuto: {
  136. height: 'auto'
  137. },
  138. applyObj: {
  139. unitPrice: '',
  140. currency: 'RMB',
  141. encapsulation: '',
  142. produceDate: '',
  143. amount: '',
  144. deadline: ''
  145. },
  146. validObj: {
  147. unitPrice: true,
  148. amount: true,
  149. deadline: true
  150. },
  151. pickerOptions: {
  152. disabledDate (time) {
  153. // 大于等于今天 小于三个月后
  154. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
  155. }
  156. },
  157. hasDialog: false,
  158. searchCode: ''
  159. }
  160. },
  161. computed: {
  162. detail () {
  163. return this.$store.state.supplier.detail.detail.data
  164. },
  165. cmpInfo () {
  166. return this.$store.state.supplier.detail.cmpInfo.data
  167. },
  168. user () {
  169. return this.$store.state.option.user
  170. }
  171. },
  172. methods: {
  173. spliceString (str, length) {
  174. return spliceStr(str, length)
  175. },
  176. // 弹出询价界面
  177. immediatelyClick () {
  178. if (!this.user.logged) {
  179. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  180. } else {
  181. this.hasDialog = true
  182. }
  183. },
  184. // 时间格式化
  185. setDeadLineValid: function () {
  186. this.applyObj.deadline = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
  187. this.validObj.deadline = true
  188. },
  189. // 检查单价预算
  190. checkUnitPrice () {
  191. this.validObj.unitPrice = this.applyObj.unitPrice === '' ? true : this.applyObj.unitPrice > 0 && this.applyObj.unitPrice < 100000000
  192. if (!this.validObj.unitPrice && this.applyObj.unitPrice <= 0) {
  193. this.$message.error('单价必须是大于0的数字')
  194. }
  195. return this.validObj.unitPrice
  196. },
  197. // 检查采购数量
  198. checkAmount () {
  199. this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 1000000000
  200. return this.validObj.amount
  201. },
  202. // 检查时间是否有输入
  203. checkDeadline () {
  204. this.validObj.deadline = Boolean(this.applyObj.deadline)
  205. return this.validObj.deadline
  206. },
  207. // 检查各个字段输入正常数据
  208. checkAll () {
  209. return this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
  210. },
  211. emptyForm () {
  212. for (let attr in this.applyObj) {
  213. this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
  214. }
  215. },
  216. // 请求询价信息
  217. goPublish () {
  218. let _this = this
  219. this.isClick = true
  220. setTimeout(function () {
  221. _this.isClick = false
  222. }, 1000)
  223. if (this.checkAll()) {
  224. let inquiry = {}
  225. let inquiryItem = {}
  226. if (this.user.data.enterprise) {
  227. inquiry.enUU = this.user.data.enterprise.uu
  228. }
  229. let date = new Date()
  230. let currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  231. inquiry.recorderUU = this.user.data.userUU
  232. inquiry.code = 'MALL' + date.getTime()
  233. inquiry.date = date
  234. inquiry.recorder = this.user.data.userName
  235. inquiry.endDate = this.applyObj.deadline
  236. inquiry.sourceapp = 'MALL'
  237. inquiry.amount = 1
  238. inquiryItem.userUU = this.user.data.userUU
  239. inquiryItem.source = 'MALL'
  240. inquiryItem.userName = this.user.data.userName
  241. inquiryItem.userTel = this.user.data.userTel
  242. inquiryItem.needquantity = this.applyObj.amount
  243. inquiryItem.inbrand = this.detail.brand
  244. inquiryItem.currency = currency
  245. inquiryItem.cmpCode = this.detail.cmpCode.toUpperCase()
  246. inquiryItem.unitPrice = this.applyObj.unitPrice
  247. inquiryItem.produceDate = this.applyObj.produceDate
  248. inquiryItem.date = date
  249. inquiryItem.endDate = this.applyObj.deadline
  250. inquiryItem.encapsulation = this.applyObj.encapsulation
  251. inquiryItem.spec = this.detail.spec
  252. inquiryItem.prodTitle = this.detail.prodName
  253. let inquiryItems = []
  254. inquiryItems.push(inquiryItem)
  255. inquiry.inquiryItems = inquiryItems
  256. inquiry.currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  257. this.$http.post('/inquiry/buyer/save', inquiry)
  258. .then(res => {
  259. this.$message.success('发布成功')
  260. this.hasDialog = false
  261. this.emptyForm()
  262. }, error => {
  263. console.log(error)
  264. this.$message.error('发布失败')
  265. })
  266. } else {
  267. if (!this.validObj.deadline) {
  268. this.$message.error('截止日期不能为空')
  269. } else if (!this.validObj.amount) {
  270. this.$message.error('请输入正确的数值')
  271. }
  272. }
  273. }
  274. }
  275. }
  276. </script>
  277. <style type="text/scss" lang="scss">
  278. .details_info{
  279. background: #fff;
  280. .el-dialog{
  281. width: 680px!important;
  282. .el-dialog__header{
  283. background: #4290f7;
  284. line-height: 40px;
  285. padding: 0 20px 0;
  286. .el-dialog__title{
  287. color:#fff;
  288. }
  289. .el-dialog__headerbtn:hover .el-dialog__close, .el-dialog__headerbtn:focus .el-dialog__close{
  290. color:#fff;
  291. }
  292. }
  293. .el-dialog__body{
  294. padding: 10px 20px;
  295. }
  296. .el-dialog__footer{
  297. text-align: center;
  298. button{
  299. display:inline-block;
  300. border:0;
  301. box-shadow: none;
  302. background: #3c7cf5;
  303. color:#fff;
  304. font-size: 14px;
  305. line-height: 30px;
  306. height:30px;
  307. padding:0 10px;
  308. border-radius:5px;
  309. }
  310. }
  311. }
  312. .form_dialog{
  313. .el-date-editor--date {
  314. width: 230px;
  315. &.error {
  316. input {
  317. border: 1px solid #f4645f !important;
  318. }
  319. }
  320. }
  321. ul{
  322. li{
  323. width:50%;
  324. font-size: 14px;
  325. color:#666;
  326. vertical-align: top;
  327. margin-bottom:15px;
  328. &.form-item {
  329. position: relative;
  330. p{
  331. margin:0;
  332. margin-left:80px;
  333. word-break: break-all;
  334. word-wrap: break-word;
  335. }
  336. span {
  337. float:left;
  338. width: 80px;
  339. text-align: right;
  340. display: inline-block;
  341. color:#3c7cf5;
  342. i {
  343. position: relative;
  344. top: 2px;
  345. right: 5px;
  346. color: #e41515;
  347. }
  348. }
  349. ul {
  350. line-height: normal;
  351. position: absolute;
  352. top: 19px;
  353. left: 79px;
  354. background: #fff;
  355. border: 1px solid #b5b5b5;
  356. z-index: 1;
  357. max-height: 120px;
  358. overflow-y: auto;
  359. overflow-x: hidden;
  360. border-radius: 3px;
  361. width: 114px;
  362. font-size: 12px;
  363. li {
  364. height: 24px;
  365. line-height: 24px;
  366. cursor: pointer;
  367. overflow: hidden;
  368. text-overflow: ellipsis;
  369. white-space: nowrap;
  370. padding: 0 5px;
  371. &:hover {
  372. background: #ddd;
  373. }
  374. }
  375. }
  376. select {
  377. width: 40px;
  378. position: absolute;
  379. height: 20px;
  380. background: url('/images/applyPurchase/select.png')no-repeat right;
  381. background-position-x: 23px;
  382. padding: 0 0 0 7px;
  383. border-radius: 0;
  384. & + input {
  385. padding-left: 45px;
  386. }
  387. }
  388. .el-input {
  389. width: 230px;
  390. }
  391. input {
  392. font-size: 14px;
  393. width: 230px;
  394. height: 20px;
  395. line-height: 20px;
  396. border-radius: 2px;
  397. padding: 0 3px;
  398. box-shadow: none;
  399. -webkit-box-shadow: none;
  400. -moz-box-shadow: none;
  401. &.error {
  402. border-color: #f4645f!important;
  403. }
  404. }
  405. }
  406. }
  407. }
  408. }
  409. .crumbs{
  410. background: #fff;
  411. .menu-com{
  412. margin: 0;
  413. .menu-title{
  414. line-height: 40px;
  415. font-size: 14px;
  416. padding-left: 0;
  417. margin:0;
  418. a{
  419. color: #5078cb;
  420. font-size: 14px;
  421. }
  422. }
  423. }
  424. }
  425. .top{
  426. margin-bottom:20px;
  427. .img{
  428. float:left;
  429. width:350px;
  430. height:350px;
  431. vertical-align: top;
  432. padding:36px;
  433. border:1px solid #bababa;
  434. img{
  435. width:100%;
  436. height:100%;
  437. }
  438. }
  439. .right{
  440. position:relative;
  441. height:350px;
  442. margin-left:370px;
  443. h4{
  444. width:800px;
  445. font-size: 25px;
  446. line-height: 25px;
  447. font-weight: bold;
  448. overflow: hidden;
  449. text-overflow: ellipsis;
  450. white-space:nowrap;
  451. border-bottom:1px solid #3c7cf5;
  452. margin:0;
  453. padding-bottom:20px;
  454. }
  455. a{
  456. display:inline-block;
  457. position:absolute;
  458. bottom:0;
  459. left: 0;
  460. background: #3c7cf5;
  461. color:#fff;
  462. font-size: 14px;
  463. line-height: 30px;
  464. height:30px;
  465. padding:0 10px;
  466. border-radius:5px;
  467. }
  468. ul{
  469. padding-top:35px;
  470. li{
  471. margin-bottom:25px;
  472. span{
  473. display:inline-block;
  474. width:70px;
  475. float:left;
  476. color:#3c7cf5;
  477. vertical-align: top;
  478. text-align: right;
  479. }
  480. p{
  481. width:365px;
  482. font-size: 14px;
  483. color:#333;
  484. margin:0;
  485. margin-left:90px;
  486. word-wrap: break-word;
  487. word-break: normal;
  488. }
  489. }
  490. }
  491. }
  492. }
  493. .detail{
  494. margin-bottom:90px;
  495. border:1px solid #e5e5e5;
  496. .empty {
  497. padding:75px 0;
  498. text-align: center;
  499. img {
  500. vertical-align: top;
  501. margin-right: 15px;
  502. }
  503. .info {
  504. display: inline-block;
  505. padding-top: 10px;
  506. }
  507. }
  508. .info_title{
  509. position:relative;
  510. line-height: 34px;
  511. font-weight: bold;
  512. color:#fff;
  513. background: #3c7cf5;
  514. padding-left:15px;
  515. text-align: left;
  516. p{
  517. font-size: 16px;
  518. margin:0;
  519. span{
  520. font-size: 12px;
  521. }
  522. }
  523. a{
  524. position:absolute;
  525. top:0;
  526. right:20px;
  527. color:#fff;
  528. }
  529. }
  530. ul{
  531. margin-left:0;
  532. overflow: hidden;
  533. li{
  534. line-height: 34px;
  535. text-align: center;
  536. overflow: hidden;
  537. > span{
  538. display:inline-block;
  539. width:50%;
  540. }
  541. &:nth-child(odd){
  542. background: #fff;
  543. }
  544. &:nth-child(even){
  545. background: #f5f6f8;
  546. }
  547. &.empty{
  548. padding: 100px 0;
  549. font-size: 24px;
  550. }
  551. }
  552. }
  553. }
  554. }
  555. </style>