对接帮助管理、电话、系统参数接口

This commit is contained in:
zhouyanli
2026-11-05 09:27:00 +08:00
parent 914153a07c
commit 8cdaa3c69c
19 changed files with 2026 additions and 115 deletions

29
src/api/income/index.ts Normal file
View File

@@ -0,0 +1,29 @@
import type { IncomeRecordQuery, IncomeRecordVO, IncomeStatisticsPeriodType, IncomeStatisticsVO } from '@/api/income/types';
import type { PageResult } from '@/api/types';
import type { AxiosPromise } from '@/utils/api-types';
import request from '@/utils/request';
/**
* 查询收入明细列表
* @param query
* @returns {*}
*/
export const listIncome = (query?: IncomeRecordQuery): AxiosPromise<PageResult<IncomeRecordVO>> => {
return request({
url: '/merchantManage/incomeRecord/list',
method: 'get',
params: query
});
};
/**
* 查询收入统计
* @param periodType month 按月(趋势按天) / year 按年(趋势按月)
*/
export const getIncomeStatistics = (periodType: IncomeStatisticsPeriodType): AxiosPromise<IncomeStatisticsVO> => {
return request({
url: '/merchantManage/incomeRecord/statistics',
method: 'get',
params: { periodType }
});
};

134
src/api/income/types.ts Normal file
View File

@@ -0,0 +1,134 @@
export interface IncomeRecordVO {
/**
* 收入ID
*/
incomeId: string | number;
/**
* 商户ID
*/
merchantId?: string | number | null;
/**
* 商户名称
*/
merchantName?: string | null;
/**
* 房间ID
*/
roomId?: string | number | null;
/**
* 房间名称
*/
roomName?: string | null;
/**
* 房间号(如「101室」)
*/
roomNo?: string | null;
/**
* 设备ID
*/
deviceId?: string | number | null;
/**
* 设备名称
*/
deviceName?: string | null;
/**
* 设备编号
*/
deviceNo?: string | null;
/**
* 设备类型(0:电表,1:水表)
*/
deviceType?: string | null;
/**
* 用户ID
*/
userId?: string | number | null;
/**
* 充值记录ID
*/
rechargeId?: string | number | null;
/**
* 金额,后端以字符串返回(如 "0.00")
*/
amount?: string | number | null;
/**
* 收入类型(0电费 1水费)
*/
incomeType?: string | null;
/**
* 收入渠道
*/
incomeChannel?: string | null;
/**
* 交易时间
*/
occurredAt?: string | null;
/**
* 状态
*/
status?: string | null;
}
/** 统计周期:month 按月 / year 按年 */
export type IncomeStatisticsPeriodType = 'month' | 'year';
export interface IncomeTrendPoint {
/**
* 金额,后端以字符串返回(如 "0.00")
*/
amount: string | number;
/**
* X 轴刻度(如「1月」「3日」)
*/
label: string;
/**
* 周期序号
*/
periodIndex: number;
}
export interface IncomeStatisticsVO {
/**
* 对比对象文案(如「较上年」「较上月」)
*/
compareLabel?: string;
/**
* 增长率(百分数,字符串如 "12.34" / "-5.20")
*/
growthRate?: string | number;
/**
* 月份(按年统计时为 null)
*/
month?: number | null;
/**
* 统计周期
*/
periodType?: IncomeStatisticsPeriodType;
/**
* 合计标题(如「2026年合计收入」)
*/
title?: string;
/**
* 合计收入,后端以字符串返回(如 "0.00")
*/
totalAmount?: string | number;
/**
* 趋势数据
*/
trendList?: IncomeTrendPoint[];
/**
* 年份
*/
year?: number;
}
export interface IncomeRecordQuery extends PageQuery {
/**
* 设备类型(0:电表,1:水表)
*/
deviceType?: string;
/**
* 日期范围参数(beginOccurredAt / endOccurredAt)
*/
params?: any;
}

88
src/api/merchant/index.ts Normal file
View File

@@ -0,0 +1,88 @@
import type { MerchantDeviceVO, MerchantForm, MerchantQuery, MerchantVO } from '@/api/merchant/types';
import type { PageResult } from '@/api/types';
import type { AxiosPromise } from '@/utils/api-types';
import request from '@/utils/request';
/**
* 查询水电业务商户(房东)列表
* @param query
* @returns {*}
*/
export const listMerchant = (query?: MerchantQuery): AxiosPromise<PageResult<MerchantVO>> => {
return request({
url: '/merchantManage/merchant/list',
method: 'get',
params: query
});
};
/**
* 查询水电业务商户(房东)详细
* @param merchantId
*/
export const getMerchant = (merchantId: string | number): AxiosPromise<MerchantVO> => {
return request({
url: '/merchantManage/merchant/' + merchantId,
method: 'get'
});
};
/**
* 新增水电业务商户(房东)
* @param data
*/
export const addMerchant = (data: MerchantForm) => {
return request({
url: '/merchantManage/merchant',
method: 'post',
data: data
});
};
/**
* 修改水电业务商户(房东)
* @param data
*/
export const updateMerchant = (data: MerchantForm) => {
return request({
url: '/merchantManage/merchant',
method: 'put',
data: data
});
};
/**
* 查询商户名下的设备(详情页「设备分配」)
* @param merchantId 商户ID
*/
export const listMerchantDevices = (merchantId: string | number): AxiosPromise<MerchantDeviceVO[]> => {
return request({
url: '/merchantManage/merchant/' + merchantId + '/devices',
method: 'get'
});
};
/**
* 修改水电业务商户(房东)状态
* @param merchantId 商户ID
* @param status 状态(0正常 1禁用)
*/
export const changeMerchantStatus = (merchantId: string | number, status: string) => {
return request({
url: '/merchantManage/merchant/status/' + merchantId + '/' + status,
method: 'put'
});
};
/**
* 删除水电业务商户(房东)
* @param merchantId
*/
export const delMerchant = (merchantId: string | number | Array<string | number>) => {
return request({
url: '/merchantManage/merchant/' + merchantId,
method: 'delete'
});
};

214
src/api/merchant/types.ts Normal file
View File

@@ -0,0 +1,214 @@
export interface MerchantVO {
/**
* 商户ID
*/
merchantId: string | number;
/**
* 房东用户ID
*/
ownerUserId: string | number;
/**
* 商户编号
*/
merchantNo: string;
/**
* 商户名称
*/
merchantName: string;
/**
* 联系人
*/
contactName: string;
/**
* 联系电话
*/
contactPhone: string;
/**
* 商户头像
*/
avatarUrl: string | null;
/**
* 默认电费单价(元/度),后端以字符串返回(如 "0.0000")
*/
defaultElectricPrice: string | number;
/**
* 默认水费单价(元/吨),后端以字符串返回(如 "0.0000")
*/
defaultWaterPrice: string | number;
/**
* 状态(0正常 1禁用)
*/
status: string;
/**
* 绑定设备数
*/
bindingDeviceCount?: number;
/**
* 用户数
*/
userCount?: number;
/**
* 本月收入,后端以字符串返回(如 "0.00")
*/
monthIncome?: string | number;
/**
* 累计收入,后端以字符串返回(如 "0.00")
*/
totalIncome?: string | number;
/**
* 创建时间(详情页展示)
*/
createTime?: string;
/**
* 更新时间(详情页展示)
*/
updateTime?: string;
}
/**
* 商户名下的设备(详情页「设备分配」列表)
*/
export interface MerchantDeviceVO {
/** 设备ID */
deviceId: string | number;
/** 设备编号 */
deviceNo: string;
/** 设备名称 */
deviceName: string;
/** 设备类型(0:电表,1:水表) */
deviceType: string;
/** 房间号,如「101室」 */
roomNo?: string | null;
/** 房间名称(后端可能为空,回退 roomNo / roomId) */
roomName?: string | null;
/** 房间ID */
roomId?: string | number | null;
/** 剩余金额,后端以字符串返回(如 "0.00") */
remainingBalance?: string | number | null;
/** 当前单价,后端可能为空 */
currentUnitPrice?: string | number | null;
/** 设备启用状态 */
status?: string;
/** 开关状态(0正常 1强制拉闸 2欠费拉闸 3离线) */
switchStatus?: string;
/** 通讯类型 */
communicationType?: string | null;
}
export interface MerchantForm extends BaseEntity {
/**
* 商户ID
*/
merchantId?: string | number;
/**
* 房东用户ID
*/
ownerUserId?: number;
/**
* 商户编号
*/
merchantNo?: string;
/**
* 商户名称
*/
merchantName?: string;
/**
* 联系人
*/
contactName?: string;
/**
* 联系电话
*/
contactPhone?: string;
/**
* 商户头像
*/
avatarUrl?: string;
/**
* 默认电费单价(元/度)
*/
defaultElectricPrice?: number;
/**
* 默认水费单价(元/吨)
*/
defaultWaterPrice?: number;
/**
* 状态(0正常 1禁用)
*/
status?: string;
/**
* 创建后台账号ID
*/
createBy?: number;
/**
* 创建时间
*/
createTime?: string;
/**
* 更新后台账号ID
*/
updateBy?: number;
/**
* 更新时间
*/
updateTime?: string;
}
export interface MerchantQuery extends PageQuery {
/**
* 房东用户ID
*/
ownerUserId?: string | number;
/**
* 商户编号
*/
merchantNo?: string;
/**
* 商户名称
*/
merchantName?: string;
/**
* 联系人
*/
contactName?: string;
/**
* 联系电话
*/
contactPhone?: string;
/**
* 商户头像
*/
avatarUrl?: string;
/**
* 默认电费单价(元/度)
*/
defaultElectricPrice?: number;
/**
* 默认水费单价(元/吨)
*/
defaultWaterPrice?: number;
/**
* 状态(0正常 1禁用)
*/
status?: string;
/**
* 创建后台账号ID
*/
createBy?: number;
/**
* 创建时间
*/
createTime?: string;
/**
* 更新后台账号ID
*/
updateBy?: number;
/**
* 更新时间
*/
updateTime?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,65 @@
import type { PlatformConfigForm, PlatformConfigQuery, PlatformConfigVO } from './types';
import type { PageResult } from '@/api/types';
import type { AxiosPromise } from '@/utils/api-types';
import request from '@/utils/request';
/**
* 查询水电充值平台配置列表
* @param query
* @returns {*}
*/
export const listPlatformConfig = (query?: PlatformConfigQuery): AxiosPromise<PageResult<PlatformConfigVO>> => {
return request({
url: '/rechargeManage/platformConfig/list',
method: 'get',
params: query
});
};
/**
* 查询水电充值平台配置详细
* @param configId
*/
export const getPlatformConfig = (configId: string | number): AxiosPromise<PlatformConfigVO> => {
return request({
url: '/rechargeManage/platformConfig/' + configId,
method: 'get'
});
};
/**
* 新增水电充值平台配置
* @param data
*/
export const addPlatformConfig = (data: PlatformConfigForm) => {
return request({
url: '/rechargeManage/platformConfig',
method: 'post',
data: data
});
};
/**
* 修改水电充值平台配置
* @param data
*/
export const updatePlatformConfig = (data: PlatformConfigForm) => {
return request({
url: '/rechargeManage/platformConfig',
method: 'put',
data: data
});
};
/**
* 删除水电充值平台配置
* @param configId
*/
export const delPlatformConfig = (configId: string | number | Array<string | number>) => {
return request({
url: '/rechargeManage/platformConfig/' + configId,
method: 'delete'
});
};

View File

@@ -0,0 +1,116 @@
export interface PlatformConfigVO {
/**
* 配置ID
*/
configId: string | number;
/**
* 配置键
*/
configKey: string;
/**
* 配置值
*/
configValue: string;
/**
* 值类型(0string 1integer 2decimal)
*/
valueType: string;
/**
* 配置说明
*/
remark: string;
/**
* 状态(0启用 1停用)
*/
status: string;
}
export interface PlatformConfigForm extends BaseEntity {
/**
* 配置ID
*/
configId?: string | number;
/**
* 配置键
*/
configKey?: string;
/**
* 配置值
*/
configValue?: string;
/**
* 值类型(0string 1integer 2decimal)
*/
valueType?: string;
/**
* 配置说明
*/
remark?: string;
/**
* 状态(0启用 1停用)
*/
status?: string;
/**
* 创建部门
*/
createDept?: number;
/**
* 创建后台账号ID
*/
createBy?: number;
/**
* 创建时间
*/
createTime?: string;
/**
* 更新后台账号ID
*/
updateBy?: number;
/**
* 更新时间
*/
updateTime?: string;
}
export interface PlatformConfigQuery extends PageQuery {
/**
* 配置键
*/
configKey?: string;
/**
* 配置值
*/
configValue?: string;
/**
* 值类型(0string 1integer 2decimal)
*/
valueType?: string;
/**
* 状态(0启用 1停用)
*/
status?: string;
/**
* 创建部门
*/
createDept?: number;
/**
* 创建后台账号ID
*/
createBy?: number;
/**
* 创建时间
*/
createTime?: string;
/**
* 更新后台账号ID
*/
updateBy?: number;
/**
* 更新时间
*/
updateTime?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,73 @@
import type { ServicePhoneForm, ServicePhoneQuery, ServicePhoneVO } from '@/api/system/servicePhone/types';
import type { PageResult } from '@/api/types';
import type { AxiosPromise } from '@/utils/api-types';
import request from '@/utils/request';
/**
* 查询客服及服务电话列表
* @param query
* @returns {*}
*/
export const listServicePhone = (query?: ServicePhoneQuery): AxiosPromise<PageResult<ServicePhoneVO>> => {
return request({
url: '/system/servicePhone/list',
method: 'get',
params: query
});
};
/**
* 查询客服及服务电话详细
* @param phoneId
*/
export const getServicePhone = (phoneId: string | number): AxiosPromise<ServicePhoneVO> => {
return request({
url: '/system/servicePhone/' + phoneId,
method: 'get'
});
};
/**
* 新增客服及服务电话
* @param data
*/
export const addServicePhone = (data: ServicePhoneForm) => {
return request({
url: '/system/servicePhone',
method: 'post',
data: data
});
};
/**
* 修改客服及服务电话
* @param data
*/
export const updateServicePhone = (data: ServicePhoneForm) => {
return request({
url: '/system/servicePhone',
method: 'put',
data: data
});
};/**
* 启用 / 停用客服及服务电话
* @param phoneId
* @param status 状态(0启用 1停用)
*/
export const changeServicePhoneStatus = (phoneId: string | number, status: string) => {
return request({
url: '/system/servicePhone/' + phoneId + '/' + status,
method: 'put'
});
};
/**
* 删除客服及服务电话
* @param phoneId
*/
export const delServicePhone = (phoneId: string | number | Array<string | number>) => {
return request({
url: '/system/servicePhone/' + phoneId,
method: 'delete'
});
};

View File

@@ -0,0 +1,120 @@
export interface ServicePhoneVO {
/**
* 服务电话ID
*/
phoneId: string | number;
/**
* 电话类型
*/
phoneType: string;
/**
* 电话号码
*/
phoneNumber: string;
/**
* 说明
*/
description: string;
/**
* 排序号
*/
sortNo: number;
/**
* 状态(0启用 1停用)
*/
status: string;
}
export interface ServicePhoneForm extends BaseEntity {
/**
* 服务电话ID
*/
phoneId?: string | number;
/**
* 电话类型
*/
phoneType?: string;
/**
* 电话号码
*/
phoneNumber?: string;
/**
* 说明
*/
description?: string;
/**
* 排序号
*/
sortNo?: number;
/**
* 状态(0启用 1停用)
*/
status?: string;
/**
* 创建部门
*/
createDept?: number;
/**
* 创建后台账号ID
*/
createBy?: number;
/**
* 创建时间
*/
createTime?: string;
/**
* 更新后台账号ID
*/
updateBy?: number;
/**
* 更新时间
*/
updateTime?: string;
}
export interface ServicePhoneQuery extends PageQuery {
/**
* 电话类型
*/
phoneType?: string;
/**
* 电话号码
*/
phoneNumber?: string;
/**
* 说明
*/
description?: string;
/**
* 排序号
*/
sortNo?: number;
/**
* 状态(0启用 1停用)
*/
status?: string;
/**
* 创建部门
*/
createDept?: number;
/**
* 创建后台账号ID
*/
createBy?: number;
/**
* 创建时间
*/
createTime?: string;
/**
* 更新后台账号ID
*/
updateBy?: number;
/**
* 更新时间
*/
updateTime?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,17 @@
import type { PageResult } from '@/api/types';
import type { WithdrawalQuery, WithdrawalVO } from '@/api/withdrawal/types';
import type { AxiosPromise } from '@/utils/api-types';
import request from '@/utils/request';
/**
* 查询商户提现申请列表
* @param query
* @returns {*}
*/
export const listWithdrawal = (query?: WithdrawalQuery): AxiosPromise<PageResult<WithdrawalVO>> => {
return request({
url: '/merchantManage/merchantWithdrawalOrder/list',
method: 'get',
params: query
});
};

View File

@@ -0,0 +1,97 @@
export interface WithdrawalVO {
/**
* 提现ID
*/
withdrawalId: string | number;
/**
* 商户ID
*/
merchantId?: string | number | null;
/**
* 钱包ID
*/
walletId?: string | number | null;
/**
* 申请人用户ID
*/
applicantUserId?: string | number | null;
/**
* 申请人姓名
*/
applicantName?: string | null;
/**
* 申请编号
*/
applyNo?: string | null;
/**
* 提现金额,后端以字符串返回(如 "100.00")
*/
amount?: string | number | null;
/**
* 银行卡账户ID
*/
bankAccountId?: string | number | null;
/**
* 银行名称
*/
bankName?: string | null;
/**
* 脱敏卡号
*/
cardNoMasked?: string | null;
/**
* 收款账户展示文案(如「中国银行 22」)
*/
receiveAccount?: string | null;
/**
* 渠道订单号(打款后回填)
*/
channelOrderNo?: string | null;
/**
* 审核状态(状态码含义以后端为准)
*/
status?: string | null;
/**
* 驳回原因
*/
rejectReason?: string | null;
/**
* 审核人ID
*/
reviewerId?: string | number | null;
/**
* 审核时间
*/
reviewedAt?: string | null;
/**
* 打款时间
*/
paidAt?: string | null;
/**
* 申请时间
*/
createTime?: string | null;
}
export interface WithdrawalQuery extends PageQuery {
/**
* 申请编号
*/
applyNo?: string;
/**
* 申请人姓名
*/
applicantName?: string;
/**
* 商户ID
*/
merchantId?: string | number;
/**
* 审核状态
*/
status?: string;
/**
* 日期范围参数(beginCreateTime / endCreateTime)
*/
params?: any;
}

View File

@@ -57,7 +57,13 @@
<template #default="scope">{{ getDeviceTypeLabel(deviceTypeDict, scope.row.deviceType) }}</template> <template #default="scope">{{ getDeviceTypeLabel(deviceTypeDict, scope.row.deviceType) }}</template>
</el-table-column> </el-table-column>
<el-table-column label="所属商户" align="center" min-width="130" show-overflow-tooltip> <el-table-column label="所属商户" align="center" min-width="130" show-overflow-tooltip>
<template #default="scope">{{ scope.row.merchantName || scope.row.merchantId || '—' }}</template> <template #default="scope">{{ scope.row.merchantName}}</template>
</el-table-column>
<el-table-column label="二维码" align="center" prop="qrCode" width="100">
<template #default="scope">
<image-preview v-if="scope.row.qrCode" :src="scope.row.qrCode" :width="50" :height="50" />
<span v-else class="text-muted"></span>
</template>
</el-table-column> </el-table-column>
<el-table-column label="剩余金额" align="center" min-width="110"> <el-table-column label="剩余金额" align="center" min-width="110">
<template #default="scope"> <template #default="scope">

View File

@@ -55,7 +55,7 @@
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['helpManage:helpArticle:add']">新增</el-button> <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['helpManage:helpArticle:add']">新增</el-button>
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['helpManage:helpArticle:edit']">修改</el-button> <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['helpManage:helpArticle:edit']">修改</el-button>
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['helpManage:helpArticle:remove']">删除</el-button> <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['helpManage:helpArticle:remove']">删除</el-button>
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['helpManage:helpArticle:export']">导出</el-button> <!-- <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['helpManage:helpArticle:export']">导出</el-button> -->
<right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar> <right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,365 @@
<template>
<div class="p-2 app-container income-statistics-page">
<div class="page-head">
<h2 class="page-title">收入统计</h2>
<div class="range-tabs" role="tablist" aria-label="统计范围">
<button
v-for="tab in rangeTabs"
:key="tab.value"
type="button"
role="tab"
class="range-tab"
:class="{ 'is-active': activeRange === tab.value }"
:aria-selected="activeRange === tab.value"
@click="activeRange = tab.value"
>
{{ tab.label }}
</button>
</div>
</div>
<section v-loading="loading" class="hero-card">
<div class="hero-main">
<div class="hero-label">{{ periodLabel }}</div>
<div class="hero-value">{{ formatMoney(totalAmount) }}</div>
<div class="hero-delta" :class="`is-${growthTone}`">
<span>{{ compareLabel }}</span>
<span class="hero-delta-value">{{ growthRateText }}</span>
</div>
</div>
<div class="hero-icon" aria-hidden="true">
<el-icon :size="26"><Wallet /></el-icon>
</div>
</section>
<el-card shadow="hover" class="trend-card">
<h3 class="section-title">收入趋势</h3>
<div ref="chartRef" class="trend-chart" role="img" :aria-label="`收入趋势折线图,${periodLabel}`"></div>
<!-- 图表的可读版本:数据同时以表格提供,屏幕阅读器与色觉障碍用户不依赖颜色读数 -->
<table class="visually-hidden">
<caption>收入趋势数据</caption>
<thead>
<tr>
<th scope="col">{{ activeRange === 'month' ? '日期' : '月份' }}</th>
<th scope="col">收入(元)</th>
</tr>
</thead>
<tbody>
<tr v-for="item in chartData" :key="item.label">
<th scope="row">{{ item.label }}</th>
<td>{{ formatMoney(item.value) }}</td>
</tr>
</tbody>
</table>
</el-card>
</div>
</template>
<script setup name="IncomeStatistics" lang="ts">
import * as echarts from 'echarts';
import { getIncomeStatistics } from '@/api/income';
import type { IncomeStatisticsVO } from '@/api/income/types';
import { useLoading } from '@/hooks/async/useLoading';
interface IncomeStatPoint {
/** X 轴刻度(1日 / 1月) */
label: string;
/** 收入金额(元) */
value: number;
}
const rangeTabs = [
{ label: '月收入', value: 'month' as const },
{ label: '年收入', value: 'year' as const }
];
const activeRange = ref<'month' | 'year'>('month');
const chartRef = ref<HTMLDivElement>();
const { loading, withLoading } = useLoading(true);
/** 接口返回:合计 + 环比 + 趋势点 */
const statistics = ref<IncomeStatisticsVO>();
/** 合计标题,如「2026年合计收入」 */
const periodLabel = computed(
() => statistics.value?.title || (activeRange.value === 'month' ? '本月合计收入' : '本年合计收入')
);
const totalAmount = computed(() => Number(statistics.value?.totalAmount ?? 0));
const compareLabel = computed(
() => statistics.value?.compareLabel || (activeRange.value === 'month' ? '较上月' : '较上年')
);
const growthRate = computed(() => Number(statistics.value?.growthRate ?? 0));
/** 增长率带符号展示:正数补 +,负数自带 - */
const growthRateText = computed(() => `${growthRate.value > 0 ? '+' : ''}${growthRate.value.toFixed(2)}%`);
/** 涨跌配色:涨绿、跌红、持平用默认弱化色 */
const growthTone = computed(() => (growthRate.value > 0 ? 'up' : growthRate.value < 0 ? 'down' : 'flat'));
const chartData = computed<IncomeStatPoint[]>(() =>
(statistics.value?.trendList ?? []).map(item => ({
label: item.label,
value: Number(item.amount ?? 0)
}))
);
/** 快速切换月/年时,丢弃先发后至的旧响应 */
let requestSeq = 0;
const fetchStatistics = async () => {
const seq = ++requestSeq;
await withLoading(async () => {
const res = await getIncomeStatistics(activeRange.value);
if (seq !== requestSeq) return;
statistics.value = res.data ?? undefined;
});
};
/** 与设置抽屉共用同一套暗色偏好 */
const isDark = useDark({ storageKey: 'useDarkKey', valueDark: 'dark', valueLight: 'light' });
const formatMoney = (value: number) =>
Number(value).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
/** 坐标轴数值:过万后压缩成「万」,避免轴标签过长 */
const formatAxisValue = (value: number) => (Math.abs(value) >= 10000 ? `${value / 10000}万` : `${value}`);
const readCssVar = (name: string, fallback: string) => {
const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
return value || fallback;
};
let chart: echarts.ECharts | undefined;
let resizeObserver: ResizeObserver | undefined;
const buildChartOption = () => {
const dark = isDark.value;
// 单序列折线:浅色用品牌蓝,暗色用其提亮步进,两者均已按各自底色校验过对比度
const seriesColor = dark ? '#3987e5' : '#356dff';
const surfaceColor = readCssVar('--app-surface-bg', dark ? '#111827' : '#ffffff');
const labelColor = readCssVar('--el-text-color-secondary', dark ? '#c3c2b7' : '#52514e');
const gridColor = readCssVar('--el-border-color-lighter', dark ? '#2c2c2a' : '#e1e0d9');
const axisColor = readCssVar('--app-surface-border', dark ? '#383835' : '#c3c2b7');
return {
animationDuration: 320,
grid: { left: 8, right: 18, top: 16, bottom: 4, containLabel: true },
tooltip: {
trigger: 'axis',
axisPointer: { type: 'line', lineStyle: { color: axisColor, width: 1, type: 'solid' } },
backgroundColor: surfaceColor,
borderColor: gridColor,
textStyle: { color: labelColor, fontSize: 12 },
valueFormatter: (value: unknown) => `¥${formatMoney(Number(value))}`
},
xAxis: {
type: 'category',
data: chartData.value.map(item => item.label),
boundaryGap: false,
axisLine: { lineStyle: { color: axisColor } },
axisTick: { show: false },
axisLabel: { color: labelColor, fontSize: 12, margin: 12 }
},
yAxis: {
type: 'value',
// 从 0 起算,避免截断纵轴放大波动
min: 0,
axisLine: { show: false },
axisTick: { show: false },
axisLabel: { color: labelColor, fontSize: 12, formatter: formatAxisValue },
splitLine: { lineStyle: { color: gridColor, width: 1, type: 'solid' } }
},
series: [
{
name: '收入',
type: 'line',
data: chartData.value.map(item => item.value),
symbol: 'circle',
symbolSize: 7,
// 2px 底色描边:数据点在折线交叠处仍可分辨
itemStyle: { color: seriesColor, borderColor: surfaceColor, borderWidth: 2 },
lineStyle: { width: 2, color: seriesColor, cap: 'round', join: 'round' },
emphasis: { scale: 1.6 }
}
]
};
};
const renderChart = () => {
if (!chartRef.value) return;
if (!chart) {
chart = echarts.init(chartRef.value);
}
chart.setOption(buildChartOption(), true);
chart.resize();
};
// 切换月/年:重新拉数据,数据到位后再重绘,避免用旧数据画图
watch(activeRange, async () => {
await fetchStatistics();
await nextTick();
renderChart();
});
// 主题切换时重新读取 CSS 变量,让轴线、标签、描边跟着换色
watch(isDark, () => {
nextTick(renderChart);
});
onMounted(async () => {
await fetchStatistics();
await nextTick();
renderChart();
if (chartRef.value) {
resizeObserver = new ResizeObserver(() => chart?.resize());
resizeObserver.observe(chartRef.value);
}
});
onBeforeUnmount(() => {
resizeObserver?.disconnect();
resizeObserver = undefined;
chart?.dispose();
chart = undefined;
});
</script>
<style lang="scss" scoped>
.page-head {
display: flex;
align-items: center;
gap: 20px;
}
.page-title {
margin: 0;
font-size: 20px;
font-weight: 700;
color: var(--el-text-color-primary);
}
.range-tabs {
display: inline-flex;
gap: 4px;
padding: 4px;
border-radius: 10px;
background: var(--el-fill-color-light);
}
.range-tab {
padding: 7px 20px;
border: 0;
border-radius: 8px;
background: transparent;
color: var(--el-text-color-secondary);
font-size: 14px;
cursor: pointer;
transition:
background-color 0.2s,
color 0.2s;
&:hover {
color: var(--el-text-color-primary);
}
&.is-active {
background: var(--app-surface-bg);
color: var(--el-text-color-primary);
font-weight: 600;
box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
}
}
.hero-card {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24px;
padding: 26px 30px;
border-radius: 14px;
background: linear-gradient(135deg, #0b1220 0%, #111c30 100%);
}
.hero-label {
font-size: 13px;
color: rgb(255 255 255 / 62%);
}
/* 单页唯一的主数字:系统无衬线、比例数字,不用 tabular-nums */
.hero-value {
margin-top: 10px;
color: #fff;
font-size: 48px;
font-weight: 700;
line-height: 1.1;
letter-spacing: 0.5px;
}
.hero-delta {
display: inline-flex;
align-items: center;
gap: 8px;
margin-top: 16px;
padding: 5px 12px;
border-radius: 8px;
background: rgb(255 255 255 / 8%);
color: rgb(255 255 255 / 66%);
font-size: 12px;
}
.hero-delta-value {
font-weight: 600;
}
.hero-delta.is-up .hero-delta-value {
color: #4ade80;
}
.hero-delta.is-down .hero-delta-value {
color: #f87171;
}
.hero-delta.is-flat .hero-delta-value {
color: rgb(255 255 255 / 82%);
}
.hero-icon {
display: flex;
flex: 0 0 auto;
align-items: center;
justify-content: center;
width: 56px;
height: 56px;
border-radius: 14px;
background: rgb(219 234 254 / 92%);
color: #356dff;
}
.trend-card {
:deep(.el-card__body) {
padding: 20px 22px 12px;
}
}
.section-title {
margin: 0 0 8px;
font-size: 16px;
font-weight: 700;
color: var(--el-text-color-primary);
}
.trend-chart {
width: 100%;
height: 540px;
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
border: 0;
clip: rect(0 0 0 0);
white-space: nowrap;
}
</style>

View File

@@ -0,0 +1,285 @@
<template>
<div class="p-2 app-container merchantManage-merchant-detail-page">
<div class="detail-header">
<el-button link class="back-button" title="返回" @click="goBack">
<el-icon :size="20"><ArrowLeft /></el-icon>
</el-button>
<h2 class="detail-title">多商户详情</h2>
</div>
<!-- 商户概要 -->
<el-card shadow="hover" class="summary-card" v-loading="loading">
<template v-if="merchant.merchantId != null">
<div class="summary-head">
<el-avatar :size="52" shape="square" :src="merchant.avatarUrl" class="merchant-avatar">
<el-icon :size="24"><Shop /></el-icon>
</el-avatar>
<div class="merchant-name">{{ merchant.merchantName }}</div>
</div>
<div class="summary-grid">
<div class="summary-item">
<span class="summary-label">手机号</span>
<span class="summary-value">{{ merchant.contactPhone }}</span>
</div>
<div class="summary-item">
<span class="summary-label">设备数</span>
<span class="summary-value">{{ merchant.bindingDeviceCount ?? 0 }}台</span>
</div>
<div class="summary-item">
<span class="summary-label">用户数</span>
<span class="summary-value">{{ merchant.userCount ?? 0 }}人</span>
</div>
<div class="summary-item">
<span class="summary-label">本月收入</span>
<span class="summary-value">{{ formatMoney(merchant.monthIncome) }}</span>
</div>
<div class="summary-item">
<span class="summary-label">累计收入</span>
<span class="summary-value">{{ formatMoney(merchant.totalIncome) }}</span>
</div>
</div>
</template>
<el-empty v-else-if="!loading" description="未找到商户信息" />
</el-card>
<!-- 设备分配 -->
<el-card shadow="hover" class="device-card">
<h3 class="section-title">设备分配</h3>
<p class="section-sub">共{{ deviceCount }}台设备</p>
<el-table
v-if="devices.length"
border
class="data-table"
data-full-height-table="false"
:data="devices"
>
<el-table-column label="设备编号" align="center" prop="deviceNo" min-width="130" show-overflow-tooltip />
<el-table-column label="设备名称" align="center" prop="deviceName" min-width="130" show-overflow-tooltip />
<el-table-column label="设备类型" align="center" min-width="100">
<template #default="scope">{{ deviceTypeText(scope.row.deviceType) }}</template>
</el-table-column>
<el-table-column label="房间" align="center" min-width="100" show-overflow-tooltip>
<template #default="scope">{{ scope.row.roomNo || scope.row.roomName || scope.row.roomId }}</template>
</el-table-column>
<el-table-column label="剩余金额" align="center" min-width="110">
<template #default="scope">
<span class="amount-text">{{ scope.row.remainingBalance }}</span>
</template>
</el-table-column>
<el-table-column label="状态" align="center" min-width="110">
<template #default="scope">
<span class="switch-status" :class="getSwitchStatusClass(scope.row.switchStatus)">
{{ statusText(scope.row.switchStatus) }}
</span>
</template>
</el-table-column>
<el-table-column label="单价" align="center" min-width="100">
<template #default="scope">{{ scope.row.currentUnitPrice }}</template>
</el-table-column>
</el-table>
<el-empty v-else :image-size="90" description="暂无设备" />
</el-card>
<div class="detail-footer">
<el-button icon="ArrowLeft" @click="goBack">返 回</el-button>
</div>
</div>
</template>
<script setup name="MerchantDetail" lang="ts">
import { useRoute, useRouter } from 'vue-router';
import { getMerchant, listMerchantDevices } from '@/api/merchant';
import type { MerchantDeviceVO, MerchantVO } from '@/api/merchant/types';
import { useLoading } from '@/hooks/async/useLoading';
import modal from '@/plugins/modal';
import { getDeviceTypeLabel, getSwitchStatusClass, getSwitchStatusLabel, useDeviceTypeDict } from '../device/constants';
const route = useRoute();
const router = useRouter();
const { loading, withLoading } = useLoading(true);
const deviceTypeDict = useDeviceTypeDict();
/** 当前商户ID(由商户列表跳转携带) */
const merchantId = computed(() => route.query.merchantId as string | undefined);
const merchant = ref<Partial<MerchantVO>>({});
const devices = ref<MerchantDeviceVO[]>([]);
/** 设备台数:接口返回的是不分页数组,直接用长度 */
const deviceCount = computed(() => devices.value.length);
/** 金额展示:后端以字符串返回(如 "0.00"),统一保留两位小数;无值时不展示 */
const formatMoney = (value?: string | number | null) => {
if (value == null || value === '') return '';
const amount = Number(value);
return Number.isNaN(amount) ? `${value}` : `${amount.toFixed(2)}元`;
};
/** 设备类型文案:无值时不展示(留空,不用占位符) */
const deviceTypeText = (deviceType?: string | null) => {
if (deviceType == null || deviceType === '') return '';
return getDeviceTypeLabel(deviceTypeDict.value, String(deviceType));
};
/** 开关状态文案:无值时不展示 */
const statusText = (switchStatus?: string | null) => {
if (switchStatus == null || switchStatus === '') return '';
return getSwitchStatusLabel(switchStatus);
};
const goBack = () => {
router.back();
};
/** 查询商户详情 + 该商户名下的设备 */
const getDetail = async () => {
const id = merchantId.value;
if (!id) {
modal.msgError('缺少商户ID,请从商户列表进入');
loading.value = false;
return;
}
await withLoading(async () => {
const [merchantRes, deviceRes] = await Promise.all([getMerchant(id), listMerchantDevices(id)]);
merchant.value = merchantRes.data ?? {};
devices.value = deviceRes.data ?? [];
});
};
onMounted(() => {
getDetail();
});
</script>
<style lang="scss" scoped>
.detail-header {
display: flex;
align-items: center;
gap: 4px;
padding: 2px 4px;
}
.back-button {
color: var(--el-text-color-primary);
:deep(.el-icon) {
font-weight: 700;
}
}
.detail-title {
margin: 0;
font-size: 18px;
font-weight: 700;
color: var(--el-text-color-primary);
}
.summary-card {
:deep(.el-card__body) {
padding: 22px 26px;
}
}
.summary-head {
display: flex;
align-items: center;
gap: 14px;
}
.merchant-avatar {
border-radius: 10px;
background: #e8f0ff;
color: #356dff;
font-size: 20px;
font-weight: 600;
}
.merchant-name {
font-size: 18px;
font-weight: 700;
color: var(--el-text-color-primary);
}
.summary-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
row-gap: 14px;
margin-top: 20px;
}
.summary-item {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
font-size: 14px;
}
.summary-label {
flex: 0 0 auto;
color: var(--el-text-color-regular);
&::after {
content: ':';
}
}
.summary-value {
color: var(--el-text-color-primary);
word-break: break-all;
}
.device-card {
:deep(.el-card__body) {
padding: 22px 26px;
}
}
.section-title {
margin: 0;
font-size: 16px;
font-weight: 700;
color: #356dff;
}
.section-sub {
margin: 14px 0 18px;
font-size: 14px;
color: var(--el-text-color-regular);
}
.detail-footer {
display: flex;
justify-content: center;
padding: 4px 0 8px;
}
.data-table {
.amount-text {
color: #356dff;
font-variant-numeric: tabular-nums;
}
.switch-status {
font-size: 13px;
font-weight: 500;
}
.switch-status--success {
color: var(--el-color-success);
}
.switch-status--danger {
color: var(--el-color-danger);
}
.switch-status--warning {
color: var(--el-color-warning);
}
.switch-status--info {
color: var(--el-text-color-secondary);
}
}
</style>

View File

@@ -0,0 +1,12 @@
<template>
<IncomeStatistics />
</template>
<script setup lang="ts">
/**
* 后台菜单的组件路径是 income/income-stat,而页面实现按项目约定放在
* biz/income/statistics.vue,这里做一层薄入口把两者对上。
* 若后台菜单改成 biz/income/statistics,可以直接删掉本文件。
*/
import IncomeStatistics from '@/views/biz/income/statistics.vue';
</script>

View File

@@ -0,0 +1,12 @@
<template>
<IncomeStatistics />
</template>
<script setup lang="ts">
/**
* 后台菜单组件路径若为 income/statistics(与路由 /income/statistics 对应),
* 会命中本文件;页面实现按项目约定放在 biz/income/statistics.vue。
* 后台菜单改指向 biz/income/statistics 后可直接删掉本文件。
*/
import IncomeStatistics from '@/views/biz/income/statistics.vue';
</script>

View File

@@ -53,14 +53,14 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item v-if="captchaEnabled" prop="code" label="验证码" class="captcha-row"> <!-- <el-form-item v-if="captchaEnabled" prop="code" label="验证码" class="captcha-row">
<el-input v-model="loginForm.code" size="large" autocomplete="off" @keyup.enter="handleLogin"> <el-input v-model="loginForm.code" size="large" autocomplete="off" @keyup.enter="handleLogin">
<template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template> <template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template>
</el-input> </el-input>
<div class="login-code"> <div class="login-code">
<img :src="codeUrl" class="login-code-img" alt="验证码" @click="getCode" /> <img :src="codeUrl" class="login-code-img" alt="验证码" @click="getCode" />
</div> </div>
</el-form-item> </el-form-item> -->
<div class="form-meta"> <div class="form-meta">
<el-checkbox v-model="loginForm.rememberMe">记住账号</el-checkbox> <el-checkbox v-model="loginForm.rememberMe">记住账号</el-checkbox>

View File

@@ -0,0 +1,171 @@
<template>
<div class="p-2 page-shell system-params-page">
<el-card shadow="hover" class="table-panel">
<template #header>
<div class="toolbar-shell">
<div class="table-heading">
<h3>系统参数</h3>
</div>
</div>
</template>
<el-table v-loading="loading" border class="data-table" :data="platformConfigList">
<el-table-column label="设置项" align="center" prop="configKey" min-width="180" show-overflow-tooltip />
<el-table-column label="当前值" align="center" prop="configValue" min-width="180" show-overflow-tooltip />
<el-table-column label="说明" align="center" prop="remark" min-width="220" show-overflow-tooltip />
<el-table-column label="操作" align="center" width="120">
<template #default="scope">
<div class="table-actions">
<el-button
link
type="primary"
@click="handleUpdate(scope.row)"
v-hasPermi="['rechargeManage:platformConfig:edit']"
>
编辑
</el-button>
</div>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 编辑系统参数对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="platformConfigFormRef" :model="form" :rules="rules" label-width="90px">
<el-form-item label="当前值" prop="configValue">
<el-input v-model="form.configValue" placeholder="请输入当前值" clearable />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="SystemParams" lang="ts">
import { getPlatformConfig, listPlatformConfig, updatePlatformConfig } from '@/api/system/platformConfig/index';
import { PlatformConfigForm, PlatformConfigQuery, PlatformConfigVO } from '@/api/system/platformConfig/types';
import { useLoading } from '@/hooks/async/useLoading';
import { useFormDialog } from '@/hooks/dialog/useFormDialog';
import modal from '@/plugins/modal';
const platformConfigList = ref<PlatformConfigVO[]>([]);
const buttonLoading = ref(false);
const { loading, withLoading } = useLoading(true);
const total = ref(0);
const platformConfigFormRef = ref<ElFormInstance>();
const initFormData: PlatformConfigForm = {
configId: undefined,
configKey: undefined,
configValue: undefined,
valueType: undefined,
remark: undefined,
status: undefined,
createDept: undefined,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined
};
const data = reactive<PageData<PlatformConfigForm, PlatformConfigQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10
},
rules: {
configValue: [{ required: true, message: '当前值不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
const { dialog, resetForm: reset, showDialog, closeDialog } = useFormDialog({
form,
formRef: platformConfigFormRef,
initialFormData: initFormData
});
/** 查询水电充值平台配置列表 */
const getList = async () => {
await withLoading(async () => {
const res = await listPlatformConfig(queryParams.value);
platformConfigList.value = res.data?.rows;
total.value = res.data?.total;
});
};
/** 取消按钮 */
const cancel = () => {
reset();
closeDialog();
};
/** 编辑按钮操作 */
const handleUpdate = async (row?: Partial<PlatformConfigVO>) => {
reset();
const configId = row?.configId;
if (configId == null) return;
const res = await getPlatformConfig(configId);
Object.assign(form.value, res.data);
// 弹窗标题显示当前设置项名称,例如「最低提现金额」
showDialog(form.value.configKey || '编辑系统参数');
};
/** 提交按钮 */
const submitForm = () => {
platformConfigFormRef.value?.validate(async (valid: boolean) => {
if (!valid) return;
buttonLoading.value = true;
try {
await updatePlatformConfig(form.value);
modal.msgSuccess('修改成功');
closeDialog();
await getList();
} finally {
buttonLoading.value = false;
}
});
};
onMounted(() => {
getList();
});
</script>
<style scoped lang="scss">
/* 全局 _search-panel.scss 给 .data-table 里的 link 按钮加了 28x28 圆角底色,操作列只保留文字 */
.data-table {
:deep(.table-actions) {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: 4px 10px;
}
: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;
}
}
</style>

View File

@@ -1,27 +1,20 @@
<template> <template>
<div class="p-2 app-container service-phone-index-page"> <div class="p-2 page-shell system-servicePhone-page">
<div class="search-wrap"> <div class="search-wrap">
<el-card shadow="hover" class="search-panel" :class="{ 'is-collapsed': !showSearch }"> <el-card shadow="hover" class="search-panel" :class="{ 'is-collapsed': !showSearch }">
<template #header> <template #header>
<div class="panel-heading search-panel-toggle" @click.stop="showSearch = !showSearch"> <div class="panel-heading search-panel-toggle" @click.stop="showSearch = !showSearch">
<div> <div><h3>筛选条件</h3></div>
<span class="panel-kicker">Search Filters</span>
<h3>筛选条件</h3>
</div>
</div> </div>
</template> </template>
<el-form ref="queryFormRef" :model="queryParams" :inline="true" class="query-form"> <el-form ref="queryFormRef" :model="queryParams" :inline="true" class="query-form">
<el-form-item label="电话" prop="phone"> <el-form-item label="电话号码" prop="phoneNumber">
<el-input v-model="queryParams.phone" placeholder="请输入电话" clearable @keyup.enter="handleQuery" /> <el-input v-model="queryParams.phoneNumber" placeholder="请输入电话号码" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="类型" prop="phoneType">
<el-select v-model="queryParams.phoneType" placeholder="请选择类型" clearable>
<el-option v-for="item in phoneTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable > <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-option label="启用" value="0" />
<el-option label="停用" value="1" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@@ -36,129 +29,165 @@
<template #header> <template #header>
<div class="toolbar-shell"> <div class="toolbar-shell">
<div class="table-heading"> <div class="table-heading">
<span class="panel-kicker">Service Phone Dataset</span> <h3>电话列表</h3>
<h3>电话管理</h3>
<p>共 {{ total }} 条记录,用于维护住户端展示的客服/报修电话。</p>
</div> </div>
<div class="toolbar-actions"> <div class="toolbar-actions">
<!-- 电话模块的接口与菜单尚未建立,权限标识待后端约定后再补 v-hasPermi --> <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:servicePhone:add']">新增</el-button>
<el-button type="primary" plain icon="Plus" @click="notImplemented">新增</el-button> <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:servicePhone:edit']">修改</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="handleDelete()" v-hasPermi="['system:servicePhone:remove']">删除</el-button>
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="notImplemented">删除</el-button> <!-- <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:servicePhone:export']">导出</el-button> -->
<right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar> <right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar>
</div> </div>
</div> </div>
</template> </template>
<el-table v-loading="loading" :data="phoneList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" border class="data-table" :data="servicePhoneList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="电话类型" prop="phoneType" align="center" > <el-table-column label="电话类型" align="center" prop="phoneType" />
<el-table-column label="电话号码" align="center" prop="phoneNumber" />
<el-table-column label="状态" align="center" prop="status" width="120">
<template #default="scope"> <template #default="scope">
<dict-tag :options="phoneTypeOptions" :value="scope.row.phoneType" /> <span class="status-text" :class="statusClass(scope.row.status)">{{ formatStatus(scope.row.status) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="电话号码" prop="phone" align="center" /> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="状态" prop="status" align="center" >
<template #default="scope"> <template #default="scope">
<dict-tag :options="statusOptions" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" 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-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="notImplemented"></el-button> <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:servicePhone:edit']"></el-button>
</el-tooltip>
<!-- 启用显示停用,停用显示启用 -->
<el-tooltip v-if="String(scope.row.status) === '0'" content="停用" placement="top">
<el-button link type="warning" icon="CircleClose" @click="handleToggleStatus(scope.row)" v-hasPermi="['system:servicePhone:edit']"></el-button>
</el-tooltip>
<el-tooltip v-else content="启用" placement="top">
<el-button link type="success" icon="CircleCheck" @click="handleToggleStatus(scope.row)" v-hasPermi="['system:servicePhone:edit']"></el-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="删除" placement="top"> <el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="notImplemented"></el-button> <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:servicePhone:remove']"></el-button>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
v-show="total > 0"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
:total="total"
@pagination="getList"
/>
</el-card> </el-card>
<!-- 添加或修改客服及服务电话对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="servicePhoneFormRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="电话名称" prop="phoneType">
<el-input v-model="form.phoneType" placeholder="请输入电话名称" clearable />
</el-form-item>
<el-form-item label="电话号码" prop="phoneNumber">
<el-input v-model="form.phoneNumber" placeholder="请输入电话号码" clearable />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</template>
</el-dialog>
</div> </div>
</template> </template>
<script setup name="ServicePhone" lang="ts"> <script setup name="ServicePhone" lang="ts">
import {
addServicePhone,
changeServicePhoneStatus,
delServicePhone,
getServicePhone,
listServicePhone,
updateServicePhone
} from '@/api/system/servicePhone';
import { ServicePhoneForm, ServicePhoneQuery, ServicePhoneVO } from '@/api/system/servicePhone/types';
import { useLoading } from '@/hooks/async/useLoading'; import { useLoading } from '@/hooks/async/useLoading';
import { useFormDialog } from '@/hooks/dialog/useFormDialog';
import { useSearchReset } from '@/hooks/form/useSearchReset'; import { useSearchReset } from '@/hooks/form/useSearchReset';
import { useSearchToggle } from '@/hooks/form/useSearchToggle'; import { useSearchToggle } from '@/hooks/form/useSearchToggle';
import { useTableSelection } from '@/hooks/table/useTableSelection'; import { useTableSelection } from '@/hooks/table/useTableSelection';
import modal from '@/plugins/modal'; import modal from '@/plugins/modal';
import { download as requestDownload } from '@/utils/request';
/** 客服/报修电话(住户端展示) */
interface ServicePhoneVO {
/** 电话ID */
phoneId?: string;
/** 名称 */
name?: string;
/** 电话 */
phone?: string;
/** 类型(1客服 2报修 3投诉) */
phoneType?: string;
/** 服务时间 */
serviceTime?: string;
/** 排序 */
sortNo?: number;
/** 状态(0正常 1停用) */
status?: string;
/** 创建时间 */
createTime?: string;
/** 备注 */
remark?: string;
}
interface ServicePhoneQuery extends PageQuery {
name?: string;
phone?: string;
phoneType?: string;
status?: string;
}
// 电话字典后端尚未建立,先用本地兜底选项 const servicePhoneList = ref<ServicePhoneVO[]>([]);
const phoneTypeOptions: DictDataOption[] = [ const buttonLoading = ref(false);
{ label: '客服', value: '1', elTagType: 'primary' },
{ label: '报修', value: '2', elTagType: 'warning' },
{ label: '投诉', value: '3', elTagType: 'danger' }
];
const statusOptions: DictDataOption[] = [
{ label: '正常', value: '0', elTagType: 'success' },
{ label: '停用', value: '1', elTagType: 'danger' }
];
const phoneList = ref<ServicePhoneVO[]>([]);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const { showSearch } = useSearchToggle();
const { loading, withLoading } = useLoading(true); const { loading, withLoading } = useLoading(true);
const { single, multiple, handleSelectionChange } = useTableSelection<ServicePhoneVO>(item => item.phoneId); const { showSearch } = useSearchToggle();
const total = ref(0);
const queryParams = ref<ServicePhoneQuery>({ const queryFormRef = ref<ElFormInstance>();
const servicePhoneFormRef = ref<ElFormInstance>();
const initFormData: ServicePhoneForm = {
phoneId: undefined,
phoneType: undefined,
phoneNumber: undefined,
description: undefined,
sortNo: undefined,
status: undefined,
createDept: undefined,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined,
}
const data = reactive<PageData<ServicePhoneForm, ServicePhoneQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
name: '', phoneNumber: undefined,
phone: '', status: undefined
phoneType: '', },
status: '' rules: {
phoneType: [
{ required: true, message: '电话名称不能为空', trigger: 'blur' }
],
phoneNumber: [
{ required: true, message: '电话号码不能为空', trigger: 'blur' }
]
}
}); });
/** 查询电话列表 */ const { queryParams, form, rules } = toRefs(data);
const getList = async () => { const { ids, single, multiple, handleSelectionChange } = useTableSelection<ServicePhoneVO>(item => item.phoneId);
// TODO: 电话接口就绪后替换为真实请求,例如 listServicePhone(queryParams.value) 取 res.data.rows / res.data.total const { dialog, resetForm: reset, openDialog, showDialog, closeDialog } = useFormDialog({
await withLoading(async () => { form,
phoneList.value = []; formRef: servicePhoneFormRef,
total.value = 0; initialFormData: initFormData
}); });
/** 状态文本:0启用 1停用 */
const formatStatus = (status?: string | number) => {
const value = status === undefined || status === null ? '' : String(status);
if (value === '0') return '启用';
if (value === '1') return '停用';
return '';
};
/** 状态颜色:0启用绿色 1停用红色 */
const statusClass = (status?: string | number) => {
const value = status === undefined || status === null ? '' : String(status);
if (value === '0') return 'status-text--success';
if (value === '1') return 'status-text--danger';
return '';
};
/** 查询客服及服务电话列表 */
const getList = async () => {
await withLoading(async () => {
const res = await listServicePhone(queryParams.value);
servicePhoneList.value = res.data?.rows;
total.value = res.data?.total;
});
};
/** 取消按钮 */
const cancel = () => {
reset();
closeDialog();
}; };
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@@ -171,21 +200,99 @@ const { resetQuery } = useSearchReset({
queryFormRef, queryFormRef,
queryParams, queryParams,
pageNumKey: 'pageNum', pageNumKey: 'pageNum',
pageSizeKey: 'pageSize',
initialPageSize: 10,
afterReset: () => { afterReset: () => {
handleQuery(); handleQuery();
} }
}); });
/** 尚未接入的写操作统一提示,避免静默失败 */ /** 新增按钮操作 */
const notImplemented = () => modal.msgWarning('电话接口待接入,暂不支持该操作'); const handleAdd = () => {
openDialog('添加电话');
};
/** 修改按钮操作 */
const handleUpdate = async (row?: Partial<ServicePhoneVO>) => {
reset();
const phoneId = row?.phoneId || ids.value[0];
const res = await getServicePhone(phoneId);
Object.assign(form.value, res.data);
showDialog('修改电话');
};
/** 启用 / 停用:PUT /system/servicePhone/{phoneId}/{status},启用(0) → 停用(1),停用(1) → 启用(0) */
const handleToggleStatus = async (row: Partial<ServicePhoneVO>) => {
if (row.phoneId == null) return;
const nextStatus = String(row.status) === '0' ? '1' : '0';
const actionText = nextStatus === '0' ? '启用' : '停用';
try {
await modal.confirm(`是否确认${actionText}电话号码为"${row.phoneNumber || row.phoneId}"的数据项?`);
} catch {
// 用户取消确认
return;
}
await changeServicePhoneStatus(row.phoneId, nextStatus);
modal.msgSuccess(`${actionText}成功`);
await getList();
};
/** 提交按钮 */
const submitForm = () => {
servicePhoneFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.phoneId) {
await updateServicePhone(form.value).finally(() => (buttonLoading.value = false));
} else {
await addServicePhone(form.value).finally(() => (buttonLoading.value = false));
}
modal.msgSuccess('操作成功');
closeDialog();
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: Partial<ServicePhoneVO>) => {
const phoneIds = row?.phoneId || ids.value;
await modal.confirm('是否确认删除客服及服务电话号码为"' + row?.phoneNumber + '"的数据项?');
await delServicePhone(phoneIds);
modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
requestDownload(
'system/servicePhone/export',
{
...queryParams.value
},
`servicePhone_${new Date().getTime()}.xlsx`
);
};
onMounted(() => { onMounted(() => {
getList(); getList();
}); });
</script> </script>
<style lang="scss" scoped> <style scoped lang="scss">
@use '@/assets/styles/components/page-shell' as pageShell; .status-text {
font-size: 13px;
font-weight: 500;
@include pageShell.table-crud-page; &--success {
color: var(--el-color-success);
}
&--danger {
color: var(--el-color-danger);
}
}
</style> </style>