details.vue 15 KB

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