1. 特色方功能迭代(固定价格),固定价格目前统一使用药品id(-102),后期会考虑新增特色方的时候自动添加一个特色方药品
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
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
Release Drafter / update_release_draft (push) Has been cancelled
2. 退款的时候可以退回分成
This commit is contained in:
@@ -3,7 +3,7 @@ import { ref, watch } from 'vue';
|
||||
|
||||
import { Page, useVbenDrawer } from '@vben/common-ui';
|
||||
|
||||
import { EditOutlined, FolderOutlined } from '@ant-design/icons-vue';
|
||||
import { EditOutlined, FolderAddOutlined, FolderOutlined } from '@ant-design/icons-vue';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
@@ -23,6 +23,7 @@ import { useFileGalleryFilter } from '#/composables/use-file-gallery-filter';
|
||||
import { resolveTypeIcon } from '#/composables/use-file-type-icon';
|
||||
import type { FileGalleryItem } from '#/api/core/file-gallery';
|
||||
import {
|
||||
addFileToGroup,
|
||||
batchArchiveFiles,
|
||||
deleteFileGalleryItem,
|
||||
getFileGalleryList,
|
||||
@@ -30,6 +31,7 @@ import {
|
||||
renameFileGalleryItem,
|
||||
syncFileGalleryFromOss,
|
||||
} from '#/api/core/file-gallery';
|
||||
import { useFileGroupCache } from '#/composables/use-file-group-cache';
|
||||
|
||||
import FileDetailDrawer from './components/file-detail-drawer.vue';
|
||||
|
||||
@@ -49,14 +51,19 @@ const pageSizeOptions = ['12', '24', '48', '96'];
|
||||
|
||||
const {
|
||||
activeType,
|
||||
activeGroupId,
|
||||
keyword,
|
||||
tabs,
|
||||
groupTabs,
|
||||
setActiveType,
|
||||
setActiveGroupId,
|
||||
buildListParams,
|
||||
fileTypes,
|
||||
typesLoading,
|
||||
} = useFileGalleryFilter('file-management-active-type');
|
||||
|
||||
const { loadGroupOptions: refreshGroupOptionsForMenu } = useFileGroupCache();
|
||||
|
||||
const [DetailDrawer, detailDrawerApi] = useVbenDrawer({
|
||||
connectedComponent: FileDetailDrawer,
|
||||
});
|
||||
@@ -151,7 +158,27 @@ async function handleMoveType(item: FileGalleryItem, type: number) {
|
||||
await load();
|
||||
}
|
||||
|
||||
function buildContextMenus(item: FileGalleryItem): ContextMenuItem[] {
|
||||
async function handleAddToGroup(item: FileGalleryItem, groupId: number) {
|
||||
await addFileToGroup(item.id, groupId);
|
||||
message.success('已加入分组');
|
||||
if (!item.group_ids) {
|
||||
item.group_ids = [];
|
||||
}
|
||||
if (!item.group_ids.includes(groupId)) {
|
||||
item.group_ids.push(groupId);
|
||||
}
|
||||
}
|
||||
|
||||
async function buildContextMenus(item: FileGalleryItem): Promise<ContextMenuItem[]> {
|
||||
const groups = await refreshGroupOptionsForMenu();
|
||||
const joinedIds = new Set(item.group_ids ?? []);
|
||||
const groupChildren: ContextMenuItem[] = groups.map((groupItem) => ({
|
||||
key: `group-${groupItem.id}`,
|
||||
label: groupItem.name,
|
||||
disabled: joinedIds.has(groupItem.id),
|
||||
handler: () => handleAddToGroup(item, groupItem.id),
|
||||
}));
|
||||
|
||||
const moveChildren: ContextMenuItem[] = fileTypes.value.map((typeItem) => ({
|
||||
key: `move-${typeItem.value}`,
|
||||
label: typeItem.name,
|
||||
@@ -167,6 +194,12 @@ function buildContextMenus(item: FileGalleryItem): ContextMenuItem[] {
|
||||
icon: EditOutlined,
|
||||
handler: () => handleRename(item),
|
||||
},
|
||||
{
|
||||
key: 'add-group',
|
||||
label: '加入分组',
|
||||
icon: FolderAddOutlined,
|
||||
children: groupChildren.length ? groupChildren : [{ key: 'empty', label: '暂无分组', disabled: true }],
|
||||
},
|
||||
{
|
||||
key: 'move',
|
||||
label: '移动分类',
|
||||
@@ -176,8 +209,9 @@ function buildContextMenus(item: FileGalleryItem): ContextMenuItem[] {
|
||||
];
|
||||
}
|
||||
|
||||
function onContextMenu(e: MouseEvent, item: FileGalleryItem) {
|
||||
showContextMenu(e, buildContextMenus(item), item);
|
||||
async function onContextMenu(e: MouseEvent, item: FileGalleryItem) {
|
||||
const menus = await buildContextMenus(item);
|
||||
showContextMenu(e, menus, item);
|
||||
}
|
||||
|
||||
function onTabChange(key: string | number) {
|
||||
@@ -186,6 +220,12 @@ function onTabChange(key: string | number) {
|
||||
void load();
|
||||
}
|
||||
|
||||
function onGroupTabChange(key: string | number) {
|
||||
setActiveGroupId(Number(key));
|
||||
page.value = 1;
|
||||
void load();
|
||||
}
|
||||
|
||||
function onSearch(value: string) {
|
||||
keyword.value = value;
|
||||
page.value = 1;
|
||||
@@ -236,6 +276,16 @@ watch(typesLoading, (val) => {
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
|
||||
<Tabs
|
||||
v-if="groupTabs.length > 1"
|
||||
:active-key="String(activeGroupId)"
|
||||
class="group-tabs"
|
||||
size="small"
|
||||
@change="onGroupTabChange"
|
||||
>
|
||||
<Tabs.TabPane v-for="tab in groupTabs" :key="String(tab.value)" :tab="tab.label" />
|
||||
</Tabs>
|
||||
|
||||
<div class="toolbar">
|
||||
<Input.Search
|
||||
v-model:value="keyword"
|
||||
@@ -315,6 +365,10 @@ watch(typesLoading, (val) => {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.group-tabs {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
|
||||
152
apps/web-antd/src/views/system/file-group/index.vue
Normal file
152
apps/web-antd/src/views/system/file-group/index.vue
Normal file
@@ -0,0 +1,152 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button, Card, Form, Input, InputNumber, Modal, Space, Table, message } from 'ant-design-vue';
|
||||
|
||||
import type { FileGroupRecord } from '#/api/core/file-group';
|
||||
import {
|
||||
createFileGroup,
|
||||
deleteFileGroup,
|
||||
getFileGroupList,
|
||||
updateFileGroup,
|
||||
} from '#/api/core/file-group';
|
||||
import { useFileGroupCache } from '#/composables/use-file-group-cache';
|
||||
|
||||
defineOptions({ name: 'FileGroup' });
|
||||
|
||||
const loading = ref(false);
|
||||
const items = ref<FileGroupRecord[]>([]);
|
||||
const modalOpen = ref(false);
|
||||
const isUpdate = ref(false);
|
||||
const form = ref<Partial<FileGroupRecord>>({
|
||||
name: '',
|
||||
sort: 0,
|
||||
});
|
||||
|
||||
const { invalidateGroupOptions } = useFileGroupCache();
|
||||
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id', width: 70 },
|
||||
{ title: '名称', dataIndex: 'name' },
|
||||
{ title: '排序', dataIndex: 'sort', width: 80 },
|
||||
{ title: '操作', key: 'action', width: 140 },
|
||||
];
|
||||
|
||||
/** 加载分组列表 */
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getFileGroupList();
|
||||
const data = (res as any)?.result ?? (res as any)?.data ?? res;
|
||||
items.value = Array.isArray(data) ? data : [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
isUpdate.value = false;
|
||||
form.value = { name: '', sort: 0 };
|
||||
modalOpen.value = true;
|
||||
}
|
||||
|
||||
function openEdit(row: FileGroupRecord) {
|
||||
isUpdate.value = true;
|
||||
form.value = { ...row };
|
||||
modalOpen.value = true;
|
||||
}
|
||||
|
||||
/** 提交创建/更新并刷新缓存 */
|
||||
async function submitForm() {
|
||||
if (!form.value.name?.trim()) {
|
||||
message.warning('请填写分组名称');
|
||||
return;
|
||||
}
|
||||
if (isUpdate.value && form.value.id) {
|
||||
await updateFileGroup({
|
||||
id: form.value.id,
|
||||
name: form.value.name,
|
||||
sort: form.value.sort,
|
||||
});
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await createFileGroup(form.value);
|
||||
message.success('创建成功');
|
||||
}
|
||||
modalOpen.value = false;
|
||||
await invalidateGroupOptions();
|
||||
await load();
|
||||
}
|
||||
|
||||
function handleDelete(row: FileGroupRecord) {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定删除分组「${row.name}」吗?组内关联将被移除。`,
|
||||
okType: 'danger',
|
||||
async onOk() {
|
||||
await deleteFileGroup(row.id);
|
||||
message.success('删除成功');
|
||||
await invalidateGroupOptions();
|
||||
await load();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
void load();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height title="分组管理">
|
||||
<Card>
|
||||
<div class="toolbar">
|
||||
<Button type="primary" @click="openCreate">新增分组</Button>
|
||||
<Button :loading="loading" @click="load">刷新</Button>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="items"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
size="small"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<Space>
|
||||
<Button type="link" size="small" @click="openEdit(record)">编辑</Button>
|
||||
<Button danger type="link" size="small" @click="handleDelete(record)">删除</Button>
|
||||
</Space>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Card>
|
||||
|
||||
<Modal
|
||||
v-model:open="modalOpen"
|
||||
:title="isUpdate ? '编辑分组' : '新增分组'"
|
||||
ok-text="保存"
|
||||
cancel-text="取消"
|
||||
@ok="submitForm"
|
||||
>
|
||||
<Form layout="vertical" class="mt-2">
|
||||
<Form.Item label="名称" required>
|
||||
<Input v-model:value="form.name" placeholder="如:活动素材" />
|
||||
</Form.Item>
|
||||
<Form.Item label="排序">
|
||||
<InputNumber v-model:value="form.sort" :min="0" class="w-full" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.toolbar {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
@@ -30,6 +30,15 @@ export function getSettlementDetail(params: { id: number; store_id: number }) {
|
||||
return requestClient.get(`${prefix}settlement-detail`, { params });
|
||||
}
|
||||
|
||||
/** 手动退回推广员分成(仅已退款/已取消订单) */
|
||||
export function reverseCommissionApi(data: {
|
||||
order_id: number;
|
||||
store_id: number;
|
||||
salesperson_id: number;
|
||||
}) {
|
||||
return requestClient.post(`${prefix}reverse-commission`, data);
|
||||
}
|
||||
|
||||
export function getDrugCommissionList(params: Record<string, any>) {
|
||||
return requestClient.get(`${prefix}drug-commission-list`, { params });
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@ import {
|
||||
Image,
|
||||
Input,
|
||||
message,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Table,
|
||||
Tabs,
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -23,6 +25,7 @@ import {
|
||||
getSettlementDetail,
|
||||
getSettlementList,
|
||||
getSettlementPreview,
|
||||
reverseCommissionApi,
|
||||
} from '../api/salesperson';
|
||||
|
||||
const visible = ref(false);
|
||||
@@ -51,17 +54,19 @@ const periodRange = ref<any[]>([]);
|
||||
const settlementConfirmRef = ref<InstanceType<typeof SalespersonSettlementConfirmModal>>();
|
||||
|
||||
const orderCommissionColumns = [
|
||||
{ title: '订单号', dataIndex: 'order_no', width: 160 },
|
||||
{ title: '明细数', dataIndex: 'item_count', width: 80 },
|
||||
{ title: '分成总额', dataIndex: 'commission_amount', width: 100 },
|
||||
{ title: '支付时间', dataIndex: 'order_pay_at_text', width: 170 },
|
||||
{ title: '操作', key: 'action', width: 90 },
|
||||
{ title: '订单号', dataIndex: 'order_no', width: 150 },
|
||||
{ title: '订单状态', key: 'order_status', width: 90 },
|
||||
{ title: '明细数', dataIndex: 'item_count', width: 70 },
|
||||
{ title: '净分成', key: 'net_commission', width: 90 },
|
||||
{ title: '支付时间', dataIndex: 'order_pay_at_text', width: 160 },
|
||||
{ title: '操作', key: 'action', width: 140 },
|
||||
];
|
||||
|
||||
const commissionDetailColumns = [
|
||||
{ title: '类型', dataIndex: 'record_type_text', width: 90 },
|
||||
{ title: '药品信息', dataIndex: 'drug_info', ellipsis: true },
|
||||
{ title: '分成金额', dataIndex: 'commission_amount', width: 100 },
|
||||
{ title: '分成时间', dataIndex: 'order_pay_at_text', width: 170 },
|
||||
{ title: '分成金额', key: 'commission_amount', width: 100 },
|
||||
{ title: '分成时间', dataIndex: 'order_pay_at_text', width: 160 },
|
||||
];
|
||||
|
||||
const settlementLineColumns = [
|
||||
@@ -162,6 +167,41 @@ async function showOrderDetail(record: { order_id: number; order_no: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
const reversingOrderIds = ref<number[]>([]);
|
||||
|
||||
/** 手动退回分成(仅已退款/已取消订单) */
|
||||
async function handleReverseCommission(record: {
|
||||
order_id: number;
|
||||
can_reverse_commission?: boolean;
|
||||
}) {
|
||||
if (!storeId.value || !salespersonId.value || reversingOrderIds.value.includes(record.order_id)) {
|
||||
return;
|
||||
}
|
||||
reversingOrderIds.value.push(record.order_id);
|
||||
try {
|
||||
await reverseCommissionApi({
|
||||
order_id: record.order_id,
|
||||
store_id: storeId.value,
|
||||
salesperson_id: salespersonId.value,
|
||||
});
|
||||
message.success('退回分成成功');
|
||||
await loadCommission();
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '退回分成失败');
|
||||
} finally {
|
||||
reversingOrderIds.value = reversingOrderIds.value.filter((id) => id !== record.order_id);
|
||||
}
|
||||
}
|
||||
|
||||
function orderStatusTagColor(text?: string) {
|
||||
if (text === '已退款' || text === '已取消') return 'warning';
|
||||
return 'default';
|
||||
}
|
||||
|
||||
function isNegativeAmount(amount?: string | number) {
|
||||
return Number(amount ?? 0) < 0;
|
||||
}
|
||||
|
||||
async function loadSettlements() {
|
||||
if (!storeId.value || !salespersonId.value) return;
|
||||
const res = await getSettlementList({
|
||||
@@ -262,8 +302,27 @@ defineExpose({ open });
|
||||
size="small"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<template v-if="column.key === 'order_status'">
|
||||
<Tag :color="orderStatusTagColor(record.order_status_text)">
|
||||
{{ record.order_status_text || '—' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'net_commission'">
|
||||
<span :class="{ 'text-red-500': isNegativeAmount(record.net_commission_amount) }">
|
||||
¥{{ record.net_commission_amount ?? record.commission_amount }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<Button type="link" size="small" @click="showOrderDetail(record)">查看明细</Button>
|
||||
<Popconfirm
|
||||
v-if="record.can_reverse_commission"
|
||||
title="确认退回该订单的推广员分成?"
|
||||
@confirm="handleReverseCommission(record)"
|
||||
>
|
||||
<Button type="link" size="small" danger :loading="reversingOrderIds.includes(record.order_id)">
|
||||
退回分成
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
@@ -278,8 +337,27 @@ defineExpose({ open });
|
||||
size="small"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<template v-if="column.key === 'order_status'">
|
||||
<Tag :color="orderStatusTagColor(record.order_status_text)">
|
||||
{{ record.order_status_text || '—' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'net_commission'">
|
||||
<span :class="{ 'text-red-500': isNegativeAmount(record.net_commission_amount) }">
|
||||
¥{{ record.net_commission_amount ?? record.commission_amount }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<Button type="link" size="small" @click="showOrderDetail(record)">查看明细</Button>
|
||||
<Popconfirm
|
||||
v-if="record.can_reverse_commission"
|
||||
title="确认退回该订单的推广员分成?"
|
||||
@confirm="handleReverseCommission(record)"
|
||||
>
|
||||
<Button type="link" size="small" danger :loading="reversingOrderIds.includes(record.order_id)">
|
||||
退回分成
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
@@ -313,7 +391,15 @@ defineExpose({ open });
|
||||
:loading="orderDetailLoading"
|
||||
:row-key="(r) => r.id"
|
||||
size="small"
|
||||
/>
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'commission_amount'">
|
||||
<span :class="{ 'text-red-500': isNegativeAmount(record.commission_amount) }">
|
||||
¥{{ record.commission_amount }}
|
||||
</span>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Drawer>
|
||||
|
||||
<Drawer v-model:open="detailVisible" title="结算单详情" width="720" destroy-on-close>
|
||||
|
||||
Reference in New Issue
Block a user