ApplyInfo.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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 || this.sayPriceObj.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?returnUrl=' + window.location.href)
  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. } else if (this.sayPriceObj.minDay > 31) {
  231. this.sayPriceObj.minDay = 31
  232. }
  233. },
  234. onMaxDayInput: function () {
  235. this.sayPriceObj.maxDay = Math.floor(this.sayPriceObj.maxDay)
  236. if (this.sayPriceObj.minDay) {
  237. if (this.sayPriceObj.maxDay < this.sayPriceObj.minDay) {
  238. this.sayPriceObj.maxDay = this.sayPriceObj.minDay
  239. }
  240. } else if (this.sayPriceObj.maxDay < 0) {
  241. this.sayPriceObj.maxDay = 0
  242. } else if (this.sayPriceObj.maxDay > 31) {
  243. this.sayPriceObj.maxDay = 31
  244. }
  245. },
  246. onProduceDateChange: function () {
  247. if (this.sayPriceObj.produceDate && getRealLen(this.sayPriceObj.produceDate) > 12) {
  248. this.sayPriceObj.produceDate = this.sayPriceObj.produceDate.substring(0, this.sayPriceObj.produceDate.length - 1)
  249. }
  250. },
  251. searchList: function () {
  252. this.resetList()
  253. },
  254. sortListByParam: function (param) {
  255. if (this.sorting[param]) {
  256. if (this.sorting[param] === 'ASC') {
  257. this.$set(this.sorting, param, 'DESC')
  258. } else {
  259. this.$delete(this.sorting, param)
  260. }
  261. } else {
  262. this.sorting = {}
  263. this.$set(this.sorting, param, 'ASC')
  264. }
  265. this.resetList()
  266. }
  267. }
  268. }
  269. </script>
  270. <style lang="scss" scoped>
  271. .apply-info {
  272. width: 1190px;
  273. margin: 0 auto;
  274. .apply-info-title {
  275. border-bottom: 1px solid #3975f4;
  276. >p {
  277. display: inline-block;
  278. width: 156px;
  279. height: 33px;
  280. line-height: 33px;
  281. color: #fff;
  282. background: #3975f4;
  283. font-size: 18px;
  284. text-align: center;
  285. border: {
  286. top-left-radius: 3px;
  287. top-right-radius: 3px;
  288. }
  289. margin: 0;
  290. }
  291. >span {
  292. color: #999;
  293. margin-left: 16px;
  294. }
  295. >div {
  296. float: right;
  297. height: 25px;
  298. line-height: 25px;
  299. >input {
  300. width: 241px;
  301. height: 25px;
  302. line-height: 25px;
  303. font-size: 13px;
  304. border: {
  305. top-right-radius: 0;
  306. bottom-right-radius: 0;
  307. }
  308. }
  309. >span {
  310. display: inline-block;
  311. width: 69px;
  312. color: #fff;
  313. background: #3975f4;
  314. text-align: center;
  315. margin: 0 6px 0 -1px;
  316. border: {
  317. top-right-radius: 3px;
  318. bottom-right-radius: 3px;
  319. }
  320. cursor: pointer;
  321. }
  322. >a {
  323. background: #ffa200;
  324. color: #fff;
  325. width: 79px;
  326. border-radius: 3px;
  327. text-align: center;
  328. display: inline-block;
  329. }
  330. }
  331. }
  332. .apply-info-list {
  333. >p {
  334. background: #ededed;
  335. height: 40px;
  336. line-height: 40px;
  337. margin: 9px 0 0 0;
  338. span {
  339. display: inline-block;
  340. text-align: center;
  341. a {
  342. i {
  343. color: #333;
  344. &.active {
  345. color: #5078cb;
  346. }
  347. }
  348. }
  349. &:nth-child(1) {
  350. width: 186px;
  351. }
  352. &:nth-child(2) {
  353. width: 106px;
  354. }
  355. &:nth-child(3) {
  356. width: 200px;
  357. }
  358. &:nth-child(4) {
  359. width: 174px;
  360. }
  361. &:nth-child(5) {
  362. width: 152px;
  363. }
  364. &:nth-child(6) {
  365. width: 158px;
  366. }
  367. &:nth-child(7) {
  368. width: 214px;
  369. }
  370. }
  371. }
  372. >ul {
  373. margin-bottom: 29px;
  374. li {
  375. min-height: 67px;
  376. line-height: 67px;
  377. border: 1px solid #ededed;
  378. >span {
  379. overflow: hidden;
  380. text-overflow: ellipsis;
  381. white-space: nowrap;
  382. display: inline-block;
  383. text-align: center;
  384. color: #3c3c3c;
  385. vertical-align: middle;
  386. &:nth-child(1) {
  387. width: 186px;
  388. }
  389. &:nth-child(2) {
  390. width: 106px;
  391. }
  392. &:nth-child(3) {
  393. width: 200px;
  394. }
  395. &:nth-child(4) {
  396. width: 174px;
  397. }
  398. &:nth-child(5) {
  399. width: 152px;
  400. }
  401. &:nth-child(6) {
  402. width: 158px;
  403. }
  404. &:nth-child(7) {
  405. width: 212px;
  406. }
  407. &.date-content {
  408. span {
  409. &:first-child {
  410. font-size: 12px;
  411. color: #666;
  412. }
  413. color: #f71026;
  414. }
  415. }
  416. &.number-content {
  417. span {
  418. color: #5392f9;
  419. &.active {
  420. color: #ff9a00;
  421. }
  422. }
  423. >img {
  424. margin-bottom: 5px;
  425. margin-right: 2px;
  426. }
  427. }
  428. &.btn-content {
  429. a {
  430. display: inline-block;
  431. width: 71px;
  432. height: 28px;
  433. line-height: 28px;
  434. color: #fff;
  435. background: #3c7cf5;
  436. border-radius: 3px;
  437. cursor: pointer;
  438. &:first-child {
  439. background: #ffa200;
  440. margin-right: 10px;
  441. }
  442. }
  443. }
  444. }
  445. .expand-content {
  446. display: none;
  447. justify-content: space-between;
  448. padding: 0 236px 0 36px;
  449. background: #fffbf0;
  450. height: 45px;
  451. line-height: 45px;
  452. color: #020202;
  453. div {
  454. display: inline-block;
  455. span {
  456. color: #f71026;
  457. }
  458. }
  459. }
  460. &:hover {
  461. box-shadow: 1.5px 3px 7px 0 rgb( 178, 178, 179 );
  462. .expand-content {
  463. display: flex;
  464. }
  465. }
  466. .say-price {
  467. background-color: #e7eef9;
  468. height: 64px;
  469. line-height: 64px;
  470. display: none;
  471. >div {
  472. display: inline-block;
  473. position: relative;
  474. height: 64px;
  475. line-height: 64px;
  476. input {
  477. border-radius: 3px;
  478. }
  479. &:nth-child(1) {
  480. width: 282px;
  481. background: url('/images/applyPurchase/say-price.png')no-repeat;
  482. text-align: center;
  483. margin-right: 44px;
  484. }
  485. &:nth-child(2) {
  486. margin-right: 39px;
  487. input {
  488. width: 118px;
  489. height: 26px;
  490. border: 1px solid #5392f9;
  491. }
  492. select {
  493. position: absolute;
  494. top: 19px;
  495. width: 32px;
  496. height: 26px;
  497. background: url('/images/applyPurchase/arrow-down.png')no-repeat right center;
  498. -webkit-box-shadow: none;
  499. -moz-box-shadow: none;
  500. box-shadow: none;
  501. border: {
  502. left: none;
  503. top: none;
  504. bottom: none;
  505. right: 1px solid #5392f9;
  506. bottom-left-radius: 4px;
  507. top-left-radius: 4px;
  508. }
  509. color: #5392f9;
  510. font: small-caption;
  511. padding-left: 3px;
  512. & + input {
  513. padding-left: 34px;
  514. }
  515. }
  516. div {
  517. position: absolute;
  518. top: 19px;
  519. left: 38px;
  520. width: 32px;
  521. height: 26px;
  522. line-height: 26px;
  523. text-align: center;
  524. border: {
  525. left: none;
  526. top: none;
  527. bottom: none;
  528. right: 1px solid #5392f9;
  529. bottom-left-radius: 4px;
  530. top-left-radius: 4px;
  531. }
  532. color: #5392f9;
  533. & + input {
  534. padding-left: 34px;
  535. }
  536. }
  537. }
  538. &:nth-child(3) {
  539. margin-right: 37px;
  540. input {
  541. width: 32px;
  542. height: 26px;
  543. }
  544. }
  545. &:nth-child(4) {
  546. margin-right: 132px;
  547. input {
  548. width: 118px;
  549. height: 26px;
  550. }
  551. }
  552. &:nth-child(5) {
  553. span {
  554. width: 71px;
  555. height: 28px;
  556. line-height: 28px;
  557. text-align: center;
  558. display: inline-block;
  559. cursor: pointer;
  560. &:first-child {
  561. background: #dedddd;
  562. margin-right: 10px;
  563. }
  564. &:last-child {
  565. background: #fa4701;
  566. color: #fff;
  567. }
  568. }
  569. }
  570. i {
  571. color: #e41515;
  572. position: relative;
  573. top: 2px;
  574. right: 3px;
  575. }
  576. }
  577. }
  578. &.active {
  579. border-color: #f71026;
  580. box-shadow: none;
  581. .expand-content {
  582. display: flex;
  583. -webkit-box-shadow: none;
  584. -moz-box-shadow: none;
  585. box-shadow: none;
  586. }
  587. .say-price {
  588. display: block;
  589. }
  590. }
  591. }
  592. }
  593. }
  594. .page-wrap {
  595. text-align: right;
  596. float: none;
  597. }
  598. }
  599. </style>