ApplyInfo.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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. if (this.checkAllSayPrice()) {
  185. this.sayPriceObj.spId = purchaseMan.id
  186. this.sayPriceObj.currency = purchaseMan.currency || this.sayPriceObj.currency
  187. this.$http.post('/seek/offer/saveOffer', this.sayPriceObj).then(response => {
  188. if (response.data.success) {
  189. this.$message.success('报价成功')
  190. this.nowPage = 1
  191. this.resetSayPrice()
  192. this.resetList()
  193. } else {
  194. this.$message.error(response.data.message)
  195. }
  196. }, error => {
  197. console.log(error)
  198. this.$message.error('系统错误')
  199. })
  200. } else {
  201. if (!this.validSayPrice.unitPrice) {
  202. if (!this.sayPriceObj.unitPrice) {
  203. this.$message.error('单价不能为空')
  204. } else {
  205. this.$message.error('单价必须是大于0的数字')
  206. }
  207. } else if (!this.validSayPrice.minDay || !this.validSayPrice.maxDay) {
  208. if (!this.sayPriceObj.minDay || !this.sayPriceObj.maxDay) {
  209. this.$message.error('交期不能为空')
  210. } else {
  211. 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) {
  212. this.$message.error('交期只能填写1-31之间的整数值')
  213. } else {
  214. this.$message.error('最短交期应小于等于最长交期')
  215. }
  216. }
  217. }
  218. }
  219. } else {
  220. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  221. }
  222. },
  223. resetList: function () {
  224. 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})
  225. },
  226. resetSayPrice: function () {
  227. this.sayPriceObj = {
  228. currency: 'RMB',
  229. unitPrice: '',
  230. minDay: '',
  231. maxDay: '',
  232. produceDate: '',
  233. spId: ''
  234. }
  235. },
  236. onUnitPriceBlur: function () {
  237. if (this.sayPriceObj.unitPrice) {
  238. if (this.sayPriceObj.unitPrice <= 0) {
  239. this.$message.error('单价必须是大于0的数字')
  240. this.validSayPrice.unitPrice = false
  241. } else {
  242. this.validSayPrice.unitPrice = true
  243. }
  244. } else {
  245. this.$message.error('单价必须是大于0的数字')
  246. this.validSayPrice.unitPrice = false
  247. }
  248. },
  249. onUnitPriceChange: function () {
  250. let price = this.sayPriceObj.unitPrice
  251. if (price >= 10000) {
  252. this.sayPriceObj.unitPrice = price.substring(0, 4)
  253. } else if (price.indexOf('.') > -1) {
  254. let arr = price.split('.')
  255. if (arr[0].length > 4) {
  256. this.sayPriceObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
  257. } else if (arr[1].length > 6) {
  258. this.sayPriceObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
  259. }
  260. }
  261. },
  262. onMinDayInput: function () {
  263. this.sayPriceObj.minDay = Number(this.sayPriceObj.minDay)
  264. if (this.sayPriceObj.minDay < 1 || this.sayPriceObj.minDay > 31 || this.sayPriceObj.minDay.toString().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. this.sayPriceObj.maxDay = Number(this.sayPriceObj.maxDay)
  281. if (this.sayPriceObj.maxDay < 1 || this.sayPriceObj.maxDay > 31 || this.sayPriceObj.maxDay.toString().indexOf('.') !== -1) {
  282. this.validSayPrice.maxDay = false
  283. this.$message.error('交期只能填写1-31之间的整数值')
  284. } else if (this.sayPriceObj.minDay && this.sayPriceObj.maxDay < this.sayPriceObj.minDay) {
  285. this.validSayPrice.maxDay = false
  286. this.$message.error('最短交期应小于等于最长交期')
  287. } else {
  288. this.validSayPrice.maxDay = true
  289. }
  290. },
  291. onMaxDayChange: function () {
  292. if (this.sayPriceObj.maxDay.length > 2) {
  293. this.sayPriceObj.maxDay = this.sayPriceObj.maxDay.substring(0, 2)
  294. }
  295. },
  296. onProduceDateChange: function () {
  297. if (this.sayPriceObj.produceDate && getRealLen(this.sayPriceObj.produceDate) > 12) {
  298. this.sayPriceObj.produceDate = this.sayPriceObj.produceDate.substring(0, this.sayPriceObj.produceDate.length - 1)
  299. }
  300. },
  301. checkAllSayPrice: function () {
  302. return this.validSayPrice.unitPrice && this.validSayPrice.minDay && this.validSayPrice.maxDay
  303. },
  304. searchList: function () {
  305. this.resetList()
  306. },
  307. sortListByParam: function (param) {
  308. if (this.sorting[param]) {
  309. if (this.sorting[param] === 'ASC') {
  310. this.$set(this.sorting, param, 'DESC')
  311. } else {
  312. this.$delete(this.sorting, param)
  313. }
  314. } else {
  315. this.sorting = {}
  316. this.$set(this.sorting, param, 'ASC')
  317. }
  318. this.resetList()
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="scss" scoped>
  324. .apply-info {
  325. width: 1190px;
  326. margin: 0 auto;
  327. .apply-info-title {
  328. border-bottom: 1px solid #3975f4;
  329. >p {
  330. display: inline-block;
  331. width: 156px;
  332. height: 33px;
  333. line-height: 33px;
  334. color: #fff;
  335. background: #3975f4;
  336. font-size: 18px;
  337. text-align: center;
  338. border: {
  339. top-left-radius: 3px;
  340. top-right-radius: 3px;
  341. }
  342. margin: 0;
  343. }
  344. >span {
  345. color: #999;
  346. margin-left: 16px;
  347. }
  348. >div {
  349. float: right;
  350. height: 25px;
  351. line-height: 25px;
  352. >input {
  353. width: 241px;
  354. height: 25px;
  355. line-height: 25px;
  356. font-size: 13px;
  357. border: {
  358. top-right-radius: 0;
  359. bottom-right-radius: 0;
  360. }
  361. }
  362. >span {
  363. display: inline-block;
  364. width: 69px;
  365. color: #fff;
  366. background: #3975f4;
  367. text-align: center;
  368. margin: 0 6px 0 -1px;
  369. border: {
  370. top-right-radius: 3px;
  371. bottom-right-radius: 3px;
  372. }
  373. cursor: pointer;
  374. }
  375. >a {
  376. background: #ffa200;
  377. color: #fff;
  378. width: 79px;
  379. border-radius: 3px;
  380. text-align: center;
  381. display: inline-block;
  382. }
  383. }
  384. }
  385. .apply-info-list {
  386. >p {
  387. background: #ededed;
  388. height: 40px;
  389. line-height: 40px;
  390. margin: 9px 0 0 0;
  391. span {
  392. display: inline-block;
  393. text-align: center;
  394. a {
  395. i {
  396. color: #333;
  397. &.active {
  398. color: #5078cb;
  399. }
  400. }
  401. }
  402. &:nth-child(1) {
  403. width: 186px;
  404. }
  405. &:nth-child(2) {
  406. width: 106px;
  407. }
  408. &:nth-child(3) {
  409. width: 200px;
  410. }
  411. &:nth-child(4) {
  412. width: 174px;
  413. }
  414. &:nth-child(5) {
  415. width: 152px;
  416. }
  417. &:nth-child(6) {
  418. width: 158px;
  419. }
  420. &:nth-child(7) {
  421. width: 214px;
  422. }
  423. }
  424. }
  425. >ul {
  426. margin-bottom: 29px;
  427. li {
  428. min-height: 67px;
  429. line-height: 67px;
  430. border: 1px solid #ededed;
  431. >span {
  432. overflow: hidden;
  433. text-overflow: ellipsis;
  434. white-space: nowrap;
  435. display: inline-block;
  436. text-align: center;
  437. color: #3c3c3c;
  438. vertical-align: middle;
  439. &:nth-child(1) {
  440. width: 186px;
  441. }
  442. &:nth-child(2) {
  443. width: 106px;
  444. }
  445. &:nth-child(3) {
  446. width: 200px;
  447. }
  448. &:nth-child(4) {
  449. width: 174px;
  450. }
  451. &:nth-child(5) {
  452. width: 152px;
  453. }
  454. &:nth-child(6) {
  455. width: 158px;
  456. }
  457. &:nth-child(7) {
  458. width: 212px;
  459. }
  460. &.date-content {
  461. span {
  462. &:first-child {
  463. font-size: 12px;
  464. color: #666;
  465. }
  466. color: #f71026;
  467. }
  468. }
  469. &.number-content {
  470. span {
  471. color: #5392f9;
  472. &.active {
  473. color: #ff9a00;
  474. }
  475. }
  476. >img {
  477. margin-bottom: 5px;
  478. margin-right: 2px;
  479. }
  480. }
  481. &.btn-content {
  482. a {
  483. display: inline-block;
  484. width: 71px;
  485. height: 28px;
  486. line-height: 28px;
  487. color: #fff;
  488. background: #3c7cf5;
  489. border-radius: 3px;
  490. cursor: pointer;
  491. &:first-child {
  492. background: #ffa200;
  493. margin-right: 10px;
  494. }
  495. }
  496. span {
  497. color: #39ae05;
  498. img {
  499. margin-bottom: 2px;
  500. }
  501. }
  502. }
  503. }
  504. .expand-content {
  505. display: none;
  506. justify-content: space-between;
  507. padding: 0 236px 0 36px;
  508. background: #fffbf0;
  509. height: 45px;
  510. line-height: 45px;
  511. color: #020202;
  512. div {
  513. display: inline-block;
  514. span {
  515. color: #f71026;
  516. }
  517. }
  518. }
  519. &:hover {
  520. box-shadow: 1.5px 3px 7px 0 rgb( 178, 178, 179 );
  521. .expand-content {
  522. display: flex;
  523. }
  524. }
  525. .say-price {
  526. background-color: #e7eef9;
  527. height: 64px;
  528. line-height: 64px;
  529. display: none;
  530. >div {
  531. display: inline-block;
  532. position: relative;
  533. height: 64px;
  534. line-height: 64px;
  535. input {
  536. border-radius: 3px;
  537. }
  538. &:nth-child(1) {
  539. width: 282px;
  540. background: url('/images/applyPurchase/say-price.png')no-repeat;
  541. text-align: center;
  542. margin-right: 44px;
  543. }
  544. &:nth-child(2) {
  545. margin-right: 39px;
  546. input {
  547. width: 118px;
  548. height: 26px;
  549. border: 1px solid #5392f9;
  550. }
  551. select {
  552. position: absolute;
  553. top: 19px;
  554. width: 32px;
  555. height: 26px;
  556. background: url('/images/applyPurchase/arrow-down.png')no-repeat right center;
  557. -webkit-box-shadow: none;
  558. -moz-box-shadow: none;
  559. box-shadow: none;
  560. border: {
  561. left: none;
  562. top: none;
  563. bottom: none;
  564. right: 1px solid #5392f9;
  565. bottom-left-radius: 4px;
  566. top-left-radius: 4px;
  567. }
  568. color: #5392f9;
  569. font: small-caption;
  570. padding-left: 8px;
  571. & + input {
  572. padding-left: 34px;
  573. }
  574. }
  575. div {
  576. position: absolute;
  577. top: 19px;
  578. left: 38px;
  579. width: 32px;
  580. height: 26px;
  581. line-height: 26px;
  582. text-align: center;
  583. border: {
  584. left: none;
  585. top: none;
  586. bottom: none;
  587. right: 1px solid #5392f9;
  588. bottom-left-radius: 4px;
  589. top-left-radius: 4px;
  590. }
  591. color: #5392f9;
  592. & + input {
  593. padding-left: 34px;
  594. }
  595. }
  596. }
  597. &:nth-child(3) {
  598. margin-right: 37px;
  599. input {
  600. width: 32px;
  601. height: 26px;
  602. padding: 0 0 0 6px;
  603. }
  604. }
  605. &:nth-child(4) {
  606. margin-right: 132px;
  607. input {
  608. width: 118px;
  609. height: 26px;
  610. }
  611. }
  612. &:nth-child(5) {
  613. span {
  614. width: 71px;
  615. height: 28px;
  616. line-height: 28px;
  617. text-align: center;
  618. display: inline-block;
  619. cursor: pointer;
  620. &:first-child {
  621. background: #dedddd;
  622. margin-right: 10px;
  623. }
  624. &:last-child {
  625. background: #fa4701;
  626. color: #fff;
  627. }
  628. }
  629. }
  630. i {
  631. color: #e41515;
  632. position: relative;
  633. top: 2px;
  634. right: 3px;
  635. }
  636. }
  637. }
  638. &.active {
  639. border-color: #f71026;
  640. box-shadow: none;
  641. .expand-content {
  642. display: flex;
  643. -webkit-box-shadow: none;
  644. -moz-box-shadow: none;
  645. box-shadow: none;
  646. }
  647. .say-price {
  648. display: block;
  649. }
  650. }
  651. }
  652. }
  653. }
  654. .page-wrap {
  655. text-align: right;
  656. float: none;
  657. }
  658. }
  659. </style>