details.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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="hasDialog = true">立即询价</a>
  41. </div>
  42. </div>
  43. <div class="info">
  44. <div class="info_title">
  45. <p>产品参数<span>(仅供参考,以实际产品为准)</span></p> <a @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. <a type="button" @click="goPublish">询价提交</a>
  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. hasDown: true,
  129. height300: {
  130. height: '300px'
  131. },
  132. heightAuto: {
  133. height: 'auto'
  134. },
  135. applyObj: {
  136. unitPrice: '',
  137. currency: 'RMB',
  138. encapsulation: '',
  139. produceDate: '',
  140. amount: '',
  141. deadline: ''
  142. },
  143. validObj: {
  144. unitPrice: true,
  145. amount: true,
  146. deadline: true
  147. },
  148. pickerOptions: {
  149. disabledDate (time) {
  150. // 大于等于今天 小于三个月后
  151. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
  152. }
  153. },
  154. hasDialog: false,
  155. searchCode: ''
  156. }
  157. },
  158. computed: {
  159. detail () {
  160. return this.$store.state.supplier.detail.detail.data
  161. },
  162. cmpInfo () {
  163. return this.$store.state.supplier.detail.cmpInfo.data
  164. },
  165. user () {
  166. return this.$store.state.option.user
  167. }
  168. },
  169. methods: {
  170. spliceString (str, length) {
  171. return spliceStr(str, length)
  172. },
  173. // 时间格式化
  174. setDeadLineValid: function () {
  175. this.applyObj.deadline = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
  176. this.validObj.deadline = true
  177. },
  178. // 检查单价预算
  179. checkUnitPrice () {
  180. this.validObj.unitPrice = this.applyObj.unitPrice === '' ? true : this.applyObj.unitPrice > 0 && this.applyObj.unitPrice < 100000000
  181. if (!this.validObj.unitPrice && this.applyObj.unitPrice <= 0) {
  182. this.$message.error('单价必须是大于0的数字')
  183. }
  184. return this.validObj.unitPrice
  185. },
  186. // 检查采购数量
  187. checkAmount () {
  188. this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 1000000000
  189. return this.validObj.amount
  190. },
  191. // 检查时间是否有输入
  192. checkDeadline () {
  193. this.validObj.deadline = Boolean(this.applyObj.deadline)
  194. return this.validObj.deadline
  195. },
  196. // 检查各个字段输入正常数据
  197. checkAll () {
  198. return this.checkDeadline() && this.checkUnitPrice() && this.checkAmount()
  199. },
  200. emptyForm () {
  201. for (let attr in this.applyObj) {
  202. this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
  203. }
  204. },
  205. // 请求询价信息
  206. goPublish () {
  207. if (this.checkAll()) {
  208. let inquiry = {}
  209. let inquiryItem = {}
  210. if (this.user.data.enterprise) {
  211. inquiry.enUU = this.user.data.enterprise.uu
  212. }
  213. let date = new Date()
  214. let currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  215. inquiry.recorderUU = this.user.data.userUU
  216. inquiry.code = 'MALL' + date.getTime()
  217. inquiry.date = date
  218. inquiry.recorder = this.user.data.userName
  219. inquiry.endDate = this.applyObj.deadline
  220. inquiry.sourceapp = 'MALL'
  221. inquiry.amount = 1
  222. inquiryItem.userUU = this.user.data.userUU
  223. inquiryItem.source = 'MALL'
  224. inquiryItem.userName = this.user.data.userName
  225. inquiryItem.userTel = this.user.data.userTel
  226. inquiryItem.needquantity = this.applyObj.amount
  227. inquiryItem.inbrand = this.detail.brand
  228. inquiryItem.currency = currency
  229. inquiryItem.cmpCode = this.detail.cmpCode.toUpperCase()
  230. inquiryItem.unitPrice = this.applyObj.unitPrice
  231. inquiryItem.produceDate = this.applyObj.produceDate
  232. inquiryItem.date = date
  233. inquiryItem.endDate = this.applyObj.deadline
  234. inquiryItem.encapsulation = this.applyObj.encapsulation
  235. inquiryItem.spec = this.detail.spec
  236. inquiryItem.prodTitle = this.detail.prodName
  237. let inquiryItems = []
  238. inquiryItems.push(inquiryItem)
  239. inquiry.inquiryItems = inquiryItems
  240. inquiry.currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  241. this.$http.post('/inquiry/buyer/save', inquiry)
  242. .then(res => {
  243. this.$message.success('发布成功')
  244. this.hasDialog = false
  245. this.emptyForm()
  246. }, error => {
  247. console.log(error)
  248. this.$message.error('发布失败')
  249. })
  250. } else {
  251. if (!this.validObj.deadline) {
  252. this.$message.error('截止日期不能为空')
  253. } else if (!this.validObj.amount) {
  254. this.$message.error('请输入正确的数值')
  255. }
  256. }
  257. }
  258. }
  259. }
  260. </script>
  261. <style type="text/scss" lang="scss">
  262. .details_info{
  263. background: #fff;
  264. .el-dialog{
  265. width: 680px!important;
  266. .el-dialog__header{
  267. background: #4290f7;
  268. line-height: 40px;
  269. padding: 0 20px 0;
  270. .el-dialog__title{
  271. color:#fff;
  272. }
  273. .el-dialog__headerbtn:hover .el-dialog__close, .el-dialog__headerbtn:focus .el-dialog__close{
  274. color:#fff;
  275. }
  276. }
  277. .el-dialog__body{
  278. padding: 10px 20px;
  279. }
  280. .el-dialog__footer{
  281. text-align: center;
  282. a{
  283. display:inline-block;
  284. background: #3c7cf5;
  285. color:#fff;
  286. font-size: 14px;
  287. line-height: 30px;
  288. height:30px;
  289. padding:0 10px;
  290. border-radius:5px;
  291. }
  292. }
  293. }
  294. .form_dialog{
  295. .el-date-editor--date {
  296. width: 230px;
  297. &.error {
  298. input {
  299. border: 1px solid #f4645f !important;
  300. }
  301. }
  302. }
  303. ul{
  304. li{
  305. width:50%;
  306. font-size: 14px;
  307. color:#666;
  308. vertical-align: top;
  309. margin-bottom:15px;
  310. &.form-item {
  311. position: relative;
  312. p{
  313. margin:0;
  314. margin-left:80px;
  315. word-break: break-all;
  316. word-wrap: break-word;
  317. }
  318. span {
  319. float:left;
  320. width: 80px;
  321. text-align: right;
  322. display: inline-block;
  323. color:#3c7cf5;
  324. i {
  325. position: relative;
  326. top: 2px;
  327. right: 5px;
  328. color: #e41515;
  329. }
  330. }
  331. ul {
  332. line-height: normal;
  333. position: absolute;
  334. top: 19px;
  335. left: 79px;
  336. background: #fff;
  337. border: 1px solid #b5b5b5;
  338. z-index: 1;
  339. max-height: 120px;
  340. overflow-y: auto;
  341. overflow-x: hidden;
  342. border-radius: 3px;
  343. width: 114px;
  344. font-size: 12px;
  345. li {
  346. height: 24px;
  347. line-height: 24px;
  348. cursor: pointer;
  349. overflow: hidden;
  350. text-overflow: ellipsis;
  351. white-space: nowrap;
  352. padding: 0 5px;
  353. &:hover {
  354. background: #ddd;
  355. }
  356. }
  357. }
  358. select {
  359. width: 40px;
  360. position: absolute;
  361. height: 20px;
  362. background: url('/images/applyPurchase/select.png')no-repeat right;
  363. background-position-x: 23px;
  364. padding: 0 0 0 7px;
  365. border-radius: 0;
  366. & + input {
  367. padding-left: 45px;
  368. }
  369. }
  370. .el-input {
  371. width: 230px;
  372. }
  373. input {
  374. font-size: 14px;
  375. width: 230px;
  376. height: 20px;
  377. line-height: 20px;
  378. border-radius: 2px;
  379. padding: 0 3px;
  380. box-shadow: none;
  381. -webkit-box-shadow: none;
  382. -moz-box-shadow: none;
  383. &.error {
  384. border-color: #f4645f!important;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. }
  391. .crumbs{
  392. background: #fff;
  393. .menu-com{
  394. margin: 0;
  395. .menu-title{
  396. line-height: 40px;
  397. font-size: 14px;
  398. padding-left: 0;
  399. margin:0;
  400. a{
  401. color: #5078cb;
  402. font-size: 14px;
  403. }
  404. }
  405. }
  406. }
  407. .top{
  408. margin-bottom:20px;
  409. .img{
  410. float:left;
  411. width:350px;
  412. height:350px;
  413. vertical-align: top;
  414. padding:36px;
  415. border:1px solid #bababa;
  416. img{
  417. width:100%;
  418. height:100%;
  419. }
  420. }
  421. .right{
  422. position:relative;
  423. height:350px;
  424. margin-left:370px;
  425. h4{
  426. width:800px;
  427. font-size: 25px;
  428. line-height: 25px;
  429. font-weight: bold;
  430. overflow: hidden;
  431. text-overflow: ellipsis;
  432. white-space:nowrap;
  433. border-bottom:1px solid #3c7cf5;
  434. margin:0;
  435. padding-bottom:20px;
  436. }
  437. a{
  438. display:inline-block;
  439. position:absolute;
  440. bottom:0;
  441. left: 0;
  442. background: #3c7cf5;
  443. color:#fff;
  444. font-size: 14px;
  445. line-height: 30px;
  446. height:30px;
  447. padding:0 10px;
  448. border-radius:5px;
  449. }
  450. ul{
  451. padding-top:35px;
  452. li{
  453. margin-bottom:25px;
  454. span{
  455. display:inline-block;
  456. width:70px;
  457. float:left;
  458. color:#3c7cf5;
  459. vertical-align: top;
  460. text-align: right;
  461. }
  462. p{
  463. width:365px;
  464. font-size: 14px;
  465. color:#333;
  466. margin:0;
  467. margin-left:90px;
  468. word-wrap: break-word;
  469. word-break: normal;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. .info{
  476. padding-bottom:90px;
  477. .empty {
  478. padding-top: 25px;
  479. text-align: center;
  480. img {
  481. vertical-align: top;
  482. margin-right: 15px;
  483. }
  484. .info {
  485. display: inline-block;
  486. padding-top: 10px;
  487. }
  488. }
  489. .info_title{
  490. position:relative;
  491. line-height: 34px;
  492. font-weight: bold;
  493. color:#fff;
  494. background: #3c7cf5;
  495. padding-left:15px;
  496. text-align: left;
  497. p{
  498. font-size: 16px;
  499. margin:0;
  500. span{
  501. font-size: 12px;
  502. }
  503. }
  504. a{
  505. position:absolute;
  506. top:0;
  507. right:20px;
  508. color:#fff;
  509. }
  510. }
  511. ul{
  512. margin-left:0;
  513. overflow: hidden;
  514. li{
  515. line-height: 34px;
  516. text-align: center;
  517. overflow: hidden;
  518. > span{
  519. display:inline-block;
  520. width:50%;
  521. }
  522. &:nth-child(odd){
  523. background: #fff;
  524. }
  525. &:nth-child(even){
  526. background: #f5f6f8;
  527. }
  528. &.empty{
  529. padding: 100px 0;
  530. font-size: 24px;
  531. }
  532. }
  533. }
  534. }
  535. }
  536. </style>