<template>
	<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9" :zIndex="999">
		<view class="u-p-32 box u-font-28">
			<view class="u-flex u-relative u-row-center">
				<view class="u-font-32">报损</view>
				<view class="u-absolute close">
					<up-icon @click="close" :size="16" color="#000" name="close-circle-fill"></up-icon>
				</view>
			</view>
			<view class="u-m-t-48">
				<view>商品名称</view>
				<view class="u-m-t-16">{{data.name}}</view>
				<view class="u-m-t-38">
					<view class="u-m-b-32">
						<view class="u-flex ">
							报损数量
						</view>
						<view class="u-m-t-16">
							<up-input v-model="form.number">
								<template #suffix>
									<view>{{data.unitName}}</view>
								</template>
							</up-input>
						</view>
					</view>
					<view class="u-m-b-32">
						<view class="u-flex u-row-between">
							<view>备注</view>
						</view>
						<view class="u-m-t-16">
							<up-textarea :height="42" v-model="form.note" placeholder="请输入备注"></up-textarea>
						</view>
					</view>
					<view class="u-m-b-32">
						<view class="u-flex u-row-between">
							<view>上传图片</view>
						</view>
						<view class="u-m-t-16">
							<scroll-view scroll-y="true" style="max-height: 300rpx;">
								<my-up-upload v-model="form.images"></my-up-upload>
							</scroll-view>
						</view>
					</view>
					<view class="u-m-t-60">
						<my-button type="primary" shape="circle" @tap="save">
							<view class="u-font-32">
								保存
							</view>
						</my-button>
					</view>
				</view>
			</view>
		</view>
	</up-popup>
</template>

<script setup>
	import {
		reactive,
		ref,
		watch,
		onMounted
	} from 'vue';
	import {
		returnSkuSnap,
		returnTypeEnum,
		returnCategory
	} from '@/pageProduct/util.js'
	import {
		$tbShopUnit
	} from '@/http/yskApi/goods.js'
	const props = defineProps({
		show: {
			type: Boolean,
			default: false
		},
		category: {
			type: Array,
			default: () => []
		},
		goods: {
			type: Object,
			default: () => {
				skuList: []
			}
		}
	})
	const data = ref(props.goods)
	const emits = defineEmits(['update:show', 'save'])
	const form = reactive({
		note: '',
		number: 1,
		images: []
	})
	let popShow = ref(props.show)
	watch(() => props.show, (newval) => {
		popShow.value = newval
		if (newval) {
			data.value = props.goods
		}
	})
	watch(() => popShow.value, (newval) => {
		emits('update:show', newval)
	})

	function close() {
		popShow.value = false
	}

	function open() {

	}

	function save() {
		console.log(form.images);
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 556rpx;
		border-radius: 18rpx 18rpx 18rpx 18rpx;
		box-sizing: border-box;
	}

	.close {
		position: absolute;
		right: 0;
	}

	.number {
		color: #EE4646;
	}
</style>