feat: 公账周期账单与合并明细优化,退款弹窗与开方成功页按钮换行
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
周期账单生成与变动记录抽屉;查看合并按账单日 Tabs;退款原因必填;开方成功页操作按钮自动换行。
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 带快捷预设的搜索时间范围选择器
|
||||
* - 上方 RangePicker 手选,下方快捷 link:今天 / 本周 / 本月 / 上一个月 / 下一个月
|
||||
* - 支持 valueFormat='YYYY-MM-DD'(VbenForm)或 Dayjs 二元组(对账页)
|
||||
*/
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
import { Button, DatePicker } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
formatRangeByValueFormat,
|
||||
normalizeRangeToYmd,
|
||||
resolveSearchTimePreset,
|
||||
type SearchTimePreset,
|
||||
} from '#/utils/search-time-range';
|
||||
|
||||
defineOptions({
|
||||
name: 'SearchTimeRangePicker',
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value?: [string, string] | [Dayjs, Dayjs] | null;
|
||||
valueFormat?: 'YYYY-MM-DD';
|
||||
disabled?: boolean;
|
||||
/** 是否展示翻月按钮 */
|
||||
showMonthNav?: boolean;
|
||||
/** 是否展示「本月」快捷(队列近7天页可关) */
|
||||
showThisMonth?: boolean;
|
||||
format?: string;
|
||||
class?: string;
|
||||
}>(),
|
||||
{
|
||||
value: null,
|
||||
disabled: false,
|
||||
showMonthNav: true,
|
||||
showThisMonth: true,
|
||||
format: 'YYYY-MM-DD',
|
||||
class: 'w-full',
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:value': [[string, string] | [Dayjs, Dayjs] | null];
|
||||
change: [[string, string] | [Dayjs, Dayjs] | null];
|
||||
}>();
|
||||
|
||||
const mValue = useVModel(props, 'value', emit, { passive: true });
|
||||
|
||||
/** RangePicker 内部统一用 Dayjs */
|
||||
const innerRange = computed<[Dayjs, Dayjs] | null>({
|
||||
get() {
|
||||
if (!mValue.value || !Array.isArray(mValue.value) || mValue.value.length < 2) {
|
||||
return null;
|
||||
}
|
||||
const normalized = normalizeRangeToYmd(mValue.value);
|
||||
if (!normalized) return null;
|
||||
return [dayjs(normalized[0]), dayjs(normalized[1])];
|
||||
},
|
||||
set(next) {
|
||||
if (!next || !next[0] || !next[1]) {
|
||||
mValue.value = null;
|
||||
emit('change', null);
|
||||
return;
|
||||
}
|
||||
const formatted = formatRangeByValueFormat(
|
||||
[next[0].startOf('day'), next[1].startOf('day')],
|
||||
props.valueFormat,
|
||||
);
|
||||
mValue.value = formatted as [string, string] | [Dayjs, Dayjs];
|
||||
emit('change', formatted as [string, string] | [Dayjs, Dayjs]);
|
||||
},
|
||||
});
|
||||
|
||||
type QuickItem = {
|
||||
key: SearchTimePreset | 'thisMonth';
|
||||
label: string;
|
||||
};
|
||||
|
||||
const quickItems = computed<QuickItem[]>(() => {
|
||||
const items: QuickItem[] = [
|
||||
{ key: 'today', label: '今天' },
|
||||
{ key: 'thisWeek', label: '本周' },
|
||||
];
|
||||
if (props.showThisMonth) {
|
||||
items.push({ key: 'thisMonth', label: '本月' });
|
||||
}
|
||||
if (props.showMonthNav) {
|
||||
items.push(
|
||||
{ key: 'prevMonth', label: '上一个月' },
|
||||
{ key: 'nextMonth', label: '下一个月' },
|
||||
);
|
||||
}
|
||||
return items;
|
||||
});
|
||||
|
||||
/** 点击快捷预设 */
|
||||
function applyPreset(preset: SearchTimePreset) {
|
||||
const range = resolveSearchTimePreset(preset, mValue.value);
|
||||
innerRange.value = range;
|
||||
}
|
||||
|
||||
/** 手选 RangePicker */
|
||||
function onPickerChange(
|
||||
dates: [Dayjs, Dayjs] | [string, string] | null,
|
||||
) {
|
||||
if (!dates || !Array.isArray(dates) || dates.length < 2) {
|
||||
innerRange.value = null;
|
||||
return;
|
||||
}
|
||||
const a = dayjs(dates[0]);
|
||||
const b = dayjs(dates[1]);
|
||||
if (!a.isValid() || !b.isValid()) {
|
||||
innerRange.value = null;
|
||||
return;
|
||||
}
|
||||
innerRange.value = [a, b];
|
||||
}
|
||||
|
||||
/** 无值时展示默认本月至今(仅 UI 占位,不写回 v-model 直到用户操作) */
|
||||
const pickerValue = computed<[Dayjs, Dayjs] | undefined>({
|
||||
get() {
|
||||
return innerRange.value ?? undefined;
|
||||
},
|
||||
set(val) {
|
||||
if (!val) {
|
||||
innerRange.value = null;
|
||||
return;
|
||||
}
|
||||
innerRange.value = val;
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="search-time-range-picker" :class="props.class">
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="pickerValue"
|
||||
v-bind="$attrs"
|
||||
:disabled="disabled"
|
||||
:format="format"
|
||||
:value-format="valueFormat"
|
||||
class="search-time-range-picker__picker w-full"
|
||||
@change="onPickerChange"
|
||||
/>
|
||||
<div class="search-time-range-picker__quick">
|
||||
<Button
|
||||
v-for="item in quickItems"
|
||||
:key="item.key"
|
||||
size="small"
|
||||
type="link"
|
||||
:disabled="disabled"
|
||||
class="search-time-range-picker__quick-btn"
|
||||
@click="applyPreset(item.key as SearchTimePreset)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.search-time-range-picker {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.search-time-range-picker__quick {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0 4px;
|
||||
margin-top: 2px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.search-time-range-picker__quick-btn {
|
||||
height: auto;
|
||||
padding: 0 4px;
|
||||
font-size: 12px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
color: hsl(var(--primary));
|
||||
}
|
||||
}
|
||||
|
||||
.search-time-range-picker__picker {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -5,5 +5,6 @@ export type CustomComponentType =
|
||||
| 'ApiSelect'
|
||||
| 'ApiTreeSelect'
|
||||
| 'IconPicker'
|
||||
| 'SearchTimeRangePicker'
|
||||
| 'StoreMultiSearch'
|
||||
| 'WarehouseAdminDrugSearch';
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 锁店页只读:日账单 + 下属商品订单
|
||||
* 从合计应付款点开,不提供任何写操作
|
||||
* 锁店 / 查看合并:日账单 + 下属商品订单(只读)
|
||||
* 按账单日用 Tabs 切换,避免多日堆叠难扫
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { Button, Spin } from 'ant-design-vue';
|
||||
import { Button, Spin, Tabs, Tag } from 'ant-design-vue';
|
||||
|
||||
import DailyChangeLogDrawer from '#/views/finance/public-account-pay/components/daily-change-log-drawer.vue';
|
||||
import { getPublicAccountDailyLockOrders } from '#/views/finance/public-account-pay/api';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -28,40 +29,52 @@ const showBackBtn = computed(() => props.showBack !== false);
|
||||
const loading = ref(false);
|
||||
const loadError = ref('');
|
||||
const bundle = ref<Record<string, any> | null>(null);
|
||||
/** 展开的日账单 id */
|
||||
const openDayIds = ref<Record<number, boolean>>({});
|
||||
/** 当前选中的日账单 id(Tabs) */
|
||||
const activeDayId = ref<string>('');
|
||||
const changeLogOpen = ref(false);
|
||||
|
||||
const days = computed(() => {
|
||||
const list = bundle.value?.items;
|
||||
return Array.isArray(list) ? list : [];
|
||||
});
|
||||
|
||||
const summaryTxt = computed(() => {
|
||||
const activeDay = computed(() => {
|
||||
const id = Number(activeDayId.value || 0);
|
||||
if (id < 1) {
|
||||
return days.value[0] || null;
|
||||
}
|
||||
return days.value.find((d) => Number(d.id) === id) || days.value[0] || null;
|
||||
});
|
||||
|
||||
const summary = computed(() => {
|
||||
const b = bundle.value;
|
||||
if (!b) {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
const range = b.bill_date_range_txt || '';
|
||||
const billCount = Number(b.bill_count || 0);
|
||||
const orderCount = Number(b.order_count || 0);
|
||||
const amount = b.platform_amount_total || '0.00';
|
||||
return `${range} · ${billCount} 张日账单 · ${orderCount} 笔商品订单 · 合计 ¥${amount}`;
|
||||
return {
|
||||
range: b.bill_date_range_txt || '',
|
||||
billCount: Number(b.bill_count || 0),
|
||||
orderCount: Number(b.order_count || 0),
|
||||
amount: b.platform_amount_total || '0.00',
|
||||
periodEnd: b.period_end_at_txt || '',
|
||||
};
|
||||
});
|
||||
|
||||
function dayDateTxt(day: Record<string, any>) {
|
||||
return day.bill_date_txt || day.bill_date || '—';
|
||||
return day.bill_date_txt || String(day.bill_date || '—');
|
||||
}
|
||||
|
||||
function isDayOpen(id: number) {
|
||||
return !!openDayIds.value[id];
|
||||
/** Tab 标题:月-日,短一点好扫 */
|
||||
function dayTabLabel(day: Record<string, any>) {
|
||||
const txt = dayDateTxt(day);
|
||||
if (/^\d{4}-\d{2}-\d{2}$/.test(txt)) {
|
||||
return txt.slice(5);
|
||||
}
|
||||
return txt;
|
||||
}
|
||||
|
||||
/** 默认全部展开,方便一眼看完 */
|
||||
function toggleDay(id: number) {
|
||||
openDayIds.value = {
|
||||
...openDayIds.value,
|
||||
[id]: !openDayIds.value[id],
|
||||
};
|
||||
function dayOrderCount(day: Record<string, any>) {
|
||||
return (day.items || []).length;
|
||||
}
|
||||
|
||||
async function loadOrders() {
|
||||
@@ -74,17 +87,12 @@ async function loadOrders() {
|
||||
overdue_daily_ids: (props.overdueDailyIds || []).join(',') || undefined,
|
||||
});
|
||||
bundle.value = data && typeof data === 'object' ? data : null;
|
||||
const next: Record<number, boolean> = {};
|
||||
for (const day of days.value) {
|
||||
const id = Number(day.id || 0);
|
||||
if (id > 0) {
|
||||
next[id] = true;
|
||||
}
|
||||
}
|
||||
openDayIds.value = next;
|
||||
const first = days.value[0];
|
||||
activeDayId.value = first ? String(Number(first.id || 0)) : '';
|
||||
} catch (err: any) {
|
||||
loadError.value = err?.message || '加载失败';
|
||||
bundle.value = null;
|
||||
activeDayId.value = '';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -109,53 +117,100 @@ watch(
|
||||
<template>
|
||||
<div class="pap-orders" :class="{ 'is-embedded': embedded }">
|
||||
<div class="pap-orders-head">
|
||||
<div>
|
||||
<div class="pap-orders-head-main">
|
||||
<div class="pap-orders-badge">只读明细</div>
|
||||
<h3 class="pap-orders-title">日账单与商品订单</h3>
|
||||
<p v-if="summaryTxt" class="pap-orders-summary">{{ summaryTxt }}</p>
|
||||
<h3 class="pap-orders-title">合并账单明细</h3>
|
||||
<div v-if="summary" class="pap-orders-stats">
|
||||
<div class="pap-stat">
|
||||
<span class="pap-stat-label">账单区间</span>
|
||||
<strong class="pap-stat-value">{{ summary.range || '—' }}</strong>
|
||||
</div>
|
||||
<div class="pap-stat">
|
||||
<span class="pap-stat-label">日账单</span>
|
||||
<strong class="pap-stat-value">{{ summary.billCount }} 张</strong>
|
||||
</div>
|
||||
<div class="pap-stat">
|
||||
<span class="pap-stat-label">商品订单</span>
|
||||
<strong class="pap-stat-value">{{ summary.orderCount }} 笔</strong>
|
||||
</div>
|
||||
<div class="pap-stat pap-stat-amount">
|
||||
<span class="pap-stat-label">合计应付款</span>
|
||||
<strong class="pap-stat-value">¥{{ summary.amount }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="summary?.periodEnd" class="pap-orders-deadline">
|
||||
周期截止 {{ summary.periodEnd }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="pap-orders-actions">
|
||||
<Button
|
||||
v-if="showBackBtn"
|
||||
size="middle"
|
||||
@click="emit('back')"
|
||||
>
|
||||
返回
|
||||
</Button>
|
||||
<Button
|
||||
v-if="Number(mergeId || 0) > 0 || Number(dailyId || 0) > 0"
|
||||
size="middle"
|
||||
@click="changeLogOpen = true"
|
||||
>
|
||||
变动记录
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
v-if="showBackBtn"
|
||||
size="large"
|
||||
class="pap-orders-back"
|
||||
@click="emit('back')"
|
||||
>
|
||||
返回
|
||||
</Button>
|
||||
</div>
|
||||
<DailyChangeLogDrawer
|
||||
v-model:open="changeLogOpen"
|
||||
:daily-bill-id="Number(dailyId || 0)"
|
||||
:merge-id="Number(mergeId || 0)"
|
||||
/>
|
||||
<Spin :spinning="loading">
|
||||
<p v-if="loadError" class="pap-orders-empty">{{ loadError }}</p>
|
||||
<p v-else-if="!loading && !days.length" class="pap-orders-empty">
|
||||
暂无日账单明细
|
||||
</p>
|
||||
<div v-else class="pap-orders-list">
|
||||
<div v-for="day in days" :key="day.id" class="pap-day">
|
||||
<button
|
||||
type="button"
|
||||
class="pap-day-head"
|
||||
@click="toggleDay(Number(day.id))"
|
||||
<div v-else class="pap-orders-body">
|
||||
<Tabs
|
||||
v-model:active-key="activeDayId"
|
||||
class="pap-day-tabs"
|
||||
type="card"
|
||||
size="small"
|
||||
>
|
||||
<Tabs.TabPane
|
||||
v-for="day in days"
|
||||
:key="String(Number(day.id || 0))"
|
||||
>
|
||||
<div class="pap-day-meta">
|
||||
<strong>日账单 {{ dayDateTxt(day) }}</strong>
|
||||
<span>
|
||||
¥{{ day.platform_amount || '0.00' }} ·
|
||||
{{ (day.items || []).length }} 笔商品订单 ·
|
||||
{{ day.status_txt || '' }}
|
||||
<template #tab>
|
||||
<span class="pap-day-tab">
|
||||
<span class="pap-day-tab-date">{{ dayTabLabel(day) }}</span>
|
||||
<span class="pap-day-tab-amt">¥{{ day.platform_amount || '0.00' }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<div v-if="activeDay" class="pap-day-panel">
|
||||
<div class="pap-day-panel-head">
|
||||
<div class="pap-day-panel-title">
|
||||
<strong>{{ dayDateTxt(activeDay) }}</strong>
|
||||
<Tag>{{ activeDay.status_txt || '—' }}</Tag>
|
||||
</div>
|
||||
<div class="pap-day-panel-meta">
|
||||
<span>{{ dayOrderCount(activeDay) }} 笔订单</span>
|
||||
<span>应付款 ¥{{ activeDay.platform_amount || '0.00' }}</span>
|
||||
<span v-if="activeDay.order_amount">
|
||||
订单合计 ¥{{ activeDay.order_amount }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="pap-day-toggle">
|
||||
{{ isDayOpen(Number(day.id)) ? '收起' : '展开' }}
|
||||
</span>
|
||||
</button>
|
||||
<div v-if="isDayOpen(Number(day.id))" class="pap-day-body">
|
||||
</div>
|
||||
<div
|
||||
v-if="!(activeDay.items || []).length"
|
||||
class="pap-order-empty"
|
||||
>
|
||||
该日暂无商品订单
|
||||
</div>
|
||||
<div v-else class="pap-order-list">
|
||||
<div
|
||||
v-if="!(day.items || []).length"
|
||||
class="pap-order-empty"
|
||||
>
|
||||
该日暂无商品订单
|
||||
</div>
|
||||
<div
|
||||
v-for="order in day.items || []"
|
||||
v-for="order in activeDay.items || []"
|
||||
:key="order.id"
|
||||
class="pap-order-row"
|
||||
>
|
||||
@@ -211,7 +266,7 @@ watch(
|
||||
|
||||
<style scoped>
|
||||
.pap-orders {
|
||||
width: min(640px, 100%);
|
||||
width: min(720px, 100%);
|
||||
max-width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
@@ -223,7 +278,11 @@ watch(
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.pap-orders-head-main {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.pap-orders-badge {
|
||||
display: inline-block;
|
||||
@@ -231,25 +290,57 @@ watch(
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: hsl(var(--pap-accent));
|
||||
border: 1px solid hsl(var(--pap-accent) / 40%);
|
||||
color: hsl(var(--pap-accent, var(--primary)));
|
||||
border: 1px solid hsl(var(--pap-accent, var(--primary)) / 40%);
|
||||
border-radius: 999px;
|
||||
background: hsl(var(--pap-accent) / 12%);
|
||||
background: hsl(var(--pap-accent, var(--primary)) / 12%);
|
||||
}
|
||||
.pap-orders-title {
|
||||
margin: 0 0 6px;
|
||||
font-size: var(--pap-fs-title, 22px);
|
||||
margin: 0 0 10px;
|
||||
font-size: var(--pap-fs-title, 20px);
|
||||
font-weight: 700;
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
.pap-orders-summary {
|
||||
margin: 0;
|
||||
font-size: var(--pap-fs-flow, 13px);
|
||||
line-height: 1.5;
|
||||
.pap-orders-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
.pap-stat {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid hsl(var(--border));
|
||||
border-radius: 8px;
|
||||
background: hsl(var(--muted) / 0.22);
|
||||
}
|
||||
.pap-stat-amount {
|
||||
border-color: hsl(var(--pap-accent, var(--primary)) / 30%);
|
||||
box-shadow: 0 0 6px hsl(var(--pap-accent, var(--primary)) / 14%);
|
||||
}
|
||||
.pap-stat-label {
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
font-size: 12px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.pap-orders-back {
|
||||
.pap-stat-value {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: hsl(var(--foreground));
|
||||
word-break: break-all;
|
||||
}
|
||||
.pap-stat-amount .pap-stat-value {
|
||||
color: hsl(var(--pap-accent, var(--primary)));
|
||||
}
|
||||
.pap-orders-deadline {
|
||||
margin: 8px 0 0;
|
||||
font-size: 12px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.pap-orders-actions {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.pap-orders-empty {
|
||||
margin: 24px 0;
|
||||
@@ -257,67 +348,86 @@ watch(
|
||||
color: hsl(var(--muted-foreground));
|
||||
text-align: center;
|
||||
}
|
||||
.pap-orders-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
.pap-day {
|
||||
border: 1px solid hsl(var(--pap-accent) / 28%);
|
||||
border-radius: 12px;
|
||||
.pap-orders-body {
|
||||
border: 1px solid hsl(var(--border));
|
||||
border-radius: 10px;
|
||||
background: hsl(var(--card, var(--background)));
|
||||
box-shadow: 0 0 6px hsl(var(--pap-accent) / 14%);
|
||||
overflow: hidden;
|
||||
}
|
||||
.pap-day-head {
|
||||
.pap-day-tabs {
|
||||
padding: 8px 8px 0;
|
||||
background: hsl(var(--muted) / 0.18);
|
||||
}
|
||||
.pap-day-tabs :deep(.ant-tabs-nav) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.pap-day-tabs :deep(.ant-tabs-tab) {
|
||||
padding: 6px 10px !important;
|
||||
}
|
||||
.pap-day-tab {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 2px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.pap-day-tab-date {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
.pap-day-tab-amt {
|
||||
font-size: 11px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.pap-day-panel {
|
||||
padding: 12px 14px 14px;
|
||||
}
|
||||
.pap-day-panel-head {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid hsl(var(--border));
|
||||
}
|
||||
.pap-day-meta {
|
||||
.pap-day-panel-title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.pap-day-meta strong {
|
||||
.pap-day-panel-title strong {
|
||||
font-size: 15px;
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
.pap-day-meta span {
|
||||
.pap-day-panel-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
font-size: 12px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.pap-day-toggle {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
color: hsl(var(--pap-accent));
|
||||
}
|
||||
.pap-day-body {
|
||||
padding: 0 12px 12px;
|
||||
border-top: 1px solid hsl(var(--border));
|
||||
}
|
||||
.pap-order-empty {
|
||||
padding: 12px 4px;
|
||||
padding: 16px 4px;
|
||||
font-size: 13px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
text-align: center;
|
||||
}
|
||||
.pap-order-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.pap-order-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px 8px;
|
||||
margin-top: 8px;
|
||||
padding: 12px;
|
||||
border: 1px solid hsl(var(--border));
|
||||
border-radius: 8px;
|
||||
background: hsl(var(--muted) / 0.2);
|
||||
background: hsl(var(--muted) / 0.18);
|
||||
}
|
||||
.pap-order-top {
|
||||
display: flex;
|
||||
@@ -334,10 +444,10 @@ watch(
|
||||
.pap-order-tag {
|
||||
padding: 1px 8px;
|
||||
font-size: 11px;
|
||||
color: hsl(var(--pap-accent));
|
||||
border: 1px solid hsl(var(--pap-accent) / 30%);
|
||||
color: hsl(var(--pap-accent, var(--primary)));
|
||||
border: 1px solid hsl(var(--pap-accent, var(--primary)) / 30%);
|
||||
border-radius: 999px;
|
||||
background: hsl(var(--pap-accent) / 10%);
|
||||
background: hsl(var(--pap-accent, var(--primary)) / 10%);
|
||||
}
|
||||
.pap-order-main strong {
|
||||
font-size: 13px;
|
||||
@@ -351,7 +461,7 @@ watch(
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.pap-order-side strong {
|
||||
color: hsl(var(--pap-accent));
|
||||
color: hsl(var(--pap-accent, var(--primary)));
|
||||
}
|
||||
.pap-order-products {
|
||||
display: flex;
|
||||
@@ -423,16 +533,16 @@ watch(
|
||||
font-size: 12px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
@media (max-width: 560px) {
|
||||
@media (max-width: 720px) {
|
||||
.pap-orders-stats {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
.pap-orders-head {
|
||||
flex-direction: column;
|
||||
}
|
||||
.pap-orders-back {
|
||||
.pap-orders-actions {
|
||||
width: 100%;
|
||||
}
|
||||
.pap-orders-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
.pap-product:not(.is-chinese) {
|
||||
width: calc(50% - 3px);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { computed, ref } from 'vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { useUserStore } from '@vben/stores';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
import {
|
||||
Avatar,
|
||||
Button,
|
||||
@@ -37,22 +37,24 @@ import {
|
||||
import { getSalespersonList } from '#/views/system/store/api/salesperson';
|
||||
import { resolveAvatarUrl } from '#/views/system/store-input/utils/inputUser';
|
||||
import AddDoctorFromStoreModal from '#/views/system/store/components/AddDoctorFromStoreModal.vue';
|
||||
import { canAddStoreDoctor } from '#/views/system/admin/_shared/platform-admin-role';
|
||||
import { canAddStoreDoctor, isPlatformSuperAdmin } from '#/views/system/admin/_shared/platform-admin-role';
|
||||
import StoreFinancePanel from '#/components/store-card/StoreFinancePanel.vue';
|
||||
|
||||
const RangePicker = DatePicker.RangePicker;
|
||||
|
||||
const userStore = useUserStore();
|
||||
// 是否允许「添加医生」:超管/管理员/省经理/市经理/业务员
|
||||
const canAddDoctor = computed(() => canAddStoreDoctor(userStore.userInfo));
|
||||
// 是否可查看门店资金账户:仅超管/系统管理员
|
||||
const canViewStoreFinance = computed(() => isPlatformSuperAdmin(userStore.userInfo));
|
||||
|
||||
const financePanelRef = ref<InstanceType<typeof StoreFinancePanel> | null>(null);
|
||||
|
||||
const storeId = ref(0);
|
||||
const loading = ref(false);
|
||||
const activeTab = ref('basic');
|
||||
const cardData = ref<any>(null);
|
||||
const searchTime = ref<[Dayjs, Dayjs]>([
|
||||
dayjs().startOf('month'),
|
||||
dayjs(),
|
||||
]);
|
||||
const searchTime = ref<[Dayjs, Dayjs]>(monthToTodayRangeDayjs());
|
||||
|
||||
const bankLoading = ref(false);
|
||||
const bankDetail = ref<any>(null);
|
||||
@@ -113,14 +115,18 @@ const [Modal, modalApi] = useVbenModal({
|
||||
modalApi.close();
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) return;
|
||||
if (!isOpen) {
|
||||
financePanelRef.value?.reset?.();
|
||||
return;
|
||||
}
|
||||
const data = modalApi.getData<Record<string, any>>() || {};
|
||||
storeId.value = Number(data.storeId || data.id || 0);
|
||||
activeTab.value = 'basic';
|
||||
searchTime.value = [dayjs().startOf('month'), dayjs()];
|
||||
searchTime.value = monthToTodayRangeDayjs();
|
||||
bankDetail.value = null;
|
||||
drugList.value = [];
|
||||
promoterList.value = [];
|
||||
financePanelRef.value?.reset?.();
|
||||
if (storeId.value) {
|
||||
loadCard();
|
||||
}
|
||||
@@ -427,6 +433,14 @@ function clinicTypeText(v: number) {
|
||||
</div>
|
||||
</Tabs.TabPane>
|
||||
|
||||
<Tabs.TabPane v-if="canViewStoreFinance" key="finance" tab="资金账户">
|
||||
<StoreFinancePanel
|
||||
v-if="storeId && activeTab === 'finance'"
|
||||
ref="financePanelRef"
|
||||
:store-id="storeId"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
|
||||
<Tabs.TabPane v-if="isClinic" key="doctors" tab="诊所医生团队">
|
||||
<div class="pl-4">
|
||||
<div v-if="canAddDoctor" class="mb-3">
|
||||
|
||||
394
apps/web-antd/src/components/store-card/StoreFinancePanel.vue
Normal file
394
apps/web-antd/src/components/store-card/StoreFinancePanel.vue
Normal file
@@ -0,0 +1,394 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 门店详情 - 资金账户面板(余额 + 资金流水 + 账户变动)
|
||||
* 仅超管/系统管理员在 StoreCardModal 中可见,数据按门店 ID 查询
|
||||
*/
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { DatePicker, Empty, Segmented, Spin, Table, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
import {
|
||||
getStoreAccountChangeLogListApi,
|
||||
getStoreBalanceApi,
|
||||
getStoreFundWaterListApi,
|
||||
} from '#/views/system/store/api';
|
||||
|
||||
const props = defineProps<{
|
||||
storeId: number;
|
||||
}>();
|
||||
|
||||
const RangePicker = DatePicker.RangePicker;
|
||||
|
||||
const balanceLoading = ref(false);
|
||||
const balance = ref<Record<string, any> | null>(null);
|
||||
|
||||
const fundWaterLoading = ref(false);
|
||||
const fundWaterList = ref<any[]>([]);
|
||||
const fundWaterPage = ref(1);
|
||||
const fundWaterPageSize = ref(10);
|
||||
const fundWaterTotal = ref(0);
|
||||
|
||||
const changeLogLoading = ref(false);
|
||||
const changeLogList = ref<any[]>([]);
|
||||
const changeLogPage = ref(1);
|
||||
const changeLogPageSize = ref(10);
|
||||
const changeLogTotal = ref(0);
|
||||
|
||||
const fundWaterTime = ref<[Dayjs, Dayjs]>(monthToTodayRangeDayjs());
|
||||
const changeLogTime = ref<[Dayjs, Dayjs]>(monthToTodayRangeDayjs());
|
||||
|
||||
/** 流水列表切换:资金流水 / 账户变动(用 Segmented 避免窄容器下 Tab 折叠成 ...) */
|
||||
const activeListTab = ref<'fundWater' | 'changeLog'>('fundWater');
|
||||
const changeLogLoaded = ref(false);
|
||||
const listTabOptions = [
|
||||
{ label: '资金流水', value: 'fundWater' },
|
||||
{ label: '账户变动', value: 'changeLog' },
|
||||
];
|
||||
|
||||
/** 余额概览卡片配置 */
|
||||
const balanceCards = [
|
||||
{ key: 'balance', label: '可提现余额' },
|
||||
{ key: 'total', label: '累计收益' },
|
||||
{ key: 'pending_earnings', label: '待结算' },
|
||||
{ key: 'withdrawn', label: '已提现' },
|
||||
{ key: 'withdrawn_frozen', label: '审核中' },
|
||||
{ key: 'public_account_amount', label: '公账累计' },
|
||||
{ key: 'tcm_balance', label: '中药可提' },
|
||||
{ key: 'western_balance', label: '西药可提' },
|
||||
{ key: 'other_balance', label: '其他可提' },
|
||||
];
|
||||
|
||||
const fundWaterColumns = [
|
||||
{ title: '金额', dataIndex: 'price', key: 'price', width: 110 },
|
||||
{ title: '流水类型', dataIndex: 'type', key: 'type', width: 110 },
|
||||
{ title: '订单类型', dataIndex: 'order_type', key: 'order_type', width: 110 },
|
||||
{ title: '订单号', dataIndex: 'order_no', key: 'order_no', ellipsis: true },
|
||||
{ title: '医生', dataIndex: 'doctor_name', key: 'doctor_name', width: 100 },
|
||||
{ title: '时间', dataIndex: 'created_at', key: 'created_at', width: 170 },
|
||||
];
|
||||
|
||||
const changeLogColumns = [
|
||||
{ title: '时间', dataIndex: 'created_at', key: 'created_at', width: 170 },
|
||||
{ title: '来源', dataIndex: 'source_type_txt', key: 'source_type_txt', width: 100 },
|
||||
{ title: '字段', dataIndex: 'field_name_txt', key: 'field_name_txt', width: 140 },
|
||||
{ title: '变动前', dataIndex: 'before_amount', key: 'before_amount', width: 100 },
|
||||
{ title: '变动后', dataIndex: 'after_amount', key: 'after_amount', width: 100 },
|
||||
{ title: '变动值', dataIndex: 'change_amount', key: 'change_amount', width: 100 },
|
||||
{ title: '订单号', dataIndex: 'order_no', key: 'order_no', ellipsis: true },
|
||||
{ title: '来源表', dataIndex: 'source_table_txt', key: 'source_table_txt', width: 110 },
|
||||
{ title: '备注', dataIndex: 'remark', key: 'remark', ellipsis: true },
|
||||
];
|
||||
|
||||
/** 时间范围转接口参数 */
|
||||
function timeParam(range: [Dayjs, Dayjs]): [string, string] {
|
||||
return [
|
||||
range[0].format('YYYY-MM-DD 00:00:00'),
|
||||
range[1].format('YYYY-MM-DD 23:59:59'),
|
||||
];
|
||||
}
|
||||
|
||||
function formatMoney(val: unknown) {
|
||||
return `¥${Number(val || 0).toFixed(2)}`;
|
||||
}
|
||||
|
||||
/** 拉取门店余额概览 */
|
||||
async function loadBalance() {
|
||||
if (!props.storeId) return;
|
||||
balanceLoading.value = true;
|
||||
try {
|
||||
balance.value = await getStoreBalanceApi({ id: props.storeId });
|
||||
} catch (e: any) {
|
||||
balance.value = null;
|
||||
message.error(e?.message || '加载余额失败');
|
||||
} finally {
|
||||
balanceLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 拉取资金流水 */
|
||||
async function loadFundWater(page = fundWaterPage.value) {
|
||||
if (!props.storeId) return;
|
||||
fundWaterLoading.value = true;
|
||||
fundWaterPage.value = page;
|
||||
try {
|
||||
const res = await getStoreFundWaterListApi({
|
||||
id: props.storeId,
|
||||
page,
|
||||
pageSize: fundWaterPageSize.value,
|
||||
search_time: timeParam(fundWaterTime.value),
|
||||
});
|
||||
fundWaterList.value = (res?.items || []).map((item: any) => ({
|
||||
...item,
|
||||
doctor_name: item?.doctor_info?.name || '-',
|
||||
}));
|
||||
fundWaterTotal.value = Number(res?.total || 0);
|
||||
} catch (e: any) {
|
||||
fundWaterList.value = [];
|
||||
fundWaterTotal.value = 0;
|
||||
message.error(e?.message || '加载资金流水失败');
|
||||
} finally {
|
||||
fundWaterLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 拉取账户变动 */
|
||||
async function loadChangeLog(page = changeLogPage.value) {
|
||||
if (!props.storeId) return;
|
||||
changeLogLoading.value = true;
|
||||
changeLogPage.value = page;
|
||||
try {
|
||||
const res = await getStoreAccountChangeLogListApi({
|
||||
id: props.storeId,
|
||||
page,
|
||||
pageSize: changeLogPageSize.value,
|
||||
search_time: timeParam(changeLogTime.value),
|
||||
});
|
||||
changeLogList.value = res?.items || [];
|
||||
changeLogTotal.value = Number(res?.total || 0);
|
||||
} catch (e: any) {
|
||||
changeLogList.value = [];
|
||||
changeLogTotal.value = 0;
|
||||
message.error(e?.message || '加载账户变动失败');
|
||||
} finally {
|
||||
changeLogLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置分页并加载余额与当前列表 Tab 数据 */
|
||||
function loadAll() {
|
||||
fundWaterPage.value = 1;
|
||||
changeLogPage.value = 1;
|
||||
changeLogLoaded.value = false;
|
||||
activeListTab.value = 'fundWater';
|
||||
loadBalance();
|
||||
loadFundWater(1);
|
||||
}
|
||||
|
||||
/** 列表切换:懒加载账户变动 */
|
||||
function onListTabChange(value: string | number) {
|
||||
activeListTab.value = value === 'changeLog' ? 'changeLog' : 'fundWater';
|
||||
if (activeListTab.value === 'changeLog' && !changeLogLoaded.value) {
|
||||
loadChangeLog(1);
|
||||
changeLogLoaded.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置面板状态(弹窗关闭时由父组件调用) */
|
||||
function reset() {
|
||||
balance.value = null;
|
||||
fundWaterList.value = [];
|
||||
changeLogList.value = [];
|
||||
fundWaterTotal.value = 0;
|
||||
changeLogTotal.value = 0;
|
||||
fundWaterPage.value = 1;
|
||||
changeLogPage.value = 1;
|
||||
fundWaterTime.value = monthToTodayRangeDayjs();
|
||||
changeLogTime.value = monthToTodayRangeDayjs();
|
||||
activeListTab.value = 'fundWater';
|
||||
changeLogLoaded.value = false;
|
||||
}
|
||||
|
||||
defineExpose({ loadAll, reset });
|
||||
|
||||
watch(
|
||||
() => props.storeId,
|
||||
(id) => {
|
||||
if (id) loadAll();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function fundWaterTypeTag(type: string) {
|
||||
if (type === 'refund') return { color: 'purple', text: '出账' };
|
||||
if (type === 'enter') return { color: 'green', text: '入账' };
|
||||
if (type === 'withdraw') return { color: 'orange', text: '提现' };
|
||||
if (type === 'charge') return { color: 'red', text: '代付手续费' };
|
||||
return { color: 'default', text: type || '-' };
|
||||
}
|
||||
|
||||
function orderTypeTag(orderType: number) {
|
||||
if (orderType === 1) return { color: 'purple', text: '产品订单' };
|
||||
if (orderType === 2) return { color: 'green', text: '挂号订单' };
|
||||
if (orderType === 3) return { color: 'blue', text: '问诊订单' };
|
||||
return { color: 'default', text: '-' };
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="store-finance-panel pl-4">
|
||||
<section class="finance-section">
|
||||
<div class="section-title">余额概览</div>
|
||||
<Spin :spinning="balanceLoading">
|
||||
<div v-if="balance" class="balance-grid">
|
||||
<div
|
||||
v-for="card in balanceCards"
|
||||
:key="card.key"
|
||||
class="balance-card"
|
||||
>
|
||||
<span class="balance-card__label">{{ card.label }}</span>
|
||||
<span class="balance-card__value">{{ formatMoney(balance[card.key]) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<Empty v-else-if="!balanceLoading" description="暂无余额数据" />
|
||||
</Spin>
|
||||
</section>
|
||||
|
||||
<section class="finance-section finance-section--list">
|
||||
<Segmented
|
||||
v-model:value="activeListTab"
|
||||
block
|
||||
class="finance-list-segment"
|
||||
:options="listTabOptions"
|
||||
@change="onListTabChange"
|
||||
/>
|
||||
|
||||
<div v-show="activeListTab === 'fundWater'">
|
||||
<div class="list-toolbar">
|
||||
<RangePicker
|
||||
v-model:value="fundWaterTime"
|
||||
format="YYYY-MM-DD"
|
||||
@change="loadFundWater(1)"
|
||||
/>
|
||||
</div>
|
||||
<Table
|
||||
:columns="fundWaterColumns"
|
||||
:data-source="fundWaterList"
|
||||
:loading="fundWaterLoading"
|
||||
:pagination="{
|
||||
current: fundWaterPage,
|
||||
pageSize: fundWaterPageSize,
|
||||
total: fundWaterTotal,
|
||||
showSizeChanger: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`,
|
||||
}"
|
||||
row-key="id"
|
||||
size="small"
|
||||
:scroll="{ x: 800, y: 320 }"
|
||||
@change="(pag: any) => {
|
||||
fundWaterPageSize = pag.pageSize || fundWaterPageSize;
|
||||
loadFundWater(pag.current || 1);
|
||||
}"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'price'">
|
||||
{{ formatMoney(record.price) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'type'">
|
||||
<Tag :color="fundWaterTypeTag(record.type).color">
|
||||
{{ fundWaterTypeTag(record.type).text }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'order_type'">
|
||||
<Tag :color="orderTypeTag(Number(record.order_type)).color">
|
||||
{{ orderTypeTag(Number(record.order_type)).text }}
|
||||
</Tag>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
<div v-show="activeListTab === 'changeLog'">
|
||||
<div class="list-toolbar">
|
||||
<RangePicker
|
||||
v-model:value="changeLogTime"
|
||||
format="YYYY-MM-DD"
|
||||
@change="loadChangeLog(1)"
|
||||
/>
|
||||
</div>
|
||||
<Table
|
||||
:columns="changeLogColumns"
|
||||
:data-source="changeLogList"
|
||||
:loading="changeLogLoading"
|
||||
:pagination="{
|
||||
current: changeLogPage,
|
||||
pageSize: changeLogPageSize,
|
||||
total: changeLogTotal,
|
||||
showSizeChanger: true,
|
||||
showTotal: (total: number) => `共 ${total} 条`,
|
||||
}"
|
||||
row-key="id"
|
||||
size="small"
|
||||
:scroll="{ x: 960, y: 320 }"
|
||||
@change="(pag: any) => {
|
||||
changeLogPageSize = pag.pageSize || changeLogPageSize;
|
||||
loadChangeLog(pag.current || 1);
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.store-finance-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.finance-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
|
||||
.finance-section--list {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.finance-list-segment {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.list-toolbar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.balance-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.balance-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid hsl(var(--primary) / 30%);
|
||||
border-radius: 10px;
|
||||
background: hsl(var(--card, var(--background)));
|
||||
box-shadow: 0 0 6px hsl(var(--primary) / 18%);
|
||||
}
|
||||
|
||||
.balance-card__label {
|
||||
font-size: 12px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
|
||||
.balance-card__value {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
</style>
|
||||
55
apps/web-antd/src/components/store-card/StoreNameLink.vue
Normal file
55
apps/web-antd/src/components/store-card/StoreNameLink.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 表格内门店名称链接:支持自动换行,点击打开门店详情
|
||||
* 用于处方/挂号/订单等列宽较窄的场景,避免长诊所名撑出列外
|
||||
*/
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
defineProps<{
|
||||
storeId?: number;
|
||||
name?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
click: [storeId: number];
|
||||
}>();
|
||||
|
||||
/** 有门店 ID 时触发打开详情 */
|
||||
function handleClick(storeId?: number) {
|
||||
if (!storeId) return;
|
||||
emit('click', storeId);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button
|
||||
v-if="storeId"
|
||||
type="link"
|
||||
size="small"
|
||||
class="store-name-link"
|
||||
@click="handleClick(storeId)"
|
||||
>
|
||||
{{ name || '—' }}
|
||||
</Button>
|
||||
<span v-else class="store-name-link store-name-link--plain">{{ name || '—' }}</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.store-name-link {
|
||||
height: auto !important;
|
||||
max-width: 100%;
|
||||
padding: 0 !important;
|
||||
white-space: normal !important;
|
||||
word-break: break-all;
|
||||
text-align: left;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.store-name-link--plain {
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
white-space: normal;
|
||||
word-break: break-all;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
@@ -2,33 +2,24 @@
|
||||
/**
|
||||
* 卡片视图专用操作栏(与列表交互解耦)
|
||||
*
|
||||
* 列表单元格里 TableAction 平铺全部按钮没问题,但卡片 footer 空间小,
|
||||
* 按钮超过 2 个会触发 TableAction 的两列 grid 换行堆叠,显得杂乱。
|
||||
* 这里改成 C 端惯例:只露出前 maxVisible 个主操作(默认 1 个,通常是「详情」),
|
||||
* 其余操作全部合并进「···」下拉菜单。
|
||||
*
|
||||
* 权限(auth)/ 显隐(ifShow)/ 二次确认(popConfirm)逻辑不重写:
|
||||
* - 挑主操作前先按与 TableAction 相同的规则过滤,保证露出的一定是可见按钮;
|
||||
* - 渲染仍复用 TableAction(flex=false 关闭多列 grid),菜单项行为完全一致。
|
||||
* 列表单元格里 TableAction 平铺全部按钮没问题,但卡片 footer 空间小。
|
||||
* 只露出前 maxVisible 个主操作(默认「详情」),其余收进「更多」气泡卡片(Popover)。
|
||||
*/
|
||||
import type { ActionItem } from './types';
|
||||
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
import { isBoolean, isFunction } from '@vben/utils';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { Button, Popconfirm, Popover, Space } from 'ant-design-vue';
|
||||
|
||||
import { Icon } from '#/components/icon';
|
||||
|
||||
import TableAction from './table-action.vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
actions?: ActionItem[];
|
||||
dropDownActions?: ActionItem[];
|
||||
/** 露出的主操作数量,其余进「···」菜单 */
|
||||
maxVisible?: number;
|
||||
}>(),
|
||||
{
|
||||
@@ -39,6 +30,7 @@ const props = withDefaults(
|
||||
);
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
const moreOpen = ref(false);
|
||||
|
||||
/** 与 TableAction 同规则判断单个操作是否可见(auth + ifShow) */
|
||||
function isActionVisible(action: ActionItem): boolean {
|
||||
@@ -51,38 +43,190 @@ function isActionVisible(action: ActionItem): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 过滤后的可见操作:前 maxVisible 个露出,其余与原下拉操作合并进「···」 */
|
||||
function mapAction(action: ActionItem) {
|
||||
const { popConfirm } = action;
|
||||
return {
|
||||
...action,
|
||||
...popConfirm,
|
||||
onConfirm: popConfirm?.confirm,
|
||||
onCancel: popConfirm?.cancel,
|
||||
enable: !!popConfirm,
|
||||
};
|
||||
}
|
||||
|
||||
/** 过滤后的可见操作:前 maxVisible 个露出,其余合并进「更多」 */
|
||||
const splitActions = computed(() => {
|
||||
const visible = (props.actions || []).filter((action) =>
|
||||
isActionVisible(action),
|
||||
);
|
||||
const rest = [
|
||||
...visible.slice(props.maxVisible),
|
||||
...(props.dropDownActions || []).filter((action) => isActionVisible(action)),
|
||||
].map(mapAction);
|
||||
return {
|
||||
primary: visible.slice(0, props.maxVisible),
|
||||
// 下拉里的项 TableAction 会再过滤一遍 auth/ifShow,这里直接透传原始项即可
|
||||
rest: [...visible.slice(props.maxVisible), ...(props.dropDownActions || [])],
|
||||
primary: visible.slice(0, props.maxVisible).map(mapAction),
|
||||
rest,
|
||||
};
|
||||
});
|
||||
|
||||
function getButtonProps(action: ActionItem) {
|
||||
const res = {
|
||||
type: action.type || 'link',
|
||||
size: action.size || 'small',
|
||||
...action,
|
||||
};
|
||||
delete (res as any).icon;
|
||||
delete (res as any).popConfirm;
|
||||
delete (res as any).onClick;
|
||||
return res;
|
||||
}
|
||||
|
||||
function runAction(action: ReturnType<typeof mapAction>) {
|
||||
if (action.disabled) return;
|
||||
if (!action.enable && action.onClick) {
|
||||
action.onClick();
|
||||
moreOpen.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getPopConfirmProps(attrs: Record<string, any>) {
|
||||
const originAttrs: any = { ...attrs };
|
||||
delete originAttrs.icon;
|
||||
if (attrs.confirm && isFunction(attrs.confirm)) {
|
||||
originAttrs.onConfirm = attrs.confirm;
|
||||
delete originAttrs.confirm;
|
||||
}
|
||||
if (attrs.cancel && isFunction(attrs.cancel)) {
|
||||
originAttrs.onCancel = attrs.cancel;
|
||||
delete originAttrs.cancel;
|
||||
}
|
||||
return originAttrs;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableAction
|
||||
:actions="splitActions.primary"
|
||||
:drop-down-actions="splitActions.rest"
|
||||
:flex="false"
|
||||
>
|
||||
<!-- 默认的「···」图标点击区太小,换成 link 文字「更多」,与主操作按钮同视觉 -->
|
||||
<template #more>
|
||||
<Button size="small" type="link" class="card-actions__more">
|
||||
更多
|
||||
<Icon icon="ant-design:down-outlined" class="card-actions__more-icon" />
|
||||
</Button>
|
||||
</template>
|
||||
</TableAction>
|
||||
<div class="card-actions m-table-action">
|
||||
<Space :size="0">
|
||||
<template v-for="(action, index) in splitActions.primary" :key="'p-' + index">
|
||||
<Popconfirm
|
||||
v-if="action.enable"
|
||||
v-bind="getPopConfirmProps(action)"
|
||||
@confirm="() => { action.onConfirm?.(); moreOpen = false; }"
|
||||
>
|
||||
<Button v-bind="getButtonProps(action)">
|
||||
<template v-if="action.icon" #icon>
|
||||
<Icon :icon="action.icon" />
|
||||
</template>
|
||||
{{ action.label }}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
<Button
|
||||
v-else
|
||||
v-bind="getButtonProps(action)"
|
||||
@click="runAction(action)"
|
||||
>
|
||||
<template v-if="action.icon" #icon>
|
||||
<Icon :icon="action.icon" />
|
||||
</template>
|
||||
{{ action.label }}
|
||||
</Button>
|
||||
</template>
|
||||
<Popover
|
||||
v-if="splitActions.rest.length > 0"
|
||||
v-model:open="moreOpen"
|
||||
trigger="click"
|
||||
placement="topRight"
|
||||
overlay-class-name="card-actions-popover"
|
||||
>
|
||||
<Button size="small" type="link" class="card-actions__more">
|
||||
更多
|
||||
<Icon icon="ant-design:down-outlined" class="card-actions__more-icon" />
|
||||
</Button>
|
||||
<template #content>
|
||||
<div class="card-actions-popover__panel">
|
||||
<template v-for="(action, index) in splitActions.rest" :key="'m-' + index">
|
||||
<Popconfirm
|
||||
v-if="action.enable"
|
||||
v-bind="getPopConfirmProps(action)"
|
||||
@confirm="() => { action.onConfirm?.(); moreOpen = false; }"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="card-actions-popover__item"
|
||||
:class="{ 'is-disabled': action.disabled === true }"
|
||||
:disabled="action.disabled === true"
|
||||
>
|
||||
<Icon v-if="action.icon" :icon="action.icon" class="card-actions-popover__icon" />
|
||||
<span>{{ action.label }}</span>
|
||||
</button>
|
||||
</Popconfirm>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="card-actions-popover__item"
|
||||
:class="{ 'is-disabled': action.disabled === true }"
|
||||
:disabled="action.disabled === true"
|
||||
@click="runAction(action)"
|
||||
>
|
||||
<Icon v-if="action.icon" :icon="action.icon" class="card-actions-popover__icon" />
|
||||
<span>{{ action.label }}</span>
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</Popover>
|
||||
</Space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 箭头比文字略小一号;左间距由 TableAction 全局的 span+iconify 规则统一控制 */
|
||||
.card-actions__more-icon {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
:global(.card-actions-popover .ant-popover-inner) {
|
||||
padding: 6px;
|
||||
background: hsl(var(--card, var(--background)));
|
||||
border: 1px solid hsl(var(--border));
|
||||
box-shadow: 0 4px 16px hsl(var(--foreground) / 8%);
|
||||
}
|
||||
|
||||
.card-actions-popover__panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
.card-actions-popover__item {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
font-size: 13px;
|
||||
color: hsl(var(--foreground));
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
transition: background 0.15s ease;
|
||||
|
||||
&:hover:not(.is-disabled):not(:disabled) {
|
||||
background: hsl(var(--primary) / 10%);
|
||||
color: hsl(var(--primary));
|
||||
}
|
||||
|
||||
&.is-disabled,
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.45;
|
||||
}
|
||||
}
|
||||
|
||||
.card-actions-popover__icon {
|
||||
flex-shrink: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
|
||||
119
apps/web-antd/src/composables/use-fresh-search-time.ts
Normal file
119
apps/web-antd/src/composables/use-fresh-search-time.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
import { onActivated, onMounted, ref } from 'vue';
|
||||
|
||||
import { isSameRange } from '#/utils/search-time-range';
|
||||
|
||||
type FormApiLike = {
|
||||
getValues: () => Promise<Record<string, any>>;
|
||||
setValues: (values: Record<string, any>) => Promise<void>;
|
||||
reset?: () => Promise<void>;
|
||||
};
|
||||
|
||||
export type UseFreshSearchTimeOptions = {
|
||||
formApi: FormApiLike;
|
||||
searchValues?: Ref<Record<string, any>>;
|
||||
fieldName?: string;
|
||||
/** 返回最新默认区间(字符串或 Dayjs 均可) */
|
||||
getDefaultRange: () => unknown;
|
||||
/** 写入表单并刷新列表/卡片 */
|
||||
onRefresh?: (range: unknown) => void | Promise<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* 搜索时间「本月至今」跨天自动滚到今天
|
||||
* - 未手动改时间:onMounted / onActivated 刷新默认区间并触发 onRefresh
|
||||
* - 用户手选或点快捷预设后:标记 touched,回页不覆盖
|
||||
* - resetSearchTime:清 touched + 写最新默认 + onRefresh
|
||||
*/
|
||||
export function useFreshSearchTime(options: UseFreshSearchTimeOptions) {
|
||||
const {
|
||||
formApi,
|
||||
searchValues,
|
||||
fieldName = 'search_time',
|
||||
getDefaultRange,
|
||||
onRefresh,
|
||||
} = options;
|
||||
|
||||
const searchTimeTouched = ref(false);
|
||||
|
||||
async function applyFreshDefaultRange() {
|
||||
const range = getDefaultRange();
|
||||
await formApi.setValues({ [fieldName]: range });
|
||||
if (searchValues) {
|
||||
searchValues.value = {
|
||||
...searchValues.value,
|
||||
[fieldName]: range,
|
||||
};
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
async function refreshIfUntouched() {
|
||||
if (searchTimeTouched.value) return;
|
||||
const range = getDefaultRange();
|
||||
if (range == null) return;
|
||||
const applied = await applyFreshDefaultRange();
|
||||
await onRefresh?.(applied);
|
||||
}
|
||||
|
||||
function markSearchTimeTouched() {
|
||||
searchTimeTouched.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听表单字段变化:与默认区间不同则视为用户改过
|
||||
*/
|
||||
async function syncTouchedFromForm() {
|
||||
try {
|
||||
const values = await formApi.getValues();
|
||||
const current = values?.[fieldName];
|
||||
const defaults = getDefaultRange();
|
||||
if (current == null || current === '') {
|
||||
return;
|
||||
}
|
||||
if (!isSameRange(current, defaults)) {
|
||||
searchTimeTouched.value = true;
|
||||
}
|
||||
} catch {
|
||||
// 表单未就绪时忽略
|
||||
}
|
||||
}
|
||||
|
||||
async function resetSearchTime() {
|
||||
searchTimeTouched.value = false;
|
||||
if (formApi.reset) {
|
||||
await formApi.reset();
|
||||
}
|
||||
const range = getDefaultRange();
|
||||
if (range != null) {
|
||||
await applyFreshDefaultRange();
|
||||
} else if (searchValues) {
|
||||
try {
|
||||
const values = await formApi.getValues();
|
||||
searchValues.value = { ...(values || {}) };
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
await onRefresh?.(range);
|
||||
return range;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void refreshIfUntouched();
|
||||
});
|
||||
|
||||
onActivated(() => {
|
||||
void refreshIfUntouched();
|
||||
});
|
||||
|
||||
return {
|
||||
searchTimeTouched,
|
||||
applyFreshDefaultRange,
|
||||
refreshIfUntouched,
|
||||
markSearchTimeTouched,
|
||||
syncTouchedFromForm,
|
||||
resetSearchTime,
|
||||
};
|
||||
}
|
||||
169
apps/web-antd/src/utils/search-time-range.ts
Normal file
169
apps/web-antd/src/utils/search-time-range.ts
Normal file
@@ -0,0 +1,169 @@
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export type SearchTimePreset =
|
||||
| 'today'
|
||||
| 'thisWeek'
|
||||
| 'thisMonth'
|
||||
| 'prevMonth'
|
||||
| 'nextMonth';
|
||||
|
||||
const YMD = 'YYYY-MM-DD';
|
||||
|
||||
/** 今天日期(Dayjs) */
|
||||
export function todayDayjs(): Dayjs {
|
||||
return dayjs().startOf('day');
|
||||
}
|
||||
|
||||
/** 本周一(国内习惯:周一为周起点) */
|
||||
export function startOfWeekMonday(base: Dayjs = todayDayjs()): Dayjs {
|
||||
const d = base.startOf('day');
|
||||
const day = d.day();
|
||||
const diff = day === 0 ? 6 : day - 1;
|
||||
return d.subtract(diff, 'day');
|
||||
}
|
||||
|
||||
/** 本月1日 ~ 今天(字符串,供 RangePicker valueFormat) */
|
||||
export function monthToTodayRangeString(): [string, string] {
|
||||
const today = todayDayjs();
|
||||
return [today.startOf('month').format(YMD), today.format(YMD)];
|
||||
}
|
||||
|
||||
/** 本月1日 ~ 今天(Dayjs) */
|
||||
export function monthToTodayRangeDayjs(): [Dayjs, Dayjs] {
|
||||
const today = todayDayjs();
|
||||
return [today.startOf('month'), today];
|
||||
}
|
||||
|
||||
/** 近 N 天(含今天),默认 7 天 */
|
||||
export function lastNDaysRangeString(days = 7): [string, string] {
|
||||
const today = todayDayjs();
|
||||
const start = today.subtract(Math.max(days - 1, 0), 'day');
|
||||
return [start.format(YMD), today.format(YMD)];
|
||||
}
|
||||
|
||||
/** 近 N 天(Dayjs) */
|
||||
export function lastNDaysRangeDayjs(days = 7): [Dayjs, Dayjs] {
|
||||
const today = todayDayjs();
|
||||
const start = today.subtract(Math.max(days - 1, 0), 'day');
|
||||
return [start, today];
|
||||
}
|
||||
|
||||
/** 将 Dayjs / 字符串 / 时间戳统一为 YYYY-MM-DD */
|
||||
export function normalizeRangeToYmd(
|
||||
value: unknown,
|
||||
): [string, string] | null {
|
||||
if (!value || !Array.isArray(value) || value.length < 2) {
|
||||
return null;
|
||||
}
|
||||
const a = pickYmd(value[0]);
|
||||
const b = pickYmd(value[1]);
|
||||
if (!a || !b) return null;
|
||||
return [a, b];
|
||||
}
|
||||
|
||||
function pickYmd(v: unknown): string {
|
||||
if (v == null) return '';
|
||||
if (
|
||||
typeof v === 'object' &&
|
||||
v !== null &&
|
||||
'format' in v &&
|
||||
typeof (v as { format: (s: string) => string }).format === 'function'
|
||||
) {
|
||||
return (v as Dayjs).format(YMD);
|
||||
}
|
||||
const d = dayjs(v as string | number);
|
||||
return d.isValid() ? d.format(YMD) : '';
|
||||
}
|
||||
|
||||
/** 比较两段范围是否相同(按 YYYY-MM-DD) */
|
||||
export function isSameRange(
|
||||
a: unknown,
|
||||
b: unknown,
|
||||
): boolean {
|
||||
const na = normalizeRangeToYmd(a);
|
||||
const nb = normalizeRangeToYmd(b);
|
||||
if (!na || !nb) return false;
|
||||
return na[0] === nb[0] && na[1] === nb[1];
|
||||
}
|
||||
|
||||
/** 翻月锚点:优先取当前范围开始日,否则今天 */
|
||||
export function getMonthAnchorDayjs(current: unknown): Dayjs {
|
||||
const normalized = normalizeRangeToYmd(current);
|
||||
if (normalized?.[0]) {
|
||||
const d = dayjs(normalized[0], YMD);
|
||||
if (d.isValid()) return d.startOf('day');
|
||||
}
|
||||
return todayDayjs();
|
||||
}
|
||||
|
||||
/** 自然月整月,结束日不超过今天 */
|
||||
function fullMonthRangeCapped(
|
||||
month: Dayjs,
|
||||
): [Dayjs, Dayjs] {
|
||||
const start = month.startOf('month');
|
||||
const end = month.endOf('month').startOf('day');
|
||||
const today = todayDayjs();
|
||||
return [start, end.isAfter(today) ? today : end];
|
||||
}
|
||||
|
||||
/** 按预设计算区间(Dayjs) */
|
||||
export function resolveSearchTimePreset(
|
||||
preset: SearchTimePreset,
|
||||
current: unknown,
|
||||
): [Dayjs, Dayjs] {
|
||||
const today = todayDayjs();
|
||||
switch (preset) {
|
||||
case 'today':
|
||||
return [today, today];
|
||||
case 'thisWeek':
|
||||
return [startOfWeekMonday(today), today];
|
||||
case 'thisMonth':
|
||||
return [today.startOf('month'), today];
|
||||
case 'prevMonth': {
|
||||
const anchor = getMonthAnchorDayjs(current);
|
||||
return fullMonthRangeCapped(anchor.subtract(1, 'month'));
|
||||
}
|
||||
case 'nextMonth': {
|
||||
const anchor = getMonthAnchorDayjs(current);
|
||||
return fullMonthRangeCapped(anchor.add(1, 'month'));
|
||||
}
|
||||
default:
|
||||
return monthToTodayRangeDayjs();
|
||||
}
|
||||
}
|
||||
|
||||
/** 按预设计算区间(字符串) */
|
||||
export function resolveSearchTimePresetString(
|
||||
preset: SearchTimePreset,
|
||||
current: unknown,
|
||||
): [string, string] {
|
||||
const [a, b] = resolveSearchTimePreset(preset, current);
|
||||
return [a.format(YMD), b.format(YMD)];
|
||||
}
|
||||
|
||||
/** Dayjs 区间转字符串 */
|
||||
export function rangeDayjsToString(
|
||||
range: [Dayjs, Dayjs],
|
||||
): [string, string] {
|
||||
return [range[0].format(YMD), range[1].format(YMD)];
|
||||
}
|
||||
|
||||
/** 字符串区间转 Dayjs */
|
||||
export function rangeStringToDayjs(
|
||||
range: [string, string],
|
||||
): [Dayjs, Dayjs] {
|
||||
return [dayjs(range[0], YMD), dayjs(range[1], YMD)];
|
||||
}
|
||||
|
||||
/** 将区间按 valueFormat 输出 */
|
||||
export function formatRangeByValueFormat(
|
||||
range: [Dayjs, Dayjs],
|
||||
valueFormat?: string,
|
||||
): [string, string] | [Dayjs, Dayjs] {
|
||||
if (valueFormat === YMD) {
|
||||
return rangeDayjsToString(range);
|
||||
}
|
||||
return range;
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 商品订单推广员分成 Popover 区块(列表列与卡片视图共用)
|
||||
*/
|
||||
import { Button, Image, Popconfirm, Popover, Tag } from 'ant-design-vue';
|
||||
|
||||
const props = defineProps<{
|
||||
row: Record<string, any>;
|
||||
canViewInviterCommission?: boolean;
|
||||
accruingOrderIds?: number[];
|
||||
reversingOrderIds?: number[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
accrue: [row: Record<string, any>];
|
||||
reverse: [row: Record<string, any>, salespersonId?: number];
|
||||
}>();
|
||||
|
||||
function isNegativeCommission(amount?: string | number) {
|
||||
return Number(amount ?? 0) < 0;
|
||||
}
|
||||
|
||||
function salespersonStatusColor(text: string) {
|
||||
if (text === '已分成') return 'success';
|
||||
if (text === '未分成') return 'warning';
|
||||
if (text === '已冲销') return 'warning';
|
||||
if (text === '未支付') return 'default';
|
||||
return 'default';
|
||||
}
|
||||
|
||||
function formatCommissionRecordDetail(record: Record<string, any>) {
|
||||
const typeText = record.record_type_text ? `${record.record_type_text} · ` : '';
|
||||
const path = record.commission_path_text || '—';
|
||||
const rule = record.commission_rule_text || '—';
|
||||
if (record.commission_mode_text === '比例分成') {
|
||||
return `${typeText}${path} · ${rule}`;
|
||||
}
|
||||
return `${typeText}${path} · ${record.commission_mode_text || '固定单价'} · ${rule}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="row.salesperson?.id" class="salesperson-commission-block space-y-1">
|
||||
<Popover trigger="click" placement="topLeft" overlay-class-name="salesperson-commission-popover">
|
||||
<template #title>
|
||||
<span class="font-semibold">推广员分成</span>
|
||||
</template>
|
||||
<template #content>
|
||||
<div class="w-80 space-y-3 text-sm">
|
||||
<div class="salesperson-commission-block__panel">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="font-semibold">直推推广员</span>
|
||||
<span class="font-medium text-[hsl(var(--warning))]">
|
||||
¥{{ row.salesperson.commission_amount || '0.00' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-1 text-[hsl(var(--muted-foreground))]">
|
||||
{{ row.salesperson.nick_name || '—' }}
|
||||
</div>
|
||||
<div
|
||||
v-if="!(row.salesperson.commission_records?.length > 0)"
|
||||
class="text-[hsl(var(--muted-foreground))]"
|
||||
>
|
||||
暂无分成明细
|
||||
</div>
|
||||
<div
|
||||
v-for="(record, idx) in row.salesperson.commission_records || []"
|
||||
:key="'d-' + idx"
|
||||
class="flex items-start justify-between border-b border-[hsl(var(--border))] py-2 last:border-0"
|
||||
>
|
||||
<div class="min-w-0 flex-1 pr-2">
|
||||
<div class="font-medium">{{ record.drug_name || '—' }}</div>
|
||||
<div class="text-xs text-[hsl(var(--muted-foreground))]">
|
||||
{{ formatCommissionRecordDetail(record) }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="shrink-0 font-medium"
|
||||
:class="isNegativeCommission(record.commission_amount) ? 'text-red-500' : 'text-[hsl(var(--warning))]'"
|
||||
>
|
||||
¥{{ record.commission_amount }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="row.salesperson.can_reverse_commission" class="mt-2 text-right">
|
||||
<Popconfirm
|
||||
title="确认退回直推推广员分成?"
|
||||
@confirm="emit('reverse', row)"
|
||||
>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
danger
|
||||
class="!h-auto !px-0 !py-0"
|
||||
:loading="reversingOrderIds?.includes(row.id)"
|
||||
>
|
||||
退回分成
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="canViewInviterCommission && row.salesperson.has_inviter && row.salesperson.inviter"
|
||||
class="salesperson-commission-block__panel salesperson-commission-block__panel--inviter"
|
||||
>
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="font-semibold">
|
||||
邀请人({{ row.salesperson.inviter.inviter_split }}%)
|
||||
</span>
|
||||
<span class="font-medium text-[hsl(var(--warning))]">
|
||||
¥{{ row.salesperson.inviter.commission_amount || '0.00' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-1 text-[hsl(var(--muted-foreground))]">
|
||||
{{ row.salesperson.inviter.nick_name || '—' }}
|
||||
</div>
|
||||
<div
|
||||
v-if="!(row.salesperson.inviter.commission_records?.length > 0)"
|
||||
class="text-[hsl(var(--muted-foreground))]"
|
||||
>
|
||||
暂无邀请分成明细
|
||||
</div>
|
||||
<div
|
||||
v-for="(record, idx) in row.salesperson.inviter.commission_records || []"
|
||||
:key="'i-' + idx"
|
||||
class="flex items-start justify-between border-b border-[hsl(var(--border))] py-2 last:border-0"
|
||||
>
|
||||
<div class="min-w-0 flex-1 pr-2">
|
||||
<div class="font-medium">{{ record.drug_name || '—' }}</div>
|
||||
<div class="text-xs text-[hsl(var(--muted-foreground))]">
|
||||
{{ formatCommissionRecordDetail(record) }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="shrink-0 font-medium"
|
||||
:class="isNegativeCommission(record.commission_amount) ? 'text-red-500' : 'text-[hsl(var(--warning))]'"
|
||||
>
|
||||
¥{{ record.commission_amount }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="canViewInviterCommission && row.salesperson.inviter?.can_reverse_commission"
|
||||
class="mt-2 text-right"
|
||||
>
|
||||
<Popconfirm
|
||||
title="确认退回邀请人分成?"
|
||||
@confirm="emit('reverse', row, row.salesperson.inviter.id)"
|
||||
>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
danger
|
||||
class="!h-auto !px-0 !py-0"
|
||||
:loading="reversingOrderIds?.includes(row.id)"
|
||||
>
|
||||
退回邀请分成
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<slot>
|
||||
<div class="flex cursor-pointer items-center gap-2 hover:opacity-80">
|
||||
<Image
|
||||
:src="row.salesperson.avatar || '/img/user-default-avatar.png'"
|
||||
:width="32"
|
||||
:height="32"
|
||||
class="shrink-0 rounded-full object-cover"
|
||||
/>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="truncate text-sm font-medium">{{
|
||||
row.salesperson.nick_name || '—'
|
||||
}}</span>
|
||||
<Tag
|
||||
:color="salespersonStatusColor(row.salesperson.commission_status_text)"
|
||||
class="!m-0 shrink-0"
|
||||
>
|
||||
{{ row.salesperson.commission_status_text }}
|
||||
</Tag>
|
||||
</div>
|
||||
<div class="text-sm font-medium text-[hsl(var(--warning))]">
|
||||
¥{{ row.salesperson.commission_amount || '0.00' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</slot>
|
||||
</Popover>
|
||||
<Button
|
||||
v-if="
|
||||
row.is_pay === 1 &&
|
||||
row.salesperson_id > 0 &&
|
||||
!row.salesperson.has_commission
|
||||
"
|
||||
class="!h-auto !px-0 !py-0"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="accruingOrderIds?.includes(row.id)"
|
||||
@click="emit('accrue', row)"
|
||||
>
|
||||
立即分成
|
||||
</Button>
|
||||
<Popconfirm
|
||||
v-else-if="row.is_pay === 1 && row.salesperson.can_reverse_commission"
|
||||
title="确认退回推广员分成?"
|
||||
@confirm="emit('reverse', row)"
|
||||
>
|
||||
<Button
|
||||
class="!h-auto !px-0 !py-0"
|
||||
type="link"
|
||||
size="small"
|
||||
danger
|
||||
:loading="reversingOrderIds?.includes(row.id)"
|
||||
>
|
||||
退回分成
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
<span v-else class="text-sm text-[hsl(var(--muted-foreground))]">
|
||||
{{ row.salesperson?.commission_status_text || '无推广员' }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.salesperson-commission-block__panel {
|
||||
padding: 12px;
|
||||
background: hsl(var(--muted) / 0.2);
|
||||
border: 1px solid hsl(var(--border));
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.salesperson-commission-block__panel--inviter {
|
||||
border-color: hsl(var(--warning) / 30%);
|
||||
box-shadow: 0 0 6px hsl(var(--warning) / 12%);
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { getOrderPrescriptionTypeOption } from '#/views/business/order/product-order/api';
|
||||
import { monthToTodayRangeString } from '#/utils/search-time-range';
|
||||
|
||||
import { PRESCRIPTION_IS_ONLINE_OPTIONS } from './constants';
|
||||
|
||||
@@ -21,16 +21,12 @@ export const formOptions: VbenFormProps = {
|
||||
schema: [
|
||||
{
|
||||
// 放第一位:时间范围有默认值(本月至今),默认收起时必须始终可见,否则用户不知道当前查的是哪段数据
|
||||
component: 'RangePicker',
|
||||
component: 'SearchTimeRangePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
// 提交纯日期,后端 getWhereBetween 会把结束日扩到当天 23:59:59
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
},
|
||||
defaultValue: [
|
||||
dayjs().startOf('month').format('YYYY-MM-DD'),
|
||||
dayjs().format('YYYY-MM-DD'),
|
||||
],
|
||||
defaultValue: monthToTodayRangeString(),
|
||||
fieldName: 'search_time',
|
||||
label: '时间范围',
|
||||
},
|
||||
|
||||
@@ -27,7 +27,7 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
{ field: 'prescription_no', align: 'left', title: '处方订单号' },
|
||||
{ field: 'doctor_info.name', align: 'left', title: '开方医生' },
|
||||
{ field: 'user_patient.name', align: 'left', title: '就诊人名称' },
|
||||
{ field: 'store.name', align: 'left', title: '开方诊所', slots: { default: 'store-name' } },
|
||||
{ field: 'store.name', align: 'left', title: '开方诊所', minWidth: 140, slots: { default: 'store-name' } },
|
||||
{ field: 'status', title: '状态', slots: { default: 'status' } },
|
||||
{
|
||||
field: 'is_online',
|
||||
|
||||
@@ -17,9 +17,12 @@ import { Button, Tabs, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { useFreshSearchTime } from '#/composables/use-fresh-search-time';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { monthToTodayRangeString } from '#/utils/search-time-range';
|
||||
import { useViewMode, ViewModeSwitch } from '#/components/view-mode-switch';
|
||||
import StoreCardModal from '#/components/store-card/StoreCardModal.vue';
|
||||
import StoreNameLink from '#/components/store-card/StoreNameLink.vue';
|
||||
import PrescriptionDetail from '#/views/doctor/doctor-reception/components/PrescriptionDetail.vue';
|
||||
|
||||
import { getPrescriptionListApi } from './api';
|
||||
@@ -60,7 +63,11 @@ function collectDefaultSearchValues(): Record<string, any> {
|
||||
const values: Record<string, any> = {};
|
||||
for (const item of formOptions.schema ?? []) {
|
||||
if (item.fieldName && item.defaultValue !== undefined) {
|
||||
values[item.fieldName] = item.defaultValue;
|
||||
if (item.fieldName === 'search_time') {
|
||||
values[item.fieldName] = monthToTodayRangeString();
|
||||
} else {
|
||||
values[item.fieldName] = item.defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return values;
|
||||
@@ -69,6 +76,11 @@ function collectDefaultSearchValues(): Record<string, any> {
|
||||
/** 列表与卡片共用的搜索条件(不含 status Tab,Tab 单独合并) */
|
||||
const searchValues = ref<Record<string, any>>(collectDefaultSearchValues());
|
||||
|
||||
const freshSearchTimeBridge = {
|
||||
resetSearchTime: async () => {},
|
||||
markSearchTimeTouched: () => {},
|
||||
};
|
||||
|
||||
/**
|
||||
* 读搜索表单现值(不要只用 handleSubmit 快照)
|
||||
* 抽出独立 SearchForm 后,列表 query 必须自己取表单值,否则点查询/翻页会丢掉刚填的条件
|
||||
@@ -95,6 +107,11 @@ const cardFormValues = computed(() => ({
|
||||
*/
|
||||
const [SearchForm, searchFormApi] = useVbenForm({
|
||||
...formOptions,
|
||||
handleValuesChange(_values, fieldsChanged) {
|
||||
if (fieldsChanged?.includes('search_time')) {
|
||||
freshSearchTimeBridge.markSearchTimeTouched();
|
||||
}
|
||||
},
|
||||
handleSubmit: async () => {
|
||||
searchValues.value = await readLiveSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
@@ -102,12 +119,7 @@ const [SearchForm, searchFormApi] = useVbenForm({
|
||||
}
|
||||
},
|
||||
handleReset: async () => {
|
||||
// 自定义 handleReset 会接管默认行为,必须手动还原控件到 defaultValue(reset 为新 API,resetForm 已弃用)
|
||||
await searchFormApi.reset();
|
||||
searchValues.value = collectDefaultSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
gridApi.reload();
|
||||
}
|
||||
await freshSearchTimeBridge.resetSearchTime();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -144,6 +156,20 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridEvents,
|
||||
});
|
||||
|
||||
const freshSearchTime = useFreshSearchTime({
|
||||
formApi: searchFormApi,
|
||||
searchValues,
|
||||
getDefaultRange: () => monthToTodayRangeString(),
|
||||
onRefresh: async () => {
|
||||
searchValues.value = await readLiveSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
gridApi.reload();
|
||||
}
|
||||
},
|
||||
});
|
||||
freshSearchTimeBridge.resetSearchTime = freshSearchTime.resetSearchTime;
|
||||
freshSearchTimeBridge.markSearchTimeTouched = freshSearchTime.markSearchTimeTouched;
|
||||
|
||||
// Tab 切换:列表模式重查(卡片模式由 cardFormValues computed 触发 CardList watch)
|
||||
watch(statusTab, () => {
|
||||
if (viewMode.value === 'list') {
|
||||
@@ -223,16 +249,11 @@ function rowIsOnlineMeta(row: Record<string, any>) {
|
||||
</TableAction>
|
||||
</template>
|
||||
<template #store-name="{ row }">
|
||||
<Button
|
||||
v-if="row.store?.id || row.store_id"
|
||||
type="link"
|
||||
size="small"
|
||||
class="!px-0"
|
||||
@click="openStoreCard(row.store?.id || row.store_id)"
|
||||
>
|
||||
{{ row.store?.name || '—' }}
|
||||
</Button>
|
||||
<span v-else>{{ row.store?.name || '—' }}</span>
|
||||
<StoreNameLink
|
||||
:store-id="Number(row.store?.id || row.store_id || 0) || undefined"
|
||||
:name="row.store?.name"
|
||||
@click="openStoreCard"
|
||||
/>
|
||||
</template>
|
||||
<template #status="{ row }">
|
||||
<!-- 处方类型与审核状态渲染统一走 constants 映射,与卡片视图同语义 -->
|
||||
|
||||
@@ -17,6 +17,7 @@ import { Button, Empty, Image, message, Spin, Switch } from 'ant-design-vue';
|
||||
|
||||
import { CardActions } from '#/components/table-action';
|
||||
import SensitiveText from '#/components/sensitive-text/SensitiveText.vue';
|
||||
import SalespersonCommissionPanel from '#/views/business/order/components/SalespersonCommissionPanel.vue';
|
||||
import { pillStyle, tagColorHex } from '#/utils/tagColor';
|
||||
|
||||
import { getOrderList } from '../api';
|
||||
@@ -38,6 +39,9 @@ const props = defineProps<{
|
||||
};
|
||||
/** 金额是否可点调价(与列表 price-info 槽一致) */
|
||||
canPercentAdjust?: (row: Record<string, any>) => boolean;
|
||||
canViewInviterCommission?: boolean;
|
||||
accruingOrderIds?: number[];
|
||||
reversingOrderIds?: number[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -49,6 +53,9 @@ const emit = defineEmits<{
|
||||
toggleFreeShipping: [row: Record<string, any>, checked: boolean];
|
||||
percentAdjust: [row: Record<string, any>];
|
||||
goRegister: [row: Record<string, any>];
|
||||
openChinaErpSyncLog: [row: Record<string, any>];
|
||||
accrueSalesperson: [row: Record<string, any>];
|
||||
reverseSalesperson: [row: Record<string, any>, salespersonId?: number];
|
||||
}>();
|
||||
|
||||
const items = ref<any[]>([]);
|
||||
@@ -358,8 +365,14 @@ onBeforeUnmount(() => {
|
||||
<span v-else-if="row.delivery_method === 0" class="po-pill" :style="pillStyle('green')">
|
||||
上门快递
|
||||
</span>
|
||||
<span class="po-pill" :style="pillStyle(row.is_sync_erp === 1 ? 'green' : 'red')">
|
||||
{{ row.is_sync_erp === 1 ? 'Erp已同步' : 'Erp未同步' }}
|
||||
<span
|
||||
v-if="Number(row.prescription_type) === 1"
|
||||
class="po-pill po-pill--action"
|
||||
:style="pillStyle(row.is_sync_erp === 1 ? 'green' : 'red')"
|
||||
role="button"
|
||||
@click="emit('openChinaErpSyncLog', row)"
|
||||
>
|
||||
{{ row.is_sync_erp === 1 ? 'Erp已同步' : 'Erp未同步' }} ›
|
||||
</span>
|
||||
<template
|
||||
v-if="Array.isArray(row.delivery_warehouses) && row.delivery_warehouses.length"
|
||||
@@ -497,20 +510,31 @@ onBeforeUnmount(() => {
|
||||
<!-- 行6 推广员内联行(有则显示) -->
|
||||
<div v-if="row.salesperson?.id" class="po-card__express po-card__salesperson">
|
||||
<i>推广</i>
|
||||
<Image
|
||||
:src="row.salesperson.avatar || '/img/user-default-avatar.png'"
|
||||
:width="16"
|
||||
:height="16"
|
||||
:preview="false"
|
||||
class="shrink-0 rounded-full object-cover"
|
||||
/>
|
||||
<span class="truncate">{{ row.salesperson.nick_name || '—' }}</span>
|
||||
<span class="po-card__salesperson-status">
|
||||
{{ row.salesperson.commission_status_text || '—' }}
|
||||
</span>
|
||||
<span class="shrink-0 font-medium text-orange-500">
|
||||
¥{{ row.salesperson.commission_amount || '0.00' }}
|
||||
</span>
|
||||
<SalespersonCommissionPanel
|
||||
:row="row"
|
||||
:can-view-inviter-commission="props.canViewInviterCommission"
|
||||
:accruing-order-ids="props.accruingOrderIds"
|
||||
:reversing-order-ids="props.reversingOrderIds"
|
||||
@accrue="(r) => emit('accrueSalesperson', r)"
|
||||
@reverse="(r, spId) => emit('reverseSalesperson', r, spId)"
|
||||
>
|
||||
<div class="po-card__salesperson-inline flex min-w-0 flex-1 items-center gap-1.5">
|
||||
<Image
|
||||
:src="row.salesperson.avatar || '/img/user-default-avatar.png'"
|
||||
:width="16"
|
||||
:height="16"
|
||||
:preview="false"
|
||||
class="shrink-0 rounded-full object-cover"
|
||||
/>
|
||||
<span class="truncate">{{ row.salesperson.nick_name || '—' }}</span>
|
||||
<span class="po-card__salesperson-status">
|
||||
{{ row.salesperson.commission_status_text || '—' }}
|
||||
</span>
|
||||
<span class="shrink-0 font-medium text-[hsl(var(--warning))]">
|
||||
¥{{ row.salesperson.commission_amount || '0.00' }}
|
||||
</span>
|
||||
</div>
|
||||
</SalespersonCommissionPanel>
|
||||
</div>
|
||||
<!-- 弹性占位:高度富余时把 footer 推到底(同行等高卡对齐),紧凑时保底 8px 间距 -->
|
||||
<div class="po-card__spacer"></div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
|
||||
import {
|
||||
Button,
|
||||
@@ -69,7 +69,7 @@ const DELIVERY_OPTIONS = [
|
||||
{ label: '诊所自提', value: 1 },
|
||||
];
|
||||
|
||||
const searchTime = ref<[Dayjs, Dayjs]>([dayjs().startOf('month'), dayjs()]);
|
||||
const searchTime = ref<[Dayjs, Dayjs]>(monthToTodayRangeDayjs());
|
||||
const orderNo = ref('');
|
||||
const storeId = ref<number | undefined>(undefined);
|
||||
const status = ref<number | undefined>(undefined);
|
||||
@@ -663,7 +663,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
locked_store_name?: string;
|
||||
}>() || {};
|
||||
|
||||
searchTime.value = [dayjs().startOf('month'), dayjs()];
|
||||
searchTime.value = monthToTodayRangeDayjs();
|
||||
activeSchemeId.value = CUSTOM_SCHEME_VALUE;
|
||||
clearSchemeModified();
|
||||
resetFormDefaults();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 商品订单退款弹窗
|
||||
* 确认时自行校验并调 refund 接口;不再走已弃用的 validateAndSubmitForm
|
||||
* 展示订单摘要并必填退款原因,确认时校验后调 refund 接口
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
@@ -14,8 +14,13 @@ import { useVbenForm } from '#/adapter/form';
|
||||
import { refundApi } from '../api';
|
||||
import { modalRefundFormProps } from '../config/form';
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const gridApi = ref();
|
||||
/** 弹窗打开时带入的订单摘要,用于展示不可编辑信息 */
|
||||
const orderSummary = ref<Record<string, any> | null>(null);
|
||||
|
||||
const isPublicAccountOrder = computed(
|
||||
() => Number(orderSummary.value?.public_account_pay_enabled ?? 0) === 1,
|
||||
);
|
||||
|
||||
const [Form, formApi] = useVbenForm(modalRefundFormProps);
|
||||
|
||||
@@ -32,27 +37,112 @@ const [Modal, modalApi] = useVbenModal({
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
await refundApi(values);
|
||||
message.success('保存成功');
|
||||
gridApi.value?.reload();
|
||||
message.success('退款申请已提交');
|
||||
gridApi.value?.reload?.();
|
||||
gridApi.value?.query?.();
|
||||
modalApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
gridApi.value = isOpen ? modalApi.getData()?.gridApi : null;
|
||||
if (isOpen) {
|
||||
const { values, update } = modalApi.getData<Record<string, any>>();
|
||||
if (values) {
|
||||
isUpdate.value = update;
|
||||
formApi.setValues(values);
|
||||
}
|
||||
if (!isOpen) {
|
||||
gridApi.value = null;
|
||||
orderSummary.value = null;
|
||||
return;
|
||||
}
|
||||
const data = modalApi.getData<Record<string, any>>() || {};
|
||||
gridApi.value = data.gridApi ?? null;
|
||||
orderSummary.value = data.orderSummary ?? null;
|
||||
formApi.setValues({
|
||||
order_id: data.values?.order_id,
|
||||
refund_reason: '',
|
||||
});
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Modal title="退款" class="w-[80%] md:w-[50%] lg:w-[30%] h-[60%]">
|
||||
<Form />
|
||||
<Modal title="订单退款" class="w-[480px]">
|
||||
<div class="refund-modal-body">
|
||||
<div v-if="orderSummary" class="refund-summary">
|
||||
<div class="refund-summary-row">
|
||||
<span class="refund-summary-label">订单号</span>
|
||||
<span class="refund-summary-value">{{ orderSummary.order_no || '-' }}</span>
|
||||
</div>
|
||||
<div class="refund-summary-row">
|
||||
<span class="refund-summary-label">诊所</span>
|
||||
<span class="refund-summary-value">{{
|
||||
orderSummary.store_name || '-'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="refund-summary-row">
|
||||
<span class="refund-summary-label">实付金额</span>
|
||||
<span class="refund-summary-value refund-summary-amount">
|
||||
¥{{ orderSummary.total_pay_price ?? '0.00' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
v-if="isPublicAccountOrder"
|
||||
class="refund-hint refund-hint-warning"
|
||||
>
|
||||
该订单走公账支付,退款后将同步冲销台账并更新日账单,请确认原因无误后再提交。
|
||||
</p>
|
||||
<p v-else class="refund-hint">
|
||||
提交后将进入退款流程,请填写明确的退款原因。
|
||||
</p>
|
||||
<Form />
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
<style scoped>
|
||||
.refund-modal-body {
|
||||
padding-top: 4px;
|
||||
}
|
||||
.refund-summary {
|
||||
margin-bottom: 12px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid hsl(var(--border));
|
||||
border-radius: 8px;
|
||||
background: hsl(var(--muted) / 0.25);
|
||||
}
|
||||
.refund-summary-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.refund-summary-row + .refund-summary-row {
|
||||
margin-top: 6px;
|
||||
}
|
||||
.refund-summary-label {
|
||||
flex-shrink: 0;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.refund-summary-value {
|
||||
text-align: right;
|
||||
color: hsl(var(--foreground));
|
||||
word-break: break-all;
|
||||
}
|
||||
.refund-summary-amount {
|
||||
font-weight: 600;
|
||||
color: hsl(var(--primary));
|
||||
}
|
||||
.refund-hint {
|
||||
margin: 0 0 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.refund-hint-warning {
|
||||
padding: 8px 10px;
|
||||
border: 1px solid hsl(var(--warning) / 35%);
|
||||
border-radius: 6px;
|
||||
background: hsl(var(--warning) / 0.12);
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -74,22 +74,17 @@ export const modalFormProps: VbenFormProps = {
|
||||
showDefaultActions: false,
|
||||
};
|
||||
export const modalRefundFormProps: VbenFormProps = {
|
||||
wrapperClass: 'grid-cols-12', // 24栅格,
|
||||
layout: 'vertical',
|
||||
commonConfig: {
|
||||
formItemClass: 'col-span-12',
|
||||
// 所有表单项
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
// handleSubmit: onSubmit,
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'order_id',
|
||||
label: 'ID',
|
||||
formItemClass: 'col-span-6',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['order_id'],
|
||||
@@ -98,10 +93,14 @@ export const modalRefundFormProps: VbenFormProps = {
|
||||
{
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入退款备注',
|
||||
placeholder: '请填写退款原因,便于财务与客服追溯',
|
||||
rows: 4,
|
||||
maxlength: 200,
|
||||
showCount: true,
|
||||
},
|
||||
fieldName: 'refund_reason',
|
||||
label: '退款备注',
|
||||
label: '退款原因',
|
||||
rules: 'required',
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import {
|
||||
getOrderPrescriptionTypeOption,
|
||||
getOrderStatusOption,
|
||||
} from '#/views/business/order/product-order/api';
|
||||
import { monthToTodayRangeString } from '#/utils/search-time-range';
|
||||
|
||||
export const formOptions: VbenFormProps = {
|
||||
// 默认收起只显示第一行,点「展开」看全部筛选(字段多,全展开太占高度)
|
||||
@@ -22,16 +22,12 @@ export const formOptions: VbenFormProps = {
|
||||
schema: [
|
||||
{
|
||||
// 放第一位:时间范围有默认值(本月至今),默认收起时必须始终可见,否则用户不知道当前查的是哪段数据
|
||||
component: 'RangePicker',
|
||||
component: 'SearchTimeRangePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
// 提交纯日期,后端 getWhereBetween 会把结束日扩到当天 23:59:59
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
},
|
||||
defaultValue: [
|
||||
dayjs().startOf('month').format('YYYY-MM-DD'),
|
||||
dayjs().format('YYYY-MM-DD'),
|
||||
],
|
||||
defaultValue: monthToTodayRangeString(),
|
||||
fieldName: 'search_time',
|
||||
label: '时间范围',
|
||||
},
|
||||
|
||||
@@ -14,20 +14,19 @@ import {
|
||||
message,
|
||||
Modal as AntdModal,
|
||||
Popconfirm,
|
||||
Popover,
|
||||
Space,
|
||||
Switch,
|
||||
Table,
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import type { ActionItem } from '#/components/table-action';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { useFreshSearchTime } from '#/composables/use-fresh-search-time';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { monthToTodayRangeString } from '#/utils/search-time-range';
|
||||
import SensitiveText from '#/components/sensitive-text/SensitiveText.vue';
|
||||
import {
|
||||
cancelOrderApi,
|
||||
@@ -46,6 +45,7 @@ import {
|
||||
simulatePayApi,
|
||||
} from '#/views/business/order/api/order-ops';
|
||||
import ChinaErpSyncLogDrawer from '#/views/business/order/components/china-erp-sync-log-drawer.vue';
|
||||
import SalespersonCommissionPanel from '#/views/business/order/components/SalespersonCommissionPanel.vue';
|
||||
import OrderTraceDrawer from '#/views/business/order/components/order-trace-drawer.vue';
|
||||
import OrderPricePercentAdjustDrawer from '#/views/business/order/components/OrderPricePercentAdjustDrawer.vue';
|
||||
import { getOrderPriceAdjustConfig } from '#/api/order/priceAdjust';
|
||||
@@ -54,6 +54,7 @@ import { normalizeQuickOptions } from '#/utils/pricePercentAdjust';
|
||||
import PrescriptionDetail from '#/views/doctor/doctor-reception/components/PrescriptionDetail.vue';
|
||||
import DoctorCardModal from '#/views/doctor/doctor/components/DoctorCardModal.vue';
|
||||
import StoreCardModal from '#/components/store-card/StoreCardModal.vue';
|
||||
import StoreNameLink from '#/components/store-card/StoreNameLink.vue';
|
||||
import {
|
||||
WxUserPatientDetailModal,
|
||||
WxUserPatientsModal,
|
||||
@@ -167,10 +168,7 @@ function buildFormOptionsFromRoute(): VbenFormProps {
|
||||
// 与 RangePicker valueFormat 保持一致用字符串,defaultValue 会直接进入首屏搜索条件
|
||||
return {
|
||||
...item,
|
||||
defaultValue: [
|
||||
dayjs().startOf('month').format('YYYY-MM-DD'),
|
||||
dayjs().format('YYYY-MM-DD'),
|
||||
],
|
||||
defaultValue: monthToTodayRangeString(),
|
||||
};
|
||||
}
|
||||
if (timeScope === 'all') {
|
||||
@@ -197,7 +195,11 @@ function collectDefaultSearchValues(): Record<string, any> {
|
||||
const values: Record<string, any> = {};
|
||||
for (const item of effectiveFormOptions.schema ?? []) {
|
||||
if (item.fieldName && item.defaultValue !== undefined) {
|
||||
values[item.fieldName] = item.defaultValue;
|
||||
if (item.fieldName === 'search_time' && item.defaultValue !== null) {
|
||||
values[item.fieldName] = monthToTodayRangeString();
|
||||
} else {
|
||||
values[item.fieldName] = item.defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return values;
|
||||
@@ -206,6 +208,20 @@ function collectDefaultSearchValues(): Record<string, any> {
|
||||
/** 列表与卡片共用的搜索条件(提交/重置时整体替换,卡片靠 watch 自动拉数) */
|
||||
const searchValues = ref<Record<string, any>>(collectDefaultSearchValues());
|
||||
|
||||
/** 时间范围默认:路由指定 null 时不自动滚到今天 */
|
||||
function getFreshSearchTimeDefault() {
|
||||
const item = effectiveFormOptions.schema?.find(
|
||||
(s) => s.fieldName === 'search_time',
|
||||
);
|
||||
if (item?.defaultValue === null) return null;
|
||||
return monthToTodayRangeString();
|
||||
}
|
||||
|
||||
const freshSearchTimeBridge = {
|
||||
resetSearchTime: async () => {},
|
||||
markSearchTimeTouched: () => {},
|
||||
};
|
||||
|
||||
/**
|
||||
* 读搜索表单现值(不要只用 handleSubmit 快照)
|
||||
* 抽出独立 SearchForm 后,列表 query 必须自己取表单值,否则点查询/翻页会丢掉刚选的门店等条件
|
||||
@@ -227,6 +243,11 @@ async function readLiveSearchValues(): Promise<Record<string, any>> {
|
||||
*/
|
||||
const [SearchForm, searchFormApi] = useVbenForm({
|
||||
...effectiveFormOptions,
|
||||
handleValuesChange(_values, fieldsChanged) {
|
||||
if (fieldsChanged?.includes('search_time')) {
|
||||
freshSearchTimeBridge.markSearchTimeTouched();
|
||||
}
|
||||
},
|
||||
handleSubmit: async () => {
|
||||
searchValues.value = await readLiveSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
@@ -237,14 +258,7 @@ const [SearchForm, searchFormApi] = useVbenForm({
|
||||
}
|
||||
},
|
||||
handleReset: async () => {
|
||||
// 自定义 handleReset 会接管默认行为,必须手动还原控件到 defaultValue(reset 为新 API,resetForm 已弃用)
|
||||
await searchFormApi.reset();
|
||||
searchValues.value = collectDefaultSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
gridApi.reload();
|
||||
} else {
|
||||
saleAmount(searchValues.value);
|
||||
}
|
||||
await freshSearchTimeBridge.resetSearchTime();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -271,6 +285,23 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridEvents,
|
||||
});
|
||||
|
||||
const freshSearchTime = useFreshSearchTime({
|
||||
formApi: searchFormApi,
|
||||
searchValues,
|
||||
getDefaultRange: getFreshSearchTimeDefault,
|
||||
onRefresh: async () => {
|
||||
searchValues.value = await readLiveSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
gridApi.reload();
|
||||
} else {
|
||||
saleAmount(searchValues.value);
|
||||
cardListRef.value?.reload?.();
|
||||
}
|
||||
},
|
||||
});
|
||||
freshSearchTimeBridge.resetSearchTime = freshSearchTime.resetSearchTime;
|
||||
freshSearchTimeBridge.markSearchTimeTouched = freshSearchTime.markSearchTimeTouched;
|
||||
|
||||
// 记忆持久化由 useViewMode 内部完成;这里只处理切回列表时 grid 被 v-if 卸载过需重查
|
||||
watch(viewMode, (mode, prev) => {
|
||||
if (mode === 'list' && prev === 'card') {
|
||||
@@ -696,10 +727,6 @@ async function handleReverseSalesperson(row: Record<string, any>, salespersonId?
|
||||
}
|
||||
}
|
||||
|
||||
function isNegativeCommission(amount?: string | number) {
|
||||
return Number(amount ?? 0) < 0;
|
||||
}
|
||||
|
||||
function formatExpressAddress(row: Record<string, any>) {
|
||||
if (Number(row.delivery_method) === 1) {
|
||||
return row.store?.position || row.store?.name || '到店自提';
|
||||
@@ -709,24 +736,6 @@ function formatExpressAddress(row: Record<string, any>) {
|
||||
return [region, detail].filter(Boolean).join(' ') || '—';
|
||||
}
|
||||
|
||||
function salespersonStatusColor(text: string) {
|
||||
if (text === '已分成') return 'success';
|
||||
if (text === '未分成') return 'warning';
|
||||
if (text === '已冲销') return 'warning';
|
||||
if (text === '未支付') return 'default';
|
||||
return 'default';
|
||||
}
|
||||
|
||||
function formatCommissionRecordDetail(record: Record<string, any>) {
|
||||
const typeText = record.record_type_text ? `${record.record_type_text} · ` : '';
|
||||
const path = record.commission_path_text || '—';
|
||||
const rule = record.commission_rule_text || '—';
|
||||
if (record.commission_mode_text === '比例分成') {
|
||||
return `${typeText}${path} · ${rule}`;
|
||||
}
|
||||
return `${typeText}${path} · ${record.commission_mode_text || '固定单价'} · ${rule}`;
|
||||
}
|
||||
|
||||
const openPrescriptionDetail = (values: number) => {
|
||||
openOrderPopup(
|
||||
PrescriptionDetailModalApi,
|
||||
@@ -742,10 +751,16 @@ const openExportModal = () => {
|
||||
exportModalApi.open();
|
||||
};
|
||||
|
||||
const openRefundModal = (id: number) => {
|
||||
const openRefundModal = (row: Record<string, any>) => {
|
||||
RefundModalApi.setData({
|
||||
values: {
|
||||
order_id: id,
|
||||
order_id: row.id,
|
||||
},
|
||||
orderSummary: {
|
||||
order_no: row.order_no,
|
||||
store_name: row.store?.name,
|
||||
total_pay_price: row.total_pay_price,
|
||||
public_account_pay_enabled: row.store?.public_account_pay_enabled,
|
||||
},
|
||||
gridApi: gridApiProxy,
|
||||
});
|
||||
@@ -1100,7 +1115,7 @@ function buildRowActions(row: Record<string, any>): {
|
||||
icon: 'mingcute:refund-dollar-fill',
|
||||
auth: ['Super Admin', 'Admin'],
|
||||
ifShow: row.is_pay === 1,
|
||||
onClick: openRefundModal.bind(null, row.id),
|
||||
onClick: openRefundModal.bind(null, row),
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -1248,16 +1263,11 @@ function buildRowActions(row: Record<string, any>): {
|
||||
</div>
|
||||
<div class="font-medium">{{ row.order_no }}</div>
|
||||
<div class="text-xs text-[hsl(var(--muted-foreground))]">
|
||||
<Button
|
||||
v-if="row.store?.id"
|
||||
class="!h-auto max-w-[xxx] whitespace-normal break-words !px-0 text-left"
|
||||
size="small"
|
||||
type="link"
|
||||
@click="openStoreCard(row.store.id)"
|
||||
>
|
||||
{{ row.store?.name || '—' }}
|
||||
</Button>
|
||||
<span v-else>{{ row.store?.name || '—' }}</span>
|
||||
<StoreNameLink
|
||||
:store-id="row.store?.id"
|
||||
:name="row.store?.name"
|
||||
@click="openStoreCard"
|
||||
/>
|
||||
</div>
|
||||
<div class="text-xs text-[hsl(var(--muted-foreground))]">
|
||||
下单时间: {{ row.created_at || '—' }}
|
||||
@@ -1344,179 +1354,14 @@ function buildRowActions(row: Record<string, any>): {
|
||||
</div>
|
||||
</template>
|
||||
<template #salesperson="{ row }">
|
||||
<div v-if="row.salesperson?.id" class="space-y-1">
|
||||
<Popover trigger="click" placement="topLeft" overlay-class-name="salesperson-commission-popover">
|
||||
<template #title>
|
||||
<span class="font-semibold">推广员分成</span>
|
||||
</template>
|
||||
<template #content>
|
||||
<div class="w-80 space-y-3 text-sm">
|
||||
<div class="rounded-lg bg-gray-50 p-3">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="font-semibold text-gray-800">直推推广员</span>
|
||||
<span class="font-medium text-orange-600">
|
||||
¥{{ row.salesperson.commission_amount || '0.00' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-1 text-gray-600">{{ row.salesperson.nick_name || '—' }}</div>
|
||||
<div
|
||||
v-if="!(row.salesperson.commission_records?.length > 0)"
|
||||
class="text-gray-400"
|
||||
>
|
||||
暂无分成明细
|
||||
</div>
|
||||
<div
|
||||
v-for="(record, idx) in row.salesperson.commission_records || []"
|
||||
:key="'d-' + idx"
|
||||
class="flex items-start justify-between border-b border-gray-100 py-2 last:border-0"
|
||||
>
|
||||
<div class="min-w-0 flex-1 pr-2">
|
||||
<div class="font-medium text-gray-800">{{ record.drug_name || '—' }}</div>
|
||||
<div class="text-xs text-gray-500">
|
||||
{{ formatCommissionRecordDetail(record) }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="shrink-0 font-medium"
|
||||
:class="isNegativeCommission(record.commission_amount) ? 'text-red-500' : 'text-orange-600'"
|
||||
>
|
||||
¥{{ record.commission_amount }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="row.salesperson.can_reverse_commission" class="mt-2 text-right">
|
||||
<Popconfirm
|
||||
title="确认退回直推推广员分成?"
|
||||
@confirm="handleReverseSalesperson(row)"
|
||||
>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
danger
|
||||
class="!h-auto !px-0 !py-0"
|
||||
:loading="reversingOrderIds.includes(row.id)"
|
||||
>
|
||||
退回分成
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="canViewInviterCommission && row.salesperson.has_inviter && row.salesperson.inviter"
|
||||
class="rounded-lg bg-orange-50 p-3"
|
||||
>
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="font-semibold text-gray-800">
|
||||
邀请人({{ row.salesperson.inviter.inviter_split }}%)
|
||||
</span>
|
||||
<span class="font-medium text-orange-600">
|
||||
¥{{ row.salesperson.inviter.commission_amount || '0.00' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-1 text-gray-600">{{ row.salesperson.inviter.nick_name || '—' }}</div>
|
||||
<div
|
||||
v-if="!(row.salesperson.inviter.commission_records?.length > 0)"
|
||||
class="text-gray-400"
|
||||
>
|
||||
暂无邀请分成明细
|
||||
</div>
|
||||
<div
|
||||
v-for="(record, idx) in row.salesperson.inviter.commission_records || []"
|
||||
:key="'i-' + idx"
|
||||
class="flex items-start justify-between border-b border-orange-100 py-2 last:border-0"
|
||||
>
|
||||
<div class="min-w-0 flex-1 pr-2">
|
||||
<div class="font-medium text-gray-800">{{ record.drug_name || '—' }}</div>
|
||||
<div class="text-xs text-gray-500">
|
||||
{{ formatCommissionRecordDetail(record) }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="shrink-0 font-medium"
|
||||
:class="isNegativeCommission(record.commission_amount) ? 'text-red-500' : 'text-orange-600'"
|
||||
>
|
||||
¥{{ record.commission_amount }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="canViewInviterCommission && row.salesperson.inviter?.can_reverse_commission"
|
||||
class="mt-2 text-right"
|
||||
>
|
||||
<Popconfirm
|
||||
title="确认退回邀请人分成?"
|
||||
@confirm="handleReverseSalesperson(row, row.salesperson.inviter.id)"
|
||||
>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
danger
|
||||
class="!h-auto !px-0 !py-0"
|
||||
:loading="reversingOrderIds.includes(row.id)"
|
||||
>
|
||||
退回邀请分成
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="flex cursor-pointer items-center gap-2 hover:opacity-80">
|
||||
<Image
|
||||
:src="row.salesperson.avatar || '/img/user-default-avatar.png'"
|
||||
:width="32"
|
||||
:height="32"
|
||||
class="shrink-0 rounded-full object-cover"
|
||||
/>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="truncate text-sm font-medium">{{
|
||||
row.salesperson.nick_name || '—'
|
||||
}}</span>
|
||||
<Tag
|
||||
:color="salespersonStatusColor(row.salesperson.commission_status_text)"
|
||||
class="!m-0 shrink-0"
|
||||
>
|
||||
{{ row.salesperson.commission_status_text }}
|
||||
</Tag>
|
||||
</div>
|
||||
<div class="text-sm font-medium text-orange-600">
|
||||
¥{{ row.salesperson.commission_amount || '0.00' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
<Button
|
||||
v-if="
|
||||
row.is_pay === 1 &&
|
||||
row.salesperson_id > 0 &&
|
||||
!row.salesperson.has_commission
|
||||
"
|
||||
class="!h-auto !px-0 !py-0"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="accruingOrderIds.includes(row.id)"
|
||||
@click="handleAccrueSalesperson(row)"
|
||||
>
|
||||
立即分成
|
||||
</Button>
|
||||
<Popconfirm
|
||||
v-else-if="row.is_pay === 1 && row.salesperson.can_reverse_commission"
|
||||
title="确认退回推广员分成?"
|
||||
@confirm="handleReverseSalesperson(row)"
|
||||
>
|
||||
<Button
|
||||
class="!h-auto !px-0 !py-0"
|
||||
type="link"
|
||||
size="small"
|
||||
danger
|
||||
:loading="reversingOrderIds.includes(row.id)"
|
||||
>
|
||||
退回分成
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
<span v-else class="text-sm text-gray-500">
|
||||
{{ row.salesperson?.commission_status_text || '无推广员' }}
|
||||
</span>
|
||||
<SalespersonCommissionPanel
|
||||
:row="row"
|
||||
:can-view-inviter-commission="canViewInviterCommission"
|
||||
:accruing-order-ids="accruingOrderIds"
|
||||
:reversing-order-ids="reversingOrderIds"
|
||||
@accrue="handleAccrueSalesperson"
|
||||
@reverse="handleReverseSalesperson"
|
||||
/>
|
||||
</template>
|
||||
<template #pay-time="{ row }">
|
||||
{{ row?.pay_time || '未支付' }}
|
||||
@@ -1697,6 +1542,9 @@ function buildRowActions(row: Record<string, any>): {
|
||||
:form-values="searchValues"
|
||||
:build-row-actions="buildRowActions"
|
||||
:can-percent-adjust="canRowPercentAdjust"
|
||||
:can-view-inviter-commission="canViewInviterCommission"
|
||||
:accruing-order-ids="accruingOrderIds"
|
||||
:reversing-order-ids="reversingOrderIds"
|
||||
@open-store="openStoreCard"
|
||||
@open-doctor="showOrderDoctorCard"
|
||||
@open-user-patients="openOrderUserPatients"
|
||||
@@ -1705,6 +1553,9 @@ function buildRowActions(row: Record<string, any>): {
|
||||
@toggle-free-shipping="toggleFreeShipping"
|
||||
@percent-adjust="openOrderPercentAdjust"
|
||||
@go-register="goRegisterOrder"
|
||||
@open-china-erp-sync-log="openChinaErpSyncLog"
|
||||
@accrue-salesperson="handleAccrueSalesperson"
|
||||
@reverse-salesperson="handleReverseSalesperson"
|
||||
/>
|
||||
</div>
|
||||
<PercentAdjustDrawer />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { monthToTodayRangeString } from '#/utils/search-time-range';
|
||||
|
||||
import {
|
||||
REGISTER_IS_PAY_OPTIONS,
|
||||
@@ -25,16 +25,12 @@ export const formOptions: VbenFormProps = {
|
||||
schema: [
|
||||
{
|
||||
// 放第一位:时间范围有默认值(本月至今),默认收起时必须始终可见,否则用户不知道当前查的是哪段数据
|
||||
component: 'RangePicker',
|
||||
component: 'SearchTimeRangePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
// 提交纯日期,后端 getWhereBetween 会把结束日扩到当天 23:59:59
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
},
|
||||
defaultValue: [
|
||||
dayjs().startOf('month').format('YYYY-MM-DD'),
|
||||
dayjs().format('YYYY-MM-DD'),
|
||||
],
|
||||
defaultValue: monthToTodayRangeString(),
|
||||
fieldName: 'search_time',
|
||||
label: '时间范围',
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@ export const gridOptions: VxeGridProps<RegisterOrderItem> = {
|
||||
{ field: 'doctor_info.name', title: '开方医生' },
|
||||
{ field: 'doctor_info.depart.name', title: '科室' },
|
||||
{ field: 'user_patient.name', title: '就诊人名称' },
|
||||
{ field: 'store.name', title: '开方诊所', slots: { default: 'store-name' } },
|
||||
{ field: 'store.name', title: '开方诊所', minWidth: 140, slots: { default: 'store-name' } },
|
||||
{ field: 'salesperson', title: '推广员', slots: { default: 'salesperson' } },
|
||||
{ field: 'type', title: '挂号类型', slots: { default: 'type' } },
|
||||
{ field: 'prescription', title: '处方', width: 240, slots: { default: 'prescription'} },
|
||||
|
||||
@@ -19,8 +19,11 @@ import { Button, Image, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { useFreshSearchTime } from '#/composables/use-fresh-search-time';
|
||||
import StoreCardModal from '#/components/store-card/StoreCardModal.vue';
|
||||
import StoreNameLink from '#/components/store-card/StoreNameLink.vue';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { monthToTodayRangeString } from '#/utils/search-time-range';
|
||||
import { useViewMode, ViewModeSwitch } from '#/components/view-mode-switch';
|
||||
import PrescriptionDetail from '#/views/doctor/doctor-reception/components/PrescriptionDetail.vue';
|
||||
import {
|
||||
@@ -95,7 +98,11 @@ function collectDefaultSearchValues(): Record<string, any> {
|
||||
const values: Record<string, any> = {};
|
||||
for (const item of effectiveFormOptions.schema ?? []) {
|
||||
if (item.fieldName && item.defaultValue !== undefined) {
|
||||
values[item.fieldName] = item.defaultValue;
|
||||
if (item.fieldName === 'search_time' && item.defaultValue !== null) {
|
||||
values[item.fieldName] = monthToTodayRangeString();
|
||||
} else {
|
||||
values[item.fieldName] = item.defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return values;
|
||||
@@ -104,6 +111,19 @@ function collectDefaultSearchValues(): Record<string, any> {
|
||||
/** 列表与卡片共用的搜索条件(提交/重置时整体替换,卡片靠 watch 自动拉数) */
|
||||
const searchValues = ref<Record<string, any>>(collectDefaultSearchValues());
|
||||
|
||||
function getFreshSearchTimeDefault() {
|
||||
const item = effectiveFormOptions.schema?.find(
|
||||
(s) => s.fieldName === 'search_time',
|
||||
);
|
||||
if (item?.defaultValue === null) return null;
|
||||
return monthToTodayRangeString();
|
||||
}
|
||||
|
||||
const freshSearchTimeBridge = {
|
||||
resetSearchTime: async () => {},
|
||||
markSearchTimeTouched: () => {},
|
||||
};
|
||||
|
||||
/**
|
||||
* 读搜索表单现值(不要只用 handleSubmit 快照)
|
||||
* 抽出独立 SearchForm 后,列表 query 必须自己取表单值,否则点查询/翻页会丢掉刚填的条件
|
||||
@@ -124,6 +144,11 @@ async function readLiveSearchValues(): Promise<Record<string, any>> {
|
||||
*/
|
||||
const [SearchForm, searchFormApi] = useVbenForm({
|
||||
...effectiveFormOptions,
|
||||
handleValuesChange(_values, fieldsChanged) {
|
||||
if (fieldsChanged?.includes('search_time')) {
|
||||
freshSearchTimeBridge.markSearchTimeTouched();
|
||||
}
|
||||
},
|
||||
handleSubmit: async () => {
|
||||
searchValues.value = await readLiveSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
@@ -131,12 +156,7 @@ const [SearchForm, searchFormApi] = useVbenForm({
|
||||
}
|
||||
},
|
||||
handleReset: async () => {
|
||||
// 自定义 handleReset 会接管默认行为,必须手动还原控件到 defaultValue(reset 为新 API,resetForm 已弃用)
|
||||
await searchFormApi.reset();
|
||||
searchValues.value = collectDefaultSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
gridApi.reload();
|
||||
}
|
||||
await freshSearchTimeBridge.resetSearchTime();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -166,6 +186,22 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridEvents,
|
||||
});
|
||||
|
||||
const freshSearchTime = useFreshSearchTime({
|
||||
formApi: searchFormApi,
|
||||
searchValues,
|
||||
getDefaultRange: getFreshSearchTimeDefault,
|
||||
onRefresh: async () => {
|
||||
searchValues.value = await readLiveSearchValues();
|
||||
if (viewMode.value === 'list') {
|
||||
gridApi.reload();
|
||||
} else {
|
||||
cardListRef.value?.reload?.();
|
||||
}
|
||||
},
|
||||
});
|
||||
freshSearchTimeBridge.resetSearchTime = freshSearchTime.resetSearchTime;
|
||||
freshSearchTimeBridge.markSearchTimeTouched = freshSearchTime.markSearchTimeTouched;
|
||||
|
||||
// 记忆持久化由 useViewMode 内部完成;切回列表时 grid 被 v-if 卸载过需主动重查
|
||||
watch(viewMode, (mode, prev) => {
|
||||
if (mode === 'list' && prev === 'card') {
|
||||
@@ -323,16 +359,11 @@ function rowRefundMeta(row: Record<string, any>) {
|
||||
</TableAction>
|
||||
</template>
|
||||
<template #store-name="{ row }">
|
||||
<Button
|
||||
v-if="row.store?.id || row.store_id"
|
||||
type="link"
|
||||
size="small"
|
||||
class="!px-0"
|
||||
@click="openStoreCard(row.store?.id || row.store_id)"
|
||||
>
|
||||
{{ row.store?.name || '—' }}
|
||||
</Button>
|
||||
<span v-else>{{ row.store?.name || '—' }}</span>
|
||||
<StoreNameLink
|
||||
:store-id="Number(row.store?.id || row.store_id || 0) || undefined"
|
||||
:name="row.store?.name"
|
||||
@click="openStoreCard"
|
||||
/>
|
||||
</template>
|
||||
<template #prescription="{ row }">
|
||||
<div v-for="item in row.prescription" :key="item.id">
|
||||
|
||||
@@ -25,7 +25,10 @@ import DrugFreeShippingCell from '#/views/business/product/_shared/drug-free-shi
|
||||
import ProductInfoCell from '#/views/business/product/_shared/product-info-cell.vue';
|
||||
import WarehouseDrugPriceModal from '#/views/business/warehouse-drug-management/admin/components/modal.vue';
|
||||
import BindListModal from '#/views/system/delivery-warehouse-drug/components/bind-list-modal.vue';
|
||||
import { resolveCentralPrice } from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
import {
|
||||
resolveCentralMarketPrice,
|
||||
resolveCentralPrice,
|
||||
} from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
|
||||
// 导入保健食品管理相关API
|
||||
import {
|
||||
@@ -135,17 +138,20 @@ function handleSyncPinyin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开某产品的配送仓绑定列表(带总仓售价供费用封顶/默认平台费)
|
||||
* 打开某产品的配送仓绑定列表(带总仓售价/供货价供费用封顶与自动算费)
|
||||
* @param autoCreate 为 true 时打开后立刻弹出新增绑定表单
|
||||
*/
|
||||
function openBindList(row: any, autoCreate = false) {
|
||||
const price = resolveCentralPrice(row);
|
||||
const market = resolveCentralMarketPrice(row);
|
||||
bindListModalApi.setData({
|
||||
drug_id: row.id,
|
||||
drug_name: row.drug_name,
|
||||
specification: row.specification,
|
||||
image: row.image,
|
||||
central_price: price,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
values: row,
|
||||
gridApi,
|
||||
autoCreate,
|
||||
|
||||
@@ -18,7 +18,10 @@ import DrugFreeShippingCell from '#/views/business/product/_shared/drug-free-shi
|
||||
import ProductInfoCell from '#/views/business/product/_shared/product-info-cell.vue';
|
||||
import WarehouseDrugPriceModal from '#/views/business/warehouse-drug-management/admin/components/modal.vue';
|
||||
import BindListModal from '#/views/system/delivery-warehouse-drug/components/bind-list-modal.vue';
|
||||
import { resolveCentralPrice } from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
import {
|
||||
resolveCentralMarketPrice,
|
||||
resolveCentralPrice,
|
||||
} from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
|
||||
import {
|
||||
deleteMedicalDevice,
|
||||
@@ -113,17 +116,20 @@ function handleSyncPinyin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开某产品的配送仓绑定列表(带总仓售价供费用封顶/默认平台费)
|
||||
* 打开某产品的配送仓绑定列表(带总仓售价/供货价供费用封顶与自动算费)
|
||||
* @param autoCreate 为 true 时打开后立刻弹出新增绑定表单
|
||||
*/
|
||||
function openBindList(row: any, autoCreate = false) {
|
||||
const price = resolveCentralPrice(row);
|
||||
const market = resolveCentralMarketPrice(row);
|
||||
bindListModalApi.setData({
|
||||
drug_id: row.id,
|
||||
drug_name: row.drug_name,
|
||||
specification: row.specification,
|
||||
image: row.image,
|
||||
central_price: price,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
values: row,
|
||||
gridApi,
|
||||
autoCreate,
|
||||
|
||||
@@ -18,7 +18,10 @@ import DrugFreeShippingCell from '#/views/business/product/_shared/drug-free-shi
|
||||
import ProductInfoCell from '#/views/business/product/_shared/product-info-cell.vue';
|
||||
import WarehouseDrugPriceModal from '#/views/business/warehouse-drug-management/admin/components/modal.vue';
|
||||
import BindListModal from '#/views/system/delivery-warehouse-drug/components/bind-list-modal.vue';
|
||||
import { resolveCentralPrice } from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
import {
|
||||
resolveCentralMarketPrice,
|
||||
resolveCentralPrice,
|
||||
} from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
|
||||
import { deleteNonDrug, exportNonDrugApi, syncNonDrugPinyin } from './api';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
@@ -109,17 +112,20 @@ function handleSyncPinyin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开某产品的配送仓绑定列表(带总仓售价供费用封顶/默认平台费)
|
||||
* 打开某产品的配送仓绑定列表(带总仓售价/供货价供费用封顶与自动算费)
|
||||
* @param autoCreate 为 true 时打开后立刻弹出新增绑定表单
|
||||
*/
|
||||
function openBindList(row: any, autoCreate = false) {
|
||||
const price = resolveCentralPrice(row);
|
||||
const market = resolveCentralMarketPrice(row);
|
||||
bindListModalApi.setData({
|
||||
drug_id: row.id,
|
||||
drug_name: row.drug_name,
|
||||
specification: row.specification,
|
||||
image: row.image,
|
||||
central_price: price,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
values: row,
|
||||
gridApi,
|
||||
autoCreate,
|
||||
|
||||
@@ -17,7 +17,10 @@ import DrugFreeShippingCell from '#/views/business/product/_shared/drug-free-shi
|
||||
import ProductInfoCell from '#/views/business/product/_shared/product-info-cell.vue';
|
||||
import WarehouseDrugPriceModal from '#/views/business/warehouse-drug-management/admin/components/modal.vue';
|
||||
import BindListModal from '#/views/system/delivery-warehouse-drug/components/bind-list-modal.vue';
|
||||
import { resolveCentralPrice } from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
import {
|
||||
resolveCentralMarketPrice,
|
||||
resolveCentralPrice,
|
||||
} from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
|
||||
import { deleteServicePack, syncServicePackPinyin } from './api';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
@@ -105,17 +108,20 @@ function handleSyncPinyin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开某产品的配送仓绑定列表(带总仓售价供费用封顶/默认平台费)
|
||||
* 打开某产品的配送仓绑定列表(带总仓售价/供货价供费用封顶与自动算费)
|
||||
* @param autoCreate 为 true 时打开后立刻弹出新增绑定表单
|
||||
*/
|
||||
function openBindList(row: any, autoCreate = false) {
|
||||
const price = resolveCentralPrice(row);
|
||||
const market = resolveCentralMarketPrice(row);
|
||||
bindListModalApi.setData({
|
||||
drug_id: row.id,
|
||||
drug_name: row.drug_name,
|
||||
specification: row.specification,
|
||||
image: row.image,
|
||||
central_price: price,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
values: row,
|
||||
gridApi,
|
||||
autoCreate,
|
||||
|
||||
@@ -18,7 +18,10 @@ import DrugFreeShippingCell from '#/views/business/product/_shared/drug-free-shi
|
||||
import ProductInfoCell from '#/views/business/product/_shared/product-info-cell.vue';
|
||||
import WarehouseDrugPriceModal from '#/views/business/warehouse-drug-management/admin/components/modal.vue';
|
||||
import BindListModal from '#/views/system/delivery-warehouse-drug/components/bind-list-modal.vue';
|
||||
import { resolveCentralPrice } from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
import {
|
||||
resolveCentralMarketPrice,
|
||||
resolveCentralPrice,
|
||||
} from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
|
||||
import {
|
||||
deleteWesternMedicine,
|
||||
@@ -125,17 +128,20 @@ function handleSyncPinyin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开某药的配送仓绑定列表(带总仓售价供费用封顶/默认平台费)
|
||||
* 打开某药的配送仓绑定列表(带总仓售价/供货价供费用封顶与自动算费)
|
||||
* @param autoCreate 为 true 时打开后立刻弹出新增绑定表单
|
||||
*/
|
||||
function openBindList(row: any, autoCreate = false) {
|
||||
const price = resolveCentralPrice(row);
|
||||
const market = resolveCentralMarketPrice(row);
|
||||
bindListModalApi.setData({
|
||||
drug_id: row.id,
|
||||
drug_name: row.drug_name,
|
||||
specification: row.specification,
|
||||
image: row.image,
|
||||
central_price: price,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
values: row,
|
||||
gridApi,
|
||||
autoCreate,
|
||||
|
||||
@@ -11,6 +11,7 @@ import { Alert, InputNumber, Table, message } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
calcFeeSum,
|
||||
calcPlatformFee,
|
||||
calcPromoFee,
|
||||
} from '#/views/system/delivery-warehouse-drug/config/form';
|
||||
|
||||
@@ -34,6 +35,9 @@ const gridApi = ref<any>(null);
|
||||
const onSuccess = ref<(() => void) | null>(null);
|
||||
|
||||
const saleText = computed(() => `¥${Number(salePrice.value || 0).toFixed(4)}`);
|
||||
const marketText = computed(
|
||||
() => `¥${Number(marketPrice.value || 0).toFixed(4)}`,
|
||||
);
|
||||
|
||||
const columns = [
|
||||
{ title: '配送仓', dataIndex: 'warehouse_name', key: 'warehouse_name', ellipsis: true },
|
||||
@@ -44,15 +48,18 @@ const columns = [
|
||||
];
|
||||
|
||||
/**
|
||||
* 售价变化后自动回填推广费 = 售价 − 报价 − 平台费
|
||||
* 按新公式回填:推广费=售价−供货价,平台费=供货价−报价
|
||||
*/
|
||||
function syncPromo(row: BindRow) {
|
||||
row.promo_fee = calcPromoFee({
|
||||
function syncFees(row: BindRow) {
|
||||
const base = {
|
||||
sale_price: salePrice.value,
|
||||
market_price: marketPrice.value,
|
||||
quote: row.quote,
|
||||
platform_fee: row.platform_fee,
|
||||
promo_fee: row.promo_fee,
|
||||
});
|
||||
platform_fee: row.platform_fee,
|
||||
};
|
||||
row.platform_fee = calcPlatformFee(base);
|
||||
row.promo_fee = calcPromoFee(base);
|
||||
}
|
||||
|
||||
function feeSum(row: BindRow) {
|
||||
@@ -139,12 +146,9 @@ const [Modal, modalApi] = useVbenModal({
|
||||
platform_fee: Number(b.platform_fee || 0),
|
||||
promo_fee: Number(b.promo_fee || 0),
|
||||
};
|
||||
// 按新售价重算推广费默认值
|
||||
if (salePrice.value > 0) {
|
||||
if (!(row.platform_fee > 0)) {
|
||||
row.platform_fee = Number((salePrice.value * 0.05).toFixed(4));
|
||||
}
|
||||
syncPromo(row);
|
||||
// 按新售价/供货价重算两费默认值
|
||||
if (salePrice.value > 0 || marketPrice.value > 0) {
|
||||
syncFees(row);
|
||||
}
|
||||
return row;
|
||||
});
|
||||
@@ -159,7 +163,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
show-icon
|
||||
class="mb-3"
|
||||
message="该药品已绑定配送仓,总仓改价后必须重新填写各仓报价/平台费/推广费后才能保存"
|
||||
:description="`新建议售价 ${saleText};推广费默认=售价−报价−平台费,可微调`"
|
||||
:description="`新建议售价 ${saleText},平台供货价 ${marketText};推广费=售价−供货价,平台费=供货价−报价,可微调`"
|
||||
/>
|
||||
<Table
|
||||
size="small"
|
||||
@@ -177,7 +181,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
:precision="4"
|
||||
class="w-full"
|
||||
size="small"
|
||||
@change="syncPromo(record)"
|
||||
@change="syncFees(record)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'platform_fee'">
|
||||
@@ -187,7 +191,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
:precision="4"
|
||||
class="w-full"
|
||||
size="small"
|
||||
@change="syncPromo(record)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'promo_fee'">
|
||||
|
||||
@@ -20,7 +20,10 @@ import {
|
||||
updateWarehouseDrugManagementStatusApi
|
||||
} from './api';
|
||||
import BindListModalDemo from '#/views/system/delivery-warehouse-drug/components/bind-list-modal.vue';
|
||||
import { resolveCentralPrice } from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
import {
|
||||
resolveCentralMarketPrice,
|
||||
resolveCentralPrice,
|
||||
} from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import ExcelUpload from './components/ExcelUpload.vue';
|
||||
@@ -128,6 +131,8 @@ function openBindList(row: Record<string, any>, autoCreate = false) {
|
||||
message.warning('无法识别药品');
|
||||
return;
|
||||
}
|
||||
const market =
|
||||
(resolveCentralMarketPrice(row) ?? Number(row.market_price || 0)) || null;
|
||||
bindListModalApi.setData({
|
||||
drug_id: drugId,
|
||||
drug_name: drug.drug_name || row.drug_name || '',
|
||||
@@ -135,6 +140,8 @@ function openBindList(row: Record<string, any>, autoCreate = false) {
|
||||
image: drug.image || '',
|
||||
// ?? 与 || 混用必须加括号,否则 vue/compiler-sfc 打包报错
|
||||
central_price: (resolveCentralPrice(row) ?? Number(row.price || 0)) || null,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
values: row,
|
||||
gridApi,
|
||||
autoCreate,
|
||||
|
||||
@@ -582,6 +582,47 @@ export async function getUserPatientClaimQrcodeApi(userPatientId: number) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 医生创建过的全部就诊人(分页) */
|
||||
export async function getDoctorCreatedUserPatientListApi(params: {
|
||||
keyword?: string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}) {
|
||||
return requestClient.get<{
|
||||
items: Array<{
|
||||
id: number;
|
||||
user_id: number;
|
||||
name: string;
|
||||
mobile?: string;
|
||||
sex?: number;
|
||||
age?: number;
|
||||
created_at?: string;
|
||||
is_claimed: number;
|
||||
latest_register_id: number;
|
||||
latest_register_status: number;
|
||||
latest_register_is_pay: number;
|
||||
}>;
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
}>(`${prefix}doctor-created-user-patient-list`, { params });
|
||||
}
|
||||
|
||||
/** 选择医生创建的就诊人开始线下接诊 */
|
||||
export async function startOfflineReceptionByPatientApi(data: {
|
||||
user_patient_id: number;
|
||||
waive_register_fee?: number;
|
||||
}) {
|
||||
return requestClient.post<{
|
||||
user_patient_id: number;
|
||||
register_id: number;
|
||||
is_pay: number;
|
||||
status: number;
|
||||
action: 'claim_qrcode' | 'proxy_pay' | 'reception';
|
||||
price: string;
|
||||
}>(`${prefix}start-offline-reception-by-patient`, data);
|
||||
}
|
||||
|
||||
/** 医生代支付小程序码(患者端扫码付) */
|
||||
export async function getProxyPayQrcodeApi(orderId: number) {
|
||||
return requestClient.post<any>(`${prefix}proxy-pay-qrcode`, {
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 医生创建就诊人记录:搜索 + 分页列表 + 选择接诊
|
||||
* 未支付时回调父页打开认领码;已可接诊时回调父页选中挂号
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, Empty, Input, message, Pagination, Spin, Table, Tag } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
getDoctorCreatedUserPatientListApi,
|
||||
startOfflineReceptionByPatientApi,
|
||||
} from '#/views/doctor/doctor-reception/api';
|
||||
|
||||
export type DoctorCreatedPatientStartResult = {
|
||||
user_patient_id: number;
|
||||
register_id: number;
|
||||
is_pay: number;
|
||||
status: number;
|
||||
action: 'claim_qrcode' | 'proxy_pay' | 'reception';
|
||||
price: string;
|
||||
};
|
||||
|
||||
type ListItem = {
|
||||
id: number;
|
||||
name: string;
|
||||
mobile?: string;
|
||||
sex?: number;
|
||||
age?: number;
|
||||
created_at?: string;
|
||||
is_claimed: number;
|
||||
latest_register_status: number;
|
||||
};
|
||||
|
||||
const loading = ref(false);
|
||||
const startingId = ref(0);
|
||||
const keyword = ref('');
|
||||
const page = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const total = ref(0);
|
||||
const list = ref<ListItem[]>([]);
|
||||
const onStartCb = ref<
|
||||
null | ((res: DoctorCreatedPatientStartResult) => void | Promise<void>)
|
||||
>(null);
|
||||
|
||||
const columns = [
|
||||
{ title: '姓名', dataIndex: 'name', key: 'name', width: 100 },
|
||||
{ title: '手机', dataIndex: 'mobile', key: 'mobile', width: 120 },
|
||||
{ title: '年龄', dataIndex: 'age', key: 'age', width: 60 },
|
||||
{ title: '认领', key: 'is_claimed', width: 80 },
|
||||
{ title: '最近挂号', key: 'register_status', width: 100 },
|
||||
{ title: '创建时间', dataIndex: 'created_at', key: 'created_at', width: 160 },
|
||||
{ title: '操作', key: 'action', width: 90, fixed: 'right' as const },
|
||||
];
|
||||
|
||||
/**
|
||||
* 挂号状态文案(与 RegisterStatusEnum 对齐)
|
||||
*/
|
||||
function registerStatusText(status: number): string {
|
||||
const map: Record<number, string> = {
|
||||
0: '待支付',
|
||||
1: '待接诊',
|
||||
2: '接诊中',
|
||||
3: '已结束',
|
||||
4: '已取消',
|
||||
7: '已拒诊',
|
||||
};
|
||||
return map[status] || '—';
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取医生创建记录列表
|
||||
*/
|
||||
async function fetchList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getDoctorCreatedUserPatientListApi({
|
||||
keyword: keyword.value.trim(),
|
||||
page: page.value,
|
||||
page_size: pageSize.value,
|
||||
});
|
||||
list.value = Array.isArray(res?.items) ? res.items : [];
|
||||
total.value = Number(res?.total || 0);
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '加载创建记录失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
page.value = 1;
|
||||
fetchList();
|
||||
}
|
||||
|
||||
function onPageChange(p: number, ps: number) {
|
||||
page.value = p;
|
||||
pageSize.value = ps;
|
||||
fetchList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择该就诊人开始接诊:后端复用或新建挂号
|
||||
*/
|
||||
async function handleStart(row: ListItem) {
|
||||
if (!row?.id) return;
|
||||
startingId.value = row.id;
|
||||
try {
|
||||
const res = await startOfflineReceptionByPatientApi({
|
||||
user_patient_id: row.id,
|
||||
waive_register_fee: 1,
|
||||
});
|
||||
message.success('操作成功');
|
||||
modalApi.close();
|
||||
await onStartCb.value?.(res as DoctorCreatedPatientStartResult);
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '接诊失败');
|
||||
} finally {
|
||||
startingId.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
showConfirmButton: false,
|
||||
cancelText: '关闭',
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) return;
|
||||
const data = modalApi.getData() as {
|
||||
onStart?: (res: DoctorCreatedPatientStartResult) => void | Promise<void>;
|
||||
};
|
||||
onStartCb.value = data?.onStart || null;
|
||||
keyword.value = '';
|
||||
page.value = 1;
|
||||
await fetchList();
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[860px]" title="医生创建记录">
|
||||
<div class="mb-3 flex gap-2">
|
||||
<Input
|
||||
v-model:value="keyword"
|
||||
allow-clear
|
||||
placeholder="姓名 / 手机号"
|
||||
class="max-w-xs"
|
||||
@press-enter="onSearch"
|
||||
/>
|
||||
<Button type="primary" @click="onSearch">搜索</Button>
|
||||
</div>
|
||||
<Spin :spinning="loading">
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="list"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
size="small"
|
||||
:scroll="{ x: 720 }"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'is_claimed'">
|
||||
<Tag :color="record.is_claimed ? 'success' : 'warning'">
|
||||
{{ record.is_claimed ? '已认领' : '未认领' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'register_status'">
|
||||
{{ registerStatusText(record.latest_register_status) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="startingId === record.id"
|
||||
@click="handleStart(record)"
|
||||
>
|
||||
接诊
|
||||
</Button>
|
||||
</template>
|
||||
</template>
|
||||
<template #emptyText>
|
||||
<Empty description="暂无创建记录" />
|
||||
</template>
|
||||
</Table>
|
||||
<div v-if="total > 0" class="mt-3 flex justify-end">
|
||||
<Pagination
|
||||
:current="page"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
size="small"
|
||||
show-size-changer
|
||||
@change="onPageChange"
|
||||
/>
|
||||
</div>
|
||||
</Spin>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
Col,
|
||||
@@ -42,6 +43,7 @@ import {
|
||||
SelectOption,
|
||||
Modal as AntModal,
|
||||
Tag,
|
||||
Tooltip,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Textarea,
|
||||
@@ -74,6 +76,7 @@ import {
|
||||
getPrescriptionTypeOptionsApi,
|
||||
getPatientItem,
|
||||
getPatientList,
|
||||
getDoctorCreatedUserPatientListApi,
|
||||
getPrescriptionInfoApi,
|
||||
getProcessRuleList,
|
||||
getProductListDoctorReception,
|
||||
@@ -95,8 +98,11 @@ import RefusalOfTreatmentModal
|
||||
from "#/views/doctor/doctor-reception/components/RefusalOfTreatmentModal.vue";
|
||||
import CreateUserPatientModal from './components/CreateUserPatientModal.vue';
|
||||
import ClaimQrcodeModal from './components/ClaimQrcodeModal.vue';
|
||||
import DoctorCreatedPatientModal from './components/DoctorCreatedPatientModal.vue';
|
||||
import type { DoctorCreatedPatientStartResult } from './components/DoctorCreatedPatientModal.vue';
|
||||
import ProxyPayQrcodeModal from './components/ProxyPayQrcodeModal.vue';
|
||||
import ApplyPublicAccountPayModal from '#/views/finance/public-account-pay/components/apply-modal.vue';
|
||||
import { applyPublicAccountPay } from '#/views/finance/public-account-pay/api';
|
||||
// 常用方选择弹窗组件
|
||||
import CommonPrescriptionModal from './components/CommonPrescriptionModal.vue';
|
||||
import GoldenFormulaModal from './components/GoldenFormulaModal.vue';
|
||||
@@ -229,6 +235,20 @@ function restoreRxMrTab(registerId: number) {
|
||||
const category = ref(1);
|
||||
const listType = ref(1);
|
||||
const receptionStatus = ref(0);
|
||||
/** 医生创建就诊人记录总数(用于侧栏「创建记录」角标,未支付挂号不在左侧列表) */
|
||||
const doctorCreatedRecordTotal = ref(0);
|
||||
/**
|
||||
* 拉取医生创建记录总数:侧栏角标提示,避免医生以为创建失败
|
||||
*/
|
||||
async function loadDoctorCreatedRecordTotal() {
|
||||
try {
|
||||
const res = await getDoctorCreatedUserPatientListApi({ page: 1, page_size: 1 });
|
||||
doctorCreatedRecordTotal.value = Number(res?.total || 0);
|
||||
} catch {
|
||||
doctorCreatedRecordTotal.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const updateTabType = ref(false);
|
||||
// 患者数据
|
||||
const patients = ref<Patient[]>([]);
|
||||
@@ -336,7 +356,9 @@ const allowInsuranceCategory = ref(0);
|
||||
/** 是否开启订单百分比调价 */
|
||||
const priceAdjustEnabled = ref(false);
|
||||
const publicAccountPayEnabled = ref(false);
|
||||
const publicAccountDailyMode = ref(false);
|
||||
const publicAccountPayTrigger = ref<'immediate' | 'doctor_confirm'>('immediate');
|
||||
const publicAccountBillMode = ref<'order' | 'daily'>('order');
|
||||
const publicAccountPaySubmitting = ref(false);
|
||||
/** 开方购物车整单价格比例,100=原价 */
|
||||
const priceDiscount = ref(100);
|
||||
const { config: priceAdjustConfig, loadByStoreId, applyRatioToDrugs: applyRatioDrugs } = useOrderPriceAdjust();
|
||||
@@ -411,7 +433,12 @@ async function fetchStoreSeeRate() {
|
||||
allowInsuranceCategory.value = Number(res?.allow_insurance_category ?? 0);
|
||||
priceAdjustEnabled.value = Number(res?.enable_order_price_percent_adjust ?? 0) === 1;
|
||||
publicAccountPayEnabled.value = Number(res?.public_account_pay_enabled ?? 0) === 1;
|
||||
publicAccountDailyMode.value = String(res?.public_account_bill_mode || '') === 'daily';
|
||||
publicAccountPayTrigger.value =
|
||||
String(res?.public_account_pay_trigger || '') === 'doctor_confirm'
|
||||
? 'doctor_confirm'
|
||||
: 'immediate';
|
||||
publicAccountBillMode.value =
|
||||
String(res?.public_account_bill_mode || '') === 'daily' ? 'daily' : 'order';
|
||||
// 有挂号时 vip 已按履约诊所返回,供病历/AI/金方门控
|
||||
receptionVip.value = res?.vip ?? null;
|
||||
await loadByStoreId(myStoreId.value);
|
||||
@@ -503,6 +530,7 @@ async function handleFloatTransferImport(payload: {
|
||||
|
||||
onMounted(() => {
|
||||
registerDoctorTransferImportHandler(handleFloatTransferImport);
|
||||
loadDoctorCreatedRecordTotal();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -804,6 +832,14 @@ const setVisible = (value, instruction = ''): void => {
|
||||
*/
|
||||
const sentPrescriptionInfo = ref<any>(null);
|
||||
|
||||
/** 开方成功页默认可结束接诊;工作台仅在接诊中展示 */
|
||||
const canEndReception = computed(() => {
|
||||
if (tabType.value === 3 && sentPrescriptionInfo.value) {
|
||||
return true;
|
||||
}
|
||||
return receptionStatus.value === 2;
|
||||
});
|
||||
|
||||
/**
|
||||
* 选择患者:已接诊直接进开方工作台;未接诊进轻量接诊操作区(不再进旧患者信息大页)
|
||||
*/
|
||||
@@ -1387,6 +1423,11 @@ const [ClaimQrcodeModals, ClaimQrcodeModalApi] = useVbenModal({
|
||||
connectedComponent: ClaimQrcodeModal,
|
||||
});
|
||||
|
||||
/** 医生创建就诊人记录弹窗 */
|
||||
const [DoctorCreatedPatientModals, DoctorCreatedPatientModalApi] = useVbenModal({
|
||||
connectedComponent: DoctorCreatedPatientModal,
|
||||
});
|
||||
|
||||
/** 医生代支付码弹窗 */
|
||||
const [ProxyPayQrcodeModals, ProxyPayQrcodeModalApi] = useVbenModal({
|
||||
connectedComponent: ProxyPayQrcodeModal,
|
||||
@@ -1454,6 +1495,7 @@ function openCreateUserPatientModal() {
|
||||
} else {
|
||||
message.warning('已创建,请在列表中手动选择');
|
||||
}
|
||||
loadDoctorCreatedRecordTotal();
|
||||
})
|
||||
.catch((e: any) => {
|
||||
message.error(e?.message || '刷新患者列表失败');
|
||||
@@ -1466,11 +1508,51 @@ function openCreateUserPatientModal() {
|
||||
});
|
||||
ClaimQrcodeModalApi.open();
|
||||
refreshPatientList();
|
||||
loadDoctorCreatedRecordTotal();
|
||||
},
|
||||
});
|
||||
CreateUserPatientModalApi.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理「创建记录」选择接诊后的分流:可接诊进列表;未支付弹认领码
|
||||
*/
|
||||
async function handleDoctorCreatedPatientStart(res: DoctorCreatedPatientStartResult) {
|
||||
const registerId = Number(res?.register_id || 0);
|
||||
const userPatientId = Number(res?.user_patient_id || 0);
|
||||
if (res?.action === 'claim_qrcode' && userPatientId > 0) {
|
||||
ClaimQrcodeModalApi.setData({ user_patient_id: userPatientId });
|
||||
ClaimQrcodeModalApi.open();
|
||||
refreshPatientList();
|
||||
return;
|
||||
}
|
||||
if (registerId < 1) {
|
||||
message.warning('未获取到挂号信息');
|
||||
return;
|
||||
}
|
||||
listType.value = 1;
|
||||
try {
|
||||
const list = await getPatientList({ type: listType.value });
|
||||
patients.value = Array.isArray(list) ? list : [];
|
||||
const hit = patients.value.find((p) => Number(p.id) === registerId);
|
||||
if (hit) {
|
||||
selectPatient(hit);
|
||||
} else {
|
||||
message.warning('已创建挂号,请在列表中手动选择');
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '刷新患者列表失败');
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开医生创建记录弹窗 */
|
||||
function openDoctorCreatedPatientModal() {
|
||||
DoctorCreatedPatientModalApi.setData({
|
||||
onStart: handleDoctorCreatedPatientStart,
|
||||
});
|
||||
DoctorCreatedPatientModalApi.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前就诊人是否未认领(user_id=0)
|
||||
* 认领码入口仅在未认领时出现在右侧工具栏
|
||||
@@ -1498,7 +1580,7 @@ function openProxyPayQrcode(orderId: number) {
|
||||
ProxyPayQrcodeModalApi.open();
|
||||
}
|
||||
|
||||
/** 开方成功页申请公账支付(付款凭证选填) */
|
||||
/** 开方成功页申请公账支付(一单一结:弹窗可选凭证) */
|
||||
function openApplyPublicAccountPay() {
|
||||
const info = sentPrescriptionInfo.value || {};
|
||||
const oid = Number(info.order_id || 0);
|
||||
@@ -1510,10 +1592,46 @@ function openApplyPublicAccountPay() {
|
||||
order_id: oid,
|
||||
order_no: info.order_no,
|
||||
total_pay_price: info.total_pay_price,
|
||||
bill_mode: 'order',
|
||||
});
|
||||
ApplyPublicAccountPayModalApi.open();
|
||||
}
|
||||
|
||||
/** 按天先用后付:一键确认公账已支付,无需上传凭证 */
|
||||
function confirmDailyPublicAccountPay() {
|
||||
const info = sentPrescriptionInfo.value || {};
|
||||
const oid = Number(info.order_id || 0);
|
||||
if (!oid) {
|
||||
message.error('订单ID无效');
|
||||
return;
|
||||
}
|
||||
AntModal.confirm({
|
||||
title: '确认公账已支付',
|
||||
content: `订单 ${info.order_no || oid} 将标记为已支付,并计入当日日汇总。`,
|
||||
okText: '确认已支付',
|
||||
cancelText: '取消',
|
||||
async onOk() {
|
||||
publicAccountPaySubmitting.value = true;
|
||||
try {
|
||||
const res = await applyPublicAccountPay({
|
||||
order_id: oid,
|
||||
apply_remark: '医生确认公账已支付',
|
||||
});
|
||||
message.success(
|
||||
res?.bill_mode === 'daily'
|
||||
? '订单已标记为已支付,将计入当日日汇总'
|
||||
: '已提交公账支付申请',
|
||||
);
|
||||
if (sentPrescriptionInfo.value && res?.bill_mode === 'daily') {
|
||||
sentPrescriptionInfo.value = { ...sentPrescriptionInfo.value, is_pay: 1 };
|
||||
}
|
||||
} finally {
|
||||
publicAccountPaySubmitting.value = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开金方导入弹窗(VIP:golden_formula);仅中药处方可用
|
||||
*/
|
||||
@@ -2164,18 +2282,33 @@ function refuseReception() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束诊断
|
||||
* 结束接诊(线下接诊结束诊断,挂号 status → 已结束)
|
||||
*/
|
||||
function endOfDiagnosis() {
|
||||
endOfDiagnosisApi(localStorage.getItem(`doctorReception-id`)).then(
|
||||
(value) => {
|
||||
message.success('接诊成功');
|
||||
const registerId = localStorage.getItem(`doctorReception-id`);
|
||||
if (!registerId) {
|
||||
message.warning('未找到当前挂号,无法结束接诊');
|
||||
return;
|
||||
}
|
||||
const patientName =
|
||||
activePatient.value?.name ||
|
||||
sentPrescriptionInfo.value?.patient_name ||
|
||||
'患者';
|
||||
AntModal.confirm({
|
||||
title: '确认结束接诊',
|
||||
content: `确定要结束${patientName}的接诊吗?`,
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
await endOfDiagnosisApi(registerId);
|
||||
message.success('结束接诊成功');
|
||||
updateTabType.value = false;
|
||||
sentPrescriptionInfo.value = null;
|
||||
receptionStatus.value = 3;
|
||||
getPatientListByReception();
|
||||
receptionStatus.value = 2;
|
||||
tabType.value = 0;
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// 基础配置
|
||||
@@ -3259,7 +3392,11 @@ const leftShow = computed(() => leftPinned.value || leftHover.value);
|
||||
|
||||
function getDoctorReceptionLeftPinned() {
|
||||
const v = localStorage.getItem('doctorReceptionLeftPinned');
|
||||
leftPinned.value = v === 'true';
|
||||
// 无本地偏好时默认固定展开,避免「当前/历史」就诊人列表默认被侧栏收起藏住
|
||||
leftPinned.value = v === null ? true : v === 'true';
|
||||
if (leftPinned.value) {
|
||||
leftHover.value = true;
|
||||
}
|
||||
}
|
||||
getDoctorReceptionLeftPinned();
|
||||
|
||||
@@ -3313,6 +3450,7 @@ function onStoreSelectOpenChange(open: boolean) {
|
||||
<RefusalOfTreatmentModals />
|
||||
<CreateUserPatientModals />
|
||||
<ClaimQrcodeModals />
|
||||
<DoctorCreatedPatientModals />
|
||||
<ProxyPayQrcodeModals />
|
||||
<ApplyPublicAccountPayModals />
|
||||
<InfoModalComponent />
|
||||
@@ -3382,6 +3520,23 @@ function onStoreSelectOpenChange(open: boolean) {
|
||||
<UserAddOutlined />
|
||||
就诊人
|
||||
</Button>
|
||||
<Tooltip title="未支付挂号不会出现在左侧列表,请在此查看并选择接诊">
|
||||
<Badge
|
||||
:count="doctorCreatedRecordTotal"
|
||||
:overflow-count="99"
|
||||
:offset="[-4, 2]"
|
||||
>
|
||||
<!-- 必须带 type=primary:裸 ghost 默认文字/边框透明,只有悬停才看得见 -->
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
ghost
|
||||
@click="openDoctorCreatedPatientModal"
|
||||
>
|
||||
创建记录
|
||||
</Button>
|
||||
</Badge>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div
|
||||
v-for="(patient, index) in patients"
|
||||
@@ -3527,14 +3682,14 @@ function onStoreSelectOpenChange(open: boolean) {
|
||||
认领码
|
||||
</Button>
|
||||
<Button
|
||||
v-if="receptionStatus === 2"
|
||||
v-if="canEndReception"
|
||||
type="link"
|
||||
size="small"
|
||||
danger
|
||||
@click="endOfDiagnosis"
|
||||
>
|
||||
<StopOutlined />
|
||||
结束诊断
|
||||
结束接诊
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -4397,7 +4552,16 @@ function onStoreSelectOpenChange(open: boolean) {
|
||||
<p class="rx-sent-sub">已推送到患者微信 · 支付完成后门店按方发药</p>
|
||||
<div class="rx-sent-pills">
|
||||
<Button shape="round" size="small" @click="openPatientRxHistoryDrawer">处方记录</Button>
|
||||
<Button shape="round" size="small" danger @click="endOfDiagnosis">结束诊断</Button>
|
||||
<Button
|
||||
v-if="canEndReception"
|
||||
shape="round"
|
||||
size="small"
|
||||
danger
|
||||
@click="endOfDiagnosis"
|
||||
>
|
||||
<StopOutlined />
|
||||
结束接诊
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 卡 2:订单明细(label 加粗深色 / 值灰色,合计行大号金额) -->
|
||||
@@ -4446,7 +4610,26 @@ function onStoreSelectOpenChange(open: boolean) {
|
||||
v-if="
|
||||
sentPrescriptionInfo?.order_id &&
|
||||
publicAccountPayEnabled &&
|
||||
!publicAccountDailyMode &&
|
||||
publicAccountPayTrigger === 'doctor_confirm' &&
|
||||
publicAccountBillMode === 'daily' &&
|
||||
Number(sentPrescriptionInfo?.is_pay) !== 1
|
||||
"
|
||||
type="primary"
|
||||
shape="round"
|
||||
size="large"
|
||||
class="rx-sent-next"
|
||||
:loading="publicAccountPaySubmitting"
|
||||
@click="confirmDailyPublicAccountPay"
|
||||
>
|
||||
<BankOutlined />
|
||||
公账支付
|
||||
</Button>
|
||||
<Button
|
||||
v-if="
|
||||
sentPrescriptionInfo?.order_id &&
|
||||
publicAccountPayEnabled &&
|
||||
publicAccountPayTrigger === 'doctor_confirm' &&
|
||||
publicAccountBillMode === 'order' &&
|
||||
Number(sentPrescriptionInfo?.is_pay) !== 1
|
||||
"
|
||||
shape="round"
|
||||
@@ -4458,6 +4641,17 @@ function onStoreSelectOpenChange(open: boolean) {
|
||||
申请公账支付
|
||||
</Button>
|
||||
<Button shape="round" size="large" class="rx-sent-next" @click="tabType = 2">继续开方</Button>
|
||||
<Button
|
||||
v-if="canEndReception"
|
||||
danger
|
||||
shape="round"
|
||||
size="large"
|
||||
class="rx-sent-next"
|
||||
@click="endOfDiagnosis"
|
||||
>
|
||||
<StopOutlined />
|
||||
结束接诊
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Page>
|
||||
@@ -4817,6 +5011,7 @@ function onStoreSelectOpenChange(open: boolean) {
|
||||
.rx-sent-pills {
|
||||
margin-top: 18px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
}
|
||||
@@ -4871,17 +5066,17 @@ function onStoreSelectOpenChange(open: boolean) {
|
||||
font-weight: 600;
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
/* 底部操作:主按钮胶囊撑满(对齐 C 端底部通栏「确认」钮),次按钮等宽排布 */
|
||||
/* 底部操作:按钮多时自动换行,避免撑破成功页卡片 */
|
||||
.rx-sent-ops {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.rx-sent-main {
|
||||
flex: 1.6;
|
||||
}
|
||||
.rx-sent-main,
|
||||
.rx-sent-next {
|
||||
flex: 1;
|
||||
flex: 1 1 calc(50% - 5px);
|
||||
min-width: 140px;
|
||||
}
|
||||
/* Page 根下的内容区:未开 autoContentHeight 时 class 是 flex-1(开了才是 h-full),
|
||||
两种都要命中,否则「固定顶栏 + 内容滚动」的高度链路断裂,长处方整页无法滚动 */
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
|
||||
export const formOptions: VbenFormProps = {
|
||||
// 默认展开
|
||||
collapsed: false,
|
||||
schema: [
|
||||
{
|
||||
component: 'RangePicker',
|
||||
component: 'SearchTimeRangePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD', // 确保格式与你需要的一致
|
||||
format: 'YYYY-MM-DD',
|
||||
},
|
||||
defaultValue: [dayjs().startOf('month'), dayjs()],
|
||||
defaultValue: monthToTodayRangeDayjs(),
|
||||
fieldName: 'search_time',
|
||||
label: '时间范围',
|
||||
},
|
||||
|
||||
@@ -9,7 +9,9 @@ import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Button, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { useFreshSearchTime } from '#/composables/use-fresh-search-time';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
import { getChargeCashPayRecordListApi } from '#/views/finance/charge-cash-pay-record/api';
|
||||
import StatisticsReconciliation from '#/views/finance/reconciliation/components/statistics.vue';
|
||||
import WithdrawalRelationDetail from '#/views/finance/withdrawal/components/withdrawal-relation-detail.vue';
|
||||
@@ -18,11 +20,34 @@ import { useWithdrawOrderDetailModals } from '#/views/finance/withdrawal/utils/u
|
||||
import { formOptions } from './config/search';
|
||||
import { gridOptions } from './config/table';
|
||||
|
||||
const freshSearchTimeBridge = {
|
||||
resetSearchTime: async () => {},
|
||||
markSearchTimeTouched: () => {},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
formOptions: {
|
||||
...formOptions,
|
||||
handleValuesChange(_values, fieldsChanged) {
|
||||
if (fieldsChanged?.includes('search_time')) {
|
||||
freshSearchTimeBridge.markSearchTimeTouched();
|
||||
}
|
||||
},
|
||||
handleReset: async () => {
|
||||
await freshSearchTimeBridge.resetSearchTime();
|
||||
},
|
||||
},
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const freshSearchTime = useFreshSearchTime({
|
||||
formApi: gridApi.formApi,
|
||||
getDefaultRange: () => monthToTodayRangeDayjs(),
|
||||
onRefresh: () => gridApi.reload(),
|
||||
});
|
||||
freshSearchTimeBridge.resetSearchTime = freshSearchTime.resetSearchTime;
|
||||
freshSearchTimeBridge.markSearchTimeTouched = freshSearchTime.markSearchTimeTouched;
|
||||
|
||||
const statistics = ref();
|
||||
|
||||
const { OrderDetailModal, RegisterDetailModal, TraceDrawer, openOrderDetail } =
|
||||
|
||||
@@ -6,14 +6,14 @@ import { ref } from 'vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { DatePicker, Form, message } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
|
||||
import { generateDepartmentFinanceReportApi } from '#/views/finance/department-finance/api';
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
/** 默认统计区间:当月1日 ~ 今天(与对账单一致) */
|
||||
const searchTime = ref<[Dayjs, Dayjs]>([dayjs().startOf('month'), dayjs()]);
|
||||
const searchTime = ref<[Dayjs, Dayjs]>(monthToTodayRangeDayjs());
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
title: '手动生成部门财务报表',
|
||||
@@ -44,7 +44,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
},
|
||||
onOpenChange(isOpen) {
|
||||
if (isOpen) {
|
||||
searchTime.value = [dayjs().startOf('month'), dayjs()];
|
||||
searchTime.value = monthToTodayRangeDayjs();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
|
||||
export const formOptions: VbenFormProps = {
|
||||
// 默认展开
|
||||
collapsed: false,
|
||||
schema: [
|
||||
{
|
||||
component: 'RangePicker',
|
||||
component: 'SearchTimeRangePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD', // 确保格式与你需要的一致
|
||||
format: 'YYYY-MM-DD',
|
||||
},
|
||||
defaultValue: [dayjs().startOf('month'), dayjs()],
|
||||
defaultValue: monthToTodayRangeDayjs(),
|
||||
fieldName: 'search_time',
|
||||
label: '时间范围',
|
||||
},
|
||||
|
||||
@@ -6,18 +6,43 @@ import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Button, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { useFreshSearchTime } from '#/composables/use-fresh-search-time';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
import DetailModal from '#/views/business/order/product-order/components/detail.vue';
|
||||
import StatisticsReconciliation from '#/views/finance/reconciliation/components/statistics.vue';
|
||||
|
||||
import { formOptions } from './config/search';
|
||||
import { gridOptions } from './config/table';
|
||||
|
||||
const freshSearchTimeBridge = {
|
||||
resetSearchTime: async () => {},
|
||||
markSearchTimeTouched: () => {},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
formOptions: {
|
||||
...formOptions,
|
||||
handleValuesChange(_values, fieldsChanged) {
|
||||
if (fieldsChanged?.includes('search_time')) {
|
||||
freshSearchTimeBridge.markSearchTimeTouched();
|
||||
}
|
||||
},
|
||||
handleReset: async () => {
|
||||
await freshSearchTimeBridge.resetSearchTime();
|
||||
},
|
||||
},
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const freshSearchTime = useFreshSearchTime({
|
||||
formApi: gridApi.formApi,
|
||||
getDefaultRange: () => monthToTodayRangeDayjs(),
|
||||
onRefresh: () => gridApi.reload(),
|
||||
});
|
||||
freshSearchTimeBridge.resetSearchTime = freshSearchTime.resetSearchTime;
|
||||
freshSearchTimeBridge.markSearchTimeTouched = freshSearchTime.markSearchTimeTouched;
|
||||
|
||||
const statistics = ref();
|
||||
|
||||
const [OrderDetailModal, OrderDetailModalApi] = useVbenModal({
|
||||
|
||||
@@ -99,3 +99,8 @@ export async function confirmPublicAccountDailyBill(data: Record<string, any>) {
|
||||
export async function cancelPublicAccountDailyBill(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}daily-cancel`, data);
|
||||
}
|
||||
|
||||
/** 日账单变动记录 */
|
||||
export async function getPublicAccountDailyChangeLog(data: Record<string, any>) {
|
||||
return requestClient.get<any>(`${prefix}daily-change-log`, { params: data });
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ const TextArea = Input.TextArea;
|
||||
const orderId = ref(0);
|
||||
const orderNo = ref('');
|
||||
const amount = ref('');
|
||||
const billMode = ref<'order' | 'daily'>('order');
|
||||
const voucherUrls = ref<string[]>([]);
|
||||
const applyRemark = ref('');
|
||||
|
||||
@@ -56,6 +57,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
orderId.value = Number(data.order_id || 0);
|
||||
orderNo.value = String(data.order_no || '');
|
||||
amount.value = String(data.total_pay_price || data.order_amount || '');
|
||||
billMode.value = data.bill_mode === 'daily' ? 'daily' : 'order';
|
||||
voucherUrls.value = [];
|
||||
applyRemark.value = '';
|
||||
},
|
||||
@@ -76,9 +78,9 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
按天模式:提交后订单立即变为已支付,公账金额等日汇总确认再入账。按订单模式:提交后等管理员确认到账,确认前患者无法再微信/易票联支付。
|
||||
提交后等待管理员确认到账;确认前患者无法再微信/易票联支付。付款凭证可选。
|
||||
</p>
|
||||
<div>
|
||||
<div v-if="billMode === 'order'">
|
||||
<div class="mb-1 font-medium text-foreground">付款凭证(选填)</div>
|
||||
<UploadDraggerPaste
|
||||
v-model="voucherUrls"
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 公账日账单变动记录抽屉:按 daily_bill_id 或 merge_id 拉取 Timeline
|
||||
*/
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { Drawer, Empty, Spin, Timeline } from 'ant-design-vue';
|
||||
|
||||
import { getPublicAccountDailyChangeLog } from '../api';
|
||||
|
||||
defineOptions({ name: 'DailyChangeLogDrawer' });
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
dailyBillId?: number;
|
||||
mergeId?: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:open': [boolean];
|
||||
}>();
|
||||
|
||||
const loading = ref(false);
|
||||
const items = ref<any[]>([]);
|
||||
|
||||
/** 拉取变动记录 */
|
||||
async function loadLogs() {
|
||||
const dailyBillId = Number(props.dailyBillId || 0);
|
||||
const mergeId = Number(props.mergeId || 0);
|
||||
if (dailyBillId < 1 && mergeId < 1) {
|
||||
items.value = [];
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getPublicAccountDailyChangeLog({
|
||||
daily_bill_id: dailyBillId > 0 ? dailyBillId : undefined,
|
||||
merge_id: mergeId > 0 ? mergeId : undefined,
|
||||
page: 1,
|
||||
page_size: 50,
|
||||
});
|
||||
items.value = Array.isArray(res?.items) ? res.items : [];
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
items.value = [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
emit('update:open', false);
|
||||
}
|
||||
|
||||
/** 从快照拼金额摘要 */
|
||||
function amountLine(row: Record<string, any>) {
|
||||
const before = row.before_snapshot?.platform_amount;
|
||||
const after = row.after_snapshot?.platform_amount;
|
||||
if (before !== undefined && after !== undefined && before !== after) {
|
||||
return `应付款 ${before} → ${after}`;
|
||||
}
|
||||
return row.remark || '';
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.open, props.dailyBillId, props.mergeId],
|
||||
([open]) => {
|
||||
if (open) {
|
||||
loadLogs();
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer
|
||||
:open="open"
|
||||
title="日账单变动记录"
|
||||
width="480"
|
||||
destroy-on-close
|
||||
@close="close"
|
||||
>
|
||||
<Spin :spinning="loading">
|
||||
<Timeline v-if="items.length">
|
||||
<Timeline.Item v-for="row in items" :key="row.id">
|
||||
<div class="text-sm font-medium text-[hsl(var(--foreground))]">
|
||||
{{ row.change_type_txt || '变动' }}
|
||||
</div>
|
||||
<div
|
||||
v-if="amountLine(row)"
|
||||
class="mt-0.5 text-xs text-[hsl(var(--muted-foreground))]"
|
||||
>
|
||||
{{ amountLine(row) }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-xs text-[hsl(var(--muted-foreground))]">
|
||||
{{ row.operator_name || '系统' }} · {{ row.created_at || '' }}
|
||||
</div>
|
||||
</Timeline.Item>
|
||||
</Timeline>
|
||||
<Empty v-else description="暂无变动记录" />
|
||||
</Spin>
|
||||
</Drawer>
|
||||
</template>
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 手动生成日汇总弹窗
|
||||
* 诊所管理员只生成本店、不推站内信;超管/系统管理员选店后生成并站内信通知诊所
|
||||
* 手动生成日汇总 / 周期账单弹窗
|
||||
* lock_days=1 选单日;lock_days>1 直接生成当天~当天+宽限天数的周期账单
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
@@ -15,12 +15,24 @@ import { useVbenForm } from '#/adapter/form';
|
||||
import { generatePublicAccountDailyBill } from '../api';
|
||||
|
||||
const isPlatformAdmin = ref(false);
|
||||
const lockDays = ref(1);
|
||||
const gridApi = ref<any>();
|
||||
|
||||
const hint = computed(() =>
|
||||
isPlatformAdmin.value
|
||||
const isPeriodMode = computed(() => lockDays.value > 1);
|
||||
|
||||
const hint = computed(() => {
|
||||
if (isPeriodMode.value) {
|
||||
return isPlatformAdmin.value
|
||||
? `将把待出账订单收成一张周期账单(${lockDays.value} 天宽限期),生成后站内信通知诊所`
|
||||
: `将本店待出账订单收成一张周期账单,账单区间为今天起 ${lockDays.value} 天`;
|
||||
}
|
||||
return isPlatformAdmin.value
|
||||
? '生成后将站内信通知该诊所管理员上传凭证'
|
||||
: '将本店该日待出账订单收成一张日汇总',
|
||||
: '将本店该日待出账订单收成一张日汇总';
|
||||
});
|
||||
|
||||
const modalTitle = computed(() =>
|
||||
isPeriodMode.value ? '生成周期账单' : '生成日账单',
|
||||
);
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
@@ -67,9 +79,9 @@ const [Modal, modalApi] = useVbenModal({
|
||||
try {
|
||||
await generatePublicAccountDailyBill({
|
||||
store_id: values.store_id || 0,
|
||||
bill_date: values.bill_date,
|
||||
bill_date: isPeriodMode.value ? undefined : values.bill_date,
|
||||
});
|
||||
message.success('日汇总已生成');
|
||||
message.success(isPeriodMode.value ? '周期账单已生成' : '日汇总已生成');
|
||||
if (gridApi.value?.reload) {
|
||||
gridApi.value.reload();
|
||||
} else {
|
||||
@@ -85,9 +97,11 @@ const [Modal, modalApi] = useVbenModal({
|
||||
if (!isOpen) return;
|
||||
const data = modalApi.getData<{
|
||||
isPlatformAdmin?: boolean;
|
||||
lockDays?: number;
|
||||
gridApi?: any;
|
||||
}>();
|
||||
isPlatformAdmin.value = Boolean(data?.isPlatformAdmin);
|
||||
lockDays.value = Math.max(1, Number(data?.lockDays ?? 1));
|
||||
gridApi.value = data?.gridApi;
|
||||
await formApi.resetForm();
|
||||
await formApi.updateSchema([
|
||||
@@ -99,6 +113,14 @@ const [Modal, modalApi] = useVbenModal({
|
||||
triggerFields: ['store_id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'bill_date',
|
||||
rules: isPeriodMode.value ? '' : 'required',
|
||||
dependencies: {
|
||||
show: !isPeriodMode.value,
|
||||
triggerFields: ['bill_date'],
|
||||
},
|
||||
},
|
||||
]);
|
||||
await formApi.setValues({
|
||||
store_id: undefined,
|
||||
@@ -109,7 +131,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="生成日账单" class="w-[480px]">
|
||||
<Modal :title="modalTitle" class="w-[480px]">
|
||||
<p class="mb-3 text-sm text-[hsl(var(--muted-foreground))]">{{ hint }}</p>
|
||||
<Form />
|
||||
</Modal>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 合并账单明细弹窗:日账单 + 下属商品订单(只读)
|
||||
* 确认到账 / 公账账单页「查看合并」共用,避免页脚内联卡片
|
||||
* 合并账单明细弹窗:按账单日 Tabs 查看日账单与商品订单
|
||||
* 确认到账 / 公账账单页「查看合并」共用
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
@@ -11,10 +11,12 @@ import LockOrdersPanel from '#/components/public-account-lock/LockOrdersPanel.vu
|
||||
|
||||
const mergeId = ref(0);
|
||||
const panelKey = ref(0);
|
||||
const modalTitle = computed(() =>
|
||||
mergeId.value > 0 ? `合并账单明细 #${mergeId.value}` : '合并账单明细',
|
||||
);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
title: '合并账单明细',
|
||||
class: 'w-[min(860px,96vw)]',
|
||||
class: 'w-[min(920px,96vw)]',
|
||||
contentClass: 'pap-merge-orders-modal-body',
|
||||
showConfirmButton: false,
|
||||
cancelText: '关闭',
|
||||
@@ -34,7 +36,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal>
|
||||
<Modal :title="modalTitle">
|
||||
<div class="pap-merge-orders-wrap">
|
||||
<LockOrdersPanel
|
||||
v-if="mergeId > 0"
|
||||
@@ -50,9 +52,9 @@ const [Modal, modalApi] = useVbenModal({
|
||||
|
||||
<style scoped>
|
||||
.pap-merge-orders-wrap {
|
||||
max-height: min(72vh, 720px);
|
||||
max-height: min(78vh, 780px);
|
||||
overflow: auto;
|
||||
padding-right: 4px;
|
||||
padding-right: 2px;
|
||||
}
|
||||
.pap-merge-orders-empty {
|
||||
margin: 24px 0;
|
||||
|
||||
@@ -40,9 +40,13 @@ export const dailyGridOptions: VxeGridProps<RowType> = {
|
||||
{
|
||||
field: 'bill_date_range_txt',
|
||||
title: '账单日',
|
||||
width: 180,
|
||||
formatter: ({ row }) =>
|
||||
row.bill_date_range_txt || row.bill_date_txt || row.bill_date || '—',
|
||||
width: 220,
|
||||
formatter: ({ row }) => {
|
||||
const range =
|
||||
row.bill_date_range_txt || row.bill_date_txt || row.bill_date || '—';
|
||||
const endTxt = row.period_end_at_txt;
|
||||
return endTxt ? `${range}(截止 ${endTxt})` : range;
|
||||
},
|
||||
},
|
||||
{ field: 'order_count', title: '订单数', width: 90 },
|
||||
{ field: 'order_amount', title: '订单合计', width: 110 },
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
getPublicAccountPayList,
|
||||
} from './api';
|
||||
import DailyUploadModal from './components/daily-upload-modal.vue';
|
||||
import DailyChangeLogDrawer from './components/daily-change-log-drawer.vue';
|
||||
import GenerateDailyModal from './components/generate-daily-modal.vue';
|
||||
import MergeOrdersModal from './components/merge-orders-modal.vue';
|
||||
import VoucherThumbs from './components/voucher-thumbs.vue';
|
||||
@@ -41,11 +42,15 @@ const route = useRoute();
|
||||
const TAB_STORAGE_KEY = 'finance_public_account_pay_tab';
|
||||
const activeTab = ref(localStorage.getItem(TAB_STORAGE_KEY) || 'daily');
|
||||
const billMode = ref<'order' | 'daily'>('order');
|
||||
const lockDays = ref(1);
|
||||
const canConfirm = ref(false);
|
||||
const canUpload = ref(false);
|
||||
const canGenerate = ref(false);
|
||||
const detail = ref<Record<string, any> | null>(null);
|
||||
const dailyDetail = ref<Record<string, any> | null>(null);
|
||||
const changeLogOpen = ref(false);
|
||||
const changeLogDailyId = ref(0);
|
||||
const changeLogMergeId = ref(0);
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
@@ -82,6 +87,7 @@ function persistTab(key: string) {
|
||||
function openGenerateDaily() {
|
||||
generateDailyModalApi.setData({
|
||||
isPlatformAdmin: canConfirm.value,
|
||||
lockDays: lockDays.value,
|
||||
gridApi: {
|
||||
reload: () => {
|
||||
persistTab('daily');
|
||||
@@ -127,6 +133,17 @@ function openMergeDetail(mergeId: number) {
|
||||
mergeOrdersModalApi.open();
|
||||
}
|
||||
|
||||
/** 打开日账单变动记录 */
|
||||
function openChangeLog(row: Record<string, any>) {
|
||||
const isPeriod = Number(row.is_period || 0) === 1;
|
||||
changeLogDailyId.value = isPeriod ? 0 : Number(row.id || 0);
|
||||
changeLogMergeId.value = Number(row.merge_id || 0);
|
||||
if (changeLogDailyId.value < 1 && changeLogMergeId.value < 1) {
|
||||
changeLogDailyId.value = Number(row.id || 0);
|
||||
}
|
||||
changeLogOpen.value = true;
|
||||
}
|
||||
|
||||
async function handleCancel(row: Record<string, any>) {
|
||||
await cancelPublicAccountPay({ id: row.id });
|
||||
message.success('已取消');
|
||||
@@ -197,6 +214,7 @@ initTableAjax();
|
||||
onMounted(async () => {
|
||||
const cfg = await getPublicAccountPayConfig().catch(() => null);
|
||||
billMode.value = cfg?.bill_mode === 'daily' ? 'daily' : 'order';
|
||||
lockDays.value = Math.max(1, Number(cfg?.lock_days ?? 1));
|
||||
canConfirm.value = Number(cfg?.can_confirm) === 1 || cfg?.can_confirm === true;
|
||||
canUpload.value = Number(cfg?.can_upload) === 1 || cfg?.can_upload === true;
|
||||
canGenerate.value = Number(cfg?.can_generate) === 1 || cfg?.can_generate === true;
|
||||
@@ -218,6 +236,11 @@ watch(
|
||||
<DailyUploadPayModal />
|
||||
<GenerateDailyPayModal />
|
||||
<MergeOrdersPayModal />
|
||||
<DailyChangeLogDrawer
|
||||
v-model:open="changeLogOpen"
|
||||
:daily-bill-id="changeLogDailyId"
|
||||
:merge-id="changeLogMergeId"
|
||||
/>
|
||||
<Tabs
|
||||
v-if="billMode === 'daily'"
|
||||
class="pap-tabs"
|
||||
@@ -230,7 +253,7 @@ watch(
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '生成日账单',
|
||||
label: lockDays > 1 ? '生成周期账单' : '生成日账单',
|
||||
type: 'primary',
|
||||
ifShow: canGenerate,
|
||||
onClick: openGenerateDaily,
|
||||
@@ -268,6 +291,7 @@ watch(
|
||||
v-for="item in row.items || []"
|
||||
:key="item.id"
|
||||
class="expand-row"
|
||||
:class="{ 'text-muted-foreground line-through opacity-70': item.status === 2 }"
|
||||
>
|
||||
{{ item.order_no }} · ¥{{ item.platform_amount }} · {{ item.status_txt }}
|
||||
</div>
|
||||
@@ -296,6 +320,12 @@ watch(
|
||||
Number(row.status) !== 4)),
|
||||
onClick: openDailyUpload.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '变动记录',
|
||||
type: 'link',
|
||||
ifShow: Number(row.id || 0) > 0 || Number(row.merge_id || 0) > 0,
|
||||
onClick: openChangeLog.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '查看合并',
|
||||
type: 'link',
|
||||
@@ -334,7 +364,7 @@ watch(
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '生成日账单',
|
||||
label: lockDays > 1 ? '生成周期账单' : '生成日账单',
|
||||
type: 'primary',
|
||||
ifShow: canGenerate,
|
||||
onClick: openGenerateDaily,
|
||||
@@ -402,6 +432,12 @@ watch(
|
||||
{{ dailyDetail.bill_date_range_txt || dailyDetail.bill_date_txt }}
|
||||
</b>
|
||||
<a class="text-sm text-primary" @click="dailyDetail = null">关闭</a>
|
||||
<a
|
||||
class="ml-3 text-sm text-primary"
|
||||
@click="openChangeLog(dailyDetail)"
|
||||
>
|
||||
变动记录
|
||||
</a>
|
||||
</div>
|
||||
<div class="text-sm text-[hsl(var(--muted-foreground))]">
|
||||
{{ dailyDetail.store_name }} · {{ dailyDetail.status_txt }} · 应付款
|
||||
@@ -421,6 +457,7 @@ watch(
|
||||
v-for="item in dailyDetail.items"
|
||||
:key="item.id"
|
||||
class="expand-row"
|
||||
:class="{ 'text-muted-foreground line-through opacity-70': item.status === 2 }"
|
||||
>
|
||||
{{ item.order_no }} · 平台 ¥{{ item.platform_amount }} · {{ item.status_txt }}
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { debounce } from 'lodash-es';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { useUserStore } from '@vben/stores';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import StoreMultiSearch from '#/components/form/components/store-multi-search.vue';
|
||||
import SearchTimeRangePicker from '#/components/form/components/search-time-range-picker.vue';
|
||||
import {
|
||||
getReconciliationDrugList,
|
||||
getReconciliationDrugOptions,
|
||||
@@ -88,7 +89,7 @@ const canViewInvoicePrice = computed(
|
||||
const activeTab = ref('store');
|
||||
|
||||
/** 整页共用时间 */
|
||||
const searchTime = ref<[Dayjs, Dayjs]>([dayjs().startOf('month'), dayjs()]);
|
||||
const searchTime = ref<[Dayjs, Dayjs]>(monthToTodayRangeDayjs());
|
||||
/** 对账诊所 Tab 多选门店(诊所+药店) */
|
||||
const storeIds = ref<number[]>([]);
|
||||
const excludeZeroSales = ref(loadExcludeZeroSales());
|
||||
@@ -381,7 +382,7 @@ watch(byOrder, () => {
|
||||
|
||||
<div class="mb-3 flex flex-wrap items-center gap-3 rounded border px-3 py-2">
|
||||
<span class="text-sm text-muted-foreground">时间范围(全页共用)</span>
|
||||
<DatePicker.RangePicker
|
||||
<SearchTimeRangePicker
|
||||
v-model:value="searchTime"
|
||||
format="YYYY-MM-DD"
|
||||
:get-popup-container="popupContainerBody"
|
||||
|
||||
@@ -2,6 +2,8 @@ import type { Dayjs } from 'dayjs';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
|
||||
/** 整页共用时间(新) */
|
||||
const KEY_PAGE_SEARCH_TIME = 'reconciliation.page.search_time';
|
||||
/** 历史 key:迁移后删除 */
|
||||
@@ -11,7 +13,7 @@ const KEY_LEGACY_DRUG_SEARCH_TIME = 'reconciliation.drug.search_time';
|
||||
const KEY_EXCLUDE_ZERO_SALES = 'reconciliation.store.exclude_zero_sales';
|
||||
|
||||
export function defaultSearchTimeRange(): [Dayjs, Dayjs] {
|
||||
return [dayjs().startOf('month'), dayjs()];
|
||||
return monthToTodayRangeDayjs();
|
||||
}
|
||||
|
||||
function parseStoredRange(raw: string | null): [Dayjs, Dayjs] | null {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { onActivated, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import {
|
||||
@@ -8,9 +8,11 @@ import {
|
||||
useEcharts,
|
||||
} from '@vben/plugins/echarts';
|
||||
|
||||
import { Button, Card, RangePicker } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { Button, Card } from 'ant-design-vue';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
import SearchTimeRangePicker from '#/components/form/components/search-time-range-picker.vue';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
import { getReconciliationChartApi } from '#/views/finance/visualization-chart/api';
|
||||
|
||||
// 图表相关
|
||||
@@ -144,10 +146,11 @@ const initCharts = () => {
|
||||
// });
|
||||
|
||||
// 时间选择器相关
|
||||
const searchTime = ref([dayjs().startOf('month'), dayjs()]);
|
||||
const handleTimeChange = (dates: [dayjs.Dayjs, dayjs.Dayjs]) => {
|
||||
console.log('时间范围变化:', dates);
|
||||
// 这里可以添加数据更新逻辑
|
||||
const searchTime = ref<[Dayjs, Dayjs]>(monthToTodayRangeDayjs());
|
||||
const searchTimeTouched = ref(false);
|
||||
|
||||
const handleTimeChange = () => {
|
||||
searchTimeTouched.value = true;
|
||||
getData();
|
||||
};
|
||||
|
||||
@@ -161,9 +164,18 @@ const getData = () => {
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
searchTime.value = [dayjs().startOf('month'), dayjs()]
|
||||
searchTimeTouched.value = false;
|
||||
searchTime.value = monthToTodayRangeDayjs();
|
||||
getData();
|
||||
}
|
||||
};
|
||||
|
||||
onActivated(() => {
|
||||
if (!searchTimeTouched.value) {
|
||||
searchTime.value = monthToTodayRangeDayjs();
|
||||
getData();
|
||||
}
|
||||
});
|
||||
|
||||
getData();
|
||||
</script>
|
||||
|
||||
@@ -171,9 +183,10 @@ getData();
|
||||
<Page>
|
||||
<!-- 搜索区域 -->
|
||||
<div class="search-container">
|
||||
<RangePicker
|
||||
<SearchTimeRangePicker
|
||||
v-model:value="searchTime"
|
||||
style="width: 300px"
|
||||
format="YYYY-MM-DD"
|
||||
style="width: 100%; max-width: 420px"
|
||||
@change="handleTimeChange"
|
||||
/>
|
||||
<Button type="link" @click="getData">刷新</Button>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
|
||||
export const formOptions: VbenFormProps = {
|
||||
// 默认展开
|
||||
@@ -38,11 +38,11 @@ export const formOptions: VbenFormProps = {
|
||||
label: '审核状态',
|
||||
},
|
||||
{
|
||||
component: 'RangePicker',
|
||||
component: 'SearchTimeRangePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD', // 确保格式与你需要的一致
|
||||
format: 'YYYY-MM-DD',
|
||||
},
|
||||
defaultValue: [dayjs().startOf('month'), dayjs()],
|
||||
defaultValue: monthToTodayRangeDayjs(),
|
||||
fieldName: 'search_time',
|
||||
label: '时间范围',
|
||||
},
|
||||
|
||||
@@ -9,7 +9,9 @@ import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Button, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { useFreshSearchTime } from '#/composables/use-fresh-search-time';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { monthToTodayRangeDayjs } from '#/utils/search-time-range';
|
||||
import StatisticsReconciliation from '#/views/finance/reconciliation/components/statistics.vue';
|
||||
import WithdrawalRelationDetail from '#/views/finance/withdrawal/components/withdrawal-relation-detail.vue';
|
||||
import { useWithdrawOrderDetailModals } from '#/views/finance/withdrawal/utils/use-withdraw-order-detail';
|
||||
@@ -18,11 +20,34 @@ import WithdrawalAudit from './components/WithdrawalAudit.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { gridOptions } from './config/table';
|
||||
|
||||
const freshSearchTimeBridge = {
|
||||
resetSearchTime: async () => {},
|
||||
markSearchTimeTouched: () => {},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
formOptions: {
|
||||
...formOptions,
|
||||
handleValuesChange(_values, fieldsChanged) {
|
||||
if (fieldsChanged?.includes('search_time')) {
|
||||
freshSearchTimeBridge.markSearchTimeTouched();
|
||||
}
|
||||
},
|
||||
handleReset: async () => {
|
||||
await freshSearchTimeBridge.resetSearchTime();
|
||||
},
|
||||
},
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const freshSearchTime = useFreshSearchTime({
|
||||
formApi: gridApi.formApi,
|
||||
getDefaultRange: () => monthToTodayRangeDayjs(),
|
||||
onRefresh: () => gridApi.reload(),
|
||||
});
|
||||
freshSearchTimeBridge.resetSearchTime = freshSearchTime.resetSearchTime;
|
||||
freshSearchTimeBridge.markSearchTimeTouched = freshSearchTime.markSearchTimeTouched;
|
||||
|
||||
const statistics = ref();
|
||||
|
||||
const { OrderDetailModal, RegisterDetailModal, TraceDrawer, openOrderDetail } =
|
||||
|
||||
@@ -11,7 +11,9 @@ import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { message, Modal, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { useFreshSearchTime } from '#/composables/use-fresh-search-time';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { lastNDaysRangeString } from '#/utils/search-time-range';
|
||||
|
||||
import {
|
||||
cancelQueueJob,
|
||||
@@ -38,14 +40,37 @@ const props = defineProps<{
|
||||
|
||||
const route = useRoute();
|
||||
const isBusiness = props.category === QUEUE_JOB_CATEGORY.BUSINESS;
|
||||
const formOptions = createFormOptions({ showDelayFilter: isBusiness });
|
||||
const baseFormOptions = createFormOptions({ showDelayFilter: isBusiness });
|
||||
const gridOptions = createGridOptions(props.category);
|
||||
|
||||
const freshSearchTimeBridge = {
|
||||
resetSearchTime: async () => {},
|
||||
markSearchTimeTouched: () => {},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
formOptions: {
|
||||
...baseFormOptions,
|
||||
handleValuesChange(_values, fieldsChanged) {
|
||||
if (fieldsChanged?.includes('search_time')) {
|
||||
freshSearchTimeBridge.markSearchTimeTouched();
|
||||
}
|
||||
},
|
||||
handleReset: async () => {
|
||||
await freshSearchTimeBridge.resetSearchTime();
|
||||
},
|
||||
},
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const freshSearchTime = useFreshSearchTime({
|
||||
formApi: gridApi.formApi,
|
||||
getDefaultRange: () => lastNDaysRangeString(7),
|
||||
onRefresh: () => gridApi.reload(),
|
||||
});
|
||||
freshSearchTimeBridge.resetSearchTime = freshSearchTime.resetSearchTime;
|
||||
freshSearchTimeBridge.markSearchTimeTouched = freshSearchTime.markSearchTimeTouched;
|
||||
|
||||
const [DetailModalComp, detailModalApi] = useVbenModal({
|
||||
connectedComponent: DetailModal,
|
||||
});
|
||||
|
||||
@@ -2,6 +2,8 @@ import type { VbenFormProps } from '#/adapter/form';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { lastNDaysRangeString } from '#/utils/search-time-range';
|
||||
|
||||
import {
|
||||
QUEUE_JOB_DELAY_TYPE_OPTIONS,
|
||||
QUEUE_JOB_STATUS_OPTIONS,
|
||||
@@ -61,16 +63,13 @@ export function createFormOptions(options?: {
|
||||
});
|
||||
}
|
||||
schema.push({
|
||||
component: 'RangePicker',
|
||||
component: 'SearchTimeRangePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
showThisMonth: false,
|
||||
},
|
||||
// 默认近 7 天
|
||||
defaultValue: [
|
||||
dayjs().subtract(6, 'day').format('YYYY-MM-DD'),
|
||||
dayjs().format('YYYY-MM-DD'),
|
||||
],
|
||||
defaultValue: lastNDaysRangeString(7),
|
||||
fieldName: 'search_time',
|
||||
label: '时间范围',
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridListeners } from '#/adapter/vxe-table';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
resetPassword,
|
||||
updateAdmin,
|
||||
} from '#/views/system/admin/api';
|
||||
import { getRoleInfo } from '#/views/system/role/api';
|
||||
|
||||
import { normalizeAdminPayload } from './admin-payload';
|
||||
import { createAdminModalFormProps } from './form-schemas';
|
||||
@@ -49,6 +50,20 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const meta = computed(() => getRoleMeta(props.roleId));
|
||||
/** 优先展示接口返回的角色昵称(自定义角色尤为重要) */
|
||||
const roleTitle = ref('');
|
||||
const pageTitle = computed(() => roleTitle.value || meta.value.title);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const info = await getRoleInfo(props.roleId);
|
||||
if (info?.name) {
|
||||
roleTitle.value = String(info.name);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
const hasTopTableDropDownActions = ref(false);
|
||||
const isUpdate = ref(false);
|
||||
@@ -217,9 +232,9 @@ const copyToClipboard = async (text: string) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height :title="meta.title">
|
||||
<Page auto-content-height :title="pageTitle">
|
||||
<Modal
|
||||
:title="`${isUpdate ? '编辑' : '新增'}${meta.title}`"
|
||||
:title="`${isUpdate ? '编辑' : '新增'}${pageTitle}`"
|
||||
class="w-[60%]"
|
||||
>
|
||||
<Form />
|
||||
|
||||
@@ -38,8 +38,14 @@ export const ROLE_SALESPERSON = 6;
|
||||
|
||||
export function getRoleMeta(roleId: number): AdminRoleMeta {
|
||||
const meta = ADMIN_ROLE_LIST.find((r) => r.id === roleId);
|
||||
if (!meta) {
|
||||
throw new Error(`Unknown admin role id: ${roleId}`);
|
||||
if (meta) {
|
||||
return meta;
|
||||
}
|
||||
return meta;
|
||||
// 自定义角色:无静态页元数据时回落为通用 basic 表单,避免抛错
|
||||
return {
|
||||
id: roleId,
|
||||
title: `角色${roleId}`,
|
||||
slug: `role-${roleId}`,
|
||||
formType: 'basic',
|
||||
};
|
||||
}
|
||||
|
||||
25
apps/web-antd/src/views/system/admin/dynamic/index.vue
Normal file
25
apps/web-antd/src/views/system/admin/dynamic/index.vue
Normal file
@@ -0,0 +1,25 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 自定义角色通用管理员页:从路由 path 解析 roleId,复用 AdminPage
|
||||
* 菜单 path 约定:/system/admin/role/{roleId}
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import AdminPage from '../_shared/admin-page.vue';
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
/** 从 path 提取角色 ID,解析失败返回 0 */
|
||||
const roleId = computed(() => {
|
||||
const match = String(route.path).match(/\/system\/admin\/role\/(\d+)/);
|
||||
return match ? Number(match[1]) : 0;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AdminPage v-if="roleId > 0" :role-id="roleId" />
|
||||
<div v-else class="p-6 text-[hsl(var(--muted-foreground))]">
|
||||
无法识别角色 ID,请检查菜单路径是否为 /system/admin/role/{角色ID}
|
||||
</div>
|
||||
</template>
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* 某药品的配送仓绑定列表弹窗(卡片展示)
|
||||
* 展示报价/推广费/平台费/库存;新增/编辑打开仓药绑定表单(药品预填)
|
||||
* 打开时尽量补齐总仓售价,供费用封顶与平台费默认 5%
|
||||
* 打开时尽量补齐总仓售价与平台供货价,供费用封顶与自动算费
|
||||
*/
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
|
||||
@@ -13,14 +13,19 @@ import { Button, Empty, message, Pagination, Spin, Tag } from 'ant-design-vue';
|
||||
import { getWarehouseDrugManagementList } from '#/views/business/warehouse-drug-management/admin/api';
|
||||
|
||||
import { deleteDeliveryWarehouseDrug, getDeliveryWarehouseDrugList } from '../api';
|
||||
import { resolveCentralPrice } from '../utils/resolve-central-price';
|
||||
import {
|
||||
resolveCentralMarketPrice,
|
||||
resolveCentralPrice,
|
||||
} from '../utils/resolve-central-price';
|
||||
import FormModal from './modal.vue';
|
||||
|
||||
const drugId = ref(0);
|
||||
const drugName = ref('');
|
||||
const drugMeta = ref<Record<string, any>>({});
|
||||
/** 总仓售价,用于绑仓表单默认平台费与封顶 */
|
||||
/** 总仓售价,用于绑仓表单封顶与推广费计算 */
|
||||
const centralPrice = ref<number | null>(null);
|
||||
/** 总仓平台供货价,用于自动算推广费/平台费 */
|
||||
const centralMarketPrice = ref<number | null>(null);
|
||||
const productGridApi = ref();
|
||||
const loading = ref(false);
|
||||
const items = ref<Record<string, any>[]>([]);
|
||||
@@ -41,6 +46,13 @@ const priceText = computed(() => {
|
||||
return '无总仓售价';
|
||||
});
|
||||
|
||||
const marketText = computed(() => {
|
||||
if (centralMarketPrice.value != null && centralMarketPrice.value > 0) {
|
||||
return `¥${Number(centralMarketPrice.value).toFixed(2)}`;
|
||||
}
|
||||
return '无总仓供货价';
|
||||
});
|
||||
|
||||
/**
|
||||
* 加载绑定卡片数据
|
||||
*/
|
||||
@@ -65,10 +77,15 @@ async function loadList() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表未带售价时,按 drug_id 查总仓补齐
|
||||
* 列表未带售价/供货价时,按 drug_id 查总仓补齐
|
||||
*/
|
||||
async function ensureCentralPrice() {
|
||||
if (centralPrice.value != null && centralPrice.value > 0) return;
|
||||
const needSale = !(centralPrice.value != null && centralPrice.value > 0);
|
||||
const needMarket = !(
|
||||
centralMarketPrice.value != null &&
|
||||
centralMarketPrice.value > 0
|
||||
);
|
||||
if (!needSale && !needMarket) return;
|
||||
if (!drugId.value) return;
|
||||
try {
|
||||
const res = await getWarehouseDrugManagementList({
|
||||
@@ -78,16 +95,20 @@ async function ensureCentralPrice() {
|
||||
});
|
||||
const row = res?.items?.[0];
|
||||
const price = Number(row?.price ?? 0);
|
||||
if (price > 0) {
|
||||
const market = Number(row?.market_price ?? 0);
|
||||
if (needSale && price > 0) {
|
||||
centralPrice.value = price;
|
||||
}
|
||||
if (needMarket && market > 0) {
|
||||
centralMarketPrice.value = market;
|
||||
}
|
||||
} catch {
|
||||
// 补齐失败不阻断绑仓,表单内仍可手填三费
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开新增:药品锁定预填 + 带上 number 类型总仓售价
|
||||
* 打开新增:药品锁定预填 + 带上总仓售价与平台供货价
|
||||
*/
|
||||
async function openCreate() {
|
||||
await ensureCentralPrice();
|
||||
@@ -95,6 +116,10 @@ async function openCreate() {
|
||||
centralPrice.value != null && centralPrice.value > 0
|
||||
? Number(centralPrice.value)
|
||||
: null;
|
||||
const market =
|
||||
centralMarketPrice.value != null && centralMarketPrice.value > 0
|
||||
? Number(centralMarketPrice.value)
|
||||
: null;
|
||||
formModalApi.setData({
|
||||
update: false,
|
||||
// 新增成功后刷新业务列表与本卡片列表
|
||||
@@ -110,16 +135,21 @@ async function openCreate() {
|
||||
},
|
||||
lockDrug: true,
|
||||
central_price: price,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
presetDrug: {
|
||||
id: drugId.value,
|
||||
drug_name: drugName.value,
|
||||
specification: drugMeta.value.specification || '',
|
||||
image: drugMeta.value.image || '',
|
||||
central_price: price,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
},
|
||||
values: {
|
||||
drug_id: drugId.value,
|
||||
...(price != null ? { sale_price: price } : {}),
|
||||
...(market != null ? { market_price: market } : {}),
|
||||
},
|
||||
});
|
||||
formModalApi.open();
|
||||
@@ -131,6 +161,10 @@ async function openEdit(row: any) {
|
||||
centralPrice.value != null && centralPrice.value > 0
|
||||
? Number(centralPrice.value)
|
||||
: resolveCentralPrice(row);
|
||||
const market =
|
||||
centralMarketPrice.value != null && centralMarketPrice.value > 0
|
||||
? Number(centralMarketPrice.value)
|
||||
: resolveCentralMarketPrice(row);
|
||||
formModalApi.setData({
|
||||
update: true,
|
||||
gridApi: {
|
||||
@@ -144,9 +178,12 @@ async function openEdit(row: any) {
|
||||
},
|
||||
},
|
||||
central_price: price,
|
||||
central_market_price: market,
|
||||
market_price: market,
|
||||
values: {
|
||||
...row,
|
||||
...(price != null ? { sale_price: price } : {}),
|
||||
...(market != null ? { market_price: market } : {}),
|
||||
},
|
||||
});
|
||||
formModalApi.open();
|
||||
@@ -192,6 +229,11 @@ const [Modal, modalApi] = useVbenModal({
|
||||
resolveCentralPrice(data.values) ??
|
||||
resolveCentralPrice(data.presetDrug) ??
|
||||
null;
|
||||
centralMarketPrice.value =
|
||||
resolveCentralMarketPrice(data) ??
|
||||
resolveCentralMarketPrice(data.values) ??
|
||||
resolveCentralMarketPrice(data.presetDrug) ??
|
||||
null;
|
||||
productGridApi.value = data.gridApi;
|
||||
pendingAutoCreate.value = !!data.autoCreate;
|
||||
page.value = 1;
|
||||
@@ -220,6 +262,17 @@ const [Modal, modalApi] = useVbenModal({
|
||||
>
|
||||
{{ priceText }}
|
||||
</span>
|
||||
<span class="bind-list-header__sep">·</span>
|
||||
<span>平台供货价:</span>
|
||||
<span
|
||||
:class="
|
||||
centralMarketPrice && centralMarketPrice > 0
|
||||
? 'bind-list-header__price'
|
||||
: 'bind-list-header__price--empty'
|
||||
"
|
||||
>
|
||||
{{ marketText }}
|
||||
</span>
|
||||
</div>
|
||||
<Button type="primary" @click="openCreate">新增绑定</Button>
|
||||
</div>
|
||||
@@ -289,6 +342,10 @@ const [Modal, modalApi] = useVbenModal({
|
||||
font-size: 13px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.bind-list-header__sep {
|
||||
margin: 0 6px;
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
.bind-list-header__price {
|
||||
font-weight: 600;
|
||||
color: hsl(var(--foreground));
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* 仓药绑定弹窗
|
||||
* 新增时用 DrugSearchSelect(is-card) 选药;编辑/预填锁定时不可换药
|
||||
* 有总仓售价时:展示、新增默认平台费=售价5%、三费超售价实时提醒并拦截提交
|
||||
* 注意:必须 await setValues,否则异步覆盖会把 sale_price 冲掉
|
||||
* 有总仓售价/供货价时:展示、按公式自动算推广费/平台费、三费超售价实时提醒并拦截提交
|
||||
* 注意:必须 await setValues,否则异步覆盖会把 sale_price/market_price 冲掉
|
||||
*/
|
||||
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
|
||||
|
||||
@@ -27,7 +27,10 @@ import {
|
||||
seedAutoPromoFeeKey,
|
||||
syncFeeSumDisplay,
|
||||
} from '#/views/system/delivery-warehouse-drug/config/form';
|
||||
import { resolveCentralPrice } from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
import {
|
||||
resolveCentralMarketPrice,
|
||||
resolveCentralPrice,
|
||||
} from '#/views/system/delivery-warehouse-drug/utils/resolve-central-price';
|
||||
|
||||
/** 非中药品类:西药/保健/中成药/服务包/非药品/医疗器械 */
|
||||
const NON_CHINESE_DRUG_TYPES = [2, 3, 4, 5, 6, 7];
|
||||
@@ -62,31 +65,31 @@ onUnmounted(() => {
|
||||
});
|
||||
|
||||
/**
|
||||
* 写入售价;新增时默认平台费 = 售价 5%,并按差额回填推广费
|
||||
* 编辑仅写售价并锁定依赖 key,不覆盖已有三费
|
||||
* 写入总仓售价与平台供货价
|
||||
* 新增时按公式自动回填推广费/平台费;编辑仅写入价并锁定依赖 key,不覆盖已有三费
|
||||
*/
|
||||
async function applyCentralPrice(
|
||||
async function applyCentralPrices(
|
||||
price: number | string | null | undefined,
|
||||
market: number | string | null | undefined,
|
||||
isCreate: boolean,
|
||||
) {
|
||||
const n = Number(price);
|
||||
if (!(n > 0)) {
|
||||
await formApi.setFieldValue('sale_price', undefined);
|
||||
return;
|
||||
}
|
||||
const sale = Number(n.toFixed(4));
|
||||
const saleN = Number(price);
|
||||
const marketN = Number(market);
|
||||
const sale = saleN > 0 ? Number(saleN.toFixed(4)) : undefined;
|
||||
const marketPrice = marketN > 0 ? Number(marketN.toFixed(4)) : undefined;
|
||||
await formApi.setFieldValue('sale_price', sale);
|
||||
await formApi.setFieldValue('market_price', marketPrice);
|
||||
const values = await formApi.getValues();
|
||||
const merged = {
|
||||
...values,
|
||||
...(sale != null ? { sale_price: sale } : {}),
|
||||
...(marketPrice != null ? { market_price: marketPrice } : {}),
|
||||
};
|
||||
if (isCreate) {
|
||||
const platform = Number((sale * 0.05).toFixed(4));
|
||||
await formApi.setFieldValue('platform_fee', platform);
|
||||
const values = await formApi.getValues();
|
||||
const merged = { ...values, sale_price: sale, platform_fee: platform };
|
||||
applyAutoPromoFee(merged, formApi);
|
||||
syncFeeSumDisplay(merged, formApi);
|
||||
return;
|
||||
}
|
||||
const values = await formApi.getValues();
|
||||
const merged = { ...values, sale_price: sale };
|
||||
seedAutoPromoFeeKey(merged);
|
||||
syncFeeSumDisplay(merged, formApi);
|
||||
}
|
||||
@@ -102,6 +105,17 @@ function pickSalePrice(data: Record<string, any>) {
|
||||
return resolveCentralPrice(data.presetDrug);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从弹窗入参解析平台供货价:优先 data.central_market_price / market_price
|
||||
*/
|
||||
function pickMarketPrice(data: Record<string, any>) {
|
||||
const fromData = resolveCentralMarketPrice(data);
|
||||
if (fromData != null) return fromData;
|
||||
const fromValues = resolveCentralMarketPrice(data.values);
|
||||
if (fromValues != null) return fromValues;
|
||||
return resolveCentralMarketPrice(data.presetDrug);
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
@@ -124,10 +138,13 @@ const [Modal, modalApi] = useVbenModal({
|
||||
const e = await formApi.validate();
|
||||
if (!e.valid) return;
|
||||
const payload = { ...(await formApi.getValues()) };
|
||||
// sale_price 只作封顶校验,不用费用合计覆盖
|
||||
// sale_price / market_price 只作算费与封顶,不落仓药绑定表
|
||||
if (payload.sale_price === undefined || payload.sale_price === '') {
|
||||
delete payload.sale_price;
|
||||
}
|
||||
if (payload.market_price === undefined || payload.market_price === '') {
|
||||
delete payload.market_price;
|
||||
}
|
||||
delete payload._fee_sum;
|
||||
if (Number(calcFeeSum(payload)) <= 0) {
|
||||
message.warning('报价/推广费/平台费合计必须大于0');
|
||||
@@ -160,14 +177,16 @@ const [Modal, modalApi] = useVbenModal({
|
||||
lockDrug.value = !!data.lockDrug && !update;
|
||||
editDrugCard.value = null;
|
||||
feeOverTip.value = '';
|
||||
// 清零自动算费 key,避免沿用上一单的报价/平台费组合
|
||||
// 清零自动算费 key,避免沿用上一单的报价/供货价组合
|
||||
resetAutoPromoFeeKey();
|
||||
const salePrice = pickSalePrice(data);
|
||||
// 先重置,再 await 写入,避免异步 setValues 冲掉 sale_price
|
||||
const marketPrice = pickMarketPrice(data);
|
||||
// 先重置,再 await 写入,避免异步 setValues 冲掉售价/供货价
|
||||
await formApi.resetForm();
|
||||
const nextValues = {
|
||||
...(values || {}),
|
||||
...(salePrice != null ? { sale_price: salePrice } : {}),
|
||||
...(marketPrice != null ? { market_price: marketPrice } : {}),
|
||||
};
|
||||
if (Object.keys(nextValues).length) {
|
||||
await formApi.setValues(nextValues);
|
||||
@@ -182,8 +201,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||
spec: values.drug?.specification || values.specification || '',
|
||||
image: values.drug?.image || values.image || DRUG_PLACEHOLDER_IMAGE,
|
||||
};
|
||||
// 编辑:只写售价,不覆盖已有三费
|
||||
await applyCentralPrice(salePrice, false);
|
||||
// 编辑:只写售价/供货价,不覆盖已有三费
|
||||
await applyCentralPrices(salePrice, marketPrice, false);
|
||||
} else if (lockDrug.value && presetDrug) {
|
||||
const id = Number(presetDrug.id || values?.drug_id || 0);
|
||||
await formApi.setFieldValue('drug_id', id);
|
||||
@@ -193,18 +212,24 @@ const [Modal, modalApi] = useVbenModal({
|
||||
spec: presetDrug.specification || '',
|
||||
image: presetDrug.image || DRUG_PLACEHOLDER_IMAGE,
|
||||
};
|
||||
await applyCentralPrice(salePrice, true);
|
||||
await applyCentralPrices(salePrice, marketPrice, true);
|
||||
} else if (!update) {
|
||||
await applyCentralPrice(salePrice, true);
|
||||
await applyCentralPrices(salePrice, marketPrice, true);
|
||||
}
|
||||
// 再确认一次:部分表单实现会二次回填空值
|
||||
await nextTick();
|
||||
const after = await formApi.getValues();
|
||||
const afterSale = Number(after?.sale_price);
|
||||
if (salePrice != null && (!(afterSale > 0) || afterSale !== salePrice)) {
|
||||
await applyCentralPrice(salePrice, !update);
|
||||
const afterMarket = Number(after?.market_price);
|
||||
const saleMismatch =
|
||||
salePrice != null && (!(afterSale > 0) || afterSale !== salePrice);
|
||||
const marketMismatch =
|
||||
marketPrice != null &&
|
||||
(!(afterMarket > 0) || afterMarket !== marketPrice);
|
||||
if (saleMismatch || marketMismatch) {
|
||||
await applyCentralPrices(salePrice, marketPrice, !update);
|
||||
}
|
||||
// 打开后同步一次上限与提示(售价写入后 dependencies 可能未立刻跑完)
|
||||
// 打开后同步一次上限与提示(价写入后 dependencies 可能未立刻跑完)
|
||||
const latest = await formApi.getValues();
|
||||
feeOverTip.value = syncFeeSumDisplay(latest, formApi);
|
||||
},
|
||||
@@ -222,10 +247,14 @@ async function onSelectDrug(item: any) {
|
||||
return;
|
||||
}
|
||||
await formApi.setFieldValue('drug_id', drugId);
|
||||
// 搜药选中后若带总仓价则预填平台费 5%
|
||||
const price = resolveCentralPrice(item) ?? resolveCentralPrice(item?.drug);
|
||||
if (price != null) {
|
||||
await applyCentralPrice(price, true);
|
||||
// 搜药选中后若带总仓售价/供货价则按新公式自动算费
|
||||
const price =
|
||||
resolveCentralPrice(item) ?? resolveCentralPrice(item?.drug);
|
||||
const market =
|
||||
resolveCentralMarketPrice(item) ??
|
||||
resolveCentralMarketPrice(item?.drug);
|
||||
if (price != null || market != null) {
|
||||
await applyCentralPrices(price, market, true);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -11,15 +11,25 @@ export function calcFeeSum(values: Record<string, any>) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店推广费 = 售价 − (报价 + 平台费),不低于 0
|
||||
* 有售价时用于自动回填,保证三费合计贴合售价
|
||||
* 推广费 = 商品售价 − 平台供货价,不低于 0
|
||||
* 有售价与供货价时用于自动回填
|
||||
*/
|
||||
export function calcPromoFee(values: Record<string, any>): number {
|
||||
const sale = Number(values.sale_price) || 0;
|
||||
if (!(sale > 0)) return Number(values.promo_fee) || 0;
|
||||
const market = Number(values.market_price) || 0;
|
||||
if (!(sale > 0) || !(market > 0)) return Number(values.promo_fee) || 0;
|
||||
return Number(Math.max(0, sale - market).toFixed(4));
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台费 = 平台供货价 − 仓库报价,不低于 0
|
||||
* 有供货价时用于自动回填
|
||||
*/
|
||||
export function calcPlatformFee(values: Record<string, any>): number {
|
||||
const market = Number(values.market_price) || 0;
|
||||
if (!(market > 0)) return Number(values.platform_fee) || 0;
|
||||
const quote = Number(values.quote) || 0;
|
||||
const platformFee = Number(values.platform_fee) || 0;
|
||||
return Number(Math.max(0, sale - quote - platformFee).toFixed(4));
|
||||
return Number(Math.max(0, market - quote).toFixed(4));
|
||||
}
|
||||
|
||||
/** 三费是否超过药品售价 */
|
||||
@@ -34,8 +44,8 @@ type FeeOverTipHandler = (tip: string) => void;
|
||||
let feeOverTipHandler: FeeOverTipHandler | null = null;
|
||||
|
||||
/**
|
||||
* 记录上次自动算费依赖(售价|报价|平台费)
|
||||
* 仅依赖变化时覆盖 promo_fee,避免手改推广费被立刻冲掉
|
||||
* 记录上次自动算费依赖(售价|供货价|报价)
|
||||
* 仅依赖变化时覆盖两费,避免手改被立刻冲掉
|
||||
*/
|
||||
let lastAutoPromoKey = '';
|
||||
|
||||
@@ -50,47 +60,55 @@ export function resetAutoPromoFeeKey() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑回填后锁定当前依赖 key,避免一打开就把已有推广费冲掉
|
||||
* 之后只有改报价/平台费/售价才会重新自动算
|
||||
* 编辑回填后锁定当前依赖 key,避免一打开就把已有两费冲掉
|
||||
* 之后只有改售价/供货价/报价才会重新自动算
|
||||
*/
|
||||
export function seedAutoPromoFeeKey(values: Record<string, any>) {
|
||||
const sale = Number(values.sale_price) || 0;
|
||||
if (!(sale > 0)) {
|
||||
const market = Number(values.market_price) || 0;
|
||||
if (!(sale > 0) && !(market > 0)) {
|
||||
lastAutoPromoKey = '';
|
||||
return;
|
||||
}
|
||||
lastAutoPromoKey = `${sale}|${Number(values.quote) || 0}|${Number(values.platform_fee) || 0}`;
|
||||
lastAutoPromoKey = `${sale}|${market}|${Number(values.quote) || 0}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 有售价且 quote/platform/sale 变化时,自动回填门店推广费
|
||||
* @returns 回填后的 values(含最新 promo_fee),供合计展示使用
|
||||
* 有售价/供货价且 sale/market/quote 变化时,自动回填推广费与平台费
|
||||
* @returns 回填后的 values(含最新两费),供合计展示使用
|
||||
*/
|
||||
export function applyAutoPromoFee(
|
||||
values: Record<string, any>,
|
||||
formApi: any,
|
||||
): Record<string, any> {
|
||||
const sale = Number(values.sale_price) || 0;
|
||||
if (!(sale > 0)) {
|
||||
const market = Number(values.market_price) || 0;
|
||||
// 无售价且无供货价时不强算
|
||||
if (!(sale > 0) && !(market > 0)) {
|
||||
return values;
|
||||
}
|
||||
const key = `${sale}|${Number(values.quote) || 0}|${Number(values.platform_fee) || 0}`;
|
||||
const nextPromo = calcPromoFee(values);
|
||||
// 依赖未变:可能是手改推广费触发,不覆盖
|
||||
const key = `${sale}|${market}|${Number(values.quote) || 0}`;
|
||||
// 依赖未变:可能是手改推广费/平台费触发,不覆盖
|
||||
if (key === lastAutoPromoKey) {
|
||||
return values;
|
||||
}
|
||||
lastAutoPromoKey = key;
|
||||
const cur = Number(values.promo_fee);
|
||||
if (!(Math.abs(cur - nextPromo) < 0.00005)) {
|
||||
const nextPromo = calcPromoFee(values);
|
||||
const nextPlatform = calcPlatformFee(values);
|
||||
const curPromo = Number(values.promo_fee);
|
||||
const curPlatform = Number(values.platform_fee);
|
||||
if (!(Math.abs(curPromo - nextPromo) < 0.00005)) {
|
||||
formApi.setFieldValue('promo_fee', nextPromo);
|
||||
}
|
||||
return { ...values, promo_fee: nextPromo };
|
||||
if (!(Math.abs(curPlatform - nextPlatform) < 0.00005)) {
|
||||
formApi.setFieldValue('platform_fee', nextPlatform);
|
||||
}
|
||||
return { ...values, promo_fee: nextPromo, platform_fee: nextPlatform };
|
||||
}
|
||||
|
||||
/**
|
||||
* 费用合计联动:先按差额回填推广费,再刷新合计 / 超售价提示
|
||||
* 为什么放在 trigger:输入报价或平台费即触发,不必等提交
|
||||
* 费用合计联动:先按新公式回填两费,再刷新合计 / 超售价提示
|
||||
* 为什么放在 trigger:输入报价或供货价即触发,不必等提交
|
||||
* @returns 超售价提示文案(无则空串)
|
||||
*/
|
||||
export function syncFeeSumDisplay(
|
||||
@@ -101,14 +119,16 @@ export function syncFeeSumDisplay(
|
||||
const sum = calcFeeSum(merged);
|
||||
formApi.setFieldValue('_fee_sum', sum);
|
||||
const sale = Number(merged.sale_price) || 0;
|
||||
const market = Number(merged.market_price) || 0;
|
||||
const canAuto = sale > 0 && market > 0;
|
||||
const over = sale > 0 && Number(sum) > sale;
|
||||
const tip = over
|
||||
? `三费合计已超过药品售价 ¥${sale.toFixed(4)},请下调报价/推广费/平台费`
|
||||
: '';
|
||||
const feeHelp = over
|
||||
? tip
|
||||
: sale > 0
|
||||
? `推广费自动=售价−(报价+平台费);合计不得超过 ¥${sale.toFixed(4)}`
|
||||
: canAuto
|
||||
? `推广费=售价−供货价,平台费=供货价−报价;合计不得超过 ¥${sale.toFixed(4)}`
|
||||
: '报价+推广费+平台费之和,保存时需大于0';
|
||||
// 单项输入上限:有售价时不得超过售价;同时刷新合计 help
|
||||
const feeInputProps = {
|
||||
@@ -127,17 +147,18 @@ export function syncFeeSumDisplay(
|
||||
},
|
||||
{
|
||||
fieldName: 'promo_fee',
|
||||
help: sale > 0 ? '自动计算:售价 − (报价 + 平台费),可微调' : undefined,
|
||||
help: canAuto ? '自动计算:售价 − 平台供货价,可微调' : undefined,
|
||||
componentProps: {
|
||||
...feeInputProps,
|
||||
placeholder: sale > 0 ? '自动=售价−报价−平台费' : '请输入推广费',
|
||||
placeholder: canAuto ? '自动=售价−供货价' : '请输入推广费',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'platform_fee',
|
||||
help: market > 0 ? '自动计算:平台供货价 − 仓库报价,可微调' : undefined,
|
||||
componentProps: {
|
||||
...feeInputProps,
|
||||
placeholder: '请输入平台费',
|
||||
placeholder: market > 0 ? '自动=供货价−报价' : '请输入平台费',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -216,6 +237,19 @@ export const modalFormProps: VbenFormProps = {
|
||||
label: '药品售价',
|
||||
help: '来自总仓库建议售价;三费合计不得超过该值',
|
||||
},
|
||||
{
|
||||
// 总仓供货价只读,用于自动算推广费/平台费
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
precision: 4,
|
||||
class: 'w-full',
|
||||
placeholder: '无总仓供货价',
|
||||
},
|
||||
fieldName: 'market_price',
|
||||
label: '平台供货价',
|
||||
help: '来自总仓库供货价;推广费=售价−供货价,平台费=供货价−报价',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
@@ -238,7 +272,7 @@ export const modalFormProps: VbenFormProps = {
|
||||
},
|
||||
fieldName: 'promo_fee',
|
||||
label: '推广费',
|
||||
help: '有售价时自动=售价−(报价+平台费)',
|
||||
help: '有售价与供货价时自动=售价−供货价',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
@@ -251,6 +285,7 @@ export const modalFormProps: VbenFormProps = {
|
||||
},
|
||||
fieldName: 'platform_fee',
|
||||
label: '平台费',
|
||||
help: '有供货价时自动=供货价−报价',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
@@ -266,7 +301,13 @@ export const modalFormProps: VbenFormProps = {
|
||||
trigger(values, formApi) {
|
||||
syncFeeSumDisplay(values, formApi);
|
||||
},
|
||||
triggerFields: ['quote', 'promo_fee', 'platform_fee', 'sale_price'],
|
||||
triggerFields: [
|
||||
'quote',
|
||||
'promo_fee',
|
||||
'platform_fee',
|
||||
'sale_price',
|
||||
'market_price',
|
||||
],
|
||||
},
|
||||
},
|
||||
// 创建时可填初始库存,提交后走入库流水(编辑时不展示)
|
||||
|
||||
@@ -21,3 +21,27 @@ export function resolveCentralPrice(
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从列表行 / 弹窗入参中解析总仓平台供货价(market_price)
|
||||
* 用于三费自动计算:推广费=售价−供货价,平台费=供货价−报价
|
||||
*/
|
||||
export function resolveCentralMarketPrice(
|
||||
source: Record<string, any> | null | undefined,
|
||||
): number | null {
|
||||
if (!source) return null;
|
||||
const nested =
|
||||
source.central_warehouse_drug ?? source.centralWarehouseDrug ?? null;
|
||||
const candidates = [
|
||||
source.central_market_price,
|
||||
source.centralMarketPrice,
|
||||
nested?.market_price,
|
||||
source.market_price,
|
||||
source.marketPrice,
|
||||
];
|
||||
for (const c of candidates) {
|
||||
const n = Number(c);
|
||||
if (n > 0) return Number(n.toFixed(4));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -29,13 +29,12 @@ const gridApi = ref();
|
||||
const detail = ref<Record<string, any> | null>(null);
|
||||
/** 三费超售价红色提示 */
|
||||
const feeOverTip = ref('');
|
||||
/** 记录已按售价自动填过平台费的售价,避免反复覆盖手改 */
|
||||
const lastAutoPlatformSale = ref(0);
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
wrapperClass: 'grid-cols-12',
|
||||
// 一行两个:默认半宽,弹窗加宽后排布更紧凑
|
||||
commonConfig: {
|
||||
formItemClass: 'col-span-12',
|
||||
formItemClass: 'col-span-6',
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
@@ -145,7 +144,7 @@ const [Form, formApi] = useVbenForm({
|
||||
fieldName: 'market_price',
|
||||
label: '仓库供货价',
|
||||
rules: 'required',
|
||||
help: '写入总仓并同步到门店供货价',
|
||||
help: '写入总仓并同步到门店;推广费=售价−本价,平台费=本价−绑仓报价',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
@@ -184,12 +183,12 @@ const [Form, formApi] = useVbenForm({
|
||||
fieldName: 'platform_fee',
|
||||
label: '平台费',
|
||||
rules: 'required',
|
||||
help: '默认售价的 5%,可改',
|
||||
help: '自动=平台供货价−仓库报价,可改',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '自动=售价−报价−平台费',
|
||||
placeholder: '自动=售价−供货价',
|
||||
min: 0,
|
||||
precision: 4,
|
||||
class: 'w-full',
|
||||
@@ -197,7 +196,7 @@ const [Form, formApi] = useVbenForm({
|
||||
fieldName: 'promo_fee',
|
||||
label: '推广费',
|
||||
rules: 'required',
|
||||
help: '有售价时自动计算,可微调',
|
||||
help: '自动=售价−平台供货价,可微调',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
@@ -210,23 +209,22 @@ const [Form, formApi] = useVbenForm({
|
||||
// 把 price 映射为仓药绑定逻辑里的 sale_price,复用三费联动
|
||||
dependencies: {
|
||||
async trigger(values, formApiInst) {
|
||||
const sale = Number(values.price) || 0;
|
||||
// 售价变化时默认平台费 = 售价 * 5%(仅该售价首次自动填)
|
||||
if (sale > 0 && lastAutoPlatformSale.value !== sale) {
|
||||
const platform = Number((sale * 0.05).toFixed(4));
|
||||
await formApiInst.setFieldValue('platform_fee', platform);
|
||||
lastAutoPlatformSale.value = sale;
|
||||
values = { ...values, platform_fee: platform };
|
||||
}
|
||||
syncFeeSumDisplay(
|
||||
{
|
||||
...values,
|
||||
sale_price: sale,
|
||||
sale_price: Number(values.price) || 0,
|
||||
market_price: Number(values.market_price) || 0,
|
||||
},
|
||||
formApiInst,
|
||||
);
|
||||
},
|
||||
triggerFields: ['quote', 'promo_fee', 'platform_fee', 'price'],
|
||||
triggerFields: [
|
||||
'quote',
|
||||
'promo_fee',
|
||||
'platform_fee',
|
||||
'price',
|
||||
'market_price',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -262,60 +260,60 @@ const [Modal, modalApi] = useVbenModal({
|
||||
onConfirm: async () => {
|
||||
const e = await formApi.validate();
|
||||
if (!e.valid) return;
|
||||
const values = await formApi.getValues();
|
||||
const status = Number(values.status);
|
||||
if (status !== 2 && status !== 3) {
|
||||
message.warning('请选择上架或下架');
|
||||
return;
|
||||
}
|
||||
if (!values.zone_id) {
|
||||
message.warning('请选择所属分区');
|
||||
return;
|
||||
}
|
||||
const drugNumber = String(values.drug_number || '').trim();
|
||||
if (!drugNumber) {
|
||||
message.warning('请填写 ERP 编号(无 ERP 可点「非erp」填 -1)');
|
||||
return;
|
||||
}
|
||||
const feeValues = {
|
||||
quote: values.quote,
|
||||
promo_fee: values.promo_fee,
|
||||
platform_fee: values.platform_fee,
|
||||
sale_price: values.price,
|
||||
};
|
||||
if (isFeeOverSalePrice(feeValues)) {
|
||||
message.warning(
|
||||
`三费合计已超过售价 ¥${Number(values.price).toFixed(4)}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (Number(calcFeeSum(feeValues)) <= 0) {
|
||||
message.warning('报价/推广费/平台费合计必须大于0');
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
auditDeliveryWarehouseProduct({
|
||||
id: Number(values.id),
|
||||
status: status as 2 | 3,
|
||||
zone_id: Number(values.zone_id),
|
||||
category_id: Number(values.category_id || 0),
|
||||
drug_number: drugNumber,
|
||||
market_price: Number(values.market_price),
|
||||
price: Number(values.price),
|
||||
quote: Number(values.quote),
|
||||
promo_fee: Number(values.promo_fee),
|
||||
platform_fee: Number(values.platform_fee),
|
||||
initial_stock: Number(values.initial_stock || 0),
|
||||
})
|
||||
.then(() => {
|
||||
message.success('审核成功,已完成总仓同步与仓药绑定');
|
||||
gridApi.value?.query?.() ?? gridApi.value?.reload?.();
|
||||
modalApi.close();
|
||||
})
|
||||
.finally(() => {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
});
|
||||
|
||||
const values = await formApi.getValues();
|
||||
const status = Number(values.status);
|
||||
if (status !== 2 && status !== 3) {
|
||||
message.warning('请选择上架或下架');
|
||||
return;
|
||||
}
|
||||
if (!values.zone_id) {
|
||||
message.warning('请选择所属分区');
|
||||
return;
|
||||
}
|
||||
const drugNumber = String(values.drug_number || '').trim();
|
||||
if (!drugNumber) {
|
||||
message.warning('请填写 ERP 编号(无 ERP 可点「非erp」填 -1)');
|
||||
return;
|
||||
}
|
||||
const feeValues = {
|
||||
quote: values.quote,
|
||||
promo_fee: values.promo_fee,
|
||||
platform_fee: values.platform_fee,
|
||||
sale_price: values.price,
|
||||
};
|
||||
if (isFeeOverSalePrice(feeValues)) {
|
||||
message.warning(
|
||||
`三费合计已超过售价 ¥${Number(values.price).toFixed(4)}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (Number(calcFeeSum(feeValues)) <= 0) {
|
||||
message.warning('报价/推广费/平台费合计必须大于0');
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
await auditDeliveryWarehouseProduct({
|
||||
id: Number(values.id),
|
||||
status: status as 2 | 3,
|
||||
zone_id: Number(values.zone_id),
|
||||
category_id: Number(values.category_id || 0),
|
||||
drug_number: drugNumber,
|
||||
market_price: Number(values.market_price),
|
||||
price: Number(values.price),
|
||||
quote: Number(values.quote),
|
||||
promo_fee: Number(values.promo_fee),
|
||||
platform_fee: Number(values.platform_fee),
|
||||
initial_stock: Number(values.initial_stock || 0),
|
||||
});
|
||||
message.success('审核成功,已完成总仓同步与仓药绑定');
|
||||
gridApi.value?.query?.() ?? gridApi.value?.reload?.();
|
||||
modalApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
@@ -326,7 +324,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||
const data = modalApi.getData<Record<string, any>>() || {};
|
||||
gridApi.value = data.gridApi ?? null;
|
||||
resetAutoPromoFeeKey();
|
||||
lastAutoPlatformSale.value = 0;
|
||||
feeOverTip.value = '';
|
||||
await formApi.resetForm();
|
||||
const id = Number(data.id || data.values?.id || 0);
|
||||
@@ -364,18 +361,25 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="仓品审核" class="w-[80%] md:w-[560px] lg:w-[520px]">
|
||||
<!-- 加宽弹窗,配合表单一行两列 -->
|
||||
<Modal title="仓品审核" class="w-[92%] md:w-[780px] lg:w-[860px]">
|
||||
<div v-if="detail" class="mb-4">
|
||||
<Descriptions :column="1" size="small" bordered>
|
||||
<Descriptions :column="2" size="small" bordered>
|
||||
<Descriptions.Item label="药品名称">
|
||||
{{ detail.drug_name || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="规格">
|
||||
{{ detail.specification || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="别名">
|
||||
{{ detail.drug_alias || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="类型">
|
||||
{{ detail.type_txt || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="供应商">
|
||||
{{ detail.supplier?.name || '-' }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="上传报价">
|
||||
¥{{ detail.upload_quote || '0' }}
|
||||
</Descriptions.Item>
|
||||
|
||||
@@ -6,7 +6,13 @@ interface RowType {
|
||||
id: number;
|
||||
image?: string;
|
||||
drug_name: string;
|
||||
/** 规格、别名等仓侧建品信息,审核列表需一眼可见 */
|
||||
specification?: string;
|
||||
drug_alias?: string;
|
||||
type_txt?: string;
|
||||
/** 仓侧上传报价,审核绑仓时默认带入 */
|
||||
upload_quote?: number | string;
|
||||
supplier?: { id?: number; name?: string };
|
||||
audit_status: number;
|
||||
audit_status_txt?: string;
|
||||
status: number;
|
||||
@@ -39,7 +45,27 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
slots: { default: 'image' },
|
||||
},
|
||||
{ field: 'drug_name', title: '药品名称', minWidth: 160 },
|
||||
{ field: 'specification', title: '规格', minWidth: 120 },
|
||||
{ field: 'drug_alias', title: '别名', minWidth: 120 },
|
||||
{ field: 'type_txt', title: '类型', width: 110 },
|
||||
{
|
||||
field: 'supplier.name',
|
||||
title: '供应商',
|
||||
minWidth: 120,
|
||||
formatter: ({ row }) => row?.supplier?.name || '—',
|
||||
},
|
||||
{
|
||||
field: 'upload_quote',
|
||||
title: '上传报价',
|
||||
width: 110,
|
||||
formatter: ({ cellValue }) => {
|
||||
// 与审核弹窗「上传报价」一致,空值显示 —
|
||||
if (cellValue === null || cellValue === undefined || cellValue === '') {
|
||||
return '—';
|
||||
}
|
||||
return `¥${cellValue}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'audit_status_txt',
|
||||
title: '审核状态',
|
||||
|
||||
@@ -96,7 +96,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{ field: 'status', title: '状态', width: 90, slots: { default: 'status' } },
|
||||
{ field: 'sort', title: '排序', width: 80 },
|
||||
{ field: 'created_at', title: '创建时间', width: 170 },
|
||||
{ title: '操作', slots: { default: 'action' }, width: 220, fixed: 'right' },
|
||||
// 三个操作横排需要约 200+;过窄会挤换行,配合 TableAction :flex=false 避免两列叠字
|
||||
{ title: '操作', slots: { default: 'action' }, width: 240, fixed: 'right' },
|
||||
],
|
||||
keepSource: true,
|
||||
pagerConfig: {},
|
||||
@@ -334,7 +335,9 @@ async function handleConfirmImport(payload: { rows: any[]; sourceId: number }) {
|
||||
</Tag>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<!-- flex=false:超过 2 个按钮时禁止两列 grid,避免行高被裁切叠字 -->
|
||||
<TableAction
|
||||
:flex="false"
|
||||
:actions="[
|
||||
{
|
||||
label: '编辑',
|
||||
|
||||
162
apps/web-antd/src/views/system/menu/components/auth-role.vue
Normal file
162
apps/web-antd/src/views/system/menu/components/auth-role.vue
Normal file
@@ -0,0 +1,162 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 菜单反向授权抽屉:勾选角色后全量同步该菜单在 xk_role_menu_relations 中的绑定
|
||||
* 与「角色→授权菜单」共用同一张关系表,入口方向相反
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenDrawer } from '@vben/common-ui';
|
||||
|
||||
import { Alert, Button, Checkbox, Empty, Spin, message } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
getRoleIdsByMenuId,
|
||||
getRoleOption,
|
||||
saveMenuRoles,
|
||||
} from '#/views/system/role/api';
|
||||
|
||||
type RoleOptionItem = { label: string; value: number };
|
||||
|
||||
const record = ref<any>({});
|
||||
const loading = ref(false);
|
||||
const roleOptions = ref<RoleOptionItem[]>([]);
|
||||
const selectedRoleIds = ref<number[]>([]);
|
||||
|
||||
const drawerTitle = computed(() => {
|
||||
const menuName = record.value?.title || record.value?.name || '';
|
||||
return menuName ? `授权角色 - ${menuName}` : '授权角色';
|
||||
});
|
||||
|
||||
/** 是否勾选了超级管理员(role_id=1);登录时超管不依赖关系表,需提示 */
|
||||
const hasSuperAdmin = computed(() => selectedRoleIds.value.includes(1));
|
||||
|
||||
/**
|
||||
* 加载全部角色选项 + 当前菜单已绑定角色,用于回显勾选
|
||||
*/
|
||||
async function loadData() {
|
||||
const menuId = Number(record.value?.id || 0);
|
||||
if (!menuId) {
|
||||
roleOptions.value = [];
|
||||
selectedRoleIds.value = [];
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const [options, boundIds] = await Promise.all([
|
||||
getRoleOption({}),
|
||||
getRoleIdsByMenuId(menuId),
|
||||
]);
|
||||
roleOptions.value = (Array.isArray(options) ? options : [])
|
||||
.map((item: any) => ({
|
||||
label: String(item.label || item.name || ''),
|
||||
value: Number(item.value || item.id),
|
||||
}))
|
||||
.filter((item: RoleOptionItem) => item.value > 0 && item.label);
|
||||
const ids = Array.isArray(boundIds) ? boundIds : [];
|
||||
selectedRoleIds.value = ids
|
||||
.map((id: any) => Number(id))
|
||||
.filter((id) => id > 0);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 全选当前列表中的角色 */
|
||||
function selectAll() {
|
||||
selectedRoleIds.value = roleOptions.value.map((row) => row.value);
|
||||
}
|
||||
|
||||
/** 清空勾选 */
|
||||
function clearAll() {
|
||||
selectedRoleIds.value = [];
|
||||
}
|
||||
|
||||
/** 反选 */
|
||||
function invertAll() {
|
||||
const set = new Set(selectedRoleIds.value);
|
||||
selectedRoleIds.value = roleOptions.value
|
||||
.map((row) => row.value)
|
||||
.filter((id) => !set.has(id));
|
||||
}
|
||||
|
||||
const [Drawer, DrawerApi] = useVbenDrawer({
|
||||
onOpenChange: async (isOpen) => {
|
||||
record.value = isOpen ? DrawerApi.getData()?.record : {};
|
||||
if (isOpen) {
|
||||
await loadData();
|
||||
} else {
|
||||
selectedRoleIds.value = [];
|
||||
roleOptions.value = [];
|
||||
}
|
||||
},
|
||||
onConfirm: async () => {
|
||||
const menuId = Number(record.value?.id || 0);
|
||||
if (!menuId) {
|
||||
message.warning('菜单无效');
|
||||
return;
|
||||
}
|
||||
DrawerApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
await saveMenuRoles({
|
||||
menu_id: menuId,
|
||||
role_id: selectedRoleIds.value.slice(),
|
||||
});
|
||||
message.success('授权成功');
|
||||
DrawerApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
DrawerApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineExpose(DrawerApi);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer class="w-[520px]" :title="drawerTitle">
|
||||
<Spin :spinning="loading">
|
||||
<Alert
|
||||
v-if="hasSuperAdmin"
|
||||
class="mb-3"
|
||||
type="info"
|
||||
show-icon
|
||||
message="超级管理员登录时默认拥有全部菜单,不依赖本关系表;勾选仍会写入绑定记录。"
|
||||
/>
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<Button size="small" @click="selectAll">全选</Button>
|
||||
<Button size="small" @click="clearAll">清空</Button>
|
||||
<Button size="small" @click="invertAll">反选</Button>
|
||||
<span class="text-muted-foreground text-xs">
|
||||
已选 {{ selectedRoleIds.length }} / {{ roleOptions.length }}
|
||||
</span>
|
||||
</div>
|
||||
<Empty
|
||||
v-if="!loading && roleOptions.length === 0"
|
||||
description="暂无角色可选"
|
||||
/>
|
||||
<Checkbox.Group
|
||||
v-else
|
||||
v-model:value="selectedRoleIds"
|
||||
class="flex w-full flex-col gap-2"
|
||||
>
|
||||
<div
|
||||
v-for="item in roleOptions"
|
||||
:key="item.value"
|
||||
class="border-border hover:bg-muted/40 rounded border px-3 py-2"
|
||||
>
|
||||
<Checkbox :value="item.value">
|
||||
<span>{{ item.label }}</span>
|
||||
<span class="text-muted-foreground ml-2 text-xs">
|
||||
#{{ item.value }}
|
||||
</span>
|
||||
<span v-if="item.value === 1" class="text-primary ml-2 text-xs">
|
||||
(超管默认全菜单)
|
||||
</span>
|
||||
</Checkbox>
|
||||
</div>
|
||||
</Checkbox.Group>
|
||||
</Spin>
|
||||
</Drawer>
|
||||
</template>
|
||||
@@ -4,18 +4,18 @@ import type { VxeGridListeners } from '#/adapter/vxe-table';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import AuthMenu from '../role/components/auth-menu.vue';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { Icon } from '#/components/icon';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
|
||||
import { deleteMenu } from './api';
|
||||
import AuthRole from './components/auth-role.vue';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { gridOptions } from './config/table';
|
||||
import {Icon} from "#/components/icon";
|
||||
|
||||
const hasTopTableDropDownActions = ref(false);
|
||||
|
||||
@@ -72,11 +72,19 @@ const expandAll = () => {
|
||||
const collapseAll = () => {
|
||||
gridApi.grid?.setAllTreeExpand(false);
|
||||
};
|
||||
|
||||
/** 菜单反向授权:打开角色勾选抽屉 */
|
||||
const authRoleRef = ref();
|
||||
const handleAuthRole = (record: any) => {
|
||||
authRoleRef.value.setData({ record });
|
||||
authRoleRef.value.open();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="菜单管理">
|
||||
<FormModal />
|
||||
<AuthRole ref="authRoleRef" />
|
||||
<Grid>
|
||||
<template #toolbar-actions>
|
||||
<TableAction
|
||||
@@ -137,6 +145,13 @@ const collapseAll = () => {
|
||||
// auth: ['admin', 'sys:role:detail'],
|
||||
onClick: showModal.bind(null, row, true),
|
||||
},
|
||||
{
|
||||
label: '授权角色',
|
||||
type: 'link',
|
||||
icon: 'ant-design:team-outlined',
|
||||
size: 'small',
|
||||
onClick: handleAuthRole.bind(null, row),
|
||||
},
|
||||
]"
|
||||
:drop-down-actions="[
|
||||
{
|
||||
@@ -150,17 +165,6 @@ const collapseAll = () => {
|
||||
confirm: deleteApi.bind(null, row.id),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'link',
|
||||
icon: 'ant-design:delete-outlined',
|
||||
size: 'small',
|
||||
// auth: ['admin', 'sys:role:detail'],
|
||||
popConfirm: {
|
||||
title: '确定删除吗?',
|
||||
confirm: deleteApi.bind(null, row.id),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -44,6 +44,25 @@ export async function saveRoleMenu(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}save-role-menu`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按菜单反查已授权的角色 ID(菜单→角色反向授权回显)
|
||||
*/
|
||||
export async function getRoleIdsByMenuId(menuId: number) {
|
||||
return requestClient.get<any>(`${prefix}get-role-ids-by-menu-id`, {
|
||||
params: { menu_id: menuId },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单反向授权:全量同步该菜单绑定的角色
|
||||
*/
|
||||
export async function saveMenuRoles(data: {
|
||||
menu_id: number;
|
||||
role_id: number[];
|
||||
}) {
|
||||
return requestClient.post<any>(`${prefix}save-menu-roles`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
* @param data
|
||||
@@ -68,6 +87,48 @@ export async function deleteRole(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}delete`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计无任何菜单绑定的角色
|
||||
*/
|
||||
export async function countEmptyMenuRoles() {
|
||||
return requestClient.get<any>(`${prefix}count-empty-menu-roles`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按模板角色为「空菜单」角色批量补全菜单
|
||||
*/
|
||||
export async function backfillEmptyMenuRoles(data: { source_role_id: number }) {
|
||||
return requestClient.post<any>(`${prefix}backfill-empty-role-menus`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计缺少管理员管理菜单的预设角色
|
||||
*/
|
||||
export async function countMissingAdminMenus() {
|
||||
return requestClient.get<any>(`${prefix}count-missing-admin-menus`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为预设管理员角色补全「管理员」菜单组
|
||||
*/
|
||||
export async function syncAdminManagementMenus() {
|
||||
return requestClient.post<any>(`${prefix}sync-admin-management-menus`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计缺少管理员管理入口的自定义角色
|
||||
*/
|
||||
export async function countMissingCustomAdminMenus() {
|
||||
return requestClient.get<any>(`${prefix}count-missing-custom-admin-menus`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为历史自定义角色批量补生成管理员管理入口
|
||||
*/
|
||||
export async function backfillCustomRoleAdminMenus() {
|
||||
return requestClient.post<any>(`${prefix}backfill-custom-role-admin-menus`);
|
||||
}
|
||||
|
||||
const workbenchPrefix = 'role-workbench-widget/';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,147 +1,52 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
|
||||
import { useVbenDrawer } from '@vben/common-ui';
|
||||
|
||||
import { Button, message, Tree } from 'ant-design-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { getAllNodeIds, getLeafNodeIds } from '#/util/tool';
|
||||
import { getMenuTreeOption } from '#/views/system/menu/api';
|
||||
import { saveRoleMenu } from '../api';
|
||||
import RoleMenuTree from './role-menu-tree.vue';
|
||||
|
||||
import { getMenuIdsByRoleIds, saveRoleMenu } from '../api';
|
||||
import {Icon} from "#/components/icon";
|
||||
const record = ref<any>({});
|
||||
const menuTreeRef = ref<InstanceType<typeof RoleMenuTree>>();
|
||||
|
||||
const record = ref();
|
||||
const treeRef = ref();
|
||||
const treeData = ref([]);
|
||||
const isExpand = ref(false);
|
||||
|
||||
// 计算标题:授权菜单 - 角色名称
|
||||
const drawerTitle = computed(() => {
|
||||
const roleName = record.value?.name || '';
|
||||
return roleName ? `授权菜单 - ${roleName}` : '授权菜单';
|
||||
});
|
||||
|
||||
// 勾选的key
|
||||
const checkedKeys = ref([]);
|
||||
// 提交的勾选的key,会进行特殊处理,包含半勾状态的父节点halfCheckedKeys
|
||||
const submitCheckedKeys = ref<any>([]);
|
||||
// 所有叶子节点key
|
||||
const leafKeys = ref<any>([]);
|
||||
// 所有节点key
|
||||
const allNodeIds = ref([]);
|
||||
// 当前展开的key
|
||||
const currentExpandedKeys = ref([]);
|
||||
/**
|
||||
* api请求成功回调
|
||||
*/
|
||||
const handleFetchSuccess = () => {
|
||||
getMenuIdsByRoleIds({
|
||||
id: record.value.id,
|
||||
// appCode: props.appCode,
|
||||
}).then((res: any) => {
|
||||
// 设置的勾选节点只能为叶子节点
|
||||
checkedKeys.value = res.filter((item: any) => {
|
||||
return leafKeys.value.includes(item);
|
||||
});
|
||||
submitCheckedKeys.value = res;
|
||||
});
|
||||
};
|
||||
const [Drawer, DrawerApi] = useVbenDrawer({
|
||||
onOpenChange(isOpen) {
|
||||
onOpenChange: async (isOpen) => {
|
||||
record.value = isOpen ? DrawerApi.getData()?.record : {};
|
||||
if (isOpen) {
|
||||
DrawerApi.setState({
|
||||
loading: true,
|
||||
});
|
||||
getMenuTreeOption({
|
||||
filterByUser: 1,
|
||||
})
|
||||
.then((res) => {
|
||||
treeData.value = res;
|
||||
leafKeys.value = getLeafNodeIds(res);
|
||||
allNodeIds.value = getAllNodeIds(res);
|
||||
handleFetchSuccess();
|
||||
})
|
||||
.finally(() => {
|
||||
DrawerApi.setState({
|
||||
loading: false,
|
||||
});
|
||||
});
|
||||
await nextTick();
|
||||
menuTreeRef.value?.reload();
|
||||
}
|
||||
},
|
||||
onConfirm() {
|
||||
const menus = submitCheckedKeys.value.map((item: any) => {
|
||||
return item;
|
||||
});
|
||||
DrawerApi.setState({
|
||||
loading: true,
|
||||
confirmLoading: true,
|
||||
});
|
||||
saveRoleMenu({
|
||||
role_id: record.value.id,
|
||||
menu_id: menus,
|
||||
})
|
||||
.then(() => {
|
||||
message.success('保存成功');
|
||||
DrawerApi.close();
|
||||
})
|
||||
.finally(() => {
|
||||
DrawerApi.setState({
|
||||
loading: false,
|
||||
confirmLoading: false,
|
||||
});
|
||||
onConfirm: async () => {
|
||||
const menus = menuTreeRef.value?.getSubmitMenuIds() || [];
|
||||
DrawerApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
await saveRoleMenu({
|
||||
role_id: record.value.id,
|
||||
menu_id: menus,
|
||||
});
|
||||
message.success('保存成功');
|
||||
DrawerApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
DrawerApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
});
|
||||
/**
|
||||
* 点击复选框触发处理
|
||||
* @param mCheckedKeys
|
||||
*/
|
||||
const handleCheck = (mCheckedKeys: any, e: any) => {
|
||||
checkedKeys.value = mCheckedKeys;
|
||||
// 提交的时候需要将半选的父节点也提交上
|
||||
submitCheckedKeys.value = [...mCheckedKeys, ...e.halfCheckedKeys];
|
||||
};
|
||||
// 展开折叠事件
|
||||
const handleExpand = (expandedKeys: any) => {
|
||||
currentExpandedKeys.value = expandedKeys;
|
||||
};
|
||||
// 展开折叠按钮事件
|
||||
const handleExpandAndCollapse = () => {
|
||||
isExpand.value = !isExpand.value;
|
||||
currentExpandedKeys.value = isExpand.value ? allNodeIds.value : [];
|
||||
};
|
||||
|
||||
defineExpose(DrawerApi);
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<Drawer class="w-[60%]" :title="drawerTitle">
|
||||
<Button type="primary" @click="handleExpandAndCollapse">
|
||||
{{ isExpand ? '折叠' : '展开' }}
|
||||
</Button>
|
||||
<Tree
|
||||
ref="treeRef"
|
||||
v-model:checked-keys="checkedKeys"
|
||||
:expanded-keys="currentExpandedKeys"
|
||||
:field-names="{
|
||||
title: 'title',
|
||||
key: 'id',
|
||||
}"
|
||||
:show-line="true"
|
||||
:tree-data="treeData"
|
||||
checkable
|
||||
style="margin: 20px auto"
|
||||
@check="handleCheck"
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<template #title="{ title, icon }">
|
||||
<Icon :icon="icon" />
|
||||
{{ $t(title) }}
|
||||
</template>
|
||||
</Tree>
|
||||
</Drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template>
|
||||
<Drawer class="w-[60%]" :title="drawerTitle">
|
||||
<RoleMenuTree ref="menuTreeRef" :role-id="record?.id" />
|
||||
</Drawer>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 补生成自定义角色的管理员管理入口:在「管理员」菜单组下创建管理页并授权超管/系统管理员
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Alert, message } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
backfillCustomRoleAdminMenus,
|
||||
countMissingCustomAdminMenus,
|
||||
} from '../api';
|
||||
|
||||
const missingCount = ref(0);
|
||||
const missingRoleIds = ref<number[]>([]);
|
||||
const gridApi = ref();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
const res = await backfillCustomRoleAdminMenus();
|
||||
const created = res?.created_count ?? 0;
|
||||
if (created > 0) {
|
||||
message.success(
|
||||
`已为 ${created} 个自定义角色生成管理员管理入口(超管/系统管理员重新登录后可见)`,
|
||||
);
|
||||
} else {
|
||||
message.info('没有需要补生成的自定义角色');
|
||||
}
|
||||
gridApi.value?.reload?.();
|
||||
modalApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
gridApi.value = modalApi.getData()?.gridApi;
|
||||
modalApi.setState({ loading: true });
|
||||
try {
|
||||
const res = await countMissingCustomAdminMenus();
|
||||
missingCount.value = res?.count ?? 0;
|
||||
missingRoleIds.value = res?.role_ids ?? [];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineExpose(modalApi);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[80%] md:w-[50%]" title="补生成管理员入口">
|
||||
<Alert
|
||||
class="mb-4"
|
||||
show-icon
|
||||
type="info"
|
||||
:message="
|
||||
missingCount > 0
|
||||
? `${missingCount} 个自定义角色缺少管理员管理入口`
|
||||
: '自定义角色的管理员管理入口已齐全'
|
||||
"
|
||||
:description="
|
||||
missingCount > 0
|
||||
? `待补生成角色 ID:${missingRoleIds.join('、')}(将在「管理员」下创建菜单,并授权超管/系统管理员)`
|
||||
: '可点击确定执行一次幂等检查'
|
||||
"
|
||||
/>
|
||||
<div class="text-sm text-[hsl(var(--muted-foreground))]">
|
||||
仅处理非预设自定义角色;每个角色会生成 path=/system/admin/role/{id}
|
||||
的管理页。预设角色(如诊所管理员)已有静态入口,不会重复创建。
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,105 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 补全空角色菜单弹窗:为从未绑定菜单的角色按模板角色批量写入菜单
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Alert, message, Select } from 'ant-design-vue';
|
||||
|
||||
import { backfillEmptyMenuRoles, countEmptyMenuRoles, getRoleOption } from '../api';
|
||||
|
||||
const emptyCount = ref(0);
|
||||
const emptyRoleIds = ref<number[]>([]);
|
||||
const roleOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const sourceRoleId = ref<number>();
|
||||
const gridApi = ref();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
if (!sourceRoleId.value) {
|
||||
message.warning('请选择模板角色');
|
||||
return;
|
||||
}
|
||||
if (emptyCount.value <= 0) {
|
||||
message.info('暂无需要补全的角色');
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
const res = await backfillEmptyMenuRoles({
|
||||
source_role_id: sourceRoleId.value,
|
||||
});
|
||||
const filled = res?.filled_count ?? 0;
|
||||
message.success(`已成功为 ${filled} 个角色补全菜单`);
|
||||
gridApi.value?.reload?.();
|
||||
modalApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
sourceRoleId.value = undefined;
|
||||
return;
|
||||
}
|
||||
gridApi.value = modalApi.getData()?.gridApi;
|
||||
modalApi.setState({ loading: true });
|
||||
try {
|
||||
const [countRes, options] = await Promise.all([
|
||||
countEmptyMenuRoles(),
|
||||
getRoleOption({}),
|
||||
]);
|
||||
emptyCount.value = countRes?.count ?? 0;
|
||||
emptyRoleIds.value = countRes?.role_ids ?? [];
|
||||
roleOptions.value = (options || []).map((item: any) => ({
|
||||
label: item.label || item.name,
|
||||
value: Number(item.value || item.id),
|
||||
}));
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineExpose(modalApi);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[80%] md:w-[50%]" title="补全空角色菜单">
|
||||
<Alert
|
||||
class="mb-4"
|
||||
show-icon
|
||||
type="info"
|
||||
:message="`待补全 ${emptyCount} 个角色(无任何菜单绑定)`"
|
||||
:description="
|
||||
emptyCount > 0
|
||||
? `角色 ID:${emptyRoleIds.join('、')}`
|
||||
: '当前没有需要补全的角色'
|
||||
"
|
||||
/>
|
||||
<div class="mb-2 text-sm text-[hsl(var(--muted-foreground))]">
|
||||
仅针对「从未绑定过任何菜单」的角色;选择模板角色后复制其全部菜单。已有菜单的角色不会被覆盖。
|
||||
若需补全「管理员管理」菜单组,请使用「同步管理员菜单」。
|
||||
</div>
|
||||
<Select
|
||||
v-model:value="sourceRoleId"
|
||||
allow-clear
|
||||
class="w-full"
|
||||
placeholder="请选择模板角色"
|
||||
:options="roleOptions"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
/>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,96 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 角色列表内「添加管理员」弹窗:按当前行 role_id 动态切换表单 schema 后提交 createAdmin
|
||||
* 复用 admin/_shared 的表单与 payload,避免各角色字段分叉再写一套
|
||||
*/
|
||||
import { nextTick, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createAdmin } from '#/views/system/admin/api';
|
||||
import { normalizeAdminPayload } from '#/views/system/admin/_shared/admin-payload';
|
||||
import { createAdminModalFormProps } from '#/views/system/admin/_shared/form-schemas';
|
||||
import { getRoleMeta } from '#/views/system/admin/_shared/role-meta';
|
||||
|
||||
const DEFAULT_AVATAR =
|
||||
'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk_upload_20251022/20251022104156946505ca86d97626c08882f31797dbcef49c.png';
|
||||
|
||||
/** 当前弹窗绑定的角色 ID(打开时写入,提交时带上) */
|
||||
const currentRoleId = ref(0);
|
||||
/** 当前角色表单类型,提交归一化用 */
|
||||
const currentFormType = ref(getRoleMeta(0).formType);
|
||||
|
||||
const [Form, formApi] = useVbenForm(
|
||||
createAdminModalFormProps(0, currentFormType.value),
|
||||
);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
const e = await formApi.validate();
|
||||
if (!e.valid) return;
|
||||
const roleId = currentRoleId.value;
|
||||
if (!roleId) {
|
||||
message.warning('角色无效');
|
||||
return;
|
||||
}
|
||||
const values = await formApi.getValues();
|
||||
const payload = normalizeAdminPayload(
|
||||
{ ...values, role_id: roleId },
|
||||
currentFormType.value,
|
||||
);
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
await createAdmin(payload);
|
||||
message.success('添加管理员成功');
|
||||
modalApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
currentRoleId.value = 0;
|
||||
return;
|
||||
}
|
||||
const data = modalApi.getData<Record<string, any>>() ?? {};
|
||||
const roleId = Number(data.role_id || data.id || 0);
|
||||
const roleName = String(data.role_name || data.name || '');
|
||||
if (!roleId) {
|
||||
message.warning('角色无效');
|
||||
modalApi.close();
|
||||
return;
|
||||
}
|
||||
const meta = getRoleMeta(roleId);
|
||||
currentRoleId.value = roleId;
|
||||
currentFormType.value = meta.formType;
|
||||
modalApi.setState({
|
||||
title: `添加管理员 - ${roleName || meta.title}`,
|
||||
});
|
||||
// 按角色切换字段(省市区/供应商/诊所等),用 setState 整表替换 schema
|
||||
const formProps = createAdminModalFormProps(roleId, meta.formType);
|
||||
formApi.setState({ schema: formProps.schema });
|
||||
await nextTick();
|
||||
formApi.resetForm();
|
||||
formApi.setValues({
|
||||
role_id: roleId,
|
||||
avatar: DEFAULT_AVATAR,
|
||||
});
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[60%]">
|
||||
<Form />
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -1,21 +1,64 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
/**
|
||||
* 角色新建/编辑弹窗:新建可一并勾选菜单;编辑可同步修改菜单授权
|
||||
*/
|
||||
import { nextTick, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
import { Divider, message, Select } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createRole, updateRole } from '#/views/system/role/api';
|
||||
import {
|
||||
createRole,
|
||||
getMenuIdsByRoleIds,
|
||||
getRoleOption,
|
||||
saveRoleMenu,
|
||||
updateRole,
|
||||
} from '#/views/system/role/api';
|
||||
import { modalFormProps } from '#/views/system/role/config/form';
|
||||
|
||||
|
||||
import RoleMenuTree from './role-menu-tree.vue';
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const gridApi = ref();
|
||||
const menuTreeRef = ref<InstanceType<typeof RoleMenuTree>>();
|
||||
const copyFromRoleId = ref<number>();
|
||||
const roleOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const initialMenuIds = ref<number[]>([]);
|
||||
const currentRoleId = ref<number>();
|
||||
|
||||
const [Form, formApi] = useVbenForm(modalFormProps);
|
||||
|
||||
/** 判断菜单勾选是否相对回显有变更 */
|
||||
const isMenuChanged = (menuIds: number[]) => {
|
||||
const current = [...menuIds].map(Number).sort((a, b) => a - b);
|
||||
const initial = [...initialMenuIds.value].map(Number).sort((a, b) => a - b);
|
||||
if (current.length !== initial.length) {
|
||||
return true;
|
||||
}
|
||||
return current.some((id, index) => id !== initial[index]);
|
||||
};
|
||||
|
||||
/** 加载角色下拉(从角色复制) */
|
||||
const loadRoleOptions = async () => {
|
||||
const options = await getRoleOption({});
|
||||
roleOptions.value = (options || []).map((item: any) => ({
|
||||
label: item.label || item.name,
|
||||
value: Number(item.value || item.id),
|
||||
}));
|
||||
};
|
||||
|
||||
/** 编辑时记录初始菜单,用于判断是否需要 saveRoleMenu */
|
||||
const loadInitialMenus = async (roleId?: number) => {
|
||||
if (!roleId) {
|
||||
initialMenuIds.value = [];
|
||||
return;
|
||||
}
|
||||
const res = await getMenuIdsByRoleIds({ id: roleId });
|
||||
initialMenuIds.value = (res || []).map((item: number) => Number(item));
|
||||
};
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
@@ -26,12 +69,28 @@ const [Modal, modalApi] = useVbenModal({
|
||||
const e = await formApi.validate();
|
||||
if (!e.valid) return;
|
||||
const values = await formApi.getValues();
|
||||
const menuIds = menuTreeRef.value?.getSubmitMenuIds() || [];
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
const submitApi = isUpdate.value ? updateRole : createRole;
|
||||
try {
|
||||
await submitApi(values);
|
||||
message.success('保存成功');
|
||||
gridApi.value?.reload();
|
||||
if (isUpdate.value) {
|
||||
await updateRole(values);
|
||||
if (isMenuChanged(menuIds)) {
|
||||
await saveRoleMenu({
|
||||
role_id: values.id,
|
||||
menu_id: menuIds,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
await createRole({
|
||||
...values,
|
||||
menu_id: menuIds,
|
||||
});
|
||||
message.success('创建成功,已自动生成管理员管理入口(超管/系统管理员重新登录后可见)');
|
||||
}
|
||||
if (isUpdate.value) {
|
||||
message.success('保存成功');
|
||||
}
|
||||
gridApi.value?.reload?.();
|
||||
modalApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@@ -39,20 +98,65 @@ const [Modal, modalApi] = useVbenModal({
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
onOpenChange: async (isOpen: boolean) => {
|
||||
gridApi.value = isOpen ? modalApi.getData()?.gridApi : null;
|
||||
if (isOpen) {
|
||||
const { values, update } = modalApi.getData<Record<string, any>>();
|
||||
if (values) {
|
||||
isUpdate.value = update;
|
||||
formApi.setValues(values);
|
||||
if (!isOpen) {
|
||||
copyFromRoleId.value = undefined;
|
||||
currentRoleId.value = undefined;
|
||||
initialMenuIds.value = [];
|
||||
return;
|
||||
}
|
||||
const { values, update } = modalApi.getData<Record<string, any>>();
|
||||
isUpdate.value = !!update;
|
||||
copyFromRoleId.value = undefined;
|
||||
currentRoleId.value = values?.id ? Number(values.id) : undefined;
|
||||
if (values) {
|
||||
formApi.setValues(values);
|
||||
}
|
||||
modalApi.setState({ loading: true });
|
||||
try {
|
||||
await loadRoleOptions();
|
||||
if (isUpdate.value && currentRoleId.value) {
|
||||
await loadInitialMenus(currentRoleId.value);
|
||||
} else {
|
||||
initialMenuIds.value = [];
|
||||
}
|
||||
await nextTick();
|
||||
await menuTreeRef.value?.reload();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false });
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="`${isUpdate === true ? '编辑' : '新增'}角色`" class="w-[80%] md:w-[50%] lg:w-[30%] h-[60%]">
|
||||
<Modal
|
||||
:title="`${isUpdate === true ? '编辑' : '新增'}角色`"
|
||||
class="w-[90%] md:w-[70%] lg:w-[50%]"
|
||||
>
|
||||
<Form />
|
||||
<Divider orientation="left">授权菜单</Divider>
|
||||
<div class="mb-3 flex items-center gap-2">
|
||||
<span class="shrink-0 text-sm text-[hsl(var(--muted-foreground))]">
|
||||
从角色复制
|
||||
</span>
|
||||
<Select
|
||||
v-model:value="copyFromRoleId"
|
||||
allow-clear
|
||||
class="flex-1"
|
||||
placeholder="选择模板角色预填菜单(可选)"
|
||||
:options="roleOptions"
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
/>
|
||||
</div>
|
||||
<RoleMenuTree
|
||||
ref="menuTreeRef"
|
||||
:copy-from-role-id="copyFromRoleId"
|
||||
:role-id="isUpdate ? currentRoleId : undefined"
|
||||
/>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 角色菜单授权树(新建/编辑/授权抽屉复用)
|
||||
* 勾选叶子节点展示,提交时合并半选父节点
|
||||
*/
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { Button, Spin, Tree } from 'ant-design-vue';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
import { Icon } from '#/components/icon';
|
||||
import { getAllNodeIds, getLeafNodeIds } from '#/util/tool';
|
||||
import { getMenuTreeOption } from '#/views/system/menu/api';
|
||||
|
||||
import { getMenuIdsByRoleIds } from '../api';
|
||||
|
||||
const props = defineProps<{
|
||||
/** 当前角色 ID,有则回显已授权菜单 */
|
||||
roleId?: number;
|
||||
/** 从模板角色复制菜单勾选 */
|
||||
copyFromRoleId?: number;
|
||||
}>();
|
||||
|
||||
const treeRef = ref();
|
||||
const treeData = ref<any[]>([]);
|
||||
const isExpand = ref(false);
|
||||
const loading = ref(false);
|
||||
const checkedKeys = ref<number[]>([]);
|
||||
const submitCheckedKeys = ref<number[]>([]);
|
||||
const leafKeys = ref<number[]>([]);
|
||||
const allNodeIds = ref<number[]>([]);
|
||||
const currentExpandedKeys = ref<number[]>([]);
|
||||
|
||||
/**
|
||||
* 按角色 ID 加载菜单勾选(叶子展示 + 提交含半选父节点)
|
||||
*/
|
||||
const loadMenuIdsByRole = async (roleId?: number) => {
|
||||
if (!roleId) {
|
||||
checkedKeys.value = [];
|
||||
submitCheckedKeys.value = [];
|
||||
return;
|
||||
}
|
||||
const res = await getMenuIdsByRoleIds({ id: roleId });
|
||||
const menuIds = (res || []).map((item: number) => Number(item));
|
||||
checkedKeys.value = menuIds.filter((item: number) => leafKeys.value.includes(item));
|
||||
submitCheckedKeys.value = menuIds;
|
||||
};
|
||||
|
||||
/**
|
||||
* 初始化菜单树数据
|
||||
*/
|
||||
const initTree = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getMenuTreeOption({ filterByUser: 1 });
|
||||
treeData.value = res;
|
||||
leafKeys.value = getLeafNodeIds(res);
|
||||
allNodeIds.value = getAllNodeIds(res);
|
||||
const sourceRoleId = props.copyFromRoleId || props.roleId;
|
||||
await loadMenuIdsByRole(sourceRoleId);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => [props.roleId, props.copyFromRoleId] as const,
|
||||
async () => {
|
||||
if (!treeData.value.length) {
|
||||
return;
|
||||
}
|
||||
const sourceRoleId = props.copyFromRoleId || props.roleId;
|
||||
await loadMenuIdsByRole(sourceRoleId);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* 勾选变化:提交需包含半选父节点
|
||||
*/
|
||||
const handleCheck = (mCheckedKeys: number[], e: { halfCheckedKeys?: number[] }) => {
|
||||
checkedKeys.value = mCheckedKeys;
|
||||
submitCheckedKeys.value = [...mCheckedKeys, ...(e.halfCheckedKeys || [])];
|
||||
};
|
||||
|
||||
const handleExpand = (expandedKeys: number[]) => {
|
||||
currentExpandedKeys.value = expandedKeys;
|
||||
};
|
||||
|
||||
const handleExpandAndCollapse = () => {
|
||||
isExpand.value = !isExpand.value;
|
||||
currentExpandedKeys.value = isExpand.value ? allNodeIds.value : [];
|
||||
};
|
||||
|
||||
/** 对外暴露:获取待提交的 menu_id 列表 */
|
||||
const getSubmitMenuIds = () => {
|
||||
return [...submitCheckedKeys.value];
|
||||
};
|
||||
|
||||
/** 对外暴露:重新加载树与勾选 */
|
||||
const reload = async () => {
|
||||
await initTree();
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
getSubmitMenuIds,
|
||||
reload,
|
||||
});
|
||||
|
||||
initTree();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Spin :spinning="loading">
|
||||
<div class="role-menu-tree">
|
||||
<Button type="primary" size="small" @click="handleExpandAndCollapse">
|
||||
{{ isExpand ? '折叠' : '展开' }}
|
||||
</Button>
|
||||
<Tree
|
||||
ref="treeRef"
|
||||
v-model:checked-keys="checkedKeys"
|
||||
:expanded-keys="currentExpandedKeys"
|
||||
:field-names="{
|
||||
title: 'title',
|
||||
key: 'id',
|
||||
}"
|
||||
:show-line="true"
|
||||
:tree-data="treeData"
|
||||
checkable
|
||||
class="role-menu-tree__tree"
|
||||
@check="handleCheck"
|
||||
@expand="handleExpand"
|
||||
>
|
||||
<template #title="{ title, icon }">
|
||||
<Icon :icon="icon" />
|
||||
{{ $t(title) }}
|
||||
</template>
|
||||
</Tree>
|
||||
</div>
|
||||
</Spin>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.role-menu-tree__tree {
|
||||
margin: 12px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,84 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 同步管理员管理菜单:为预设管理员角色补全「管理员」菜单组(73 + 对应子页)
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Alert, message } from 'ant-design-vue';
|
||||
|
||||
import { countMissingAdminMenus, syncAdminManagementMenus } from '../api';
|
||||
|
||||
const missingCount = ref(0);
|
||||
const missingRoleIds = ref<number[]>([]);
|
||||
const gridApi = ref();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm: async () => {
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
try {
|
||||
const res = await syncAdminManagementMenus();
|
||||
const synced = res?.synced_count ?? 0;
|
||||
if (synced > 0) {
|
||||
message.success(`已为 ${synced} 个角色补全管理员管理菜单(含父级菜单链)`);
|
||||
} else {
|
||||
message.info('未发现需要补全的管理员菜单');
|
||||
}
|
||||
gridApi.value?.reload?.();
|
||||
modalApi.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
}
|
||||
},
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
gridApi.value = modalApi.getData()?.gridApi;
|
||||
modalApi.setState({ loading: true });
|
||||
try {
|
||||
const res = await countMissingAdminMenus();
|
||||
missingCount.value = res?.count ?? 0;
|
||||
missingRoleIds.value = res?.role_ids ?? [];
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
modalApi.setState({ loading: false });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineExpose(modalApi);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[80%] md:w-[50%]" title="同步管理员管理菜单">
|
||||
<Alert
|
||||
class="mb-4"
|
||||
show-icon
|
||||
type="info"
|
||||
:message="
|
||||
missingCount > 0
|
||||
? `${missingCount} 个预设管理员角色缺少「管理员」菜单组`
|
||||
: '各预设管理员角色的「管理员」菜单已齐全'
|
||||
"
|
||||
:description="
|
||||
missingCount > 0
|
||||
? `待补全角色 ID:${missingRoleIds.join('、')}(将追加菜单 4→21→73 及对应子页)`
|
||||
: '可点击确定执行一次幂等检查;若侧栏仍无「管理员」菜单,请让对应账号重新登录'
|
||||
"
|
||||
/>
|
||||
<div class="text-sm text-[hsl(var(--muted-foreground))]">
|
||||
自动为可识别的管理员角色补全「基础管理 → RBAC管理 → 管理员 → 子页」整条菜单链。
|
||||
预设角色按 ID 匹配;自定义角色按角色代码(value)与菜单路径匹配。仅追加缺失项。
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -30,7 +30,8 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
columns: [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
{ field: 'id', align: 'left', title: 'ID', width: 100 },
|
||||
{ field: 'name', align: 'left', title: '名称' },
|
||||
// 名称可点,打开授权菜单抽屉(与操作列「授权菜单」同入口)
|
||||
{ field: 'name', align: 'left', title: '名称', slots: { default: 'name' } },
|
||||
{ field: 'value', title: '角色代码' },
|
||||
{ field: 'desc', title: '备注' },
|
||||
{ field: 'created_at', title: '创建时间' },
|
||||
|
||||
@@ -8,16 +8,21 @@ import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { Button, Image, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { Icon } from '#/components/icon';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
|
||||
import { deleteRole } from './api';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import BackfillMenuModal from './components/backfill-menu-modal.vue';
|
||||
import SyncAdminMenuModalDemo from './components/sync-admin-menu-modal.vue';
|
||||
import BackfillCustomAdminMenuModalDemo from './components/backfill-custom-admin-menu-modal.vue';
|
||||
import CreateAdminModalDemo from './components/create-admin-modal.vue';
|
||||
import { formOptions } from './config/search';
|
||||
import { gridOptions } from './config/table';
|
||||
import AuthMenu from "#/views/system/role/components/auth-menu.vue";
|
||||
import MpEntry from "#/views/system/role/components/mp-entry.vue";
|
||||
import QuickNav from "#/views/system/role/components/quick-nav.vue";
|
||||
import WorkbenchWidget from "#/views/system/role/components/workbench-widget.vue";
|
||||
import AuthMenu from '#/views/system/role/components/auth-menu.vue';
|
||||
import MpEntry from '#/views/system/role/components/mp-entry.vue';
|
||||
import QuickNav from '#/views/system/role/components/quick-nav.vue';
|
||||
import WorkbenchWidget from '#/views/system/role/components/workbench-widget.vue';
|
||||
|
||||
// 支持配置小程序工作台入口的角色(1/2平台 3/4/6业务员线 8诊所管理员 14诊所推广员)
|
||||
const MP_ENTRY_ROLE_IDS = [1, 2, 3, 4, 6, 8, 14];
|
||||
@@ -47,6 +52,39 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: FormModalDemo,
|
||||
});
|
||||
|
||||
const [BackfillModal, backfillModalApi] = useVbenModal({
|
||||
connectedComponent: BackfillMenuModal,
|
||||
});
|
||||
|
||||
const [SyncAdminMenuModal, syncAdminMenuModalApi] = useVbenModal({
|
||||
connectedComponent: SyncAdminMenuModalDemo,
|
||||
});
|
||||
|
||||
const [BackfillCustomAdminMenuModal, backfillCustomAdminMenuModalApi] =
|
||||
useVbenModal({
|
||||
connectedComponent: BackfillCustomAdminMenuModalDemo,
|
||||
});
|
||||
|
||||
/** 角色列表内直接新增该角色管理员(不跳转管理员页) */
|
||||
const [CreateAdminModal, createAdminModalApi] = useVbenModal({
|
||||
connectedComponent: CreateAdminModalDemo,
|
||||
});
|
||||
|
||||
const showBackfillModal = () => {
|
||||
backfillModalApi.setData({ gridApi });
|
||||
backfillModalApi.open();
|
||||
};
|
||||
|
||||
const showSyncAdminMenuModal = () => {
|
||||
syncAdminMenuModalApi.setData({ gridApi });
|
||||
syncAdminMenuModalApi.open();
|
||||
};
|
||||
|
||||
const showBackfillCustomAdminMenuModal = () => {
|
||||
backfillCustomAdminMenuModalApi.setData({ gridApi });
|
||||
backfillCustomAdminMenuModalApi.open();
|
||||
};
|
||||
|
||||
const showModal = (data = {}, isUpdate = false) => {
|
||||
formModalApi.setData({
|
||||
// 表单值
|
||||
@@ -63,7 +101,7 @@ const showModal = (data = {}, isUpdate = false) => {
|
||||
formModalApi.open();
|
||||
};
|
||||
|
||||
// 授权菜单
|
||||
// 授权菜单(操作列 / 点击角色名称共用)
|
||||
const authMenuRef = ref();
|
||||
const handleAuthMenu = (record: any) => {
|
||||
authMenuRef.value.setData({
|
||||
@@ -72,6 +110,23 @@ const handleAuthMenu = (record: any) => {
|
||||
authMenuRef.value.open();
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开「添加管理员」弹窗,role_id 固定为当前行角色
|
||||
* 表单字段按该角色 formType 动态切换(复用 admin/_shared)
|
||||
*/
|
||||
const openCreateAdminModal = (record: any) => {
|
||||
const roleId = Number(record?.id || 0);
|
||||
if (!roleId) {
|
||||
message.warning('角色无效');
|
||||
return;
|
||||
}
|
||||
createAdminModalApi.setData({
|
||||
role_id: roleId,
|
||||
role_name: record?.name,
|
||||
});
|
||||
createAdminModalApi.open();
|
||||
};
|
||||
|
||||
// 快捷导航
|
||||
const quickNavRef = ref();
|
||||
const handleQuickNav = (record: any) => {
|
||||
@@ -121,6 +176,10 @@ const deleteApi = (row: any) => {
|
||||
<template>
|
||||
<Page auto-content-height title="角色管理">
|
||||
<FormModal />
|
||||
<BackfillModal />
|
||||
<SyncAdminMenuModal />
|
||||
<BackfillCustomAdminMenuModal />
|
||||
<CreateAdminModal />
|
||||
<AuthMenu ref="authMenuRef" />
|
||||
<QuickNav ref="quickNavRef" />
|
||||
<WorkbenchWidget ref="workbenchWidgetRef" />
|
||||
@@ -136,6 +195,24 @@ const deleteApi = (row: any) => {
|
||||
// auth: ['超级角色', 'sys:user:save'],
|
||||
onClick: showModal.bind(null),
|
||||
},
|
||||
{
|
||||
label: '补全空角色菜单',
|
||||
type: 'default',
|
||||
icon: 'ant-design:menu-unfold-outlined',
|
||||
onClick: showBackfillModal,
|
||||
},
|
||||
{
|
||||
label: '同步管理员菜单',
|
||||
type: 'default',
|
||||
icon: 'grommet-icons:user-admin',
|
||||
onClick: showSyncAdminMenuModal,
|
||||
},
|
||||
{
|
||||
label: '补生成管理员入口',
|
||||
type: 'default',
|
||||
icon: 'ant-design:appstore-add-outlined',
|
||||
onClick: showBackfillCustomAdminMenuModal,
|
||||
},
|
||||
]"
|
||||
:drop-down-actions="[
|
||||
{
|
||||
@@ -161,6 +238,12 @@ const deleteApi = (row: any) => {
|
||||
<template #avatar="{ row }">
|
||||
<Image :src="row.avatar" height="30" width="30" />
|
||||
</template>
|
||||
<!-- 点击角色名称打开授权菜单 -->
|
||||
<template #name="{ row }">
|
||||
<Button type="link" class="!px-0" @click="handleAuthMenu(row)">
|
||||
{{ row.name }}
|
||||
</Button>
|
||||
</template>
|
||||
<template #toolbar-tools></template>
|
||||
<template #action="{ row }">
|
||||
<TableAction
|
||||
@@ -181,6 +264,13 @@ const deleteApi = (row: any) => {
|
||||
// auth: ['admin', 'sys:role:detail'],
|
||||
onClick: handleAuthMenu.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '添加管理员',
|
||||
type: 'link',
|
||||
icon: 'ant-design:user-add-outlined',
|
||||
size: 'small',
|
||||
onClick: openCreateAdminModal.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '快捷导航',
|
||||
type: 'link',
|
||||
|
||||
@@ -108,6 +108,39 @@ export async function getStoreCardStatsApi(params: {
|
||||
return requestClient.get<any>(`${prefix}card-stats`, { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店资金账户余额(仅超管/系统管理员)
|
||||
*/
|
||||
export async function getStoreBalanceApi(params: { id: number }) {
|
||||
return requestClient.get<any>(`${prefix}store-balance`, { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店资金流水列表(仅超管/系统管理员)
|
||||
*/
|
||||
export async function getStoreFundWaterListApi(params: {
|
||||
id: number;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
search_time?: [string, string];
|
||||
}) {
|
||||
return requestClient.get<any>(`${prefix}store-fund-water-list`, { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* 门店账户变动列表(仅超管/系统管理员)
|
||||
*/
|
||||
export async function getStoreAccountChangeLogListApi(params: {
|
||||
id: number;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
search_time?: [string, string];
|
||||
}) {
|
||||
return requestClient.get<any>(`${prefix}store-account-change-log-list`, {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增诊所
|
||||
* @param data
|
||||
|
||||
@@ -25,6 +25,8 @@ defineOptions({ name: 'PublicAccountPayConfigPanel' });
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const billMode = ref<'order' | 'daily'>('order');
|
||||
/** immediate=发方后自动走公账;doctor_confirm=须医生手动申请 */
|
||||
const payTrigger = ref<'immediate' | 'doctor_confirm'>('immediate');
|
||||
const generateTime = ref<Dayjs>(dayjs('22:00', 'HH:mm'));
|
||||
const lockTime = ref<Dayjs>(dayjs('09:00', 'HH:mm'));
|
||||
/** 账单日起算满 N 天后锁店,默认 1=次日 */
|
||||
@@ -65,6 +67,9 @@ async function load() {
|
||||
if (row.config_key === 'public_account_bill_mode') {
|
||||
billMode.value = row.config_value === 'daily' ? 'daily' : 'order';
|
||||
}
|
||||
if (row.config_key === 'public_account_pay_trigger') {
|
||||
payTrigger.value = row.config_value === 'doctor_confirm' ? 'doctor_confirm' : 'immediate';
|
||||
}
|
||||
if (row.config_key === 'public_account_daily_generate_time') {
|
||||
generateTime.value = parseHm(row.config_value, '22:00');
|
||||
}
|
||||
@@ -201,6 +206,14 @@ async function handleSave() {
|
||||
config_group: 'public_account_pay',
|
||||
value_type: 'string',
|
||||
},
|
||||
{
|
||||
config_key: 'public_account_pay_trigger',
|
||||
config_value: payTrigger.value,
|
||||
config_group: 'public_account_pay',
|
||||
value_type: 'string',
|
||||
description: '公账支付触发时机:immediate=发方后自动走公账,doctor_confirm=须医生点申请',
|
||||
sort: 401,
|
||||
},
|
||||
{
|
||||
config_key: 'public_account_daily_generate_time',
|
||||
config_value: generateTime.value.format('HH:mm'),
|
||||
@@ -286,6 +299,16 @@ onMounted(() => {
|
||||
<Radio value="daily">按天先用后付(到点出日汇总)</Radio>
|
||||
</Radio.Group>
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<div class="mb-2 font-medium text-[hsl(var(--foreground))]">支付时机</div>
|
||||
<Radio.Group v-model:value="payTrigger">
|
||||
<Radio value="immediate">立即支付(发方后自动走公账)</Radio>
|
||||
<Radio value="doctor_confirm">医生确认后再支付</Radio>
|
||||
</Radio.Group>
|
||||
<div class="mt-1 text-xs text-[hsl(var(--muted-foreground))]">
|
||||
与出账模式无关:立即支付时诊所已开通则发方后自动申请公账;医生确认时须手动点「申请公账支付」
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="isDaily">
|
||||
<div class="mb-6">
|
||||
<div class="mb-2 font-medium text-[hsl(var(--foreground))]">日汇总生成时刻</div>
|
||||
|
||||
Reference in New Issue
Block a user