feat: 包邮费用设置
This commit is contained in:
@@ -32,6 +32,20 @@ export async function getSystemConfigByKeys(keys: string[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 满额包邮门槛(老库 yii_system_config config_type=2 type=2),返回 { id, name, rule, value } */
|
||||
export async function getFreeShippingConfig() {
|
||||
return requestClient.get<any>(`${prefix}free-shipping-config`);
|
||||
}
|
||||
|
||||
/** 保存满额包邮门槛,只传 value 时后端保留 name/rule 原值 */
|
||||
export async function saveFreeShippingConfig(data: {
|
||||
name?: string;
|
||||
rule?: string;
|
||||
value: number;
|
||||
}) {
|
||||
return requestClient.post<any>(`${prefix}save-free-shipping-config`, data);
|
||||
}
|
||||
|
||||
const wxEntryPrefix = 'wx-workbench-entry/';
|
||||
|
||||
/** 某角色已分配的医生端功能入口(含 is_default_fav) */
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 系统配置 - 满额包邮:订单商品金额达到门槛免运费
|
||||
* 数据存老库 yii_system_config(config_type=2, type=2),下单运费计算直接读该行,
|
||||
* 走独立接口 free-shipping-config,不与新库 xk_system_config 的 key-value 混存
|
||||
*/
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { Button, InputNumber, message } from 'ant-design-vue';
|
||||
|
||||
import { getFreeShippingConfig, saveFreeShippingConfig } from '../api';
|
||||
|
||||
defineOptions({ name: 'FreeShippingConfigPanel' });
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
/** 门槛金额(元),null 表示尚未加载成功 */
|
||||
const thresholdValue = ref<null | number>(null);
|
||||
/** 配置行是否存在(不存在时禁止保存,提示先初始化 SQL) */
|
||||
const configExists = ref(true);
|
||||
|
||||
/** 加载当前门槛金额,配置行缺失时后端会报错,这里标记后禁用保存 */
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await getFreeShippingConfig();
|
||||
thresholdValue.value = Number(data?.value ?? 0);
|
||||
configExists.value = true;
|
||||
} catch {
|
||||
// 老库无配置行(新环境未跑初始化 SQL)时走到这里
|
||||
configExists.value = false;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 保存门槛金额,name/rule 不传由后端保留库中原值 */
|
||||
async function handleSave() {
|
||||
const v = thresholdValue.value;
|
||||
if (v === null || Number.isNaN(v) || v < 0) {
|
||||
message.warning('请填写有效的包邮门槛金额');
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await saveFreeShippingConfig({ value: v });
|
||||
message.success('保存成功');
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="cfg-panel" :class="{ 'opacity-60': loading }">
|
||||
<div class="cfg-panel-body">
|
||||
<div class="mb-2 font-medium text-[hsl(var(--foreground))]">满额包邮门槛(元)</div>
|
||||
<div class="mb-3 text-sm text-[hsl(var(--muted-foreground))]">
|
||||
订单商品金额达到该门槛时免运费;未达到时按收货省份运费(「地区管理」中的快递费)计费。
|
||||
单品包邮、门店包邮、特色方包邮的优先级高于本规则;门槛为 0 表示任意金额均包邮。
|
||||
</div>
|
||||
<InputNumber
|
||||
v-model:value="thresholdValue"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="1"
|
||||
:disabled="!configExists"
|
||||
style="width: 220px"
|
||||
placeholder="请输入门槛金额"
|
||||
>
|
||||
<template #addonAfter> 元 </template>
|
||||
</InputNumber>
|
||||
<div v-if="!configExists" class="mt-3 text-sm text-[hsl(var(--warning))]">
|
||||
未找到包邮配置数据,请先在老库执行初始化 SQL(sql/20260827/01_yii_system_config_free_shipping_init.sql)后刷新
|
||||
</div>
|
||||
</div>
|
||||
<div class="cfg-panel-footer">
|
||||
<Button type="primary" :loading="saving" :disabled="!configExists" @click="handleSave">
|
||||
保存本模块配置
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -17,6 +17,7 @@ import AiModelConfigPanel from './components/ai-model-config-panel.vue';
|
||||
import DictSearchConfigPanel from './components/dict-search-config-panel.vue';
|
||||
import DispenseSignConfigPanel from './components/dispense-sign-config-panel.vue';
|
||||
import DoctorLoginConfigPanel from './components/doctor-login-config-panel.vue';
|
||||
import FreeShippingConfigPanel from './components/free-shipping-config-panel.vue';
|
||||
import HomeDisplayConfigPanel from './components/home-display-config-panel.vue';
|
||||
import InputAuditConfigPanel from './components/input-audit-config-panel.vue';
|
||||
import InvoiceNoticeConfigPanel from './components/invoice-notice-config-panel.vue';
|
||||
@@ -83,6 +84,11 @@ const menuItems: MenuItem[] = [
|
||||
component: PriceAdjustConfigPanel,
|
||||
},
|
||||
{ key: 'logistics', title: '物流展示', component: LogisticsConfigPanel },
|
||||
{
|
||||
key: 'free_shipping',
|
||||
title: '满额包邮',
|
||||
component: FreeShippingConfigPanel,
|
||||
},
|
||||
{
|
||||
key: 'public_account_pay',
|
||||
title: '公账支付',
|
||||
|
||||
Reference in New Issue
Block a user