SayPrice.vue 8.9 KB

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