绿植管理

This commit is contained in:
FLL
2025-07-02 11:02:14 +08:00
parent b6f7558aaa
commit 79fe4c6412
17 changed files with 1031 additions and 133 deletions

View File

@@ -0,0 +1,229 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';
import {h} from "vue";
import {Rate} from "ant-design-vue";
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'maintainName',
label: '养护名称',
},
{
component: 'Select',
componentProps: {
},
fieldName: 'state',
label: '处理状态',
},
];
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '养护名称',
field: 'maintainName',
},
{
title: '小区id',
field: 'communityId',
},
{
title: '建筑id',
field: 'buildingId',
},
{
title: '楼层id',
field: 'floorId',
},
{
title: '服务类型',
field: 'serveType',
},
{
title: '养护周期类型',
field: 'periodType',
slots: {
default: ({ row }) => {
// 可选从DictEnum中获取 DictEnum.WY_TIME_UNIT 便于维护
return renderDict(row.periodType, 'wy_time_unit');
},
},
},
{
title: '养护周期频次',
field: 'periodFrequency',
},
{
title: '订单id',
field: 'orderId',
},
{
title: '计划执行时间',
field: 'startTime',
},
{
title: '计划完成时间',
field: 'endTime',
},
{
title: '巡检结果',
field: 'inspectResult',
},
{
title: '处理措施',
field: 'measure',
},
{
title: '客户评分',
field: 'customerScore',
slots: {
default: ({ row }) => {
return h(Rate, {
value: row.customerScore || 0,
disabled: true,
});
},
},
width:200
},
{
title: '客户反馈',
field: 'customerAdvice',
},
{
title: '处理状态',
field: 'state',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '养护名称',
fieldName: 'maintainName',
component: 'Input',
rules: 'required',
},
{
label: '小区id',
fieldName: 'communityId',
component: 'Input',
rules: 'required',
},
{
label: '建筑id',
fieldName: 'buildingId',
component: 'Input',
rules: 'required',
},
{
label: '楼层id',
fieldName: 'floorId',
component: 'Input',
rules: 'required',
},
{
label: '服务类型',
fieldName: 'serveType',
component: 'Select',
componentProps: {
},
rules: 'selectRequired',
},
{
label: '养护周期类型',
fieldName: 'periodType',
component: 'Select',
componentProps: {
// 可选从DictEnum中获取 DictEnum.WY_TIME_UNIT 便于维护
options: getDictOptions('wy_time_unit'),
},
rules: 'selectRequired',
},
{
label: '养护周期频次',
fieldName: 'periodFrequency',
component: 'Input',
rules: 'required',
},
{
label: '订单id',
fieldName: 'orderId',
component: 'Input',
rules: 'required',
},
{
label: '计划执行时间',
fieldName: 'startTime',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
},
{
label: '计划完成时间',
fieldName: 'endTime',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
},
rules: 'required',
},
{
label: '巡检结果',
fieldName: 'inspectResult',
component: 'Input',
},
{
label: '处理措施',
fieldName: 'measure',
component: 'Input',
},
{
label: '客户评分',
fieldName: 'customerScore',
component: 'Rate',
componentProps: {
allowHalf: false,
count: 5,
tooltips: ['1星', '2星', '3星', '4星', '5星'],
defaultValue: 0
},
rules: 'required',
},
{
label: '客户反馈',
fieldName: 'customerAdvice',
component: 'Textarea',
},
{
label: '处理状态',
fieldName: 'state',
component: 'Select',
componentProps: {
},
},
];

View File

@@ -1,5 +1,143 @@
<script setup lang="ts">
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import {
orderMaintainList,
orderMaintainRemove,
} from '#/api/property/conservationManagement';
import type { OrderMaintainForm } from '#/api/property/conservationManagement/model';
import orderMaintainModal from './orderMaintain-modal.vue';
import { columns, querySchema } from './data';
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
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,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await orderMaintainList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
id: 'property-orderMaintain-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [OrderMaintainModal, modalApi] = useVbenModal({
connectedComponent: orderMaintainModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<OrderMaintainForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<OrderMaintainForm>) {
await orderMaintainRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<OrderMaintainForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await orderMaintainRemove(ids);
await tableApi.query();
},
});
}
</script>
<template>
<div>
养护管理
</div>
</template>
<Page :auto-content-height="true">
<BasicTable table-title="绿植租赁-订单养护管理列表">
<template #toolbar-tools>
<Space>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['property:orderMaintain:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['property:orderMaintain:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['property:orderMaintain:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['property:orderMaintain:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<OrderMaintainModal @reload="tableApi.query()" />
</Page>
</template>

View File

@@ -0,0 +1,93 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { orderMaintainAdd, orderMaintainInfo, orderMaintainUpdate } from '#/api/property/conservationManagement';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
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: {
formItemClass: 'col-span-2',
labelWidth: 80,
componentProps: {
class: 'w-full',
}
},
schema: modalSchema(),
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{
initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi),
},
);
const [BasicModal, modalApi] = useVbenModal({
class: 'w-[550px]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await orderMaintainInfo(id);
await formApi.setValues(record);
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? orderMaintainUpdate(data) : orderMaintainAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm />
</BasicModal>
</template>