1、入驻单位、人员优化
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
parent
ef24216dbc
commit
f01cb4abce
@ -1,6 +1,7 @@
|
||||
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||
|
||||
export interface FloorVO {
|
||||
id: string | number;
|
||||
/**
|
||||
* 社区编码
|
||||
*/
|
||||
|
@ -1,6 +1,9 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import {getDictOptions} from "#/utils/dict";
|
||||
import {renderDict} from "#/utils/render";
|
||||
import {resident_unitList} from "#/api/property/resident/unit";
|
||||
|
||||
|
||||
export const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
@ -8,6 +11,22 @@ export const querySchema: FormSchemaGetter = () => [
|
||||
fieldName: 'unitId',
|
||||
label: '所属单位',
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'unitId',
|
||||
label: '所属单位',
|
||||
componentProps: {
|
||||
api: getUnitList,
|
||||
resultField: 'data',
|
||||
labelField: 'label',
|
||||
valueField: 'value',
|
||||
immediate: true,
|
||||
debounceTime: 500,
|
||||
allowClear: true,
|
||||
placeholder: '请选择所属单位',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'userName',
|
||||
@ -16,7 +35,7 @@ export const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions('wy_state'),
|
||||
options: getDictOptions('wy_rzryzt'),
|
||||
},
|
||||
fieldName: 'state',
|
||||
label: '状态',
|
||||
@ -49,6 +68,11 @@ export const columns: VxeGridProps['columns'] = [
|
||||
{
|
||||
title: '性别',
|
||||
field: 'gender',
|
||||
slots:{
|
||||
default: ({row})=>{
|
||||
return renderDict(row.gender,'wy_rzryzt')
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'img',
|
||||
@ -75,7 +99,11 @@ export const columns: VxeGridProps['columns'] = [
|
||||
{
|
||||
title: '状态',
|
||||
field: 'state',
|
||||
// slots: { default: 'state' },
|
||||
slots:{
|
||||
default: ({row})=>{
|
||||
return renderDict(row.state,'wy_rzryzt')
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
@ -114,13 +142,13 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
formItemClass: 'col-span-2',
|
||||
rules:'selectRequired',
|
||||
},
|
||||
{
|
||||
label: '入驻位置',
|
||||
fieldName: 'locathon',
|
||||
component: 'Input',
|
||||
rules:'required',
|
||||
formItemClass: 'col-span-2',
|
||||
},
|
||||
// {
|
||||
// label: '入驻位置',
|
||||
// fieldName: 'locathon',
|
||||
// component: 'Input',
|
||||
// rules:'required',
|
||||
// formItemClass: 'col-span-2',
|
||||
// },
|
||||
{
|
||||
label: '人脸图片',
|
||||
fieldName: 'img',
|
||||
@ -131,7 +159,6 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
},
|
||||
|
||||
{
|
||||
label: '入驻时间',
|
||||
fieldName: 'time',
|
||||
@ -147,6 +174,14 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
fieldName: 'carNumber',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '人员状态',
|
||||
fieldName: 'state',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions('wy_rzryzt'),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
@ -235,3 +270,19 @@ export const carColumns: VxeGridProps['columns'] = [
|
||||
field: 'remark',
|
||||
},
|
||||
];
|
||||
export async function getUnitList(): Promise<{ value: number; label: string }[]> {
|
||||
const queryParam = {
|
||||
pageNum: 1000,
|
||||
pageSize: 1,
|
||||
};
|
||||
const res = await resident_unitList(queryParam);
|
||||
const data: { value: number; label: string }[] = [];
|
||||
|
||||
res.rows.forEach((r: any) => {
|
||||
data.push({
|
||||
value: r.name,
|
||||
label: r.id,
|
||||
});
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
import {
|
||||
personExport,
|
||||
personList,
|
||||
personRemove,
|
||||
personRemove, personUpdate,
|
||||
} from '#/api/property/resident/person';
|
||||
import type { PersonForm } from '#/api/property/resident/person/model';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
@ -22,7 +22,8 @@ import { commonDownloadExcel } from '#/utils/file/download';
|
||||
import personModal from './person-modal.vue';
|
||||
import personDetail from './person-detail.vue';
|
||||
import { columns, querySchema } from './data';
|
||||
// import {TableSwitch} from "#/components/table";
|
||||
import {useAccess} from "@vben/access";
|
||||
import {TableSwitch} from "#/components/table";
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
commonConfig: {
|
||||
@ -44,8 +45,6 @@ const gridOptions: VxeGridProps = {
|
||||
// 点击行选中
|
||||
// trigger: 'row',
|
||||
},
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// columns: columns(),
|
||||
columns,
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
@ -80,6 +79,7 @@ const [PersonDetail, personDetailApi] = useVbenModal({
|
||||
connectedComponent: personDetail,
|
||||
});
|
||||
|
||||
const { hasAccessByCodes } = useAccess();
|
||||
|
||||
function handleAdd() {
|
||||
modalApi.setData({});
|
||||
@ -120,7 +120,6 @@ function handleInfo(row: Required<PersonForm>) {
|
||||
personDetailApi.setData({ id: row.id });
|
||||
personDetailApi.open();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -152,18 +151,20 @@ function handleInfo(row: Required<PersonForm>) {
|
||||
</Space>
|
||||
</template>
|
||||
<template #img="{ row }">
|
||||
<Avatar :src="row.img" />
|
||||
<Avatar :src="row.img" v-if="row.img" />
|
||||
<span v-else >无</span>
|
||||
</template>
|
||||
<template #state="{ row }">
|
||||
|
||||
<TableSwitch
|
||||
:checkedValue="1"
|
||||
:unCheckedValue="0"
|
||||
v-model:value="row.state"
|
||||
:api="() => personUpdate(row)"
|
||||
:disabled="!hasAccessByCodes(['property:person:edit'])"
|
||||
@reload="() => tableApi.query()"
|
||||
/>
|
||||
</template>
|
||||
<!-- <template #state="{ row }">-->
|
||||
<!-- <TableSwitch-->
|
||||
<!-- v-model:value="row.status"-->
|
||||
<!-- :api="() => personStatusChange(row)"-->
|
||||
<!-- :disabled="-->
|
||||
<!-- row.userId === 1 || !hasAccessByCodes(['system:user:edit'])-->
|
||||
<!-- "-->
|
||||
<!-- @reload="() => tableApi.query()"-->
|
||||
<!-- />-->
|
||||
<!-- </template>-->
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<ghost-button
|
||||
|
@ -8,11 +8,10 @@ import dayjs from 'dayjs';
|
||||
import duration from 'dayjs/plugin/duration';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
// import {personInfo} from '#/api/property/resident/person';
|
||||
import {personInfo} from '#/api/property/resident/person';
|
||||
import type {Person} from "#/api/property/resident/person/model";
|
||||
import {accessControlColumns,carColumns} from "#/views/property/resident/person/data";
|
||||
// import {personList} from "#/api/property/resident/person";
|
||||
// import {renderDict} from "#/utils/render";
|
||||
import {renderDict, renderDictValue} from "#/utils/render";
|
||||
|
||||
|
||||
dayjs.extend(duration);
|
||||
@ -36,11 +35,9 @@ async function handleOpenChange(open: boolean) {
|
||||
}
|
||||
modalApi.modalLoading(true);
|
||||
|
||||
// const {id} = modalApi.getData() as { id: number | string };
|
||||
// const response = await personInfo(id);
|
||||
const response = {id:1};
|
||||
const {id} = modalApi.getData() as { id: number | string };
|
||||
// 赋值
|
||||
personDetail.value = response;
|
||||
personDetail.value = await personInfo(id);
|
||||
|
||||
modalApi.modalLoading(false);
|
||||
}
|
||||
@ -52,25 +49,31 @@ async function handleOpenChange(open: boolean) {
|
||||
<BasicModal :footer="false" :fullscreen-button="false" title="入驻人员信息" class="w-[70%]">
|
||||
<Descriptions v-if="personDetail" size="small" :column="1" bordered :labelStyle="{width:'100px'}">
|
||||
<DescriptionsItem label="入驻人员">
|
||||
{{ '入驻人员' }}
|
||||
{{ personDetail.userName+'-'+personDetail.phone}}
|
||||
<!-- {{ personDetail.userName+'-'+renderDictValue(personDetail.gender,'sys_user_sex')+'-'+personDetail.phone}}-->
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="所属单位">
|
||||
{{ '单位名称' }}
|
||||
{{personDetail.unitName+'-'+personDetail.unitId }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="入驻位置">
|
||||
{{ '单位名称' }}
|
||||
{{ personDetail.locathon }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="人脸图片">
|
||||
{{ '单位名称' }}
|
||||
{{ personDetail.img }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="入驻时间">
|
||||
{{ '单位名称' }}
|
||||
{{ personDetail.time}}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="车牌号码">
|
||||
{{ '单位名称' }}
|
||||
{{personDetail.carNumber}}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="人员状态">
|
||||
<component
|
||||
:is="renderDict(personDetail.state,'wy_rzryzt')"
|
||||
/>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="备注">
|
||||
{{ '单位名称' }}
|
||||
{{ personDetail.remark }}
|
||||
</DescriptionsItem>
|
||||
|
||||
</Descriptions>
|
||||
@ -85,7 +88,7 @@ async function handleOpenChange(open: boolean) {
|
||||
</template>
|
||||
</Table>
|
||||
</TabPane>
|
||||
<TabPane key="2" tab="车辆记录">
|
||||
<TabPane key="2" tab="车辆记录" v-if="personDetail?.carNumber">
|
||||
<Table :dataSource="[]" :columns="carColumns" :pagination="false" >
|
||||
<template #bodyCell="{ column, index }">
|
||||
<template v-if="column.field === 'id'">
|
||||
|
@ -27,6 +27,7 @@ let userInfo = reactive({
|
||||
});
|
||||
let unitName = ref('');
|
||||
const userId = ref<number | string>(0);
|
||||
const unitId = ref<number | string>(0);
|
||||
const [BasicForm, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
// 默认占满两列
|
||||
@ -69,7 +70,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
if (isUpdate.value && id) {
|
||||
const record = await personInfo(id);
|
||||
userId.value = record.userId;
|
||||
console.log(userId.value,'====================1111')
|
||||
unitId.value = record.unitId;
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
await markInitialized();
|
||||
@ -87,10 +88,12 @@ async function handleConfirm() {
|
||||
}
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
let data = cloneDeep(await formApi.getValues());
|
||||
if (!isUpdate.value) {
|
||||
if (userInfo) {
|
||||
data.userName = userInfo.userName
|
||||
data.phone = userInfo.phone
|
||||
data.gender = userInfo.gender
|
||||
}
|
||||
if(unitName.value){
|
||||
data.unitName = unitName.value
|
||||
}
|
||||
await (isUpdate.value ? personUpdate(data) : personAdd(data));
|
||||
@ -125,7 +128,7 @@ function getUnitInfo(unit: { name: string }) {
|
||||
<QueryUserList @update:userInfo="getUserInfo" v-bind="slotProps" :isUpdate="isUpdate" :userId="userId"/>
|
||||
</template>
|
||||
<template #unitId="slotProps">
|
||||
<QueryUnitList @update:unitInfo="getUnitInfo" v-bind="slotProps" :disabled="isUpdate"/>
|
||||
<QueryUnitList @update:unitInfo="getUnitInfo" v-bind="slotProps" :isUpdate="isUpdate" :unitId="unitId"/>
|
||||
</template>
|
||||
</BasicForm>
|
||||
</BasicModal>
|
||||
|
@ -1,13 +1,20 @@
|
||||
<script lang="ts" setup>
|
||||
import {ref} from 'vue';
|
||||
import {ref, watch} from 'vue';
|
||||
import {Select} from 'ant-design-vue';
|
||||
import {resident_unitList} from "#/api/property/resident/unit";
|
||||
import {resident_unitList,resident_unitInfo} from "#/api/property/resident/unit";
|
||||
|
||||
defineOptions({name: 'QueryUnitList'});
|
||||
|
||||
withDefaults(defineProps<{ disabled?: boolean; placeholder?: string }>(), {
|
||||
const props= withDefaults(defineProps<{
|
||||
disabled?: boolean;
|
||||
placeholder?: string;
|
||||
isUpdate?:boolean;
|
||||
unitId?:number;
|
||||
}>(), {
|
||||
disabled: false,
|
||||
placeholder: '可根据单位名称进行搜索...',
|
||||
isUpdate:false,
|
||||
unitId:0,
|
||||
});
|
||||
|
||||
async function queryUnit(value: string, callback: any) {
|
||||
@ -15,11 +22,14 @@ async function queryUnit(value: string, callback: any) {
|
||||
name: value,
|
||||
pageSize: 100,
|
||||
pageNum: 1,
|
||||
state:1,
|
||||
}
|
||||
const res = await resident_unitList(queryData);
|
||||
const options = res.rows.map((unit) => ({
|
||||
label: unit.name+'-'+unit.id,
|
||||
value: unit.id,
|
||||
name:unit.name,
|
||||
unitNumber:unit.unitNumber,
|
||||
}));
|
||||
callback(options);
|
||||
}
|
||||
@ -32,19 +42,33 @@ const handleSearch = (val: string) => {
|
||||
const emit = defineEmits(['update:unitInfo']);
|
||||
const handleChange = (val: string) => {
|
||||
value.value = val;
|
||||
const unitInfoStr = data.value.find(option => option.value === val)?.label;
|
||||
let arr = unitInfoStr.split('-')
|
||||
let unitInfo = {
|
||||
name: arr[0],
|
||||
unitNumber: arr[1],
|
||||
}
|
||||
const unitInfo = data.value.find(option => option.value === val);
|
||||
emit('update:unitInfo', unitInfo);
|
||||
};
|
||||
|
||||
async function getUnitInfo(val:number) {
|
||||
const unit = await resident_unitInfo(val)
|
||||
if (unit) {
|
||||
data.value = [{
|
||||
label: unit.name+'-'+unit.id,
|
||||
value: unit.id,
|
||||
name:unit.name,
|
||||
unitNumber:unit.id,
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.unitId,
|
||||
(newX) => {
|
||||
if (props.isUpdate) {
|
||||
getUnitInfo(newX)
|
||||
}
|
||||
}, {immediate: true})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- v-model:value="value"-->
|
||||
<Select
|
||||
v-model="value"
|
||||
show-search
|
||||
:placeholder="placeholder"
|
||||
style="width: 100%"
|
||||
|
@ -17,10 +17,10 @@ const props = withDefaults(defineProps<{
|
||||
isUpdate: false,
|
||||
userId: 0
|
||||
});
|
||||
watch(() => props.isUpdate,
|
||||
watch(() => props.userId,
|
||||
(newX) => {
|
||||
if (newX) {
|
||||
getUserInfo()
|
||||
if (props.isUpdate) {
|
||||
getUserInfo(newX)
|
||||
}
|
||||
}, {immediate: true})
|
||||
|
||||
@ -50,30 +50,33 @@ const handleSearch = (val: string) => {
|
||||
};
|
||||
const emit = defineEmits(['update:userInfo']);
|
||||
const handleChange = (val: string) => {
|
||||
// value.value = val;
|
||||
value.value = val;
|
||||
const userInfo = data.value.find(option => option.value === val);
|
||||
queryUser(val, (d: any[]) => (data.value = d));
|
||||
emit('update:userInfo', userInfo);
|
||||
};
|
||||
|
||||
async function getUserInfo() {
|
||||
console.log(value.value, '=============value')
|
||||
const user = await (await findUserInfo(value.value)).user
|
||||
console.log(user, '=================ss')
|
||||
async function getUserInfo(val:number|string) {
|
||||
if (!val) return;
|
||||
const res = await findUserInfo(val)
|
||||
const user = res.user
|
||||
if (user) {
|
||||
data.value = [{
|
||||
label: user.nickName + '-' + renderDictValue(user.sex, 'sys_user_sex') + '-' + user.phonenumber,
|
||||
// label: user.nickName + '-' + renderDictValue(user.sex, 'sys_user_sex') + '-' + user.phonenumber,
|
||||
label: user.nickName + '-' + user.phonenumber,
|
||||
value: user.userId,
|
||||
userName: user.userName,
|
||||
gender: user.sex,
|
||||
phone: user.phonenumber,
|
||||
}]
|
||||
emit('update:userInfo', data.value[0]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Select
|
||||
:disabled="isUpdate"
|
||||
v-model="value"
|
||||
show-search
|
||||
:placeholder="placeholder"
|
||||
|
@ -141,7 +141,10 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
{
|
||||
label: '入驻位置',
|
||||
fieldName: 'location',
|
||||
component: 'Input',
|
||||
component: 'Select',
|
||||
slots:{
|
||||
default:'location'
|
||||
},
|
||||
rules: 'required',
|
||||
formItemClass: 'col-span-2'
|
||||
},
|
||||
|
@ -10,6 +10,7 @@ import { resident_unitAdd, resident_unitInfo, resident_unitUpdate } from '#/api/
|
||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
||||
|
||||
import { modalSchema } from './data';
|
||||
import RoomSelect from "#/views/property/room/room-select.vue";
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
|
||||
@ -95,7 +96,11 @@ async function handleClosed() {
|
||||
|
||||
<template>
|
||||
<BasicModal :title="title">
|
||||
<BasicForm />
|
||||
<BasicForm>
|
||||
<template #location="slotProps">
|
||||
<RoomSelect v-bind="slotProps" :isUpdate="isUpdate" :level="2"/>
|
||||
</template>
|
||||
</BasicForm>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
|
218
apps/web-antd/src/views/property/room/room-select.vue
Normal file
218
apps/web-antd/src/views/property/room/room-select.vue
Normal file
@ -0,0 +1,218 @@
|
||||
<script lang="ts" setup>
|
||||
import {onMounted, ref, watch} from 'vue';
|
||||
import {Select} from 'ant-design-vue';
|
||||
import {communityList} from "#/api/property/community";
|
||||
import {buildingList} from "#/api/property/building";
|
||||
import {unitList} from "#/api/property/unit";
|
||||
import {floorList} from "#/api/property/floor";
|
||||
import {roomList} from "#/api/property/room";
|
||||
|
||||
defineOptions({name: 'RoomSelect'});
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
disabled?: boolean;
|
||||
isUpdate?: boolean;
|
||||
level?:number;
|
||||
}>(), {
|
||||
disabled: false,
|
||||
isUpdate: false,
|
||||
level:5
|
||||
});
|
||||
|
||||
|
||||
const communityData = ref<any[]>([]);
|
||||
const buildingData = ref<any[]>([]);
|
||||
const unitData = ref<any[]>([]);
|
||||
const floorData = ref<any[]>([]);
|
||||
const roomData = ref<any[]>([]);
|
||||
const communityValue = ref();
|
||||
const buildingValue = ref();
|
||||
const unitValue = ref();
|
||||
const floorValue = ref();
|
||||
const roomValue = ref();
|
||||
const changeData=ref();
|
||||
|
||||
onMounted(() => {
|
||||
queryCommunity()
|
||||
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:roomCode']);
|
||||
|
||||
async function queryCommunity() {
|
||||
const queryData = {
|
||||
pageSize: 100,
|
||||
pageNum: 1,
|
||||
state: 1,
|
||||
}
|
||||
const res = await communityList(queryData);
|
||||
communityData.value = res.rows.map((item) => ({
|
||||
label: item.communityName,
|
||||
value: item.id,
|
||||
}));
|
||||
}
|
||||
|
||||
async function queryBuilding() {
|
||||
const queryData = {
|
||||
pageSize: 100,
|
||||
pageNum: 1,
|
||||
state: 1,
|
||||
communityCode: communityValue.value
|
||||
}
|
||||
const res = await buildingList(queryData);
|
||||
buildingData.value = res.rows.map((item) => ({
|
||||
label: item.buildingName,
|
||||
value: item.id,
|
||||
}));
|
||||
}
|
||||
|
||||
async function queryUnit() {
|
||||
const queryData = {
|
||||
pageSize: 100,
|
||||
pageNum: 1,
|
||||
state: 1,
|
||||
buildingCode: buildingValue.value
|
||||
}
|
||||
const res = await unitList(queryData);
|
||||
unitData.value = res.rows.map((item) => ({
|
||||
label: item.unitName,
|
||||
value: item.id,
|
||||
}));
|
||||
}
|
||||
|
||||
async function queryFloor() {
|
||||
const queryData = {
|
||||
pageSize: 100,
|
||||
pageNum: 1,
|
||||
state: 1,
|
||||
unitCode: unitValue.value
|
||||
}
|
||||
const res = await floorList(queryData);
|
||||
floorData.value = res.rows.map((item) => ({
|
||||
label: item.floorName,
|
||||
value: item.id,
|
||||
}));
|
||||
}
|
||||
|
||||
async function queryRoom() {
|
||||
const queryData = {
|
||||
pageSize: 100,
|
||||
pageNum: 1,
|
||||
state: 1,
|
||||
floorCode: floorValue.value
|
||||
}
|
||||
const res = await roomList(queryData);
|
||||
roomData.value = res.rows.map((item) => ({
|
||||
label: item.roomCode,
|
||||
value: item.id,
|
||||
}));
|
||||
}
|
||||
|
||||
const handleChangeCommunity = (val: string) => {
|
||||
communityValue.value = val;
|
||||
buildingValue.value = undefined;
|
||||
unitValue.value = undefined;
|
||||
floorValue.value = undefined;
|
||||
roomValue.value = undefined;
|
||||
queryBuilding()
|
||||
};
|
||||
const handleChangeBuilding = (val: string) => {
|
||||
buildingValue.value = val;
|
||||
unitValue.value = undefined;
|
||||
floorValue.value = undefined;
|
||||
roomValue.value = undefined;
|
||||
queryUnit()
|
||||
};
|
||||
const handleChangeUnit = (val: string) => {
|
||||
unitValue.value = val;
|
||||
floorValue.value = undefined;
|
||||
roomValue.value = undefined;
|
||||
queryFloor()
|
||||
};
|
||||
const handleChangeFloor = (val: string) => {
|
||||
floorValue.value = val;
|
||||
roomValue.value = undefined;
|
||||
queryRoom()
|
||||
};
|
||||
const handleChangeRoom = (val: string) => {
|
||||
roomValue.value = val;
|
||||
};
|
||||
|
||||
watch(() => props.isUpdate,
|
||||
(newX) => {
|
||||
console.log(newX, '==========================')
|
||||
}, {immediate: true})
|
||||
watch(() => roomValue.value,
|
||||
(newX) => {
|
||||
emit('update:roomCode', newX);
|
||||
console.log(newX, '==========================roomCode')
|
||||
},)
|
||||
|
||||
const filterOption = (input: string, option: any) => {
|
||||
return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Select
|
||||
v-if="props.level>1"
|
||||
v-model:value="communityValue"
|
||||
show-search
|
||||
placeholder="请选择区域"
|
||||
:options="communityData"
|
||||
:filter-option="filterOption"
|
||||
@change="handleChangeCommunity"
|
||||
style="width: 20%"
|
||||
></Select>
|
||||
<Select
|
||||
v-if="props.level>1"
|
||||
v-model:value="buildingValue"
|
||||
show-search
|
||||
:disabled="!communityValue"
|
||||
placeholder="请选择建筑"
|
||||
:options="buildingData"
|
||||
:filter-option="filterOption"
|
||||
@change="handleChangeBuilding"
|
||||
@focus="queryBuilding"
|
||||
style="width: 20%"
|
||||
></Select>
|
||||
<Select
|
||||
v-if="props.level>2"
|
||||
v-model:value="unitValue"
|
||||
:disabled="!buildingValue"
|
||||
show-search
|
||||
placeholder="请选择单元"
|
||||
:options="unitData"
|
||||
:filter-option="filterOption"
|
||||
@change="handleChangeUnit"
|
||||
@focus="queryUnit"
|
||||
style="width: 20%"
|
||||
></Select>
|
||||
<Select
|
||||
v-if="props.level>3"
|
||||
v-model:value="floorValue"
|
||||
:disabled="!unitValue"
|
||||
show-search
|
||||
placeholder="请选择楼层"
|
||||
:options="floorData"
|
||||
:filter-option="filterOption"
|
||||
@change="handleChangeFloor"
|
||||
@focus="queryFloor"
|
||||
style="width: 20%"
|
||||
></Select>
|
||||
<Select
|
||||
v-if="props.level>4"
|
||||
v-model:value="roomValue"
|
||||
:disabled="!floorValue"
|
||||
show-search
|
||||
placeholder="请选择房间"
|
||||
:options="roomData"
|
||||
:filter-option="filterOption"
|
||||
@change="handleChangeRoom"
|
||||
@focus="queryRoom"
|
||||
style="width: 20%"
|
||||
></Select>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -1,12 +1,45 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import {communityList} from "#/api/property/community";
|
||||
import {buildingList} from "#/api/property/building";
|
||||
|
||||
|
||||
export const querySchema: FormSchemaGetter = () => [
|
||||
{
|
||||
component: 'Input',
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'communityCode',
|
||||
label: '所属区域',
|
||||
componentProps: (formModel, formActionType) => ({
|
||||
api: getCommunityList,
|
||||
resultField: 'data',
|
||||
labelField: 'label',
|
||||
valueField: 'value',
|
||||
immediate: true,
|
||||
debounceTime: 500,
|
||||
allowClear: true,
|
||||
placeholder: '请选择区域',
|
||||
onChange: () => {
|
||||
// 清空建筑字段
|
||||
formModel.buildingCode = undefined;
|
||||
// 更新表单值
|
||||
formActionType.setFieldValue('buildingCode', undefined);
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'buildingCode',
|
||||
label: '建筑名称',
|
||||
label: '所属建筑',
|
||||
componentProps:{
|
||||
api: getBuildingList,
|
||||
resultField: 'data',
|
||||
labelField: 'label',
|
||||
valueField: 'value',
|
||||
immediate: true,
|
||||
debounceTime: 500,
|
||||
allowClear: true,
|
||||
placeholder: '请选择建筑',
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
@ -18,25 +51,9 @@ export const querySchema: FormSchemaGetter = () => [
|
||||
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 },
|
||||
{
|
||||
@ -83,9 +100,41 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '建筑名称',
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'communityCode',
|
||||
label: '所属区域',
|
||||
componentProps: (formModel, formActionType) => ({
|
||||
api: getCommunityList,
|
||||
resultField: 'data',
|
||||
labelField: 'label',
|
||||
valueField: 'value',
|
||||
immediate: true,
|
||||
debounceTime: 500,
|
||||
allowClear: true,
|
||||
placeholder: '请选择区域',
|
||||
onChange: () => {
|
||||
// 清空建筑字段
|
||||
formModel.buildingCode = undefined;
|
||||
// 更新表单值
|
||||
formActionType.setFieldValue('buildingCode', undefined);
|
||||
},
|
||||
}),
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'buildingCode',
|
||||
component: 'Input',
|
||||
label: '所属建筑',
|
||||
componentProps: {
|
||||
api: getBuildingList,
|
||||
resultField: 'data',
|
||||
labelField: 'label',
|
||||
valueField: 'value',
|
||||
immediate: true,
|
||||
debounceTime: 500,
|
||||
allowClear: true,
|
||||
placeholder: '请选择建筑',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
@ -103,16 +152,69 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
{
|
||||
label: '单元层数',
|
||||
fieldName: 'floorCount',
|
||||
component: 'Input',
|
||||
component: 'InputNumber',
|
||||
rules: 'required',
|
||||
componentProps:{
|
||||
defaultValue:0,
|
||||
precision:0,
|
||||
min:0
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '单元户数',
|
||||
fieldName: 'householdCount',
|
||||
component: 'Input',
|
||||
component: 'InputNumber',
|
||||
rules: 'required',
|
||||
componentProps:{
|
||||
defaultValue:0,
|
||||
precision:0,
|
||||
min:0
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '楼梯数量',
|
||||
fieldName: 'stairCount',
|
||||
component: 'Input',
|
||||
component: 'InputNumber',
|
||||
rules: 'required',
|
||||
componentProps:{
|
||||
defaultValue:0,
|
||||
precision:0,
|
||||
min:0
|
||||
}
|
||||
},
|
||||
];
|
||||
//获取区域数据
|
||||
async function getCommunityList(): Promise<{ value: number; label: string }[]> {
|
||||
const queryParam = {
|
||||
pageNum: 1000,
|
||||
pageSize: 1,
|
||||
};
|
||||
const res = await communityList(queryParam);
|
||||
const data: { value: number; label: string }[] = [];
|
||||
res.rows.forEach((r: any) => {
|
||||
data.push({
|
||||
value: r.communityName,
|
||||
label: r.id,
|
||||
});
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
//获取建筑数据
|
||||
export async function getBuildingList(): Promise<{ value: number; label: string }[]> {
|
||||
const queryParam = {
|
||||
pageNum: 1000,
|
||||
pageSize: 1,
|
||||
};
|
||||
const res = await buildingList(queryParam);
|
||||
const data: { value: number; label: string }[] = [];
|
||||
|
||||
res.rows.forEach((r: any) => {
|
||||
data.push({
|
||||
value: r.buildingName,
|
||||
label: r.id,
|
||||
});
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,9 @@
|
||||
<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,
|
||||
@ -35,15 +31,6 @@ const formOptions: VbenFormProps = {
|
||||
},
|
||||
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 = {
|
||||
@ -55,8 +42,6 @@ const gridOptions: VxeGridProps = {
|
||||
// 点击行选中
|
||||
// trigger: 'row',
|
||||
},
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// columns: columns(),
|
||||
columns,
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
|
Loading…
Reference in New Issue
Block a user