开发多商户管理及联调,收入管理
This commit is contained in:
@@ -112,6 +112,21 @@ export const constantRoutes: RouteRecordRaw[] = [
|
||||
meta: { title: '用户详情', activeMenu: '/userManage/appUser', noCache: true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// 商户详情:从多商户列表跳转,不进侧边栏
|
||||
path: '/merchant',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: 'noredirect',
|
||||
children: [
|
||||
{
|
||||
path: 'detail',
|
||||
component: () => import('@/views/biz/merchant/detail.vue'),
|
||||
name: 'MerchantDetail',
|
||||
meta: { title: '多商户详情', activeMenu: '/merchantManage/merchant', noCache: true }
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { defineComponent, h, ref } from 'vue';
|
||||
import { getRouters } from '@/api/menu';
|
||||
import ParentView from '@/components/ParentView/index.vue';
|
||||
import InnerLink from '@/layout/components/InnerLink/index.vue';
|
||||
@@ -156,12 +156,41 @@ export const filterDynamicRoutes = (routes: RouteRecordRaw[]) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* 菜单组件路径对不上时显示的兜底页面。
|
||||
* 路由照样注册、页面原本只会一片空白,无从排查,这里把缺失路径和相近的可用路径画出来。
|
||||
*/
|
||||
const createMissingView = (view: string) => {
|
||||
const keyword = view.split('/').pop()?.toLowerCase() ?? '';
|
||||
const suggestions = [...viewModuleMap.keys()]
|
||||
.filter(key => keyword && key.toLowerCase().includes(keyword))
|
||||
.slice(0, 8);
|
||||
|
||||
return defineComponent({
|
||||
name: 'MissingView',
|
||||
setup() {
|
||||
return () =>
|
||||
h('div', { style: 'padding: 32px; line-height: 2; font-size: 14px; color: var(--el-text-color-regular)' }, [
|
||||
h('h2', { style: 'margin: 0 0 12px; font-size: 18px; color: var(--el-text-color-primary)' }, '页面组件未找到'),
|
||||
h('p', {}, `后台菜单返回的组件路径:${view}`),
|
||||
h('p', {}, `前端查找的是 src/views/${view}.vue`),
|
||||
h('p', {}, suggestions.length ? `相近的已存在路径:${suggestions.join('、')}` : '没有相近的已存在路径')
|
||||
]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const loadView = (view: any, name: string) => {
|
||||
const loader = viewModuleMap.get(view);
|
||||
if (loader) {
|
||||
return createCustomNameComponent(loader, { name });
|
||||
}
|
||||
// 目录型菜单可能没有组件路径,保持原样返回 undefined
|
||||
if (!view) {
|
||||
return undefined;
|
||||
}
|
||||
console.warn(`[路由] 未找到视图组件「${view}」,请确认 src/views/${view}.vue 是否存在`);
|
||||
return createMissingView(String(view));
|
||||
};
|
||||
|
||||
// 非setup
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
<el-form-item label="手机号" prop="phoneNumber">
|
||||
<el-input v-model="queryParams.phoneNumber" placeholder="请输入手机号" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="keyword">
|
||||
<el-input v-model="queryParams.keyword" placeholder="请输入姓名或昵称" clearable @keyup.enter="handleQuery" />
|
||||
<el-form-item label="姓名" prop="nickName">
|
||||
<el-input v-model="queryParams.nickName" placeholder="请输入姓名或昵称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
||||
@@ -117,8 +117,7 @@ const queryParams = ref<AppUserQuery>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
phoneNumber: undefined,
|
||||
// 后端 keyword 同时匹配手机号、昵称、实名姓名
|
||||
keyword: undefined,
|
||||
nickName: undefined,
|
||||
status: undefined
|
||||
});
|
||||
|
||||
|
||||
@@ -4,35 +4,24 @@
|
||||
<el-card shadow="hover" class="search-panel" :class="{ 'is-collapsed': !showSearch }">
|
||||
<template #header>
|
||||
<div class="panel-heading search-panel-toggle" @click.stop="showSearch = !showSearch">
|
||||
<div>
|
||||
<span class="panel-kicker">Search Filters</span>
|
||||
<h3>筛选条件</h3>
|
||||
</div>
|
||||
<div><h3>筛选条件</h3></div>
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" class="query-form">
|
||||
<el-form-item label="充值流水号" prop="orderNo">
|
||||
<el-input v-model="queryParams.orderNo" placeholder="请输入充值流水号" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商户名称" prop="merchantName">
|
||||
<el-input v-model="queryParams.merchantName" placeholder="请输入商户名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="支付方式" prop="payType">
|
||||
<el-select v-model="queryParams.payType" placeholder="请选择支付方式" clearable>
|
||||
<el-option v-for="item in payTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="收入时间" style="width: 308px">
|
||||
<el-form-item label="开始日期" prop="beginDate">
|
||||
<el-date-picker
|
||||
v-model="dateRangeIncomeTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
||||
v-model="queryParams.beginDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择开始日期"
|
||||
clearable
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="收入类型" prop="chargeType">
|
||||
<el-select v-model="queryParams.chargeType" placeholder="全部类型" clearable>
|
||||
<el-option v-for="item in chargeTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
@@ -45,31 +34,28 @@
|
||||
<template #header>
|
||||
<div class="toolbar-shell">
|
||||
<div class="table-heading">
|
||||
<span class="panel-kicker">Income Dataset</span>
|
||||
<h3>收入明细</h3>
|
||||
<p>共 {{ total }} 条记录,支持按商户、支付方式和收入时间筛选。</p>
|
||||
<h3>收入明细列表</h3>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<!-- 收入模块的接口与菜单尚未建立,权限标识待后端约定后再补 v-hasPermi -->
|
||||
<el-button type="primary" plain icon="Download" @click="notImplemented">导出</el-button>
|
||||
<right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="incomeList">
|
||||
<el-table-column label="充值流水号" prop="orderNo" align="center" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="商户名称" prop="merchantName" align="center" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="设备编号" prop="deviceNo" align="center" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="用户名称" prop="userName" align="center" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="充值金额(元)" prop="amount" align="center" width="130" />
|
||||
<el-table-column label="支付方式" prop="payType" align="center" width="110">
|
||||
<!-- data-full-height-table="false":表格按内容自适应高度,不跟随全局「全高表格」设置铺满整屏 -->
|
||||
<el-table v-loading="loading" border class="data-table" data-full-height-table="false" :data="incomeList">
|
||||
<el-table-column label="交易日期" align="center" prop="incomeTime" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="商户" align="center" prop="merchantName" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="房间" align="center" prop="roomNo" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="设备编号" align="center" prop="deviceNo" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="充值类型" align="center" min-width="120">
|
||||
<template #default="scope">{{ getChargeTypeLabel(scope.row.chargeType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" align="center" min-width="120">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="payTypeOptions" :value="scope.row.payType" />
|
||||
<span class="amount-text">{{ formatAmount(scope.row.amount) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="收入时间" prop="incomeTime" align="center" width="170" />
|
||||
<el-table-column label="备注" prop="remark" align="center" min-width="140" show-overflow-tooltip />
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
@@ -85,70 +71,61 @@
|
||||
|
||||
<script setup name="Income" lang="ts">
|
||||
import { useLoading } from '@/hooks/async/useLoading';
|
||||
import { useDateRangeQuery } from '@/hooks/form/useDateRangeQuery';
|
||||
import { useSearchReset } from '@/hooks/form/useSearchReset';
|
||||
import { useSearchToggle } from '@/hooks/form/useSearchToggle';
|
||||
import modal from '@/plugins/modal';
|
||||
|
||||
/** 充值收入流水明细(只读台账) */
|
||||
/** 收入明细流水(只读台账) */
|
||||
interface IncomeVO {
|
||||
/** 收入ID */
|
||||
incomeId?: string;
|
||||
/** 充值流水号 */
|
||||
orderNo?: string;
|
||||
/** 交易日期 */
|
||||
incomeTime?: string;
|
||||
/** 商户名称 */
|
||||
merchantName?: string;
|
||||
/** 房间号 */
|
||||
roomNo?: string;
|
||||
/** 设备编号 */
|
||||
deviceNo?: string;
|
||||
/** 用户名称 */
|
||||
userName?: string;
|
||||
/** 充值金额(元) */
|
||||
/** 充值类型(0电费 1水费) */
|
||||
chargeType?: string;
|
||||
/** 金额(元) */
|
||||
amount?: number;
|
||||
/** 支付方式(1微信 2支付宝 3现金 4余额) */
|
||||
payType?: string;
|
||||
/** 收入时间 */
|
||||
incomeTime?: string;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
interface IncomeQuery extends PageQuery {
|
||||
orderNo?: string;
|
||||
merchantName?: string;
|
||||
payType?: string;
|
||||
/** 开始日期(YYYY-MM-DD) */
|
||||
beginDate?: string;
|
||||
/** 收入类型(0电费 1水费) */
|
||||
chargeType?: string;
|
||||
}
|
||||
|
||||
// 支付方式字典后端尚未建立,先用本地兜底选项
|
||||
const payTypeOptions: DictDataOption[] = [
|
||||
{ label: '微信', value: '1', elTagType: 'success' },
|
||||
{ label: '支付宝', value: '2', elTagType: 'primary' },
|
||||
{ label: '现金', value: '3', elTagType: 'warning' },
|
||||
{ label: '余额', value: '4', elTagType: 'info' }
|
||||
/** 收入类型选项:与设备类型取值保持一致(0电表/电费,1水表/水费) */
|
||||
const chargeTypeOptions: DictDataOption[] = [
|
||||
{ label: '电费', value: '0' },
|
||||
{ label: '水费', value: '1' }
|
||||
];
|
||||
|
||||
const getChargeTypeLabel = (value?: string) =>
|
||||
chargeTypeOptions.find(item => item.value === String(value))?.label || (value ? String(value) : '—');
|
||||
|
||||
const formatAmount = (value?: number | null) =>
|
||||
value == null ? '—' : `¥${Number(value).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
|
||||
const incomeList = ref<IncomeVO[]>([]);
|
||||
const total = ref(0);
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const { showSearch } = useSearchToggle();
|
||||
const { loading, withLoading } = useLoading(true);
|
||||
const {
|
||||
dateRange: dateRangeIncomeTime,
|
||||
applyDateRange: applyIncomeTimeDateRange,
|
||||
resetDateRange: resetIncomeTimeDateRange
|
||||
} = useDateRangeQuery('IncomeTime');
|
||||
|
||||
const queryParams = ref<IncomeQuery>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
orderNo: '',
|
||||
merchantName: '',
|
||||
payType: ''
|
||||
beginDate: undefined,
|
||||
chargeType: undefined
|
||||
});
|
||||
|
||||
/** 查询收入明细列表 */
|
||||
const getList = async () => {
|
||||
// 把「收入时间」区间写进 queryParams.params(beginIncomeTime / endIncomeTime)
|
||||
applyIncomeTimeDateRange(queryParams.value);
|
||||
await withLoading(async () => {
|
||||
// TODO: 收入接口就绪后替换为真实请求,例如 listIncome(queryParams.value) 取 res.data.rows / res.data.total
|
||||
incomeList.value = [];
|
||||
@@ -166,17 +143,13 @@ const { resetQuery } = useSearchReset({
|
||||
queryFormRef,
|
||||
queryParams,
|
||||
pageNumKey: 'pageNum',
|
||||
resetExtras: () => {
|
||||
resetIncomeTimeDateRange();
|
||||
},
|
||||
pageSizeKey: 'pageSize',
|
||||
initialPageSize: 10,
|
||||
afterReset: () => {
|
||||
handleQuery();
|
||||
}
|
||||
});
|
||||
|
||||
/** 尚未接入的写操作统一提示,避免静默失败 */
|
||||
const notImplemented = () => modal.msgWarning('收入接口待接入,暂不支持该操作');
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
@@ -186,4 +159,11 @@ onMounted(() => {
|
||||
@use '@/assets/styles/components/page-shell' as pageShell;
|
||||
|
||||
@include pageShell.table-crud-page;
|
||||
|
||||
.data-table {
|
||||
.amount-text {
|
||||
color: var(--el-color-primary);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,28 +1,23 @@
|
||||
<template>
|
||||
<div class="p-2 app-container merchant-index-page">
|
||||
<div class="p-2 page-shell merchantManage-merchant-page">
|
||||
<div class="search-wrap">
|
||||
<el-card shadow="hover" class="search-panel" :class="{ 'is-collapsed': !showSearch }">
|
||||
<template #header>
|
||||
<div class="panel-heading search-panel-toggle" @click.stop="showSearch = !showSearch">
|
||||
<div>
|
||||
<span class="panel-kicker">Search Filters</span>
|
||||
<h3>筛选条件</h3>
|
||||
</div>
|
||||
<div><h3>筛选条件</h3></div>
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" class="query-form">
|
||||
<el-form-item label="商户名称" prop="merchantName">
|
||||
<el-input v-model="queryParams.merchantName" placeholder="请输入商户名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系人" prop="contactName">
|
||||
<el-input v-model="queryParams.contactName" placeholder="请输入联系人" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系电话" prop="contactPhone">
|
||||
<el-input v-model="queryParams.contactPhone" placeholder="请输入联系电话" clearable @keyup.enter="handleQuery" />
|
||||
<el-form-item label="手机号" prop="contactPhone">
|
||||
<el-input v-model="queryParams.contactPhone" placeholder="请输入手机号" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
||||
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
<el-select v-model="queryParams.status" placeholder="全部状态" clearable>
|
||||
<el-option label="正常" value="0" />
|
||||
<el-option label="禁用" value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@@ -37,127 +32,144 @@
|
||||
<template #header>
|
||||
<div class="toolbar-shell">
|
||||
<div class="table-heading">
|
||||
<span class="panel-kicker">Merchant Dataset</span>
|
||||
<h3>商户列表</h3>
|
||||
<p>共 {{ total }} 条记录,支持按联系人和状态筛选。</p>
|
||||
<h3>多商户列表</h3>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<!-- 商户模块的接口与菜单尚未建立,权限标识待后端约定后再补 v-hasPermi -->
|
||||
<el-button type="primary" plain icon="Plus" @click="notImplemented">新增</el-button>
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="notImplemented">修改</el-button>
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="notImplemented">删除</el-button>
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['merchantManage:merchant:remove']">删除</el-button>
|
||||
<right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="merchantList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center" />
|
||||
<el-table-column label="商户编号" prop="merchantNo" align="center" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="商户名称" prop="merchantName" align="center" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="联系人" prop="contactName" align="center" width="120" />
|
||||
<el-table-column label="联系电话" prop="contactPhone" align="center" width="130" />
|
||||
<el-table-column label="设备数量" prop="deviceCount" align="center" width="100" />
|
||||
<el-table-column label="用户数量" prop="userCount" align="center" width="100" />
|
||||
<el-table-column label="状态" prop="status" align="center" width="100">
|
||||
<!-- data-full-height-table="false":本页表格按内容自适应高度,不跟随全局「全高表格」设置铺满整屏 -->
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
border
|
||||
class="data-table"
|
||||
data-full-height-table="false"
|
||||
:data="merchantList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="商户ID" align="center" prop="merchantId" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column label="商户名称" align="center" prop="merchantName" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column label="手机号" align="center" prop="contactPhone" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column label="绑定设备数" align="center" min-width="110">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="statusOptions" :value="scope.row.status" />
|
||||
<span>{{ scope.row.bindingDeviceCount }}台</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" prop="createTime" align="center" width="170" />
|
||||
<el-table-column label="备注" prop="remark" align="center" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="操作" align="center" width="150" fixed="right">
|
||||
<template #default>
|
||||
<el-tooltip content="详情" placement="top">
|
||||
<el-button link type="primary" icon="View" @click="notImplemented"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="notImplemented"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="notImplemented"></el-button>
|
||||
</el-tooltip>
|
||||
<el-table-column label="用户数" align="center" min-width="100">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.userCount }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="本月收入" align="center" min-width="130">
|
||||
<template #default="scope">
|
||||
<span class="amount-text">{{ formatIncome(scope.row.monthIncome) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" min-width="100">
|
||||
<template #default="scope">
|
||||
<span class="status-text" :class="getStatusClass(scope.row.status)">
|
||||
{{ getStatusLabel(scope.row.status) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" min-width="150" fixed="right">
|
||||
<template #default="scope">
|
||||
<div class="table-actions">
|
||||
<el-button link type="primary" @click="handleView(scope.row)">详情</el-button>
|
||||
<!-- 正常显示禁用,禁用显示启用 -->
|
||||
<el-button
|
||||
v-if="normalizeStatus(scope.row.status) === '0'"
|
||||
link
|
||||
type="warning"
|
||||
@click="handleToggleStatus(scope.row)"
|
||||
v-hasPermi="['merchantManage:merchant:edit']"
|
||||
>
|
||||
禁用
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else-if="normalizeStatus(scope.row.status) === '1'"
|
||||
link
|
||||
type="success"
|
||||
@click="handleToggleStatus(scope.row)"
|
||||
v-hasPermi="['merchantManage:merchant:edit']"
|
||||
>
|
||||
启用
|
||||
</el-button>
|
||||
<el-button link type="danger" @click="handleDelete(scope.row)" v-hasPermi="['merchantManage:merchant:remove']">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="Merchant" lang="ts">
|
||||
import { changeMerchantStatus, delMerchant, listMerchant } from '@/api/merchant';
|
||||
import { MerchantQuery, MerchantVO } from '@/api/merchant/types';
|
||||
import { useLoading } from '@/hooks/async/useLoading';
|
||||
import { useSearchReset } from '@/hooks/form/useSearchReset';
|
||||
import { useSearchToggle } from '@/hooks/form/useSearchToggle';
|
||||
import { useTableSelection } from '@/hooks/table/useTableSelection';
|
||||
import modal from '@/plugins/modal';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
/** 多商户(物业/房东等经营主体) */
|
||||
interface MerchantVO {
|
||||
/** 商户ID */
|
||||
merchantId?: string;
|
||||
/** 商户编号 */
|
||||
merchantNo?: string;
|
||||
/** 商户名称 */
|
||||
merchantName?: string;
|
||||
/** 联系人 */
|
||||
contactName?: string;
|
||||
/** 联系电话 */
|
||||
contactPhone?: string;
|
||||
/** 名下设备数量 */
|
||||
deviceCount?: number;
|
||||
/** 名下用户数量 */
|
||||
userCount?: number;
|
||||
/** 状态(0正常 1停用) */
|
||||
status?: string;
|
||||
/** 创建时间 */
|
||||
createTime?: string;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
interface MerchantQuery extends PageQuery {
|
||||
merchantName?: string;
|
||||
contactName?: string;
|
||||
contactPhone?: string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
// 商户状态字典后端尚未建立,先用本地兜底选项
|
||||
const statusOptions: DictDataOption[] = [
|
||||
{ label: '正常', value: '0', elTagType: 'success' },
|
||||
{ label: '停用', value: '1', elTagType: 'danger' }
|
||||
];
|
||||
const router = useRouter();
|
||||
|
||||
const merchantList = ref<MerchantVO[]>([]);
|
||||
const total = ref(0);
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const { showSearch } = useSearchToggle();
|
||||
const { loading, withLoading } = useLoading(true);
|
||||
const { single, multiple, handleSelectionChange } = useTableSelection<MerchantVO>(item => item.merchantId);
|
||||
const { showSearch } = useSearchToggle();
|
||||
const total = ref(0);
|
||||
|
||||
/** 状态统一成 '0' 正常 / '1' 禁用(兼容后端返回 '0'/'1' 或布尔值的两种形态) */
|
||||
const normalizeStatus = (status?: string | number | boolean | null): '0' | '1' | undefined => {
|
||||
if (status == null || status === '') return undefined;
|
||||
if (typeof status === 'boolean') return status ? '0' : '1';
|
||||
return String(status) === '1' ? '1' : '0';
|
||||
};
|
||||
|
||||
const getStatusLabel = (status?: string | number | boolean | null) => {
|
||||
const value = normalizeStatus(status);
|
||||
return value == null ? '—' : value === '0' ? '正常' : '禁用';
|
||||
};
|
||||
const getStatusClass = (status?: string | number | boolean | null) => {
|
||||
const value = normalizeStatus(status);
|
||||
return value == null ? 'text-muted' : value === '0' ? 'status-text--success' : 'status-text--info';
|
||||
};
|
||||
|
||||
/** 本月收入展示:空值占位,保留两位小数(后端以字符串返回,如 "0.00") */
|
||||
const formatIncome = (value?: string | number | null) => {
|
||||
if (value == null || value === '') return '—';
|
||||
const amount = Number(value);
|
||||
return Number.isNaN(amount)
|
||||
? `${value}`
|
||||
: `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
|
||||
const queryParams = ref<MerchantQuery>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
merchantName: '',
|
||||
contactName: '',
|
||||
contactPhone: '',
|
||||
status: ''
|
||||
merchantName: undefined,
|
||||
contactPhone: undefined,
|
||||
status: undefined
|
||||
});
|
||||
|
||||
/** 查询商户列表 */
|
||||
const { ids, multiple, handleSelectionChange, clearSelection } = useTableSelection<MerchantVO>(item => item.merchantId);
|
||||
|
||||
/** 查询水电业务商户(房东)列表 */
|
||||
const getList = async () => {
|
||||
// TODO: 商户接口就绪后替换为真实请求,例如 listMerchant(queryParams.value) 取 res.data.rows / res.data.total
|
||||
await withLoading(async () => {
|
||||
merchantList.value = [];
|
||||
total.value = 0;
|
||||
const res = await listMerchant(queryParams.value);
|
||||
merchantList.value = res.data?.rows;
|
||||
total.value = res.data?.total;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -171,13 +183,51 @@ const { resetQuery } = useSearchReset({
|
||||
queryFormRef,
|
||||
queryParams,
|
||||
pageNumKey: 'pageNum',
|
||||
pageSizeKey: 'pageSize',
|
||||
initialPageSize: 10,
|
||||
afterReset: () => {
|
||||
handleQuery();
|
||||
}
|
||||
});
|
||||
|
||||
/** 尚未接入的写操作统一提示,避免静默失败 */
|
||||
const notImplemented = () => modal.msgWarning('商户接口待接入,暂不支持该操作');
|
||||
/** 详情按钮操作:跳转到商户详情页 */
|
||||
const handleView = (row: Partial<MerchantVO>) => {
|
||||
router.push({ path: '/merchant/detail', query: { merchantId: String(row.merchantId) } });
|
||||
};
|
||||
|
||||
/** 启用 / 禁用:PUT /merchantManage/merchant/status/{merchantId}/{status},正常(0) → 禁用(1),禁用(1) → 正常(0) */
|
||||
const handleToggleStatus = async (row: Partial<MerchantVO>) => {
|
||||
if (row.merchantId == null) return;
|
||||
const currentStatus = normalizeStatus(row.status);
|
||||
if (currentStatus == null) return;
|
||||
const nextStatus = currentStatus === '0' ? '1' : '0';
|
||||
const actionText = nextStatus === '0' ? '启用' : '禁用';
|
||||
try {
|
||||
await modal.confirm(`是否确认${actionText}商户"${row.merchantName || row.merchantId}"?`);
|
||||
} catch {
|
||||
// 用户取消确认
|
||||
return;
|
||||
}
|
||||
await changeMerchantStatus(row.merchantId, nextStatus);
|
||||
modal.msgSuccess(`${actionText}成功`);
|
||||
await getList();
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: Partial<MerchantVO>) => {
|
||||
const merchantIds = row?.merchantId || ids.value;
|
||||
try {
|
||||
await modal.confirm('是否确认删除水电业务商户(房东)编号为"' + merchantIds + '"的数据项?');
|
||||
} catch {
|
||||
// 用户取消确认
|
||||
return;
|
||||
}
|
||||
await delMerchant(merchantIds);
|
||||
modal.msgSuccess('删除成功');
|
||||
// 清掉勾选,避免列表刷新后批量删除按钮仍拿着已删除的 ID
|
||||
clearSelection();
|
||||
await getList();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
@@ -188,4 +238,54 @@ onMounted(() => {
|
||||
@use '@/assets/styles/components/page-shell' as pageShell;
|
||||
|
||||
@include pageShell.table-crud-page;
|
||||
|
||||
.data-table {
|
||||
/* 操作列用文字按钮,覆盖 pageShell 默认的图标按钮样式 */
|
||||
:deep(.table-actions) {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px 10px;
|
||||
}
|
||||
|
||||
/* 全局 _search-panel.scss 给 .data-table 内的 link 按钮加了 28x28 圆角底色且带 !important,
|
||||
这里必须同样用 !important 才能覆盖成纯文字按钮 */
|
||||
:deep(.table-actions .el-button.is-link) {
|
||||
width: auto !important;
|
||||
min-width: auto !important;
|
||||
height: auto !important;
|
||||
padding: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
background: transparent !important;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
:deep(.table-actions .el-button.is-link + .el-button.is-link) {
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
.amount-text {
|
||||
color: var(--el-color-primary);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: var(--el-text-color-placeholder);
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.status-text--success {
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.status-text--info {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -83,7 +83,6 @@
|
||||
</p>
|
||||
<ul class="security-list">
|
||||
<li>仅限授权管理员登录,禁止共享账号</li>
|
||||
<li>连续 5 次密码错误,账号将被锁定 30 分钟</li>
|
||||
<li>长时间无操作将自动退出登录</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user