procurementAdd.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="release">
  3. <form>
  4. <view class="uni-form-item uni-column">
  5. <view class="title">商品图片</view>
  6. <view class="uploadComp">
  7. <proUpload @uploadDel='uploadDel' @uploadImg='uploadImg'/>
  8. </view>
  9. </view>
  10. <view class="uni-form-item uni-column">
  11. <view class="title"><span>*</span>商品名称</view>
  12. <view>
  13. <input class="uni-input" focus placeholder="请输入想要采购的商品名称" v-model='formData.productName' />
  14. <!-- <small>请输入商品名称</small> -->
  15. </view>
  16. </view>
  17. <view class="uni-form-item uni-column">
  18. <view class="title"><span>*</span>期望单价</view>
  19. <view>
  20. <input class="uni-input" focus placeholder="请输入您对商品的期望单价" v-model="formData.price" />
  21. </view>
  22. </view>
  23. <view class="uni-form-item uni-column">
  24. <view class="title"><span>*</span>采购数量</view>
  25. <view>
  26. <input class="uni-input" focus placeholder="请输入您的采购数量" v-model="formData.number" />
  27. </view>
  28. </view>
  29. </form>
  30. <view class="release_btn">
  31. <proBtn width="600rpx" v-if='isActive' @click="handlerSave" height="90rpx" background='#F3B574' color='#FFFFFF' fontSize='32rpx'>发布</proBtn>
  32. <proBtn width="600rpx" height="90rpx" v-else background='#E2E2E2' color='#999999' fontSize='32rpx'>发布</proBtn>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import proBtn from './components/procurement-btn.vue'
  38. import proUpload from './components/upload.vue'
  39. import {mapState} from 'vuex'
  40. export default {
  41. components: {
  42. proUpload,
  43. proBtn
  44. },
  45. data() {
  46. return {
  47. // 发布需求
  48. formData: {
  49. userId: 0,
  50. productImage: '',
  51. productName: '',
  52. price: '',
  53. number: '',
  54. userName: ''
  55. },
  56. userInfo: {}, // 用户详情
  57. isActive: false
  58. }
  59. },
  60. watch: {
  61. 'formData.productName': {
  62. handler() {
  63. this.activeBtn()
  64. },
  65. deep: true
  66. },
  67. 'formData.price': {
  68. handler() {
  69. this.activeBtn()
  70. },
  71. deep: true
  72. },
  73. 'formData.number': {
  74. handler() {
  75. this.activeBtn()
  76. },
  77. deep: true
  78. }
  79. },
  80. onLoad(options) {
  81. if (options.id) {
  82. }
  83. },
  84. mounted() {
  85. this.userInfo = uni.getStorageSync('userInfo')
  86. this.formData.userId = this.userInfo.userId
  87. this.formData.userName = this.userInfo.name
  88. },
  89. methods: {
  90. // 发布按钮
  91. activeBtn() {
  92. if (this.formData.productName === '' || this.formData.price === ''|| this.formData.number === '') {
  93. this.isActive = false
  94. } else {
  95. this.isActive = true
  96. }
  97. },
  98. // 图片上传
  99. uploadImg(url) {
  100. if (url !== '' || url !== null) {
  101. this.formData.productImage = url
  102. }
  103. },
  104. // 图片删除
  105. uploadDel(e) {
  106. this.formData.productImage = e
  107. },
  108. // submit 发布
  109. async handlerSave() {
  110. console.log(this.formData)
  111. try{
  112. const data = await this.ProcurementService.procurementSave(this.formData)
  113. console.log(data)
  114. }catch(error){
  115. console.log(error)
  116. }
  117. },
  118. // 集采详情
  119. async handlerDetail(id) {
  120. try{
  121. const data = await this.ProcurementService.procurementSave()
  122. }catch(e){
  123. //TODO handle the exception
  124. }
  125. },
  126. },
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .release {
  131. padding: 24rpx;
  132. }
  133. span{
  134. color: #F85050;
  135. font-size: 28rpx;
  136. }
  137. .title {
  138. font-size: 28rpx;
  139. color: #666666;
  140. margin-bottom: 24rpx;
  141. }
  142. .uploadComp {
  143. margin-bottom: 40rpx;
  144. }
  145. .uni-input {
  146. height: 90rpx;
  147. border: 1px solid #B2B2B2;
  148. border-radius: 6rpx 6rpx 6rpx 6rpx;
  149. font-size: 28rpx;
  150. padding-left: 47rpx;
  151. margin-bottom: 40rpx;
  152. }
  153. .release_btn {
  154. position: fixed;
  155. left: 0;
  156. bottom: 0;
  157. margin-bottom: 76rpx;
  158. display: flex;
  159. justify-content: center;
  160. align-items: center;
  161. width: 100%;
  162. }
  163. </style>