增加电梯页面
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
15683799673 2025-07-10 08:45:59 +08:00
parent 0d2a4db6a6
commit ed2e88b99e
6 changed files with 912 additions and 1 deletions

View File

@ -0,0 +1,61 @@
import type { ElevatorInfoVO, ElevatorInfoForm, ElevatorInfoQuery } 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 elevatorInfoList(params?: ElevatorInfoQuery) {
return requestClient.get<PageResult<ElevatorInfoVO>>('/sis/elevatorInfo/list', { params });
}
/**
*
* @param params
* @returns
*/
export function elevatorInfoExport(params?: ElevatorInfoQuery) {
return commonExport('/sis/elevatorInfo/export', params ?? {});
}
/**
*
* @param elevatorId id
* @returns
*/
export function elevatorInfoInfo(elevatorId: ID) {
return requestClient.get<ElevatorInfoVO>(`/sis/elevatorInfo/${elevatorId}`);
}
/**
*
* @param data
* @returns void
*/
export function elevatorInfoAdd(data: ElevatorInfoForm) {
return requestClient.postWithMsg<void>('/sis/elevatorInfo', data);
}
/**
*
* @param data
* @returns void
*/
export function elevatorInfoUpdate(data: ElevatorInfoForm) {
return requestClient.putWithMsg<void>('/sis/elevatorInfo', data);
}
/**
*
* @param elevatorId id
* @returns void
*/
export function elevatorInfoRemove(elevatorId: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/sis/elevatorInfo/${elevatorId}`);
}

View File

@ -0,0 +1,294 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface ElevatorInfoVO {
/**
*
*/
elevatorId: string | number;
/**
*
*/
elevatorCode: string;
/**
*
*/
elevatorName: string;
/**
*
*/
location: string;
/**
*
*/
brand: string;
/**
*
*/
model: string;
/**
*
*/
manufactureDate: string;
/**
*
*/
installationDate: string;
/**
* (kg)
*/
maxLoad: number;
/**
*
*/
floorsServed: number;
/**
*
*/
maintenanceCompany: string;
/**
*
*/
maintenancePhone: string;
/**
*
*/
lastInspectionDate: string;
/**
*
*/
nextInspectionDate: string;
/**
*
*/
controlFactory: string;
/**
* ip
*/
controlIp: string;
/**
*
*/
controlPort: number;
/**
*
*/
controlAccount: string;
/**
*
*/
controlPwd: string;
}
export interface ElevatorInfoForm extends BaseEntity {
/**
*
*/
elevatorId?: string | number;
/**
*
*/
elevatorCode?: string;
/**
*
*/
elevatorName?: string;
/**
*
*/
location?: string;
/**
*
*/
brand?: string;
/**
*
*/
model?: string;
/**
*
*/
manufactureDate?: string;
/**
*
*/
installationDate?: string;
/**
* (kg)
*/
maxLoad?: number;
/**
*
*/
floorsServed?: number;
/**
*
*/
maintenanceCompany?: string;
/**
*
*/
maintenancePhone?: string;
/**
*
*/
lastInspectionDate?: string;
/**
*
*/
nextInspectionDate?: string;
/**
*
*/
controlFactory?: string;
/**
* ip
*/
controlIp?: string;
/**
*
*/
controlPort?: number;
/**
*
*/
controlAccount?: string;
/**
*
*/
controlPwd?: string;
}
export interface ElevatorInfoQuery extends PageQuery {
/**
*
*/
elevatorCode?: string;
/**
*
*/
elevatorName?: string;
/**
*
*/
location?: string;
/**
*
*/
brand?: string;
/**
*
*/
model?: string;
/**
*
*/
manufactureDate?: string;
/**
*
*/
installationDate?: string;
/**
* (kg)
*/
maxLoad?: number;
/**
*
*/
floorsServed?: number;
/**
*
*/
maintenanceCompany?: string;
/**
*
*/
maintenancePhone?: string;
/**
*
*/
lastInspectionDate?: string;
/**
*
*/
nextInspectionDate?: string;
/**
*
*/
controlFactory?: string;
/**
* ip
*/
controlIp?: string;
/**
*
*/
controlPort?: number;
/**
*
*/
controlAccount?: string;
/**
*
*/
controlPwd?: string;
/**
*
*/
params?: any;
}

View File

@ -0,0 +1,231 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'elevatorCode',
label: '电梯编号',
},
{
component: 'Input',
fieldName: 'elevatorName',
label: '电梯名称',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '电梯编号',
field: 'elevatorCode',
},
{
title: '电梯名称',
field: 'elevatorName',
},
{
title: '安装位置',
field: 'location',
},
{
title: '品牌',
field: 'brand',
},
{
title: '型号',
field: 'model',
},
{
title: '生产日期',
field: 'manufactureDate',
},
{
title: '安装日期',
field: 'installationDate',
},
{
title: '最大载重(kg)',
field: 'maxLoad',
},
{
title: '服务楼层数',
field: 'floorsServed',
},
{
title: '维保公司',
field: 'maintenanceCompany',
},
/*{
title: '维保电话',
field: 'maintenancePhone',
},
{
title: '上次年检日期',
field: 'lastInspectionDate',
},
{
title: '下次年检日期',
field: 'nextInspectionDate',
},*/
{
title: '梯控厂商',
field: 'controlFactory',
},
{
title: '梯控ip',
field: 'controlIp',
},
{
title: '梯控端口',
field: 'controlPort',
},
{
title: '梯控账号',
field: 'controlAccount',
},
{
title: '梯控密码',
field: 'controlPwd',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '',
fieldName: 'elevatorId',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '电梯名称',
fieldName: 'elevatorName',
component: 'Input',
rules: 'required',
},
{
component: 'TreeSelect',
fieldName: 'unitId',
defaultValue: undefined,
label: '社区建筑',
rules: 'selectRequired',
},
{
label: '安装位置',
fieldName: 'location',
component: 'Input',
rules: 'required',
},
{
label: '品牌',
fieldName: 'brand',
component: 'Input',
},
{
label: '型号',
fieldName: 'model',
component: 'Input',
},
{
label: '生产日期',
fieldName: 'manufactureDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},
{
label: '安装日期',
fieldName: 'installationDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},
{
label: '最大载重(kg)',
fieldName: 'maxLoad',
component: 'Input',
},
{
label: '服务楼层数',
fieldName: 'floorsServed',
component: 'Input',
},
{
label: '维保公司',
fieldName: 'maintenanceCompany',
component: 'Input',
},
/* {
label: '维保电话',
fieldName: 'maintenancePhone',
component: 'Input',
},
{
label: '上次年检日期',
fieldName: 'lastInspectionDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},
{
label: '下次年检日期',
fieldName: 'nextInspectionDate',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
},*/
{
label: '梯控厂商',
fieldName: 'controlFactory',
component: 'Input',
rules: 'required',
},
{
label: '梯控ip',
fieldName: 'controlIp',
component: 'Input',
rules: 'required',
},
{
label: '梯控端口',
fieldName: 'controlPort',
component: 'Input',
rules: 'required',
},
{
label: '梯控账号',
fieldName: 'controlAccount',
component: 'Input',
rules: 'required',
},
{
label: '梯控密码',
fieldName: 'controlPwd',
component: 'Input',
rules: 'required',
},
];

View File

@ -0,0 +1,142 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { elevatorInfoAdd, elevatorInfoInfo, elevatorInfoUpdate } from '#/api/sis/elevatorInfo';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
import { communityTree } from '#/api/property/community';
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-1',
// label px
labelWidth: 100,
//
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-[60%]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
setupCommunitySelect()
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await elevatorInfoInfo(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 ? elevatorInfoUpdate(data) : elevatorInfoAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
/**
* 初始化城市
*/
async function setupCommunitySelect() {
const areaList = await communityTree(3);
// /
// addFullName(areaList, 'areaName', ' / ');
const splitStr = '/';
handleNode(areaList, 'label', splitStr, function (node: any) {
if (node.level != 3) {
node.disabled = true;
}
});
formApi.updateSchema([
{
componentProps: () => ({
class: 'w-full',
fieldNames: {
key: 'id',
label: 'label',
value: 'code',
children: 'children',
},
getPopupContainer,
placeholder: '请选择建筑',
showSearch: true,
treeData: areaList,
treeDefaultExpandAll: true,
treeLine: { showLeafIcon: false },
//
treeNodeFilterProp: 'label',
//
treeNodeLabelProp: 'fullName',
}),
fieldName: 'unitId',
},
]);
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm />
</BasicModal>
</template>

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 {
elevatorInfoExport,
elevatorInfoList,
elevatorInfoRemove,
} from '#/api/sis/elevatorInfo';
import type { ElevatorInfoForm } from '#/api/sis/elevatorInfo/model';
import { commonDownloadExcel } from '#/utils/file/download';
import elevatorInfoModal from './elevatorInfo-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 elevatorInfoList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'elevatorId',
},
//
id: 'sis-elevatorInfo-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [ElevatorInfoModal, modalApi] = useVbenModal({
connectedComponent: elevatorInfoModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<ElevatorInfoForm>) {
modalApi.setData({ id: row.elevatorId });
modalApi.open();
}
async function handleDelete(row: Required<ElevatorInfoForm>) {
await elevatorInfoRemove(row.elevatorId);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<ElevatorInfoForm>) => row.elevatorId);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await elevatorInfoRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(elevatorInfoExport, '电梯基本信息数据', 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="['sis:elevatorInfo:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['sis:elevatorInfo:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['sis:elevatorInfo:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['sis:elevatorInfo: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="['sis:elevatorInfo:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<ElevatorInfoModal @reload="tableApi.query()" />
</Page>
</template>

View File

@ -28,7 +28,8 @@ export default defineConfig(async () => {
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
// mock代理目标地址
target: 'http://192.168.43.169:8080',
// target: 'http://192.168.43.169:8080',
target: 'http://127.0.0.1:8080',
// target: 'http://192.168.0.108:8080',
// target: 'http://192.168.0.106:8080',
// target: 'http://47.109.37.87:3010',