Skip to content

Commit 1f8e419

Browse files
author
puhui999
committed
【代码优化】商城: 完善积分商城
1 parent 7a6c694 commit 1f8e419

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/views/mall/promotion/point/activity/PointActivityForm.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
>
1010
<!-- 先选择 -->
1111
<template #spuId>
12-
<el-button @click="spuSelectRef.open()">选择商品</el-button>
12+
<el-button v-if="!isFormUpdate" @click="spuSelectRef.open()">选择商品</el-button>
1313
<SpuAndSkuList
1414
ref="spuAndSkuListRef"
1515
:rule-config="ruleConfig"
@@ -18,7 +18,12 @@
1818
>
1919
<el-table-column align="center" label="可兑换库存" min-width="168">
2020
<template #default="{ row: sku }">
21-
<el-input-number v-model="sku.productConfig.stock" :min="0" class="w-100%" />
21+
<el-input-number
22+
v-model="sku.productConfig.stock"
23+
:max="sku.stock"
24+
:min="0"
25+
class="w-100%"
26+
/>
2227
</template>
2328
</el-table-column>
2429
<el-table-column align="center" label="可兑换次数" min-width="168">
@@ -77,6 +82,7 @@ const dialogTitle = ref('') // 弹窗的标题
7782
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
7883
const formType = ref('') // 表单的类型:create - 新增;update - 修改
7984
const formRef = ref() // 表单 Ref
85+
const isFormUpdate = ref(false) // 是否更新表单
8086
8187
// ================= 商品选择相关 =================
8288
@@ -163,6 +169,7 @@ const open = async (type: string, id?: number) => {
163169
formLoading.value = true
164170
try {
165171
const data = (await PointActivityApi.getPointActivity(id)) as PointActivityVO
172+
isFormUpdate.value = true
166173
await getSpuDetails(
167174
data.spuId!,
168175
data.products?.map((sku) => sku.skuId),
@@ -213,6 +220,7 @@ const submitForm = async () => {
213220
const resetForm = async () => {
214221
spuList.value = []
215222
spuPropertyList.value = []
223+
isFormUpdate.value = false
216224
await nextTick()
217225
formRef.value.getElFormRef().resetFields()
218226
}

src/views/mall/promotion/point/activity/index.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,13 @@
8383
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
8484
</template>
8585
</el-table-column>
86-
<!-- TODO @puhui999:这里没读取到 -->
8786
<el-table-column align="center" label="库存" min-width="80" prop="stock" />
8887
<el-table-column align="center" label="总库存" min-width="80" prop="totalStock" />
89-
<el-table-column label="已兑换数量" min-width="100" prop="redeemedQuantity" />
88+
<el-table-column align="center" label="已兑换数量" min-width="100" prop="redeemedQuantity">
89+
<template #default="{ row }">
90+
{{ getRedeemedQuantity(row) }}
91+
</template>
92+
</el-table-column>
9093
<el-table-column
9194
:formatter="dateFormatter"
9295
align="center"
@@ -160,6 +163,7 @@ const queryParams = reactive({
160163
status: null
161164
})
162165
const queryFormRef = ref() // 搜索的表单
166+
const getRedeemedQuantity = computed(() => (row: any) => (row.totalStock || 0) - (row.stock || 0)) // 获得商品已兑换数量
163167
164168
/** 查询列表 */
165169
const getList = async () => {

0 commit comments

Comments
 (0)