2024-06-04 18:43:13 +08:00
|
|
|
|
<template>
|
2024-06-07 02:05:33 +08:00
|
|
|
|
<div class="sku-item">
|
|
|
|
|
<uni-forms label-width="176rpx" label-position="left">
|
|
|
|
|
|
|
|
|
|
<template v-if="specType">
|
|
|
|
|
<template v-for="item in formData.properties">
|
|
|
|
|
<uni-forms-item :label="item.propertyName">
|
|
|
|
|
<uni-easyinput type="text" :value="item.valueName" disabled />
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<uni-forms-item label="商品封面图" name="picUrl" label-position="top">
|
2024-06-11 00:34:43 +08:00
|
|
|
|
<p-uploader v-model:url="formData.picUrl" :readonly="!canEdit" fileMediatype="image" limit="1" mode="grid"
|
2024-06-07 02:05:33 +08:00
|
|
|
|
:imageStyles="{ width: '168rpx', height: '168rpx' }" />
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="商品条码" name="barCode">
|
2024-06-11 00:34:43 +08:00
|
|
|
|
<uni-easyinput type="text" trim="all" v-model="formData.barCode" :disabled="!canEdit" placeholder="请输入商品条码" />
|
2024-06-07 02:05:33 +08:00
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="销售价" name="price">
|
2024-06-11 00:34:43 +08:00
|
|
|
|
<uni-easyinput type="number" trim="all" v-model="formData.price" :disabled="!canEdit" placeholder="请输入商品销售价" />
|
2024-06-07 02:05:33 +08:00
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="市场价" name="marketPrice">
|
2024-06-11 00:34:43 +08:00
|
|
|
|
<uni-easyinput type="number" trim="all" v-model="formData.marketPrice" :disabled="!canEdit"
|
|
|
|
|
placeholder="请输入商品销售价" />
|
2024-06-07 02:05:33 +08:00
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="成本价" name="costPrice">
|
2024-06-11 00:34:43 +08:00
|
|
|
|
<uni-easyinput type="number" trim="all" v-model="formData.costPrice" :disabled="!canEdit"
|
|
|
|
|
placeholder="请输入商品销售价" />
|
2024-06-07 02:05:33 +08:00
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="库存" name="stock">
|
2024-06-11 00:34:43 +08:00
|
|
|
|
<uni-easyinput type="number" trim="all" v-model="formData.stock" :disabled="!canEdit" placeholder="请输入商品库存" />
|
2024-06-07 02:05:33 +08:00
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="重量(kg)" name="weight">
|
2024-06-11 00:34:43 +08:00
|
|
|
|
<uni-easyinput type="number" trim="all" v-model="formData.weight" :disabled="!canEdit" placeholder="请输入商品重量" />
|
2024-06-07 02:05:33 +08:00
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="体积(m³)" name="volume">
|
2024-06-11 00:34:43 +08:00
|
|
|
|
<uni-easyinput type="number" trim="all" v-model="formData.volume" :disabled="!canEdit" placeholder="请输入商品体积" />
|
2024-06-07 02:05:33 +08:00
|
|
|
|
</uni-forms-item>
|
|
|
|
|
</uni-forms>
|
|
|
|
|
</div>
|
2024-06-04 18:43:13 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2024-06-07 02:05:33 +08:00
|
|
|
|
import { ref, watch, computed, defineProps } from 'vue'
|
|
|
|
|
import peach from '@/peach'
|
2024-06-11 00:34:43 +08:00
|
|
|
|
import { canEdit } from '../js/sku';
|
2024-06-07 02:05:33 +08:00
|
|
|
|
const props = defineProps({
|
|
|
|
|
skus: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => []
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-06-04 18:43:13 +08:00
|
|
|
|
const formData = ref({})
|
2024-06-07 02:05:33 +08:00
|
|
|
|
const specType = computed(() => peach.$store("trade").goodsInfo.specType);
|
|
|
|
|
|
|
|
|
|
watch(() => props.skus, (newVal) => {
|
|
|
|
|
console.log(newVal)
|
2024-06-11 00:34:43 +08:00
|
|
|
|
// 如果是单规格,取 sku 第一条数据
|
|
|
|
|
if (!specType.value) {
|
|
|
|
|
formData.value = newVal[0] ?? {}
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-06-07 02:05:33 +08:00
|
|
|
|
formData.value = newVal ?? {}
|
|
|
|
|
}, { immediate: true })
|
|
|
|
|
|
|
|
|
|
|
2024-06-04 18:43:13 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.sku-item {
|
2024-06-07 02:05:33 +08:00
|
|
|
|
margin: 40rpx;
|
|
|
|
|
padding-top: 40rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sku-item:first-child {
|
|
|
|
|
border-top: 1px solid var(--ui-BG-Main);
|
|
|
|
|
|
2024-06-04 18:43:13 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|