#
luxiaotao1123
13 小时以前 d2309a34e386d0528a56116f511e2cfb093f4f42
#
1个文件已添加
2个文件已修改
35 ■■■■■ 已修改文件
zy-acs-flow/src/page/sta/StaCreate.jsx 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/page/sta/StaEdit.jsx 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/page/sta/staValidation.js 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/page/sta/StaCreate.jsx
@@ -32,12 +32,14 @@
import MemoInput from "../components/MemoInput";
import { compDirectChoices } from "../loc/compDirect";
import { stateSourceChoices } from "./stateSource";
import { useLatentCodeValidate } from "./staValidation";
const StaCreate = (props) => {
    const { open, setOpen } = props;
    const translate = useTranslate();
    const notify = useNotify();
    const latentCodeValidate = useLatentCodeValidate();
    const greaterThanZero = useMemo(() => (value) => {
        if (value === undefined || value === null || value === '') {
            return undefined;
@@ -163,6 +165,7 @@
                                            label="table.field.sta.latentCode"
                                            optionText="data"
                                            filterToQuery={(val) => ({ data: val })}
                                            validate={latentCodeValidate}
                                        />
                                    </ReferenceInput>
                                </Grid>
zy-acs-flow/src/page/sta/StaEdit.jsx
@@ -30,6 +30,7 @@
import StatusSelectInput from "../components/StatusSelectInput";
import { compDirectChoices } from "../loc/compDirect";
import { stateSourceChoices } from "./stateSource";
import { useLatentCodeValidate } from "./staValidation";
const FormToolbar = () => {
    const { getValues } = useFormContext();
@@ -44,6 +45,7 @@
const StaEdit = () => {
    const translate = useTranslate();
    const latentCodeValidate = useLatentCodeValidate();
    const greaterThanZero = useMemo(() => (value) => {
        if (value === undefined || value === null || value === '') {
            return undefined;
@@ -139,6 +141,7 @@
                                    label="table.field.sta.latentCode"
                                    optionText="data"
                                    filterToQuery={(val) => ({ data: val })}
                                    validate={latentCodeValidate}
                                />
                            </ReferenceInput>
                        </Stack>
zy-acs-flow/src/page/sta/staValidation.js
New file
@@ -0,0 +1,29 @@
import { useMemo } from "react";
import { required, useGetList } from "react-admin";
const TRANSFER_STA_TYPE = 'TRANSFER';
export const useLatentCodeValidate = () => {
    const { data: staTypes = [] } = useGetList('staType', {
        pagination: { page: 1, perPage: 1 },
        sort: { field: 'id', order: 'ASC' },
        filter: { uuid: TRANSFER_STA_TYPE },
    });
    const transferStaTypeId = staTypes[0]?.id;
    return useMemo(() => {
        const requiredValidate = required();
        return (value, allValues) => {
            const isTransferStaType = allValues?.staType$ === TRANSFER_STA_TYPE
                || (transferStaTypeId !== undefined && String(allValues?.staType) === String(transferStaTypeId));
            if (!isTransferStaType) {
                return undefined;
            }
            return requiredValidate(value, allValues);
        };
    }, [transferStaTypeId]);
};