feat(payment): 添加统一下单接口并修复类型引用

- 添加 create 和 createWithOrder 两个统一下单接口
- 将 Order 类型替换为 ShopOrder 类型
- 修复 getNativeCode 函数的参数类型引用
- 修复 importArticles 导入语句的格式问题

feat(navigation): 实现导航管理导入导出功能

- 添加导航导入弹窗组件 Import.vue
- 实现导航数据导出功能,支持按搜索结果导出
- 优化导出数据的列宽设置
- 添加导出加载状态和错误处理
- 修复组件格式化问题

refactor(led): 重构LED显示页面实现自动轮播

- 重命名组件名称为 LedIndex
- 添加两个表格实例引用用于独立控制
- 实现页面自动轮播功能,设置10秒间隔
- 隐藏表格分页组件
- 优化页面加载和卸载逻辑

style(components): 统一组件代码格式化

- 修复多个组件中的格式化问题
- 统一 import 语句的格式
- 修复组件标签闭合问题
- 优化代码缩进和换行

chore(env): 更新开发环境配置注释

- 注释掉 VITE_API_URL 配置项
- 保持其他环境配置不变
This commit is contained in:
2025-12-30 21:26:01 +08:00
parent 9d5896dc86
commit 4f9a0e7f91
7 changed files with 469 additions and 344 deletions

View File

@@ -1,5 +1,5 @@
VITE_APP_NAME=后台管理(开发环境) VITE_APP_NAME=后台管理(开发环境)
VITE_API_URL=http://127.0.0.1:9200/api #VITE_API_URL=http://127.0.0.1:9200/api
#VITE_SERVER_API_URL=http://127.0.0.1:8000/api #VITE_SERVER_API_URL=http://127.0.0.1:8000/api

View File

@@ -2,7 +2,7 @@ import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api'; import type { ApiResult, PageResult } from '@/api';
import type { Payment, PaymentParam } from './model'; import type { Payment, PaymentParam } from './model';
import { SERVER_API_URL } from '@/config/setting'; import { SERVER_API_URL } from '@/config/setting';
import type { Order } from '@/api/shop/order/model'; import type { ShopOrder } from '@/api/shop/shopOrder/model';
/** /**
* 分页查询支付方式 * 分页查询支付方式
@@ -50,6 +50,34 @@ export async function addPayment(data: Payment) {
return Promise.reject(new Error(res.data.message)); return Promise.reject(new Error(res.data.message));
} }
/**
* 统一下单订单接口
*/
export async function create(data: Payment) {
const res = await request.post<ApiResult<unknown>>(
SERVER_API_URL + '/system/payment/create',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 统一下单订单接口(包含订单信息)
*/
export async function createWithOrder(data: Payment) {
const res = await request.post<ApiResult<unknown>>(
SERVER_API_URL + '/system/payment/create-with-order',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/** /**
* 修改支付方式 * 修改支付方式
*/ */
@@ -109,7 +137,7 @@ export async function getPayment(id: number) {
/** /**
* 生成支付二维码(微信native) * 生成支付二维码(微信native)
*/ */
export async function getNativeCode(data: Order) { export async function getNativeCode(data: ShopOrder) {
const res = await request.post<ApiResult<unknown>>( const res = await request.post<ApiResult<unknown>>(
SERVER_API_URL + '/system/wx-native-pay/codeUrl', SERVER_API_URL + '/system/wx-native-pay/codeUrl',
data data

View File

@@ -30,7 +30,7 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { message } from 'ant-design-vue/es'; import { message } from 'ant-design-vue/es';
import { CloudUploadOutlined } from '@ant-design/icons-vue'; import { CloudUploadOutlined } from '@ant-design/icons-vue';
import {importArticles} from "@/api/cms/cmsArticle"; import { importArticles } from '@/api/cms/cmsArticle';
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'done'): void; (e: 'done'): void;

View File

@@ -0,0 +1,80 @@
<!-- 导航导入弹窗 -->
<template>
<ele-modal
:width="520"
:footer="null"
title="导入备份"
:visible="visible"
@update:visible="updateVisible"
>
<a-spin :spinning="loading">
<a-upload-dragger
accept=".xls,.xlsx"
:show-upload-list="false"
:customRequest="doUpload"
style="padding: 24px 0; margin-bottom: 16px"
>
<p class="ant-upload-drag-icon">
<cloud-upload-outlined />
</p>
<p class="ant-upload-hint">将文件拖到此处或点击上传</p>
</a-upload-dragger>
</a-spin>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { message } from 'ant-design-vue/es';
import { CloudUploadOutlined } from '@ant-design/icons-vue';
import { importCmsNavigation } from '@/api/cms/cmsNavigation';
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
defineProps<{
// 是否打开弹窗
visible: boolean;
}>();
// 导入请求状态
const loading = ref(false);
/* 上传 */
const doUpload = ({ file }) => {
if (
![
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
].includes(file.type)
) {
message.error('只能选择 excel 文件');
return false;
}
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return false;
}
loading.value = true;
importCmsNavigation(file)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
return false;
};
/* 更新 visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
</script>

View File

@@ -3,22 +3,32 @@
<a-space :size="10" style="flex-wrap: wrap"> <a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="emit('add')"> <a-button type="primary" class="ele-btn-icon" @click="emit('add')">
<template #icon> <template #icon>
<plus-outlined/> <plus-outlined />
</template> </template>
<span>新建</span> <span>新建</span>
</a-button> </a-button>
<a-button type="dashed" :disabled="!hasRole('superAdmin')" @click="handleExport">备份</a-button> <a-button
<a-button type="dashed" :disabled="!hasRole('superAdmin')" @click="openImport">恢复</a-button> type="dashed"
:disabled="!hasRole('superAdmin')"
@click="handleExport"
>备份</a-button
>
<a-button
type="dashed"
:disabled="!hasRole('superAdmin')"
@click="openImport"
>恢复</a-button
>
<a-button type="dashed" @click="openUrl('/website/model')" <a-button type="dashed" @click="openUrl('/website/model')"
>模型管理 >模型管理
</a-button> </a-button>
<a-divider type="vertical"/> <a-divider type="vertical" />
<a-radio-group v-model:value="position" @change="reload"> <a-radio-group v-model:value="position" @change="reload">
<a-radio-button :value="1">顶部</a-radio-button> <a-radio-button :value="1">顶部</a-radio-button>
<a-radio-button :value="2">底部</a-radio-button> <a-radio-button :value="2">底部</a-radio-button>
<a-radio-button :value="0">不限</a-radio-button> <a-radio-button :value="0">不限</a-radio-button>
</a-radio-group> </a-radio-group>
<a-divider type="vertical"/> <a-divider type="vertical" />
<a-select <a-select
v-model:value="where.model" v-model:value="where.model"
style="width: 150px" style="width: 150px"
@@ -42,66 +52,72 @@
/> />
</a-space> </a-space>
<!-- 导入弹窗 --> <!-- 导入弹窗 -->
<import v-model:visible="showImport" @done="reload"/> <import v-model:visible="showImport" @done="reload" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {PlusOutlined} from '@ant-design/icons-vue'; import { PlusOutlined } from '@ant-design/icons-vue';
import type {GradeParam} from '@/api/user/grade/model'; import type { GradeParam } from '@/api/user/grade/model';
import {watch, ref} from 'vue'; import { watch, ref } from 'vue';
import {openUrl} from "@/utils/common"; import { openUrl } from '@/utils/common';
import {hasRole} from "@/utils/permission"; import { hasRole } from '@/utils/permission';
import {utils, writeFile} from 'xlsx'; import { utils, writeFile } from 'xlsx';
import {message} from 'ant-design-vue'; import { message } from 'ant-design-vue';
import {listCmsNavigation} from "@/api/cms/cmsNavigation"; import { listCmsNavigation } from '@/api/cms/cmsNavigation';
import {getTenantId} from "@/utils/domain"; import { getTenantId } from '@/utils/domain';
import Import from "./Import.vue"; import Import from './Import.vue';
// 是否显示导入弹窗 // 是否显示导入弹窗
const showImport = ref(false); const showImport = ref(false);
const searchText = ref(''); const searchText = ref('');
// 导出请求状态
const loading = ref(false);
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
// 选中的角色 // 选中的角色
selection?: []; selection?: [];
}>(), }>(),
{} {}
); );
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'search', where?: GradeParam): void; (e: 'search', where?: GradeParam): void;
(e: 'add'): void; (e: 'add'): void;
}>(); }>();
watch( watch(
() => props.selection, () => props.selection,
() => { () => {}
} );
);
// 表单数据 // 表单数据
const where = ref({ const where = ref({
keywords: '', keywords: '',
model: '', model: '',
position: 0 position: 0
}); });
const position = ref(0); const position = ref(0);
const reload = () => { const reload = () => {
// 更新搜索关键词 // 更新搜索关键词
where.value.keywords = searchText.value; where.value.keywords = searchText.value;
emit('search', where.value); emit('search', where.value);
}; };
/* 打开编辑弹窗 */ /* 打开编辑弹窗 */
const openImport = () => { const openImport = () => {
showImport.value = true; showImport.value = true;
}; };
// 导出 // 导出
const handleExport = async () => { const handleExport = async () => {
if (loading.value) {
return;
}
loading.value = true;
const array: (string | number)[][] = [ const array: (string | number)[][] = [
[ [
'上级id', '上级id',
@@ -131,9 +147,19 @@ const handleExport = async () => {
]; ];
// 按搜索结果导出 // 按搜索结果导出
await listCmsNavigation(where.value) message.loading('正在准备导出数据...', 0);
.then((list) => {
list?.forEach((d) => { try {
const list = await listCmsNavigation(where.value);
if (!list || list.length === 0) {
message.destroy();
message.warning('没有数据可以导出');
loading.value = false;
return;
}
list.forEach((d) => {
array.push([ array.push([
`${d.parentId || ''}`, `${d.parentId || ''}`,
`${d.title || ''}`, `${d.title || ''}`,
@@ -160,6 +186,7 @@ const handleExport = async () => {
`${d.status || 0}` `${d.status || 0}`
]); ]);
}); });
const sheetName = `bak_navigation_${getTenantId()}`; const sheetName = `bak_navigation_${getTenantId()}`;
const workbook = { const workbook = {
SheetNames: [sheetName], SheetNames: [sheetName],
@@ -167,18 +194,47 @@ const handleExport = async () => {
}; };
const sheet = utils.aoa_to_sheet(array); const sheet = utils.aoa_to_sheet(array);
workbook.Sheets[sheetName] = sheet; workbook.Sheets[sheetName] = sheet;
// 设置列宽 // 设置列宽
sheet['!cols'] = []; sheet['!cols'] = [
message.loading('正在导出...'); { wch: 10 }, // 上级id
{ wch: 20 }, // 菜单名称
{ wch: 10 }, // 模型
{ wch: 20 }, // 标识
{ wch: 30 }, // 菜单路由地址
{ wch: 30 }, // 菜单组件地址
{ wch: 10 }, // 打开位置
{ wch: 18 }, // 菜单图标
{ wch: 24 }, // banner图片
{ wch: 12 }, // 图标颜色
{ wch: 10 }, // 是否隐藏
{ wch: 10 }, // 可见类型
{ wch: 16 }, // 访问密码
{ wch: 10 }, // 位置
{ wch: 12 }, // 仅在顶部显示
{ wch: 12 }, // 仅在底部显示
{ wch: 26 }, // 菜单侧栏选中的path
{ wch: 20 }, // 其它路由元信息
{ wch: 20 }, // css样式
{ wch: 10 }, // 是否推荐
{ wch: 10 }, // 排序
{ wch: 20 }, // 备注
{ wch: 10 } // 状态
];
message.destroy();
message.loading('正在生成Excel文件...', 0);
setTimeout(() => { setTimeout(() => {
writeFile( writeFile(workbook, `${sheetName}.xlsx`);
workbook, loading.value = false;
`${sheetName}.xlsx` message.destroy();
); message.success(`成功导出 ${list.length} 条记录`);
}, 1000); }, 1000);
}) } catch (e: any) {
.catch((msg) => { loading.value = false;
message.error(msg); message.destroy();
}); message.error(e.message || '导出失败,请重试');
}; }
};
</script> </script>

View File

@@ -4,61 +4,60 @@
<div class="text-4xl font-bold">广西医科大学第一附属医院</div> <div class="text-4xl font-bold">广西医科大学第一附属医院</div>
<div class="text-2xl my-5">门诊医生一周内停替诊公布</div> <div class="text-2xl my-5">门诊医生一周内停替诊公布</div>
<ele-pro-table <ele-pro-table
ref="tableRef" ref="stopTableRef"
row-key="id" row-key="id"
:columns="columns" :columns="columns"
:datasource="datasource" :datasource="datasource"
:customRow="customRow" :customRow="customRow"
:toolkit="[]"
:toolbar="false"
:page-size="pageSize"
tool-class="ele-toolbar-form" tool-class="ele-toolbar-form"
class="sys-org-table" class="sys-org-table led-table"
@done="onStopDone"
/> />
<div class="text-2xl my-5">门诊医生当天剩余号源公布</div> <div class="text-2xl my-5">门诊医生当天剩余号源公布</div>
<ele-pro-table <ele-pro-table
ref="tableRef" ref="numberTableRef"
row-key="id" row-key="id"
:columns="columns2" :columns="columns2"
:datasource="datasource2" :datasource="datasource2"
:customRow="customRow" :customRow="customRow"
:toolkit="[]"
:toolbar="false"
:page-size="pageSize"
tool-class="ele-toolbar-form" tool-class="ele-toolbar-form"
class="sys-org-table" class="sys-org-table led-table"
@done="onNumberDone"
/> />
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { createVNode, ref } from 'vue'; import { onBeforeUnmount, onMounted, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro'; import type { EleProTable } from 'ele-admin-pro';
import { toTreeData } from 'ele-admin-pro';
import { useI18n } from 'vue-i18n';
import type { import type {
DatasourceFunction, DatasourceFunction,
ColumnItem ColumnItem,
EleProTableDone
} from 'ele-admin-pro/es/ele-pro-table/types'; } from 'ele-admin-pro/es/ele-pro-table/types';
import { pageCmsAd, removeCmsAd, removeBatchCmsAd } from '@/api/cms/cmsAd';
import type { CmsAd, CmsAdParam } from '@/api/cms/cmsAd/model';
import { CmsNavigation } from '@/api/cms/cmsNavigation/model';
import { listCmsNavigation } from '@/api/cms/cmsNavigation';
import { numberReplace, stopReplace } from '@/api/led'; import { numberReplace, stopReplace } from '@/api/led';
const pageSize = 10;
const rotateIntervalMs = 10000;
// 表格实例 // 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null); const stopTableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 国际化 const numberTableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const { locale } = useI18n();
// 表格选中数据 const stopPageCount = ref(1);
const selection = ref<CmsAd[]>([]); const numberPageCount = ref(1);
// 当前编辑数据 const stopCurrPage = ref(1);
const current = ref<CmsAd | null>(null); const numberCurrPage = ref(1);
// 是否显示编辑弹窗
const showEdit = ref(false); let stopTimer: number | undefined;
// 是否显示批量移动弹窗 let numberTimer: number | undefined;
const showMove = ref(false);
// 栏目数据
const navigationList = ref<CmsNavigation[]>();
// 加载状态
const loading = ref(true);
// 表格数据源 // 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => { const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
@@ -191,107 +190,70 @@
}); });
}; };
/* 搜索 */ const onStopDone: EleProTableDone<any> = (_res, curr, count) => {
const reload = (where?: CmsAdParam) => { stopCurrPage.value = curr;
selection.value = []; stopPageCount.value = count || 1;
tableRef?.value?.reload({ where: where });
}; };
/* 打开编辑弹窗 */ const onNumberDone: EleProTableDone<any> = (_res, curr, count) => {
const openEdit = (row?: CmsAd) => { numberCurrPage.value = curr;
current.value = row ?? null; numberPageCount.value = count || 1;
showEdit.value = true;
}; };
/* 打开批量移动弹窗 */ const nextStopPage = () => {
const openMove = () => { if (stopPageCount.value <= 1) return;
showMove.value = true; stopCurrPage.value =
stopCurrPage.value >= stopPageCount.value ? 1 : stopCurrPage.value + 1;
stopTableRef.value?.reload({ page: stopCurrPage.value, limit: pageSize });
}; };
/* 删除单个 */ const nextNumberPage = () => {
const remove = (row: CmsAd) => { if (numberPageCount.value <= 1) return;
const hide = message.loading('请求中..', 0); numberCurrPage.value =
removeCmsAd(row.adId) numberCurrPage.value >= numberPageCount.value
.then((msg) => { ? 1
hide(); : numberCurrPage.value + 1;
message.success(msg); numberTableRef.value?.reload({
reload(); page: numberCurrPage.value,
}) limit: pageSize
.catch((e) => {
hide();
message.error(e.message);
}); });
}; };
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchCmsAd(selection.value.map((d) => d.adId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
// 加载栏目数据
if (!navigationList.value) {
listCmsNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (!d.component) {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
};
/* 自定义行属性 */ /* 自定义行属性 */
const customRow = (record: CmsAd) => { const customRow = (_record: any) => {
return { return {
// 行点击事件 // 行点击事件
onClick: () => { onClick: () => {
// console.log(record); //
}, },
// 行双击事件 // 行双击事件
onDblclick: () => { onDblclick: () => {
// openEdit(record); //
} }
}; };
}; };
query();
onMounted(() => {
stopTimer = window.setInterval(nextStopPage, rotateIntervalMs);
numberTimer = window.setInterval(nextNumberPage, rotateIntervalMs);
});
onBeforeUnmount(() => {
if (stopTimer) window.clearInterval(stopTimer);
if (numberTimer) window.clearInterval(numberTimer);
});
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'CmsAd' name: 'LedIndex'
}; };
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped>
.led-table {
:deep(.ant-pagination) {
display: none;
}
}
</style>

View File

@@ -14,59 +14,59 @@
</a-space> </a-space>
<!-- 导入弹窗 --> <!-- 导入弹窗 -->
<import v-model:visible="showImport" @done="reload"/> <import v-model:visible="showImport" @done="reload" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { utils, writeFile } from 'xlsx'; import { utils, writeFile } from 'xlsx';
import { listMenus } from '@/api/system/menu'; import { listMenus } from '@/api/system/menu';
import type { Menu, MenuParam } from '@/api/system/menu/model'; import type { Menu, MenuParam } from '@/api/system/menu/model';
import useSearch from '@/utils/use-search'; import useSearch from '@/utils/use-search';
import Import from "./Import.vue"; import Import from './Import.vue';
import {getTenantId} from "@/utils/domain"; import { getTenantId } from '@/utils/domain';
// 定义包含关键词的参数类型 // 定义包含关键词的参数类型
interface MenuSearchParam extends MenuParam { interface MenuSearchParam extends MenuParam {
keywords?: string; keywords?: string;
} }
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
// 选中的数据 // 选中的数据
selection?: Menu[]; selection?: Menu[];
}>(), }>(),
{} {}
); );
// 请求状态 // 请求状态
const loading = ref(false); const loading = ref(false);
const menuList = ref<Menu[]>([]); const menuList = ref<Menu[]>([]);
// 是否显示导入弹窗 // 是否显示导入弹窗
const showImport = ref(false); const showImport = ref(false);
// 表单数据 // 表单数据
const { where, resetFields } = useSearch<MenuSearchParam>({ const { where, resetFields } = useSearch<MenuSearchParam>({
keywords: '' keywords: ''
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'search', where?: MenuSearchParam): void; (e: 'search', where?: MenuSearchParam): void;
(e: 'add'): void; (e: 'add'): void;
}>(); }>();
// 新增 // 新增
const add = () => { const add = () => {
emit('add'); emit('add');
}; };
const reload = () => { const reload = () => {
emit('search', where); emit('search', where);
}; };
// 导出 // 导出
const handleExport = async () => { const handleExport = async () => {
if (loading.value) { if (loading.value) {
return; return;
} }
@@ -153,22 +153,21 @@ const handleExport = async () => {
message.destroy(); message.destroy();
message.success(`成功导出 ${list.length} 条记录`); message.success(`成功导出 ${list.length} 条记录`);
}, 1000); }, 1000);
} catch (error: any) { } catch (error: any) {
loading.value = false; loading.value = false;
message.destroy(); message.destroy();
message.error(error.message || '导出失败,请重试'); message.error(error.message || '导出失败,请重试');
} }
}; };
/* 打开导入弹窗 */ /* 打开导入弹窗 */
const openImport = () => { const openImport = () => {
showImport.value = true; showImport.value = true;
}; };
/* 重置 */ /* 重置 */
const reset = () => { const reset = () => {
resetFields(); resetFields();
reload(); reload();
}; };
</script> </script>