2025-06-30 18:42:21 +08:00
|
|
|
|
import {
|
|
|
|
|
|
MyBetaModalFormProps,
|
|
|
|
|
|
MyButtons,
|
|
|
|
|
|
MyModalFormProps,
|
|
|
|
|
|
rulesHelper,
|
|
|
|
|
|
} from '@/common';
|
|
|
|
|
|
import { Selects } from '@/components/Select';
|
|
|
|
|
|
import { Apis } from '@/gen/Apis';
|
|
|
|
|
|
import { BetaSchemaForm, ProCard } from '@ant-design/pro-components';
|
|
|
|
|
|
import { Form, message } from 'antd';
|
|
|
|
|
|
|
|
|
|
|
|
export default function Update(props: MyBetaModalFormProps) {
|
|
|
|
|
|
const [form] = Form.useForm();
|
2025-07-17 13:58:54 +08:00
|
|
|
|
console.log(props.item, 'pppp');
|
2025-06-30 18:42:21 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<BetaSchemaForm<ApiTypes.Grid.Grids.Update>
|
|
|
|
|
|
{...MyModalFormProps.props}
|
2025-07-17 13:58:54 +08:00
|
|
|
|
title={`网格编辑`}
|
2025-06-30 18:42:21 +08:00
|
|
|
|
width="700px"
|
2025-09-08 17:22:58 +08:00
|
|
|
|
layout="horizontal"
|
|
|
|
|
|
labelCol={{ span: 4 }}
|
|
|
|
|
|
wrapperCol={{ span: 24 }}
|
|
|
|
|
|
labelAlign="right"
|
2025-06-30 18:42:21 +08:00
|
|
|
|
trigger={<MyButtons.Default title={`编辑`} size="small" type="link" />}
|
|
|
|
|
|
form={form}
|
2025-08-08 18:35:02 +08:00
|
|
|
|
key={new Date().getTime()}
|
2025-06-30 18:42:21 +08:00
|
|
|
|
onOpenChange={(open: any) => {
|
|
|
|
|
|
if (open) {
|
|
|
|
|
|
Apis.Grid.Grids.Show({ id: props?.item?.id }).then((res) => {
|
|
|
|
|
|
form.setFieldsValue(res?.data);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
|
values?.grid_ranges?.map((res: { asset_projects_id: string }) => {
|
|
|
|
|
|
res.asset_projects_id = props?.item?.id;
|
|
|
|
|
|
});
|
|
|
|
|
|
return Apis.Grid.Grids.Update({
|
|
|
|
|
|
...values,
|
|
|
|
|
|
id: props?.item?.id,
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
props.reload?.();
|
2025-07-17 13:58:54 +08:00
|
|
|
|
message.success('网格编辑成功');
|
2025-06-30 18:42:21 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => false);
|
|
|
|
|
|
}}
|
|
|
|
|
|
columns={[
|
|
|
|
|
|
Selects?.GetGridMark({
|
|
|
|
|
|
key: 'grid_mark',
|
2025-09-08 17:22:58 +08:00
|
|
|
|
title: '范围标识',
|
2025-06-30 18:42:21 +08:00
|
|
|
|
params: {
|
|
|
|
|
|
asset_projects_id: props?.item?.id,
|
|
|
|
|
|
},
|
|
|
|
|
|
colProps: { span: 24 },
|
|
|
|
|
|
formItemProps: { ...rulesHelper.text },
|
|
|
|
|
|
}),
|
|
|
|
|
|
{
|
|
|
|
|
|
valueType: 'formList',
|
|
|
|
|
|
dataIndex: 'grid_ranges',
|
|
|
|
|
|
colProps: { span: 24 },
|
|
|
|
|
|
initialValue: [''],
|
|
|
|
|
|
formItemProps: { ...rulesHelper.array },
|
|
|
|
|
|
fieldProps: {
|
|
|
|
|
|
copyIconProps: false,
|
|
|
|
|
|
creatorButtonProps: {
|
2025-07-16 10:18:01 +08:00
|
|
|
|
creatorButtonText: '添加楼栋单元',
|
2025-06-30 18:42:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
itemRender: (
|
|
|
|
|
|
{ listDom, action }: any,
|
|
|
|
|
|
{ index }: { index: number },
|
|
|
|
|
|
) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<ProCard
|
|
|
|
|
|
bordered
|
2025-09-08 17:22:58 +08:00
|
|
|
|
style={{ marginBlockEnd: 5 }}
|
|
|
|
|
|
title={`选择范围${index + 1}`}
|
2025-06-30 18:42:21 +08:00
|
|
|
|
extra={action}
|
|
|
|
|
|
bodyStyle={{ paddingBlockEnd: 0 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
{listDom}
|
|
|
|
|
|
</ProCard>
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
columns: [
|
|
|
|
|
|
{
|
|
|
|
|
|
valueType: 'dependency',
|
|
|
|
|
|
name: ['asset_buildings_id', 'asset_units_id'],
|
|
|
|
|
|
columns: ({ asset_buildings_id }) => {
|
|
|
|
|
|
return [
|
|
|
|
|
|
{
|
|
|
|
|
|
valueType: 'group',
|
|
|
|
|
|
columns: [
|
|
|
|
|
|
Selects?.AssetBuildings({
|
|
|
|
|
|
key: 'asset_buildings_id',
|
|
|
|
|
|
title: '选择楼栋',
|
|
|
|
|
|
params: {
|
2025-09-08 17:22:58 +08:00
|
|
|
|
asset_projects_id: props?.item?.id,
|
2025-06-30 18:42:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
colProps: { span: 12 },
|
|
|
|
|
|
formItemProps: { ...rulesHelper.number },
|
|
|
|
|
|
fieldProps: {
|
|
|
|
|
|
showSearch: true,
|
2025-09-08 17:22:58 +08:00
|
|
|
|
onChange: (value: any) => {
|
|
|
|
|
|
// 获取当前表单的所有值
|
|
|
|
|
|
const formValues = form.getFieldsValue();
|
|
|
|
|
|
const gridRanges = formValues.grid_ranges || [];
|
|
|
|
|
|
|
|
|
|
|
|
// 清空所有行的asset_units_id,因为楼栋变化会影响所有单元选择
|
|
|
|
|
|
const updatedGridRanges = gridRanges.map(
|
|
|
|
|
|
(item: any, index: number) => {
|
|
|
|
|
|
if (item.asset_buildings_id === value) {
|
|
|
|
|
|
return { ...item, asset_units_id: undefined };
|
|
|
|
|
|
}
|
|
|
|
|
|
return item;
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
// 更新表单值
|
2025-06-30 18:42:21 +08:00
|
|
|
|
form.setFieldsValue({
|
2025-09-08 17:22:58 +08:00
|
|
|
|
grid_ranges: updatedGridRanges,
|
2025-06-30 18:42:21 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-09-08 17:22:58 +08:00
|
|
|
|
...(asset_buildings_id
|
|
|
|
|
|
? [
|
|
|
|
|
|
Selects?.GridUnits({
|
|
|
|
|
|
key: 'asset_units_id',
|
|
|
|
|
|
title: '选择单元',
|
|
|
|
|
|
params: {
|
|
|
|
|
|
asset_projects_id: props?.item?.id,
|
|
|
|
|
|
asset_buildings_id: asset_buildings_id,
|
|
|
|
|
|
},
|
|
|
|
|
|
colProps: { span: 12 },
|
|
|
|
|
|
formItemProps: { ...rulesHelper.text },
|
|
|
|
|
|
fieldProps: {
|
|
|
|
|
|
showSearch: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
]
|
|
|
|
|
|
: []),
|
2025-06-30 18:42:21 +08:00
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|