ApplyInfo.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <template>
  2. <div class="apply-info">
  3. <div class="apply-info-title">
  4. <p>最新求购信息</p>
  5. <span>海量求购,一网打尽</span>
  6. <div>
  7. <input type="text" class="form-control" v-model="keyWord" @keyup.13="searchList" placeholder="请输入要查找的内容" />
  8. <span @click="searchList">查询</span>
  9. </div>
  10. </div>
  11. <div class="apply-info-list">
  12. <p>
  13. <span>发布时间
  14. <a href="javascript:void(0)" @click="sortListByParam('releaseDate')">
  15. <i class=" fa fa-long-arrow-up" :class="{active: sorting.releaseDate == 'ASC'}"></i>
  16. <i class=" fa fa-long-arrow-down" :class="{active: sorting.releaseDate == 'DESC'}"></i>
  17. </a>
  18. </span>
  19. <span>买家</span>
  20. <span>型号</span>
  21. <span>品牌</span>
  22. <span>截止时间
  23. <a href="javascript:void(0)" @click="sortListByParam('deadline')">
  24. <i class=" fa fa-long-arrow-up" :class="{active: sorting.deadline == 'ASC'}"></i>
  25. <i class=" fa fa-long-arrow-down" :class="{active: sorting.deadline == 'DESC'}"></i>
  26. </a>
  27. </span>
  28. <span>已报价
  29. <a href="javascript:void(0)" @click="sortListByParam('offerAmount')">
  30. <i class=" fa fa-long-arrow-up" :class="{active: sorting.offerAmount == 'ASC'}"></i>
  31. <i class=" fa fa-long-arrow-down" :class="{active: sorting.offerAmount == 'DESC'}"></i>
  32. </a>
  33. </span>
  34. <span>操作</span>
  35. </p>
  36. <ul>
  37. <li v-for="purchaseMan in purchaseManList.content" :class="{'active': purchaseMan.active}">
  38. <span>{{purchaseMan.releaseDate | date}}</span>
  39. <span :title="getPurchaseManName(purchaseMan)">{{getPurchaseManName(purchaseMan)}}</span>
  40. <span :title="purchaseMan.code">{{purchaseMan.code}}</span>
  41. <span :title="purchaseMan.brand">{{purchaseMan.brand}}</span>
  42. <span class="date-content"><span>剩余&nbsp;</span><span v-text="getDay(purchaseMan.remainingTime)"></span>&nbsp;天&nbsp;<span v-text="getHours(purchaseMan.remainingTime)"></span>&nbsp;小时</span>
  43. <span class="number-content"><img src="/images/applyPurchase/hot-fire.png" alt="" v-if="purchaseMan.offerAmount > 10"><span :style="purchaseMan.offerAmount > 10 ? 'color: #ff9a00': ''">{{purchaseMan.offerAmount || 0}}</span>&nbsp;条</span>
  44. <span class="btn-content">
  45. <a>联系买家</a>
  46. <a v-if="!purchaseMan.isOffer" @click="sayPrice(purchaseMan)">我要报价</a>
  47. <span v-else>已报价 <img src="/images/applyPurchase/green-check.png" alt=""></span>
  48. </span>
  49. <div class="expand-content">
  50. <div>
  51. 生产日期:{{purchaseMan.produceDate || '-'}}
  52. </div>
  53. <div>
  54. 封装:{{purchaseMan.encapsulation || '-'}}
  55. </div>
  56. <div>
  57. 采购数量:<span>{{purchaseMan.amount || '-'}}</span><span v-if="purchaseMan.amount">个</span>
  58. </div>
  59. <div>
  60. 单价预算:<span>{{purchaseMan.unitPrice ? (purchaseMan.currency == 'RMB' ? '¥' : '$') + purchaseMan.unitPrice : '-'}}</span>
  61. </div>
  62. </div>
  63. <div class="say-price">
  64. <div>报价</div>
  65. <div>
  66. <i>*</i>单价
  67. <select v-if="!purchaseMan.currency" v-model="sayPriceObj.currency">
  68. <option value="RMB">¥</option>
  69. <option value="USD">$</option>
  70. </select>
  71. <div v-if="purchaseMan.currency" v-text="purchaseMan.currency == 'RMB' ? '¥' : '$'"></div>
  72. <input type="number" v-model="sayPriceObj.unitPrice" class="form-control" @blur="onUnitPriceBlur" @input="onUnitPriceChange">
  73. </div>
  74. <div>
  75. <i>*</i>交期&nbsp;
  76. <input type="number" v-model="sayPriceObj.minDay" @blur="onMinDayInput" @input="onMinDayChange" class="form-control">&nbsp;-&nbsp;<input type="number" v-model="sayPriceObj.maxDay" @blur="onMaxDayInput" @input="onMaxDayChange" class="form-control">&nbsp;天
  77. </div>
  78. <div>
  79. 生产日期&nbsp;<input v-model="sayPriceObj.produceDate" @input="onProduceDateChange" type="text" class="form-control">
  80. </div>
  81. <div>
  82. <span @click="cancelSayPrice(purchaseMan)">取消</span>
  83. <span @click="commitSayPrice(purchaseMan)">提交</span>
  84. </div>
  85. </div>
  86. </li>
  87. </ul>
  88. </div>
  89. <page :total="totalCount" :page-size="pageSize"
  90. :current="nowPage" v-on:childEvent="listenPage"></page>
  91. </div>
  92. </template>
  93. <script>
  94. let getRealLen = function (str) {
  95. let len = 0
  96. for (let i = 0; i < str.length; i++) {
  97. if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
  98. len += 2
  99. } else {
  100. len++
  101. }
  102. }
  103. return len
  104. }
  105. import Page from '~components/common/page/pageComponent.vue'
  106. export default {
  107. data () {
  108. return {
  109. pageSize: 10,
  110. nowPage: 1,
  111. sayPriceObj: {
  112. currency: 'RMB',
  113. unitPrice: '',
  114. minDay: '',
  115. maxDay: '',
  116. produceDate: '',
  117. spId: ''
  118. },
  119. validSayPrice: {
  120. unitPrice: false,
  121. minDay: false,
  122. maxDay: false
  123. },
  124. keyWord: '',
  125. sorting: {}
  126. }
  127. },
  128. components: {
  129. Page
  130. },
  131. filters: {
  132. date: function (date) {
  133. const d = new Date(Number(date))
  134. const year = d.getFullYear()
  135. const monthTemp = d.getMonth() + 1
  136. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  137. const hour = d.getHours() < 10 ? '0' + d.getHours() : '' + d.getHours()
  138. const minutes = d.getMinutes() < 10 ? '0' + d.getMinutes() : '' + d.getMinutes() + ' '
  139. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate() + ' '
  140. return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
  141. },
  142. phone: function (str) {
  143. return str.substring(0, 3) + '****' + str.substring(7, 11)
  144. }
  145. },
  146. computed: {
  147. purchaseManList () {
  148. return this.$store.state.applyPurchase.purchaseManList.purchaseManList.data
  149. },
  150. totalCount () {
  151. return this.purchaseManList.totalElements
  152. },
  153. user () {
  154. return this.$store.state.option.user
  155. }
  156. },
  157. methods: {
  158. getDay: function (timeStamp) {
  159. return Math.floor(timeStamp / (1000 * 60 * 60 * 24))
  160. },
  161. getHours: function (timeStamp) {
  162. return Math.floor((timeStamp / (1000 * 60 * 60)) % 24)
  163. },
  164. getPurchaseManName: function (purchaseMan) {
  165. return purchaseMan.enUu ? purchaseMan.userName : purchaseMan.userName.charAt(0) + '**'
  166. },
  167. listenPage: function (page) {
  168. this.nowPage = page
  169. this.resetList()
  170. },
  171. sayPrice: function (purchaseMan) {
  172. let _this = this
  173. for (let i = 0; i < this.purchaseManList.content.length; i++) {
  174. _this.purchaseManList.content[i].active = false
  175. }
  176. this.resetSayPrice()
  177. purchaseMan.active = true
  178. },
  179. cancelSayPrice: function (purchaseMan) {
  180. purchaseMan.active = false
  181. },
  182. commitSayPrice: function (purchaseMan) {
  183. if (this.user.logged) {
  184. let valid = this.checkAllSayPrice()
  185. if (valid) {
  186. this.sayPriceObj.spId = purchaseMan.id
  187. this.sayPriceObj.currency = purchaseMan.currency || this.sayPriceObj.currency
  188. this.$http.post('/seek/offer/saveOffer', this.sayPriceObj).then(response => {
  189. if (response.data.success) {
  190. this.$message.success('报价成功')
  191. this.nowPage = 1
  192. this.resetSayPrice()
  193. this.resetList()
  194. } else {
  195. this.$message.error(response.data.message)
  196. }
  197. }, error => {
  198. console.log(error)
  199. this.$message.error('系统错误')
  200. })
  201. } else {
  202. if (!this.validSayPrice.unitPrice) {
  203. if (!this.sayPriceObj.unitPrice) {
  204. this.$message.error('单价不能为空')
  205. } else {
  206. this.$message.error('单价必须是大于0的数字')
  207. }
  208. } else if (!this.validSayPrice.minDay || !this.validSayPrice.maxDay) {
  209. if (!this.sayPriceObj.minDay || !this.sayPriceObj.maxDay) {
  210. this.$message.error('交期不能为空')
  211. } else {
  212. if (this.sayPriceObj.minDay > 31 || this.sayPriceObj.minDay < 1 || this.sayPriceObj.minDay.indexOf('.') !== -1 || this.sayPriceObj.maxDay > 31 || this.sayPriceObj.maxDay < 1 || this.sayPriceObj.maxDay.indexOf('.') !== -1) {
  213. this.$message.error('交期只能填写1-31之间的整数值')
  214. } else {
  215. this.$message.error('最短交期应小于等于最长交期')
  216. }
  217. }
  218. }
  219. }
  220. } else {
  221. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  222. }
  223. },
  224. resetList: function () {
  225. this.$store.dispatch('applyPurchase/loadPurchaseManList', {page: this.nowPage, count: this.pageSize, keyWord: this.keyWord, sorting: !this.sorting || JSON.stringify(this.sorting) === '{}' ? {releaseDate: 'DESC'} : this.sorting})
  226. },
  227. resetSayPrice: function () {
  228. this.sayPriceObj = {
  229. currency: 'RMB',
  230. unitPrice: '',
  231. minDay: '',
  232. maxDay: '',
  233. produceDate: '',
  234. spId: ''
  235. }
  236. },
  237. onUnitPriceBlur: function () {
  238. if (this.sayPriceObj.unitPrice) {
  239. if (this.sayPriceObj.unitPrice < 0) {
  240. this.$message.error('单价必须是大于0的数字')
  241. this.validSayPrice.unitPrice = false
  242. } else {
  243. this.validSayPrice.unitPrice = true
  244. }
  245. } else {
  246. this.$message.error('单价必须是大于0的数字')
  247. this.validSayPrice.unitPrice = false
  248. }
  249. },
  250. onUnitPriceChange: function () {
  251. let price = this.sayPriceObj.unitPrice
  252. if (price >= 9999) {
  253. this.sayPriceObj.unitPrice = price.substring(0, 4)
  254. } else if (price.indexOf('.') > -1) {
  255. let arr = price.split('.')
  256. if (arr[0].length > 4) {
  257. this.sayPriceObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
  258. } else if (arr[1].length > 6) {
  259. this.sayPriceObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
  260. }
  261. }
  262. },
  263. onMinDayInput: function () {
  264. if (this.sayPriceObj.minDay < 1 || this.sayPriceObj.minDay > 31 || this.sayPriceObj.minDay.indexOf('.') !== -1) {
  265. this.validSayPrice.minDay = false
  266. this.$message.error('交期只能填写1-31之间的整数值')
  267. } else if (this.sayPriceObj.maxDay && this.sayPriceObj.maxDay < this.sayPriceObj.minDay) {
  268. this.validSayPrice.minDay = false
  269. this.$message.error('最短交期应小于等于最长交期')
  270. } else {
  271. this.validSayPrice.minDay = true
  272. }
  273. },
  274. onMinDayChange: function () {
  275. if (this.sayPriceObj.minDay.length > 2) {
  276. this.sayPriceObj.minDay = this.sayPriceObj.minDay.substring(0, 2)
  277. }
  278. },
  279. onMaxDayInput: function () {
  280. if (this.sayPriceObj.maxDay < 1 || this.sayPriceObj.maxDay > 31 || this.sayPriceObj.maxDay.indexOf('.') !== -1) {
  281. this.validSayPrice.maxDay = false
  282. this.$message.error('交期只能填写1-31之间的整数值')
  283. } else if (this.sayPriceObj.minDay && this.sayPriceObj.maxDay < this.sayPriceObj.minDay) {
  284. this.validSayPrice.maxDay = false
  285. this.$message.error('最短交期应小于等于最长交期')
  286. } else {
  287. this.validSayPrice.maxDay = true
  288. }
  289. },
  290. onMaxDayChange: function () {
  291. if (this.sayPriceObj.maxDay.length > 2) {
  292. this.sayPriceObj.maxDay = this.sayPriceObj.maxDay.substring(0, 2)
  293. }
  294. },
  295. onProduceDateChange: function () {
  296. if (this.sayPriceObj.produceDate && getRealLen(this.sayPriceObj.produceDate) > 12) {
  297. this.sayPriceObj.produceDate = this.sayPriceObj.produceDate.substring(0, this.sayPriceObj.produceDate.length - 1)
  298. }
  299. },
  300. checkAllSayPrice: function () {
  301. return this.validSayPrice.unitPrice && this.validSayPrice.minDay && this.validSayPrice.maxDay
  302. },
  303. searchList: function () {
  304. this.resetList()
  305. },
  306. sortListByParam: function (param) {
  307. if (this.sorting[param]) {
  308. if (this.sorting[param] === 'ASC') {
  309. this.$set(this.sorting, param, 'DESC')
  310. } else {
  311. this.$delete(this.sorting, param)
  312. }
  313. } else {
  314. this.sorting = {}
  315. this.$set(this.sorting, param, 'ASC')
  316. }
  317. this.resetList()
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. .apply-info {
  324. width: 1190px;
  325. margin: 0 auto;
  326. .apply-info-title {
  327. border-bottom: 1px solid #3975f4;
  328. >p {
  329. display: inline-block;
  330. width: 156px;
  331. height: 33px;
  332. line-height: 33px;
  333. color: #fff;
  334. background: #3975f4;
  335. font-size: 18px;
  336. text-align: center;
  337. border: {
  338. top-left-radius: 3px;
  339. top-right-radius: 3px;
  340. }
  341. margin: 0;
  342. }
  343. >span {
  344. color: #999;
  345. margin-left: 16px;
  346. }
  347. >div {
  348. float: right;
  349. height: 25px;
  350. line-height: 25px;
  351. >input {
  352. width: 241px;
  353. height: 25px;
  354. line-height: 25px;
  355. font-size: 13px;
  356. border: {
  357. top-right-radius: 0;
  358. bottom-right-radius: 0;
  359. }
  360. }
  361. >span {
  362. display: inline-block;
  363. width: 69px;
  364. color: #fff;
  365. background: #3975f4;
  366. text-align: center;
  367. margin: 0 6px 0 -1px;
  368. border: {
  369. top-right-radius: 3px;
  370. bottom-right-radius: 3px;
  371. }
  372. cursor: pointer;
  373. }
  374. >a {
  375. background: #ffa200;
  376. color: #fff;
  377. width: 79px;
  378. border-radius: 3px;
  379. text-align: center;
  380. display: inline-block;
  381. }
  382. }
  383. }
  384. .apply-info-list {
  385. >p {
  386. background: #ededed;
  387. height: 40px;
  388. line-height: 40px;
  389. margin: 9px 0 0 0;
  390. span {
  391. display: inline-block;
  392. text-align: center;
  393. a {
  394. i {
  395. color: #333;
  396. &.active {
  397. color: #5078cb;
  398. }
  399. }
  400. }
  401. &:nth-child(1) {
  402. width: 186px;
  403. }
  404. &:nth-child(2) {
  405. width: 106px;
  406. }
  407. &:nth-child(3) {
  408. width: 200px;
  409. }
  410. &:nth-child(4) {
  411. width: 174px;
  412. }
  413. &:nth-child(5) {
  414. width: 152px;
  415. }
  416. &:nth-child(6) {
  417. width: 158px;
  418. }
  419. &:nth-child(7) {
  420. width: 214px;
  421. }
  422. }
  423. }
  424. >ul {
  425. margin-bottom: 29px;
  426. li {
  427. min-height: 67px;
  428. line-height: 67px;
  429. border: 1px solid #ededed;
  430. >span {
  431. overflow: hidden;
  432. text-overflow: ellipsis;
  433. white-space: nowrap;
  434. display: inline-block;
  435. text-align: center;
  436. color: #3c3c3c;
  437. vertical-align: middle;
  438. &:nth-child(1) {
  439. width: 186px;
  440. }
  441. &:nth-child(2) {
  442. width: 106px;
  443. }
  444. &:nth-child(3) {
  445. width: 200px;
  446. }
  447. &:nth-child(4) {
  448. width: 174px;
  449. }
  450. &:nth-child(5) {
  451. width: 152px;
  452. }
  453. &:nth-child(6) {
  454. width: 158px;
  455. }
  456. &:nth-child(7) {
  457. width: 212px;
  458. }
  459. &.date-content {
  460. span {
  461. &:first-child {
  462. font-size: 12px;
  463. color: #666;
  464. }
  465. color: #f71026;
  466. }
  467. }
  468. &.number-content {
  469. span {
  470. color: #5392f9;
  471. &.active {
  472. color: #ff9a00;
  473. }
  474. }
  475. >img {
  476. margin-bottom: 5px;
  477. margin-right: 2px;
  478. }
  479. }
  480. &.btn-content {
  481. a {
  482. display: inline-block;
  483. width: 71px;
  484. height: 28px;
  485. line-height: 28px;
  486. color: #fff;
  487. background: #3c7cf5;
  488. border-radius: 3px;
  489. cursor: pointer;
  490. &:first-child {
  491. background: #ffa200;
  492. margin-right: 10px;
  493. }
  494. }
  495. span {
  496. color: #39ae05;
  497. img {
  498. margin-bottom: 2px;
  499. }
  500. }
  501. }
  502. }
  503. .expand-content {
  504. display: none;
  505. justify-content: space-between;
  506. padding: 0 236px 0 36px;
  507. background: #fffbf0;
  508. height: 45px;
  509. line-height: 45px;
  510. color: #020202;
  511. div {
  512. display: inline-block;
  513. span {
  514. color: #f71026;
  515. }
  516. }
  517. }
  518. &:hover {
  519. box-shadow: 1.5px 3px 7px 0 rgb( 178, 178, 179 );
  520. .expand-content {
  521. display: flex;
  522. }
  523. }
  524. .say-price {
  525. background-color: #e7eef9;
  526. height: 64px;
  527. line-height: 64px;
  528. display: none;
  529. >div {
  530. display: inline-block;
  531. position: relative;
  532. height: 64px;
  533. line-height: 64px;
  534. input {
  535. border-radius: 3px;
  536. }
  537. &:nth-child(1) {
  538. width: 282px;
  539. background: url('/images/applyPurchase/say-price.png')no-repeat;
  540. text-align: center;
  541. margin-right: 44px;
  542. }
  543. &:nth-child(2) {
  544. margin-right: 39px;
  545. input {
  546. width: 118px;
  547. height: 26px;
  548. border: 1px solid #5392f9;
  549. }
  550. select {
  551. position: absolute;
  552. top: 19px;
  553. width: 32px;
  554. height: 26px;
  555. background: url('/images/applyPurchase/arrow-down.png')no-repeat right center;
  556. -webkit-box-shadow: none;
  557. -moz-box-shadow: none;
  558. box-shadow: none;
  559. border: {
  560. left: none;
  561. top: none;
  562. bottom: none;
  563. right: 1px solid #5392f9;
  564. bottom-left-radius: 4px;
  565. top-left-radius: 4px;
  566. }
  567. color: #5392f9;
  568. font: small-caption;
  569. padding-left: 8px;
  570. & + input {
  571. padding-left: 34px;
  572. }
  573. }
  574. div {
  575. position: absolute;
  576. top: 19px;
  577. left: 38px;
  578. width: 32px;
  579. height: 26px;
  580. line-height: 26px;
  581. text-align: center;
  582. border: {
  583. left: none;
  584. top: none;
  585. bottom: none;
  586. right: 1px solid #5392f9;
  587. bottom-left-radius: 4px;
  588. top-left-radius: 4px;
  589. }
  590. color: #5392f9;
  591. & + input {
  592. padding-left: 34px;
  593. }
  594. }
  595. }
  596. &:nth-child(3) {
  597. margin-right: 37px;
  598. input {
  599. width: 32px;
  600. height: 26px;
  601. padding: 0 0 0 3px;
  602. }
  603. }
  604. &:nth-child(4) {
  605. margin-right: 132px;
  606. input {
  607. width: 118px;
  608. height: 26px;
  609. }
  610. }
  611. &:nth-child(5) {
  612. span {
  613. width: 71px;
  614. height: 28px;
  615. line-height: 28px;
  616. text-align: center;
  617. display: inline-block;
  618. cursor: pointer;
  619. &:first-child {
  620. background: #dedddd;
  621. margin-right: 10px;
  622. }
  623. &:last-child {
  624. background: #fa4701;
  625. color: #fff;
  626. }
  627. }
  628. }
  629. i {
  630. color: #e41515;
  631. position: relative;
  632. top: 2px;
  633. right: 3px;
  634. }
  635. }
  636. }
  637. &.active {
  638. border-color: #f71026;
  639. box-shadow: none;
  640. .expand-content {
  641. display: flex;
  642. -webkit-box-shadow: none;
  643. -moz-box-shadow: none;
  644. box-shadow: none;
  645. }
  646. .say-price {
  647. display: block;
  648. }
  649. }
  650. }
  651. }
  652. }
  653. .page-wrap {
  654. text-align: right;
  655. float: none;
  656. }
  657. }
  658. </style>