refactor(property): 入驻人员表单变动
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
53f5640f02
commit
532869a4a3
@ -144,9 +144,9 @@ export interface PersonForm extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
authGroupId?: string | number
|
authGroupId?: string | number
|
||||||
|
|
||||||
begDate?: string
|
authBegDate?: string
|
||||||
|
|
||||||
endDate?: string
|
authEndDate?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonQuery extends PageQuery {
|
export interface PersonQuery extends PageQuery {
|
||||||
|
@ -5,6 +5,7 @@ import { renderDict } from "#/utils/render"
|
|||||||
import { resident_unitList } from "#/api/property/resident/unit"
|
import { resident_unitList } from "#/api/property/resident/unit"
|
||||||
import { authGroupList } from '#/api/sis/authGroup'
|
import { authGroupList } from '#/api/sis/authGroup'
|
||||||
import type { AuthGroupVO, AuthGroupQuery } from '#/api/sis/authGroup/model'
|
import type { AuthGroupVO, AuthGroupQuery } from '#/api/sis/authGroup/model'
|
||||||
|
import { toRaw } from 'vue'
|
||||||
|
|
||||||
|
|
||||||
export const querySchema: FormSchemaGetter = () => [
|
export const querySchema: FormSchemaGetter = () => [
|
||||||
@ -151,15 +152,16 @@ export const modalSchema: FormSchemaGetter = () => [
|
|||||||
label: '性别',
|
label: '性别',
|
||||||
fieldName: 'gender',
|
fieldName: 'gender',
|
||||||
component: "Select",
|
component: "Select",
|
||||||
componentProps:{
|
componentProps: {
|
||||||
options: getDictOptions('sys_user_sex')
|
options: getDictOptions('sys_user_sex')
|
||||||
},
|
},
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '身份证号',
|
label: '证件号',
|
||||||
fieldName: 'idCard',
|
fieldName: 'idCard',
|
||||||
component: "Input",
|
component: "Input",
|
||||||
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '邮箱',
|
label: '邮箱',
|
||||||
@ -221,12 +223,23 @@ export const modalSchema: FormSchemaGetter = () => [
|
|||||||
format: 'YYYY-MM-DD HH:mm:ss',
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
},
|
},
|
||||||
rules: 'required',
|
dependencies: {
|
||||||
|
show: (values) => {
|
||||||
|
return typeof (values.id) !== 'undefined'
|
||||||
|
},
|
||||||
|
triggerFields: ['id'],
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '通行权限组',
|
label: '通行权限组',
|
||||||
fieldName: 'authGroupId',
|
fieldName: 'authGroupId',
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
|
dependencies: {
|
||||||
|
show: (values) => {
|
||||||
|
return typeof (values.id) !== 'undefined'
|
||||||
|
},
|
||||||
|
triggerFields: ['id'],
|
||||||
|
},
|
||||||
componentProps: {
|
componentProps: {
|
||||||
resultField: 'list', // 根据API返回结构调整
|
resultField: 'list', // 根据API返回结构调整
|
||||||
labelField: 'name',
|
labelField: 'name',
|
||||||
@ -244,8 +257,7 @@ export const modalSchema: FormSchemaGetter = () => [
|
|||||||
}
|
}
|
||||||
return authGroupArr
|
return authGroupArr
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
rules: 'required',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '人脸图片',
|
label: '人脸图片',
|
||||||
|
@ -1,56 +1,60 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {computed, reactive, ref} from 'vue';
|
import { computed, reactive, 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 } from "@vben/utils";
|
||||||
import {useVbenForm} from '#/adapter/form';
|
import { useVbenForm } from "#/adapter/form";
|
||||||
import {personAdd, personInfo, personUpdate} from '#/api/property/resident/person';
|
import {
|
||||||
import {defaultFormValueGetter, useBeforeCloseDiff} from '#/utils/popup';
|
personAdd,
|
||||||
import {modalSchema} from './data';
|
personInfo,
|
||||||
import QueryUserList from './query-user-list.vue'
|
personUpdate,
|
||||||
import QueryUnitList from './query-unit-list.vue'
|
} from "#/api/property/resident/person";
|
||||||
|
import { defaultFormValueGetter, useBeforeCloseDiff } from "#/utils/popup";
|
||||||
|
import { modalSchema } from "./data";
|
||||||
|
import QueryUserList from "./query-user-list.vue";
|
||||||
|
import QueryUnitList from "./query-unit-list.vue";
|
||||||
|
|
||||||
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");
|
||||||
});
|
});
|
||||||
let userInfo = reactive({
|
let userInfo = reactive({
|
||||||
userId: '',
|
userId: "",
|
||||||
userName: '',
|
userName: "",
|
||||||
phone: '',
|
phone: "",
|
||||||
gender: '',
|
gender: "",
|
||||||
});
|
});
|
||||||
let unitName = ref('');
|
let unitName = ref("");
|
||||||
const userId = ref<number | string>(0);
|
const userId = ref<number | string>(0);
|
||||||
const unitId = ref<string>('');
|
const unitId = ref<string>("");
|
||||||
const [BasicForm, formApi] = useVbenForm({
|
const [BasicForm, formApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
// 默认占满两列
|
// 默认占满两列
|
||||||
formItemClass: 'col-span-1',
|
formItemClass: "col-span-1",
|
||||||
// 默认label宽度 px
|
// 默认label宽度 px
|
||||||
labelWidth: 100,
|
labelWidth: 100,
|
||||||
// 通用配置项 会影响到所有表单项
|
// 通用配置项 会影响到所有表单项
|
||||||
componentProps: {
|
componentProps: {
|
||||||
class: 'w-full',
|
class: "w-full",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
schema: modalSchema(),
|
schema: modalSchema(),
|
||||||
showDefaultActions: false,
|
showDefaultActions: false,
|
||||||
wrapperClass: 'grid-cols-2',
|
wrapperClass: "grid-cols-2",
|
||||||
});
|
});
|
||||||
|
|
||||||
const {onBeforeClose, markInitialized, resetInitialized} = useBeforeCloseDiff(
|
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||||
{
|
{
|
||||||
initializedGetter: defaultFormValueGetter(formApi),
|
initializedGetter: defaultFormValueGetter(formApi),
|
||||||
currentGetter: defaultFormValueGetter(formApi),
|
currentGetter: defaultFormValueGetter(formApi),
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const [BasicModal, modalApi] = useVbenModal({
|
const [BasicModal, modalApi] = useVbenModal({
|
||||||
// 在这里更改宽度
|
// 在这里更改宽度
|
||||||
class: 'w-[70%]',
|
class: "w-[70%]",
|
||||||
fullscreenButton: false,
|
fullscreenButton: false,
|
||||||
onBeforeClose,
|
onBeforeClose,
|
||||||
onClosed: handleClosed,
|
onClosed: handleClosed,
|
||||||
@ -61,14 +65,14 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
}
|
}
|
||||||
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 personInfo(id);
|
const record = await personInfo(id);
|
||||||
userId.value = record.userId;
|
userId.value = record.userId;
|
||||||
unitId.value = record.unitId.toString();
|
unitId.value = record.unitId.toString();
|
||||||
record.state=record.state?.toString()
|
record.state = record.state?.toString();
|
||||||
await formApi.setValues(record);
|
await formApi.setValues(record);
|
||||||
}
|
}
|
||||||
await markInitialized();
|
await markInitialized();
|
||||||
@ -80,7 +84,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
async function handleConfirm() {
|
async function handleConfirm() {
|
||||||
try {
|
try {
|
||||||
modalApi.lock(true);
|
modalApi.lock(true);
|
||||||
const {valid} = await formApi.validate();
|
const { valid } = await formApi.validate();
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -91,15 +95,17 @@ async function handleConfirm() {
|
|||||||
// data.phone = userInfo.phone
|
// data.phone = userInfo.phone
|
||||||
// data.gender = userInfo.gender
|
// data.gender = userInfo.gender
|
||||||
// }
|
// }
|
||||||
if(unitName.value){
|
if (unitName.value) {
|
||||||
data.unitName = unitName.value
|
data.unitName = unitName.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.begDate = data.authTime[0]
|
if (isUpdate.value && data.authTime !== 0) {
|
||||||
data.endDate = data.authTime[1]
|
data.authBegDate = data.authTime[0];
|
||||||
|
data.authEndDate = data.authTime[1];
|
||||||
|
}
|
||||||
await (isUpdate.value ? personUpdate(data) : personAdd(data));
|
await (isUpdate.value ? personUpdate(data) : personAdd(data));
|
||||||
resetInitialized();
|
resetInitialized();
|
||||||
emit('reload');
|
emit("reload");
|
||||||
modalApi.close();
|
modalApi.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -126,10 +132,16 @@ function getUnitInfo(unit: { name: string }) {
|
|||||||
<BasicModal :title="title">
|
<BasicModal :title="title">
|
||||||
<BasicForm>
|
<BasicForm>
|
||||||
<template #userId="slotProps">
|
<template #userId="slotProps">
|
||||||
<QueryUserList @update:userInfo="getUserInfo" v-bind="slotProps" :isUpdate="isUpdate" :userId="userId"/>
|
<QueryUserList @update:userInfo="getUserInfo"
|
||||||
|
v-bind="slotProps"
|
||||||
|
:isUpdate="isUpdate"
|
||||||
|
:userId="userId" />
|
||||||
</template>
|
</template>
|
||||||
<template #unitId="slotProps">
|
<template #unitId="slotProps">
|
||||||
<QueryUnitList @update:unitInfo="getUnitInfo" v-bind="slotProps" :isUpdate="isUpdate" :unitId="unitId"/>
|
<QueryUnitList @update:unitInfo="getUnitInfo"
|
||||||
|
v-bind="slotProps"
|
||||||
|
:isUpdate="isUpdate"
|
||||||
|
:unitId="unitId" />
|
||||||
</template>
|
</template>
|
||||||
</BasicForm>
|
</BasicForm>
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
|
Loading…
Reference in New Issue
Block a user