sql数据流,amdin业务逻辑接入
This commit is contained in:
@@ -180,11 +180,75 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 其他步骤占位 -->
|
||||
<view v-if="activeStep > 2" class="step-content">
|
||||
<view class="placeholder-step">
|
||||
<text>步骤 {{ steps[activeStep] }} 逻辑接入中...</text>
|
||||
<text class="sub-tip">该模块涉及物流模板、会员等级定价等,将在后续阶段补齐</text>
|
||||
<!-- Step 3: 物流设置 -->
|
||||
<view v-if="activeStep === 3" class="step-content">
|
||||
<view class="form-item">
|
||||
<view class="label"><text class="required">*</text><text>运费模板:</text></view>
|
||||
<view class="input-wrap">
|
||||
<picker :value="shippingIndex" :range="shippingLabels" @change="onShippingChange">
|
||||
<view class="tag-selector">
|
||||
<view v-if="form.shipping_template_id" class="tag-item">
|
||||
<text>{{ shippingLabels[shippingIndex] }}</text>
|
||||
</view>
|
||||
<text class="add-link">{{ form.shipping_template_id ? '点击切换模板' : '选择运费模板' }}</text>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Step 4: 会员价/佣金 -->
|
||||
<view v-if="activeStep === 4" class="step-content">
|
||||
<view class="form-item">
|
||||
<view class="label"><text>会员价设置:</text></view>
|
||||
<view class="input-wrap">
|
||||
<button class="btn-white small-btn" @click="goMemberPrice">前往配置会员价</button>
|
||||
<text class="tip" style="margin-top: 8px; display: block;">点击上方按钮,可以为不同规格的商品设置各级会员的专属价格。</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Step 5: 营销设置 -->
|
||||
<view v-if="activeStep === 5" class="step-content">
|
||||
<view class="form-item">
|
||||
<view class="label"><text>赠送积分:</text></view>
|
||||
<view class="input-wrap">
|
||||
<view class="input-box small">
|
||||
<input class="real-input" type="number" v-model="form.give_integral" placeholder="0" />
|
||||
</view>
|
||||
<text class="tip">用户购买该商品后赠送的积分数量</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Step 6: 其他设置 -->
|
||||
<view v-if="activeStep === 6" class="step-content">
|
||||
<view class="form-item">
|
||||
<view class="label"><text>排序权重:</text></view>
|
||||
<view class="input-wrap">
|
||||
<view class="input-box small">
|
||||
<input class="real-input" type="number" v-model="form.sort_order" placeholder="0" />
|
||||
</view>
|
||||
<text class="tip">数字越大,商品在列表中越靠前</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<view class="label"><text>虚拟销量:</text></view>
|
||||
<view class="input-wrap">
|
||||
<view class="input-box small">
|
||||
<input class="real-input" type="number" v-model="form.virtual_sales" placeholder="0" />
|
||||
</view>
|
||||
<text class="tip">显示的销量 = 真实销量 + 虚拟销量</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<view class="label"><text>库存预警:</text></view>
|
||||
<view class="input-wrap">
|
||||
<view class="input-box small">
|
||||
<input class="real-input" type="number" v-model="form.stock_warning" placeholder="10" />
|
||||
</view>
|
||||
<text class="tip">当商品总库存低于此数值时,管理后台将进行提醒</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -229,8 +293,10 @@ import { openRoute } from '@/layouts/admin/store/adminNavStore.uts'
|
||||
import {
|
||||
fetchAdminProductDetail,
|
||||
saveAdminProduct,
|
||||
fetchShippingTemplates,
|
||||
AdminProduct,
|
||||
AdminProductSku
|
||||
AdminProductSku,
|
||||
ShippingTemplate
|
||||
} from '@/services/admin/productService.uts'
|
||||
import { fetchAdminCategoryList, AdminCategory } from '@/services/admin/productCategoryService.uts'
|
||||
import { fetchLabels, ProductLabel } from '@/services/admin/productLabelService.uts'
|
||||
@@ -240,6 +306,7 @@ import { fetchSpecTemplates, fetchParamTemplates, ProductSpecTemplate, ProductPa
|
||||
const activeStep = ref(0)
|
||||
const steps = ['基础信息', '规格库存', '商品详情', '物流设置', '会员价/佣金', '营销设置', '其他设置']
|
||||
const isLoading = ref(false)
|
||||
const isSaving = ref(false)
|
||||
const productId = ref<string | null>(null)
|
||||
|
||||
// 响应式表单数据
|
||||
@@ -256,7 +323,13 @@ const form = reactive({
|
||||
price: 0,
|
||||
stock: 0,
|
||||
product_code: '',
|
||||
attributes: {} as any
|
||||
attributes: {} as any,
|
||||
// 扩展字段
|
||||
shipping_template_id: null as string | null,
|
||||
give_integral: 0,
|
||||
stock_warning: 10,
|
||||
virtual_sales: 0,
|
||||
sort_order: 0
|
||||
})
|
||||
|
||||
const skus = ref<AdminProductSku[]>([])
|
||||
@@ -266,10 +339,12 @@ const categories = ref<AdminCategory[]>([])
|
||||
const labelList = ref<ProductLabel[]>([])
|
||||
const specTemplates = ref<ProductSpecTemplate[]>([])
|
||||
const paramTemplates = ref<ProductParamTemplate[]>([])
|
||||
const shippingTemplates = ref<ShippingTemplate[]>([])
|
||||
|
||||
// --- UI 控制状态 ---
|
||||
const showLabelModal = ref(false)
|
||||
const categoryIndex = ref(0)
|
||||
const shippingIndex = ref(-1)
|
||||
|
||||
// 计算属性:分类名称列表供 picker 使用
|
||||
const categoryLabels = computed((): string[] => {
|
||||
@@ -287,6 +362,11 @@ const specTemplateLabels = computed((): string[] => {
|
||||
return specTemplates.value.map(t => t.name)
|
||||
})
|
||||
|
||||
// 计算属性:运费模板列表
|
||||
const shippingLabels = computed((): string[] => {
|
||||
return shippingTemplates.value.map(t => t.name)
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 1. 获取商品 ID
|
||||
const pages = getCurrentPages()
|
||||
@@ -305,16 +385,18 @@ onMounted(() => {
|
||||
|
||||
async function initBaseData() {
|
||||
try {
|
||||
const [cateRes, labelRes, specRes, paramRes] = await Promise.all([
|
||||
const [cateRes, labelRes, specRes, paramRes, shipRes] = await Promise.all([
|
||||
fetchAdminCategoryList({ isActive: true }),
|
||||
fetchLabels(),
|
||||
fetchSpecTemplates(),
|
||||
fetchParamTemplates()
|
||||
fetchParamTemplates(),
|
||||
fetchShippingTemplates()
|
||||
])
|
||||
categories.value = cateRes
|
||||
labelList.value = labelRes
|
||||
specTemplates.value = specRes
|
||||
paramTemplates.value = paramRes
|
||||
shippingTemplates.value = shipRes
|
||||
} catch (e) {
|
||||
console.error('加载基础资料失败:', e)
|
||||
}
|
||||
@@ -340,6 +422,18 @@ async function loadProductDetail(id: string) {
|
||||
form.product_code = p.product_code ?? ''
|
||||
form.attributes = p.attributes ?? {}
|
||||
|
||||
// 扩展字段
|
||||
form.shipping_template_id = p.shipping_template_id
|
||||
form.give_integral = p.give_integral
|
||||
form.stock_warning = p.stock_warning
|
||||
form.virtual_sales = p.virtual_sales
|
||||
form.sort_order = p.sort_order
|
||||
|
||||
// 匹配运费模板索引
|
||||
if (p.shipping_template_id != null) {
|
||||
shippingIndex.value = shippingTemplates.value.findIndex(t => t.id === p.shipping_template_id)
|
||||
}
|
||||
|
||||
skus.value = res.skus
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -367,10 +461,25 @@ function prevStep() {
|
||||
}
|
||||
}
|
||||
|
||||
function onShippingChange(e : any) {
|
||||
const index = parseInt(String(e.detail.value))
|
||||
shippingIndex.value = index
|
||||
form.shipping_template_id = shippingTemplates.value[index].id
|
||||
}
|
||||
|
||||
function goMemberPrice() {
|
||||
if (productId.value == null) {
|
||||
uni.showToast({ title: '请先保存商品基础信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
openRoute('product_member_price', { id: productId.value })
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
isLoading.value = true
|
||||
if (isSaving.value) return
|
||||
isSaving.value = true
|
||||
try {
|
||||
const productData: Partial<AdminProduct> = {
|
||||
const productData : Partial<AdminProduct> = {
|
||||
id: productId.value ?? undefined,
|
||||
...form
|
||||
}
|
||||
@@ -384,7 +493,7 @@ async function handleSave() {
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '系统异常', icon: 'none' })
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
isSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user