Merge branch 'master' of http://47.109.37.87:3000/by2025/admin-vben5
Some checks failed
/ Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
/ Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
commit
fc08c5525c
61
apps/web-antd/src/api/property/meter/lightInfo/index.ts
Normal file
61
apps/web-antd/src/api/property/meter/lightInfo/index.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import type { LightInfoVO, LightInfoForm, LightInfoQuery } 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 lightInfoList(params?: LightInfoQuery) {
|
||||
return requestClient.get<PageResult<LightInfoVO>>('/property/lightInfo/list', { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出灯控开关信息列表
|
||||
* @param params
|
||||
* @returns 灯控开关信息列表
|
||||
*/
|
||||
export function lightInfoExport(params?: LightInfoQuery) {
|
||||
return commonExport('/property/lightInfo/export', params ?? {});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询灯控开关信息详情
|
||||
* @param id id
|
||||
* @returns 灯控开关信息详情
|
||||
*/
|
||||
export function lightInfoInfo(id: ID) {
|
||||
return requestClient.get<LightInfoVO>(`/property/lightInfo/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增灯控开关信息
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function lightInfoAdd(data: LightInfoForm) {
|
||||
return requestClient.postWithMsg<void>('/property/lightInfo', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新灯控开关信息
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function lightInfoUpdate(data: LightInfoForm) {
|
||||
return requestClient.putWithMsg<void>('/property/lightInfo', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除灯控开关信息
|
||||
* @param id id
|
||||
* @returns void
|
||||
*/
|
||||
export function lightInfoRemove(id: ID | IDS) {
|
||||
return requestClient.deleteWithMsg<void>(`/property/lightInfo/${id}`);
|
||||
}
|
134
apps/web-antd/src/api/property/meter/lightInfo/model.d.ts
vendored
Normal file
134
apps/web-antd/src/api/property/meter/lightInfo/model.d.ts
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||
|
||||
export interface LightInfoVO {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 位置描述
|
||||
*/
|
||||
locationRemark: string;
|
||||
|
||||
/**
|
||||
* 开关状态(0:关,1:开)
|
||||
*/
|
||||
isOn: number;
|
||||
|
||||
/**
|
||||
* 灯控模块编码
|
||||
*/
|
||||
code: number;
|
||||
|
||||
/**
|
||||
* 园区编码
|
||||
*/
|
||||
communityId: string | number;
|
||||
|
||||
/**
|
||||
* 建筑名称
|
||||
*/
|
||||
buildingId: string | number;
|
||||
|
||||
/**
|
||||
* 单元编码
|
||||
*/
|
||||
unitId: string | number;
|
||||
|
||||
/**
|
||||
* 所属楼层ID
|
||||
*/
|
||||
floorId: string | number;
|
||||
|
||||
/**
|
||||
* 楼层
|
||||
*/
|
||||
floorName: string;
|
||||
|
||||
}
|
||||
|
||||
export interface LightInfoForm extends BaseEntity {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 位置描述
|
||||
*/
|
||||
locationRemark?: string;
|
||||
|
||||
/**
|
||||
* 开关状态(0:关,1:开)
|
||||
*/
|
||||
isOn?: number;
|
||||
|
||||
/**
|
||||
* 灯控模块编码
|
||||
*/
|
||||
code?: number;
|
||||
|
||||
/**
|
||||
* 园区编码
|
||||
*/
|
||||
communityId?: string | number;
|
||||
|
||||
/**
|
||||
* 建筑名称
|
||||
*/
|
||||
buildingId?: string | number;
|
||||
|
||||
/**
|
||||
* 单元编码
|
||||
*/
|
||||
unitId?: string | number;
|
||||
|
||||
/**
|
||||
* 所属楼层ID
|
||||
*/
|
||||
floorId?: string | number;
|
||||
|
||||
}
|
||||
|
||||
export interface LightInfoQuery extends PageQuery {
|
||||
/**
|
||||
* 位置描述
|
||||
*/
|
||||
locationRemark?: string;
|
||||
|
||||
/**
|
||||
* 开关状态(0:关,1:开)
|
||||
*/
|
||||
isOn?: number;
|
||||
|
||||
/**
|
||||
* 灯控模块编码
|
||||
*/
|
||||
code?: number;
|
||||
|
||||
/**
|
||||
* 园区编码
|
||||
*/
|
||||
communityId?: string | number;
|
||||
|
||||
/**
|
||||
* 建筑名称
|
||||
*/
|
||||
buildingId?: string | number;
|
||||
|
||||
/**
|
||||
* 单元编码
|
||||
*/
|
||||
unitId?: string | number;
|
||||
|
||||
/**
|
||||
* 所属楼层ID
|
||||
*/
|
||||
floorId?: string | number;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
84
apps/web-antd/src/views/property/meter/lightInfo/data.ts
Normal file
84
apps/web-antd/src/views/property/meter/lightInfo/data.ts
Normal file
@ -0,0 +1,84 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form'
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table'
|
||||
|
||||
|
||||
export const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'locationRemark',
|
||||
label: '位置描述',
|
||||
},
|
||||
]
|
||||
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// export const columns: () => VxeGridProps['columns'] = () => [
|
||||
export const columns: VxeGridProps['columns'] = [
|
||||
{ type: 'checkbox', width: 60 },
|
||||
// {
|
||||
// title: '主键id',
|
||||
// field: 'id',
|
||||
// },
|
||||
{
|
||||
title: '位置描述',
|
||||
field: 'locationRemark',
|
||||
},
|
||||
|
||||
{
|
||||
title: '楼 层',
|
||||
field: 'floorName',
|
||||
},
|
||||
{
|
||||
title: '开关状态',
|
||||
field: 'isOn',
|
||||
slots: { default: 'isOn' },
|
||||
},
|
||||
{
|
||||
field: 'action',
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
title: '操作',
|
||||
width: 180,
|
||||
},
|
||||
]
|
||||
|
||||
export const drawerSchema: FormSchemaGetter = () => [
|
||||
{
|
||||
label: '主键id',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '楼层',
|
||||
fieldName: 'floorId',
|
||||
component: 'TreeSelect',
|
||||
defaultValue: undefined,
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '位置描述',
|
||||
fieldName: 'locationRemark',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '开关状态',
|
||||
fieldName: 'isOn',
|
||||
component: 'Switch',
|
||||
rules: 'required',
|
||||
defaultValue: false,
|
||||
componentProps: {
|
||||
class: 'w-auto',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '灯控模块编码',
|
||||
fieldName: 'code',
|
||||
component: 'Input',
|
||||
rules: 'required',
|
||||
},
|
||||
|
||||
]
|
181
apps/web-antd/src/views/property/meter/lightInfo/index.vue
Normal file
181
apps/web-antd/src/views/property/meter/lightInfo/index.vue
Normal file
@ -0,0 +1,181 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import { TableSwitch } from "#/components/table"
|
||||
import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
|
||||
|
||||
import { Modal, Popconfirm, Space } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
useVbenVxeGrid,
|
||||
vxeCheckboxChecked,
|
||||
type VxeGridProps
|
||||
} from '#/adapter/vxe-table';
|
||||
|
||||
import {
|
||||
lightInfoExport,
|
||||
lightInfoList,
|
||||
lightInfoRemove,
|
||||
} from '#/api/property/meter/lightInfo';
|
||||
import type { LightInfoForm } from '#/api/property/meter/lightInfo/model';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
|
||||
import lightInfoDrawer from './lightInfo-drawer.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 lightInfoList({
|
||||
pageNum: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
},
|
||||
// 表格全局唯一表示 保存列配置需要用到
|
||||
id: 'property-lightInfo-index'
|
||||
};
|
||||
|
||||
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const [LightInfoDrawer, drawerApi] = useVbenDrawer({
|
||||
connectedComponent: lightInfoDrawer,
|
||||
});
|
||||
|
||||
function handleAdd() {
|
||||
drawerApi.setData({});
|
||||
drawerApi.open();
|
||||
}
|
||||
|
||||
async function handleEdit(row: Required<LightInfoForm>) {
|
||||
drawerApi.setData({ id: row.id });
|
||||
drawerApi.open();
|
||||
}
|
||||
|
||||
async function handleDelete(row: Required<LightInfoForm>) {
|
||||
await lightInfoRemove(row.id);
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
function handleMultiDelete() {
|
||||
const rows = tableApi.grid.getCheckboxRecords();
|
||||
const ids = rows.map((row: Required<LightInfoForm>) => row.id);
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
okType: 'danger',
|
||||
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||
onOk: async () => {
|
||||
await lightInfoRemove(ids);
|
||||
await tableApi.query();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(lightInfoExport, '灯控开关信息数据', 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:lightInfo:export']"
|
||||
@click="handleDownloadExcel"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!vxeCheckboxChecked(tableApi)"
|
||||
danger
|
||||
type="primary"
|
||||
v-access:code="['property:lightInfo:remove']"
|
||||
@click="handleMultiDelete">
|
||||
{{ $t('pages.common.delete') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-access:code="['property:lightInfo:add']"
|
||||
@click="handleAdd"
|
||||
>
|
||||
{{ $t('pages.common.add') }}
|
||||
</a-button>
|
||||
</Space>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<ghost-button
|
||||
v-access:code="['property:lightInfo: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:lightInfo:remove']"
|
||||
@click.stop=""
|
||||
>
|
||||
{{ $t('pages.common.delete') }}
|
||||
</ghost-button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
<template #isOn="{ row }">
|
||||
<TableSwitch :checkedValue=true :unCheckedValue=false :value="row.isOn" @reload="() => tableApi.query()" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<LightInfoDrawer @reload="tableApi.query()" />
|
||||
</Page>
|
||||
</template>
|
@ -0,0 +1,140 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { useVbenDrawer } from '@vben/common-ui'
|
||||
import { $t } from '@vben/locales'
|
||||
import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils'
|
||||
|
||||
import { useVbenForm } from '#/adapter/form'
|
||||
import { communityTree } from '#/api/property/community'
|
||||
import { lightInfoAdd, lightInfoInfo, lightInfoUpdate } from '#/api/property/meter/lightInfo'
|
||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'
|
||||
|
||||
import { drawerSchema } 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: 100,
|
||||
// 通用配置项 会影响到所有表单项
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
}
|
||||
},
|
||||
schema: drawerSchema(),
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-2',
|
||||
})
|
||||
|
||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||
{
|
||||
initializedGetter: defaultFormValueGetter(formApi),
|
||||
currentGetter: defaultFormValueGetter(formApi),
|
||||
},
|
||||
)
|
||||
|
||||
const [BasicModal, modalApi] = useVbenDrawer({
|
||||
// 在这里更改宽度
|
||||
class: 'w-[550px]',
|
||||
fullscreenButton: false,
|
||||
onBeforeClose,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null
|
||||
}
|
||||
modalApi.drawerLoading(true)
|
||||
|
||||
const { id } = modalApi.getData() as { id?: number | string }
|
||||
isUpdate.value = !!id
|
||||
setupCommunitySelect()
|
||||
if (isUpdate.value && id) {
|
||||
const record = await lightInfoInfo(id)
|
||||
await formApi.setValues(record)
|
||||
}
|
||||
await markInitialized()
|
||||
|
||||
modalApi.drawerLoading(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 ? lightInfoUpdate(data) : lightInfoAdd(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: () => ({
|
||||
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: 'floorId',
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
await formApi.resetForm()
|
||||
resetInitialized()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicModal :title="title">
|
||||
<BasicForm />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
@ -76,7 +76,6 @@ async function handleConfirm() {
|
||||
// 自定义深拷贝
|
||||
const data = {
|
||||
...cloneDeep(formValues),
|
||||
facePictures: 1,
|
||||
visitingBeginTime: formValues.visitingTimeRange?.[0],
|
||||
visitingEndTime: formValues.visitingTimeRange?.[1],
|
||||
visitingTimeRange: undefined
|
||||
|
Loading…
Reference in New Issue
Block a user