2025-07-10 17:33:46 +08:00
|
|
|
<script setup lang="ts">
|
2025-08-06 16:42:37 +08:00
|
|
|
import { computed, ref } from 'vue';
|
2025-07-10 17:33:46 +08:00
|
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
|
|
import { $t } from '@vben/locales';
|
|
|
|
import { cloneDeep } from '@vben/utils';
|
|
|
|
import { useVbenForm } from '#/adapter/form';
|
2025-08-06 16:42:37 +08:00
|
|
|
import {
|
|
|
|
inspectionRouteAdd,
|
|
|
|
inspectionRouteInfo,
|
|
|
|
inspectionRouteList,
|
|
|
|
inspectionRouteUpdate
|
|
|
|
} from '#/api/property/inspectionManagement/inspectionRoute';
|
2025-07-10 17:33:46 +08:00
|
|
|
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
2025-08-04 17:06:09 +08:00
|
|
|
import {
|
|
|
|
inspectionPointList,
|
|
|
|
} from '#/api/property/inspectionManagement/inspectionPoint';
|
2025-08-05 17:26:09 +08:00
|
|
|
import {modalSchema} from './data';
|
2025-07-10 17:33:46 +08:00
|
|
|
|
|
|
|
const emit = defineEmits<{ reload: [] }>();
|
|
|
|
|
|
|
|
const isUpdate = ref(false);
|
|
|
|
const title = computed(() => {
|
|
|
|
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
|
|
|
});
|
|
|
|
|
|
|
|
const [BasicForm, formApi] = useVbenForm({
|
|
|
|
commonConfig: {
|
2025-08-04 17:06:09 +08:00
|
|
|
formItemClass: 'col-span-1',
|
2025-07-11 17:07:29 +08:00
|
|
|
labelWidth: 100,
|
2025-07-10 17:33:46 +08:00
|
|
|
componentProps: {
|
|
|
|
class: 'w-full',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
schema: modalSchema(),
|
|
|
|
showDefaultActions: false,
|
|
|
|
wrapperClass: 'grid-cols-2',
|
|
|
|
});
|
|
|
|
|
|
|
|
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
|
|
|
{
|
|
|
|
initializedGetter: defaultFormValueGetter(formApi),
|
|
|
|
currentGetter: defaultFormValueGetter(formApi),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2025-08-06 14:09:26 +08:00
|
|
|
const pointList = ref<any[]>([]);
|
2025-07-10 17:33:46 +08:00
|
|
|
const [BasicModal, modalApi] = useVbenModal({
|
2025-08-04 17:06:09 +08:00
|
|
|
class: 'w-[60%]',
|
2025-07-10 17:33:46 +08:00
|
|
|
fullscreenButton: false,
|
|
|
|
onBeforeClose,
|
|
|
|
onClosed: handleClosed,
|
|
|
|
onConfirm: handleConfirm,
|
|
|
|
onOpenChange: async (isOpen) => {
|
|
|
|
if (!isOpen) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
modalApi.modalLoading(true);
|
2025-08-04 17:06:09 +08:00
|
|
|
await queryWorkOrdersType()
|
2025-07-10 17:33:46 +08:00
|
|
|
const { id } = modalApi.getData() as { id?: number | string };
|
|
|
|
isUpdate.value = !!id;
|
|
|
|
|
|
|
|
if (isUpdate.value && id) {
|
|
|
|
const record = await inspectionRouteInfo(id);
|
2025-08-06 16:42:37 +08:00
|
|
|
pointList.value = (record.inspectionRoutePointVoList || []).map(item => ({
|
|
|
|
pointId: item.pointId ?? '',
|
|
|
|
pointName: item.pointName ?? '',
|
|
|
|
}));
|
|
|
|
await tableApi.reload();
|
2025-08-06 14:09:26 +08:00
|
|
|
console.log(pointList.value,111)
|
2025-07-10 17:33:46 +08:00
|
|
|
await formApi.setValues(record);
|
|
|
|
}
|
|
|
|
await markInitialized();
|
|
|
|
modalApi.modalLoading(false);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
async function handleConfirm() {
|
|
|
|
try {
|
|
|
|
modalApi.lock(true);
|
|
|
|
const { valid } = await formApi.validate();
|
|
|
|
if (!valid) {
|
|
|
|
return;
|
|
|
|
}
|
2025-08-06 14:09:26 +08:00
|
|
|
let data = {
|
|
|
|
...cloneDeep(await formApi.getValues()),
|
|
|
|
inspectionRoutePointBoList:[pointData.value]
|
|
|
|
}
|
|
|
|
console.log(data,333)
|
2025-07-10 17:33:46 +08:00
|
|
|
await (isUpdate.value ? inspectionRouteUpdate(data) : inspectionRouteAdd(data));
|
|
|
|
resetInitialized();
|
|
|
|
emit('reload');
|
|
|
|
modalApi.close();
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
} finally {
|
|
|
|
modalApi.lock(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function handleClosed() {
|
|
|
|
await formApi.resetForm();
|
|
|
|
resetInitialized();
|
|
|
|
}
|
2025-08-04 17:06:09 +08:00
|
|
|
|
|
|
|
async function queryWorkOrdersType() {
|
|
|
|
let params = {
|
|
|
|
pageSize: 1000,
|
|
|
|
pageNum: 1
|
|
|
|
}
|
|
|
|
const res = await inspectionPointList(params)
|
|
|
|
const options = res.rows.map((item) => ({
|
|
|
|
label: item.pointName,
|
|
|
|
value: item.id,
|
|
|
|
}));
|
2025-08-05 17:26:09 +08:00
|
|
|
tableApi.formApi.updateSchema([{
|
2025-08-04 17:06:09 +08:00
|
|
|
componentProps: () => ({
|
|
|
|
options: options,
|
|
|
|
showSearch: true,
|
|
|
|
filterOption: filterOption,
|
|
|
|
}),
|
|
|
|
fieldName: 'pointId',
|
|
|
|
}])
|
|
|
|
}
|
|
|
|
|
|
|
|
const filterOption = (input: string, option: any) => {
|
|
|
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
|
|
};
|
2025-08-05 17:26:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
//!!!!!!
|
|
|
|
import { Page, type VbenFormProps } from '@vben/common-ui';
|
|
|
|
import { Space } from 'ant-design-vue';
|
|
|
|
import {
|
|
|
|
useVbenVxeGrid,
|
|
|
|
type VxeGridProps
|
|
|
|
} from '#/adapter/vxe-table';
|
2025-08-06 14:09:26 +08:00
|
|
|
import dayjs from 'dayjs';
|
2025-08-05 17:26:09 +08:00
|
|
|
import type { InspectionRouteForm } from '#/api/property/inspectionManagement/inspectionRoute/model';
|
|
|
|
import pointModal from './point-modal.vue';
|
|
|
|
import { columnsPoint, querySchemaPoint } from './data';
|
|
|
|
|
|
|
|
const formOptions: VbenFormProps = {
|
|
|
|
commonConfig: {
|
|
|
|
labelWidth: 90,
|
|
|
|
componentProps: {
|
|
|
|
allowClear: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
schema: querySchemaPoint(),
|
|
|
|
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
|
|
|
};
|
|
|
|
|
|
|
|
const gridOptions: VxeGridProps = {
|
|
|
|
checkboxConfig: {
|
|
|
|
highlight: true,
|
|
|
|
reserve: true,
|
|
|
|
},
|
|
|
|
columns: columnsPoint,
|
|
|
|
height: 'auto',
|
|
|
|
keepSource: true,
|
|
|
|
pagerConfig: {},
|
|
|
|
rowConfig: {
|
|
|
|
keyField: 'id',
|
|
|
|
},
|
2025-08-06 16:42:37 +08:00
|
|
|
id: 'property-inspectionRoutePoint-index'
|
2025-08-05 17:26:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const [BasicTable, tableApi] = useVbenVxeGrid({
|
|
|
|
formOptions,
|
|
|
|
gridOptions,
|
|
|
|
});
|
|
|
|
|
|
|
|
const [PointModal, pointModalApi] = useVbenModal({
|
|
|
|
connectedComponent: pointModal,
|
|
|
|
});
|
|
|
|
|
|
|
|
function handleAdd() {
|
|
|
|
pointModalApi.setData({});
|
|
|
|
pointModalApi.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function handleEdit(row: Required<InspectionRouteForm>) {
|
2025-08-06 14:09:26 +08:00
|
|
|
pointModalApi.setData({ id: row.id });
|
|
|
|
pointModalApi.open();
|
2025-08-05 17:26:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const pointData = ref({})
|
|
|
|
const handlePoint = (data) => {
|
2025-08-06 14:09:26 +08:00
|
|
|
data.startTime = dayjs(data.startTime).format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
data.endTime = dayjs(data.endTime).format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
pointData.value = data;
|
2025-08-05 17:26:09 +08:00
|
|
|
};
|
2025-07-10 17:33:46 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<BasicModal :title="title">
|
|
|
|
<BasicForm />
|
2025-08-05 17:26:09 +08:00
|
|
|
<Page :auto-content-height="true" style="background-color: #F1F3F6">
|
2025-08-06 16:42:37 +08:00
|
|
|
<BasicTable table-title="巡检点" :grid-options="gridOptions">
|
2025-08-05 17:26:09 +08:00
|
|
|
<template #toolbar-tools>
|
|
|
|
<Space>
|
|
|
|
<a-button
|
|
|
|
type="primary"
|
|
|
|
@click="handleAdd"
|
|
|
|
>
|
|
|
|
{{ $t('pages.common.add') }}
|
|
|
|
</a-button>
|
|
|
|
</Space>
|
|
|
|
</template>
|
|
|
|
<template #action="{ row }">
|
|
|
|
<Space>
|
|
|
|
<ghost-button
|
|
|
|
@click.stop="handleEdit(row)"
|
|
|
|
>
|
|
|
|
{{ '巡检点' }}
|
|
|
|
</ghost-button>
|
|
|
|
</Space>
|
|
|
|
</template>
|
|
|
|
</BasicTable>
|
|
|
|
<PointModal @reload="tableApi.query()" @update-data="handlePoint"/>
|
|
|
|
</Page>
|
2025-07-10 17:33:46 +08:00
|
|
|
</BasicModal>
|
|
|
|
</template>
|
|
|
|
|