PublishSupplierSeek.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="mobile-modal" v-if="showPublishBox" @touchmove="preventTouchMove($event)">
  3. <div class="mobile-modal-box">
  4. <div class="mobile-modal-header">我要询价<i class="icon-guanbi iconfont" @click="cancel"></i></div>
  5. <div class="props">
  6. <div class="prop">品牌:{{applyObj.brand || '-'}}</div>
  7. <div class="prop">物料名称:{{applyObj.prodTitle || '-'}}</div>
  8. <div class="prop">型号:{{applyObj.code || '-'}}</div>
  9. <div class="prop">规格:{{applyObj.spec || '-'}}</div>
  10. </div>
  11. <div class="publish-seek">
  12. <div class="content-line">
  13. <span><i>*</i>截止日期:</span>
  14. <input type="date" v-model="applyObj.deadline" :min="minDay" :max="maxDay" @blur="deadlineChange">
  15. </div>
  16. <div class="content-line">
  17. <span>数量(PCS):</span>
  18. <input type="text" v-model="applyObj.amount" @blur="checkAmount" @input="onAmountInput">
  19. </div>
  20. <a @click="authorityInterceptor(baseUrls.userPublishSeek, goPublish)">确认</a>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. props: ['showPublishBox', 'product'],
  28. data () {
  29. return {
  30. applyObj: {
  31. code: '',
  32. brand: '',
  33. amount: '',
  34. deadline: '',
  35. prodTitle: ''
  36. },
  37. validObj: {
  38. amount: true,
  39. deadline: true
  40. }
  41. }
  42. },
  43. computed: {
  44. minDay: function () {
  45. return this.baseUtils.formatDate(new Date(), 'yyyy-MM-dd')
  46. },
  47. maxDay: function () {
  48. let deadDate = new Date().getTime() + 1000 * 60 * 60 * 24 * 90
  49. deadDate = this.baseUtils.formatDate(new Date(deadDate), 'yyyy-MM-dd')
  50. return deadDate
  51. }
  52. },
  53. watch: {
  54. // showPublishBox: function (val, old) {
  55. // if (val) {
  56. // document.body.style.position = 'fixed'
  57. // document.body.style.left = '0'
  58. // document.body.style.right = '0'
  59. // } else {
  60. // document.body.style.position = 'relative'
  61. // }
  62. // },
  63. product: {
  64. handler (val, oldVal) {
  65. if (val) {
  66. let isStandard = val.standard === 1
  67. this.applyObj.code = val.cmpCode
  68. this.applyObj.brand = isStandard ? val.pbranden : val.brand
  69. this.applyObj.spec = val.spec
  70. // this.applyObj.unit = val.unit || 'PCS'
  71. this.applyObj.prodTitle = val.kind || val.prodName
  72. }
  73. },
  74. immediate: true
  75. }
  76. },
  77. methods: {
  78. cancel: function () {
  79. this.$emit('cancelAction')
  80. },
  81. emptyForm: function () {
  82. for (let attr in this.applyObj) {
  83. this.applyObj[attr] = ''
  84. }
  85. },
  86. setRemindText: function (str) {
  87. this.$emit('remindAction', str)
  88. },
  89. getMaterialKind: function (code, brand) {
  90. return this.$http.get('/productuser/match/getKind', {params: {cmpCode: code, brand: brand}})
  91. },
  92. startPublish: function (prodTitle) {
  93. let inquiry = {}
  94. let inquiryItem = {}
  95. if (this.user.data.enterprise) {
  96. inquiry.enUU = this.user.data.enterprise.uu
  97. }
  98. let date = new Date()
  99. let endDate = this.baseUtils.formatDate(this.baseUtils.getFullDay(new Date(this.baseUtils.getClearDay(new Date(this.applyObj.deadline)))), 'yyyy-MM-dd hh:mm:ss')
  100. inquiry.recorderUU = this.user.data.userUU
  101. inquiry.code = 'MALL' + date.getTime()
  102. inquiry.date = date
  103. inquiry.recorder = this.user.data.userName
  104. inquiry.endDate = endDate
  105. inquiry.sourceapp = 'MALL'
  106. inquiryItem.userUU = this.user.data.userUU
  107. inquiryItem.source = 'MALL'
  108. inquiryItem.userName = this.user.data.userName
  109. inquiryItem.userTel = this.user.data.userTel
  110. inquiryItem.needquantity = this.applyObj.amount
  111. inquiryItem.inbrand = this.applyObj.brand
  112. inquiryItem.cmpCode = (this.applyObj.code).toUpperCase()
  113. inquiryItem.prodTitle = prodTitle || this.applyObj.prodTitle || '其他'
  114. inquiryItem.date = date
  115. inquiryItem.endDate = endDate
  116. let inquiryItems = []
  117. inquiryItems.push(inquiryItem)
  118. inquiry.inquiryItems = inquiryItems
  119. this.$http.post('/inquiry/buyer/save', inquiry)
  120. .then(response => {
  121. // this.$message.success('发布成功')
  122. this.setRemindText('发布成功')
  123. // this.showRemindBox = true
  124. this.emptyForm()
  125. // this.validObj.deadline = true
  126. // this.$emit('reloadAction')
  127. this.cancel()
  128. }, error => {
  129. console.log(error)
  130. // this.$message.error('发布失败')
  131. this.setRemindText('发布失败')
  132. })
  133. },
  134. goPublish: function () {
  135. if (this.checkAll()) {
  136. if (!this.applyObj.prodTitle || this.applyObj.prodTitle.length === 0) {
  137. this.getMaterialKind(this.applyObj.code, this.applyObj.brand).then(response => {
  138. this.startPublish(response.data && response.data.length ? response.data : '其他')
  139. })
  140. } else {
  141. this.startPublish()
  142. }
  143. } else {
  144. if (!this.validObj.deadline) {
  145. this.setRemindText('截止日期不能为空')
  146. } else if (!this.validObj.amount) {
  147. this.setRemindText('请输入正确的数值')
  148. }
  149. }
  150. },
  151. isValidDate: function (date) {
  152. let now = new Date(this.baseUtils.formatDate(new Date(), 'yyyy-MM-dd')).getTime()
  153. let time = new Date(date).getTime()
  154. return !time || (time >= now && time <= now + 1000 * 60 * 60 * 24 * 90)
  155. },
  156. deadlineChange: function () {
  157. // this.applyObj.deadline = this.baseUtils.formatDate(this.baseUtils.getFullDay(new Date(this.baseUtils.getClearDay(new Date(this.applyObj.deadline)))), 'yyyy-MM-dd hh:mm:ss')
  158. if (!this.isValidDate(this.applyObj.deadline)) {
  159. this.setRemindText('日期需不小于今天且在90天以内')
  160. this.applyObj.deadline = ''
  161. this.validObj.deadline = false
  162. } else {
  163. this.validObj.deadline = true
  164. }
  165. },
  166. checkAll: function () {
  167. return this.checkDeadline() && this.checkAmount()
  168. },
  169. checkAmount: function () {
  170. this.validObj.amount = this.applyObj.amount === '' ? true : this.applyObj.amount > 0 && this.applyObj.amount < 1000000000
  171. return this.validObj.amount
  172. },
  173. checkDeadline: function () {
  174. this.validObj.deadline = Boolean(this.applyObj.deadline)
  175. return this.validObj.deadline
  176. },
  177. onAmountInput: function () {
  178. if (!(/^[0-9]*$/).test(this.applyObj.amount)) {
  179. let chineseIndex = -1
  180. for (let i = 0; i < this.applyObj.amount.length; i++) {
  181. if (!(/^[0-9]*$/).test(this.applyObj.amount.charAt(i))) {
  182. chineseIndex = i
  183. break
  184. }
  185. }
  186. this.applyObj.amount = this.baseUtils.cutOutString(this.applyObj.amount, chineseIndex)
  187. } else if (this.applyObj.amount.length > 9) {
  188. this.applyObj.amount = this.baseUtils.cutOutString(this.applyObj.amount, 9)
  189. }
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .mobile-modal {
  196. .mobile-modal-box {
  197. position: fixed;
  198. width: 5.92rem;
  199. font-size: .28rem;
  200. top: 50%;
  201. left: 50%;
  202. right: 11%;
  203. z-index: 1000;
  204. margin-top: -3.7rem;
  205. margin-left: -2.96rem;
  206. background: #f3f3f3;
  207. .mobile-modal-header {
  208. border-radius: 0;
  209. }
  210. .publish-seek {
  211. background: #fff;
  212. padding-top: .1rem;
  213. padding-bottom: .4rem;
  214. .content-line {
  215. position: relative;
  216. height: .8rem;
  217. line-height: .8rem;
  218. font-size: .26rem;
  219. text-align: left;
  220. input {
  221. width: 3.49rem;
  222. height: .52rem;
  223. line-height: normal;
  224. padding: .1rem .19rem;
  225. border: 1px solid #7e7e7e;
  226. font-size: .26rem;
  227. vertical-align: middle;
  228. background: #fff;
  229. border-radius: 0;
  230. }
  231. > span {
  232. display: inline-block;
  233. width: 1.76rem;
  234. text-align: right;
  235. i {
  236. color: #ff0000;
  237. margin-right: .05rem;
  238. font-style: normal;
  239. }
  240. }
  241. > a {
  242. font-size: .26rem;
  243. color: #666;
  244. }
  245. > img {
  246. width: .12rem;
  247. height: .06rem;
  248. margin-left: .04rem;
  249. }
  250. }
  251. > a {
  252. display: block;
  253. width: 5.19rem;
  254. height: .84rem;
  255. text-align: center;
  256. line-height: .84rem;
  257. font-size: .38rem;
  258. margin: .3rem auto 0;
  259. background: #3f84f6;
  260. color: #fff;
  261. border-radius: .08rem;
  262. }
  263. }
  264. .props {
  265. font-size: .28rem;
  266. background: #fff;
  267. margin: .2rem 0;
  268. padding: 0 .29rem;
  269. .prop {
  270. padding-top: .2rem;
  271. word-break: break-all;
  272. &:last-child {
  273. padding-bottom: .2rem;
  274. }
  275. span {
  276. color: #666;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. </style>