|
|
@@ -53,6 +53,21 @@
|
|
|
</el-row>
|
|
|
</template>
|
|
|
|
|
|
+ <!-- 关联成长档案 -->
|
|
|
+ <el-divider content-position="left">关联成长档案</el-divider>
|
|
|
+ <el-form-item label="关联成长档案">
|
|
|
+ <el-switch
|
|
|
+ v-model="growthArchive.enabled"
|
|
|
+ active-text="开启"
|
|
|
+ inactive-text="关闭"
|
|
|
+ />
|
|
|
+ <span style="margin-left: 10px; font-size: 12px; color: #999;">在成长档案上传页推荐该商品</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序值">
|
|
|
+ <el-input-number v-model="growthArchive.sortOrder" :min="0" :precision="0" style="width: 200px;" controls />
|
|
|
+ <span style="margin-left: 10px; font-size: 12px; color: #999;">越小越靠前</span>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
<el-form-item label="商品简介" prop="intro">
|
|
|
<el-input v-model="form.intro" type="textarea" :rows="2" placeholder="简短描述" maxlength="200" />
|
|
|
</el-form-item>
|
|
|
@@ -216,7 +231,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getProduct, createProduct, updateProduct, listAllSupplySystems, getPredefinedPurchaseFields, getProductPurchaseFields, saveProductPurchaseFields, getMySupplySystem, saveProductGiftRule, listProductGiftRules, listMembershipLevels } from '@/api/admin'
|
|
|
+import { getProduct, createProduct, updateProduct, listAllSupplySystems, getPredefinedPurchaseFields, getProductPurchaseFields, saveProductPurchaseFields, getMySupplySystem, saveProductGiftRule, listProductGiftRules, listMembershipLevels, getGrowthArchiveProduct, saveGrowthArchiveProduct } from '@/api/admin'
|
|
|
import { saveDimensionWeights, getDimensionWeights } from '@/api/dimension-weight'
|
|
|
import DimensionWeightPicker from '@/components/DimensionWeightPicker.vue'
|
|
|
import ProductSkuEditor from './components/ProductSkuEditor.vue'
|
|
|
@@ -251,6 +266,10 @@ export default {
|
|
|
validityDays: 365,
|
|
|
guideScope: 'all'
|
|
|
},
|
|
|
+ growthArchive: {
|
|
|
+ enabled: false,
|
|
|
+ sortOrder: 0
|
|
|
+ },
|
|
|
imageList: [],
|
|
|
supplySystems: [],
|
|
|
giftRuleEnabled: false,
|
|
|
@@ -402,8 +421,10 @@ export default {
|
|
|
this.loadDimensionWeights(p.id)
|
|
|
// Load purchase fields config
|
|
|
this.loadPurchaseFields(p.id)
|
|
|
- // 赠送会员规则回显
|
|
|
+// 赠送会员规则回显
|
|
|
this.loadGiftRule(p.id)
|
|
|
+ // Load growth archive config
|
|
|
+ this.loadGrowthArchive(p.id)
|
|
|
// v-model 已绑定 form.description,editor 内容自动更新
|
|
|
}
|
|
|
} catch (e) {
|
|
|
@@ -457,7 +478,7 @@ export default {
|
|
|
console.warn('加载购买字段配置失败', e)
|
|
|
}
|
|
|
},
|
|
|
- async loadGiftRule(productId) {
|
|
|
+async loadGiftRule(productId) {
|
|
|
try {
|
|
|
const lvRes = await listMembershipLevels()
|
|
|
if (lvRes.code === 200 && Array.isArray(lvRes.data)) {
|
|
|
@@ -475,6 +496,19 @@ export default {
|
|
|
console.warn('加载赠送会员规则失败', e)
|
|
|
}
|
|
|
},
|
|
|
+ async loadGrowthArchive(productId) {
|
|
|
+ try {
|
|
|
+ const res = await getGrowthArchiveProduct(productId)
|
|
|
+ if (res.code === 200 && res.data) {
|
|
|
+ this.growthArchive = {
|
|
|
+ enabled: res.data.status === 1,
|
|
|
+ sortOrder: res.data.sortOrder || 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('加载成长档案关联配置失败', e)
|
|
|
+ }
|
|
|
+ },
|
|
|
handlePurchaseFieldsToggle(val) {
|
|
|
if (!val) {
|
|
|
this.predefinedFields.forEach(pf => { pf.selected = false })
|
|
|
@@ -590,7 +624,7 @@ export default {
|
|
|
console.warn('保存购买字段配置失败', e)
|
|
|
}
|
|
|
}
|
|
|
- // 保存赠送会员规则
|
|
|
+// 保存赠送会员规则
|
|
|
if (productId) {
|
|
|
try {
|
|
|
await saveProductGiftRule(productId, this.giftRuleEnabled ? 1 : 0,
|
|
|
@@ -599,6 +633,19 @@ export default {
|
|
|
console.warn('保存赠送会员规则失败', e)
|
|
|
}
|
|
|
}
|
|
|
+ // Save growth archive config (only for existing products)
|
|
|
+ if (this.form.id) {
|
|
|
+ try {
|
|
|
+ await saveGrowthArchiveProduct({
|
|
|
+ productId: this.form.id,
|
|
|
+ status: this.growthArchive.enabled ? 1 : 0,
|
|
|
+ sortOrder: this.growthArchive.sortOrder
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ this.$message.error('保存成长档案关联失败')
|
|
|
+ console.warn('保存成长档案关联失败', e)
|
|
|
+ }
|
|
|
+ }
|
|
|
this.$message.success(this.isEdit ? '保存成功' : '创建成功')
|
|
|
this.$router.push('/product-manage')
|
|
|
} else {
|