PublishApply.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <div class="publish-apply">
  3. <div class="good-purchaser">
  4. <p class="good-purchaser-title">
  5. <img src="/images/applyPurchase/good-purchaser-title.png" alt="">
  6. </p>
  7. <ul>
  8. <li v-for="(goodMan, index) in goodPurchaseMan.content">
  9. <i v-text="index + 1" :style="'background: url(/images/applyPurchase/level-' + getRankBg(index) + '.png) center no-repeat;'"></i>
  10. <span v-text="goodMan.name"></span>
  11. </li>
  12. </ul>
  13. </div>
  14. <div class="publish-area">
  15. <div class="publish-form-area">
  16. <p>单个发布</p>
  17. <div>
  18. <div class="form-item">
  19. <span>
  20. <i>*</i>型号:
  21. </span>
  22. <input type="text" class="form-control" :class="{'error': !validObj.code}" v-model="applyObj.code" maxlength="30" @blur="checkCode" @input="onCodeChange" />
  23. </div>
  24. <div class="form-item">
  25. <span>
  26. <i>*</i>品牌:
  27. </span>
  28. <input type="text" class="form-control" :class="{'error': !validObj.brand}" maxlength="20" v-model="applyObj.brand" @blur="checkBrand" @input="onBrandChange" />
  29. </div>
  30. <div class="form-item">
  31. <span>
  32. 单价预算:
  33. </span>
  34. <select v-model="applyObj.currency">
  35. <option value="RMB">¥</option>
  36. <option value="USD">$</option>
  37. </select>
  38. <input type="number" class="form-control" :class="{'error': !validObj.unitPrice}" v-model="applyObj.unitPrice" @blur="checkUnitPrice" @input="onUnitPriceInput" />
  39. </div>
  40. <div class="form-item">
  41. <span>
  42. 封装:
  43. </span>
  44. <input type="text" class="form-control" maxlength="20" v-model="applyObj.encapsulation" @input="onEncapsulationChange" />
  45. </div>
  46. <div class="form-item">
  47. <span>
  48. 生产日期:
  49. </span>
  50. <input type="text" class="form-control" v-model="applyObj.produceDate" @input="onProduceDateChange" />
  51. </div>
  52. <div class="form-item">
  53. <span>
  54. 采购数量:
  55. </span>
  56. <input type="number" class="form-control" :class="{'error': !validObj.amount}" v-model="applyObj.amount" @blur="checkAmount" />
  57. </div>
  58. <div class="form-item">
  59. <span>
  60. <i>*</i>截止日期:
  61. </span>
  62. <!--<input type="text" class="form-control" readonly :class="{'error': !validObj.deadline}" v-model="applyObj.deadline" @blur="checkDeadline" />-->
  63. <el-date-picker
  64. v-model="applyObj.deadline"
  65. type="date"
  66. :picker-options="pickerOptions"
  67. :class="{'error': !validObj.deadline}"
  68. @change="checkDeadline"
  69. size="mini">
  70. </el-date-picker>
  71. </div>
  72. </div>
  73. <a @click="goPublish()">发布求购</a>
  74. </div>
  75. <div class="publish-upload">
  76. <h1>批量发布</h1>
  77. <h2>3秒一键配单采购</h2>
  78. <img src="/images/applyPurchase/upload.png" alt="" />
  79. <h3>把Excel格式的BOM拖放到框中</h3>
  80. <img class="download-line" src="/images/applyPurchase/download.png" alt="">
  81. <img class="apply-logo" src="/images/applyPurchase/publish-apply.png" alt="">
  82. </div>
  83. </div>
  84. <div class="apply-rank">
  85. <table>
  86. <thead>
  87. <tr>
  88. <th width="62">排名</th>
  89. <th width="124">求购型号</th>
  90. <th width="57">数量</th>
  91. <th width="72">求购次数</th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. <tr v-for="(rank, index) in purchaseRank">
  96. <td><div>NO.<span>{{index + 1}}</span><i>|</i></div></td>
  97. <td :title="rank.spCode"><div><span>{{rank.spCode}}</span><i>|</i></div></td>
  98. <td :title="rank.spAmount"><div><span>{{rank.spAmount}}</span><i>|</i></div></td>
  99. <td :title="rank.uuAmount"><div>{{rank.uuAmount}}</div></td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. </div>
  104. <!--提示框-->
  105. <div class="com-del-box" v-if="showRemindBox">
  106. <div class="title">
  107. <a @click="showRemindBox = false"><i class="fa fa-close fa-lg"></i></a>
  108. </div>
  109. <div class="content">
  110. <!--<p style="line-height: 20px;margin-top: 10px;padding:0 10px">非常抱歉,目前暂无此品牌!<br>若直接前往“品牌申请”,我们将为您先开通寄售功能,待申请通过后再提交开店申请。</p>-->
  111. <!--<p style="line-height: 20px;">前往<a @click="goBrandApply()" target="_blank" style="color: #5078CB">品牌申请&nbsp;<i class="fa fa-arrow-right"></i></a></p>-->
  112. <p><img src="/images/applyPurchase/check.png" alt="">发布成功</p>
  113. <p>其中 <span>100</span>个求购型号有现货在售,您可前往“<span>买家中心-我的求购</span>”查询并直接购买</p>
  114. <div>
  115. <a @click="showRemindBox = false">我知道了</a>
  116. <a href="javascript:void(0)">前往我的求购</a>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </template>
  122. <script>
  123. let getRealLen = function (str) {
  124. let len = 0
  125. for (let i = 0; i < str.length; i++) {
  126. if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
  127. len += 2
  128. } else {
  129. len++
  130. }
  131. }
  132. return len
  133. }
  134. export default {
  135. data () {
  136. return {
  137. applyObj: {
  138. code: '',
  139. brand: '',
  140. unitPrice: '',
  141. currency: 'RMB',
  142. encapsulation: '',
  143. produceDate: '',
  144. amount: '',
  145. deadline: ''
  146. },
  147. validObj: {
  148. code: true,
  149. brand: true,
  150. unitPrice: true,
  151. // encapsulation: true,
  152. // produceDate: true,
  153. amount: true
  154. // deadline: true,
  155. },
  156. pickerOptions: {
  157. disabledDate (time) {
  158. // 大于等于今天 小于三个月后
  159. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
  160. }
  161. },
  162. showRemindBox: false
  163. }
  164. },
  165. computed: {
  166. goodPurchaseMan () {
  167. return this.$store.state.applyPurchase.goodPurchaseMan.goodPurchaseMan.data
  168. },
  169. purchaseRank () {
  170. return this.$store.state.applyPurchase.purchaseApplyRank.purchaseApplyRank.data
  171. },
  172. user () {
  173. return this.$store.state.option.user
  174. }
  175. },
  176. methods: {
  177. emptyForm: function () {
  178. for (let attr in this.applyObj) {
  179. this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
  180. }
  181. },
  182. getRankBg: function (index) {
  183. return index === 0 ? 1 : index < 3 ? 2 : 3
  184. },
  185. goPublish: function () {
  186. if (this.user.logged) {
  187. if (this.checkAll()) {
  188. this.$http.post('/seek/saveOneSeekPurchase', this.applyObj)
  189. .then(response => {
  190. this.$message.success('发布成功')
  191. // this.showRemindBox = true
  192. this.emptyForm()
  193. this.$store.dispatch('applyPurchase/loadPurchaseManList', {page: 1, count: 10})
  194. }, error => {
  195. console.log(error)
  196. this.$message.error('发布失败')
  197. })
  198. } else {
  199. if (!this.validObj.code) {
  200. this.$message.error('型号不能为空')
  201. } else if (!this.validObj.brand) {
  202. this.$message.error('品牌不能为空')
  203. } else if (!this.validObj.deadline) {
  204. this.$message.error('截止日期不能为空')
  205. } else if (!this.validObj.amount || !this.validObj.unitPrice) {
  206. this.$message.error('请输入正确的数值')
  207. }
  208. // this.$message.error('请填写正确的信息')
  209. }
  210. } else {
  211. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  212. }
  213. },
  214. checkCode: function () {
  215. this.validObj.code = this.applyObj.code && this.applyObj.code !== ''
  216. return this.validObj.code
  217. },
  218. checkBrand: function () {
  219. this.validObj.brand = this.applyObj.brand && this.applyObj.brand !== ''
  220. return this.validObj.brand
  221. },
  222. checkUnitPrice: function () {
  223. this.validObj.unitPrice = this.applyObj.unitPrice === '' ? true : this.applyObj.unitPrice > 0 && this.applyObj.unitPrice < 100000000
  224. return this.validObj.unitPrice
  225. },
  226. // checkEncapsulation: function () {
  227. // this.validObj.encapsulation = this.applyObj.encapsulation && this.applyObj.encapsulation !== ''
  228. // },
  229. // checkProduceDate: function () {
  230. // this.validObj.produceDate = this.applyObj.produceDate && this.applyObj.produceDate !== ''
  231. // },
  232. checkAmount: function () {
  233. this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 100000000
  234. return this.validObj.amount
  235. },
  236. checkAll: function () {
  237. return this.checkCode() && this.checkBrand() && this.checkUnitPrice() && this.checkAmount() && this.checkDeadline()
  238. },
  239. checkDeadline: function () {
  240. this.validObj.deadline = this.applyObj.deadline && this.applyObj.deadline !== ''
  241. return this.validObj.deadline
  242. },
  243. onUnitPriceInput: function () {
  244. let price = this.applyObj.unitPrice
  245. if (price >= 9999) {
  246. this.applyObj.unitPrice = price.substring(0, 4)
  247. } else if (price.indexOf('.') > -1) {
  248. let arr = price.split('.')
  249. if (arr[0].length > 4) {
  250. this.applyObj.unitPrice = Number(arr[0].substring(0, 4) + '.' + arr[1])
  251. } else if (arr[1].length > 6) {
  252. this.applyObj.unitPrice = Number(arr[0] + '.' + arr[1].substring(0, 6))
  253. }
  254. }
  255. },
  256. onProduceDateChange: function () {
  257. if (this.applyObj.produceDate && getRealLen(this.applyObj.produceDate) > 12) {
  258. this.applyObj.produceDate = this.applyObj.produceDate.substring(0, this.applyObj.produceDate.length - 1)
  259. }
  260. },
  261. onEncapsulationChange: function () {
  262. if (this.applyObj.encapsulation && getRealLen(this.applyObj.encapsulation) > 20) {
  263. this.applyObj.encapsulation = this.applyObj.encapsulation.substring(0, this.applyObj.encapsulation.length - 1)
  264. }
  265. },
  266. onCodeChange: function () {
  267. if (this.applyObj.code && getRealLen(this.applyObj.code) > 30) {
  268. this.applyObj.code = this.applyObj.code.substring(0, this.applyObj.code.length - 1)
  269. }
  270. },
  271. onBrandChange: function () {
  272. if (this.applyObj.brand && getRealLen(this.applyObj.brand) > 20) {
  273. this.applyObj.brand = this.applyObj.brand.substring(0, this.applyObj.brand.length - 1)
  274. }
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss" scoped>
  280. .publish-apply {
  281. background: url('/images/applyPurchase/banner.png') center center/cover no-repeat;
  282. height: 583px;
  283. text-align: center;
  284. padding-top: 290px;
  285. >div {
  286. display: inline-block;
  287. border: 1px solid #3975f4;
  288. height: 267px;
  289. margin-right: 6px;
  290. vertical-align: middle;
  291. background: #fff;
  292. }
  293. .good-purchaser {
  294. width: 225px;
  295. .good-purchaser-title {
  296. height: 55px;
  297. line-height: 55px;
  298. background: #3975f4;
  299. margin: 0;
  300. }
  301. ul {
  302. padding: 0 22px 0 10px;
  303. li {
  304. line-height: 42px;
  305. span {
  306. float: right;
  307. display: inline-block;
  308. width: 152px;
  309. overflow: hidden;
  310. text-overflow: ellipsis;
  311. white-space: nowrap;
  312. text-align: left;
  313. }
  314. i {
  315. display: inline-block;
  316. float: left;
  317. width: 25px;
  318. color: #fff;
  319. font-size: 16px;
  320. font-style: normal;
  321. }
  322. }
  323. }
  324. }
  325. .publish-area {
  326. width: 549px;
  327. .publish-form-area {
  328. width: 243px;
  329. float: left;
  330. height: 100%;
  331. p {
  332. padding-top: 18px;
  333. font-size: 26px;
  334. color: #3975f4;
  335. margin-bottom: 7px;
  336. }
  337. >div {
  338. text-align: left;
  339. margin-left: 14px;
  340. .form-item {
  341. margin-bottom: 5px;
  342. span {
  343. width: 80px;
  344. text-align: right;
  345. display: inline-block;
  346. i {
  347. position: relative;
  348. top: 2px;
  349. right: 3px;
  350. color: #e41515;
  351. }
  352. }
  353. select {
  354. width: 32px;
  355. position: absolute;
  356. height: 20px;
  357. background: url('/images/applyPurchase/select.png')no-repeat right;
  358. background-position-x: 15px;
  359. padding: 0 0 0 3px;
  360. & + input {
  361. padding-left: 34px;
  362. }
  363. }
  364. input {
  365. width: 111px;
  366. height: 20px;
  367. line-height: 20px;
  368. border-radius: 2px;
  369. padding: 0 3px;
  370. box-shadow: none;
  371. -webkit-box-shadow: none;
  372. -moz-box-shadow: none;
  373. &.error {
  374. border-color: #f4645f!important;
  375. }
  376. }
  377. }
  378. }
  379. >a {
  380. width: 90px;
  381. height: 25px;
  382. line-height: 25px;
  383. background: #3975f4;
  384. color: #fefefe;
  385. font-size: 16px;
  386. display: block;
  387. margin: 0 auto;
  388. border-radius: 3px;
  389. cursor: pointer;
  390. }
  391. }
  392. .publish-upload {
  393. background: url('/images/applyPurchase/publish-apply-bg.png')no-repeat;
  394. background-size: cover;
  395. width: 304px;
  396. height: 100%;
  397. padding-left: 22px;
  398. float: right;
  399. color: #fff;
  400. position: relative;
  401. h1 {
  402. font-size: 26px;
  403. margin: 22px 0 0 0;
  404. }
  405. h2 {
  406. font-size: 16px;
  407. margin: 10px 0 23px 0;
  408. }
  409. h3 {
  410. font-size: 16px;
  411. margin: 20px 0 13px 0;
  412. }
  413. .download-line {
  414. cursor: pointer;
  415. }
  416. .apply-logo {
  417. position: absolute;
  418. left: -20px;
  419. top: 86px;
  420. }
  421. }
  422. }
  423. .apply-rank {
  424. width: 317px;
  425. margin-right: 0;
  426. background: url('/images/applyPurchase/rank-title.png') no-repeat;
  427. background-color: #fff;
  428. background-size: 319px 74px;
  429. background-position: -3px -2px;
  430. table {
  431. margin: 76px auto 0;
  432. width: 98%;
  433. thead {
  434. background: #e0e0e0;
  435. height: 26px;
  436. line-height: 26px;
  437. border-radius: 3px;
  438. tr {
  439. th {
  440. font-size: 16px;
  441. font-weight: bold;
  442. text-align: center;
  443. }
  444. }
  445. }
  446. tbody {
  447. tr {
  448. height: 25px;
  449. line-height: 25px;
  450. &:first-child {
  451. td {
  452. padding-top: 10px;
  453. }
  454. }
  455. td {
  456. color: #666;
  457. &:nth-child(1) {
  458. color: #f6682f;
  459. font-size: 12px;
  460. >div {
  461. width: 62px;
  462. span {
  463. font-size: 16px;
  464. }
  465. }
  466. }
  467. &:nth-child(2) {
  468. >div {
  469. width: 122px;
  470. }
  471. }
  472. &:nth-child(3) {
  473. >div {
  474. width: 55px;
  475. }
  476. }
  477. &:nth-child(4) {
  478. >div {
  479. width: 72px;
  480. }
  481. }
  482. >div {
  483. overflow: hidden;
  484. text-overflow: ellipsis;
  485. white-space: nowrap;
  486. padding: 0 8px;
  487. position: relative;
  488. height: 30px;
  489. i {
  490. font-style: normal;
  491. float: right;
  492. color: #8b8b8b;
  493. font-size: 14px;
  494. position: absolute;
  495. right: 0;
  496. }
  497. }
  498. }
  499. }
  500. }
  501. }
  502. }
  503. .com-del-box{
  504. position: fixed;
  505. z-index: 1000;
  506. height: auto;
  507. opacity: 1;
  508. background-color: white;
  509. width: 310px;
  510. -webkit-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  511. -moz-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  512. -o-box-shadow: 0 5px 15px rgba(0,0,0,.5);
  513. box-shadow: 0 5px 15px rgba(0,0,0,.5);
  514. margin: -155px 0 0 -75px;
  515. top: 55%;
  516. left: 43%;
  517. .title{
  518. height: 24px;
  519. background-color: #007aff;
  520. text-align: right;
  521. padding-right: 15px;
  522. line-height: 24px;
  523. a{
  524. color: white;
  525. font-size: 12px;
  526. }
  527. }
  528. .content{
  529. width: 100%;
  530. text-align: center;
  531. margin: 0 auto;
  532. p{
  533. padding: 12px 31px;
  534. margin: 0;
  535. i{
  536. color: #5078cb;
  537. font-size: 16px;
  538. margin-right: 10px;
  539. }
  540. span {
  541. color: #007aff;
  542. }
  543. &:last-child {
  544. font-size: 12px;
  545. }
  546. }
  547. div{
  548. width: 100%;
  549. text-align: center;
  550. margin: 0 auto 20px;
  551. a{
  552. padding: 0 19px;
  553. height: 26px;
  554. line-height: 26px;
  555. display: inline-block;
  556. text-align: center;
  557. font-size: 14px;
  558. color: #fff;
  559. &:first-child{
  560. background: #c8c6c6;
  561. margin-right: 10px;
  562. }
  563. &:last-child{
  564. background: #007aff;
  565. }
  566. }
  567. }
  568. }
  569. }
  570. }
  571. .el-date-editor--date{
  572. width: 110px;
  573. &.error {
  574. input {
  575. border: 1px solid #f4645f !important;
  576. }
  577. }
  578. }
  579. .el-icon-date {
  580. display: none;
  581. }
  582. .el-input__inner {
  583. height: 20px;
  584. border-radius: 0;
  585. border: 1px solid #c9c9c9;
  586. }
  587. </style>