<template>
	<view>
		<view class='wrap'>
			<view class="xinxi" v-if="detailData.expensesType == '2'" style="font-size: 28rpx; ">请款信息</view>
			<view class="xinxi" v-if="detailData.expensesType == '1'" style="font-size: 28rpx; ">收款信息</view>
			<view class="c-row">
				<view class="title">用途</view>
				<view class="con-list">
					<view>{{detailData.purpose}}</view>
				</view>
			</view>
			<view class="c-row" v-if="detailData.purpose == '库点费用'">
				<view class="title">仓库名称</view>
				<view class="con-list">
					<view>{{detailData.warehouseName}}</view>
				</view>
			</view>
			<view class="c-row" v-if="detailData.purpose == '库点费用'">
				<view class="title">类型</view>
				<view class="con-list">
					<view>{{detailData.wareExpenseType}}</view>
				</view>
			</view>
			<view class="c-row" v-if="detailData.purpose == '合同费用'">
				<view class="title">合同编号</view>
				<view class="con-list">
					<view>{{detailData.contractNo}}</view>
				</view>
			</view>
			<view class="c-row">
				<view class="title">费用名称</view>
				<view class="con-list">
					<view>{{detailData.expenseName}}</view>
				</view>
			</view>
			<view class="c-row" v-if="detailData.expensesType == '2'">
				<view class="title">付款方名头</view>
				<view class="con-list">
					<view>{{detailData.payerHeader}}</view>
				</view>
			</view>
			<view class="c-row" v-if="detailData.purpose == '经营性费用' && detailData.expensesType == '2'">
				<view class="title">所属名头</view>
				<view class="con-list">
					<view>{{detailData.belongName}}</view>
				</view>
			</view>
			<view class="c-row">
				<view class="title">金额（元）</view>
				<view class="con-list">
					<view>{{detailData.amountMoney}}</view>
				</view>
			</view>
			<view class="c-row">
				<view class="left">备注</view>
			</view>
			<view style='position:relative;' class="wrap no-boder">
				<u-input class='textarea' v-model="detailData.remark" :disabled="disabled" :type="type" :border="border"
					placeholder="选填,不超过150字" :height="height" :auto-height="autoHeight" maxlength="150" />
				<view style='position:absolute;right:10px;bottom:20px;color:#AFB3BF;'>
					{{detailData.remark?detailData.remark.length:"0"}}/150个字
				</view>
			</view>
			<view class="c-row">
				<view class="title">附件</view>
			</view>
			<view>
				<view v-if='imglist2.length>0'>
					<view style="margin-top: 20rpx;" v-for='item in imglist2'>
						<view class="img_item">
							<view class="" style="width: 16%;">
								<image
									v-if="item.type == 'pdf'"
									style="width: 40px; height: 40px;" src="../../static/img/oa_office/pdf3.png"
									mode=""></image>
								<image v-else-if="item.type == 'xls'||item.type == 'xlsx'"
									style="width: 40px; height: 40px;" src="../../static/img/oa_office/excle3.png"
									mode=""></image>
								<image v-else-if="item.type == 'doc'||item.type == 'docx'"
									style="width: 40px; height: 40px;" src="../../static/img/oa_office/word3.png"
									mode=""></image>
								<image v-else style="width: 40px; height: 40px;" :src="item.appendixPath" mode="">
								</image>
							</view>
							<view class="" style="width: 70%;">
								<view class="char_css">{{item.appendixName}}</view>
								<view class="">{{item.appendixSize}}</view>
							</view>
							<view class="img_dowload" @click="openDocument(item)">下载</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-if="detailData.expensesType == '2'" class='wrap margin-bottom'>
			<view class="xinxi"  style="font-size: 28rpx; ">收款账户信息</view>
			<view class="c-row">
				<view class="title">收款方</view>
				<view class="con-list">
					<view>{{detailData.payee}}</view>
				</view>
			</view>
			<view class="c-row">
				<view class="title">账户</view>
				<view class="con-list">
					<view>{{detailData.accountNumber}}</view>
				</view>
			</view>
			<view class="c-row">
				<view class="title">开户行</view>
				<view class="con-list">
					<view>{{detailData.bank}}</view>
				</view>
			</view>
			<view class="c-row">
				<view class="title">开户支行</view>
				<view class="con-list">
					<view>{{detailData.bankBranch}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				disabled: false,
				detailData: {
					purpose: '',
					remark: "",
					warehouseName: '',
					expenseName: '',
					amountMoney: '',
					contractNo: '',
					expensesPurpose: ''
				},
				type: 'textarea',
				border: true,
				imglist: [], //存
				imglist2: [], //展示
				height: 150,
				autoHeight: true,
			}
		},
		onLoad(options) {
			this.id = options.id
			if (this.id) {
				this.disabled = true
			} else {
				return
			}
			this.getList()
		},
		watch: {
			imglist: {
				handler: function() {
					this.$api.doRequest('get', 'appendix/query/getFileList', {
						appendixIds: this.imglist.toString()
					}).then(res => {
						this.imglist2 = res.data.data
						for (let i = 0; i < this.imglist2.length; i++) {
							if (this.imglist2[i].appendixName) {
								this.imglist2[i].type = this.imglist2[i].appendixName.split(".")[1]
							}
						}
					})
				},
				deep: true
			}
		},
		methods: {
			openDocument(src) {
				uni.downloadFile({
					url: src.appendixPath,
					success: function(res) {
						var filePath = res.tempFilePath;
						uni.openDocument({
							filePath: filePath,
							showMenu: true,
							success: function(res) {
								console.log('打开文档成功');
							}
						});
					}
				});
			},
			calculate() {
				const query = uni.createSelectorQuery().in(this);
				query.selectAll('.left')
				console.log(query)
			},
			//获取信息
			getList() {
				this.$api.doRequest('get', '/expenseInfo/ExpenseInfo', {
					id: this.id,
				}).then(res => {
					if (res.data.code == 200) {
						this.detailData = res.data.data
						this.imglist = this.detailData.addressUrl.split(',')
					}
				})
			},
		},
	}
</script>

<style lang='scss' scoped>
	page {
		background: #F5F6FA;
	}

	.delete_img {
		position: absolute;
		z-index: 9999;
		left: 84px;
		color: #ffffff;
		font-size: 28rpx;
		border: 1px;
		border-radius: 5rpx;
		width: 32rpx;
		height: 32rpx;
		background-color: #ff0000;
		text-align: center;
	}

	.title_b {
		margin: 20rpx 20rpx 0rpx 20rpx;
		padding: 20rpx 10rpx 20rpx 10rpx;
		font-size: 18px;
		font-weight: 550;
	}

	.xinxi {
		padding: 20rpx 30rpx;
	}

	.c-row {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-align: center;
		-webkit-align-items: center;
		align-items: center;
		padding: 20rpx 30rpx;
		position: relative;
	}

	.con-list {
		-webkit-box-flex: 1;
		flex: 1;
		display: flex;
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		flex-direction: column;
		color: #303133;
		line-height: 20px;
		text-align: right;
		padding-right: 10px;
		justify-content: space-between;
	}

	.wrap {
		padding-bottom: 10px;
		font-size: 14px;
		background: #fff;
		margin: 10px;
		border-radius: 10px;

		input {
			font-size: 14px;
		}

		>.title {
			padding: 10px 16px;
		}

	}

	.buns_item {
		display: flex;
		padding: 80rpx 0 50rpx 0;
		justify-content: space-around;
	}

	.but_css {
		background: #22C572;
		width: 40%;
		padding: 20rpx;
		color: #fff;
		text-align: center;
		border-radius: 20rpx;
	}

	/deep/.u-radio-group {
		flex-direction: row-reverse;
	}

	.no-boder {
		border: 0;
	}

	.textarea {
		background: #F9F9FA;
		border: 1px solid #EEEEEE;
	}

	.submit {
		width: 100%;
		background: #2c8ac5;
		border-radius: 10rpx;
	}

	.bottom-btn {
		padding: 30rpx;
		background: #FFFFFF;
		width: 100%;
		position: fixed;
		bottom: 0rpx;
		display: flex;
		z-index: 9999;
	}

	.upload {
		width: 80rpx;
		height: 80rpx;
	}

	.char_css {
		font-size: 30rpx;
		font-weight: 600;
		display: -webkit-box;
		overflow: hidden;
		/*! autoprefixer: off; */
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		word-break: break-all;
	}

	.img_item {
		display: flex;
		width: 100%;
		margin: 10px 0;
		padding: 0 10rpx;

		.img_dowload {
			width: 14%;
			color: #22C572;
			text-align: right;
		}
	}
</style>
