|
9 | 9 | >
|
10 | 10 | <!-- 先选择 -->
|
11 | 11 | <template #spuId>
|
12 |
| - <el-button @click="spuSelectRef.open()">选择商品</el-button> |
| 12 | + <el-button v-if="!isFormUpdate" @click="spuSelectRef.open()">选择商品</el-button> |
13 | 13 | <SpuAndSkuList
|
14 | 14 | ref="spuAndSkuListRef"
|
15 | 15 | :rule-config="ruleConfig"
|
|
18 | 18 | >
|
19 | 19 | <el-table-column align="center" label="可兑换库存" min-width="168">
|
20 | 20 | <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 | + /> |
22 | 27 | </template>
|
23 | 28 | </el-table-column>
|
24 | 29 | <el-table-column align="center" label="可兑换次数" min-width="168">
|
@@ -77,6 +82,7 @@ const dialogTitle = ref('') // 弹窗的标题
|
77 | 82 | const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
78 | 83 | const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
79 | 84 | const formRef = ref() // 表单 Ref
|
| 85 | +const isFormUpdate = ref(false) // 是否更新表单 |
80 | 86 |
|
81 | 87 | // ================= 商品选择相关 =================
|
82 | 88 |
|
@@ -163,6 +169,7 @@ const open = async (type: string, id?: number) => {
|
163 | 169 | formLoading.value = true
|
164 | 170 | try {
|
165 | 171 | const data = (await PointActivityApi.getPointActivity(id)) as PointActivityVO
|
| 172 | + isFormUpdate.value = true |
166 | 173 | await getSpuDetails(
|
167 | 174 | data.spuId!,
|
168 | 175 | data.products?.map((sku) => sku.skuId),
|
@@ -213,6 +220,7 @@ const submitForm = async () => {
|
213 | 220 | const resetForm = async () => {
|
214 | 221 | spuList.value = []
|
215 | 222 | spuPropertyList.value = []
|
| 223 | + isFormUpdate.value = false |
216 | 224 | await nextTick()
|
217 | 225 | formRef.value.getElFormRef().resetFields()
|
218 | 226 | }
|
|
0 commit comments