feat: 包邮费用设置

This commit is contained in:
李琦
2026-08-27 09:38:11 +08:00
parent 2d8a328db2
commit 0d18089f71
3 changed files with 105 additions and 0 deletions

View File

@@ -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 */

View File

@@ -0,0 +1,85 @@
<script lang="ts" setup>
/**
* 系统配置 - 满额包邮:订单商品金额达到门槛免运费
* 数据存老库 yii_system_configconfig_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))]">
未找到包邮配置数据请先在老库执行初始化 SQLsql/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>

View File

@@ -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: '公账支付',