综合模块完成
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
15683799673
2025-06-28 22:49:40 +08:00
parent acd63bc96e
commit 54cea19b78
22 changed files with 523 additions and 571 deletions

View File

@@ -1,4 +1,4 @@
import type { PageQuery, BaseEntity } from '#/api/common'; import type { BaseEntity, PageQuery } from '#/api/common';
export interface BuildingVO { export interface BuildingVO {
/** /**
@@ -16,21 +16,6 @@ export interface BuildingVO {
*/ */
buildingName: string; buildingName: string;
/**
* 省
*/
province: string;
/**
* 市
*/
city: string;
/**
* 区
*/
district: string;
/** /**
* 总层数 * 总层数
*/ */
@@ -70,67 +55,6 @@ export interface BuildingVO {
* 维度 * 维度
*/ */
lat: string; lat: string;
/**
* 产权性质(1:自持2承租3自持+承租,4政府免费使用)
*/
cqxz: number;
/**
* 不动产编号
*/
bdcbh: string;
/**
* 产权编号
*/
cqbh: string;
/**
* 图地编号
*/
tdbh: string;
/**
* 建筑面积
*/
jzmj: number;
/**
* 产权面积
*/
cqmj: number;
/**
* 可租面积
*/
kzmj: number;
/**
* 自用面积
*/
zymj: number;
/**
* 配套面积
*/
ptmj: number;
/**
* 车位面积
*/
cwmj: number;
/**
* 标准层高
*/
bzcg: number;
/**
* 排序字段
*/
sort: number;
} }
export interface BuildingForm extends BaseEntity { export interface BuildingForm extends BaseEntity {
@@ -149,21 +73,6 @@ export interface BuildingForm extends BaseEntity {
*/ */
buildingName?: string; buildingName?: string;
/**
* 省
*/
province?: string;
/**
* 市
*/
city?: string;
/**
* 区
*/
district?: string;
/** /**
* 总层数 * 总层数
*/ */
@@ -203,68 +112,6 @@ export interface BuildingForm extends BaseEntity {
* 维度 * 维度
*/ */
lat?: string; lat?: string;
/**
* 产权性质(1:自持2承租3自持+承租,4政府免费使用)
*/
cqxz?: number;
/**
* 不动产编号
*/
bdcbh?: string;
/**
* 产权编号
*/
cqbh?: string;
/**
* 图地编号
*/
tdbh?: string;
/**
* 建筑面积
*/
jzmj?: number;
/**
* 产权面积
*/
cqmj?: number;
/**
* 可租面积
*/
kzmj?: number;
/**
* 自用面积
*/
zymj?: number;
/**
* 配套面积
*/
ptmj?: number;
/**
* 车位面积
*/
cwmj?: number;
/**
* 标准层高
*/
bzcg?: number;
/**
* 排序字段
*/
sort?: number;
} }
export interface BuildingQuery extends PageQuery { export interface BuildingQuery extends PageQuery {
@@ -278,21 +125,6 @@ export interface BuildingQuery extends PageQuery {
*/ */
buildingName?: string; buildingName?: string;
/**
* 省
*/
province?: string;
/**
* 市
*/
city?: string;
/**
* 区
*/
district?: string;
/** /**
* 总层数 * 总层数
*/ */
@@ -333,68 +165,13 @@ export interface BuildingQuery extends PageQuery {
*/ */
lat?: string; lat?: string;
/**
* 产权性质(1:自持2承租3自持+承租,4政府免费使用)
*/
cqxz?: number;
/**
* 不动产编号
*/
bdcbh?: string;
/**
* 产权编号
*/
cqbh?: string;
/**
* 图地编号
*/
tdbh?: string;
/**
* 建筑面积
*/
jzmj?: number;
/**
* 产权面积
*/
cqmj?: number;
/**
* 可租面积
*/
kzmj?: number;
/**
* 自用面积
*/
zymj?: number;
/**
* 配套面积
*/
ptmj?: number;
/**
* 车位面积
*/
cwmj?: number;
/**
* 标准层高
*/
bzcg?: number;
/** /**
* 排序字段 * 排序字段
*/ */
sort?: number; sort?: number;
/** /**
* 日期范围参数 * 日期范围参数
*/ */
params?: any; params?: any;
} }

View File

@@ -1,28 +1,37 @@
import type { CityAreaVO, CityAreaForm, CityAreaQuery } from './model'; import type { CityAreaForm, CityAreaQuery, CityAreaVO } from './model';
import type { ID, IDS } from '#/api/common'; import type { ID, IDS, PageResult } from '#/api/common';
import type { PageResult } from '#/api/common';
import { commonExport } from '#/api/helper'; import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request'; import { requestClient } from '#/api/request';
/** /**
* 查询行政区划 * 查询行政区划
列表 列表
* @param params * @param params
* @returns 行政区划 * @returns 行政区划
列表 列表
*/ */
export function cityAreaList(params?: CityAreaQuery) { export function cityAreaList(params?: CityAreaQuery) {
return requestClient.get<PageResult<CityAreaVO>>('/property/cityArea/list', { params }); return requestClient.get<PageResult<CityAreaVO>>('/property/cityArea/list', {
params,
});
}
/**
* 查询城市结构数
* @param params
*/
export function getCityAreaTreeList() {
return requestClient.get<CityAreaVO[]>('/property/cityArea/treeList');
} }
/** /**
* 导出行政区划 * 导出行政区划
列表 列表
* @param params * @param params
* @returns 行政区划 * @returns 行政区划
列表 列表
*/ */
export function cityAreaExport(params?: CityAreaQuery) { export function cityAreaExport(params?: CityAreaQuery) {
return commonExport('/property/cityArea/export', params ?? {}); return commonExport('/property/cityArea/export', params ?? {});
@@ -30,10 +39,10 @@ export function cityAreaExport(params?: CityAreaQuery) {
/** /**
* 查询行政区划 * 查询行政区划
详情 详情
* @param areaCode id * @param areaCode id
* @returns 行政区划 * @returns 行政区划
详情 详情
*/ */
export function cityAreaInfo(areaCode: ID) { export function cityAreaInfo(areaCode: ID) {
return requestClient.get<CityAreaVO>(`/property/cityArea/${areaCode}`); return requestClient.get<CityAreaVO>(`/property/cityArea/${areaCode}`);

View File

@@ -1,18 +1,29 @@
import type { CommunityVO, CommunityForm, CommunityQuery } from './model'; import type { CommunityForm, CommunityQuery, CommunityVO } from './model';
import type { ID, IDS } from '#/api/common'; import type { ID, IDS, PageResult } from '#/api/common';
import type { PageResult } from '#/api/common';
import { commonExport } from '#/api/helper'; import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request'; import { requestClient } from '#/api/request';
/** /**
* 查询小区列表 * 查询小区列表
* @param params * @param params
* @returns 小区列表 * @returns 小区列表
*/ */
export function communityList(params?: CommunityQuery) { export function communityList(params?: CommunityQuery) {
return requestClient.get<PageResult<CommunityVO>>('/property/community/list', { params }); return requestClient.get<PageResult<CommunityVO>>(
'/property/community/list',
{ params },
);
}
/**
* 查询小区树结构
* @param params
* @returns 小区列表
*/
export function communityTree(level: number) {
return requestClient.get<CommunityVO[]>(`/property/community/tree/${level}`);
} }
/** /**

View File

@@ -1,8 +1,8 @@
import type { PageQuery, BaseEntity } from '#/api/common'; import type { BaseEntity, PageQuery } from '#/api/common';
export interface CommunityVO { export interface CommunityVO {
/** /**
* *
*/ */
id: string | number; id: string | number;
@@ -16,6 +16,9 @@ export interface CommunityVO {
*/ */
communityType: number; communityType: number;
cityFullCode: string;
cityFullName: string;
/** /**
* 省 * 省
*/ */
@@ -52,7 +55,7 @@ export interface CommunityVO {
area: number; area: number;
/** /**
* *
*/ */
builtYear: string; builtYear: string;
@@ -75,12 +78,11 @@ export interface CommunityVO {
* 小图图片 * 小图图片
*/ */
img: string; img: string;
} }
export interface CommunityForm extends BaseEntity { export interface CommunityForm extends BaseEntity {
/** /**
* *
*/ */
id?: string | number; id?: string | number;
@@ -94,6 +96,9 @@ export interface CommunityForm extends BaseEntity {
*/ */
communityType?: number; communityType?: number;
cityFullName: string;
cityFullCode: string;
/** /**
* 省 * 省
*/ */
@@ -130,7 +135,7 @@ export interface CommunityForm extends BaseEntity {
area?: number; area?: number;
/** /**
* *
*/ */
builtYear?: string; builtYear?: string;
@@ -153,7 +158,6 @@ export interface CommunityForm extends BaseEntity {
* 小图图片 * 小图图片
*/ */
img?: string; img?: string;
} }
export interface CommunityQuery extends PageQuery { export interface CommunityQuery extends PageQuery {
@@ -203,7 +207,7 @@ export interface CommunityQuery extends PageQuery {
area?: number; area?: number;
/** /**
* *
*/ */
builtYear?: string; builtYear?: string;
@@ -228,7 +232,7 @@ export interface CommunityQuery extends PageQuery {
img?: string; img?: string;
/** /**
* 日期范围参数 * 日期范围参数
*/ */
params?: any; params?: any;
} }

View File

@@ -21,7 +21,7 @@ const title = computed(() => {
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
// 默认占满两列 // 默认占满两列
formItemClass: 'col-span-2', formItemClass: 'col-span-1',
// 默认label宽度 px // 默认label宽度 px
labelWidth: 80, labelWidth: 80,
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
@@ -43,7 +43,7 @@ const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
const [BasicModal, modalApi] = useVbenModal({ const [BasicModal, modalApi] = useVbenModal({
// 在这里更改宽度 // 在这里更改宽度
class: 'w-[550px]', class: 'w-[60%]',
fullscreenButton: false, fullscreenButton: false,
onBeforeClose, onBeforeClose,
onClosed: handleClosed, onClosed: handleClosed,

View File

@@ -1,22 +1,44 @@
import type { FormSchemaGetter } from '#/adapter/form'; import type { FormSchemaGetter, VbenFormSchema } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import { communityList } from '#/api/property/community';
import type {
CommunityQuery,
CommunityVO,
} from '#/api/property/community/model';
import { getPopupContainer } from '@vben/utils';
import { getDictOptions } from '#/utils/dict';
import { DictEnum } from '@vben/constants';
let arr: CommunityVO[] = [];
const communitySelect: VbenFormSchema = {
component: 'ApiSelect',
fieldName: 'communityId',
label: '社区',
componentProps: {
resultField: 'list', // 根据API返回结构调整
labelField: 'communityName',
valueField: 'id',
api: async () => {
if (!arr || arr.length == 0) {
const params: CommunityQuery = {
pageNum: 1,
pageSize: 500,
};
const res = await communityList(params);
arr = res.rows;
}
return arr;
},
},
};
export const querySchema: FormSchemaGetter = () => [ export const querySchema: FormSchemaGetter = () => [
{ communitySelect,
component: 'Input',
fieldName: 'communityName',
label: '社区',
},
{ {
component: 'Input', component: 'Input',
fieldName: 'buildingName', fieldName: 'buildingName',
label: '建筑名称', label: '建筑名称',
}, },
{
component: 'Input',
fieldName: 'unitCount',
label: '单元数',
},
]; ];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新 // 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
@@ -27,18 +49,6 @@ export const columns: VxeGridProps['columns'] = [
title: '建筑名称', title: '建筑名称',
field: 'buildingName', field: 'buildingName',
}, },
{
title: '省',
field: 'province',
},
{
title: '市',
field: 'city',
},
{
title: '区',
field: 'district',
},
{ {
title: '总层数', title: '总层数',
field: 'floorCount', field: 'floorCount',
@@ -49,7 +59,7 @@ export const columns: VxeGridProps['columns'] = [
}, },
{ {
title: '建筑类型', title: '建筑类型',
field: 'buildType', field: 'buildTypeName',
}, },
{ {
title: '电梯数量', title: '电梯数量',
@@ -91,9 +101,7 @@ export const modalSchema: FormSchemaGetter = () => [
}, },
}, },
{ {
label: '园区编码', ...communitySelect,
fieldName: 'communityId',
component: 'Input',
rules: 'required', rules: 'required',
}, },
{ {
@@ -102,24 +110,6 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Input', component: 'Input',
rules: 'required', rules: 'required',
}, },
{
label: '省',
fieldName: 'province',
component: 'Input',
rules: 'required',
},
{
label: '市',
fieldName: 'city',
component: 'Input',
rules: 'required',
},
{
label: '区',
fieldName: 'district',
component: 'Input',
rules: 'required',
},
{ {
label: '总层数', label: '总层数',
fieldName: 'floorCount', fieldName: 'floorCount',
@@ -134,7 +124,10 @@ export const modalSchema: FormSchemaGetter = () => [
label: '建筑类型', label: '建筑类型',
fieldName: 'buildType', fieldName: 'buildType',
component: 'Select', component: 'Select',
componentProps: {}, componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.sys_build_use_type),
},
}, },
{ {
label: '电梯数量', label: '电梯数量',
@@ -147,8 +140,8 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
showTime: true, showTime: true,
format: 'YYYY-MM-DD HH:mm:ss', format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'YYYY-MM-DD',
}, },
}, },
{ {
@@ -161,17 +154,10 @@ export const modalSchema: FormSchemaGetter = () => [
label: '经度', label: '经度',
fieldName: 'lon', fieldName: 'lon',
component: 'Input', component: 'Input',
rules: 'required',
}, },
{ {
label: '维度', label: '维度',
fieldName: 'lat', fieldName: 'lat',
component: 'Input', component: 'Input',
rules: 'required',
},
{
label: '排序字段',
fieldName: 'sort',
component: 'Input',
}, },
]; ];

View File

@@ -1,18 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Recordable } from '@vben/types';
import { ref } from 'vue';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui'; import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils'; import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue'; import { Modal, Popconfirm, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import { import {
useVbenVxeGrid, useVbenVxeGrid,
vxeCheckboxChecked, vxeCheckboxChecked,
type VxeGridProps type VxeGridProps,
} from '#/adapter/vxe-table'; } from '#/adapter/vxe-table';
import { import {
@@ -76,7 +71,7 @@ const gridOptions: VxeGridProps = {
keyField: 'id', keyField: 'id',
}, },
// 表格全局唯一表示 保存列配置需要用到 // 表格全局唯一表示 保存列配置需要用到
id: 'property-building-index' id: 'property-building-index',
}; };
const [BasicTable, tableApi] = useVbenVxeGrid({ const [BasicTable, tableApi] = useVbenVxeGrid({
@@ -118,9 +113,14 @@ function handleMultiDelete() {
} }
function handleDownloadExcel() { function handleDownloadExcel() {
commonDownloadExcel(buildingExport, '建筑数据', tableApi.formApi.form.values, { commonDownloadExcel(
fieldMappingTime: formOptions.fieldMappingTime, buildingExport,
}); '建筑数据',
tableApi.formApi.form.values,
{
fieldMappingTime: formOptions.fieldMappingTime,
},
);
} }
</script> </script>
@@ -138,9 +138,10 @@ function handleDownloadExcel() {
<a-button <a-button
:disabled="!vxeCheckboxChecked(tableApi)" :disabled="!vxeCheckboxChecked(tableApi)"
danger danger
type="primary" type="primary"
v-access:code="['property:building:remove']" v-access:code="['property:building:remove']"
@click="handleMultiDelete"> @click="handleMultiDelete"
>
{{ $t('pages.common.delete') }} {{ $t('pages.common.delete') }}
</a-button> </a-button>
<a-button <a-button

View File

@@ -1,10 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type {Community} from '#/api/property/community/model'; import type { CommunityVO } from '#/api/property/community/model';
import {shallowRef} from 'vue'; import { shallowRef } from 'vue';
import {useVbenModal} from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import {Descriptions, DescriptionsItem} from 'ant-design-vue'; import { Descriptions, DescriptionsItem } from 'ant-design-vue';
import {communityInfo} from '#/api/property/community'; import { communityInfo } from '#/api/property/community';
import {renderDict} from "#/utils/render"; import { renderDict } from '#/utils/render';
const [BasicModal, modalApi] = useVbenModal({ const [BasicModal, modalApi] = useVbenModal({
onOpenChange: handleOpenChange, onOpenChange: handleOpenChange,
@@ -13,14 +13,14 @@ const [BasicModal, modalApi] = useVbenModal({
}, },
}); });
const communityDetail = shallowRef<null | Community>(null); const communityDetail = shallowRef<null | CommunityVO>(null);
async function handleOpenChange(open: boolean) { async function handleOpenChange(open: boolean) {
if (!open) { if (!open) {
return null; return null;
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const {id} = modalApi.getData() as { id: number | string }; const { id } = modalApi.getData() as { id: number | string };
const response = await communityInfo(id); const response = await communityInfo(id);
communityDetail.value = response; communityDetail.value = response;
modalApi.modalLoading(false); modalApi.modalLoading(false);
@@ -28,18 +28,27 @@ async function handleOpenChange(open: boolean) {
</script> </script>
<template> <template>
<BasicModal :footer="false" :fullscreen-button="false" title="小区管理信息" class="w-[70%]"> <BasicModal
<Descriptions v-if="communityDetail" size="small" :column="2" bordered :labelStyle="{width:'100px'}"> :footer="false"
:fullscreen-button="false"
title="小区管理信息"
class="w-[70%]"
>
<Descriptions
v-if="communityDetail"
size="small"
:column="2"
bordered
:labelStyle="{ width: '100px' }"
>
<DescriptionsItem label="小区名称"> <DescriptionsItem label="小区名称">
{{ communityDetail.communityName }} {{ communityDetail.communityName }}
</DescriptionsItem> </DescriptionsItem>
<DescriptionsItem label="小区编码"> <DescriptionsItem
{{ communityDetail.communityCode }} label="小区类型"
</DescriptionsItem> v-if="communityDetail.communityType != null"
<DescriptionsItem label="小区类型" v-if="communityDetail.communityType!=null"> >
<component <component :is="renderDict(communityDetail.communityType, 'wy_sqlx')" />
:is="renderDict(communityDetail.communityType,'wy_sqlx')"
/>
</DescriptionsItem> </DescriptionsItem>
<DescriptionsItem label="省"> <DescriptionsItem label="省">
{{ communityDetail.province }} {{ communityDetail.province }}
@@ -62,12 +71,7 @@ async function handleOpenChange(open: boolean) {
<DescriptionsItem label="小图图片"> <DescriptionsItem label="小图图片">
{{ communityDetail.img }} {{ communityDetail.img }}
</DescriptionsItem> </DescriptionsItem>
<DescriptionsItem label="组织编码">
{{ communityDetail.orgCode }}
</DescriptionsItem>
<DescriptionsItem label="修改时间">
{{ communityDetail.modifyTime }}
</DescriptionsItem>
</Descriptions> </Descriptions>
</BasicModal> </BasicModal>
</template> </template>

View File

@@ -3,13 +3,20 @@ import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils'; import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { communityAdd, communityInfo, communityUpdate } from '#/api/property/community'; import {
communityAdd,
communityInfo,
communityUpdate,
} from '#/api/property/community';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data'; import { modalSchema } from './data';
import { getCityAreaTreeList } from '#/api/property/cityArea';
import type { CityAreaVO } from '#/api/property/cityArea/model';
import type { CommunityForm } from '#/api/property/community/model';
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
@@ -21,13 +28,13 @@ const title = computed(() => {
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
// 默认占满两列 // 默认占满两列
formItemClass: 'col-span-2', formItemClass: 'col-span-1',
// 默认label宽度 px // 默认label宽度 px
labelWidth: 80, labelWidth: 80,
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
componentProps: { componentProps: {
class: 'w-full', class: 'w-full',
} },
}, },
schema: modalSchema(), schema: modalSchema(),
showDefaultActions: false, showDefaultActions: false,
@@ -43,7 +50,7 @@ const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
const [BasicModal, modalApi] = useVbenModal({ const [BasicModal, modalApi] = useVbenModal({
// 在这里更改宽度 // 在这里更改宽度
class: 'w-[550px]', class: 'w-[60%]',
fullscreenButton: false, fullscreenButton: false,
onBeforeClose, onBeforeClose,
onClosed: handleClosed, onClosed: handleClosed,
@@ -53,20 +60,20 @@ const [BasicModal, modalApi] = useVbenModal({
return null; return null;
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string }; const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id; isUpdate.value = !!id;
if (isUpdate.value && id) { if (isUpdate.value && id) {
const record = await communityInfo(id); const record = await communityInfo(id);
await formApi.setValues(record); await formApi.setValues(record);
} }
setupDeptSelect();
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
}); });
let currentSelectNode: any = null;
async function handleConfirm() { async function handleConfirm() {
try { try {
modalApi.lock(true); modalApi.lock(true);
@@ -75,7 +82,8 @@ async function handleConfirm() {
return; return;
} }
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次 // getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues()); const data: CommunityForm = cloneDeep(await formApi.getValues());
data.cityFullName = currentSelectNode.fullName;
await (isUpdate.value ? communityUpdate(data) : communityAdd(data)); await (isUpdate.value ? communityUpdate(data) : communityAdd(data));
resetInitialized(); resetInitialized();
emit('reload'); emit('reload');
@@ -87,6 +95,57 @@ async function handleConfirm() {
} }
} }
/**
* 初始化城市
*/
async function setupDeptSelect() {
const areaList = await getCityAreaTreeList();
// 选中后显示在输入框的值 即父节点 / 子节点
// addFullName(areaList, 'areaName', ' / ');
const splitStr = '/';
handleNode(
areaList,
'areaName',
splitStr,
function (node: any, parentNode: any) {
node.fullCode = parentNode
? parentNode.fullCode + splitStr + node.areaCode
: node.areaCode;
if (node.areaLevel != '303') {
node.disabled = true;
}
},
);
formApi.updateSchema([
{
componentProps: () => ({
class: 'w-full',
fieldNames: {
key: 'id',
label: 'areaName',
value: 'fullCode',
children: 'children',
},
getPopupContainer,
async onSelect(fullCode: any, node: CityAreaVO) {
currentSelectNode = node;
},
placeholder: '请选择城市',
showSearch: true,
treeData: areaList,
treeDefaultExpandAll: true,
treeLine: { showLeafIcon: false },
// 筛选的字段
treeNodeFilterProp: 'areaName',
// 选中后显示在输入框的值
treeNodeLabelProp: 'fullName',
}),
fieldName: 'cityFullCode',
},
]);
}
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();
@@ -98,4 +157,3 @@ async function handleClosed() {
<BasicForm /> <BasicForm />
</BasicModal> </BasicModal>
</template> </template>

View File

@@ -1,15 +1,16 @@
import type { FormSchemaGetter } from '#/adapter/form'; import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import { getPopupContainer } from '@vben/utils';
import { getDictOptions } from '#/utils/dict';
import { DictEnum } from '@vben/constants';
export const querySchema: FormSchemaGetter = () => [ export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'communityName',
label: '社区',
},
{ {
component: 'Select', component: 'Select',
componentProps: {}, componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.wy_sqlx),
},
fieldName: 'communityType', fieldName: 'communityType',
label: '社区类型', label: '社区类型',
}, },
@@ -18,11 +19,6 @@ export const querySchema: FormSchemaGetter = () => [
fieldName: 'propertyCompany', fieldName: 'propertyCompany',
label: '物业公司', label: '物业公司',
}, },
{
component: 'Input',
fieldName: 'contactPhone',
label: '联系电话',
},
]; ];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新 // 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
@@ -36,18 +32,11 @@ export const columns: VxeGridProps['columns'] = [
{ {
title: '社区类型', title: '社区类型',
field: 'communityType', field: 'communityType',
slots: { default: 'communityType' },
}, },
{ {
title: '', title: '城市',
field: 'province', field: 'cityFullName',
},
{
title: '市',
field: 'city',
},
{
title: '区',
field: 'district',
}, },
{ {
title: '地址', title: '地址',
@@ -62,11 +51,11 @@ export const columns: VxeGridProps['columns'] = [
field: 'lat', field: 'lat',
}, },
{ {
title: '占地面积(平方米)', title: '占地面积',
field: 'area', field: 'area',
}, },
{ {
title: '', title: '建成时间',
field: 'builtYear', field: 'builtYear',
}, },
{ {
@@ -81,10 +70,6 @@ export const columns: VxeGridProps['columns'] = [
title: '社区描述', title: '社区描述',
field: 'description', field: 'description',
}, },
{
title: '小图图片',
field: 'img',
},
{ {
field: 'action', field: 'action',
fixed: 'right', fixed: 'right',
@@ -114,10 +99,20 @@ export const modalSchema: FormSchemaGetter = () => [
label: '社区类型', label: '社区类型',
fieldName: 'communityType', fieldName: 'communityType',
component: 'Select', component: 'Select',
componentProps: {}, componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.wy_sqlx),
},
rules: 'selectRequired', rules: 'selectRequired',
}, },
{ {
component: 'TreeSelect',
fieldName: 'cityFullCode',
defaultValue: undefined,
label: '城市',
rules: 'selectRequired',
},
/*{
label: '省', label: '省',
fieldName: 'province', fieldName: 'province',
component: 'Input', component: 'Input',
@@ -134,7 +129,7 @@ export const modalSchema: FormSchemaGetter = () => [
fieldName: 'district', fieldName: 'district',
component: 'Input', component: 'Input',
rules: 'required', rules: 'required',
}, },*/
{ {
label: '地址', label: '地址',
fieldName: 'addr', fieldName: 'addr',
@@ -145,27 +140,25 @@ export const modalSchema: FormSchemaGetter = () => [
label: '经度', label: '经度',
fieldName: 'lon', fieldName: 'lon',
component: 'Input', component: 'Input',
rules: 'required',
}, },
{ {
label: '维度', label: '维度',
fieldName: 'lat', fieldName: 'lat',
component: 'Input', component: 'Input',
rules: 'required',
}, },
{ {
label: '占地面积(平方米)', label: '占地面积',
fieldName: 'area', fieldName: 'area',
component: 'Input', component: 'Input',
}, },
{ {
label: '', label: '建成时间',
fieldName: 'builtYear', fieldName: 'builtYear',
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
showTime: true, showTime: true,
format: 'YYYY-MM-DD HH:mm:ss', format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'YYYY-MM-DD',
}, },
}, },
{ {
@@ -184,8 +177,12 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Textarea', component: 'Textarea',
}, },
{ {
label: '小图图片', label: '人像图片',
fieldName: 'img', fieldName: 'img',
component: 'Input', component: 'ImageUpload',
componentProps: {
maxCount: 1, // 最大上传文件数 默认为1 为1会绑定为string而非string[]类型
},
formItemClass: 'col-span-2',
}, },
]; ];

View File

@@ -6,13 +6,13 @@ import { ref } from 'vue';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui'; import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils'; import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue'; import { Modal, Popconfirm, Space, Tag } from 'ant-design-vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { import {
useVbenVxeGrid, useVbenVxeGrid,
vxeCheckboxChecked, vxeCheckboxChecked,
type VxeGridProps type VxeGridProps
} from '#/adapter/vxe-table'; } from '#/adapter/vxe-table';
import { import {
@@ -138,8 +138,8 @@ function handleDownloadExcel() {
<a-button <a-button
:disabled="!vxeCheckboxChecked(tableApi)" :disabled="!vxeCheckboxChecked(tableApi)"
danger danger
type="primary" type="primary"
v-access:code="['property:community:remove']" v-access:code="['property:community:remove']"
@click="handleMultiDelete"> @click="handleMultiDelete">
{{ $t('pages.common.delete') }} {{ $t('pages.common.delete') }}
</a-button> </a-button>
@@ -176,6 +176,12 @@ function handleDownloadExcel() {
</Popconfirm> </Popconfirm>
</Space> </Space>
</template> </template>
<template #communityType="{ row }">
<Tag v-if="row.community_type == 1" color="#108ee9">园区</Tag>
<Tag v-else color="#2db7f5">小区</Tag>
</template>
</BasicTable> </BasicTable>
<CommunityModal @reload="tableApi.query()" /> <CommunityModal @reload="tableApi.query()" />
</Page> </Page>

View File

@@ -1,12 +1,11 @@
import type { FormSchemaGetter } from '#/adapter/form'; import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
export const querySchema: FormSchemaGetter = () => [ export const querySchema: FormSchemaGetter = () => [
{ {
component: 'Input', component: 'Input',
fieldName: 'communityName', fieldName: 'floorName',
label: '社区', label: '楼层名称',
}, },
]; ];
@@ -15,21 +14,17 @@ export const querySchema: FormSchemaGetter = () => [
export const columns: VxeGridProps['columns'] = [ export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 }, { type: 'checkbox', width: 60 },
{ {
title: '单元编码', title: '楼层名称',
field: 'unitId',
},
{
title: '楼层数名称',
field: 'floorName', field: 'floorName',
}, },
{ {
title: '楼层号', title: '楼层号',
field: 'floorNumber', field: 'floorNumber',
}, },
{ /* {
title: '楼层类型', title: '楼层类型',
field: 'floorType', field: 'floorType',
}, },*/
{ {
title: '房间数量', title: '房间数量',
field: 'roomCount', field: 'roomCount',
@@ -58,10 +53,11 @@ export const modalSchema: FormSchemaGetter = () => [
}, },
}, },
{ {
label: '单元编码', component: 'TreeSelect',
fieldName: 'unitId', fieldName: 'unitId',
component: 'Input', defaultValue: undefined,
rules: 'required', label: '社区建筑',
rules: 'selectRequired',
}, },
{ {
label: '楼层数名称', label: '楼层数名称',
@@ -75,13 +71,12 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Input', component: 'Input',
rules: 'required', rules: 'required',
}, },
{ /*{
label: '楼层类型', label: '楼层类型',
fieldName: 'floorType', fieldName: 'floorType',
component: 'Select', component: 'Select',
componentProps: { componentProps: {},
}, },*/
},
{ {
label: '房间数量', label: '房间数量',
fieldName: 'roomCount', fieldName: 'roomCount',

View File

@@ -3,13 +3,14 @@ import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils'; import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { floorAdd, floorInfo, floorUpdate } from '#/api/property/floor'; import { floorAdd, floorInfo, floorUpdate } from '#/api/property/floor';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data'; import { modalSchema } from './data';
import { communityTree } from '#/api/property/community';
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
@@ -53,16 +54,14 @@ const [BasicModal, modalApi] = useVbenModal({
return null; return null;
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
setupCommunitySelect()
const { id } = modalApi.getData() as { id?: number | string }; const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id; isUpdate.value = !!id;
if (isUpdate.value && id) { if (isUpdate.value && id) {
const record = await floorInfo(id); const record = await floorInfo(id);
await formApi.setValues(record); await formApi.setValues(record);
} }
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
}); });
@@ -87,6 +86,45 @@ async function handleConfirm() {
} }
} }
/**
* 初始化城市
*/
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() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();

View File

@@ -1,5 +1,8 @@
import type { FormSchemaGetter } from '#/adapter/form'; import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import { getPopupContainer } from '@vben/utils';
import { getDictOptions } from '#/utils/dict';
import { DictEnum } from '@vben/constants';
export const querySchema: FormSchemaGetter = () => [ export const querySchema: FormSchemaGetter = () => [
{ {
@@ -11,15 +14,17 @@ export const querySchema: FormSchemaGetter = () => [
component: 'Input', component: 'Input',
fieldName: 'orientation', fieldName: 'orientation',
label: '朝向', label: '朝向',
}, componentProps: {
{ getPopupContainer,
component: 'Input', options: getDictOptions(DictEnum.wy_direction_towards),
fieldName: 'isForSale', },
label: '是否可售',
}, },
{ {
component: 'Select', component: 'Select',
componentProps: {}, componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.wy_fjzt),
},
fieldName: 'status', fieldName: 'status',
label: '状态', label: '状态',
}, },
@@ -29,20 +34,16 @@ export const querySchema: FormSchemaGetter = () => [
// export const columns: () => VxeGridProps['columns'] = () => [ // export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [ export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 }, { type: 'checkbox', width: 60 },
{
title: '所属楼层ID',
field: 'floorId',
},
{ {
title: '房间号', title: '房间号',
field: 'roomNumber', field: 'roomNumber',
}, },
{ {
title: '房间类型', title: '房间类型',
field: 'roomType', field: 'roomTypeName',
}, },
{ {
title: '面积(平方米)', title: '面积',
field: 'area', field: 'area',
}, },
{ {
@@ -51,7 +52,7 @@ export const columns: VxeGridProps['columns'] = [
}, },
{ {
title: '朝向', title: '朝向',
field: 'orientation', field: 'orientationName',
}, },
{ {
title: '是否可售', title: '是否可售',
@@ -59,7 +60,7 @@ export const columns: VxeGridProps['columns'] = [
}, },
{ {
title: '状态', title: '状态',
field: 'status', field: 'statusName',
}, },
{ {
field: 'action', field: 'action',
@@ -81,13 +82,14 @@ export const modalSchema: FormSchemaGetter = () => [
}, },
}, },
{ {
label: '所属楼层ID', component: 'TreeSelect',
fieldName: 'floorId', fieldName: 'floorId',
component: 'Input', defaultValue: undefined,
rules: 'required', label: '社区建筑',
rules: 'selectRequired',
}, },
{ {
label: '房间号(如101,202)', label: '房间号',
fieldName: 'roomNumber', fieldName: 'roomNumber',
component: 'Input', component: 'Input',
rules: 'required', rules: 'required',
@@ -96,10 +98,13 @@ export const modalSchema: FormSchemaGetter = () => [
label: '房间类型', label: '房间类型',
fieldName: 'roomType', fieldName: 'roomType',
component: 'Select', component: 'Select',
componentProps: {}, componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.wy_room_type),
},
}, },
{ {
label: '面积(平方米)', label: '面积',
fieldName: 'area', fieldName: 'area',
component: 'Input', component: 'Input',
}, },
@@ -111,7 +116,11 @@ export const modalSchema: FormSchemaGetter = () => [
{ {
label: '朝向', label: '朝向',
fieldName: 'orientation', fieldName: 'orientation',
component: 'Input', component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.wy_direction_towards),
},
}, },
{ {
label: '是否可售', label: '是否可售',
@@ -122,6 +131,9 @@ export const modalSchema: FormSchemaGetter = () => [
label: '状态', label: '状态',
fieldName: 'status', fieldName: 'status',
component: 'Select', component: 'Select',
componentProps: {}, componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.wy_fjzt),
},
}, },
]; ];

View File

@@ -3,16 +3,13 @@ import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { roomAdd, roomInfo, roomUpdate } from '#/api/property/room'; import { roomAdd, roomInfo, roomUpdate } from '#/api/property/room';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data'; import { modalSchema } from './data';
import { communityTree } from '#/api/property/community';
import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils';
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false); const isUpdate = ref(false);
const title = computed(() => { const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add'); return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
@@ -21,7 +18,7 @@ const title = computed(() => {
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
// 默认占满两列 // 默认占满两列
formItemClass: 'col-span-2', formItemClass: 'col-span-1',
// 默认label宽度 px // 默认label宽度 px
labelWidth: 80, labelWidth: 80,
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
@@ -43,7 +40,7 @@ const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
const [BasicModal, modalApi] = useVbenModal({ const [BasicModal, modalApi] = useVbenModal({
// 在这里更改宽度 // 在这里更改宽度
class: 'w-[550px]', class: 'w-[60%]',
fullscreenButton: false, fullscreenButton: false,
onBeforeClose, onBeforeClose,
onClosed: handleClosed, onClosed: handleClosed,
@@ -56,7 +53,7 @@ const [BasicModal, modalApi] = useVbenModal({
const { id } = modalApi.getData() as { id?: number | string }; const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id; isUpdate.value = !!id;
setupCommunitySelect()
if (isUpdate.value && id) { if (isUpdate.value && id) {
const record = await roomInfo(id); const record = await roomInfo(id);
await formApi.setValues(record); await formApi.setValues(record);
@@ -87,6 +84,45 @@ async function handleConfirm() {
} }
} }
/**
* 初始化城市
*/
async function setupCommunitySelect() {
const areaList = await communityTree(4);
// 选中后显示在输入框的值 即父节点 / 子节点
// addFullName(areaList, 'areaName', ' / ');
const splitStr = '/';
handleNode(areaList, 'label', splitStr, function (node: any) {
if (node.level != 4) {
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: 'floorId',
},
]);
}
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();

View File

@@ -1,12 +1,11 @@
import type { FormSchemaGetter } from '#/adapter/form'; import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
export const querySchema: FormSchemaGetter = () => [ export const querySchema: FormSchemaGetter = () => [
{ {
component: 'Input', component: 'TreeSelect',
fieldName: 'communityName', fieldName: 'unitName',
label: '社区', label: '单元名称',
}, },
]; ];
@@ -14,10 +13,6 @@ export const querySchema: FormSchemaGetter = () => [
// export const columns: () => VxeGridProps['columns'] = () => [ // export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [ export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 }, { type: 'checkbox', width: 60 },
{
title: '建筑名称',
field: 'buildingId',
},
{ {
title: '单元名称', title: '单元名称',
field: 'unitName', field: 'unitName',
@@ -54,10 +49,11 @@ export const modalSchema: FormSchemaGetter = () => [
}, },
}, },
{ {
label: '建筑名称', component: 'TreeSelect',
fieldName: 'buildingId', fieldName: 'buildingId',
component: 'Input', defaultValue: undefined,
rules: 'required', label: '社区建筑',
rules: 'selectRequired',
}, },
{ {
label: '单元名称', label: '单元名称',

View File

@@ -1,25 +1,16 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Recordable } from '@vben/types';
import { ref } from 'vue';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui'; import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils'; import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue'; import { Modal, Popconfirm, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import { import {
unitExport, useVbenVxeGrid,
unitList, vxeCheckboxChecked,
unitRemove, type VxeGridProps,
} from '#/api/property/unit'; } from '#/adapter/vxe-table';
import { unitExport, unitList, unitRemove } from '#/api/property/unit';
import type { UnitForm } from '#/api/property/unit/model'; import type { UnitForm } from '#/api/property/unit/model';
import { commonDownloadExcel } from '#/utils/file/download'; import { commonDownloadExcel } from '#/utils/file/download';
@@ -76,7 +67,7 @@ const gridOptions: VxeGridProps = {
keyField: 'id', keyField: 'id',
}, },
// 表格全局唯一表示 保存列配置需要用到 // 表格全局唯一表示 保存列配置需要用到
id: 'property-unit-index' id: 'property-unit-index',
}; };
const [BasicTable, tableApi] = useVbenVxeGrid({ const [BasicTable, tableApi] = useVbenVxeGrid({
@@ -138,9 +129,10 @@ function handleDownloadExcel() {
<a-button <a-button
:disabled="!vxeCheckboxChecked(tableApi)" :disabled="!vxeCheckboxChecked(tableApi)"
danger danger
type="primary" type="primary"
v-access:code="['property:unit:remove']" v-access:code="['property:unit:remove']"
@click="handleMultiDelete"> @click="handleMultiDelete"
>
{{ $t('pages.common.delete') }} {{ $t('pages.common.delete') }}
</a-button> </a-button>
<a-button <a-button

View File

@@ -3,13 +3,14 @@ import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils'; import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { unitAdd, unitInfo, unitUpdate } from '#/api/property/unit'; import { unitAdd, unitInfo, unitUpdate } from '#/api/property/unit';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data'; import { modalSchema } from './data';
import { communityTree } from '#/api/property/community';
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
@@ -27,7 +28,7 @@ const [BasicForm, formApi] = useVbenForm({
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
componentProps: { componentProps: {
class: 'w-full', class: 'w-full',
} },
}, },
schema: modalSchema(), schema: modalSchema(),
showDefaultActions: false, showDefaultActions: false,
@@ -53,16 +54,14 @@ const [BasicModal, modalApi] = useVbenModal({
return null; return null;
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string }; const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id; isUpdate.value = !!id;
if (isUpdate.value && id) { if (isUpdate.value && id) {
const record = await unitInfo(id); const record = await unitInfo(id);
await formApi.setValues(record); await formApi.setValues(record);
} }
setupCommunitySelect();
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
}); });
@@ -87,6 +86,45 @@ async function handleConfirm() {
} }
} }
/**
* 初始化城市
*/
async function setupCommunitySelect() {
const areaList = await communityTree(2);
// 选中后显示在输入框的值 即父节点 / 子节点
// addFullName(areaList, 'areaName', ' / ');
const splitStr = '/';
handleNode(areaList, 'label', splitStr, function (node: any) {
if (node.level != 2) {
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: 'buildingId',
},
]);
}
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();
@@ -98,4 +136,3 @@ async function handleClosed() {
<BasicForm /> <BasicForm />
</BasicModal> </BasicModal>
</template> </template>

View File

@@ -1,13 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from 'vue'; import type { PropType } from 'vue';
import type { DeptTree } from '#/api/system/user/model'; import type { DeptTree } from '#/api/system/user/model';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { SyncOutlined } from '@ant-design/icons-vue'; import { SyncOutlined } from '@ant-design/icons-vue';
import { Empty, InputSearch, Skeleton, Tree } from 'ant-design-vue'; import { Empty, InputSearch, Skeleton, Tree } from 'ant-design-vue';
import { getDeptTree } from '#/api/system/user'; import { getDeptTree } from '#/api/system/user';
defineOptions({ inheritAttrs: false }); defineOptions({ inheritAttrs: false });
@@ -45,9 +41,7 @@ async function loadTree() {
showTreeSkeleton.value = true; showTreeSkeleton.value = true;
searchValue.value = ''; searchValue.value = '';
selectDeptId.value = []; selectDeptId.value = [];
const ret = await getDeptTree(); const ret = await getDeptTree();
deptTreeArray.value = ret; deptTreeArray.value = ret;
showTreeSkeleton.value = false; showTreeSkeleton.value = false;
} }

View File

@@ -1,76 +1,33 @@
# EXAMPLE USAGE: #pre-commit:
# parallel: true
# commands:
# code-workspace:
# run: pnpm vsh code-workspace --auto-commit
# lint-md:
# run: pnpm prettier --cache --ignore-unknown --write {staged_files}
# glob: '*.md'
# lint-vue:
# run: pnpm prettier --write {staged_files} && pnpm eslint --cache --fix {staged_files} && pnpm stylelint --fix --allow-empty-input {staged_files}
# glob: '*.vue'
# lint-js:
# run: pnpm prettier --cache --ignore-unknown --write {staged_files} && pnpm eslint --cache --fix {staged_files}
# glob: '*.{js,jsx,ts,tsx}'
# lint-style:
# run: pnpm prettier --cache --ignore-unknown --write {staged_files} && pnpm stylelint --fix --allow-empty-input {staged_files}
# glob: '*.{scss,less,styl,html,vue,css}'
# lint-package:
# run: pnpm prettier --cache --write {staged_files}
# glob: 'package.json'
# lint-json:
# run: pnpm prettier --cache --write --parser json {staged_files}
# glob: '{!(package)*.json,*.code-snippets,.!(browserslist)*rc}'
# #
# Refer for explanation to following link: #post-merge:
# https://lefthook.dev/configuration/ # commands:
# install:
# run: pnpm install
# #
# pre-push: #commit-msg:
# jobs: # commands:
# - name: packages audit # commitlint:
# tags: # run: pnpm exec commitlint --edit $1
# - frontend
# - security
# run: yarn audit
#
# - name: gems audit
# tags:
# - backend
# - security
# run: bundle audit
#
# pre-commit:
# parallel: true
# jobs:
# - run: yarn eslint {staged_files}
# glob: "*.{js,ts,jsx,tsx}"
#
# - name: rubocop
# glob: "*.rb"
# exclude:
# - config/application.rb
# - config/routes.rb
# run: bundle exec rubocop --force-exclusion {all_files}
#
# - name: govet
# files: git ls-files -m
# glob: "*.go"
# run: go vet {files}
#
# - script: "hello.js"
# runner: node
#
# - script: "hello.go"
# runner: go run
pre-commit:
parallel: true
commands:
code-workspace:
run: pnpm vsh code-workspace --auto-commit
lint-md:
run: pnpm prettier --cache --ignore-unknown --write {staged_files}
glob: '*.md'
lint-vue:
run: pnpm prettier --write {staged_files} && pnpm eslint --cache --fix {staged_files} && pnpm stylelint --fix --allow-empty-input {staged_files}
glob: '*.vue'
lint-js:
run: pnpm prettier --cache --ignore-unknown --write {staged_files} && pnpm eslint --cache --fix {staged_files}
glob: '*.{js,jsx,ts,tsx}'
lint-style:
run: pnpm prettier --cache --ignore-unknown --write {staged_files} && pnpm stylelint --fix --allow-empty-input {staged_files}
glob: '*.{scss,less,styl,html,vue,css}'
lint-package:
run: pnpm prettier --cache --write {staged_files}
glob: 'package.json'
lint-json:
run: pnpm prettier --cache --write --parser json {staged_files}
glob: '{!(package)*.json,*.code-snippets,.!(browserslist)*rc}'
post-merge:
commands:
install:
run: pnpm install
commit-msg:
commands:
commitlint:
run: pnpm exec commitlint --edit $1

View File

@@ -15,6 +15,11 @@ export const DictEnum = {
WF_FORM_TYPE: 'wf_form_type', // 表单类型 WF_FORM_TYPE: 'wf_form_type', // 表单类型
WF_TASK_STATUS: 'wf_task_status', // 任务状态 WF_TASK_STATUS: 'wf_task_status', // 任务状态
WY_SF: 'wy_sf', WY_SF: 'wy_sf',
wy_sqlx: 'wy_sqlx', // 社区类型
sys_build_use_type: 'sis_build_use_type', // 建筑用途
wy_room_type: 'room_type', // 房间类型
wy_fjzt: 'wy_fjzt', // 房间状态
wy_direction_towards: 'direction_towards', // 房间朝向
SIS_ACCESS_CONTROL_DEVICE_TYPE: 'sis_access_control_device_type', SIS_ACCESS_CONTROL_DEVICE_TYPE: 'sis_access_control_device_type',
SIS_LIB_TYPE: 'sis_lib_type', SIS_LIB_TYPE: 'sis_lib_type',

View File

@@ -276,6 +276,43 @@ export function addFullName(
}); });
} }
/**
*
* 添加全名 如 祖先节点-父节点-子节点
* @param treeData 已经是tree数据
* @param labelName 标签的字段名称
* @param splitStr 分隔符
* @param callback 回调函数
* @returns void 无返回值 会修改原始数据
*/
export function handleNode(
treeData: any[],
labelName = 'label',
splitStr = '-',
callback: Function,
) {
function addFullNameProperty(
node: any,
parentNames: any[] = [],
parentNode: any = null,
) {
const fullNameParts = [...parentNames, node[labelName]];
node.fullName = fullNameParts.join(splitStr);
if (callback) {
callback(node, parentNode);
}
if (node.children && node.children.length > 0) {
node.children.forEach((childNode: any) => {
addFullNameProperty(childNode, fullNameParts, node);
});
}
}
treeData.forEach((item: any) => {
addFullNameProperty(item);
});
}
/** /**
* https://blog.csdn.net/Web_J/article/details/129281329 * https://blog.csdn.net/Web_J/article/details/129281329
* 给出节点nodeId 找到所有父节点ID * 给出节点nodeId 找到所有父节点ID