提交 5a253d46 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 更新运费模板和售后政策的处理逻辑,支持多选和新选项

上级 904bb383
...@@ -6,7 +6,7 @@ const form = inject('form') ...@@ -6,7 +6,7 @@ const form = inject('form')
<template> <template>
<div> <div>
<el-form-item label="运费模板" prop="info.shipping_template" :rules="[{ required: true, message: '请选择' }]"> <el-form-item label="运费模板" prop="info.shipping_template" :rules="[{ required: true, message: '请选择' }]">
<el-select v-model="form.info.shipping_template" style="width: 300px; max-width: 100%"> <el-select v-model="form.info.shipping_template" style="width: 300px; max-width: 100%" multiple>
<el-option v-for="item in shippingTemplate" :key="item.value" v-bind="item"></el-option> <el-option v-for="item in shippingTemplate" :key="item.value" v-bind="item"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
......
...@@ -32,7 +32,7 @@ const form = reactive({ ...@@ -32,7 +32,7 @@ const form = reactive({
delivery_time: '1', // 发货时间 delivery_time: '1', // 发货时间
reference_price: '', // 参考价格 reference_price: '', // 参考价格
order_stock_count: '1', order_stock_count: '1',
shipping_template: '', // 运费模板 shipping_template: [], // 运费模板
after_sales_policy: [], // 售后政策 after_sales_policy: [], // 售后政策
specs: [], // 规格列表 specs: [], // 规格列表
sku: [], // SKU列表(通过规格笛卡尔积生成) sku: [], // SKU列表(通过规格笛卡尔积生成)
...@@ -44,6 +44,7 @@ async function fetchInfo() { ...@@ -44,6 +44,7 @@ async function fetchInfo() {
const res = await getProduct({ id: route.query.id }) const res = await getProduct({ id: route.query.id })
const detail = res.data.detail const detail = res.data.detail
const attrs = JSON.parse(detail.live_commodity_attrs) const attrs = JSON.parse(detail.live_commodity_attrs)
const info = JSON.parse(detail.info)
Object.assign(form, detail, { Object.assign(form, detail, {
live_commodity_attrs: { live_commodity_attrs: {
importance_attrs: Array.isArray(attrs.importance_attrs) importance_attrs: Array.isArray(attrs.importance_attrs)
...@@ -55,7 +56,19 @@ async function fetchInfo() { ...@@ -55,7 +56,19 @@ async function fetchInfo() {
}, },
picture_addreses: JSON.parse(detail.picture_addreses), picture_addreses: JSON.parse(detail.picture_addreses),
picture_34_addreses: JSON.parse(detail.picture_34_addreses), picture_34_addreses: JSON.parse(detail.picture_34_addreses),
info: JSON.parse(detail.info), info: {
...info,
shipping_template: Array.isArray(info.shipping_template)
? info.shipping_template
: info.shipping_template
? [info.shipping_template]
: [],
after_sales_policy: Array.isArray(info.after_sales_policy)
? info.after_sales_policy
: info.after_sales_policy
? [info.after_sales_policy]
: [],
},
}) })
} }
watchEffect(() => { watchEffect(() => {
......
...@@ -3,7 +3,10 @@ export interface Dictionary { ...@@ -3,7 +3,10 @@ export interface Dictionary {
value: string | number value: string | number
} }
export function getNameByValue(value: string | number, list: Dictionary[]) { export function getNameByValue(value: string | number | Array<string | number>, list: Dictionary[]) {
if (Array.isArray(value)) {
return value.map((item) => getNameByValue(item, list)).filter(Boolean).join('、')
}
return list.find((item) => item.value == value)?.label || value return list.find((item) => item.value == value)?.label || value
} }
...@@ -245,6 +248,7 @@ export const shippingTemplate = [ ...@@ -245,6 +248,7 @@ export const shippingTemplate = [
{ label: '自选快递运费模板', value: '11' }, { label: '自选快递运费模板', value: '11' },
{ label: '满99元包邮', value: '12' }, { label: '满99元包邮', value: '12' },
{ label: '全国包邮(偏远地区除外)', value: '13' }, { label: '全国包邮(偏远地区除外)', value: '13' },
{ label: '未满99元统一运费12元', value: '14' },
] ]
// 售后政策 // 售后政策
...@@ -258,4 +262,7 @@ export const afterSalesPolicy = [ ...@@ -258,4 +262,7 @@ export const afterSalesPolicy = [
{ label: '闪电退货', value: '7' }, { label: '闪电退货', value: '7' },
{ label: '售后补寄', value: '8' }, { label: '售后补寄', value: '8' },
{ label: '坏果包赔', value: '9' }, { label: '坏果包赔', value: '9' },
{ label: '坏果按颗包赔', value: '10' },
{ label: '腐烂全额退款', value: '11' },
{ label: '破损拍照理赔', value: '12' },
] ]
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论