Merge branch 'master' of http://47.109.37.87:3000/by2025/admin-vben5
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
FLL
2025-07-11 14:55:47 +08:00
93 changed files with 7405 additions and 1231 deletions

View File

@@ -41,6 +41,7 @@ const isUpdate = ref(false);
const isReadonly = ref(false);
const isAudit = ref(false);
const isRefund = ref(false);
const rowData = ref<any>({});
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : isReadonly.value ? '详情' : $t('pages.common.add');
});
@@ -123,16 +124,18 @@ const [BasicModal, modalApi] = useVbenModal({
// 查询服务地址树形结构
setupCommunitySelect()
modalApi.modalLoading(true);
const { id, readonly,audit,refund } = modalApi.getData() as {
const { id, readonly,audit,refund,row } = modalApi.getData() as {
id?: string;
readonly?: boolean;
audit?: boolean;
refund?: boolean;
row?: any;
};
editCleanOrderId.value = id || '';
isReadonly.value = !!readonly;
isAudit.value = !!audit;
isRefund.value = !!refund;
rowData.value = row;
//判断是否是编辑状态需要先判断是否是只读状态
if(isReadonly.value){
isUpdate.value = false;
@@ -400,6 +403,10 @@ async function handleAudit(params: any) {
return;
}
const data = cloneDeep(await formApi.getValues());
if(rowData.value){
data.state = rowData.value.state;
data.isUnbooking = rowData.value?.isUnbooking;
}
// 单位数据缓存
if (unitListData.length === 0) {
const res = await resident_unitList();
@@ -426,7 +433,6 @@ async function handleAudit(params: any) {
}else{
data.state = 2;
}
console.log(data,'data');
// 0未审核 1审核通过 2审核不通过
await clean_orderUpdate({...data,id:editCleanOrderId.value})
resetInitialized();

View File

@@ -83,24 +83,24 @@ export const columns: VxeGridProps['columns'] = [
field: 'payState',
width: '120',
slots: {
default: ({ row }) => (row.state === 1 ? '已支付' : '待支付'),
default: ({ row }) => (row.payState === 1 ? '已支付' : '待支付'),
},
},
{
title: '服务开始时间',
field: 'starTime',
width: 'auto',
width: '200',
},
{
title: '服务结束时间',
field: 'endTime',
width: 'auto',
},
{
title: '申请单位',
field: 'unit',
width: '150',
width: '200',
},
// {
// title: '申请单位',
// field: 'unit',
// width: '150',
// },
{
title: '申请人',
field: 'persion',
@@ -109,7 +109,7 @@ export const columns: VxeGridProps['columns'] = [
{
title: '联系电话',
field: 'phone',
width: 'auto',
width: '250',
},
{
title: '订单状态',
@@ -126,6 +126,7 @@ export const columns: VxeGridProps['columns'] = [
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width:'200'
},
];

View File

@@ -136,7 +136,7 @@ function handleAudit(row:any) {
// 审核逻辑
// TODO: 实现审核功能
console.log('审核', row);
modalApi.setData({ id: row.id, readonly: true,audit:true });
modalApi.setData({ id: row.id, readonly: true,audit:true,row:row });
modalApi.open();
}
@@ -144,7 +144,7 @@ function handleRefund(row:any) {
// 退定逻辑
// TODO: 实现退定功能
console.log('退定', row);
modalApi.setData({ id: row.id, readonly: true,refund:true });
modalApi.setData({ id: row.id, readonly: true,refund:true,row:row });
modalApi.open();
}
</script>

View File

@@ -103,14 +103,14 @@ const detailSchema = [
options: getDictOptions('pro_product_classification'),
},
},
{
label: '图片',
fieldName: 'imgPath',
component: 'InputNumber',
componentProps: {
disabled: true,
},
},
// {
// label: '图片',
// fieldName: 'imgPath',
// component: 'InputNumber',
// componentProps: {
// disabled: true,
// },
// },
{
label: '规格',
fieldName: 'specification',

View File

@@ -12,6 +12,7 @@ import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
import productDetailModal from './rentalPlan-detial-modal.vue';
import { getDictOptions } from '#/utils/dict';
import { Item } from 'ant-design-vue/es/menu';
const emit = defineEmits<{ reload: [] }>();
@@ -69,7 +70,10 @@ const [BasicModal, modalApi] = useVbenModal({
if ((isUpdate.value || isReadonly.value) && id) {
const record = await rentalPlanInfo(id);
// 后端返回绿植产品包列表结构处理
detailTable.value = record.productList.map((item:any) => item.product);
// detailTable.value = record.productList.map((item:any) => {...item.product,item.productNum,});
detailTable.value = record.productList.map((item: any) => ({ ...item.product, productNum: item.productNum,productId: item.productId }));
// console.log(detailTable.value);
await formApi.setValues(record);
}
await markInitialized();
@@ -116,11 +120,11 @@ const detailColumns = [
{ title: '产品名称', dataIndex: 'plantName', key: 'plantName' },
{ title: '产品分类', dataIndex: 'plantType', key: 'plantType' },
{ title: '产品数量', dataIndex: 'productNum', key: 'productNum' },
{
title: '图片',
dataIndex: 'imgPath',
key: 'imgPath',
},
// {
// title: '图片',
// dataIndex: 'imgPath',
// key: 'imgPath',
// },
{
title: '规格',
dataIndex: 'specification',

View File

@@ -87,10 +87,14 @@ onMounted(async () => {
data: xAxisData.value,
boundaryGap: false,
},
yAxis: { type: 'value' },
yAxis: { type: 'value',
axisLabel: {
formatter: (value) => `${value * 100}%`
},
},
series: [
{
name: '订单',
name: '订单趋势',
type: 'line',
data: seriesData.value ||[],
smooth: true,
@@ -123,17 +127,22 @@ onMounted(async () => {
],
});
renderCustomerTypesBar({
title: { text: '客户类型分' },
title: { text: '客户类型分' },
tooltip: { trigger: 'axis' },
xAxis: {
type: 'category',
data: countByCusTypeData.type || [],
data: ['企业客户','个人客户','政府机构','商业地产','其他'],
boundaryGap: true,
},
yAxis: { type: 'value' },
yAxis: { type: 'value',
axisLabel: {
// formatter: (value: number) => `${parseInt(value.toString())}`
},
// interval: 0,
},
series: [
{
name: '订单数',
name: '客户数',
type: 'bar',
data: countByCusTypeData.counts || [],
},
@@ -141,16 +150,28 @@ onMounted(async () => {
});
renderCustomerRenewalLine({
title: { text: '客户续租率趋势' },
tooltip: { trigger: 'axis' },
tooltip: { trigger: 'axis',
formatter: function(params:any) {
let result = params[0].axisValue + '<br/>';
params.forEach((item:any) => {
result += item.marker + item.seriesName + '' + item.data + '%<br/>';
});
return result;
}
},
xAxis: {
type: 'category',
data: countRenewRateData.month || [],
boundaryGap: false,
},
yAxis: { type: 'value' },
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value}%',
}, },
series: [
{
name: '订单数',
name: '续租率',
type: 'line',
data: countRenewRateData.rate || [],
smooth: true,
@@ -162,6 +183,19 @@ onMounted(async () => {
tooltip: {
trigger: 'axis',
axisPointer: { type: 'shadow' },
formatter: function(params:any) {
// params 是一个数组,包含每个系列的当前项
let result = params[0].axisValue + '<br/>';
params.forEach((item:any) => {
if (item.seriesName === '完成率') {
// 假设原始数据是 80显示为 80%
result += item.marker + item.seriesName + '' + item.data + '%<br/>';
} else {
result += item.marker + item.seriesName + '' + item.data + '<br/>';
}
});
return result;
}
},
legend: {
data: ['计划任务数', '已完成数', '完成率'],
@@ -169,7 +203,7 @@ onMounted(async () => {
xAxis: [
{
type: 'category',
data: countAchievedData.type || [],
data: ['修剪整形','肥水管理','中耕除草','病虫害防治','越冬防寒'],
},
],
yAxis: [
@@ -195,7 +229,7 @@ onMounted(async () => {
{
name: '计划任务数',
type: 'bar',
data: countAchievedData.toral || [],
data: countAchievedData.total || [],
},
{
name: '已完成数',
@@ -220,7 +254,7 @@ onMounted(async () => {
orient: 'horizontal',
left: 'center',
bottom: 10,
data: ['一星', '星', '三星', '四星', '五星'],
data: ['一星', '星', '三星', '四星', '五星'],
},
series: [
{
@@ -283,7 +317,7 @@ function formatNumber(num: number | string) {
<div class="title">
<div class="title-text">绿植租赁业务统计报表</div>
<div class="title-operate">
<div class="export">
<div class="export" style="display: none;">
<Button size="large" style="color: #fff; background-color: #22c55e">
导出数据
</Button>

View File

@@ -0,0 +1,220 @@
import type {FormSchemaGetter} from '#/adapter/form';
import type {VxeGridProps} from '#/adapter/vxe-table';
import {getDictOptions} from "#/utils/dict";
import {renderDict} from "#/utils/render";
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'planName',
label: '计划名称',
},
{
component: 'Select',
componentProps: {
options: getDictOptions('wy_xjzq'),
},
fieldName: 'inspectionPlanPeriod',
label: '巡检周期',
},
{
component: 'Select',
componentProps: {
options: getDictOptions('wy_xjqdfs'),
},
fieldName: 'signType',
label: '签到方式',
},
];
export const columns: VxeGridProps['columns'] = [
{type: 'checkbox', width: 60},
{
title: '主键id',
field: 'id',
},
{
title: '巡检计划名称',
field: 'planName',
},
{
title: '巡检路线',
field: 'inspectionRouteId',
},
{
title: '巡检周期',
field: 'inspectionPlanPeriod',
slots: {
default: ({ row }) => {
return renderDict(row.inspectionPlanPeriod, 'wy_xjzq');
},
},
},
{
title: '任务提前分组',
field: 'beforeTime',
},
{
title: '开始日期',
field: 'startDate',
},
{
title: '结束日期',
field: 'endDate',
},
{
title: '开始时间',
field: 'startTime',
},
{
title: '结束时间',
field: 'endTime',
},
{
title: '签到方式',
field: 'signType',
slots: {
default: ({ row }) => {
return renderDict(row.signType, 'wy_xjqdfs');
},
},
},
{
title: '是否允许补检',
field: 'canReexamine',
slots: {
default: ({ row }) => {
return renderDict(row.canReexamine, 'wy_sf');
},
},
},
{
title: '选择员工',
field: 'userId',
},
{
title: '备注',
field: 'remark',
},
{
field: 'action',
fixed: 'right',
slots: {default: 'action'},
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '巡检计划名称',
fieldName: 'planName',
component: 'Input',
rules: 'required',
},
{
label: '巡检路线',
fieldName: 'inspectionRouteId',
component: 'Input',
rules: 'required',
},
{
label: '巡检周期',
fieldName: 'inspectionPlanPeriod',
component: 'Input',
rules: 'required',
componentProps: {
options: getDictOptions('wy_xjzq'),
},
},
{
label: '任务提前分组',
fieldName: 'beforeTime',
component: 'Input',
rules: 'required',
},
{
label: '开始日期',
fieldName: 'startDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
},
{
label: '结束日期',
fieldName: 'endDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
},
{
label: '开始时间',
fieldName: 'startTime',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
},
{
label: '结束时间',
fieldName: 'endTime',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
},
{
label: '签到方式',
fieldName: 'signType',
component: 'Select',
componentProps: {
options: getDictOptions('wy_xjqdfs'),
},
rules: 'selectRequired',
},
{
label: '允许补检',
fieldName: 'canReexamine',
component: 'Select',
componentProps: {
options: getDictOptions('wy_sf'),
},
rules: 'selectRequired',
},
{
label: '选择员工',
fieldName: 'userId',
component: 'Input',
rules: 'required',
},
{
label: '备注',
fieldName: 'remark',
component: 'Input',
},
];

View File

@@ -0,0 +1,182 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import { ref } from 'vue';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import {
inspectionPlanExport,
inspectionPlanList,
inspectionPlanRemove,
} from '#/api/property/inspectionManagement/inspectionPlan';
import type { InspectionPlanForm } from '#/api/property/inspectionManagement/inspectionPlan/model';
import { commonDownloadExcel } from '#/utils/file/download';
import inspectionPlanModal from './inspectionPlan-modal.vue';
import { columns, querySchema } from './data';
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
// 处理区间选择器RangePicker时间格式 将一个字段映射为两个字段 搜索/导出会用到
// 不需要直接删除
// fieldMappingTime: [
// [
// 'createTime',
// ['params[beginTime]', 'params[endTime]'],
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
// ],
// ],
};
const gridOptions: VxeGridProps = {
checkboxConfig: {
// 高亮
highlight: true,
// 翻页时保留选中状态
reserve: true,
// 点击行选中
// trigger: 'row',
},
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await inspectionPlanList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
// 表格全局唯一表示 保存列配置需要用到
id: 'property-inspectionPlan-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [InspectionPlanModal, modalApi] = useVbenModal({
connectedComponent: inspectionPlanModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<InspectionPlanForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<InspectionPlanForm>) {
await inspectionPlanRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<InspectionPlanForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await inspectionPlanRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(inspectionPlanExport, '巡检计划数据', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
});
}
</script>
<template>
<Page :auto-content-height="true">
<BasicTable table-title="巡检计划列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['property:inspectionPlan:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:inspectionPlan:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:inspectionPlan:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['property:inspectionPlan:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['property:inspectionPlan:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<InspectionPlanModal @reload="tableApi.query()" />
</Page>
</template>

View File

@@ -0,0 +1,101 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { inspectionPlanAdd, inspectionPlanInfo, inspectionPlanUpdate } from '#/api/property/inspectionManagement/inspectionPlan';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
});
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
// 默认占满两列
formItemClass: 'col-span-2',
// 默认label宽度 px
labelWidth: 80,
// 通用配置项 会影响到所有表单项
componentProps: {
class: 'w-full',
}
},
schema: modalSchema(),
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{
initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi),
},
);
const [BasicModal, modalApi] = useVbenModal({
// 在这里更改宽度
class: 'w-[550px]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await inspectionPlanInfo(id);
await formApi.setValues(record);
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? inspectionPlanUpdate(data) : inspectionPlanAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm />
</BasicModal>
</template>

View File

@@ -0,0 +1,59 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'routeName',
label: '路线名称',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '主键id',
field: 'id',
},
{
title: '路线名称',
field: 'routeName',
},
{
title: '备注',
field: 'remark',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '路线名称',
fieldName: 'routeName',
component: 'Input',
rules: 'required',
},
{
label: '备注',
fieldName: 'remark',
component: 'Input',
},
];

View File

@@ -0,0 +1,182 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import { ref } from 'vue';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import {
inspectionRouteExport,
inspectionRouteList,
inspectionRouteRemove,
} from '#/api/property/inspectionManagement/inspectionRoute';
import type { InspectionRouteForm } from '#/api/property/inspectionManagement/inspectionRoute/model';
import { commonDownloadExcel } from '#/utils/file/download';
import inspectionRouteModal from './inspectionRoute-modal.vue';
import { columns, querySchema } from './data';
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
// 处理区间选择器RangePicker时间格式 将一个字段映射为两个字段 搜索/导出会用到
// 不需要直接删除
// fieldMappingTime: [
// [
// 'createTime',
// ['params[beginTime]', 'params[endTime]'],
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
// ],
// ],
};
const gridOptions: VxeGridProps = {
checkboxConfig: {
// 高亮
highlight: true,
// 翻页时保留选中状态
reserve: true,
// 点击行选中
// trigger: 'row',
},
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await inspectionRouteList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
// 表格全局唯一表示 保存列配置需要用到
id: 'property-inspectionRoute-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [InspectionRouteModal, modalApi] = useVbenModal({
connectedComponent: inspectionRouteModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<InspectionRouteForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<InspectionRouteForm>) {
await inspectionRouteRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<InspectionRouteForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await inspectionRouteRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(inspectionRouteExport, '巡检路线数据', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
});
}
</script>
<template>
<Page :auto-content-height="true">
<BasicTable table-title="巡检路线列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['property:inspectionRoute:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:inspectionRoute:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:inspectionRoute:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['property:inspectionRoute:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['property:inspectionRoute:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<InspectionRouteModal @reload="tableApi.query()" />
</Page>
</template>

View File

@@ -0,0 +1,101 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { inspectionRouteAdd, inspectionRouteInfo, inspectionRouteUpdate } from '#/api/property/inspectionManagement/inspectionRoute';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
});
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
// 默认占满两列
formItemClass: 'col-span-2',
// 默认label宽度 px
labelWidth: 80,
// 通用配置项 会影响到所有表单项
componentProps: {
class: 'w-full',
}
},
schema: modalSchema(),
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{
initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi),
},
);
const [BasicModal, modalApi] = useVbenModal({
// 在这里更改宽度
class: 'w-[550px]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await inspectionRouteInfo(id);
await formApi.setValues(record);
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? inspectionRouteUpdate(data) : inspectionRouteAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm />
</BasicModal>
</template>

View File

@@ -60,7 +60,8 @@ function generateWeekDates(): void {
return startOfWeek.add(i, 'day').format('YYYY-MM-DD');
});
weekDates.value = dates;
selectedDate.value = dates[0] ?? '';
// 默认选中今天
selectedDate.value = today.format('YYYY-MM-DD');
}
// 获取预约数据
@@ -137,7 +138,6 @@ async function fetchBookings(): Promise<void> {
});
bookingTable.value = table;
}
console.log(bookingTable.value,'bookingTable.value');
} catch (error) {
console.error('获取预约数据失败:', error);
@@ -150,7 +150,8 @@ async function fetchBookings(): Promise<void> {
function handleViewModeChange(e: RadioChangeEvent): void {
viewMode.value = e.target.value;
if (viewMode.value === 'date') {
selectedDate.value = weekDates.value[0] ?? '';
// 默认选中今天
selectedDate.value = dayjs().format('YYYY-MM-DD');
} else {
selectedRoom.value = roomList.value[0]?.id ?? '';
}