saleReport.vue 4.24 KB
<template>
	<view class="pages">
		<view class="box" v-for="(item,index) in items" :key="index">
			<view class="contents">
				<view class="item">
					<view class="title">
						商品名称
					</view>
					<view class="inputContent">
						<input type="text" v-model="item.productName" placeholder="请输入" />
					</view>
				</view>
				<view class="up_line"></view>
				<view class="item">
					<view class="title">
						商品类型
					</view>
					<view class="inputContent">
						<input type="text" v-model="item.productType" placeholder="请输入" />
					</view>
				</view>
				
				<view class="up_line"></view>
				<view class="item">
					<view class="title">
						品牌
					</view>
					<view class="inputContent">
						<input type="text" v-model="item.brand" placeholder="请输入" />
					</view>
				</view>
				<view class="up_line"></view>
				<view class="item">
					<view class="title">
						价格
					</view>
					<view class="inputContent">
						<input type="text" v-model="item.price" placeholder="请输入" />
					</view>
				</view>
				<view class="up_line"></view>
				<view class="item">
					<view class="title">
						销售时间
					</view>
					<view class="inputContent">
						<u-input v-model="item.saleTime" type="select" @click="busStartshow = true" placeholder="请选择"/>
						<u-picker mode="time" v-model="busStartshow" :params="params" @confirm="busStTimeChange($event,index)"></u-picker>	
					</view>
				</view>
				<view class="up_line"></view>
				<view class="item">
					<view class="title">
						销售数量
					</view>
					<view class="inputContent">
						<input type="text" v-model="item.salesQuantity" placeholder="请输入" />
					</view>
				</view>
				<view class="up_line"></view>
			</view>
		</view>
		<view class="addBox" @click="addItems">
			<uni-icons type="plusempty" color="#0FBB59"></uni-icons>
			<span class="addName" style="color: #0FBB59;font-size: 25rpx;">添加商品</span>
		</view>
		<view class="postBox">
			<button   @click ="go"
				style="background-color: #0FBB59;color: #fff;font-size: 28rpx;border-radius: 20rpx;padding: 10rpx 0;">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				items: [{
					productName: '',
					productType: '',
					brand: '',
					price: '',
					saleTime: '',
					salesQuantity: ''
				}],
				busStartshow:false,
				params: {
					year: true,
					month: true,
					day: true
				},
			}
		},
		methods: {
			addItems() {
				this.items.push({
					productName: '',
					productType: '',
					brand: '',
					price: '',
					saleTime: '',
					salesQuantity: ''
				})
			},
			busStTimeChange(val,index){
				this.items[index].saleTime = this.timeChange(val)
			},
			timeChange(val) {
				const { year, month, day} = val;
				return `${year}-${month}-${day}`;
			},
			go(){
				this.items.map(tem=>{
					tem.merchantId =  uni.getStorageSync('shopId')
					this.$http.sendRequest('/cereSalesReporting/add', 'POST',tem,1).then(res => {
						uni.showModal({
							title: '上报成功',
							showCancel:false,
							success:ress => {
								uni.switchTab({
									url:'/pages/workbench/workbench'
								})
							}
						})
					})
				})
				 
			
			},
		}
	}
</script>

<style lang="scss" scoped>
	.pages {
		width: 100vw;
		height: 100%;
		position: relative;
		overflow-y: auto;
		padding-bottom: 200rpx;

		.box {
			width: 96%;
			margin: 0 auto;
			background-color: #fff;
			border-radius: 20rpx;

			.contents {
				width: 92%;
				margin: 0 auto;
				// padding: 20rpx;
				margin-top: 20rpx;

				.item {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 20rpx 0;

					.title {
						font-size: 26rpx;
						font-weight: bold;
					}

					.inputContent {
						input {
							font-size: 26rpx;
							text-align: right;
						}
					}
				}

				.up_line {
					width: 100%;
					background-color: #e8e8e8;
					height: 1rpx;
					transform: scaleY(.5);
				}
			}
		}

		.addBox {
			width: 20%;
			display: flex;
			align-items: center;
			margin: 0 auto;
			margin-top: 30rpx;

			.addName {
				color: #0FBB59;
			}
		}

		.postBox {
			position: fixed;
			bottom: 40rpx;
			width: 90%;
			left: 50%;
			transform: translateX(-50%);
		}
	}
</style>