zyw 1 year ago
parent
commit
7fed6f6cb1
1 changed files with 153 additions and 17 deletions
  1. 153 17
      pages/index/index.vue

+ 153 - 17
pages/index/index.vue

@@ -1,14 +1,72 @@
 <template>
 	<view class="content">
 		<view class="row row-bottom">
-			<view class="left">字段1</view>
-			<input v-model='param.filed1' class="right-bottom"
-				placeholder="请输入字段1"></input>
+		<view class="left">日期</view>
+				<picker mode="date"  @change="bindDateChange">
+					<view>{{param.date}}</view>
+				</picker>
 		</view>
 		<view class="row row-bottom">
-			<view class="left">字段2</view>
-			<input v-model='param.filed2' class="right-bottom"
-				placeholder="请输入字段2"></input>
+			<view class="left">类型</view>
+				<radio-group @change="selectType">
+					<label v-for="item in inOutType" :key="item">
+						<radio :value="item" :checked="item==param.type" />{{item}}
+					</label>
+				</radio-group>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">班组</view>
+			 <picker @change="outtypeChange" :value="industryIndex" :range="list" range-key="name">
+				{{industryIndex>0 ? list[industryIndex].name : industryIndex==0 ? list[0].name :'请选择班组'}}
+			</picker>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">班次</view>
+				<radio-group @change="chang">
+					<label v-for="item in radioGroup" :key="item">
+						<radio :value="item" :checked="item==param.banci" />{{item}}
+					</label>
+				</radio-group>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">巴西(吨)</view>
+			<input v-model='param.filed1' class="right-bottom"  type="number"
+				placeholder="请输入"></input>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">中美洲(吨)</view>
+			<input v-model='param.filed2' class="right-bottom" type="number"
+				placeholder="请输入"></input>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">回溶(吨)</view>
+			<input v-model='param.filed3' class="right-bottom"  type="number"
+				placeholder="请输入"></input>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">加工糖100%(吨)</view> 
+			<input v-model='param.filed4' class="right-bottom"  type="number"
+				placeholder="请输入"></input>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">非食用糖92%(吨)</view>
+			<input v-model='param.filed5' class="right-bottom"  type="number"
+				placeholder="请输入"></input>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">国储(吨)</view>
+			<input v-model='param.filed6' class="right-bottom"  type="number"
+				placeholder="请输入"></input>
+		</view>
+		<view v-if="param.type=='出库'" class="row row-bottom">
+			<view class="left">合计(吨)</view>
+			<input :disabled="true" v-model='total' class="right-bottom"
+				placeholder="请输入"></input>
+		</view>
+		<view v-if="param.type=='入库'" class="row row-bottom">
+			<view class="left">入库量(吨)</view>
+			<input v-model='param.inNum' class="right-bottom"
+				placeholder="请输入"></input>
 		</view>
 		<view class="bottom-btn">
 			<button type="primary" class="submit" hover-class="none" @click="submit()">提交</button>
@@ -20,28 +78,106 @@
 	export default {
 		data() {
 			return {
-				title: 'Hello',
 				param:{
-					filed1:'',
-					filed2:'',
-				}
+					filed1:'0',
+					filed2:'0',
+					filed3:'0',
+					filed4:'0',
+					filed5:'0',
+					filed6:'0',
+					total:'0',
+					banci:'白班',
+					banzu:'甲班',
+					type:'出库',
+					inNum:'0',
+					date:this.getDate()
+				},
+				radioGroup: ['白班', '夜班'],
+				inOutType: ['出库', '入库'],
+				list: [{
+							name: '甲班'
+						},
+						{
+							name: '乙班'
+						},
+						{
+							name: '丙班'
+						}
+				] ,
+				industryIndex:0,
 				
 			}
 		},
+		computed:{
+				total(){
+					return parseFloat(this.param.filed1)
+					+parseFloat(this.param.filed2)
+					+parseFloat(this.param.filed3)
+					+parseFloat(this.param.filed4)
+					+parseFloat(this.param.filed5)
+					+parseFloat(this.param.filed6);
+				}
+		},
 		onLoad() {
 
 		},
 		methods: {
 			submit(){
-				uni.request({
-					url: 'http://localhost:8888/v1/testTable',
-					method: 'POST',
-					data:this.param,
-					success: (res) => {
-						console.log(res)
+				this.param.total = this.total; 
+				let that = this
+				uni.showModal({
+						title: '提示',
+						content: '确定提交?',
+						success: function(res) {
+						if (res.confirm) {
+						    uni.showLoading({
+						    	title: '正在提交',
+								mask: true
+						    });
+							uni.request({
+								url: 'http://localhost:8888/v1/testTable',
+								method: 'POST',
+								data:this.param,
+								success: (res) => {
+									console.log(res)
+								}
+							})
+							uni.hideLoading()
+							.catch(res => {
+								uni.hideLoading()
+							})
+						} 
+						else {
+							// 执行取消后的操作
+						}
 					}
 				})
-			}
+			},
+
+			chang(e) {
+				this.banci = e.detail.value;  //选中按钮的value值
+			},
+			selectType(e) {
+				
+				this.type = e.detail.value;  //选中按钮的value值
+				this.param.type = e.detail.value; 
+			},
+			outtypeChange(e) {
+				this.industryIndex = e.detail.value
+				this.banzu= this.list[e.detail.value].name
+			},
+			getDate() {
+							const date = new Date();
+							let year = date.getFullYear();
+							let month = date.getMonth() + 1;
+							let day = date.getDate();
+							month = month > 9 ? month : '0' + month;
+							day = day > 9 ? day : '0' + day;
+							return `${year}-${month}-${day}`;
+						},
+						bindDateChange: function(e) {
+							this.date = e.detail.value;
+						}
 		}
 	}
 </script>