<template>
	<up-popup :show="popShow" @close="close" @open="open" mode="center" :round="9">
		<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-36">
				<scroll-view scroll-y="true" style="max-height: 70vh;">
					<view class="u-m-b-32" v-for="(item,index) in list" :key="index">
						<view>{{item.text}}：</view>
						<view class="u-m-t-16">
							<up-input v-model="item.value">
								<template #suffix>
									<up-button @click="itemClick(item)" type="primary" text="修改" size="mini"></up-button>
								</template>
							</up-input>
						</view>
					</view>
				</scroll-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>
	</up-popup>
</template>

<script setup>
	import {
		reactive,
		ref,
		watch,
		onMounted,
		computed
	} 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
		}
	})
	const arr = [
		{
			text: '售价',
			key: 'salePrice',
			value: ''
		},
		{
			text: '会员价',
			key: 'memberPrice',
			value: ''
		},
		{
			text: '成本价',
			key: 'costPrice',
			value: ''
		},
		{
			text: '原价',
			key: 'originPrice',
			value: ''
		},
		{
			text: '起售数量',
			key: 'suit',
			value: 1
		},
		// {
		// 	text: '库存数量',
		// 	key: 'stockNumber',
		// 	value: ''
		// },
		{
			text: '分销金额',
			key: 'firstShared',
			value: ''
		}
	]
	const list = ref([...arr])

	function changeShowRecoders(show) {
		recoders.show = show
	}

	const data = ref(props.item)
	const emits = defineEmits(['update:show', 'update','itemClick'])
	const form = reactive({
		note: ''
	})
	let popShow = ref(props.show)
	
	function itemClick(item){
		console.log(item);
		emits('update',[item])
	}
	

	watch(() => props.show, (newval) => {
		popShow.value = newval
		if (newval) {
			data.value = props.item
		}
	})
	const isSku = computed(() => {
		// return data.value.typeEnum == '多规格'
		return false
	})
	watch(() => popShow.value, (newval) => {
		emits('update:show', newval)
	})

	function close() {
		popShow.value = false
		list.value=[...arr]
	}

	function open() {

	}

	function save() {
		emits('update',list.value)
		popShow.value = false
	}
</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>