<template>
	<view>
		<view class="cu-list menu  " v-show="!showIndex">
			<view class="cu-item solid-top radius">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">项目名称</text>
					<text>{{detailForm.rechargeTypeName}}</text>
					<text>{{detailForm.projectName}}</text>
					<text>{{detailForm.tradeName}} <text class="text-price text-red margin-left">{{detailForm.tradeMoney}}</text></text>
					
				</view>
			</view>
			<view class="cu-item solid-top">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">单据时间</text>
					<text>{{detailForm.date}}</text>
					<text>{{detailForm.refundDate}}</text>
					<text>{{detailForm.rechargeDate}}</text>
					<text>{{detailForm.docDate}}</text>
					<text>{{detailForm.repayDate}}</text>
					
					
				</view>
			</view>
			<view class="cu-item solid-top">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">门店名称</text>
					<text>{{userInfo.storeName}}</text>
				</view>
			</view>
			<view class="cu-item solid-top">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">业务人员</text>
					<view class="">
						<view v-for="(item,index) in  detailForm.entities" :key="'itemA'+index">
							<text style="display: inline-block; width: 320rpx;">{{item.brandNumber}} <text> - </text>
								{{item.saleStaffName}} </text>
						</view>
					</view>
				</view>
			</view>
	
			<view class="cu-item solid-top "  v-show="detailForm.rechargeConsumeLis||detailForm.payLists">
				<view class="flex justify-start align-center padding-bottom padding-top">
					<text class="text-bold margin-right">付款金额</text>
					
					<text>
						<view v-for="(item,index) in  detailForm.rechargeConsumeList" :key="'itemB'+index">
							<text>{{item.rechargeTypeName}}</text> <text
								class="margin-left text-price text-red">{{item.spendMoney}}</text>
						</view>
						<view v-for="(item,index) in detailForm.payLists" :key="'itemC'+index">
							<text>{{item.payName}}</text> <text
								class="margin-left text-price text-red">{{item.payMoney}}</text>
						</view>
					</text>
					<view class="" v-show="!detailForm.collectionIntegralAmount==0">
						<text class="margin-left margin-right">积分支付</text> <text
							class="text-cyan">{{detailForm.collectionIntegralAmount}}</text>
					</view>
				</view>
			</view>
			
			
			<view class="cu-item solid-top" v-show="detailForm.debtMoney">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">待支付金额</text>
					<text class="text-price text-red margin-left">{{detailForm.debtMoney}}</text>
				</view>
			</view>
			<view class="cu-item solid-top" v-show="detailForm.payMoney">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">补缴金额</text>
					<text class="text-price text-red margin-left">{{detailForm.payMoney}}</text>
				</view>
			</view>
		</view>

		<view class="" v-show="detailForm.promotionNum">

			<view class="flex justify-start align-center padding">
				<text class="text-bold margin-right">促销名称</text>
				<text class="text-bold text-red">{{detailForm.promotionName}}</text>
				<text class=" text-red text-price margin-left padding-left">{{detailForm.amount}}</text>
			</view>
			<view class="flex justify-start align-center padding">
				<text class="text-bold margin-right">单据时间</text>
				<text class="text-bold text-red">{{detailForm.docDate}}</text>
		
			</view>
			<view class="flex justify-start align-center padding">
				<text class="text-bold margin-right">门店名称</text>
				<text  >{{userInfo.storeName}}</text>
			</view>
			<view class="cu-list menu  margin-bottom" v-for="(item,index) in promotionList"
				:key="'promotionList'+index">
				<view class="cu-item solid-top radius">
					<view class="flex justify-start align-center">
						<text class="text-bold margin-right">项目信息</text>
						<text>{{item.projectName}} * {{item.times}}</text>
					</view>
				</view>
				<view class="cu-item solid-top radius">
					<view class="flex justify-start align-center">
						<text class="text-bold margin-right">标准价格</text>
						<text class="text-price text-red">{{item.standardMoney}}</text>
						<text class="text-bold margin-right margin-left">促销价格</text>
						<text class="text-bold text-price text-red">{{item.projectTotalMoney}}</text>
					</view>
				</view>
			</view>
			<view class="cu-list bg-white flex justify-start align-center padding">
				<text class="text-bold margin-right">业务人员</text>
				<view class="">

					<view v-for="(item5,index) in  detailForm.entities" :key="'E'+index">
						<text style="display: inline-block; width: 320rpx;">{{item5.brandNumber}} <text> - </text>
							{{item5.saleStaffName}} </text> 
						
					</view>
				</view>
			</view>
			<view class="cu-list bg-white flex justify-start align-center padding">
				<text class="text-bold margin-right">支付金额</text>
				<view class="">

					<view v-for="(item5,index) in  detailForm.rechargeConsumeList" :key="'E'+index">
						<text class="margin-right">{{item5.rechargeTypeName }} </text> <text> - </text>
						<text class="text-price text-red margin-left margin-right">{{item5.spendMoney}}</text>
					</view>
					<view v-for="(item5,index) in  detailForm.payLists" :key="'r'+index">
						<text class="margin-right">{{item5.payName }} </text> <text> - </text>
						<text class="text-price text-red margin-left margin-right">{{item5.payMoney}}</text>
					</view>
				</view>
			</view>
			
		
				
			
		</view>


		<view class="cu-list menu  margin-bottom" v-for="(item,index) in projectList" :key='index'
			v-show="showIndex&&!detailForm.promotionNum">
			<view class="cu-item solid-top radius">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">项目名称</text>
					<text>{{item.projectName}}</text>
					<text>{{item.tradeName}}</text>
					<text>{{item.rechargeTypeName}}</text>
					<text>{{item.courseProjectName}}</text>
				</view>
			</view>
			<view class="cu-item solid-top">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">单据时间</text>
					<text v-show="!detailForm.refundNum"><text v-show="!item.refundDate">{{item.cashDate}}</text>
					</text>
					<text>{{item.repayDate}}</text>
					<text>{{item.refundDate}}</text>
				</view>
			</view>
			<view class="cu-item solid-top">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">门店名称</text>
					<text>{{userInfo.storeName}}</text>
				</view>
			</view>
			<view class="cu-item solid-top">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">业务人员</text>
					<view class="" v-if="item.entities">
						<view v-for="(item5,index) in  item.entities" :key="'f'+index" >
							<view style="display: inline-block; width: 320rpx;" 
								data-target="Modal">{{item5.brandNumber}} <text> - </text>
								{{item5.saleStaffName}} </view> 
						</view>
					</view>
					<view class="" v-else>
						<view v-for="(item1,index) in  item.largeList" :key="'A'+index">
							<view class="text-cyan text-xs " v-show="item.largeList!=[]">美容师</view>
							<text style="display: inline-block; width: 320rpx;" {{item1.brandNumber}} <text> - </text>
								{{item1.staffName}} </text> 
							
						</view>
						<view v-for="(item2,index) in  item.zhonggongList" :key="'B'+index">
							<text class="text-cyan text-xs " v-show="item.zhonggongList!=[]">美发师</text>
							<text style="display: inline-block; width: 320rpx;"  >{{item2.brandNumber}} <text> - </text>
								{{item2.staffName}} </text> 
							
						</view>
						<view v-for="(item3,index) in  item.smallList" :key="'C'+index">
							<text class="text-cyan text-xs " v-show="item.smallList!=[]">技师</text>
							<br>
							<text style="display: inline-block; width: 320rpx;" >{{item3.brandNumber}} <text> - </text>
								{{item3.staffName}} </text> 
							
						</view>

						<view v-for="(item4,index) in  item.technicianList" :key="'D'+index">
							<text class="text-cyan text-xs " v-show="item.technicianList!=[]">助理</text>
							<br>
							<text style="display: inline-block; width: 320rpx;" >{{item4.brandNumber}} <text> - </text>
								{{item4.staffName}} </text> 
							
						</view>
					</view>
				</view>
			</view>

			<view class="cu-item solid-top" v-show="!item.refundNum">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">付款金额</text>
					<text v-if="detailForm.courseAccountId!=null">
						疗程卡包支付 <text class="text-price text-red margin-left">{{detailForm.amount}}</text>
					</text>
					<text v-else>
						<view v-for="(item,index) in  item.rechargeConsumeList" :key='index'>
							<text>{{item.rechargeTypeName}}</text> <text
								class="margin-left text-price text-red">{{item.spendMoney}}</text>
						</view>
						<view v-for="(item,index) in item.payLists" :key='index'>
							<text>{{item.payName}}</text> <text
								class="margin-left text-price text-red">{{item.payMoney}}</text>
						</view>
						<text v-show="item.payMoney" class=" text-price text-red">
							{{item.payMoney}}
						</text>
					</text>
				</view>
			</view>
			<view class="cu-item solid-top" v-show="item.refundNum">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">退款金额</text>
					<text
						class="text-price text-green">{{item.cashRefundMoney}}{{item.recRefundMoney}}{{item.courseRefundMoney}}</text>
					<text class=" text-bold margin-left margin-right">补偿金额</text>
					<text
						class="text-price text-green">{{item.cashCompensation}}{{item.recCompensation}}{{item.courseCompensation}}</text>
				</view>
			</view>
			<view class="cu-item solid-top" v-show="item.refundNum">
				<view class="flex justify-start align-center">
					<text class="text-bold margin-right">附带文件</text>
					<view v-for="(fileItem,index) in item.fileLists" :key="index" class="margin-right">
						<image style="width: 100rpx;height: 100rpx;" :src="fileItem.url" mode=""
							@tap="_previewImage(fileItem.url)"></image>
					</view>
				</view>
			</view>
			
		
		</view>
		<view class="cu-list bg-white padding margin-bottom solid-top"
			v-show="showIndex&&detailForm.refundNum||detailForm.repayNum&&detailForm.payLists">
			<view class="flex justify-start align-center">
				<text class="text-bold margin-right">总支付</text>
				<view v-for="(item,index) in detailForm.payLists" :key='index'>
					<text>{{item.payName}}</text> <text class="margin-left text-price text-red">{{item.payMoney}}</text>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				modalName: null,
				acForm: {
					brandNumber: 14545
				},
				detailForm: {
					mobilePhone: null,
				},
				projectList: [],
				promotionList: [],
				showIndex: false,
				userInfo: null,
				itemList: [{
						docType: 'card_recharge',
						docTypeName: '充值开卡'
					},
					{
						docType: 'card_use',
						docTypeName: '疗程开卡'
					},
					
					{
						docType: 'store_cash',
						docTypeName: '收银'
					},
					{
						docType: 'card_repay',
						docTypeName: '充值还款'
					},
					{
						docType: 'refund_recharge',
						docTypeName: '充值退款'
					}, {
						docType: 'refund_course',
						docTypeName: '疗程退款'
					}, {
						docType: 'refund_cash',
						docTypeName: '消费退款'
					}, {
						docType: 'promotion',
						docTypeName: '促销活动'
					},
				],


			}
		},
		methods: {
		
			hideModal(e) {
				this.modalName = null
			},
			_previewImage(image) {
				var imgArr = [];
				imgArr.push(image);
				//预览图片
				uni.previewImage({
					urls: imgArr,
					current: imgArr[0]
				});
			},
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数

			this.userInfo = uni.getStorageSync('userInfo')
		
			if (option.account != undefined) {
				//业绩疗程
				let form = JSON.parse(option.account)
			console.log(form);
			// this.detailForm = form
				let page = {
					storeId: this.userInfo.storeId,
				}
			
					if (form.docType == 'card_recharge') {
						page.rechargeNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.$api.rechargePage(page).then(res => {
							if (res.code == '000000') {
								// this.detailForm = Object.assign(form, res.pageInfo.list[0])
								this.detailForm = Object.assign(form, res.pageInfo.list[0])
							} else {
								uni.showModal({
									title: '查询充值单明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '充值单明细'
						})
					}
					if (form.docType == 'recharge_roll_course') {
						page.rechargeNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.$api.courserechargePage(page).then(res => {
							if (res.code == '000000') {
								// this.detailForm = Object.assign(form, res.pageInfo.list[0])
								this.detailForm = Object.assign(form, res.pageInfo.list[0])
							} else {
								uni.showModal({
									title: '疗程转充值单明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '疗程转充值单明细'
						})
					}
					if (form.docType == 'card_change') {
						page.rechargeNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.$api.chargePage(page).then(res => {
							if (res.code == '000000') {
								// this.detailForm = Object.assign(form, res.pageInfo.list[0])
								this.detailForm = Object.assign(form, res.pageInfo.list[0])
							} else {
								uni.showModal({
									title: '加价转疗程单明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '加价转疗程单明细'
						})
					}
					if (form.docType == 'card_use') {
						page.rechargeNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.$api.coursePage(page).then(res => {
							if (res.code == '000000') {
								this.detailForm = Object.assign(form, res.pageInfo.list[0])
							} else {
								uni.showModal({
									title: '查询疗程单明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '疗程单明细'
						})
					}
					if (form.docType == 'store_cash') {
						page.cashNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.$api.cashList(page).then(res => {
							if (res.code == '000000') {
								this.showIndex = true
								this.detailForm = Object.assign(form, res.pageInfo.list[0])
								this.projectList = res.pageInfo.list[0].projectList
							} else {
								uni.showModal({
									title: '查询服务单明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '服务单明细'
						})
					}
					if (form.docType == "refund_recharge") {
						page.refundNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.showIndex = true
						this.$api.refundPage(page).then(res => {
							if (res.code == '000000') {
								let a = {
									refundNum: res.pageInfo.list[0].refundNum,
									refundOrderId: res.pageInfo.list[0].id,
									storeId: this.userInfo.storeId
								}
								this.$api.refundRechargePage(a).then(res => {
									res.pageInfo.list.forEach(item => {
										item.fileLists.forEach(items => {
											items.url =
												'https://www.decaisoft.com/img/' +
												items
												.filePath + "/" + items.fileName
										})
									})
									this.projectList = res.pageInfo.list
								})
							} else {
								uni.showModal({
									title: '查询充值退明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '充值退明细'
						})
					}
					if (form.docType == 'refund_course') {
						page.refundNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.showIndex = true
						this.$api.refundPage(page).then(res => {
							if (res.code == '000000') {
								let a = {
									refundNum: res.pageInfo.list[0].refundNum,
									refundOrderId: res.pageInfo.list[0].id,
									storeId: this.userInfo.storeId
								}
								this.$api.refundCourseList(a).then(res => {
									res.rows.forEach(item => {
										item.fileLists.forEach(items => {
											items.url =
												'https://www.decaisoft.com/img/' +
												items
												.filePath + "/" + items.fileName
										})
									})
									this.projectList = res.rows
								})
							} else {
								uni.showModal({
									title: '查询充值退明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '疗程退明细'
						})
					}
					if (form.docType == "refund_cash") {
						page.refundNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.showIndex = true
						this.$api.refundPage(page).then(res => {
							if (res.code == '000000') {
								let a = {
									refundNum: res.pageInfo.list[0].refundNum,
									refundOrderId: res.pageInfo.list[0].id,
									storeId: this.userInfo.storeId
								}
								this.$api.refundCashList(a).then(res => {
									res.rows.forEach(item => {
										item.fileLists.forEach(items => {
											items.url =
												'https://www.decaisoft.com/img/' +
												items
												.filePath + "/" + items.fileName
										})
									})
									this.projectList = res.rows
								})
							} else {
								uni.showModal({
									title: '查询充值退明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '消费退明细'
						})
					}
					if (form.docType == "promotion") {
						page.docNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.showIndex = true
						this.$api.promotionPage(page).then(res => {
							if (res.code == '000000') {
								this.detailForm = Object.assign(form, res.pageInfo.list[0])
								let a = {
									docNum: res.pageInfo.list[0].docNum,
									storeId: this.userInfo.storeId
								}
								this.$api.promotionProList(a).then(res => {
									this.promotionList = res.rows
								})
							} else {
								uni.showModal({
									title: '查询促销明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '促销明细'
						})
					}


			
					if (form.docType == 'card_repay') {
						page.repayNum = form.docNum
						if (form.docDate) {
							page.selectDate = this.formatTime(form.docDate, "YYYY-MM").replace("-", '')
						} else {
							page.selectDate = this.formatTime(new Date(), "YYYY-MM").replace("-", '')
						}
						this.$api.repayPage(page).then(res => {
							if (res.code == '000000') {
								this.showIndex = true
								this.detailForm = Object.assign(form, res.pageInfo.list[0])
								this.projectList = [...res.pageInfo.list[0].repayTradeLists]
							} else {
								uni.showModal({
									title: '查询还款单明细',
									content: res.message,
									showCancel: false
								})
							}
						})
						uni.setNavigationBarTitle({
							title: '还款单明细'
						})
					
				}
			}
			if (option.debtMoney != undefined) {
				// 门店日报
				let form = JSON.parse(option.debtMoney)
						this.detailForm =form
						uni.setNavigationBarTitle({
							title: '待支付明细'
						})
					
				

			}
			if (option.repayment != undefined) {
				//项目排行榜
				let form = JSON.parse(option.repayment)
			console.log(form);
				this.detailForm = form
					uni.setNavigationBarTitle({
						title: '补缴单明细'
					})
			
				

			}
			if(option.projectFormItem){
				let form = JSON.parse(option.projectFormItem)
				console.log(form);
			}
		}
	}
</script>

<style>

</style>
