<template>
	<view>
		<view class="ordertop" v-if="type.refno4 == 'SJRK'">
			<view>
				<view class="iconblue"></view>
				<text class="license">基础信息</text>
			</view>
			<view class="line">
				<u-line color="#ccc" border-style='dashed' />
			</view>
			<view class="basic">
				<view>客户</view>
				<view>{{form.corpName}}</view>
			</view>
			<view class="basic">
				<view>提单号</view>
				<view>{{form.fMblno}}</view>
			</view>
			<view class="basic">
				<view>计划日期</view>
				<view>{{form.fMblno}}</view>
			</view>
			<view class="basic">
				<view>入库时间</view>
				<view>{{form.fBsdate}}</view>
			</view>
			<view class="basic">
				<view>品名</view>
				<view>{{form.goodsName}}</view>
			</view>
			<view class="basic">
				<view>仓库</view>
				<view>{{form.warehouseName}}</view>
			</view>
			<view class="basic">
				<view>计划件数</view>
				<view>{{form.fPlanqty}}</view>
			</view>
			<view class="basic">
				<view>计划净重(kg)</view>
				<view>{{form.fPlannetweight}}</view>
			</view>
			<view class="basic">
				<view>计划毛重(kg)</view>
				<view>{{form.fPlangrossweight}}</view>
			</view>
			<view class="basic">
				<view>备注</view>
				<view>{{form.remark}}</view>
			</view>
			<view class="basic" v-for="(item,index) in form.cntrsList" :key="index">
				<view>箱型/箱量</view>
				<view>{{form.fMblno}}{{form.fMblno}}</view>
			</view>
		</view>
		<view class="ordertop" v-if="type.refno4 == 'SJCK'">
			<view>
				<view class="iconblue"></view>
				<text class="license">基础信息</text>
			</view>
			<view class="line">
				<u-line color="#ccc" border-style='dashed' />
			</view>
			<view class="basic">
				<view>客户</view>
				<view>{{form.corpName}}</view>
			</view>
			<view class="basic">
				<view>结算方式</view>
				<view>{{form.stltypeName}}</view>
			</view>
			<view class="basic">
				<view>提单号</view>
				<view>{{form.fMblno}}</view>
			</view>
			<view class="basic">
				<view>业务日期</view>
				<view>{{form.fBstime}}</view>
			</view>
			<view class="basic">
				<view>仓管员</view>
				<view>{{form.fStorekeeper}}</view>
			</view>
			<view class="basic">
				<view>仓库</view>
				<view>{{form.warehouseName}}</view>
			</view>
			<view class="basic">
				<view>计划件数</view>
				<view>{{form.fPlanqty}}</view>
			</view>
			<view class="basic">
				<view>计划净重(kg)</view>
				<view>{{form.fPlannetweight}}</view>
			</view>
			<view class="basic">
				<view>计划毛重(kg)</view>
				<view>{{form.fPlangrossweight}}</view>
			</view>
			<view class="basic">
				<view>收费提示(kg)</view>
				<view>{{form.fRemarksFees}}</view>
			</view>
			<view class="basic">
				<view>备注</view>
				<view>{{form.remark}}</view>
			</view>
			<view class="basic" v-for="(item,index) in form.cntrsList" :key="index">
				<view>箱型/箱量</view>
				<view>{{form.fMblno}}{{form.fMblno}}</view>
			</view>
		</view>
		<view class="ordertop" v-if="type.refno4 == 'CKDB'">
			<view>
				<view class="iconblue"></view>
				<text class="license">基础信息</text>
			</view>
			<view class="line">
				<u-line color="#ccc" border-style='dashed' />
			</view>
			<view class="basic">
				<view>客户</view>
				<view>{{form.corpName}}</view>
			</view>
			<view class="basic">
				<view>作业类型</view>
				<view>{{form.businessTypeName}}</view>
			</view>
			<view class="basic">
				<view>提单号</view>
				<view>{{form.fMblno}}</view>
			</view>
			<view class="basic">
				<view>业务日期</view>
				<view>{{form.fBsdate}}</view>
			</view>
			<view class="basic">
				<view>业务时间</view>
				<view>{{form.updateTime}}</view>
			</view>
			<view class="basic">
				<view>仓管员</view>
				<view>{{form.fStorekeeper}}</view>
			</view>
			<view class="basic">
				<view>调入仓库</view>
				<view>{{form.inWarehouseName}}</view>
			</view>
			<view class="basic">
				<view>调出仓库</view>
				<view>{{form.warehouseName}}</view>
			</view>
			<view class="basic">
				<view>单据编号</view>
				<view>{{form.fBillno}}</view>
			</view>
			<view class="basic">
				<view>计划件数</view>
				<view>{{form.fPlanqty}}</view>
			</view>
			<view class="basic">
				<view>计划净重(kg)</view>
				<view>{{form.fPlannetweight}}</view>
			</view>
			<view class="basic">
				<view>计划毛重(kg)</view>
				<view>{{form.fPlangrossweight}}</view>
			</view>
			<view class="basic">
				<view>备注</view>
				<view>{{form.remark}}</view>
			</view>
			<view class="basic" v-for="(item,index) in form.cntrsList" :key="index">
				<view>箱型/箱量</view>
				<view>{{form.fMblno}}{{form.fMblno}}</view>
			</view>
		</view>
		<view class="ordertop" v-if="type.refno4 == 'HQZY'">
			<view>
				<view class="iconblue"></view>
				<text class="license">基础信息</text>
			</view>
			<view class="line">
				<u-line color="#ccc" border-style='dashed' />
			</view>
			<view class="basic">
				<view>客户</view>
				<view>{{form.corpName}}</view>
			</view>
			<view class="basic">
				<view>新客户</view>
				<view>{{form.toCorpName}}</view>
			</view>
			<view class="basic">
				<view>业务编号</view>
				<view>{{form.fBillno}}</view>
			</view>
			<view class="basic">
				<view>货转日期</view>
				<view>{{form.fBsdate}}</view>
			</view>
			<view class="basic">
				<view>仓储费日期</view>
				<view>{{form.fChargedate}}</view>
			</view>
			<view class="basic">
				<view>仓库</view>
				<view>{{form.warehouseName}}</view>
			</view>
			<view class="basic">
				<view>结算方式</view>
				<view>{{form.stltypeName}}</view>
			</view>
			<view class="basic">
				<view>计费单位</view>
				<view>{{form.feetunitName}}</view>
			</view>
			<view class="basic">
				<view>贸易方式</view>
				<view>{{form.newTrademodeName}}</view>
			</view>
			<view class="basic">
				<view>提单号</view>
				<view>{{form.fMblno}}</view>
			</view>
			<view class="basic">
				<view>品牌</view>
				<view>{{form.fMarks}}</view>
			</view>
			<view class="basic">
				<view>品名</view>
				<view>{{form.fProductName}}</view>
			</view>
			<view class="basic">
				<view>制单人</view>
				<view>{{form.createBy}}</view>
			</view>
			<view class="basic" v-for="(item,index) in form.cntrsList" :key="index">
				<view>箱型/箱量</view>
				<view>{{form.fMblno}}{{form.fMblno}}</view>
			</view>
		</view>
		<view class="ordertop" v-if="form.enclosureList != null">
			<view>
				<view class="iconblue"></view>
				<text class="license">附件</text>
			</view>
			<view class="line">
				<u-line color="#ccc" border-style='dashed'/>
			</view>
			<view class="basic" v-for="(item,index) in form.enclosureList" :key="index">
				<view>{{item.fName}}</view>
				<view>
					<u-button type="primary" :ripple="true" ripple-bg-color="#909399" size="mini" @click="previewDocx(item.fUrl)">查看</u-button>
				</view>
			</view>
		</view>
		<view style="width: 100%;position:fixed; bottom:0rpx;background-color: #FFFFFF;padding-left: 40rpx;padding-right: 40rpx;margin-bottom: 30rpx;margin-top: 100rpx;">
			<view style="float: left;width: 49%;">
				<u-button type="primary" @click="appToExamine(true)">审核通过</u-button>
			</view>
			<view style="float: right;width: 49%;">
				<u-button type="primary" @click="appToExamine(false)">审核拒绝</u-button>
			</view>
		</view>
		<u-modal v-model="showTwo" :title="titleTwo" :show-cancel-button="true" :content-style="{margin: '40rpx auto'}"
			@confirm="confirmTwo">
			<view class="slot-content">
				<!-- <rich-text v-if="ToExamineType == true && dataList.length > 0" :nodes="content" style="text-align: center;"></rich-text> -->
				<u-form v-if="ToExamineType == true" style="width: 90%;margin: 0 auto;">
					<u-form-item label="同意意见:" label-width="130rpx">
						<u-input height="20rpx" :clearable="false" type="textarea" v-model="valueTwo" />
					</u-form-item>
				</u-form>
				<u-form v-else style="width: 90%;margin: 0 auto;">
					<u-form-item label="拒绝理由:" label-width="130rpx">
						<u-input height="20rpx" :clearable="false" type="textarea" v-model="valueTwo" />
					</u-form-item>
				</u-form>
			</view>
		</u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				titleTwo: '',
				showTwo: false,
				ToExamineType: '',
				valueTwo: '',
				type: {},
				form: {}
			}
		},
		onLoad: function(option) {
			this.type = JSON.parse(option.form)
			this.$u.get('warehouseBusiness/goodsTransfer/app?id=' + this.type.billId).then(res => {
				console.log(res.data)
				this.form = res.data
				if (this.form.cntrsList == null) this.form.cntrsList = []
			})
		},
		methods: {
			confirmTwo() {
				if (this.ToExamineType == false) {
					if (this.valueTwo) {
						this.$u.post('/warehouse/paths/approvalRejected', {
							actId: this.type.actId,
							auditItem: new Date().getFullYear() + '-' + Number(new Date().getMonth()+1) + '-' + new Date().getDate(),
							auditMsg: this.valueTwo,
							auditUserId: uni.getStorageSync('userId'),
							billId: this.form.fId,
							id: this.form.fId
						}).then(res => {
							uni.navigateBack();
						})
					} else {
						this.showTwo = true
						uni.showToast({
							icon: 'none',
							title: '请填写拒绝理由',
							position: "center"
						})
					}
				} else {
					// let tiem = moment(Date.parse(new Date())).format('YYYY-MM-DD')
					if (this.valueTwo) {
						this.$u.post('/warehouse/paths/approved', {
							actId: this.type.actId,
							auditItem: new Date().getFullYear() + '-' + Number(new Date().getMonth()+1) + '-' + new Date().getDate(),
							auditMsg: this.valueTwo,
							auditUserId: uni.getStorageSync('userId'),
							billId: this.form.fId,
							id: this.form.fId
						}).then(res => {
							uni.navigateBack();
						})
					} else {
						this.showTwo = true
						uni.showToast({
							icon: 'none',
							title: '请填写同意意见',
							position: "center"
						})
					}
				}
			},
			appToExamine(ToExamineType) {
				this.ToExamineType = ToExamineType
				this.showTwo = true
				if (ToExamineType == true) {
					this.titleTwo = '确认同意'
				} else {
					this.titleTwo = '确认拒绝'
				}
			},
			//预览
			previewDocx(item){
				if(item == null){
					uni.showToast({
						icon: 'none',
						title: '无附件',
						position: "bottom"
					})
				}else{
					uni.downloadFile({
						url: item,
						success: (res) => {
							if (res.statusCode === 200) {
								uni.openDocument({
									filePath: res.tempFilePath,
									// 如果文件名包含中文，建议使用escape(res.tempFilePath)转码，防止ios和安卓客户端导致的差异
									success: function(res) {
										uni.showToast({
											icon: 'none',
											title: '打开附件成功',
											position: "bottom"
										})
									},
									fail:function(res){
										uni.showToast({
											icon: 'none',
											title: '打开附件失败',
											position: "bottom"
										})
									}
								});
							}
						}
					})
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.ordertop {
		width: 96%;
		background-color: #fff;
		margin: 20rpx auto;
		border-radius: 20rpx;
		padding-top: 20rpx;
		box-shadow: 0px 0px 8px 0px rgba(165, 189, 251, 0.4);
		padding-bottom: 10rpx;
	}

	.ordertop>view:nth-child(1) {
		width: 98%;
		margin-bottom: 60rpx;
	}

	.iconblue {
		width: 10rpx;
		height: 45rpx;
		float: left;
		background-color: #3a63cf;
		margin-right: 10rpx;
	}

	.various {
		float: right;
		width: 150rpx;
		border: 2rpx solid #3a63cf;
		text-align: center;
		border-radius: 100rpx;
		color: #3a63cf;
	}

	.line {
		width: 92%;
		margin: 0 auto;
	}

	.license {
		float: left;
		font-size: 32rpx;
	}

	.basic {
		width: 94%;
		margin: 10rpx auto;
		display: flex;
		justify-content: space-between;
	}

	.basic>view {
		margin-bottom: 10rpx;
	}

	.basic>view:nth-child(1) {
		color: #797979;
	}
</style>
