PublishSeek.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div class="mobile-modal" v-if="showSayPriceBox">
  3. <div class="mobile-modal-box">
  4. <div class="mobile-modal-header">发布求购<i class="icon-guanbi iconfont" @click="cancel"></i></div>
  5. <div class="publish-seek">
  6. <div class="content-line">
  7. <span><i>*</i>型号:</span>
  8. <input type="text" v-model="applyObj.code" placeholder="请勿填中文符号">
  9. </div>
  10. <div class="content-line">
  11. <span><i>*</i>品牌:</span>
  12. <input type="text" v-model="applyObj.brand" placeholder="请勿填中文符号">
  13. </div>
  14. <div class="content-line">
  15. <span><i>*</i>截止日期:</span>
  16. <input type="text" v-model="applyObj.deadline" @blur="formatDeadLine" placeholder="如2017-02-11">
  17. </div>
  18. <div class="content-line">
  19. <span>币种:</span>
  20. <a v-text="applyObj.currency" @click="showCurrencyList = !showCurrencyList"></a>
  21. <img v-if="!showCurrencyList" src="/images/mobile/@2x/applyPurchase/currency-arrow-down.png" alt="">
  22. <img v-if="showCurrencyList" src="/images/mobile/@2x/applyPurchase/currency-arrow-up.png" alt="">
  23. <ul v-if="showCurrencyList">
  24. <li @click="setCurrency('RMB')">RMB</li>
  25. <li @click="setCurrency('USD')">USD</li>
  26. </ul>
  27. </div>
  28. <div class="content-line">
  29. <span>数量:</span>
  30. <input type="text" v-model="applyObj.amount">
  31. </div>
  32. <div class="content-line">
  33. <span>生产日期:</span>
  34. <input type="text" v-model="applyObj.produceDate">
  35. </div>
  36. <a @click="goPublish">确认发布</a>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. let formatDate = function (date, fmt) {
  43. if (typeof date === 'string') {
  44. date = new Date(Date.parse(date.replace(/-/g, '/')))
  45. }
  46. let o = {
  47. 'M+': date.getMonth() + 1, // 月份
  48. 'd+': date.getDate(), // 日
  49. 'h+': 23, // 小时
  50. 'm+': 59, // 分
  51. 's+': 59, // 秒
  52. 'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
  53. 'S': date.getMilliseconds() // 毫秒
  54. }
  55. if (/(y+)/.test(fmt)) {
  56. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  57. }
  58. for (let k in o) {
  59. if (new RegExp('(' + k + ')').test(fmt)) {
  60. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  61. }
  62. }
  63. return fmt
  64. }
  65. export default {
  66. props: ['showSayPriceBox'],
  67. data () {
  68. return {
  69. applyObj: {
  70. code: '',
  71. brand: '',
  72. unitPrice: '',
  73. currency: 'RMB',
  74. encapsulation: '',
  75. produceDate: '',
  76. amount: '',
  77. deadline: ''
  78. },
  79. showCurrencyList: false
  80. }
  81. },
  82. computed: {
  83. user () {
  84. return this.$store.state.option.user
  85. }
  86. },
  87. methods: {
  88. cancel: function () {
  89. this.$emit('cancelAction')
  90. },
  91. emptyForm: function () {
  92. for (let attr in this.applyObj) {
  93. this.applyObj[attr] = attr === 'currency' ? 'RMB' : ''
  94. }
  95. },
  96. goPublish: function () {
  97. let inquiry = {}
  98. let inquiryItem = {}
  99. if (this.user.data.enterprise) {
  100. inquiry.enUU = this.user.data.enterprise.uu
  101. }
  102. let date = new Date()
  103. inquiry.recorderUU = this.user.data.userUU
  104. inquiry.code = 'MALL' + date.getTime()
  105. inquiry.date = date
  106. inquiry.recorder = this.user.data.userName
  107. inquiry.endDate = this.applyObj.deadline
  108. inquiry.sourceapp = 'MALL'
  109. inquiry.amount = 1
  110. inquiryItem.prodTitle = this.applyObj.code
  111. inquiryItem.userUU = this.user.data.userUU
  112. inquiryItem.source = 'MALL'
  113. inquiryItem.userName = this.user.data.userName
  114. inquiryItem.userTel = this.user.data.userTel
  115. inquiryItem.needquantity = this.applyObj.amount
  116. inquiryItem.inbrand = this.applyObj.brand
  117. inquiryItem.currency = this.applyObj.unitPrice ? this.applyObj.currency : null
  118. inquiryItem.cmpCode = (this.applyObj.code).toUpperCase()
  119. inquiryItem.unitPrice = this.applyObj.unitPrice
  120. inquiryItem.produceDate = this.applyObj.produceDate
  121. inquiryItem.date = date
  122. inquiryItem.endDate = this.applyObj.deadline
  123. inquiryItem.encapsulation = this.applyObj.encapsulation
  124. let inquiryItems = []
  125. inquiryItems.push(inquiryItem)
  126. inquiry.inquiryItems = inquiryItems
  127. this.$http.post('/inquiry/buyer/save', inquiry)
  128. .then(response => {
  129. this.$message.success('发布成功')
  130. // this.showRemindBox = true
  131. this.emptyForm()
  132. // this.validObj.deadline = true
  133. this.$emit('reloadAction')
  134. this.cancel()
  135. }, error => {
  136. console.log(error)
  137. this.$message.error('发布失败')
  138. })
  139. },
  140. formatDeadLine: function () {
  141. if (this.applyObj.deadline) {
  142. this.applyObj.deadline = formatDate(this.applyObj.deadline, 'yyyy-MM-dd hh:mm:ss')
  143. }
  144. },
  145. setCurrency: function (type) {
  146. this.applyObj.currency = type
  147. this.showCurrencyList = false
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .mobile-modal {
  154. .mobile-modal-box {
  155. .publish-seek {
  156. background: #fff;
  157. padding-top: .1rem;
  158. padding-bottom: .4rem;
  159. .content-line {
  160. height: .8rem;
  161. line-height: .8rem;
  162. font-size: .26rem;
  163. text-align: left;
  164. border-bottom: .01rem solid #b7d5fe;
  165. position: relative;
  166. input {
  167. width: 3.49rem;
  168. height: .52rem;
  169. padding-left: .19rem;
  170. border: .01rem solid #7e7e7e;
  171. }
  172. > span {
  173. display: inline-block;
  174. width: 1.76rem;
  175. text-align: right;
  176. i {
  177. color: #ff0000;
  178. margin-right: .05rem;
  179. font-style: normal;
  180. }
  181. }
  182. > a {
  183. font-size: .26rem;
  184. color: #666;
  185. }
  186. > img {
  187. width: .12rem;
  188. height: .06rem;
  189. margin-left: .04rem;
  190. }
  191. > ul {
  192. position: absolute;
  193. top: .6rem;
  194. left: 1.16rem;
  195. z-index: 1;
  196. width: 1.75rem;
  197. background: #fff;
  198. text-align: center;
  199. border-radius: .1rem;
  200. border: .01rem solid #dfdfdf;
  201. -webkit-box-shadow: 0 0 .12rem .02rem #e2d9d975;
  202. -moz-box-shadow: 0 0 .12rem .02rem #e2d9d975;
  203. box-shadow: 0 0 .12rem .02rem #e2d9d975;
  204. li {
  205. height: .52rem;
  206. line-height: .52rem;
  207. border-bottom: .01rem solid #dfdfdf;
  208. &:hover, &:active {
  209. background: #dedede;
  210. }
  211. }
  212. }
  213. }
  214. > a {
  215. display: block;
  216. width: 5.19rem;
  217. height: .84rem;
  218. text-align: center;
  219. line-height: .84rem;
  220. font-size: .38rem;
  221. margin: .3rem auto 0;
  222. background: #3f84f6;
  223. color: #fff;
  224. border-radius: .08rem;
  225. }
  226. }
  227. }
  228. }
  229. </style>