<template>
	<view>
		<view class="cmain">
			<view class="box order_detail" style="margin-top: 0px">
				<view class="item">
					<text class="label">收购状态</text>
					<text class="desc" v-if="item.isRelease == 0">
						<text class="icon">&#xe830;</text>
						<text>未发布</text>
					</text>
					<text class="desc" v-if="item.isRelease == 1 && item.isOrders == 0">
						<text class="icon">&#xe830;</text>
						<text>未接单</text>
					</text>
					<text class="desc" v-if="item.isOrders == 1 && item.isConfirm == 0">
						<text class="icon" style="color: #13ce66">&#xe830;</text>
						<text>已接单</text>
					</text>
					<text class="desc" v-if="item.isConfirm == 1">
						<text class="icon" style="color: #13ce66">&#xe830;</text>
						<text>已确认</text>
					</text>
				</view>
			</view>
			<view class="box order_detail">
				<view class="item">
					<text class="label">收购商品</text>
					<text class="desc omit">{{ item.goodsName }}</text>
				</view>
				<view class="item">
					<text class="label">数量</text>
					<text class="desc">{{ item.goodsQuantity }}</text>
				</view>
				<view class="item">
					<text class="label">发布时间</text>
					<text class="desc">{{ item.goodsDemandTime }}</text>
				</view>
				<view class="item">
					<text class="label">接单组名</text>
					<text class="desc">{{ item.groupName }}</text>
				</view>
				<view class="item">
					<text class="label">接单组长</text>
					<text class="desc">{{ item.createName }}</text>
				</view>
				<view class="item">
					<text class="label">组长备注</text>
					<text class="desc">{{ item.remark }}</text>
				</view>
				<view class="item">
					<text class="label">出价金额</text>
					<text class="desc">{{ item.quotation }}</text>
				</view>
				<view class="item">
					<text class="label">报价时间</text>
					<text class="desc">{{ item.createTime }}</text>
				</view>
			</view>
			<button class="btn" @click.stop="confirm()" v-if="item.isRelease == 1 && item.isOrders == 1 && item.isConfirm == 0">同意接单并支付</button>
			<button class="btn" @click.stop="refuse()" style="background-color: #F44336;" v-if="item.isRelease == 1 && item.isOrders == 1 && item.isConfirm == 0">拒绝接单</button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			item: {}
		};
	},
	onLoad(e) {
		if (e.id) {
			this.http.request({
				url: '/level-two-server/app/TbGoodsDemand/goodsDemandDetail?id=' + e.id,
				success: res => {
					this.item = res.data.data;
				}
			});
		}
	},
	methods: {
		confirm() {
			this.http.request({
				url: '/level-two-server/app/TbOrders/add',
				data: this.item,
				success: res => {
					uni.showToast({ title: '操作成功' });
					// 收购商已确认
					this.item.isConfirm = 1
				}
			});
		},
		refuse() {
			this.http.request({
				url: '/level-two-server/app/TbGoodsDemand/refuse?id=' + e.id,
				success: res => {
					uni.showToast({ title: '操作成功' });
					
				}
			});
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: $pg;
}
.btn{
	margin-top: 20px;
	width: 70%;
}
</style>
