ApplyInfo.vue 18 KB

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