refactor(sis): 移动电梯楼层授权功能
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
d9621a0416
commit
9a14f9bc77
@ -1,116 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref } from 'vue'
|
|
||||||
|
|
||||||
import { cloneDeep } from '@vben/utils'
|
|
||||||
import { useVbenModal } from '@vben/common-ui'
|
|
||||||
import { useVbenForm } from '#/adapter/form'
|
|
||||||
import { queryByUnitId } from '#/api/property/floor'
|
|
||||||
import { refAdd, refQuery } from '#/api/sis/elevatorInfo'
|
|
||||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'
|
|
||||||
|
|
||||||
const dataForm = ref<any>()
|
|
||||||
const title = ref('楼层授权')
|
|
||||||
|
|
||||||
const [BasicForm, formApi] = useVbenForm({
|
|
||||||
// 所有表单项共用,可单独在表单内覆盖
|
|
||||||
commonConfig: {
|
|
||||||
// 默认占满两列
|
|
||||||
formItemClass: 'col-span-1',
|
|
||||||
// 所有表单项
|
|
||||||
componentProps: {
|
|
||||||
class: 'w-full',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
layout: 'horizontal',
|
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
component: 'CheckboxGroup',
|
|
||||||
componentProps: {
|
|
||||||
name: 'cname',
|
|
||||||
options: [],
|
|
||||||
},
|
|
||||||
defaultValue: [],
|
|
||||||
fieldName: 'floorNums',
|
|
||||||
label: '楼层'
|
|
||||||
}],
|
|
||||||
wrapperClass: 'grid-cols-1',
|
|
||||||
showDefaultActions: false
|
|
||||||
})
|
|
||||||
|
|
||||||
const [BasicModal, modalApi] = useVbenModal({
|
|
||||||
// 在这里更改宽度
|
|
||||||
class: 'w-[700px]',
|
|
||||||
fullscreenButton: false,
|
|
||||||
loading: true,
|
|
||||||
onClosed: handleClosed,
|
|
||||||
onConfirm: handleConfirm,
|
|
||||||
onOpened: handleInit,
|
|
||||||
})
|
|
||||||
|
|
||||||
function handleInit() {
|
|
||||||
dataForm.value = modalApi.getData()
|
|
||||||
const { unitId } = modalApi.getData()
|
|
||||||
queryByUnitId(unitId).then((res) => {
|
|
||||||
const arr: any[] = []
|
|
||||||
res.forEach((item) => {
|
|
||||||
arr.push({
|
|
||||||
label: item.floorName,
|
|
||||||
value: item.floorNumber,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
formApi.updateSchema([
|
|
||||||
{
|
|
||||||
fieldName: 'floorNums',
|
|
||||||
componentProps: { options: arr },
|
|
||||||
}
|
|
||||||
])
|
|
||||||
handleChecked()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleChecked() {
|
|
||||||
const { elevatorId } = modalApi.getData()
|
|
||||||
refQuery(elevatorId).then((res) => {
|
|
||||||
const arr: any[] = []
|
|
||||||
res.forEach((item) => {
|
|
||||||
arr.push(item.floorNum)
|
|
||||||
})
|
|
||||||
formApi.setFieldValue('floorNums', arr)
|
|
||||||
}).finally(() => {
|
|
||||||
modalApi.setState({ loading: false });
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const { resetInitialized } = useBeforeCloseDiff(
|
|
||||||
{
|
|
||||||
initializedGetter: defaultFormValueGetter(formApi),
|
|
||||||
currentGetter: defaultFormValueGetter(formApi),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
async function handleConfirm() {
|
|
||||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
|
||||||
const data = cloneDeep(await formApi.getValues())
|
|
||||||
const params = {
|
|
||||||
elevatorId: dataForm.value.elevatorId,
|
|
||||||
floorNums: data.floorNums
|
|
||||||
}
|
|
||||||
refAdd(params).finally(() => {
|
|
||||||
modalApi.close()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleClosed() {
|
|
||||||
await formApi.resetForm()
|
|
||||||
resetInitialized()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<BasicModal :title="title">
|
|
||||||
<BasicForm />
|
|
||||||
</BasicModal>
|
|
||||||
</template>
|
|
@ -25,7 +25,6 @@ import { commonDownloadExcel } from '#/utils/file/download';
|
|||||||
|
|
||||||
import elevatorInfoModal from './elevatorInfo-modal.vue';
|
import elevatorInfoModal from './elevatorInfo-modal.vue';
|
||||||
import { columns, querySchema } from './data';
|
import { columns, querySchema } from './data';
|
||||||
import floorAuthModal from './floorAuth-modal.vue';
|
|
||||||
|
|
||||||
const formOptions: VbenFormProps = {
|
const formOptions: VbenFormProps = {
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
@ -89,10 +88,6 @@ const [ElevatorInfoModal, modalApi] = useVbenModal({
|
|||||||
connectedComponent: elevatorInfoModal,
|
connectedComponent: elevatorInfoModal,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [FloorAuthModal, floorAuthModalApi] = useVbenModal({
|
|
||||||
connectedComponent: floorAuthModal,
|
|
||||||
});
|
|
||||||
|
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
modalApi.setData({});
|
modalApi.setData({});
|
||||||
modalApi.open();
|
modalApi.open();
|
||||||
@ -128,11 +123,6 @@ function handleDownloadExcel() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAuth(row: Required<ElevatorInfoForm>) {
|
|
||||||
floorAuthModalApi.setData({ unitId: row.unitId, elevatorId: row.elevatorId });
|
|
||||||
floorAuthModalApi.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -165,8 +155,6 @@ function handleAuth(row: Required<ElevatorInfoForm>) {
|
|||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<Space>
|
<Space>
|
||||||
<ghost-button @click.stop="handleAuth(row)">楼层授权</ghost-button>
|
|
||||||
|
|
||||||
<ghost-button
|
<ghost-button
|
||||||
v-access:code="['sis:elevatorInfo:edit']"
|
v-access:code="['sis:elevatorInfo:edit']"
|
||||||
@click.stop="handleEdit(row)"
|
@click.stop="handleEdit(row)"
|
||||||
@ -191,6 +179,5 @@ function handleAuth(row: Required<ElevatorInfoForm>) {
|
|||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
<ElevatorInfoModal @reload="tableApi.query()" />
|
<ElevatorInfoModal @reload="tableApi.query()" />
|
||||||
<FloorAuthModal @reload="tableApi.query()" />
|
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user