index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="content">
  3. <view class="row row-bottom">
  4. <view class="left">日期</view>
  5. <picker mode="date" @change="bindDateChange">
  6. <view>{{param.date}}</view>
  7. </picker>
  8. </view>
  9. <view class="row row-bottom">
  10. <view class="left">类型</view>
  11. <radio-group @change="selectType">
  12. <label v-for="item in inOutType" :key="item">
  13. <radio :value="item" :checked="item==param.type" />{{item}}
  14. </label>
  15. </radio-group>
  16. </view>
  17. <view v-if="param.type=='出库'" class="row row-bottom">
  18. <view class="left">班组</view>
  19. <picker @change="outtypeChange" :value="industryIndex" :range="list" range-key="name">
  20. {{industryIndex>0 ? list[industryIndex].name : industryIndex==0 ? list[0].name :'请选择班组'}}
  21. </picker>
  22. </view>
  23. <view v-if="param.type=='出库'" class="row row-bottom">
  24. <view class="left">班次</view>
  25. <radio-group @change="chang">
  26. <label v-for="item in radioGroup" :key="item">
  27. <radio :value="item" :checked="item==param.banci" />{{item}}
  28. </label>
  29. </radio-group>
  30. </view>
  31. <view v-if="param.type=='出库'" class="row row-bottom">
  32. <view class="left">巴西(吨)</view>
  33. <input v-model='param.filed1' class="right-bottom" type="number" placeholder="请输入"></input>
  34. </view>
  35. <view v-if="param.type=='出库'" class="row row-bottom">
  36. <view class="left">中美洲(吨)</view>
  37. <input v-model='param.filed2' class="right-bottom" type="number" placeholder="请输入"></input>
  38. </view>
  39. <view v-if="param.type=='出库'" class="row row-bottom">
  40. <view class="left">回溶(吨)</view>
  41. <input v-model='param.filed3' class="right-bottom" type="number" placeholder="请输入"></input>
  42. </view>
  43. <view v-if="param.type=='出库'" class="row row-bottom">
  44. <view class="left">加工糖100%(吨)</view>
  45. <input v-model='param.filed4' class="right-bottom" type="number" placeholder="请输入"></input>
  46. </view>
  47. <view v-if="param.type=='出库'" class="row row-bottom">
  48. <view class="left">非食用糖92%(吨)</view>
  49. <input v-model='param.filed5' class="right-bottom" type="number" placeholder="请输入"></input>
  50. </view>
  51. <view v-if="param.type=='出库'" class="row row-bottom">
  52. <view class="left">国储(吨)</view>
  53. <input v-model='param.filed6' class="right-bottom" type="number" placeholder="请输入"></input>
  54. </view>
  55. <view v-if="param.type=='出库'" class="row row-bottom">
  56. <view class="left">合计(吨)</view>
  57. <input :disabled="true" v-model='total' class="right-bottom" placeholder="请输入"></input>
  58. </view>
  59. <view v-if="param.type=='入库'" class="row row-bottom">
  60. <view class="left">入库量(吨)</view>
  61. <input v-model='param.inNum' class="right-bottom" placeholder="请输入"></input>
  62. </view>
  63. <view class="bottom-btn">
  64. <button type="primary" class="submit" hover-class="none" @click="submit()">提交</button>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. data() {
  71. return {
  72. param: {
  73. filed1: '0',
  74. filed2: '0',
  75. filed3: '0',
  76. filed4: '0',
  77. filed5: '0',
  78. filed6: '0',
  79. total: '0',
  80. banci: '白班',
  81. banzu: '甲班',
  82. type: '出库',
  83. inNum: '0',
  84. date: this.getDate()
  85. },
  86. radioGroup: ['白班', '夜班'],
  87. inOutType: ['出库', '入库'],
  88. list: [{
  89. name: '甲班'
  90. },
  91. {
  92. name: '乙班'
  93. },
  94. {
  95. name: '丙班'
  96. }
  97. ],
  98. industryIndex: 0,
  99. }
  100. },
  101. computed: {
  102. total() {
  103. return parseFloat(this.param.filed1) +
  104. parseFloat(this.param.filed2) +
  105. parseFloat(this.param.filed3) +
  106. parseFloat(this.param.filed4) +
  107. parseFloat(this.param.filed5) +
  108. parseFloat(this.param.filed6);
  109. }
  110. },
  111. onLoad() {
  112. },
  113. methods: {
  114. submit() {
  115. this.param.total = this.total;
  116. let that = this
  117. uni.showModal({
  118. title: '提示',
  119. content: '确定提交?',
  120. success: function(res) {
  121. if (res.confirm) {
  122. uni.showLoading({
  123. title: '正在提交',
  124. mask: true
  125. });
  126. uni.request({
  127. url: 'http://localhost:8888/v1/testTable',
  128. method: 'POST',
  129. data: that.param,
  130. success: (res) => {
  131. if(res.data.code!=200){
  132. uni.showToast({
  133. title: res.data.msg,
  134. mask: true,
  135. icon: 'error',
  136. duration: 2000
  137. })
  138. }
  139. else{
  140. uni.showToast({
  141. title: '提交成功',
  142. mask: true,
  143. icon: 'success',
  144. duration: 2000
  145. })
  146. }
  147. }
  148. })
  149. uni.hideLoading()
  150. .catch(res => {
  151. uni.hideLoading()
  152. })
  153. } else {
  154. // 执行取消后的操作
  155. }
  156. },
  157. })
  158. },
  159. chang(e) {
  160. this.banci = e.detail.value; //选中按钮的value值
  161. this.param.banci = e.detail.value;
  162. },
  163. selectType(e) {
  164. this.type = e.detail.value; //选中按钮的value值
  165. this.param.type = e.detail.value;
  166. },
  167. outtypeChange(e) {
  168. this.industryIndex = e.detail.value
  169. this.banzu = this.list[e.detail.value].name
  170. this.param.banzu =this.list[e.detail.value].name
  171. },
  172. getDate() {
  173. const date = new Date();
  174. let year = date.getFullYear();
  175. let month = date.getMonth() + 1;
  176. let day = date.getDate();
  177. month = month > 9 ? month : '0' + month;
  178. day = day > 9 ? day : '0' + day;
  179. return `${year}-${month}-${day}`;
  180. },
  181. bindDateChange: function(e) {
  182. this.date = e.detail.value;
  183. }
  184. }
  185. }
  186. </script>
  187. <style scoped lang="scss">
  188. .content,
  189. .content1,
  190. .content2 {
  191. border-radius: 20rpx;
  192. background: white;
  193. padding: 20rpx;
  194. .title {
  195. font-size: 28rpx;
  196. font-weight: 600;
  197. color: #333333;
  198. }
  199. .row {
  200. display: flex;
  201. justify-content: space-between;
  202. border-bottom: 1px solid #EEEEEE;
  203. padding: 21rpx 0;
  204. .right,
  205. input {
  206. font-size: 28rpx;
  207. color: #333333;
  208. }
  209. }
  210. .row-bottom {
  211. // border: 0;
  212. .right-bottom {
  213. width: 280rpx;
  214. text-align: right;
  215. }
  216. }
  217. }
  218. .right-bottom {
  219. width: 280rpx;
  220. text-align: right;
  221. }
  222. .logo {
  223. height: 200rpx;
  224. width: 200rpx;
  225. margin-top: 200rpx;
  226. margin-left: auto;
  227. margin-right: auto;
  228. margin-bottom: 50rpx;
  229. }
  230. .text-area {
  231. display: flex;
  232. justify-content: center;
  233. }
  234. .title {
  235. font-size: 36rpx;
  236. color: #8f8f94;
  237. }
  238. .bottom-btn {
  239. padding: 30rpx;
  240. background: #FFFFFF;
  241. width: 92%;
  242. position: fixed;
  243. bottom: 0rpx;
  244. display: flex;
  245. }
  246. </style>