|
|
@@ -182,9 +182,14 @@
|
|
|
<el-radio :label="3">指定商品</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
- <el-form-item v-if="form.scopeType === 2" label="指定分类" prop="scopeIds" key="scope-category">
|
|
|
- <el-select v-model="form.scopeIds" multiple filterable placeholder="请选择分类" style="width: 100%" :disabled="scopeLocked">
|
|
|
- <el-option v-for="item in categoryOptions" :key="item.cateId" :label="item.cateName" :value="item.cateId"/>
|
|
|
+ <el-form-item v-if="form.scopeType === 2" label="商品分类" prop="scopeIds" key="scope-product-type">
|
|
|
+ <el-select v-model="form.scopeIds" multiple filterable placeholder="请选择商品分类" style="width: 100%" :disabled="scopeLocked">
|
|
|
+ <el-option
|
|
|
+ v-for="item in productTypeOptions"
|
|
|
+ :key="item.dictValue"
|
|
|
+ :label="item.dictLabel"
|
|
|
+ :value="item.dictValue"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item v-if="form.scopeType === 3" label="指定商品" prop="scopeIds" key="scope-product">
|
|
|
@@ -252,9 +257,9 @@
|
|
|
|
|
|
<div v-if="detail && detail.scopeType === 2" class="detail-block">
|
|
|
<div class="detail-block-title">指定分类</div>
|
|
|
- <el-table v-if="detail.scopeCategories && detail.scopeCategories.length" :data="detail.scopeCategories" border size="mini">
|
|
|
- <el-table-column label="分类ID" prop="cateId" width="90" align="center"/>
|
|
|
- <el-table-column label="分类名称" prop="cateName" min-width="160" align="center" show-overflow-tooltip/>
|
|
|
+ <el-table v-if="detail.scopeProductTypes && detail.scopeProductTypes.length" :data="detail.scopeProductTypes" border size="mini">
|
|
|
+ <el-table-column label="分类编码" prop="productType" width="100" align="center"/>
|
|
|
+ <el-table-column label="分类名称" prop="productTypeLabel" min-width="160" align="center" show-overflow-tooltip/>
|
|
|
</el-table>
|
|
|
<div v-else class="detail-empty">暂无分类数据</div>
|
|
|
</div>
|
|
|
@@ -287,7 +292,6 @@ import {
|
|
|
delStorePromotion, enableStorePromotion, disableStorePromotion, exportStorePromotion
|
|
|
} from '@/api/hisStore/storePromotion'
|
|
|
import { listStoreOptions } from '@/api/hisStore/store'
|
|
|
-import { getAllStoreProductCategory } from '@/api/hisStore/storeProductCategory'
|
|
|
import { listStoreProduct } from '@/api/hisStore/storeProduct'
|
|
|
|
|
|
export default {
|
|
|
@@ -299,14 +303,13 @@ export default {
|
|
|
total: 0,
|
|
|
promotionList: [],
|
|
|
storeOptions: [],
|
|
|
- categoryOptions: [],
|
|
|
+ productTypeOptions: [],
|
|
|
productOptions: [],
|
|
|
productLoading: false,
|
|
|
productSearchTimer: null,
|
|
|
productLoadedStoreId: null,
|
|
|
productRequestSeq: 0,
|
|
|
- categoryLoaded: false,
|
|
|
- categoryLoading: false,
|
|
|
+ productTypeLoaded: false,
|
|
|
dateRange: [],
|
|
|
queryParams: {
|
|
|
pageNum: 1,
|
|
|
@@ -352,6 +355,7 @@ export default {
|
|
|
created() {
|
|
|
this.getList()
|
|
|
this.loadStoreOptions()
|
|
|
+ this.loadProductTypeOptions()
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
if (this.productSearchTimer) {
|
|
|
@@ -405,24 +409,24 @@ export default {
|
|
|
this.storeOptions = res.data || []
|
|
|
})
|
|
|
},
|
|
|
- loadCategories() {
|
|
|
- if (this.categoryLoaded || this.categoryLoading) {
|
|
|
- return Promise.resolve(this.categoryOptions)
|
|
|
+ loadProductTypeOptions() {
|
|
|
+ if (this.productTypeLoaded) {
|
|
|
+ return Promise.resolve(this.productTypeOptions)
|
|
|
}
|
|
|
- this.categoryLoading = true
|
|
|
- return getAllStoreProductCategory().then(res => {
|
|
|
- this.categoryOptions = res.data || []
|
|
|
- this.categoryLoaded = true
|
|
|
- return this.categoryOptions
|
|
|
- }).finally(() => {
|
|
|
- this.categoryLoading = false
|
|
|
+ return this.getDicts('store_product_type').then(response => {
|
|
|
+ this.productTypeOptions = response.data || []
|
|
|
+ this.productTypeLoaded = true
|
|
|
+ return this.productTypeOptions
|
|
|
})
|
|
|
},
|
|
|
- ensureCategoriesLoaded() {
|
|
|
+ ensureProductTypeOptionsLoaded() {
|
|
|
if (this.form.scopeType === 2) {
|
|
|
- return this.loadCategories()
|
|
|
+ return this.loadProductTypeOptions()
|
|
|
}
|
|
|
- return Promise.resolve(this.categoryOptions)
|
|
|
+ return Promise.resolve(this.productTypeOptions)
|
|
|
+ },
|
|
|
+ normalizeScopeIds(scopeIds) {
|
|
|
+ return (scopeIds || []).map(id => String(id))
|
|
|
},
|
|
|
formatProductLabel(item) {
|
|
|
return item.productName + ' (ID:' + item.productId + ')'
|
|
|
@@ -497,13 +501,13 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- /** 切换适用类型时清空已选范围,避免分类/商品 ID 混用 */
|
|
|
+ /** 切换适用类型时清空已选范围,避免商品分类/商品 ID 混用 */
|
|
|
handleScopeTypeChange() {
|
|
|
this.form.scopeIds = []
|
|
|
this.productOptions = []
|
|
|
this.productLoadedStoreId = null
|
|
|
if (this.form.scopeType === 2) {
|
|
|
- this.ensureCategoriesLoaded()
|
|
|
+ this.ensureProductTypeOptionsLoaded()
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
if (this.$refs.form) {
|
|
|
@@ -569,7 +573,7 @@ export default {
|
|
|
endTime: data.endTime,
|
|
|
scopeType: data.scopeType,
|
|
|
tierType: data.tierType == null ? 1 : data.tierType,
|
|
|
- scopeIds: data.scopeIds || [],
|
|
|
+ scopeIds: this.normalizeScopeIds(data.scopeIds),
|
|
|
isStackable: data.isStackable,
|
|
|
isCapped: data.isCapped,
|
|
|
limitPerUser: data.limitPerUser,
|
|
|
@@ -590,7 +594,7 @@ export default {
|
|
|
this.productLoadedStoreId = data.storeId
|
|
|
}
|
|
|
if (data.scopeType === 2) {
|
|
|
- this.ensureCategoriesLoaded()
|
|
|
+ this.ensureProductTypeOptionsLoaded()
|
|
|
}
|
|
|
this.open = true
|
|
|
this.title = '编辑阶梯满减活动'
|
|
|
@@ -634,7 +638,7 @@ export default {
|
|
|
this.$refs.form.validate(valid => {
|
|
|
if (!valid) return
|
|
|
if (this.form.scopeType !== 1 && (!this.form.scopeIds || !this.form.scopeIds.length)) {
|
|
|
- this.msgWarning(this.form.scopeType === 2 ? '请选择指定分类' : '请选择指定商品')
|
|
|
+ this.msgWarning(this.form.scopeType === 2 ? '请选择商品分类' : '请选择指定商品')
|
|
|
return
|
|
|
}
|
|
|
const scopeIds = this.form.scopeType === 1
|