1、单元
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7m16s

2、房间
This commit is contained in:
dev_ljl 2025-06-26 18:04:51 +08:00
parent e06f8861cc
commit 6f2e0be983
15 changed files with 2079 additions and 4 deletions

View File

@ -0,0 +1,61 @@
import type { RentalOrderVO, RentalOrderForm, RentalOrderQuery } from './model';
import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
* 绿-
* @param params
* @returns 绿-
*/
export function rentalOrderList(params?: RentalOrderQuery) {
return requestClient.get<PageResult<RentalOrderVO>>('/property/rentalOrder/list', { params });
}
/**
* 绿-
* @param params
* @returns 绿-
*/
export function rentalOrderExport(params?: RentalOrderQuery) {
return commonExport('/property/rentalOrder/export', params ?? {});
}
/**
* 绿-
* @param id id
* @returns 绿-
*/
export function rentalOrderInfo(id: ID) {
return requestClient.get<RentalOrderVO>(`/property/rentalOrder/${id}`);
}
/**
* 绿-
* @param data
* @returns void
*/
export function rentalOrderAdd(data: RentalOrderForm) {
return requestClient.postWithMsg<void>('/property/rentalOrder', data);
}
/**
* 绿-
* @param data
* @returns void
*/
export function rentalOrderUpdate(data: RentalOrderForm) {
return requestClient.putWithMsg<void>('/property/rentalOrder', data);
}
/**
* 绿-
* @param id id
* @returns void
*/
export function rentalOrderRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/property/rentalOrder/${id}`);
}

View File

@ -0,0 +1,249 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface RentalOrderVO {
/**
*
*/
id: string | number;
/**
*
*/
orderNo: string;
/**
*
*/
customerName: string;
/**
*
*/
customerType: number;
/**
*
*/
rentalPeriod: number;
/**
*
*/
startTime: string;
/**
*
*/
endTime: string;
/**
*
*/
totalAmount: number;
/**
*
*/
rentalType: number;
/**
* id
*/
planId: string | number;
/**
* 绿id
*/
productId: string | number;
/**
*
*/
productNum: number;
/**
*
*/
paymentStatus: number;
/**
*
*/
isRelet: number;
/**
*
*/
contractStatus: number;
/**
*
*/
signTime: string;
}
export interface RentalOrderForm extends BaseEntity {
/**
*
*/
id?: string | number;
/**
*
*/
orderNo?: string;
/**
*
*/
customerName?: string;
/**
*
*/
customerType?: number;
/**
*
*/
rentalPeriod?: number;
/**
*
*/
startTime?: string;
/**
*
*/
endTime?: string;
/**
*
*/
totalAmount?: number;
/**
*
*/
rentalType?: number;
/**
* id
*/
planId?: string | number;
/**
* 绿id
*/
productId?: string | number;
/**
*
*/
productNum?: number;
/**
*
*/
paymentStatus?: number;
/**
*
*/
isRelet?: number;
/**
*
*/
contractStatus?: number;
/**
*
*/
signTime?: string;
}
export interface RentalOrderQuery extends PageQuery {
/**
*
*/
orderNo?: string;
/**
*
*/
customerName?: string;
/**
*
*/
customerType?: number;
/**
*
*/
rentalPeriod?: number;
/**
*
*/
startTime?: string;
/**
*
*/
endTime?: string;
/**
*
*/
totalAmount?: number;
/**
*
*/
rentalType?: number;
/**
* id
*/
planId?: string | number;
/**
* 绿id
*/
productId?: string | number;
/**
*
*/
productNum?: number;
/**
*
*/
paymentStatus?: number;
/**
*
*/
isRelet?: number;
/**
*
*/
contractStatus?: number;
/**
*
*/
signTime?: string;
/**
*
*/
params?: any;
}

View File

@ -0,0 +1,61 @@
import type { RoomVO, RoomForm, RoomQuery } from './model';
import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
*
* @param params
* @returns
*/
export function roomList(params?: RoomQuery) {
return requestClient.get<PageResult<RoomVO>>('/property/room/list', { params });
}
/**
*
* @param params
* @returns
*/
export function roomExport(params?: RoomQuery) {
return commonExport('/property/room/export', params ?? {});
}
/**
*
* @param id id
* @returns
*/
export function roomInfo(id: ID) {
return requestClient.get<RoomVO>(`/property/room/${id}`);
}
/**
*
* @param data
* @returns void
*/
export function roomAdd(data: RoomForm) {
return requestClient.postWithMsg<void>('/property/room', data);
}
/**
*
* @param data
* @returns void
*/
export function roomUpdate(data: RoomForm) {
return requestClient.putWithMsg<void>('/property/room', data);
}
/**
*
* @param id id
* @returns void
*/
export function roomRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/property/room/${id}`);
}

View File

@ -0,0 +1,159 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface RoomVO {
/**
*
*/
id: string | number;
/**
* ID
*/
floorCode: string;
/**
*
*/
roomCode: string;
/**
* (101,202)
*/
roomNumber: string;
/**
* ('住宅','商铺','办公室','设备间','公共区域')
*/
roomType: number;
/**
* ()
*/
area: number;
/**
* (211)
*/
layout: string;
/**
* ('东','南','西','北','东南','东北','西南','西北')
*/
orientation: number;
/**
*
*/
isForSale: number;
/**
* '空置','已售','已租','自用'
*/
status: number;
}
export interface RoomForm extends BaseEntity {
/**
*
*/
id?: string | number;
/**
* ID
*/
floorCode?: string;
/**
*
*/
roomCode?: string;
/**
* (101,202)
*/
roomNumber?: string;
/**
* ('住宅','商铺','办公室','设备间','公共区域')
*/
roomType?: number;
/**
* ()
*/
area?: number;
/**
* (211)
*/
layout?: string;
/**
* ('东','南','西','北','东南','东北','西南','西北')
*/
orientation?: number;
/**
*
*/
isForSale?: number;
/**
* '空置','已售','已租','自用'
*/
status?: number;
}
export interface RoomQuery extends PageQuery {
/**
* ID
*/
floorCode?: string;
/**
*
*/
roomCode?: string;
/**
* (101,202)
*/
roomNumber?: string;
/**
* ('住宅','商铺','办公室','设备间','公共区域')
*/
roomType?: number;
/**
* ()
*/
area?: number;
/**
* (211)
*/
layout?: string;
/**
* ('东','南','西','北','东南','东北','西南','西北')
*/
orientation?: number;
/**
*
*/
isForSale?: number;
/**
* '空置','已售','已租','自用'
*/
status?: number;
/**
*
*/
params?: any;
}

View File

@ -0,0 +1,61 @@
import type { UnitVO, UnitForm, UnitQuery } from './model';
import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
*
* @param params
* @returns
*/
export function unitList(params?: UnitQuery) {
return requestClient.get<PageResult<UnitVO>>('/property/unit/list', { params });
}
/**
*
* @param params
* @returns
*/
export function unitExport(params?: UnitQuery) {
return commonExport('/property/unit/export', params ?? {});
}
/**
*
* @param id id
* @returns
*/
export function unitInfo(id: ID) {
return requestClient.get<UnitVO>(`/property/unit/${id}`);
}
/**
*
* @param data
* @returns void
*/
export function unitAdd(data: UnitForm) {
return requestClient.postWithMsg<void>('/property/unit', data);
}
/**
*
* @param data
* @returns void
*/
export function unitUpdate(data: UnitForm) {
return requestClient.putWithMsg<void>('/property/unit', data);
}
/**
*
* @param id id
* @returns void
*/
export function unitRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/property/unit/${id}`);
}

View File

@ -0,0 +1,114 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface UnitVO {
/**
* id
*/
id: string | number;
/**
*
*/
buildingCode: string;
/**
*
*/
unitCode: string;
/**
*
*/
unitName: string;
/**
*
*/
floorCount: number;
/**
*
*/
householdCount: number;
/**
*
*/
stairCount: number;
}
export interface UnitForm extends BaseEntity {
/**
* id
*/
id?: string | number;
/**
*
*/
buildingCode?: string;
/**
*
*/
unitCode?: string;
/**
*
*/
unitName?: string;
/**
*
*/
floorCount?: number;
/**
*
*/
householdCount?: number;
/**
*
*/
stairCount?: number;
}
export interface UnitQuery extends PageQuery {
/**
*
*/
buildingCode?: string;
/**
*
*/
unitCode?: string;
/**
*
*/
unitName?: string;
/**
*
*/
floorCount?: number;
/**
*
*/
householdCount?: number;
/**
*
*/
stairCount?: number;
/**
*
*/
params?: any;
}

View File

@ -0,0 +1,241 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import {getDictOptions} from "#/utils/dict";
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'orderNo',
label: '订单编号',
},
{
component: 'Input',
fieldName: 'customerName',
label: '客户名称',
},
{
component: 'Select',
componentProps: {
},
fieldName: 'customerType',
label: '客户类型',
},
{
component: 'Select',
componentProps: {
options:getDictOptions('wy_zlfs')
},
fieldName: 'rentalType',
label: '租赁方式',
},
{
component: 'Select',
componentProps: {
options:getDictOptions('pro_charging_status')
},
fieldName: 'paymentStatus',
label: '支付状态',
},
];
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '订单号',
field: 'id',
},
{
title: '订单号',
field: 'orderNo',
},
{
title: '客户名称',
field: 'customerName',
},
{
title: '客户类型',
field: 'customerType',
},
{
title: '租赁周期',
field: 'rentalPeriod',
},
{
title: '租赁开始时间',
field: 'startTime',
},
{
title: '租赁结束时间',
field: 'endTime',
},
{
title: '应付总额',
field: 'totalAmount',
},
{
title: '租赁方式',
field: 'rentalType',
},
{
title: '租赁方案id',
field: 'planId',
},
{
title: '绿植产品id',
field: 'productId',
},
{
title: '租赁产品数量',
field: 'productNum',
},
{
title: '支付状态',
field: 'paymentStatus',
},
{
title: '是否续租',
field: 'isRelet',
},
{
title: '合同状态',
field: 'contractStatus',
},
{
title: '签署时间',
field: 'signTime',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '订单号',
fieldName: 'orderNo',
component: 'Input',
rules: 'required',
},
{
label: '客户名称',
fieldName: 'customerName',
component: 'Input',
rules: 'required',
},
{
label: '客户类型',
fieldName: 'customerType',
component: 'Select',
componentProps: {
},
rules: 'selectRequired',
},
{
label: '租赁周期',
fieldName: 'rentalPeriod',
component: 'Select',
componentProps: {
},
rules: 'selectRequired',
},
{
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: 'totalAmount',
component: 'Input',
rules: 'required',
},
{
label: '租赁方式',
fieldName: 'rentalType',
component: 'Select',
componentProps: {
},
rules: 'selectRequired',
},
{
label: '租赁方案id',
fieldName: 'planId',
component: 'Input',
},
{
label: '绿植产品id',
fieldName: 'productId',
component: 'Input',
},
{
label: '租赁产品数量',
fieldName: 'productNum',
component: 'Input',
},
{
label: '支付状态',
fieldName: 'paymentStatus',
component: 'Select',
componentProps: {
},
rules: 'selectRequired',
},
{
label: '是否续租',
fieldName: 'isRelet',
component: 'RadioGroup',
componentProps: {
buttonStyle: 'solid',
optionType: 'button',
},
},
{
label: '合同状态',
fieldName: 'contractStatus',
component: 'Select',
componentProps: {
},
},
{
label: '签署时间',
fieldName: 'signTime',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},
];

View File

@ -1,5 +1,178 @@
<script setup lang="ts">
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import {
rentalOrderExport,
rentalOrderList,
rentalOrderRemove,
} from '#/api/property/rentalOrder';
import type { RentalOrderForm } from '#/api/property/rentalOrder/model';
import { commonDownloadExcel } from '#/utils/file/download';
import rentalOrderModal from './rentalOrder-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',
},
// 使i18ngetter
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await rentalOrderList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
//
id: 'property-rentalOrder-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [RentalOrderModal, modalApi] = useVbenModal({
connectedComponent: rentalOrderModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<RentalOrderForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<RentalOrderForm>) {
await rentalOrderRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<RentalOrderForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await rentalOrderRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(rentalOrderExport, '绿植租赁-订单管理数据', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
});
}
</script>
<template>
<div>
订单管理
</div>
</template>
<Page :auto-content-height="true">
<BasicTable table-title="绿植租赁-订单管理列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['property:rentalOrder:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:rentalOrder:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:rentalOrder:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['property:rentalOrder: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:rentalOrder:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<RentalOrderModal @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 { rentalOrderAdd, rentalOrderInfo, rentalOrderUpdate } from '#/api/property/rentalOrder';
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 rentalOrderInfo(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;
}
// getValuesreadonly
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? rentalOrderUpdate(data) : rentalOrderAdd(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,171 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import {getDictOptions} from "#/utils/dict";
export const querySchema: FormSchemaGetter = () => [
{
component: 'Select',
fieldName: 'floorCode',
label: '所属小区',
},
{
component: 'Select',
fieldName: 'floorCode1',
label: '所属建筑',
},
{
component: 'Select',
fieldName: 'floorCode2',
label: '所属单元',
},
{
component: 'Select',
fieldName: 'floorCode3',
label: '所属楼层',
},
{
component: 'Input',
fieldName: 'roomCode',
label: '房间编码',
},
{
component: 'Input',
fieldName: 'roomNumber',
label: '房间号',
},
{
component: 'Select',
componentProps: {
options: getDictOptions('room_type'),
},
fieldName: 'roomType',
label: '房间类型',
},
{
component: 'Select',
componentProps: {
options: getDictOptions('wy_fjzt'),
},
fieldName: 'status',
label: '房间状态',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '所属楼层ID',
field: 'floorCode',
},
{
title: '房间编码',
field: 'roomCode',
},
{
title: '房间号',
field: 'roomNumber',
},
{
title: '房间类型',
field: 'roomType',
},
{
title: '面积(㎡)',
field: 'area',
},
{
title: '户型',
field: 'layout',
},
{
title: '朝向',
field: 'orientation',
},
{
title: '是否可售',
field: 'isForSale',
},
{
title: '状态',
field: 'status',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '所属楼层ID',
fieldName: 'floorCode',
component: 'Input',
rules: 'required',
},
{
label: '房间编码',
fieldName: 'roomCode',
component: 'Input',
rules: 'required',
},
{
label: '房间号(如101,202)',
fieldName: 'roomNumber',
component: 'Input',
rules: 'required',
},
{
label: '房间类型',
fieldName: 'roomType',
component: 'Select',
componentProps: {
options: getDictOptions('room_type'),
},
},
{
label: '面积(平方米)',
fieldName: 'area',
component: 'Input',
},
{
label: '户型(如2室1厅1卫)',
fieldName: 'layout',
component: 'Input',
},
{
label: '朝向',
fieldName: 'orientation',
component: 'Select',
componentProps: {
options: getDictOptions('direction_towards'),
},
},
{
label: '是否可售',
fieldName: 'isForSale',
component: 'Input',
},
{
label: '房间状态',
fieldName: 'status',
component: 'Select',
componentProps: {
options: getDictOptions('wy_fjzt'),
},
},
];

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 {
roomExport,
roomList,
roomRemove,
} from '#/api/property/room';
import type { RoomForm } from '#/api/property/room/model';
import { commonDownloadExcel } from '#/utils/file/download';
import roomModal from './room-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',
},
// 使i18ngetter
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await roomList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
//
id: 'property-room-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [RoomModal, modalApi] = useVbenModal({
connectedComponent: roomModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<RoomForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<RoomForm>) {
await roomRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<RoomForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await roomRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(roomExport, '房间信息数据', 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:room:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:room:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:room:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['property:room: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:room:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<RoomModal @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 { roomAdd, roomInfo, roomUpdate } from '#/api/property/room';
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 roomInfo(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;
}
// getValuesreadonly
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? roomUpdate(data) : roomAdd(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,118 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'buildingCode',
label: '建筑名称',
},
{
component: 'Input',
fieldName: 'unitCode',
label: '单元编码',
},
{
component: 'Input',
fieldName: 'unitName',
label: '单元名称',
},
{
component: 'Input',
fieldName: 'floorCount',
label: '单元层数',
},
{
component: 'Input',
fieldName: 'householdCount',
label: '单元户数',
},
{
component: 'Input',
fieldName: 'stairCount',
label: '楼梯数量',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '建筑名称',
field: 'buildingCode',
},
{
title: '单元编码',
field: 'unitCode',
},
{
title: '单元名称',
field: 'unitName',
},
{
title: '单元层数',
field: 'floorCount',
},
{
title: '单元户数',
field: 'householdCount',
},
{
title: '楼梯数量',
field: 'stairCount',
},
{
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: 'buildingCode',
component: 'Input',
rules: 'required',
},
{
label: '单元编码',
fieldName: 'unitCode',
component: 'Input',
rules: 'required',
},
{
label: '单元名称',
fieldName: 'unitName',
component: 'Input',
rules: 'required',
},
{
label: '单元层数',
fieldName: 'floorCount',
component: 'Input',
},
{
label: '单元户数',
fieldName: 'householdCount',
component: 'Input',
},
{
label: '楼梯数量',
fieldName: 'stairCount',
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 {
unitExport,
unitList,
unitRemove,
} from '#/api/property/unit';
import type { UnitForm } from '#/api/property/unit/model';
import { commonDownloadExcel } from '#/utils/file/download';
import unitModal from './unit-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',
},
// 使i18ngetter
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await unitList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
//
id: 'property-unit-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [UnitModal, modalApi] = useVbenModal({
connectedComponent: unitModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<UnitForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<UnitForm>) {
await unitRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<UnitForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await unitRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(unitExport, '单元数据', 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:unit:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:unit:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:unit:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['property:unit: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:unit:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<UnitModal @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 { unitAdd, unitInfo, unitUpdate } from '#/api/property/unit';
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 unitInfo(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;
}
// getValuesreadonly
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? unitUpdate(data) : unitAdd(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>