SayPrice.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div class="say-price">
  3. <div class="base-info">
  4. <div class="content-line">
  5. 型号:<span>{{purchaseDetail.cmpCode || '-'}}</span>
  6. </div>
  7. <div class="content-line">
  8. 品牌:<span>{{purchaseDetail.inbrand || '-'}}</span>
  9. </div>
  10. <div class="content-line">
  11. 规格:<span>{{purchaseDetail.spec || '-'}}</span>
  12. </div>
  13. <div class="content-line">
  14. 采购数量:<span>{{purchaseDetail.offerAmount || '-'}}</span>
  15. </div>
  16. <div class="content-line">
  17. 币种:<span>{{purchaseDetail.currency || '不限'}}</span>
  18. </div>
  19. <div class="content-line">
  20. 截止日期:<span>{{purchaseDetail.endDate | date}}</span>
  21. </div>
  22. </div>
  23. <div class="form-list">
  24. <div class="form-title">
  25. <span class="fl">价格梯度<span>(PCS)</span></span>
  26. <span class="fr">
  27. <span v-text="sayPriceObj.currency" @click="showCurrencyList = !showCurrencyList"></span>
  28. <img v-if="!showCurrencyList" src="/images/mobile/@2x/applyPurchase/currency-arrow-down.png" alt="">
  29. <img v-if="showCurrencyList" src="/images/mobile/@2x/applyPurchase/currency-arrow-up.png" alt="">
  30. <ul v-if="showCurrencyList">
  31. <li @click="setCurrency('RMB')">RMB</li>
  32. <li @click="setCurrency('USD')">USD</li>
  33. </ul>
  34. </span>
  35. </div>
  36. <div class="form-item" v-for="(reply, index) in sayPriceObj.replies">
  37. <input type="number" placeholder="梯度" class="fl" v-model="reply.lapQty">
  38. <input type="number" placeholder="单价" class="fr" v-model="reply.price">
  39. <i class="iconfont icon-minus" v-if="sayPriceObj.replies.length > 1" @click="setReplies('sub', index)"></i>
  40. <i class="iconfont icon-add" v-if="sayPriceObj.replies.length < 5 && index == sayPriceObj.replies.length - 1" @click="setReplies('add', index)"></i>
  41. </div>
  42. <div class="date">
  43. <span>交期(天)</span>
  44. <input type="number" placeholder="最大值" v-model="sayPriceObj.leadtime" class="fr">
  45. </div>
  46. <a class="say-price-btn" @click="commitSayPrice">确定</a>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. export default {
  52. data () {
  53. return {
  54. showCurrencyList: false,
  55. sayPriceObj: {
  56. currency: 'RMB',
  57. leadtime: '',
  58. replies: [
  59. {
  60. lapQty: '',
  61. price: ''
  62. }
  63. ]
  64. }
  65. }
  66. },
  67. filters: {
  68. date: function (date) {
  69. if (date) {
  70. const d = new Date(Number(date))
  71. const year = d.getFullYear()
  72. const monthTemp = d.getMonth() + 1
  73. const month = monthTemp < 10 ? '0' + monthTemp : '' + monthTemp
  74. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate() + ' '
  75. return year + '-' + month + '-' + day
  76. } else {
  77. return '-'
  78. }
  79. }
  80. },
  81. computed: {
  82. purchaseDetail () {
  83. return this.$store.state.applyPurchase.purchaseManList.purchaseManDetail.data
  84. },
  85. user () {
  86. return this.$store.state.option.user
  87. }
  88. },
  89. methods: {
  90. setCurrency: function (type) {
  91. this.sayPriceObj.currency = type
  92. this.showCurrencyList = false
  93. },
  94. resetSayPrice: function () {
  95. this.sayPriceObj = {
  96. currency: 'RMB',
  97. leadtime: '',
  98. replies: [
  99. {
  100. lapQty: '',
  101. price: ''
  102. }
  103. ]
  104. }
  105. },
  106. setReplies: function (type, index) {
  107. if (type === 'add' && this.sayPriceObj.replies.length < 5) {
  108. if (this.sayPriceObj.replies[index].lapQty && this.sayPriceObj.replies[index].price) {
  109. this.sayPriceObj.replies.splice(index + 1, 0, {
  110. lapQty: '',
  111. price: ''
  112. })
  113. } else {
  114. this.$message.error('请填完整信息')
  115. }
  116. } else if (type === 'sub' && this.sayPriceObj.replies.length > 1) {
  117. this.sayPriceObj.replies.splice(index, 1)
  118. }
  119. },
  120. commitSayPrice: function () {
  121. if (this.checkValid()) {
  122. let purchaseMan = this.purchaseDetail
  123. // this.showLoading = true
  124. purchaseMan.leadtime = this.sayPriceObj.leadtime
  125. purchaseMan.replies = this.sayPriceObj.replies
  126. purchaseMan.vendUU = this.user.data.enterprise.uu
  127. purchaseMan.vendorUserUU = this.user.data.userUU
  128. purchaseMan.qutoApp = 'MALL'
  129. if (!purchaseMan.currency) {
  130. purchaseMan.currency = this.sayPriceObj.currency
  131. }
  132. this.$http.post('/inquiry/sale/item/save', purchaseMan).then(response => {
  133. this.showLoading = false
  134. if (response.data.success === false) {
  135. this.$message.error(response.data.message)
  136. } else {
  137. this.$message.success('报价成功')
  138. this.resetSayPrice()
  139. }
  140. }, error => {
  141. console.log(error)
  142. this.$message.error('请勿重复报价或报价自己的求购')
  143. // this.showLoading = false
  144. })
  145. } else {
  146. this.$message.error('请输入正确的报价信息')
  147. }
  148. },
  149. checkValid: function () {
  150. for (let i = 0; i < this.sayPriceObj.replies.length; i++) {
  151. if (!this.sayPriceObj.replies[i].lapQty || !this.sayPriceObj.replies[i].price) {
  152. return false
  153. }
  154. }
  155. return this.sayPriceObj.leadtime
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .say-price {
  162. background: #f3f3f3;
  163. padding: .18rem 0;
  164. position: absolute;
  165. top: .88rem;
  166. bottom: 1rem;
  167. width: 100%;
  168. overflow-y: auto;
  169. .form-list {
  170. height: 7.53rem;
  171. background: #fff;
  172. padding-top: .2rem;
  173. > div {
  174. height: .7rem;
  175. line-height: .7rem;
  176. width: 6.12rem;
  177. font-size: .28rem;
  178. margin: 0 auto .2rem;
  179. input {
  180. height: .7rem;
  181. text-align: center;
  182. border: .01rem solid #666;
  183. border-radius: .05rem;
  184. }
  185. &.form-title {
  186. border: .01rem solid #666;
  187. border-radius: .05rem;
  188. padding: 0 .07rem 0 .17rem;
  189. .fl {
  190. span {
  191. color: #666;
  192. }
  193. }
  194. .fr {
  195. position: relative;
  196. img {
  197. width: .12rem;
  198. height: .06rem;
  199. margin-left: .04rem;
  200. }
  201. > ul {
  202. position: absolute;
  203. top: .6rem;
  204. right: -.4rem;
  205. z-index: 1;
  206. width: 1.75rem;
  207. background: #fff;
  208. text-align: center;
  209. border-radius: .1rem;
  210. border: .01rem solid #dfdfdf;
  211. -webkit-box-shadow: 0 0 .12rem .02rem #e2d9d975;
  212. -moz-box-shadow: 0 0 .12rem .02rem #e2d9d975;
  213. box-shadow: 0 0 .12rem .02rem #e2d9d975;
  214. li {
  215. height: .52rem;
  216. line-height: .52rem;
  217. border-bottom: .01rem solid #dfdfdf;
  218. &:hover, &:active {
  219. background: #dedede;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. &.form-item {
  226. position: relative;
  227. input {
  228. width: 2.93rem;
  229. }
  230. i {
  231. position: absolute;
  232. right: -.32rem;
  233. top: 0;
  234. font-size: .3rem;
  235. & + i {
  236. right: -.65rem;
  237. }
  238. &.icon-add {
  239. color: #4768f3;
  240. }
  241. &.icon-minus {
  242. color: #8d8d8d;
  243. }
  244. }
  245. }
  246. &.date {
  247. input {
  248. width: 4.8rem;
  249. }
  250. }
  251. }
  252. }
  253. }
  254. </style>