details.vue 16 KB

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