【代码优化】商城: 完善积分商城

pull/558/head
puhui999 2024-09-28 10:00:46 +08:00
parent 7a6c69495d
commit 1f8e419f78
2 changed files with 16 additions and 4 deletions

View File

@ -9,7 +9,7 @@
>
<!-- 先选择 -->
<template #spuId>
<el-button @click="spuSelectRef.open()"></el-button>
<el-button v-if="!isFormUpdate" @click="spuSelectRef.open()"></el-button>
<SpuAndSkuList
ref="spuAndSkuListRef"
:rule-config="ruleConfig"
@ -18,7 +18,12 @@
>
<el-table-column align="center" label="可兑换库存" min-width="168">
<template #default="{ row: sku }">
<el-input-number v-model="sku.productConfig.stock" :min="0" class="w-100%" />
<el-input-number
v-model="sku.productConfig.stock"
:max="sku.stock"
:min="0"
class="w-100%"
/>
</template>
</el-table-column>
<el-table-column align="center" label="可兑换次数" min-width="168">
@ -77,6 +82,7 @@ const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formRef = ref() // Ref
const isFormUpdate = ref(false) //
// ================= =================
@ -163,6 +169,7 @@ const open = async (type: string, id?: number) => {
formLoading.value = true
try {
const data = (await PointActivityApi.getPointActivity(id)) as PointActivityVO
isFormUpdate.value = true
await getSpuDetails(
data.spuId!,
data.products?.map((sku) => sku.skuId),
@ -213,6 +220,7 @@ const submitForm = async () => {
const resetForm = async () => {
spuList.value = []
spuPropertyList.value = []
isFormUpdate.value = false
await nextTick()
formRef.value.getElFormRef().resetFields()
}

View File

@ -83,10 +83,13 @@
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<!-- TODO @puhui999这里没读取到 -->
<el-table-column align="center" label="库存" min-width="80" prop="stock" />
<el-table-column align="center" label="总库存" min-width="80" prop="totalStock" />
<el-table-column label="已兑换数量" min-width="100" prop="redeemedQuantity" />
<el-table-column align="center" label="已兑换数量" min-width="100" prop="redeemedQuantity">
<template #default="{ row }">
{{ getRedeemedQuantity(row) }}
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
@ -160,6 +163,7 @@ const queryParams = reactive({
status: null
})
const queryFormRef = ref() //
const getRedeemedQuantity = computed(() => (row: any) => (row.totalStock || 0) - (row.stock || 0)) //
/** 查询列表 */
const getList = async () => {