Skip to content

Commit 24e69ec

Browse files
committed
chore: 添加TODO注释;以更优雅的方式跳出循环
1 parent 372e221 commit 24e69ec

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/views/mall/product/spu/form/ProductAttributes.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
class="!w-30"
3232
@blur="handleInputConfirm(index, item.id)"
3333
@keyup.enter="handleInputConfirm(index, item.id)"
34+
@change="handleInputConfirm(index, item.id)"
3435
>
3536
<el-option
3637
v-for="item2 in item.propertyOpts"
@@ -39,7 +40,6 @@
3940
:value="item2.name"
4041
/>
4142
</el-select>
42-
<!-- <el-input :id="`input${index}`" v-model="inputValue" class="!w-20" /> -->
4343
<el-button
4444
v-show="!inputVisible(index)"
4545
class="button-new-tag ml-1"
@@ -54,7 +54,6 @@
5454
</template>
5555

5656
<script lang="ts" setup>
57-
import { ElInput } from 'element-plus'
5857
import * as PropertyApi from '@/api/mall/product/property'
5958
import { PropertyAndValues } from '@/views/mall/product/spu/components'
6059
import { propTypes } from '@/utils/propTypes'

src/views/mall/product/spu/form/ProductPropertyAddForm.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,14 @@ const submitForm = async () => {
9999
values: []
100100
})
101101
// 判断最终提交的属性名称是否是选择的 自己手动输入的属性名称不执行emit
102-
attrOption.value.forEach((item) => {
103-
if (item.name === formData.value.name) {
104-
emit('success', propertyId, item.id)
102+
for (const element of attrOption.value) {
103+
if (element.name === formData.value.name) {
104+
emit('success', propertyId, element.id)
105105
message.success(t('common.createSuccess'))
106106
dialogVisible.value = false
107-
// 中断循环
108-
throw new Error()
107+
return
109108
}
110-
})
109+
}
111110
message.success(t('common.createSuccess'))
112111
dialogVisible.value = false
113112
} finally {
@@ -127,6 +126,7 @@ const resetForm = () => {
127126
const getAttrOption = async () => {
128127
formLoading.value = true
129128
try {
129+
// TODO @芋艿:需要增加一个全列表接口
130130
const data = await PropertyApi.getPropertyPage({ pageNo: 1, pageSize: 100 })
131131
attrOption.value = data.list
132132
} finally {

src/views/mall/product/spu/form/SkuForm.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ const generateSkus = (propertyList: any[]) => {
201201
const getPropertyValueList = async (id, propertyId) => {
202202
formLoading.value = true
203203
try {
204+
// TODO @芋艿:需要增加一个全列表接口
204205
const data = await PropertyApi.getPropertyValuePage({ pageNo: 1, pageSize: 100, propertyId })
205206
propertyList.value.find((item) => item.id === id).propertyOpts = data.list
206207
} finally {

0 commit comments

Comments
 (0)