indexForm.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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="row row-bottom">
  64. <view class="left">密码(必填)</view>
  65. <input v-model='param.password' class="right-bottom" type="password" placeholder="请输入"></input>
  66. </view>
  67. <view class="bottom-btn">
  68. <button type="primary" class="submit" hover-class="none" @click="submit()">提交</button>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. param: {
  77. filed1: '0',
  78. filed2: '0',
  79. filed3: '0',
  80. filed4: '0',
  81. filed5: '0',
  82. filed6: '0',
  83. total: '0',
  84. banci: '白班',
  85. banzu: '甲班',
  86. type: '出库',
  87. inNum: '0',
  88. password:'',
  89. date: this.getDate()
  90. },
  91. radioGroup: ['白班', '夜班'],
  92. inOutType: ['出库', '入库'],
  93. list: [{
  94. name: '甲班'
  95. },
  96. {
  97. name: '乙班'
  98. },
  99. {
  100. name: '丙班'
  101. }
  102. ],
  103. industryIndex: 0,
  104. }
  105. },
  106. computed: {
  107. total() {
  108. return parseFloat(this.param.filed1) +
  109. parseFloat(this.param.filed2) +
  110. parseFloat(this.param.filed3) +
  111. parseFloat(this.param.filed4) +
  112. parseFloat(this.param.filed5) +
  113. parseFloat(this.param.filed6);
  114. }
  115. },
  116. onLoad() {
  117. },
  118. methods: {
  119. submit() {
  120. console.log(this.param,12)
  121. if (!this.param.password) {
  122. uni.showToast({
  123. title: '密码不能为空',
  124. icon: 'none'
  125. })
  126. return false;
  127. }
  128. this.param.total = this.total;
  129. let that = this
  130. uni.showModal({
  131. title: '提示',
  132. content: '确定提交?',
  133. success: function(res) {
  134. if (res.confirm) {
  135. uni.showLoading({
  136. title: '正在提交',
  137. mask: true
  138. });
  139. uni.request({
  140. url: '/v1/testTable',
  141. method: 'POST',
  142. data: that.param,
  143. success: (res) => {
  144. if(res.data.code!=200){
  145. uni.showToast({
  146. title: res.data.msg,
  147. mask: true,
  148. icon: 'error',
  149. duration: 2000
  150. })
  151. }
  152. else{
  153. uni.showToast({
  154. title: '提交成功',
  155. mask: true,
  156. icon: 'success',
  157. duration: 2000
  158. })
  159. }
  160. }
  161. })
  162. uni.hideLoading()
  163. .catch(res => {
  164. uni.hideLoading()
  165. })
  166. } else {
  167. // 执行取消后的操作
  168. }
  169. },
  170. })
  171. },
  172. chang(e) {
  173. this.banci = e.detail.value; //选中按钮的value值
  174. this.param.banci = e.detail.value;
  175. },
  176. selectType(e) {
  177. this.type = e.detail.value; //选中按钮的value值
  178. this.param.type = e.detail.value;
  179. },
  180. outtypeChange(e) {
  181. this.industryIndex = e.detail.value
  182. this.banzu = this.list[e.detail.value].name
  183. this.param.banzu =this.list[e.detail.value].name
  184. },
  185. getDate() {
  186. const date = new Date();
  187. let year = date.getFullYear();
  188. let month = date.getMonth() + 1;
  189. let day = date.getDate();
  190. month = month > 9 ? month : '0' + month;
  191. day = day > 9 ? day : '0' + day;
  192. return `${year}-${month}-${day}`;
  193. },
  194. bindDateChange: function(e) {
  195. this.date = e.detail.value;
  196. }
  197. }
  198. }
  199. </script>
  200. <style scoped lang="scss">
  201. .content,
  202. .content1,
  203. .content2 {
  204. border-radius: 20rpx;
  205. background: white;
  206. padding: 20rpx;
  207. .title {
  208. font-size: 28rpx;
  209. font-weight: 600;
  210. color: #333333;
  211. }
  212. .row {
  213. display: flex;
  214. justify-content: space-between;
  215. border-bottom: 1px solid #EEEEEE;
  216. padding: 21rpx 0;
  217. .right,
  218. input {
  219. font-size: 28rpx;
  220. color: #333333;
  221. }
  222. }
  223. .row-bottom {
  224. // border: 0;
  225. .right-bottom {
  226. width: 280rpx;
  227. text-align: right;
  228. }
  229. }
  230. }
  231. .right-bottom {
  232. width: 280rpx;
  233. text-align: right;
  234. }
  235. .logo {
  236. height: 200rpx;
  237. width: 200rpx;
  238. margin-top: 200rpx;
  239. margin-left: auto;
  240. margin-right: auto;
  241. margin-bottom: 50rpx;
  242. }
  243. .text-area {
  244. display: flex;
  245. justify-content: center;
  246. }
  247. .title {
  248. font-size: 36rpx;
  249. color: #8f8f94;
  250. }
  251. .bottom-btn {
  252. padding: 30rpx;
  253. background: #FFFFFF;
  254. width: 92%;
  255. position: fixed;
  256. bottom: 0rpx;
  257. display: flex;
  258. }
  259. </style>