<template>
	<view class="container">
		<uni-datetime-picker style="margin-bottom:20rpx;" v-model="range" type="daterange"
			@change="searchList" />
		<view class="tui-order-item boxbg" v-if="type=='khName'">
			<view style="background: #fff;border: 1px solid #eee;">
				<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
					activeColor="#007aff"></uni-segmented-control>
			</view>
			<view class="content">

				<view v-show="current === 1">
					<view class="shop-box" v-for="(item,index4) in list" :key="index4"
						style="background: #fff;display: block;overflow: hidden;margin: 0 auto 20rpx;">
						<view>
							<view style="width: 100%;height: 80rpx;line-height: 80rpx;">
								<text
									style="display:inline-block;width: 55%;text-align: center;font-weight: bold;font-size: 30rpx;">
									日期:{{item.createTime | removeStr}}
								</text>
								<text
									style="display:inline-block;width: 45%;text-align: center;border-left: 1px solid #eee;">
									操作:{{item.createByName}}
								</text>
							</view>
							<uni-table border stripe emptyText="暂无更多数据">
								<!-- 表头行 -->
								<uni-tr style="background: #eee;">
									<uni-th align="center" width="60">货号</uni-th>
									<uni-th align="center" width="50">数量</uni-th>
									<uni-th align="center" width="70">单价</uni-th>
									<uni-th align="center" width="70">总价</uni-th>
									<uni-th align="center" width="70">成本</uni-th>
									<uni-th align="center" width="70">利润</uni-th>
								</uni-tr>
								<!-- 表格数据行 -->
								<uni-tr v-for="(item1,index) in item.saleDetailDTOList" :key="index" @tap="xiaoshouDetail('1',item1)">
									<uni-td align="center">{{item1.productSn}}</uni-td>
									<uni-td align="center">{{item1.productCount == null ?'0':item1.productCount}}</uni-td>
									<uni-td align="center">{{item1.discountAmount}}</uni-td>
									<uni-td align="center">{{item1.discountAmount * item1.productCount}}</uni-td>
									<uni-td align="center">{{userType == 0 && isDownKH == false?(item1.purchasePrice * item1.productCount).toFixed(2):'0'}}</uni-td>
									<uni-td align="center">{{userType == 0 && isDownKH == false?((item1.discountAmount - item1.purchasePrice)*item1.productCount).toFixed(2):0}}</uni-td>
								</uni-tr>
								<uni-tr>
									<uni-td align="center">
										<text style="font-weight: bold;">总数量:</text>
									</uni-td>
									<uni-td align="center">
										<text style="font-weight: bold;">{{item.productCount}}</text>
									</uni-td>
									<uni-td align="center">
										<text style="font-weight: bold;"></text>
									</uni-td>
									<uni-td align="center">
										<text style="font-weight: bold;"></text>
									</uni-td>
									<uni-td align="center">
										<text style="font-weight: bold;">拿货总价:</text>
									</uni-td>
									<uni-td align="center">
										<text style="font-weight: bold;">{{item.totalAmount}}</text>
									</uni-td>
								</uni-tr>
							</uni-table>
						</view>
					</view>
				</view>
				<view v-show="current === 0">
					<view
						style="background: linear-gradient(90deg, #6484fa 0%, #66e8ff 100%);overflow: hidden;color:#eee;">
						<view class="top" ref="top">
							<view class="top1">
								<view class="hello-box">
									<view class="hello-left">
										<text
											style="font-size: 40rpx;font-weight: 800;line-height: 56rpx;color: rgba(86, 132, 255, 1);">
											Hi
										</text>
									</view>
									<view class="hello-name">
										{{shopName+'对账单'}}
									</view>
									<view class="hello-right"></view>

								</view>
								<view class="hello-text">
									欢迎查看客户:{{duizhangList.userName == null ?"" : duizhangList.userName}}的对账单
								</view>
								<view>
									<view @tap="getAmount()" style="width: 130rpx;height: 60rpx;background: linear-gradient(90deg, #6484fa 0%, #66e8ff 100%);color: #fff;border-radius: 10px;position: absolute;top: 200rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
										拿货统计
									</view>
									<!-- 彬嗨商贸 -->
									<view @tap="getBuyDetail()" v-if="shopId == '1838094297858183168' || shopId == '1810179818189361152'" style="width: 130rpx;height: 60rpx;background: linear-gradient(90deg, #6484fa 0%, #66e8ff 100%);color: #fff;border-radius: 10px;position: absolute;top: 280rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
										拿货详情
									</view>
								</view>
								<view
									style="text-align: center;display: flex;border-top: 1px solid #eee;padding: 20rpx 0;color: #7E5E60;position: absolute;top: 380rpx;width: 100%;font-weight: bold;font-size: 24rpx;">
									<view style="display: flex;flex-direction: column;width: 20%;">
										<text>{{duizhangList.initialArrears >= 0?'期初欠款':'期初余额'}}</text>
										<text>{{duizhangList.initialArrears == null ?"0" :Math.abs(duizhangList.initialArrears)}}</text>
									</view>
									<view
										style="display: flex;flex-direction: column;width: 20%;border-left: 1px solid #eee;">
										<text>{{duizhangList.endArrears >= 0?'期末欠款':'期末余额'}}</text>
										<text>{{duizhangList.endArrears == null ?"0" :Math.abs(duizhangList.endArrears)}}</text>
									</view>
									<view
										style="display: flex;flex-direction: column;width: 20%;border-left: 1px solid #eee;">
										<text>{{duizhangList.arrears >= 0?'本期欠款':'本期余额'}}</text>
										<text>{{duizhangList.arrears == null ?"0" :Math.abs(duizhangList.arrears)}}</text>
									</view>
									<view
										style="display: flex;flex-direction: column;width: 20%;border-left: 1px solid #eee;">
										<text>拿货总额</text>
										<text>{{duizhangList.totalSale == null ?"0" :duizhangList.totalSale}}</text>
									</view>
									<view
										style="display: flex;flex-direction: column;width: 20%;border-left: 1px solid #eee;">
										<text>退货总额</text>
										<text>{{duizhangList.totalReturn == null ?"0" :duizhangList.totalReturn}}</text>
									</view>
								</view>
							</view>

						</view>

					</view>
					<view v-if="duizhangList" v-for="(item,index) in duizhangRecords" :key="index"
						style="background: #fff;display: block;overflow: hidden;margin: 20rpx auto;width: 95%;border-radius: 10px;position: relative;">
						<view style="display: flex;">
							<view
								style="margin-top: 40rpx;width: 120rpx;height: 120rpx;border-radius: 80rpx;background: #8470FF;color: #fff;font-size: 26rpx;padding: 24rpx 34rpx;margin: 35rpx 0 0 35rpx;">
								{{item.dealingsType == 0 ?"销售开单" :item.dealingsType == 1 ?"退货" :item.dealingsType == 2 ?"回款" :item.dealingsType == 3 && item.amount< 0?"初始余额" :item.dealingsType == 3 && item.amount>= 0?"初始欠款" :item.dealingsType == 4 ?"充值金额" :item.dealingsType == 5 ?"追加欠款" :item.dealingsType == 6 ?"撤销订单" :item.dealingsType == 99 ?"撤销充值" :""}}
							</view>
							<view style="height: 170rpx;line-height: 50rpx;padding-left: 30rpx;">
								<view
									style="color: #747474;font-size: 28rpx;font-weight: bold;font-size: 32rpx;color: #000;" :style="{'margin-top':item.isOldName== false?'20rpx':'34rpx'}">
									{{item.createTime | removeStr}}
								</view>
								<view style="color: #747474;font-size: 28rpx;">
									操作人:{{item.createByName == null ?"" :item.createByName}}
								</view>
								<view v-if="item.isOldName== false" style="color: red;font-size: 28rpx;">
									客户:{{item.dealingsUserName}}
								</view>
								<view @tap="oneShare(item,'xiaoshou')" v-if="item.dealingsType == 0 && isDownKH == false && item.delFlag == 0 &&item.billSaleDetailVos != null" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 30rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									分享
								</view>
								<view @tap="oneShare(item,'chongzhi')" v-if="(item.dealingsType == 4 || item.dealingsType == 5) && isDownKH == false" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 30rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									分享
								</view>
								<view @tap="revokeRecharge(item)" v-if="(item.dealingsType == 4 || item.dealingsType == 5) && isDownKH == false" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 110rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									撤销
								</view>
								<view @tap="delDZD(item)" v-if="userType == 0 && isDownKH == false &&(item.dealingsType == 4 ||  item.dealingsType == 5) && item.delFlag == 1" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 110rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									删除
								</view>
								<view @tap="delDZD(item)" v-if="userType == 0 && isDownKH == false &&item.dealingsType == 99" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 110rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									删除
								</view>
								<img v-if="item.delFlag == 1 && item.dealingsType == 0 && item.billSaleDetailVos != null" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/7650e962bef14f529406866888eeff24.png" alt="" style="position: absolute;top: 0;right:0;width: 300rpx;height: 150rpx;" />
								<img v-if="item.delFlag == 1 && (item.dealingsType == 4 || item.dealingsType == 5)" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/7650e962bef14f529406866888eeff24.png" alt="" style="position: absolute;top: 0;right:0;width: 300rpx;height: 150rpx;" />
								<img v-if="item.delFlag == 1 && item.dealingsType == 0 && item.billSaleDetailVos == null" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/7517e15b5cf843d59b5b69c3a06a5d7b.png" alt="" style="position: absolute;top: 0;right:0;width: 200rpx;height: 110rpx;" />
								<img v-if="item.dealingsType == 6 || item.dealingsType == 99" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/862680ecfe5a48b1a410287fb45987ef.png" alt="" style="position: absolute;top: 0;right:0;width: 300rpx;height: 150rpx;" />
							</view>
						</view>
						<view v-if="item.billSaleDetailVos != null || item.billReturnSaleDetailVos != null"
							style="height: 60rpx;line-height: 60rpx;padding-left: 20rpx;font-size: 28rpx;background: #FFF0F5;color: #F08080;margin-bottom: 20rpx;width: 95%;margin: 0 auto 20rpx;border-radius: 5px;">
							拿货数据~请查收
						</view>
						<view @tap="delDZD(item)" v-if="userType == 0 && isDownKH == false && item.billSaleDetailVos != null && (item.dealingsType == 6 || (item.dealingsType == 0 && item.delFlag == 1))" style="position: absolute;top: 173rpx;right: 17rpx;width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;text-align: center;line-height: 60rpx;border-radius: 5px;">
							删除
						</view>
						<view @tap="delDZD(item)" v-if="userType == 0 && isDownKH == false && item.billSaleDetailVos == null && (item.dealingsType == 6 || (item.dealingsType == 0 && item.delFlag == 1))" style="position: absolute;top: 116rpx;right: 17rpx;width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;text-align: center;line-height: 60rpx;border-radius: 5px;">
							删除
						</view>
						<view v-if="item.billSaleDetailVos != null"
							style="width: 95%;margin: 0 auto;border: 1.5px solid #000;border-radius: 10px;">
							<uni-table stripe>
								<uni-tr style="background: #FFBF00;">
									<uni-th align="center" width="120">
										<text style="font-weight: bold;">
											【销】
										</text>
										货号
									</uni-th>
									<uni-th align="center" width="55">数量</uni-th>
									<uni-th align="center" width="70">销售价</uni-th>
									<uni-th align="center" width="80">总价</uni-th>
								</uni-tr>
								<!-- 表格数据行 -->
								<uni-tr v-for="(item1,index1) in item.billSaleDetailVos" :key="index1"
									@tap="clickDetail(item1)">
									<uni-td align="center">
										<text>
											{{item1.productSn == null ?"" :item1.productSn}}
										</text>
									</uni-td>
									<uni-td
										align="center">{{item1.productCount == null ?"0" :item1.productCount}}</uni-td>
									<uni-td
										align="center">{{item1.discountAmount == null ?"0" :item1.discountAmount}}</uni-td>
									<uni-td
										align="center">{{item1.totalAmount == null ?"0" :item1.totalAmount}}</uni-td>
								</uni-tr>
							</uni-table>
						</view>
						
						<view style="border-bottom: 2px solid #eee;" v-if="item.dealingsType == '4' || item.dealingsType == '5'">
							<view style="font-weight: bold;padding: 20rpx;">
								充值明细:
							</view>
							<view style="margin: 0 0 40rpx;">
								<view>
									<view style="padding-left: 20rpx;">
										<text>充值时间:{{item.dealingsTime == null?'':item.dealingsTime}}</text>
									</view>
									<view style="padding-left: 20rpx;">
										<text>充值备注:{{item.dealingsRecordRemark == null?'':item.dealingsRecordRemark}}</text>
									</view>
								</view>
							</view>
						</view>
						
						<view v-if="item.billReturnSaleDetailVos != null"
							style="width: 95%;margin: 20rpx auto 0;border: 1.5px solid #000;border-radius: 10px;">
							<uni-table stripe>
								<uni-tr style="background: #FFBF00;">
									<uni-th align="center" width="120">
										<text style="font-weight: bold;color:#F08080;">
											【退】
										</text>
										货号
									</uni-th>
									<!-- <uni-th align="center">规格</uni-th> -->
									<uni-th align="center" width="55">数量</uni-th>
									<uni-th align="center" width="70">退货价</uni-th>
									<uni-th align="center" width="80">总价</uni-th>
								</uni-tr>
								<!-- 表格数据行 -->
								<uni-tr v-for="(item1,index1) in item.billReturnSaleDetailVos" :key="index1"
									@tap="clickDetail(item1)">
									<uni-td align="center">
										<text>
											{{item1.productSn == null ?"" :item1.productSn}}
										</text>
									</uni-td>
									<uni-td
										align="center">{{item1.productCount == null ?"0" :item1.productCount}}</uni-td>
									<uni-td
										align="center">{{item1.discountAmount == null ?"0" :item1.discountAmount}}</uni-td>
									<uni-td
										align="center">{{item1.totalAmount == null ?"0" :item1.totalAmount}}</uni-td>
								</uni-tr>
							</uni-table>
						</view>


						<view style="border-bottom: 2px solid #eee;" v-if="item.billSaleDetailVos != null">
							<view style="font-weight: bold;padding: 20rpx;">
								付款明细:
							</view>
							<view>
								<view>
									<view style="padding-left: 20rpx;">
										<text>销售金额:{{item.totalAmount == null ?"0" :item.totalAmount}}</text>
									</view>
									<view style="padding-left: 20rpx;">
										<text>退货金额:{{item.returnSaleTotalAmount == null ?"0" :item.returnSaleTotalAmount}}</text>
									</view>
								</view>
								<view style="padding-left: 20rpx;margin-top: 40rpx;">
									<view>欠款抵退货:{{item.debtDeductionAmount == null ?"0" :item.debtDeductionAmount}}
									</view>
									<view>销售抵退货:{{item.saleDeductionAmount == null ?"0" :item.saleDeductionAmount}}
									</view>
									<view>
										余额抵销售:{{item.balanceDeductionAmount == null ?"0" :item.balanceDeductionAmount}}
									</view>
								</view>
								<view v-if="item.remark != '' && item.remark !=undefined && item.remark != null" style="padding-left: 20rpx;margin-top: 40rpx;">
									<view>备注:{{item.remark}}</view>
								</view>
							</view>
							<view
								style="padding-left: 20rpx;margin: 40rpx 0 20rpx;height: 60rpx;line-height: 60rpx;text-align: center;font-size: 30rpx;font-weight: bold;display: flex;">
								<text style="flex: 1;">本单应收:{{item.realAmount == null ?"0" :item.realAmount}}</text>
								<text
									style="display: inline-block;padding-left: 20rpx;flex: 1;">本单实收:{{item.alreadyEarn == null ?"0" :item.alreadyEarn}}</text>
							</view>
						</view>
						<view style="text-align: center;display: flex;padding: 20rpx 0;color: #000;">
							<view v-if="item.lastDebtAmount >= 0" style="flex: 1;display: flex;flex-direction: column;">
								<text>之前欠款</text>
								<text>{{item.lastDebtAmount == null ?"0" :item.lastDebtAmount}}</text>
							</view>
							<view v-if="item.lastDebtAmount < 0" style="flex: 1;display: flex;flex-direction: column;">
								<text>之前余额</text>
								<text>{{item.lastDebtAmount == null ?"0" :Math.abs(item.lastDebtAmount)}}</text>
							</view>
							<view v-if="item.dealingsType == 5 || item.amount >= 0"
								style="flex: 1;border-left: 1px solid #eee;display: flex;flex-direction: column;">
								<text>{{item.dealingsType == 5?'追加欠款':item.dealingsType == 4?'充值金额':item.dealingsType == 6?'撤销余额':item.dealingsType == 10?'本单退款':item.dealingsType == 99?'撤销充值':'本单欠款'}}</text>
								<text>{{item.amount == null ?"0" :item.dealingsType == 5?Math.abs(item.amount):item.amount}}</text>
							</view>
							<view v-if="item.amount < 0 && item.dealingsType != 5"
								style="flex: 1;border-left: 1px solid #eee;display: flex;flex-direction: column;">
								<text>{{item.dealingsType == 4?'充值金额':item.dealingsType == 6?'撤销欠款':item.dealingsType == 99?'撤销欠款':'本单余额'}}</text>
								<text>{{item.amount == null ?"0" :Math.abs(item.amount)}}</text>
							</view>
							<view v-if="item.balanceDue >= 0"
								style="flex: 1;border-left: 1px solid #eee;display: flex;flex-direction: column;">
								<text>{{item.dealingsType == 6?'撤销后欠款':'本单后欠款'}}</text>
								<text>{{item.balanceDue == null ?"0" :item.balanceDue}}</text>
							</view>
							<view v-if="item.balanceDue < 0"
								style="flex: 1;border-left: 1px solid #eee;display: flex;flex-direction: column;">
								<text>{{item.dealingsType == 6?'撤销后余额':'本单后余额'}}</text>
								<text>{{item.balanceDue == null ?"0" :Math.abs(item.balanceDue)}}</text>
							</view>
						</view>
					</view>
					<view style="text-align: center;margin-bottom:20rpx;">
						<text>对账时间:{{duizhangList.queryDate == null ?"" :duizhangList.queryDate}}</text>
					</view>
				</view>
				<view v-show="current === 2">
					<view class="shop-box" v-for="(item,index4) in list" :key="index4"
						style="background: #fff;display: block;overflow: hidden;margin: 0 auto 20rpx;">
						<view>
							<view
								style="padding-left: 20rpx;margin: 40rpx 0; font-weight: bold;font-size: 36rpx;text-align: center;">
								<text>货号:{{item.productSn == null?'':item.productSn}}</text>
							</view>
							<view style="text-align: center;margin-bottom:20rpx;">
								<text>名称:{{item.productName == null?'':item.productName}}</text>
								<text
									style="padding: 0 20rpx;">总数量:{{item.productCount == undefined ?'0':item.productCount}}</text>
								<text style="padding: 0 20rpx;" v-if="userType == 0 && isDownKH == false">采购价:{{item.customerBuySaleVoList[0].customerBuyProductDetailLogVos[0].purchasePrice == null ?'':item.customerBuySaleVoList[0].customerBuyProductDetailLogVos[0].purchasePrice}}</text>
							</view>
							<uni-table border stripe emptyText="暂无更多数据">
								<!-- 表头行 -->
								<uni-tr style="background: #eee;">
									<uni-th align="center" width="100">日期</uni-th>
									<uni-th align="center" width="50">数量</uni-th>
									<uni-th align="center" width="70">单价</uni-th>
									<uni-th align="center" width="70">总价</uni-th>
									<uni-th align="center" width="70">利润</uni-th>
								</uni-tr>
								<!-- 表格数据行 -->
								<uni-tr v-for="(item1,index1) in item.customerBuySaleVoList" :key="index1"
									@tap="xiaoshouDetail('2',item1)">
									<uni-td align="center">{{item1.createTime | removeStr}}</uni-td>
									<uni-td align="center">{{item1.productCount}}</uni-td>
									<uni-td
										align="center">{{item1.customerBuyProductDetailLogVos[0].realPrice}}</uni-td>
									<uni-td
										align="center">{{item1.customerBuyProductDetailLogVos[0].realPrice * item1.productCount}}</uni-td>
									<uni-td
										align="center">{{userType == 0 && isDownKH == false?((item1.customerBuyProductDetailLogVos[0].realPrice - item1.customerBuyProductDetailLogVos[0].purchasePrice) * item1.productCount).toFixed(2):0}}</uni-td>
								</uni-tr>
							</uni-table>
						</view>
					</view>
				</view>
				<view v-show="current === 3">
					<view v-for="(item,index) in list" :key="index"
						style="background: #fff;display: block;overflow: hidden;margin: 0 auto 20rpx;">
						<view style="width: 100%;height: 80rpx;line-height: 80rpx;">
							<text
								style="display:inline-block;width: 55%;text-align: center;font-weight: bold;font-size: 30rpx;">
								日期:{{item.createTime | removeStr}}
							</text>
							<text
								style="display:inline-block;width: 45%;text-align: center;border-left: 1px solid #eee;">
								操作:{{item.createByName == null?'':item.createByName}}
							</text>
						</view>
						<uni-table border stripe emptyText="暂无更多数据">
							<!-- 表头行 -->
							<uni-tr style="background: #eee;">
								<uni-th align="center" width="85">货号</uni-th>
								<uni-th align="center" width="50">数量</uni-th>
								<uni-th align="center" width="70">退货价</uni-th>
								<!-- <uni-th align="center" width="70">采购价</uni-th> -->
							</uni-tr>
							<!-- 表格数据行 -->
							<uni-tr v-for="(items,index1) in item.returnSaleDetailList" :key="index1"
								@tap="xiaoshouDetail('3',items)">
								<uni-td align="center">{{items.productSn == null ? '': items.productSn}}</uni-td>
								<uni-td align="center">{{items.productCount}}</uni-td>
								<uni-td align="center">{{items.discountAmount}}</uni-td>
								<!-- <uni-td align="center">{{userType == 0 && isDownKH == false?items.purchasePrice == null?0:items.purchasePrice:0}}</uni-td> -->
							</uni-tr>
						</uni-table>
					</view>
				</view>
			</view>
			<view class="shop-box" v-if="type==1" v-for="(item,index3) in list" :key="index3">
				<uni-card :title="'供应商：'+ (item.purchase.supplierName?item.purchase.supplierName:'暂无')"
					:sub-title="item.purchase.createTime?item.purchase.createTime:'暂无'">
					<view class="uni-body" style="text-align: center;"><text
							v-if="userType == 0 && isDownKH == false">采购价：{{item.purchaseDetails[0].purchasePrice?item.purchaseDetails[0].purchasePrice:'暂无'}}</text>
						总数量：{{item.purchase.totalAmount?item.purchase.totalAmount:'暂无'}}</view>
					<view style="margin: 10rpx 0;height: 1px;background: #eee;"></view>
					<view style="display: flex;border-bottom: 1px solid #eee;height: 50rpx;line-height: 50rpx;">
						<view style="width: 49%;text-align: center;border-right: 1px solid #eee;">商品规格</view>
						<view style="width: 50%;text-align: center;">总数量</view>
					</view>
					<view v-for="(items,index1) in item.purchaseDetails" :key="index1">
						<view v-for="(data,index2) in items.stockLogList1" :key="index2"
							style='height: 50rpx;line-height: 50rpx;'>
							<view style="width: 49%;text-align: center;border-right: 1px solid #eee;float: left;">
								{{data.attributeList | sliceMsg}}
							</view>
							<view style="width: 50%;text-align: center;float: left;">
								{{data.productCount}}
							</view>
						</view>
					</view>
				</uni-card>
			</view>
		</view>
		<view class="tui-order-item boxbg" v-else>
			<view style="background: #fff;border: 1px solid #eee;">
				<uni-segmented-control :current="current" :values="itemsGYS" @clickItem="onClickItem" styleType="text"
					activeColor="#007aff"></uni-segmented-control>
			</view>
			<view class="content">

				<view v-show="current === 1">
					<view class="shop-box" v-for="(item,index4) in list" :key="index4"
						style="background: #fff;display: block;overflow: hidden;margin: 0 auto 20rpx;">
						<view>
							<view style="width: 100%;height: 80rpx;line-height: 80rpx;">
								<text
									style="display:inline-block;width: 55%;text-align: center;font-weight: bold;font-size: 30rpx;">
									日期:{{item.purchase.createTime}}
								</text>
								<text
									style="display:inline-block;width: 45%;text-align: center;border-left: 1px solid #eee;">
									操作:{{item.purchase.createByName}}
								</text>
							</view>
							<uni-table border stripe emptyText="暂无更多数据">
								<!-- 表头行 -->
								<uni-tr style="background: #eee;">
									<uni-th align="center" width="60">货号</uni-th>
									<uni-th align="center" width="50">数量</uni-th>
									<uni-th align="center" width="70">采购价</uni-th>
									<uni-th align="center" width="70">总金额</uni-th>
								</uni-tr>
								<!-- 表格数据行 -->
								<uni-tr v-for="(item1,index) in item.purchaseDetails" :key="index"
									@tap="xiaoshouDetail('1',item1)">
									<uni-td align="center">{{item1.productSn}}</uni-td>
									<uni-td
										align="center">{{item1.productCount == null ?'0':item1.productCount}}</uni-td>
									<uni-td align="center">{{item1.purchasePrice?item1.purchasePrice:0}}</uni-td>
									<uni-td align="center">{{item1.productCount * item1.purchasePrice || 0}}</uni-td>
								</uni-tr>
								<uni-tr>
									<uni-td align="center">
										<text style="font-weight: bold;">总数量:</text>
									</uni-td>
									<uni-td align="center">
										<text style="font-weight: bold;">{{item.purchase.productCount}}</text>
									</uni-td>
									<uni-td align="center">
										<text style="font-weight: bold;">总价:</text>
									</uni-td>
									<uni-td align="center">
										<text style="font-weight: bold;">{{item.purchase.shouldPay}}</text>
									</uni-td>
								</uni-tr>
							</uni-table>
						</view>
					</view>
				</view>
				<view v-show="current === 0">
					<view
						style="background: linear-gradient(90deg, #6484fa 0%, #66e8ff 100%);overflow: hidden;color:#eee;">
						<view class="top" ref="top">
							<view class="top1">
								<view class="hello-box">
									<view class="hello-left">
										<text
											style="font-size: 40rpx;font-weight: 800;line-height: 56rpx;color: rgba(86, 132, 255, 1);">
											Hi
										</text>
									</view>
									<view class="hello-name">
										{{shopName+'对账单'}}
									</view>
									<view class="hello-right"></view>

								</view>
								<view class="hello-text">
									欢迎查看供应商:{{duizhangList.userName == null ?"" : duizhangList.userName}}的对账单
								</view>
								<view>
									<view @tap="getAmount()" style="width: 130rpx;height: 60rpx;background: linear-gradient(90deg, #6484fa 0%, #66e8ff 100%);color: #fff;border-radius: 10px;position: absolute;top: 200rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
										拿货统计
									</view>
								</view>
								<view
									style="text-align: center;display: flex;border-top: 1px solid #eee;padding: 10px 0;color: #7E5E60;position: absolute;top: 380rpx;width: 100%;font-weight: bold;">
									<view style="display: flex;flex-direction: column;width: 25%;">
										<text>{{duizhangList.initialArrears >= 0?'期初欠款':'期初余额'}}</text>
										<text>{{duizhangList.initialArrears == null ?"0" :Math.abs(duizhangList.initialArrears)}}</text>
									</view>
									<view
										style="display: flex;flex-direction: column;width: 25%;border-left: 1px solid #eee;">
										<text>{{duizhangList.endArrears >= 0?'期末欠款':'期末余额'}}</text>
										<text>{{duizhangList.endArrears == null ?"0" :Math.abs(duizhangList.endArrears)}}</text>
									</view>
									<view
										style="display: flex;flex-direction: column;width: 25%;border-left: 1px solid #eee;">
										<text>{{duizhangList.arrears >= 0?'本期欠款':'本期余额'}}</text>
										<text>{{duizhangList.arrears == null ?"0" :Math.abs(duizhangList.arrears)}}</text>
									</view>
									<view
										style="display: flex;flex-direction: column;width: 25%;border-left: 1px solid #eee;">
										<text>拿货总额</text>
										<text>{{duizhangList.totalSale == null ?"0" :duizhangList.totalSale}}</text>
									</view>
									<!-- <view
										style="display: flex;flex-direction: column;width: 20%;border-left: 1px solid #eee;">
										<text>退货总额</text>
										<text>{{duizhangList.totalReturn == null ?"0" :duizhangList.totalReturn}}</text>
									</view> -->
								</view>
							</view>

						</view>

					</view>
					<view v-if="duizhangList" v-for="(item,index) in duizhangRecords" :key="index"
						style="background: #fff;display: block;overflow: hidden;margin: 20rpx auto;width: 95%;border-radius: 10px;position: relative;">
						<view style="display: flex;position: relative;">
							<view
								style="margin-top: 40rpx;width: 100rpx;height: 100rpx;border-radius: 80rpx;background: #8470FF;color: #fff;font-size: 26rpx;padding: 17rpx 24rpx;margin: 35rpx 0 0 35rpx;">
								{{item.dealingsType == 0 ?"销售开单" :item.dealingsType == 1 ?"退货" :item.dealingsType == 2 ?"回款" :item.dealingsType == 3 && item.amount< 0?"初始余额" :item.dealingsType == 3 && item.amount>= 0?"初始欠款" :item.dealingsType == 4 ?"充值金额" :item.dealingsType == 5 ?"追加欠款" :item.dealingsType == 6 ?"撤销订单" :item.dealingsType == 7 ?"采购订单" :item.dealingsType == 9 ?"采购退货":item.dealingsType == 10 ?"撤销退货":item.dealingsType == 99 ?"撤销充值" :""}}
							</view>
							<view style="height: 170rpx;line-height: 50rpx;padding-left: 30rpx;">
								<view
									style="color: #747474;font-size: 28rpx;font-weight: bold;font-size: 32rpx;color: #000;margin-top:12rpx;">
									操作时间:{{item.createTime | removeStr}}
								</view>
								<view v-if="item.dealingsType == 7 && item.purchaseTime != null" style="color: #747474;font-size: 28rpx;">
									拿货时间:{{item.purchaseTime | removeStr}}
								</view>
								<view style="color: #747474;font-size: 28rpx;">
									操作人:{{item.createByName == null ?"" :item.createByName}}
								</view>
								<view @tap="oneShare(item,'caigou')" v-if="item.dealingsType == 7 && isDownKH == false && item.delFlag == 0 &&item.billSaleDetailVos != null" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 74rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									分享
								</view>
								<view @tap="oneShare(item,'chongzhi')" v-if="(item.dealingsType == 4 || item.dealingsType == 5) && isDownKH == false" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 74rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									分享
								</view>
								<view @tap="oneShare(item,'tuihuo')" v-if="item.dealingsType == 9 && isDownKH == false" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 74rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									分享
								</view>
								<view @tap="revokeRecharge(item)" v-if="(item.dealingsType == 4 || item.dealingsType == 5) && item.delFlag == 0 && isDownKH == false" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 150rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									撤销
								</view>
								<view @tap="delDZD(item)" v-if="userType == 0 && isDownKH == false && (item.dealingsType == 4 || item.dealingsType == 5) && item.delFlag == 1" style="width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;border-radius: 10px;position: absolute;top: 150rpx;right: 20rpx;text-align: center;line-height: 60rpx;">
									删除
								</view>
							</view>
							<img v-if="item.delFlag == 1&&( item.dealingsType == 7 ||  item.dealingsType == 5 ||  item.dealingsType == 4)" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/7650e962bef14f529406866888eeff24.png" alt="" style="position: absolute;top: 0;right:0;width: 300rpx;height: 150rpx;" />
							<img v-if="item.dealingsType == 6 || item.dealingsType == 10 || item.dealingsType == 99" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/862680ecfe5a48b1a410287fb45987ef.png" alt="" style="position: absolute;top: 0;right:0;width: 300rpx;height: 150rpx;" />
						</view>
						<view v-if="item.billSaleDetailVos != null || item.billReturnSaleDetailVos != null"
							style="height: 60rpx;line-height: 60rpx;padding-left: 20rpx;font-size: 28rpx;background: #FFF0F5;color: #F08080;margin-bottom: 20rpx;width: 95%;margin: 0 auto 20rpx;border-radius: 5px;">
							拿货数据~请查收
						</view>
						<view @tap="delDZD(item)" v-if="userType == 0 && isDownKH == false &&item.billSaleDetailVos != null && (item.dealingsType == 6 || (item.dealingsType == 7 && item.delFlag == 1))" style="position: absolute;top: 173rpx;right: 17rpx;width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;text-align: center;line-height: 60rpx;border-radius: 5px;">
							删除
						</view>
						<view @tap="delDZD(item)" v-if="userType == 0 && isDownKH == false &&item.billSaleDetailVos == null && (item.dealingsType == 6 || (item.dealingsType == 7 && item.delFlag == 1))" style="position: absolute;top: 116rpx;right: 17rpx;width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;text-align: center;line-height: 60rpx;border-radius: 5px;">
							删除
						</view>
						<view @tap="delDZD(item)" v-if="userType == 0 && isDownKH == false && item.dealingsType == 99" style="position: absolute;top: 116rpx;right: 17rpx;width: 100rpx;height: 60rpx;background: #088FEB;color: #fff;text-align: center;line-height: 60rpx;border-radius: 5px;">
							删除
						</view>
						<view v-if="item.billSaleDetailVos != null"
							style="width: 95%;margin: 0 auto;border: 1.5px solid #000;border-radius: 10px;">
							<uni-table stripe>
								<uni-tr style="background: #FFBF00;">
									<uni-th align="center" width="120">
										货号
									</uni-th>
									<uni-th align="center" width="55">数量</uni-th>
									<uni-th align="center" width="70">拿货价</uni-th>
									<uni-th align="center" width="80">总价</uni-th>
								</uni-tr>
								<!-- 表格数据行 -->
								<uni-tr v-for="(item1,index1) in item.billSaleDetailVos" :key="index1"
									@tap="clickDetail(item1)">
									<uni-td align="center">
										<text>
											{{item1.productSn == null ?"" :item1.productSn}}
										</text>
									</uni-td>
									<uni-td
										align="center">{{item1.productCount == null ?"0" :item1.productCount}}</uni-td>
									<uni-td
										align="center">{{item1.totalAmount / item1.productCount}}</uni-td>
									<uni-td
										align="center">{{item1.totalAmount == null ?"0" :item1.totalAmount}}</uni-td>
								</uni-tr>
							</uni-table>
						</view>
						<view style="border-bottom: 2px solid #eee;" v-if="item.billSaleDetailVos != null">
							<view style="font-weight: bold;padding: 20rpx;">
								付款明细:
							</view>
							<view>
								<view>
									<view style="padding-left: 20rpx;">
										<text v-if="item.dealingsType == 9 || item.dealingsType == 10">退货金额:{{item.alreadyPay == null ?"0" :item.alreadyPay}}</text>
										<text v-else>拿货金额:{{item.shouldPay == null ?"0" :item.shouldPay}}</text>
									</view>
								</view>
								<view style="padding-left: 20rpx;margin-top: 40rpx;">
									<view>
										余额抵进货:{{item.balanceDeductionAmount == null ?"0" :item.balanceDeductionAmount}}
									</view>
								</view>
								<view v-if="item.remark != '' && item.remark !=undefined && item.remark != null" style="padding-left: 20rpx;margin-top: 40rpx;">
									<view>备注:{{item.remark}}</view>
								</view>
							</view>
							<view
								style="padding-left: 20rpx;margin: 40rpx 0 20rpx;height: 60rpx;line-height: 60rpx;text-align: center;font-size: 30rpx;font-weight: bold;display: flex;">
								<text style="flex: 1;">本单应付:{{item.shouldPay == null ?"0" :item.shouldPay}}</text>
								<text
									style="display: inline-block;padding-left: 20rpx;flex: 1;">本单实付:{{item.alreadyPay == null ?"0" :item.alreadyPay}}</text>
							</view>
						</view>
						<view style="border-bottom: 2px solid #eee;" v-if="item.dealingsType == '4' || item.dealingsType == '5'">
							<view style="font-weight: bold;padding: 20rpx;">
								充值明细:
							</view>
							<view style="margin: 0 0 40rpx;">
								<view>
									<view style="padding-left: 20rpx;">
										<text>充值时间:{{item.dealingsTime == null?'':item.dealingsTime}}</text>
									</view>
									<view style="padding-left: 20rpx;">
										<text>充值备注:{{item.dealingsRecordRemark == null?'':item.dealingsRecordRemark}}</text>
									</view>
								</view>
							</view>
						</view>
						<view style="text-align: center;display: flex;padding: 20rpx 0;color: #000;">
							<view v-if="item.lastDebtAmount >= 0" style="flex: 1;display: flex;flex-direction: column;">
								<text>之前欠款</text>
								<text>{{item.lastDebtAmount == null ?"0" :item.lastDebtAmount}}</text>
							</view>
							<view v-if="item.lastDebtAmount < 0" style="flex: 1;display: flex;flex-direction: column;">
								<text>之前余额</text>
								<text>{{item.lastDebtAmount == null ?"0" :Math.abs(item.lastDebtAmount)}}</text>
							</view>
							<view v-if="item.dealingsType == 5 || item.amount >= 0"
								style="flex: 1;border-left: 1px solid #eee;display: flex;flex-direction: column;">
								<text>{{item.dealingsType == 5?'追加欠款':item.dealingsType == 4?'充值金额':item.dealingsType == 6?'撤销欠款':item.dealingsType == 9?'本单退款':item.dealingsType == 10?'本单退款':item.dealingsType == 99?'撤销充值':'本单欠款'}}</text>
								<text>{{item.amount == null ?"0" :item.dealingsType == 5?Math.abs(item.amount):item.amount}}</text>
							</view>
							<view v-if="item.amount < 0 && item.dealingsType != 5"
								style="flex: 1;border-left: 1px solid #eee;display: flex;flex-direction: column;">
								<text>{{item.dealingsType == 4?'充值金额':item.dealingsType == 6?'撤销余额':item.dealingsType == 9?'本单退款':item.dealingsType == 10?'本单退款':item.dealingsType == 99?'撤销欠款':'本单余额'}}</text>
								<text>{{item.amount == null ?"0" :Math.abs(item.amount)}}</text>
							</view>
							<view v-if="item.balanceDue >= 0"
								style="flex: 1;border-left: 1px solid #eee;display: flex;flex-direction: column;">
								<text>{{item.dealingsType == 6?'撤销后欠款':'本单后欠款'}}</text>
								<text>{{item.balanceDue == null ?"0" :item.balanceDue}}</text>
							</view>
							<view v-if="item.balanceDue < 0"
								style="flex: 1;border-left: 1px solid #eee;display: flex;flex-direction: column;">
								<text>{{item.dealingsType == 6?'撤销后余额':'本单后余额'}}</text>
								<text>{{item.balanceDue == null ?"0" :Math.abs(item.balanceDue)}}</text>
							</view>
						</view>
					</view>
					<view style="text-align: center;margin-bottom:20rpx;">
						<text>对账时间:{{duizhangList.queryDate == null ?"" :duizhangList.queryDate}}</text>
					</view>
					<view
						style="text-align: center;height: 100rpx;line-height: 100rpx;border-top: 1px solid #eee;color: #777;">
						<text>用快衣店AI，入库、开单更方便</text>
					</view>
				</view>
				<view v-show="current === 2">
					<view class="shop-box" v-for="(item,index4) in list" :key="index4"
						style="background: #fff;display: block;overflow: hidden;margin: 0 auto 20rpx;">
						<view>
							<view
								style="padding-left: 20rpx;margin: 40rpx 0; font-weight: bold;font-size: 36rpx;text-align: center;">
								<text>货号:{{item.productSn}}</text>
							</view>
							<view style="text-align: center;margin-bottom:20rpx;">
								<text>名称:{{item.productName == null ? '' : item.productName}}</text>
								<text
									style="padding: 0 20rpx;">总数量:{{item.productCount == undefined ?'0':item.productCount}}</text>
								<!-- <text style="padding: 0 20rpx;" v-if="userType == 0">利润:{{item1.lirun.toFixed(2)}}</text> -->
							</view>
							<uni-table border stripe emptyText="暂无更多数据">
								<!-- 表头行 -->
								<uni-tr style="background: #eee;">
									<uni-th align="center" width="100">日期</uni-th>
									<uni-th align="center" width="50">数量</uni-th>
									<!-- <uni-th align="center" width="70">拿货价</uni-th> -->
									<uni-th align="center" width="70">采购价</uni-th>
									<uni-th align="center" width="70">总金额</uni-th>
									<!-- <uni-th align="center" width="70">利润</uni-th> -->
								</uni-tr>
								<!-- 表格数据行 -->
								<uni-tr v-for="(item1,index1) in item.supplierBuySaleVos" :key="index1"
									@tap="xiaoshouDetail('2',item1)">
									<uni-td align="center">{{item1.createTime | removeStr}}</uni-td>
									<uni-td align="center">{{item1.productCount}}</uni-td>
									<!-- <uni-td align="center">{{item1.supplierBuyProductDetailLogVos[0].realPrice * item1.productCount}}</uni-td> -->
									<uni-td
										align="center">{{userType == 0 ?(item1.supplierBuyProductDetailLogVos[0].purchasePrice == null?0:item1.supplierBuyProductDetailLogVos[0].purchasePrice):0}}</uni-td>
									<uni-td align="center">{{item1.productCount * item1.supplierBuyProductDetailLogVos[0].purchasePrice || 0}}</uni-td>
									<!-- <uni-td align="center">{{userType == 0 && isDownKH == false?((item1.supplierBuyProductDetailLogVos[0].realPrice - item1.customerBuyProductDetailLogVos[0].purchasePrice) * item1.productCount).toFixed(2):0}}</uni-td> -->
								</uni-tr>
							</uni-table>
						</view>
					</view>
				</view>
				<view v-show="current === 3">
					<view v-for="(item,index) in list" :key="index"
						style="background: #fff;display: block;overflow: hidden;margin: 0 auto 20rpx;">
						<view style="width: 100%;height: 80rpx;line-height: 80rpx;">
							<text
								style="display:inline-block;width: 55%;text-align: center;font-weight: bold;font-size: 30rpx;">
								日期:{{item.createTime | removeStr}}
							</text>
							<text
								style="display:inline-block;width: 45%;text-align: center;border-left: 1px solid #eee;">
								操作:{{item.createByName}}
							</text>
						</view>
						<uni-table border stripe emptyText="暂无更多数据">
							<!-- 表头行 -->
							<uni-tr style="background: #eee;">
								<uni-th align="center" width="85">货号</uni-th>
								<uni-th align="center" width="50">数量</uni-th>
								<uni-th align="center" width="70">退货价</uni-th>
								<uni-th align="center" width="70">采购价</uni-th>
							</uni-tr>
							<!-- 表格数据行 -->
							<uni-tr v-for="(items,index1) in item.returnSaleDetailList" :key="index1"
								@tap="xiaoshouDetail('3',items)">
								<uni-td align="center">{{items.productSn}}</uni-td>
								<uni-td align="center">{{item.productCount}}</uni-td>
								<uni-td align="center">{{items.discountAmount}}</uni-td>
								<uni-td
									align="center">{{userType == 0 && isDownKH == false?items.purchasePrice == null?0:items.purchasePrice:0}}</uni-td>
							</uni-tr>
						</uni-table>
					</view>
				</view>
			</view>
		</view>
		<view v-if="type =='khName'&& isDownKH == false" style="width: 90rpx;height: 80rpx;position: fixed;bottom: 50rpx;right: 40rpx;">
			<button open-type="share" class="shareBtn">
				<uni-icons type="redo" size="32"></uni-icons>
			</button>
		</view>
		<u-loadmore :status="status" />
		<!-- 弹出销售商品规格 -->
		<uni-popup ref="xsdetailPopup" background-color="#fff">
			<view class="detail-popup">
				<view @tap="$refs.xsdetailPopup.close()"
					style='width: 50rpx;height: 50rpx;position: absolute;right: 20rpx;top: 25rpx;'>
					<uni-icons type="closeempty" color="red" size="22"></uni-icons>
				</view>
				<view style="height: 100rpx;line-height: 100rpx;font-weight: bold;font-size: 36rpx;text-align: center;">
					规格数量详情
				</view>
				<uni-table border stripe emptyText="暂无更多数据" style="margin-bottom: 20rpx;border-radius: 10px;">
					<!-- 表头行 -->
					<uni-tr style="background: #eee;">
						<uni-th align="center" width="80">规格</uni-th>
						<uni-th align="center" width="55">数量</uni-th>
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr v-for="(item,index) in GDList" :key="index">
						<uni-td align="center">{{item.attributeList | sliceMsg}}</uni-td>
						<uni-td align="center">{{item.productCount}}</uni-td>
					</uni-tr>
				</uni-table>
			</view>
		</uni-popup>
		<!-- 拿货详情 -->
		<uni-popup ref="buyDetailPopup" background-color="#fff">
			<view class="buy-popup">
				<view @tap="$refs.buyDetailPopup.close()"
					style='width: 50rpx;height: 50rpx;position: absolute;right: 20rpx;top: 25rpx;'>
					<uni-icons type="closeempty" color="red" size="22"></uni-icons>
				</view>
				<view style="height: 100rpx;line-height: 100rpx;font-weight: bold;font-size: 36rpx;text-align: center;">
					拿货详情（不含退货）
				</view>
				<view class="shop-box" v-for="(value,key) in Array.from(buyList)" :key="key"
					style="background: #fff;display: block;overflow: hidden;margin: 0 auto 20rpx;">
					<view>
						<view
							style="padding-left: 20rpx;margin: 40rpx 0; font-weight: bold;font-size: 36rpx;text-align: center;">
							<text>货号:{{value[1].productSn == null?'':value[1].productSn}}</text>
						</view>
						<view style="text-align: center;margin-bottom:20rpx;">
							<text>名称:{{value[1].productName == null?'':value[1].productName}}</text>
						</view>
						<uni-table border stripe emptyText="暂无更多数据">
							<!-- 表头行 -->
							<uni-tr style="background: #eee;">
								<uni-th align="center" width="100">规格</uni-th>
								<uni-th align="center" width="50">已退货数</uni-th>
								<uni-th align="center" width="50">剩余数</uni-th>
							</uni-tr>
							<!-- 表格数据行 -->
							<uni-tr v-for="(values,keys) in Array.from(value[1].stockLogList)" :key="keys">
								<uni-td align="center">{{values[1].attributeList | sliceMsg}}</uni-td>
								<uni-td align="center">{{values[1].returnNum ? values[1].returnNum : 0}}</uni-td>
								<uni-td align="center">{{values[1].productCount}}</uni-td>
							</uni-tr>
						</uni-table>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 弹出商品规格 -->
		<uni-popup ref="detailPopup" background-color="#fff">
			<view class="detail-popup">
				<view @tap="$refs.detailPopup.close()"
					style='width: 50rpx;height: 50rpx;position: absolute;right: 20rpx;top: 25rpx;'>
					<uni-icons type="closeempty" color="red" size="22"></uni-icons>
				</view>
				<view style="height: 100rpx;line-height: 100rpx;font-weight: bold;font-size: 36rpx;text-align: center;">
					{{detailList.productName}}({{detailList.productSn}})
				</view>
				<uni-table border stripe emptyText="暂无更多数据" style="margin-bottom: 20rpx;">
					<!-- 表头行 -->
					<uni-tr style="background: #eee;">
						<uni-th align="center" width="80">规格</uni-th>
						<uni-th align="center" width="55">数量</uni-th>
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr v-for="(item,index) in detailList.billAttributeListVos" :key="index">
						<uni-td align="center">{{item.attributeList | sliceMsg}}</uni-td>
						<uni-td align="center">{{item.productCount}}</uni-td>
					</uni-tr>
				</uni-table>
			</view>
		</uni-popup>
		<!-- 分享确认弹窗 -->
		<uni-popup ref="sharePopup" background-color="#fff">
			<view class="type-popup">
				<view style="height: 120rpx;font-size: 36rpx;font-weight: bold;line-height: 120rpx;text-align: center;">
					提示
				</view>
				<view style="height: 80rpx;font-size: 28rpx;text-align: center;font-weight: bold;">
					确认要将此条对账单分享给微信好友吗？
				</view>
				<view
					style="font-size:30rpx;width: 100%;height: 90rpx;line-height: 90rpx;text-align: center;border-radius: 0;background: linear-gradient(90deg, #60F3FF, #088FEB);color: #fff;display: flex;position: absolute;bottom: 0;">
					<view style="width:50%;" @tap="$refs.sharePopup.close()">取消</view>
					<view style="width:50%;">
						<button open-type="share"  style="background: linear-gradient(90deg, #FF9797, #FFC1E0);color:#fff;border-radius: 0;font-size: 35.4rpx;">
							确认
						</button>
					</view>
				</view>
			</view>
		</uni-popup>
		<view v-if="shijiPrice" style="width:100%;height:100%;position: fixed;top: 0;background: rgba(0,0,0,0.7);">
			<view 
				style="position: fixed;margin:auto;height:400rpx;left:0;right:0;top:0;bottom:0;width:600rpx;background:#fff;border-radius: 10px;color: #000;">
				<view style="width:100%;height:80rpx;font-size: 30rpx;text-align: center;line-height: 80rpx;font-weight: bold;">
					拿货明细
				</view>
				<view style="display: flex;">
					<view style="width: 33%;display: flex;flex-direction: column;text-align: center;">
						<text style="font-weight: bold;">{{(salePrice).toFixed(2)}}</text>
						<text>拿货总金额</text>
					</view>
					<view style="width: 33%;display: flex;flex-direction: column;text-align: center;">
						<text style="font-weight: bold;">{{saleCount}}</text>
						<text>总款数</text>
					</view>
					<view style="width: 33%;display: flex;flex-direction: column;text-align: center;">
						<text style="font-weight: bold;">{{saleAllCount}}</text>
						<text>总件数</text>
					</view>
				</view>
				<view style="display: flex;margin-top: 35rpx;">
					<view style="width: 33%;display: flex;flex-direction: column;text-align: center;">
						<text style="font-weight: bold;">{{(returnPrice).toFixed(2)}}</text>
						<text>退货总金额</text>
					</view>
					<view style="width: 33%;display: flex;flex-direction: column;text-align: center;">
						<text style="font-weight: bold;">{{returnCount}}</text>
						<text>总款数</text>
					</view>
					<view style="width: 33%;display: flex;flex-direction: column;text-align: center;">
						<text style="font-weight: bold;">{{returnAllCount}}</text>
						<text>总件数</text>
					</view>
				</view>
				<view @tap="shijiPrice = false" style="height: 100rpx;width: 100%;line-height: 100rpx;text-align: center;border-top: 1px solid #eee;font-size: 40rpx;margin-top: 60rpx;;">
					确定
				</view>
			</view>
		</view>
		<view style="position: absolute;top: -3000rpx;z-index: -1;opacity: 0;">
			<canvas canvas-id="myCanvas1" style="width: 3030rpx; height: 2420rpx;"></canvas>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				buyList:new Map(),
				range: [],
				oneShareData:{},
				GDList: [],
				salePrice:0,
				saleCount:0,
				saleAllCount:0,
				returnPrice:0,
				returnCount:0,
				returnAllCount:0,
				status: 'loadmore',
				isDetail:'2',
				oneShareId:'',
				shareSuccess:false,
				pages: 1,
				shijiPrice:false,
				pageNum: 1,
				userId: '',
				FWHPic:'https://jewel-shop.oss-cn-beijing.aliyuncs.com/f2ba2080aaa54c618c2e47df4f220087.png',
				mini_program_openid:'',
				unionid:'',
				official_account_openid:'',
				shopId: '',
				duizhangRecords: [],
				detailList: {},
				duizhangList: {},
				type: '',
				isDownKH: false,
				customId:'',
				userType: uni.getStorageSync('type'),
				items: ['对账单', '拿货(按订单)', '拿货(按商品)', '退货明细'],
				itemsGYS: ['对账单', '拿货(按订单)', '拿货(按商品)'],
				current: 0,
				shopName: ""
			}
		},
		filters: {
			sliceMsg(val) {
				var name = ''
				if (typeof(val) == 'string') {
					let newObj = JSON.parse(val)
					for (let as in newObj) {
						name += newObj[as] + '/'
					}
				}
				return name;
			},
			removeStr(val) {
				if (val == null) {
					return "";
				} else {
					var dotIndex = val.indexOf('.');
					if (dotIndex !== -1) {
						return val.substring(0, dotIndex);
					}
					return val;
				}
			}
		},
		async onShareAppMessage() {
			this.shareSuccess = true
			if(this.isDetail =='0'){ //销售单详情
				var dotIndex = this.oneShareData.createTime.indexOf(' ');
				if (dotIndex !== -1) {
					this.oneShareData.createTime = this.oneShareData.createTime.substring(0, dotIndex);
				}
				let titleText = this.shopName +' '+  this.oneShareData.createTime + '\n销售单'
				const imageUrl = await this.senrPath()
				this.$refs.sharePopup.close()
				this.isDetail = '3'
				return {
					title: titleText,
					imageUrl: imageUrl,
					path: '/package1/index/orderDetail?id='+ this.oneShareId + '&oneShareData='+JSON.stringify(this.oneShareData) + '&mini_program_openid=' + this.miniProgramOpenid + '&unionid=' + this.unionid +'&official_account_openid='+ this.officialAccountOpenid + '&userId='+ this.userId + '&customId='+this.customId+ '&shopId=' +uni.getStorageSync('shopId')
				}
			}else if(this.isDetail =='1'){ //充值记录
				//客户名，操作人，操作时间，之前欠款，充值金额，本单后余额，店铺id
				var dotIndex = this.oneShareData.createTime.indexOf(' ');
				if (dotIndex !== -1) {
					this.oneShareData.createTime = this.oneShareData.createTime.substring(0, dotIndex);
				}
				let titleText = this.shopName +'充值记录\n'+ this.oneShareData.createTime
				const imageUrl = await this.senrPath()
				this.$refs.sharePopup.close()
				this.isDetail = '3'
				let path = ''
				if(this.type == 'khName'){
					path = '/package1/index/rechargeRecord?type=ku&oneShareData='+ JSON.stringify(this.oneShareData) + '&mini_program_openid=' + this.miniProgramOpenid + '&unionid=' + this.unionid +'&official_account_openid='+ this.officialAccountOpenid + '&userId='+ this.userId + '&customId='+this.customId+ '&shopId=' +uni.getStorageSync('shopId')
				}else{
					path = '/package1/index/rechargeRecord?oneShareData='+ JSON.stringify(this.oneShareData) + '&mini_program_openid=' + this.miniProgramOpenid + '&unionid=' + this.unionid +'&official_account_openid='+ this.officialAccountOpenid + '&userId='+ this.userId + '&customId='+this.customId+ '&shopId=' +uni.getStorageSync('shopId')
				}
				return {
					title: titleText,
					imageUrl: imageUrl,
					path: path
				}
			}else if(this.isDetail =='4'){ //采购
				this.$refs.sharePopup.close()
				this.isDetail = '3'
				return {
					title: this.shopName + '的对账单',
					imageUrl: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/b28b3d46c21d4f60a334b25f56175cf3.jpg',
					path: '/package1/index/waitStorageDetail?id='+ this.oneShareId + '&oneShareData='+JSON.stringify(this.oneShareData) + '&shopId='+this.shopId + '&mini_program_openid=' + this.miniProgramOpenid + '&unionid=' + this.unionid +'&official_account_openid='+ this.officialAccountOpenid + '&userId='+ this.userId
				}
			}else if(this.isDetail =='5'){ //采购
				this.$refs.sharePopup.close()
				this.isDetail = '3'
				return {
					title: this.shopName + '的对账单',
					imageUrl: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/b28b3d46c21d4f60a334b25f56175cf3.jpg',
					path: '/package1/index/waitStorageDetail?returnInv=1&id='+ this.oneShareId + '&oneShareData='+JSON.stringify(this.oneShareData) + '&shopId='+this.shopId + '&mini_program_openid=' + this.miniProgramOpenid + '&unionid=' + this.unionid +'&official_account_openid='+ this.officialAccountOpenid + '&userId='+ this.userId
				}
			}else{
				let titleText = this.shopName +'对账单\n'+ this.range[0] +'至'+this.range[1]
				const imageUrl = await this.senrPath()
				return {
					title: titleText,
					imageUrl: imageUrl,
					path: '/package1/index/shareBill?popleType=khName&id=' + this.userId + '&shopId=' + this
						.shopId + '&shopName=' + this.shopName + '&range=' + JSON.stringify(this.range) + '&mini_program_openid=' + this.miniProgramOpenid + '&unionid=' + this.unionid +'&official_account_openid='+ this.officialAccountOpenid + '&userId='+ this.userId + '&customId='+this.customId + '&userName=' + this.duizhangList.userName
				}
			}
			
		},
		onLoad(option) {
			let that = this;
			this.customId = option.id
			this.userId = option.userId
			this.type = option.popleType
			this.shopName = option.shopName ? option.shopName : uni.getStorageSync('shopName')
			this.shopId = option.shopId ? option.shopId : uni.getStorageSync('shopId')
			this.miniProgramOpenid = option.miniProgramOpenid
			this.officialAccountOpenid = option.officialAccountOpenid
			this.unionid = option.unionid
			
			this.getMonth();
			if (option.shopId) {
				this.isDownKH = true
			}
			uni.setNavigationBarTitle({
				title: this.shopName
			});
			this.duizhangdan()
		},
		onShow(){
			let that = this;
			if(this.range ==''){
				this.getMonth();
			}
			if(this.shareSuccess){
				if((this.officialAccountOpenid == "null" || this.officialAccountOpenid == "" || this.officialAccountOpenid == undefined || this.officialAccountOpenid == null) && this.type == 'khName' && this.duizhangList.userName != '散客'){
					uni.showModal({
						title: "提示",
						content: "该客户没有关注公众号，无法接收消息通知，是否邀请用户关注？",
						success: function(res) {
							if (res.confirm) {
								uni.previewImage({
									urls: [that.FWHPic]
								})
							}
						}
					})
				}
				this.shareSuccess = false
			}
			// if(uni.getStorageSync('mini_program_openid')){
			// 	this.getToken()
			// }
		},
		onReachBottom() {
			if (this.pageNum >= this.pages) return;
			this.status = 'loading';
			this.pageNum++;
			if (this.current == 0) {
				this.duizhangdan()
			} else {
				this.getList();
			}
		},
		methods: {
			//获取code
			getToken() {
				uni.login({
					provider: 'weixin',
					success(res) {
						
						this.getOpenId(res.code)
					}
				});
			},
			//获取小程序openid
			getOpenId(code) {
				this.tui.request("", "post", {
					appid: 'wx6d7d4fb58d1502db',
					secret: '3a2c8cd00926764bbd12fd7361e01f1d',
					js_code: code,
					grant_type: "authorization_code",
					customId: ''
				}, false, false).then((res) => {
					this.status = 'nomore';
					if (res.code == 200) {
			
					} else {
						this.tui.toast(res.message)
					}
				}).catch((res) => {})
			},
			//canvas画分享的图
			senrPath(){
				return new Promise(async (resolve, reject) => {
					let that = this
					uni.showLoading({
						title:'生成中...'
					})
					const ctx = uni.createCanvasContext('myCanvas1', this);
					//背景图
					let imgA = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/30cc553859944b1e9fa3ce2d87905612.png';
					uni.downloadFile({
						url: imgA,
						success: (res2) => {
							if (res2.statusCode === 200) {
								// // 绘制第一张图片
								ctx.drawImage(res2.tempFilePath, 0, 0, 1515, 1210);
								ctx.draw(true);
								ctx.setFontSize(65)
								// 设置文字颜色
								ctx.fillStyle = '#FF5809';
								let beginHeight = 150
								// 计算居中位置
								beginHeight += 100
								if(this.isDetail == '1'){ //充值记录
									ctx.font = 'bold 80px SimSun';
									// 绘制文字
									ctx.fillText('充值记录', 350, beginHeight);
									ctx.draw(true)
									// 设置文字颜色
									ctx.fillStyle = '#FF5809';
									beginHeight+=150
									var text1 = (this.oneShareData.lastDebtAmount >= 0?'之前欠款:':'之前余额:') + Math.abs(this.oneShareData.lastDebtAmount)
									ctx.font = 'bold 60px SimSun';
									// 绘制文字
									ctx.fillText(text1, 350, beginHeight);
									ctx.draw(true)
									beginHeight+=150
									//
									var text2 = (this.oneShareData.dealingsType == 5?'追加欠款:':this.oneShareData.dealingsType == 4?'充值金额:':'充值金额:')+Math.abs(this.oneShareData.amount)
									// 绘制文字
									ctx.fillText(text2, 350, beginHeight);
									ctx.draw(true)
									beginHeight+=150
									var text2 = (this.oneShareData.balanceDue >= 0?'本单后欠款:':'本单后余额:')+Math.abs(this.oneShareData.balanceDue)
									// 绘制文字
									ctx.fillText(text2, 350, beginHeight);
									ctx.draw(true)
								}else if(this.isDetail == '0'){
									// // 绘制第一张图片
									ctx.drawImage(res2.tempFilePath, 0, 0, 1515, 1210);
									ctx.draw(true);
									// 设置字体样式
									ctx.font = 'bold 80px SimSun';
									// 设置文字颜色
									ctx.fillStyle = '#FF5809';
									let beginHeight = 150
										var textWidth = 350;
										// 计算居中位置
										beginHeight += 100
														
										// 绘制文字
										ctx.fillText('销售', textWidth, beginHeight);
										ctx.draw(true)
										// 设置字体样式
										ctx.font = 'bold 60px SimSun';
										// 设置文字颜色
										ctx.fillStyle = '#FF5809';
										beginHeight+=100
										var text = '总件数：'+this.oneShareData.productCount+'     总金额：'+this.oneShareData.totalAmount
										// 绘制文字
										ctx.fillText(text, textWidth, beginHeight);
										ctx.draw(true)
									if(that.oneShareData.returnCount >0){
										beginHeight+=120
										var textWidth = 350;
										// 绘制文字
										// 设置字体样式
										ctx.font = 'bold 80px SimSun';
										// 设置文字颜色
										ctx.fillStyle = '#FF5809';
										ctx.fillText('退货', textWidth, beginHeight);
										ctx.draw(true)
										beginHeight+=100
										// 设置字体样式
										ctx.font = 'bold 60px SimSun';
										// 设置文字颜色
										ctx.fillStyle = '#FF5809';
										var text = '总件数：'+that.oneShareData.returnCount+'     总金额：'+this.oneShareData.returnPrice
										// 绘制文字
										ctx.fillText(text, textWidth, beginHeight);
										ctx.draw(true)
									}
										var textWidth = 350;
										beginHeight+=150
										// 绘制文字
										// 设置字体样式
										ctx.font = 'bold 80px SimSun';
										// 设置文字颜色
										ctx.fillStyle = 'black';
										ctx.fillText('本单应收：'+this.oneShareData.realAmount, textWidth, beginHeight);
										ctx.draw(true)
										
										beginHeight+=120
										var textWidth = 350;
										// 绘制文字
										// 设置字体样式
										ctx.font = 'bold 80px SimSun';
										// 设置文字颜色
										ctx.fillStyle = 'black';
										ctx.fillText('本单实收：'+this.oneShareData.alreadyEarn, textWidth, beginHeight);
										ctx.draw(true)
										beginHeight+=120
									
									
									
								}else{
									ctx.font = 'bold 80px SimSun';
									// 绘制文字
									ctx.fillText('对账单', 350, beginHeight);
									ctx.draw(true)
									// 设置文字颜色
									ctx.fillStyle = '#FF5809';
									ctx.font = 'bold 60px SimSun';
									beginHeight+=150
									var text1 = (this.duizhangList.endArrears >= 0?'期末欠款:':'期末余额:') + (this.duizhangList.endArrears==null?'0':this.duizhangList.endArrears)
									ctx.setFontSize(54)
									// 绘制文字
									ctx.fillText(text1, 350, beginHeight);
									ctx.draw(true)
									beginHeight+=150
									var text2 = '拿货总额:'+(this.duizhangList.totalSale==null?'0':this.duizhangList.totalSale)
									// 绘制文字
									ctx.fillText(text2, 350, beginHeight);
									ctx.draw(true)
									beginHeight+=150
									var text2 = '退货总额:'+(this.duizhangList.totalReturn == null ?"0" :this.duizhangList.totalReturn)
									// 绘制文字
									ctx.fillText(text2, 350, beginHeight);
									ctx.draw(true)
								}
								
								setTimeout(ress=>{
								uni.canvasToTempFilePath({
										x: 0,
										y: 0,
										width: 1515,
										height: 1210,
										destWidth: 1515,
										destHeight: 1210,
										canvasId: 'myCanvas1',
										success: (res3) => {
											uni.hideLoading()
											return resolve(res3.tempFilePath)
										}
									});
								},500)
							}
						}
					});
				})
			},
			//获取当月1日到当前时间
			getMonth() {
				let date = new Date()
				let year = date.getFullYear().toString() //'年'
				let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1).toString() : (date.getMonth() + 1)
					.toString() //'月'
				let da = date.getDate() < 10 ? '0' + date.getDate().toString() : date.getDate().toString() //'日'
				let end = year + '-' + month + '-' + da //当天
				let beg = '2024-01-01' //当月第一天
				this.range = [beg, end]
			},
			delDZD(item){
				let that = this;
				uni.showModal({
					title: "提示",
					content: "确定删除此条数据吗？",
					success: function(res) {
						uni.showLoading({
							title: '加载中...'
						})
						if (res.confirm) {
							that.tui.request('/app/dealingRecord/deleteDealingsRecord', "post", {
								id:item.id
							}, false, true).then((res) => {
								if (res.code == 200) {
									that.tui.toast('删除成功')
									that.duizhangList = []
									that.pageNum = 1
									that.pages = 1
									that.duizhangdan()
								} else {
									that.tui.toast(res.message)
								}
							}).catch((res) => {})
						}
						setTimeout(res1 => {
							uni.hideLoading();
						}, 500)
					}
				})
				
			},
			duizhangdan() {
				var url,data
				if(this.type == 'gysName'){
					url = '/app/bill/getSupplierBill'
					data = {
						supplierId:this.customId,
					    shopId:this.shopId,
					    pageNum:this.pageNum,
						startDate: this.range[0],
						endDate: this.range[1],
					    pageSize:"10"
					}
				}else{
					url = "/app/bill/getCustomerBill"
					data = {
						customerId: this.customId,
						pageNum: this.pageNum,
						pageSize: '10',
						startDate: this.range[0],
						endDate: this.range[1],
						shopId: this.shopId
					}
				}
				this.tui.request(url, "post", data, false, false).then((res) => {
					if (res.code == 200) {
						this.status = 'nomore';
						if(this.type == 'gysName'){
							if (this.pages == 1) {
								this.duizhangList = res.result
								this.duizhangRecords = res.result.supplierBillSaleVos.records
							} else {
								for (let i = 0; i < res.result.supplierBillSaleVos.records.length; i++) {
									this.duizhangRecords.push(res.result.supplierBillSaleVos.records[i])
								}
							}
							this.pages = res.result.supplierBillSaleVos.pages
						}else{
							for(let i=0;i<res.result.customerBillSaleVos.records.length;i++){
								res.result.customerBillSaleVos.records[i].isOldName = true
								if(res.result.customerBillSaleVos.records[i].dealingsUserName != res.result.userName){
									res.result.customerBillSaleVos.records[i].isOldName = false
								}
							}
							if (this.pages == 1) {
								this.duizhangList = res.result
								this.duizhangRecords = res.result.customerBillSaleVos.records
							} else {
								for (let i = 0; i < res.result.customerBillSaleVos.records.length; i++) {
									this.duizhangRecords.push(res.result.customerBillSaleVos.records[i])
								}
							}
							this.pages = res.result.customerBillSaleVos.pages
							
						}
					} else {
						this.tui.toast(res.message)
					}
				}).catch((res) => {})
			},
			xiaoshouDetail(type, item) {
				if (item) {
					if (type == '1') {
						this.GDList = item.stockLogList1
						this.$refs.xsdetailPopup.open()
					} else if (type == '2') {
						if(this.type == 'gysName'){
							
							this.GDList = item.supplierBuyProductDetailLogVos
						}else{
							this.GDList = item.customerBuyProductDetailLogVos
						}
						
						this.$refs.xsdetailPopup.open()
					} else if (type == '3') {
						this.GDList = item.stockLogList1
						this.$refs.xsdetailPopup.open()
					}
				}
			},
			getBuyDetail(){
				this.$refs.buyDetailPopup.open('bottom')
				
				this.tui.request('/app/sale/listPages', "post", {
					userId: this.customId,
					pageVo: {
						pageSize: 10000000,
						pageNumber: 1
					},
					searchStr: "",
					startTime: this.range[0],
					endTime: this.range[1],
					shopId: this.shopId,
					fromWhere: 1
				}, false, false).then((res) => {
					this.status = 'nomore';
					if (res.code == 200) {
						let listData = res.result.records
						this.buyList = new Map()
								
						for (let i = 0; i < listData.length; i++) {
							for (let j = 0; j < listData[i].saleDetailDTOList.length; j++) {
								if(this.buyList.size == 0){ //当前没有数据
									this.buyList.set(listData[i].saleDetailDTOList[j].productSn,listData[i].saleDetailDTOList[j])
									this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList = new Map()
									for (let m = 0; m < listData[i].saleDetailDTOList[j].stockLogList1.length; m++) {
										this.buyList.get(listData[i].saleDetailDTOList[j].productSn).productCount += listData[i]
											.saleDetailDTOList[j].stockLogList1[m].productCount
										
										if(this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.size==0){
											this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.set(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList,listData[i].saleDetailDTOList[j].stockLogList1[m])
										}else{
											if(this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.has(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList)){
												this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.get(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList).productCount += listData[i].saleDetailDTOList[j].stockLogList1[m].productCount
											}else{
												this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.set(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList,listData[i].saleDetailDTOList[j].stockLogList1[m])
											}
										}
									}
								}else{ //有数据
									if(this.buyList.has(listData[i].saleDetailDTOList[j].productSn)){ // 数据相同
										
										for (let m = 0; m < listData[i].saleDetailDTOList[j].stockLogList1.length; m++) {
											this.buyList.get(listData[i].saleDetailDTOList[j].productSn).productCount += listData[i]
												.saleDetailDTOList[j].stockLogList1[m].productCount

											if(this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.has(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList)){
												this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.get(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList).productCount += listData[i].saleDetailDTOList[j].stockLogList1[m].productCount
											}else{
												this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.set(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList,listData[i].saleDetailDTOList[j].stockLogList1[m])
											}
										}
									}else{ // 数据不同
										this.buyList.set(listData[i].saleDetailDTOList[j].productSn,listData[i].saleDetailDTOList[j])
										this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList = new Map()
										for (let m = 0; m < listData[i].saleDetailDTOList[j].stockLogList1.length; m++) {
											this.buyList.get(listData[i].saleDetailDTOList[j].productSn).productCount += listData[i]
												.saleDetailDTOList[j].stockLogList1[m].productCount
											
											if(this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.size==0){
												this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.set(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList,listData[i].saleDetailDTOList[j].stockLogList1[m])
											}else{
												if(this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.has(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList)){
													this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.get(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList).productCount += listData[i].saleDetailDTOList[j].stockLogList1[m].productCount
												}else{
													this.buyList.get(listData[i].saleDetailDTOList[j].productSn).stockLogList.set(listData[i].saleDetailDTOList[j].stockLogList1[m].attributeList,listData[i].saleDetailDTOList[j].stockLogList1[m])
												}
											}
										}
									}
								}
							}
						}
						this.tui.request("/app/return/getReturnSaleListByUserId", "post", {
							userId: this.customId,
							startDate: this.range[0],
							endDate: this.range[1],
							pageNum: 1,
							pageSize: "10000000",
							shopId: this.shopId
						}, false, false).then((res) => {
							this.status = 'nomore';
							if (res.code == 200) {
								
								let returnDetail = res.result.records
								
								for (let i = 0; i < returnDetail.length; i++) {
									for (let j = 0; j < returnDetail[i].returnSaleDetailList.length; j++) {
										if(this.buyList.has(returnDetail[i].returnSaleDetailList[j].productSn)){
											
											for (let m = 0; m < returnDetail[i].returnSaleDetailList[j].stockLogList1.length; m++) {
												if(this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).stockLogList.has(returnDetail[i].returnSaleDetailList[j].stockLogList1[m].attributeList)){
													
													if(this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).stockLogList.get(returnDetail[i].returnSaleDetailList[j].stockLogList1[m].attributeList).returnNum == undefined){
														this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).stockLogList.get(returnDetail[i].returnSaleDetailList[j].stockLogList1[m].attributeList).returnNum = 0
													}
													this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).stockLogList.get(returnDetail[i].returnSaleDetailList[j].stockLogList1[m].attributeList).returnNum += returnDetail[i].returnSaleDetailList[j].stockLogList1[m].productCount
													this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).productCount -= returnDetail[i].returnSaleDetailList[j].stockLogList1[m].productCount
													this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).stockLogList.get(returnDetail[i].returnSaleDetailList[j].stockLogList1[m].attributeList).productCount -= returnDetail[i].returnSaleDetailList[j].stockLogList1[m].productCount
													if(this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).stockLogList.get(returnDetail[i].returnSaleDetailList[j].stockLogList1[m].attributeList).productCount <= 0){
														
														this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).stockLogList.delete(returnDetail[i].returnSaleDetailList[j].stockLogList1[m].attributeList)
													}
													if(this.buyList.get(returnDetail[i].returnSaleDetailList[j].productSn).stockLogList.size == 0){
														
														this.buyList.delete(returnDetail[i].returnSaleDetailList[j].productSn)
													}
													this.$forceUpdate()
												}
											}
											
										}
									}
								}
							} else {
								this.tui.toast(res.message)
							}
						}).catch((res) => {})
					} else {
						this.tui.toast(res.message)
					}
				}).catch((res) => {})
			},
			getAmount(){
				this.salePrice = 0
				this.saleCount = 0
				this.saleAllCount = 0
				this.returnPrice = 0
				this.returnCount = 0
				this.returnAllCount = 0
				this.shijiPrice = true
				if(this.type=='khName'){
					this.tui.request("/app/customer/getCustomerData", "POST", {
						customerId: this.customId,
						startDate: this.range[0],
						endDate:this.range[1]
					}, false, false).then((res1) => {
						if (res1.code == 200) {
							if(res1.result != null){
								this.salePrice = Number(res1.result.salePrice)
								this.saleCount = res1.result.saleCount
								this.returnPrice = Number(res1.result.saleReturnPrice)
								this.returnCount = res1.result.saleReturnCount
								if(res1.result.productDataVos != null && res1.result.productDataVos.length > 0){
									for(let i = 0;i<res1.result.productDataVos.length;i++){
										this.saleAllCount += res1.result.productDataVos[i].productCount
									}
								}
								if(res1.result.returnProductDataVos != null && res1.result.returnProductDataVos.length > 0){
									for(let i = 0;i<res1.result.returnProductDataVos.length;i++){
										this.returnAllCount += res1.result.returnProductDataVos[i].productCount
									}
								}
							}
						}
					}).catch((res) => {})
				}else{
					this.tui.request("/app/supplier/getSupplierData", "POST", {
						supplierId: this.customId,
						startDate: this.range[0],
						endDate:this.range[1]
					}, false, false).then((res1) => {
						if (res1.code == 200) {
							if(res1.result != null){
								this.salePrice = Number(res1.result.purchasePrice)
								this.saleCount = res1.result.purchaseCount
								this.returnPrice = Number(res1.result.purchaseReturnPrice)
								this.returnCount = res1.result.purchaseReturnCount
								if(res1.result.productDataVos != null && res1.result.productDataVos.length > 0){
									for(let i = 0;i<res1.result.productDataVos.length;i++){
										this.saleAllCount += res1.result.productDataVos[i].productCount
									}
								}
								if(res1.result.returnProductDataVos != null && res1.result.returnProductDataVos.length > 0){
									for(let i = 0;i<res1.result.returnProductDataVos.length;i++){
										this.returnAllCount += res1.result.returnProductDataVos[i].productCount
									}
								}
							}
						}
					}).catch((res) => {})
				}
			},
			//充值记录撤销
			revokeRecharge(item){
				let that = this;
				uni.showModal({
					title: "提示",
					content: "确定撤销此条数据吗？",
					success: function(res) {
						uni.showLoading({
							title: '加载中...'
						})
						if (res.confirm) {
							let pages = getCurrentPages();
							let prevPage = pages[pages.length - 2];
							prevPage.$vm.modelShow = true
							that.tui.request('/app/debt/revokeDebt', "post", {
								id:item.id,
								remark:''
							}, false, true).then((res) => {
								if (res.code == 200) {
									that.tui.toast('撤销成功')
									that.duizhangList = []
									that.pageNum = 1
									that.pages = 1
									that.duizhangdan()
								} else {
									that.tui.toast(res.message)
								}
							}).catch((res) => {})
						}
						setTimeout(res1 => {
							uni.hideLoading();
						}, 500)
					}
				})
			},
			getList(id) {
				this.status = 'loading';
				var url, data
				if (this.type == 'gysName') {
					if(this.current == 1){
						url = "/app/purchase/getPurchaseListOfSupplier"
						data = {
							supplierId: this.customId,
							pageSize: 10,
							pageNum: this.pageNum,
							startDate:this.range[0],
							endDate:this.range[1]
						}
					}else if(this.current == 2){
						url = "/app/sale/getSupplierBuyProductLog"
						data = {
							supplierId: this.customId,
							pageSize: 10,
							pageNum: this.pageNum,
							shopId: this.shopId,
							startDate:this.range[0],
							endDate:this.range[1]
						}
					}
					
				} else {
					if (this.current == 1) {
						url = "/app/sale/listPages"
						data = {
							userId: this.customId,
							pageVo: {
								pageSize: 10,
								pageNumber: this.pageNum
							},
							searchStr: "",
							startTime: this.range[0],
							endTime: this.range[1],
							shopId: this.shopId,
							fromWhere: 1
						}
					} else if (this.current == 2) {
						url = "/app/sale/getCustomerBuyProductLog"
						data = {
							userId: this.customId,
							pageSize: 10,
							startDate: this.range[0],
							endDate: this.range[1],
							pageNum: this.pageNum,
							shopId: this.shopId
						}
					} else if (this.current == 3) {
						url = "/app/return/getReturnSaleListByUserId"
						data = {
							userId: this.customId,
							startDate: this.range[0],
							endDate: this.range[1],
							pageNum: this.pageNum,
							pageSize: "10",
							shopId: this.shopId
						}
					}
				}
				this.tui.request(url, "post", data, false, false).then((res) => {
					this.status = 'nomore';
					if (res.code == 200) {
						// this.list = res.result.records
						if (this.pages == 1) {
							this.list = res.result.records
						} else {
							this.list = [...this.list, ...res.result.records]

						}
						this.pages = res.result.pages
						if (this.current == 1) {
							if(this.type == 'gysName'){
								for (let i = 0; i < this.list.length; i++) {
									this.list[i].purchase.productCount = 0
									for (let j = 0; j < this.list[i].purchaseDetails.length; j++) {
										for (let m = 0; m < this.list[i].purchaseDetails[j].stockLogList1
											.length; m++) {
											this.list[i].purchase.productCount += this.list[i]
												.purchaseDetails[j].stockLogList1[m].productCount
										}
									}
								}
							}else{
								for (let i = 0; i < this.list.length; i++) {
									this.list[i].productCount = 0
									for (let j = 0; j < this.list[i].saleDetailDTOList.length; j++) {
										this.list[i].saleDetailDTOList[j].productCount = 0
										for (let m = 0; m < this.list[i].saleDetailDTOList[j].stockLogList1
											.length; m++) {
											this.list[i].productCount += this.list[i]
												.saleDetailDTOList[j].stockLogList1[m].productCount
											this.list[i].saleDetailDTOList[j].productCount += this.list[i]
												.saleDetailDTOList[j].stockLogList1[m].productCount
										}
									}
								}
							}
							
							this.$forceUpdate()
						} else if (this.current == 2) {
							if(this.type == 'gysName'){
								for (let i = 0; i < this.list.length; i++) {
									this.list[i].productCount = 0
									for (let j = 0; j < this.list[i].supplierBuySaleVos.length; j++) {
										this.list[i].supplierBuySaleVos[j].productCount = 0

										for (let m = 0; m < this.list[i].supplierBuySaleVos[j]
											.supplierBuyProductDetailLogVos.length; m++) {
											this.list[i].productCount += this.list[i].supplierBuySaleVos[j]
												.supplierBuyProductDetailLogVos[m].productCount
											this.list[i].supplierBuySaleVos[j].productCount += this.list[i]
												.supplierBuySaleVos[j].supplierBuyProductDetailLogVos[m]
												.productCount
										}
									}
								}
								this.$forceUpdate()
							}else{
								for (let i = 0; i < this.list.length; i++) {
									this.list[i].productCount = 0
									for (let j = 0; j < this.list[i].customerBuySaleVoList.length; j++) {
										this.list[i].customerBuySaleVoList[j].productCount = 0

										for (let m = 0; m < this.list[i].customerBuySaleVoList[j]
											.customerBuyProductDetailLogVos.length; m++) {
											this.list[i].productCount += this.list[i].customerBuySaleVoList[j]
												.customerBuyProductDetailLogVos[m].productCount
											this.list[i].customerBuySaleVoList[j].productCount += this.list[i]
												.customerBuySaleVoList[j].customerBuyProductDetailLogVos[m]
												.productCount
										}
									}
								}
								this.$forceUpdate()
							}
							
						} else if (this.current == 3) {
							if(this.type == 'gysName'){
								// for (let i = 0; i < this.list.length; i++) {
								// 	this.list[i].productCount = 0
								// 	for (let j = 0; j < this.list[i].supplierBuySaleVos.length; j++) {
								// 		this.list[i].supplierBuySaleVos[j].productCount = 0

								// 		for (let m = 0; m < this.list[i].supplierBuySaleVos[j]
								// 			.supplierBuyProductDetailLogVos.length; m++) {
								// 			this.list[i].productCount += this.list[i].supplierBuySaleVos[j]
								// 				.supplierBuyProductDetailLogVos[m].productCount
								// 			this.list[i].supplierBuySaleVos[j].productCount += this.list[i]
								// 				.supplierBuySaleVos[j].supplierBuyProductDetailLogVos[m]
								// 				.productCount
								// 		}
								// 	}
								// }
								// this.$forceUpdate()
							}else{
								for (let i = 0; i < this.list.length; i++) {
									
									for (let j = 0; j < this.list[i].returnSaleDetailList.length; j++) {
										
										
										this.list[i].returnSaleDetailList[j].productCount = 0
										for (let m = 0; m < this.list[i].returnSaleDetailList[j]
											.stockLogList1.length; m++) {
											this.list[i].returnSaleDetailList[j].productCount += this.list[i]
												.returnSaleDetailList[j].stockLogList1[m]
												.productCount
										}
									}
								}
								this.$forceUpdate()
							}
							
						}
					} else {
						this.tui.toast(res.message)
					}
				}).catch((res) => {})
			},
			clickDetail(item) {
				this.detailList = item
				this.$refs.detailPopup.open()
			},
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
				if (e.currentIndex == 0) {
					this.duizhangList = []
					this.pageNum = 1
					this.pages = 1
					this.duizhangdan()
				} else if (e.currentIndex == 1) {
					this.list = []
					this.pageNum = 1
					this.getList()
				} else if (e.currentIndex == 2) {
					this.list = []
					this.pageNum = 1
					this.getList()
				} else if (e.currentIndex == 3) {
					this.list = []
					this.pageNum = 1
					this.getList()
				}
			},
			oneShare(item,type){
				if(type == 'chongzhi'){
					//客户名，操作人，操作时间，之前欠款，充值金额，本单后余额，店铺id         
					this.oneShareData = {
						userName:this.duizhangList.userName,
						createByName:item.createByName,
						createTime:item.createTime,
						lastDebtAmount:item.lastDebtAmount,
						amount:item.amount,
						balanceDue:item.balanceDue,
						shopAddress:uni.getStorageSync('shopAddress'),
						shopRemark:uni.getStorageSync('shopRemark'),
						shopMoblie:uni.getStorageSync('username'),
						shopName:uni.getStorageSync('shopName'),
						dealingsType:item.dealingsType
					}
					this.$refs.sharePopup.open()
					this.isDetail = '1'
				}else if(type == 'xiaoshou'){
					let productCount = 0
					let returnCount = 0
					this.oneShareData = {
						shopMoblie:uni.getStorageSync('username'),
						shopName:uni.getStorageSync('shopName'),
						createTime:item.createTime,
						productCount:productCount,
						returnCount:returnCount,
						returnPrice:item.returnSaleTotalAmount == null?'0':item.returnSaleTotalAmount,
						totalAmount:item.totalAmount,
						realAmount:item.realAmount,
						alreadyEarn:item.alreadyEarn
					}
					if(item.billReturnSaleDetailVos != null){
						for(let i=0;i<item.billReturnSaleDetailVos.length;i++){
							this.oneShareData.returnCount += item.billReturnSaleDetailVos[i].productCount
						}
					}
					if(item.billSaleDetailVos){
						for(let i=0;i<item.billSaleDetailVos.length;i++){
							this.oneShareData.productCount += item.billSaleDetailVos[i].productCount
						}
					}
					
					this.$refs.sharePopup.open()
					this.isDetail = '0'
					this.oneShareId = item.saleId
				}else if(type == 'caigou'){
					this.oneShareData = {
						shopMoblie:uni.getStorageSync('username'),
						shopName:uni.getStorageSync('shopName')
					}
					this.$refs.sharePopup.open()
					this.isDetail = '4'
					this.oneShareId = item.purchaseId
				}else if(type == 'tuihuo'){
					this.oneShareData = {
						shopMoblie:uni.getStorageSync('username'),
						shopName:uni.getStorageSync('shopName')
					}
					this.$refs.sharePopup.open()
					this.isDetail = '5'
					this.oneShareId = item.purchaseId
				}
				
			},
			searchList() {
				if (this.current == 0) {
					this.duizhangList = []
					this.pageNum = 1
					this.pages = 1
					this.duizhangdan()
				} else if (this.current == 1) {
					this.list = []
					this.pageNum = 1
					this.getList()
				} else if (this.current == 2) {
					this.list = []
					this.pageNum = 1
					this.getList()
				} else if (this.current == 3) {
					this.list = []
					this.pageNum = 1
					this.getList()
				}
			},
		},
	}
</script>

<style lang="scss">
	page{
		font-size:24rpx;
	}
	.uni-card__header-box {
		text-align: center !important;
	}

	.uni-card__header-content-title {
		font-weight: bold;
	}

	.container {

		.boxbg {
			padding-top: 10rpx;
			background-color: #FAF7F7;
		}

		.tui-order-item {
			.u-collapse-content {
				display: flex;
				justify-content: space-between;
				line-height: 60rpx;
			}


			.tui-goods-info {
				width: 100%;
				box-sizing: border-box;
				background: #fff;
				line-height: 52rpx;
				border-top: 20rpx solid #eee;

				.tui-price-flex {
					display: flex;
					align-items: center;
					justify-content: space-between;
				}

				.tui-size32 {
					font-size: 32rpx;
					font-weight: 500;
				}

				.tui-size-24 {
					font-size: 24rpx;
				}

				.tui-price-large {
					font-size: 32rpx;

					.lineText {
						text-decoration: line-through;
						font-size: 24rpx;
						color: #888;
					}
				}

				.tui-flex-shrink {
					flex-shrink: 0;
				}

				.tui-goods-price {
					width: 100%;
					display: flex;
					align-items: flex-end;
					justify-content: flex-end;
					font-size: 24rpx;
				}

				.tui-primary-color {
					color: #EB0909;
				}

				.tui-pbtm20 {
					padding-bottom: 20rpx;
				}

			}
		}
	}

	.tui-tabbar {
		width: 100%;
		height: 98rpx;
		background: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		font-size: 26rpx;
		box-shadow: 0 0 1px rgba(0, 0, 0, .3);
		padding-bottom: env(safe-area-inset-bottom);
		z-index: 996;
	}

	.tui-btn-mr {
		width: 130rpx;
		height: 60rpx;
		background: #088FEB;
		color: #fff;
		border-radius: 10px;
		line-height: 60rpx;
		text-align: center;
		margin-right: 30rpx;
	}

	.shop-box {
		margin: 0 auto;
		position: relative;
	}

	.shop-name {
		width: 100%;
		height: 200rpx;
		line-height: 80rpx;
		border-top: 1px solid #eee;
		border-bottom: 1px solid #eee;
		font-size: 28rpx;
		font-weight: bold;
		display: flex;

		.uni-icons {
			color: #088FEB !important;
		}
	}

	.shop-productName {
		flex: 1;
		display: flex;
		flex-direction: column;
		padding-left: 20rpx;
	}

	.shop-productName view {
		height: 55rpx;
	}
	.type-popup {
		width: 500rpx;
		height: 360rpx;
		background: #fff;
		border-radius: 10px;
		position: relative;
	}
	.shop-collapse {
		display: flex;
		height: 80rpx;
		font-size: 26rpx;
		line-height: 80rpx;
	}

	.shop-collapse text {
		flex: 1;
		text-align: center;
		padding-right: 40rpx;
		border-right: 1px solid #eee;
	}

	.content-list {
		width: 95%;
		margin: 0 auto;
		display: flex;
		height: 80rpx;
		border-bottom: 1px solid #eee;
	}

	.content-list:last-child {
		border-bottom: none;
		height: auto;
	}

	.list-name {
		width: 200rpx;
		text-align: left;
		line-height: 80rpx;
		height: 80rpx;
		padding-left: 20rpx;
	}

	.list-val {
		width: 560rpx;
		height: 80rpx;
		line-height: 80rpx;
	}

	.list-val input {
		width: 400rpx;
		height: 60rpx;
		display: inline-block;
		line-height: 60rpx;
		float: left;
		margin-top: 10rpx;
		padding-left: 20rpx;
		border-bottom: 1px solid #088FEB;
	}

	.shareBtn {
		background: rgba(255, 255, 255, 0);
		width: 90rpx;
		height: 50;
		height: 80rpx;
		line-height: 80rpx;
		border: 1px solid #f3f4f6;
		background-color: rgba(255, 255, 255, 0);
	}

	.shareBtn::after {
		border: none;
	} 
	.btn-biankuang::after {
		border: none;
		height: 90rpx !important;
	}

	textarea {
		margin: 20rpx;
		border: 1px solid #eee;
		height: 150rpx;
		width: 500rpx;
	}

	.uni-table-scroll {
		width: 100%;
		overflow-x: auto;
		border-radius: 10px;
	}

	.uni-table-th {
		background: #FAE7B5 !important;
		color: #000 !important;
	}

	.top1 {
		width: 780rpx;
		height: 390rpx;
		opacity: 1;
		background: linear-gradient(360deg, #FAF7F7 0%, rgba(255, 255, 255, 0) 100%);
	}

	.hello-box {
		position: absolute;
		left: 42rpx;
		top: 205rpx;
		width: 220rpx;
		height: 56rpx;

		.hello-left {
			width: 102rpx;
			height: 56rpx;
			opacity: 1;
			background: #fff;
			border-radius: 3px;
			text-align: center;
			transform: skewX(8deg);
		}

		.hello-right {
			position: absolute;
			left: 10rpx;
			bottom: 0rpx;
			width: 220rpx;
			height: 4rpx;
			opacity: 1;
			background: linear-gradient(270deg, rgba(255, 255, 255, 0) 0%, #ffffff 100%);
		}

		.hello-name {
			position: absolute;
			left: 118rpx;
			top: 0;
			width: 400rpx;
			height: 55rpx;
			font-size: 32rpx;
			line-height: 55rpx;
			color: white;
			overflow: hidden;
		}
	}

	.hello-text {
		position: absolute;
		top: 275rpx;
		left: 50rpx;
		color: #fff;
		font-size: 28rpx;
	}

	.top {
		width: 780rpx;
		height: 330rpx;
		opacity: 1;
		background: linear-gradient(90deg, #6484fa 0%, #66e8ff 100%);
		overflow: hidden;
	}
	.buy-popup{
		height:1200rpx;
		overflow: scroll;
	}
	.detail-popup{
		width: 500rpx;
		min-height: 500rpx;
		max-height: 1000rpx;
		overflow: scroll;
	}
	@media screen and (min-width: 760px) {
		.detail-popup{
			max-height: 750px;
		}
	}
</style>