PublishApply.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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" />
  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" />
  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" />
  45. </div>
  46. <div class="form-item">
  47. <span>
  48. 生产日期:
  49. </span>
  50. <input type="text" class="form-control" v-model="applyObj.produceDate" />
  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" @input="onAmountInput" />
  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. size="mini">
  69. </el-date-picker>
  70. </div>
  71. </div>
  72. <a @click="goPublish()">发布求购</a>
  73. </div>
  74. <div class="publish-upload">
  75. <h1>批量发布</h1>
  76. <h2>3秒一键配单采购</h2>
  77. <img src="/images/applyPurchase/upload.png" alt="" />
  78. <h3>把Excel格式的BOM拖放到框中</h3>
  79. <img class="download-line" src="/images/applyPurchase/download.png" alt="">
  80. <img class="apply-logo" src="/images/applyPurchase/publish-apply.png" alt="">
  81. </div>
  82. </div>
  83. <div class="apply-rank">
  84. <table>
  85. <thead>
  86. <tr>
  87. <th width="62">排名</th>
  88. <th width="124">求购型号</th>
  89. <th width="57">数量</th>
  90. <th width="72">求购次数</th>
  91. </tr>
  92. </thead>
  93. <tbody>
  94. <tr v-for="(rank, index) in purchaseRank">
  95. <td><div>NO.<span>{{index + 1}}</span><i>|</i></div></td>
  96. <td :title="rank.spCode"><div><span>{{rank.spCode}}</span><i>|</i></div></td>
  97. <td :title="rank.spAmount"><div><span>{{rank.spAmount}}</span><i>|</i></div></td>
  98. <td :title="rank.uuAmount"><div>{{rank.uuAmount}}</div></td>
  99. </tr>
  100. </tbody>
  101. </table>
  102. </div>
  103. </div>
  104. </template>
  105. <script>
  106. export default {
  107. data () {
  108. return {
  109. applyObj: {
  110. code: '',
  111. brand: '',
  112. unitPrice: '',
  113. currency: 'RMB',
  114. encapsulation: '',
  115. produceDate: '',
  116. amount: '',
  117. deadline: ''
  118. },
  119. validObj: {
  120. code: true,
  121. brand: true,
  122. unitPrice: true,
  123. // encapsulation: true,
  124. // produceDate: true,
  125. amount: true
  126. // deadline: true
  127. },
  128. pickerOptions: {
  129. disabledDate (time) {
  130. // 大于等于今天 小于三个月后
  131. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24 || time.getTime() > Date.now() + 1000 * 60 * 60 * 24 * 30 * 3
  132. }
  133. }
  134. }
  135. },
  136. computed: {
  137. goodPurchaseMan () {
  138. return this.$store.state.applyPurchase.goodPurchaseMan.goodPurchaseMan.data
  139. },
  140. purchaseRank () {
  141. return this.$store.state.applyPurchase.purchaseApplyRank.purchaseApplyRank.data
  142. }
  143. },
  144. methods: {
  145. emptyForm: function () {
  146. for (let attr in this.applyObj) {
  147. this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
  148. }
  149. },
  150. getRankBg: function (index) {
  151. return index === 0 ? 1 : index < 3 ? 2 : 3
  152. },
  153. goPublish: function () {
  154. if (this.checkAll()) {
  155. this.$http.post('/seek/saveOneSeekPurchase', this.applyObj)
  156. .then(response => {
  157. this.$message.success('发布成功')
  158. this.emptyForm()
  159. this.$store.dispatch('applyPurchase/loadPurchaseManList', {page: 1, count: 10})
  160. }, error => {
  161. console.log(error)
  162. this.$message.error('发布失败')
  163. })
  164. } else {
  165. this.$message.error('请填写正确的信息')
  166. }
  167. },
  168. checkCode: function () {
  169. this.validObj.code = this.applyObj.code && this.applyObj.code !== ''
  170. return this.validObj.code
  171. },
  172. checkBrand: function () {
  173. this.validObj.brand = this.applyObj.brand && this.applyObj.brand !== ''
  174. return this.validObj.brand
  175. },
  176. checkUnitPrice: function () {
  177. this.validObj.unitPrice = this.applyObj.unitPrice === '' ? true : this.applyObj.unitPrice > 0 && this.applyObj.unitPrice < 100000000
  178. return this.validObj.unitPrice
  179. },
  180. // checkEncapsulation: function () {
  181. // this.validObj.encapsulation = this.applyObj.encapsulation && this.applyObj.encapsulation !== ''
  182. // },
  183. // checkProduceDate: function () {
  184. // this.validObj.produceDate = this.applyObj.produceDate && this.applyObj.produceDate !== ''
  185. // },
  186. checkAmount: function () {
  187. this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 100000000
  188. return this.validObj.amount
  189. },
  190. checkAll: function () {
  191. return this.checkCode() && this.checkBrand() && this.checkUnitPrice() && this.checkAmount() && this.checkDeadline()
  192. },
  193. checkDeadline: function () {
  194. this.validObj.deadline = this.applyObj.deadline && this.applyObj.deadline !== ''
  195. return this.validObj.deadline
  196. },
  197. onUnitPriceInput: function () {
  198. if (this.applyObj.unitPrice < 0) {
  199. this.applyObj.unitPrice = 0
  200. } else if (this.applyObj.unitPrice.toString().indexOf('.') !== -1 && this.applyObj.unitPrice.toString().split('.')[1].length > 6) {
  201. this.applyObj.unitPrice = Number(this.applyObj.unitPrice).toFixed(6)
  202. }
  203. },
  204. onAmountInput: function () {
  205. if (this.applyObj.amount < 0) {
  206. this.applyObj.amount = 0
  207. }
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="scss" scoped>
  213. .publish-apply {
  214. background: url('/images/applyPurchase/banner.png') center center/cover no-repeat;
  215. height: 583px;
  216. text-align: center;
  217. padding-top: 290px;
  218. >div {
  219. display: inline-block;
  220. border: 1px solid #3975f4;
  221. height: 267px;
  222. margin-right: 6px;
  223. vertical-align: middle;
  224. background: #fff;
  225. }
  226. .good-purchaser {
  227. width: 225px;
  228. .good-purchaser-title {
  229. height: 55px;
  230. line-height: 55px;
  231. background: #3975f4;
  232. margin: 0;
  233. }
  234. ul {
  235. padding: 0 22px 0 10px;
  236. li {
  237. line-height: 42px;
  238. span {
  239. float: right;
  240. display: inline-block;
  241. width: 152px;
  242. overflow: hidden;
  243. text-overflow: ellipsis;
  244. white-space: nowrap;
  245. }
  246. i {
  247. display: inline-block;
  248. float: left;
  249. width: 25px;
  250. color: #fff;
  251. font-size: 16px;
  252. font-style: normal;
  253. }
  254. }
  255. }
  256. }
  257. .publish-area {
  258. width: 549px;
  259. .publish-form-area {
  260. width: 243px;
  261. float: left;
  262. height: 100%;
  263. p {
  264. padding-top: 18px;
  265. font-size: 26px;
  266. color: #3975f4;
  267. margin-bottom: 7px;
  268. }
  269. >div {
  270. text-align: left;
  271. margin-left: 14px;
  272. .form-item {
  273. margin-bottom: 5px;
  274. span {
  275. width: 80px;
  276. text-align: right;
  277. display: inline-block;
  278. i {
  279. position: relative;
  280. top: 2px;
  281. right: 3px;
  282. color: #e41515;
  283. }
  284. }
  285. select {
  286. width: 32px;
  287. position: absolute;
  288. height: 20px;
  289. background: url('/images/applyPurchase/select.png')no-repeat right;
  290. & + input {
  291. padding-left: 34px;
  292. }
  293. }
  294. input {
  295. width: 111px;
  296. height: 20px;
  297. line-height: 20px;
  298. border-radius: 2px;
  299. padding: 0 3px;
  300. box-shadow: none;
  301. -webkit-box-shadow: none;
  302. -moz-box-shadow: none;
  303. &.error {
  304. border-color: #f4645f!important;
  305. }
  306. }
  307. }
  308. }
  309. >a {
  310. width: 90px;
  311. height: 25px;
  312. line-height: 25px;
  313. background: #3975f4;
  314. color: #fefefe;
  315. font-size: 16px;
  316. display: block;
  317. margin: 0 auto;
  318. border-radius: 3px;
  319. cursor: pointer;
  320. }
  321. }
  322. .publish-upload {
  323. background: url('/images/applyPurchase/publish-apply-bg.png')no-repeat;
  324. background-size: cover;
  325. width: 304px;
  326. height: 100%;
  327. padding-left: 22px;
  328. float: right;
  329. color: #fff;
  330. position: relative;
  331. h1 {
  332. font-size: 26px;
  333. margin: 22px 0 0 0;
  334. }
  335. h2 {
  336. font-size: 16px;
  337. margin: 10px 0 23px 0;
  338. }
  339. h3 {
  340. font-size: 16px;
  341. margin: 20px 0 13px 0;
  342. }
  343. .download-line {
  344. cursor: pointer;
  345. }
  346. .apply-logo {
  347. position: absolute;
  348. left: -20px;
  349. top: 86px;
  350. }
  351. }
  352. }
  353. .apply-rank {
  354. width: 317px;
  355. margin-right: 0;
  356. background: url('/images/applyPurchase/rank-title.png') no-repeat;
  357. background-color: #fff;
  358. background-size: 319px 74px;
  359. background-position: -3px -2px;
  360. table {
  361. margin: 76px auto 0;
  362. width: 98%;
  363. thead {
  364. background: #e0e0e0;
  365. height: 26px;
  366. line-height: 26px;
  367. border-radius: 3px;
  368. tr {
  369. th {
  370. font-size: 16px;
  371. font-weight: bold;
  372. text-align: center;
  373. }
  374. }
  375. }
  376. tbody {
  377. tr {
  378. height: 25px;
  379. line-height: 25px;
  380. &:first-child {
  381. td {
  382. padding-top: 10px;
  383. }
  384. }
  385. td {
  386. &:nth-child(1) {
  387. color: #f6682f;
  388. font-size: 12px;
  389. >div {
  390. width: 62px;
  391. span {
  392. font-size: 16px;
  393. }
  394. }
  395. }
  396. &:nth-child(2) {
  397. >div {
  398. width: 122px;
  399. }
  400. }
  401. &:nth-child(3) {
  402. >div {
  403. width: 55px;
  404. }
  405. }
  406. &:nth-child(4) {
  407. >div {
  408. width: 72px;
  409. }
  410. }
  411. >div {
  412. overflow: hidden;
  413. text-overflow: ellipsis;
  414. white-space: nowrap;
  415. padding: 0 8px;
  416. position: relative;
  417. i {
  418. font-style: normal;
  419. float: right;
  420. color: #8b8b8b;
  421. font-size: 14px;
  422. position: absolute;
  423. right: 0;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. .el-date-editor--date{
  433. width: 110px;
  434. &.error {
  435. input {
  436. border: 1px solid #f4645f !important;
  437. }
  438. }
  439. }
  440. .el-icon-date {
  441. display: none;
  442. }
  443. .el-input__inner {
  444. height: 20px;
  445. border-radius: 0;
  446. border: 1px solid #c9c9c9;
  447. }
  448. </style>