|
@@ -85,6 +85,7 @@
|
|
<su-number-box
|
|
<su-number-box
|
|
:min="1"
|
|
:min="1"
|
|
:max="state.selectedSku.stock"
|
|
:max="state.selectedSku.stock"
|
|
|
|
+ :totalStock="totalStock"
|
|
:step="1"
|
|
:step="1"
|
|
ref="selectSkuRef"
|
|
ref="selectSkuRef"
|
|
v-model="state.selectedSku.goods_num"
|
|
v-model="state.selectedSku.goods_num"
|
|
@@ -104,7 +105,7 @@
|
|
defineOptions({name: 'wares-s-select-sku'})
|
|
defineOptions({name: 'wares-s-select-sku'})
|
|
import Snackbar from '@/plugins/snackbar'
|
|
import Snackbar from '@/plugins/snackbar'
|
|
import suNumberBox from '@/components/FormUI/su-number-box/su-number-box.vue'
|
|
import suNumberBox from '@/components/FormUI/su-number-box/su-number-box.vue'
|
|
-import { computed, reactive, watch, ref, onMounted } from 'vue'
|
|
|
|
|
|
+import { computed, reactive, watch, ref } from 'vue'
|
|
import { convertProductPropertyList } from '@/views/mall/utils'
|
|
import { convertProductPropertyList } from '@/views/mall/utils'
|
|
|
|
|
|
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
|
|
const emits = defineEmits(['change', 'addCart', 'buy', 'close']);
|
|
@@ -116,13 +117,6 @@ const props = defineProps({
|
|
});
|
|
});
|
|
|
|
|
|
const totalStock = ref(props.goodsInfo?.stock-0 || 0)
|
|
const totalStock = ref(props.goodsInfo?.stock-0 || 0)
|
|
- function setTotalStock() {
|
|
|
|
- if (selectSkuRef.value) selectSkuRef.value.stock = totalStock.value
|
|
|
|
- }
|
|
|
|
- onMounted(() => {
|
|
|
|
- setTotalStock()
|
|
|
|
- })
|
|
|
|
- const selectSkuRef = ref()
|
|
|
|
const state = reactive({
|
|
const state = reactive({
|
|
selectedSku: {}, // 选中的 SKU
|
|
selectedSku: {}, // 选中的 SKU
|
|
currentPropertyArray: [], // 当前选中的属性,实际是个 Map。key 是 property 编号,value 是 value 编号
|
|
currentPropertyArray: [], // 当前选中的属性,实际是个 Map。key 是 property 编号,value 是 value 编号
|
|
@@ -141,8 +135,7 @@ const props = defineProps({
|
|
watch(
|
|
watch(
|
|
() => state.selectedSku,
|
|
() => state.selectedSku,
|
|
(newVal) => {
|
|
(newVal) => {
|
|
- if (newVal?.stock) selectSkuRef.value.stock = newVal.stock
|
|
|
|
- else setTotalStock()
|
|
|
|
|
|
+ if (newVal?.stock) totalStock.value = newVal.stock
|
|
emits('change', newVal);
|
|
emits('change', newVal);
|
|
},
|
|
},
|
|
{
|
|
{
|