ApplyInfo.vue 18 KB

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