<template>
	<view class="pages">
		<uni-card title="36524快消品动产质押项目" :isFull="true" extra="点击下载Excel文件" :thumbnail="avatar"
			style="padding-top: 10px;">
			<template v-slot:title>
				<uni-section :title="info.projectName" title-font-size="25" type="line">
					<template v-slot:decoration>
						<uni-icons type="location-filled" size="18" color="green"></uni-icons>
					</template>
					<template v-slot:right> <uni-tag :inverted="true" text="下载Excel文件" type="primary"
							@click="onClick" /> </template>
				</uni-section>
			</template>

			<view style="display: flex;flex-direction: column;">

				<view class="item">
					<text class="text1">仓库数量</text>
					<text class="text2">{{info.stockNumber}}</text>
				</view>

				<view class="item">
					<text class="text1">汇总时间</text>
					<text class="text2">{{info.reportTime}}</text>
				</view>

				<view class="item" style="border-bottom: none;">
					<text class="text1">库存货值</text>
					<text class="text2">{{info.countAmount}}</text>
				</view>


			</view>

			<!-- <uni-list>
				<uni-list-item title="上报日期:" :rightText="logInfo.reportTime"></uni-list-item>
				<uni-list-item title="货值总计:" :right-text="logInfo.countAmount"></uni-list-item>
			</uni-list> -->

			<!-- 	<view v-for="(item, index) in tableData1" style="margin-top: 10px;">
				<view>
					<uni-title type="h3" :title="item.storeType" color="#444"></uni-title>
					<uni-row>
						<uni-col :span="8">
							<view class="table-header tleft"><text>仓库数量</text></view>
						</uni-col>
						<uni-col :span="8">
							<view class="table-header"><text>品种数量</text></view>
						</uni-col>
						<uni-col :span="8">
							<view class="table-header"><text>品种货值</text></view>
						</uni-col>
					</uni-row>
					<uni-row>
						<uni-col :span="8">
							<view class="table-body tleft"><text>{{item.storeNumber}}</text></view>
						</uni-col>
						<uni-col :span="8">
							<view class="table-body"><text>{{item.productCountNumber}}</text></view>
						</uni-col>
						<uni-col :span="8">
							<view class="table-body"><text>{{item.productAmount}}</text></view>
						</uni-col>
					</uni-row>

				</view>
			</view> -->

		</uni-card>

		<view v-for="(item, index) in list" style="margin-top: 10px;">

			<view class="layout" @click="itemClick(item)">

				<image src="../../static/baseIcon/warehouse.png" mode="aspectFill" style="width: 12px;height: 12px;">
				</image>

				<view class="content">
					<text class="content-text1">{{item.storeName}}</text>
					<text class="content-text2">{{item.productAmount }}</text>

				</view>
				<image src="../../static/baseIcon/zy.png" mode="aspectFill" style="width: 14px;height: 14px;"></image>
			</view>


		</view>

		<!-- 
		<uni-collapse style="margin-top: 10px;">

			<uni-collapse-item title="仓库库存明细表" style="font-size: 18px;" :open="false">

				<view style="display: flex;flex-direction: row;margin-left: 16px;">

					<view style="flex: 1;">
						<text>商品数量合计：</text>
						<text>{{logInfo2.countProductNumber}}</text>
					</view>

					<view style="flex: 1;">
						<text>商品货值合计：</text>
						<text>{{logInfo2.countAmount}}</text>
					</view>

				</view>
				<view class="ttbale" style="margin-top: 10px;">
					<uni-row>
						<uni-col :span="8">
							<view class="table-header tleft"><text>序号</text></view>
						</uni-col>
						<uni-col :span="16">
							<view class="table-header"><text>仓库名称</text></view>
						</uni-col>
					</uni-row>
					<uni-row>
						<uni-col :span="8">
							<view class="table-header tleft"><text>商品数量</text></view>
						</uni-col>
						<uni-col :span="8">
							<view class="table-header"><text>商品品种数量</text></view>
						</uni-col>
						<uni-col :span="8">
							<view class="table-header"><text>货值</text></view>
						</uni-col>
					</uni-row>
				</view>

				<view v-for="(item, index) in tableData2">

					<view class="ttbale">
						<uni-row>
							<uni-col :span="8">
								<view class="table-body tleft"><text>{{index+1}}</text></view>
							</uni-col>
							<uni-col :span="16">
								<view class="table-body"><text>{{item.storeCodeName}}</text></view>
							</uni-col>
						</uni-row>
						<uni-row>
							<uni-col :span="8">
								<view class="table-body tleft"><text>{{ item.productCountNumber}}</text></view>
							</uni-col>
							<uni-col :span="8">
								<view class="table-body"><text>{{item.typeNumber}}</text></view>
							</uni-col>
							<uni-col :span="8">
								<view class="table-body"><text>{{item.productAmount}}</text></view>
							</uni-col>
						</uni-row>
					</view>
				</view>

			</uni-collapse-item>

			<uni-collapse-item title="烟草库存明细表" style="font-size: 18px;" :open="false">

				<view style="display: flex;flex-direction: row;margin-left: 16px;">

					<view style="flex: 1;">
						<text>商品数量合计：</text>
						<text>{{logInfo3.countProductNumber}}</text>
					</view>

					<view style="flex: 1;">
						<text>商品货值合计：</text>
						<text>{{logInfo3.countAmount}}</text>
					</view>

				</view>
				<view class="ttbale" style="margin-top: 10px;">
					<uni-row>
						<uni-col :span="8">
							<view class="table-header tleft"><text>序号</text></view>
						</uni-col>
						<uni-col :span="16">
							<view class="table-header"><text>仓库名称</text></view>
						</uni-col>
					</uni-row>
					<uni-row>
						<uni-col :span="8">
							<view class="table-header tleft"><text>商品数量</text></view>
						</uni-col>
						<uni-col :span="8">
							<view class="table-header"><text>商品品种数量</text></view>
						</uni-col>
						<uni-col :span="8">
							<view class="table-header"><text>货值</text></view>
						</uni-col>
					</uni-row>
				</view>

				<view v-for="(item, index) in tableData3">

					<view class="ttbale">
						<uni-row>
							<uni-col :span="8">
								<view class="table-body tleft"><text>{{index+1}}</text></view>
							</uni-col>
							<uni-col :span="16">
								<view class="table-body"><text>{{item.storeCodeName}}</text></view>
							</uni-col>
						</uni-row>
						<uni-row>
							<uni-col :span="8">
								<view class="table-body tleft"><text>{{ item.productCountNumber}}</text></view>
							</uni-col>
							<uni-col :span="8">
								<view class="table-body"><text>{{item.typeNumber}}</text></view>
							</uni-col>
							<uni-col :span="8">
								<view class="table-body"><text>{{item.productAmount}}</text></view>
							</uni-col>
						</uni-row>
					</view>
				</view>


			</uni-collapse-item>


		</uni-collapse> -->




	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				params: {
					projectSid: "",
					orderDate: "",
				},
				info: {
					fullUrl: "",
					projectName: "",
					stockNumber: "",
					reportTime: "",
					countAmount: "",
				},
				list: [
					// {
					// 	sid: "",
					// 	name: "",
					// 	price: ""
					// },
					// {
					// 	sid: "",
					// 	name: "",
					// 	price: ""
					// },
				],

			}
		},
		onLoad(option) {

			this.params = option
			
			this.params = {
				projectSid: option.projectSid,
				orderDate: option.orderDate
			}

			this.getData()



		},
		onShow() {
			wx.hideHomeButton()
		},
		methods: {
			onClick(e) {
				if (this.info.fullUrl == '') {
					uni.showToast({
						icon: "none",
						title: "下载地址错误，请重新进入页面。",
						duration: 5000
					})
					return
				}


				uni.downloadFile({
					url: this.info.fullUrl, // 网络文档地址
					success: (data) => {
						if (data.statusCode === 200) {
							uni.saveFile({
								tempFilePath: data.tempFilePath, //临时路径
								success: function(res) {
									// 保存路径
									uni.showToast({
										title: "文件已保存：" + res.savedFilePath,
										duration: 5000
									})
									setTimeout(() => {
										//打开文档查看
										uni.openDocument({
											filePath: res.savedFilePath,
											showMenu: true, //右上角是否有可以转发分享的功能
											success: function(res) {
												console.log('打开文档成功')
											}
										})
									}, 3000);
								}
							});
						}
					},
					fail: (err) => {
						uni.showToast({
							title: '失败请重新下载'
						});
					},
				});

			},
			getData() {
				console.log('getData', this.params)
				this.$api.getDayGather(this.params).then((resp) => {
					console.log('1111>>>>>>', resp)

					this.info = resp

				}).catch(e => {
					console.log('eeeee', e)
				})
				
				this.$api.getDayStore(this.params).then((resp) => {
					console.log('1111>>>>>>', resp)
				
					this.list = resp
				
				
				}).catch(e => {
					console.log('eeeee', e)
				})

			},

			itemClick(item) {
				console.log('itemClick>>', item)
				uni.navigateTo({
					url: 'InventorySummaryDetail?sid=' + item.sid + "&projectName=" + item.storeName +
						"&stockPrice=" + item.productAmount
				});
			}

		}
	}
</script>

<style lang="scss">
	.pages {}

	$uni-success: #18bc37 !default;

	.item {

		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 20px;
		margin-right: 20px;
		border-bottom: 1px solid #F1F3F5;
		padding: 10px;

		.text1 {
			flex: 1;
			font-size: 14px;
			color: #191919;
		}


		.text2 {
			flex: 1;
			font-size: 14px;
			color: #717171;
		}

	}

	.layout {
		background: #fff;
		border-radius: 10px;
		padding: 15px;
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-bottom: 10px;

		.content {
			margin-left: 10px;
			margin-right: 10px;
			flex: 1;
			display: flex;
			flex-direction: row;
			justify-content: space-between;

			.content-text1 {
				font-size: 14px;
				color: #191919;
			}

			.content-text2 {
				font-size: 14px;
				color: #6c6c6c;
			}
		}
	}

	.table-header {
		text-align: center;
		border: 0.5px solid #ccc;
		font-weight: bold;
		font-size: 15px;
		border-left: 0.0px;
		padding: 5px;
	}

	.table-body {
		text-align: center;
		border: 0.5px solid #ccc;
		font-size: 13px;
		padding: 5px;
		border-left: 0.0px;
		border-top: 0.0px;
	}

	.tleft {
		border-left: 0.5px solid #ccc;
	}

	.ttbale {
		margin: 0px 10px 0px 10px;
		// border-bottom: 1px solid #ccc;
	}

	.uni-wrap {
		flex-direction: column;
		/* #ifdef H5 */
		height: calc(100vh - 44px);
		/* #endif */
		/* #ifndef H5 */
		height: 100vh;
		/* #endif */
		flex: 1;
	}

	.mb-10 {
		margin-bottom: 10px;
	}

	.decoration {
		width: 8px;
		height: 8px;
		margin-right: 4px;
		border-radius: 50%;
		background-color: $uni-success;
	}
</style>