fix: 修改录单的维修赔偿级联点击能显示名称,修改级联组价查看显示标题 (#958)
Reviewed-on: daoyoucloud/tachybase#958 Reviewed-by: sealday <zhanglin@daoyoucloud.com> Co-authored-by: wjh <wwwjh0710@163.com> Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
		
							parent
							
								
									12a2f7c1bb
								
							
						
					
					
						commit
						2b0e1fa573
					
				@ -32,7 +32,7 @@ export const AssociationFieldProvider = observer(
 | 
				
			|||||||
    const currentMode = useMemo(
 | 
					    const currentMode = useMemo(
 | 
				
			||||||
      () =>
 | 
					      () =>
 | 
				
			||||||
        fieldSchema['x-component-props']?.mode ||
 | 
					        fieldSchema['x-component-props']?.mode ||
 | 
				
			||||||
        (isTreeCollection ? 'Cascader' : isFileCollection ? 'FileManager' : 'Select'),
 | 
					        (isFileCollection ? 'FileManager' : isTreeCollection ? 'Cascader' : 'Select'),
 | 
				
			||||||
      // eslint-disable-next-line react-hooks/exhaustive-deps
 | 
					      // eslint-disable-next-line react-hooks/exhaustive-deps
 | 
				
			||||||
      [fieldSchema['x-component-props']?.mode],
 | 
					      [fieldSchema['x-component-props']?.mode],
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@ import { Input, Space } from 'antd';
 | 
				
			|||||||
import React, { useEffect, useMemo, useState } from 'react';
 | 
					import React, { useEffect, useMemo, useState } from 'react';
 | 
				
			||||||
import { useTranslation } from 'react-i18next';
 | 
					import { useTranslation } from 'react-i18next';
 | 
				
			||||||
import { CustomCascader, SchemaComponent } from '../..';
 | 
					import { CustomCascader, SchemaComponent } from '../..';
 | 
				
			||||||
import { css, useAPIClient } from '../../..';
 | 
					import { css, useAPIClient, useCollection, useRequest } from '../../..';
 | 
				
			||||||
import { mergeFilter } from '../../../filter-provider/utils';
 | 
					import { mergeFilter } from '../../../filter-provider/utils';
 | 
				
			||||||
import useServiceOptions, { useAssociationFieldContext } from './hooks';
 | 
					import useServiceOptions, { useAssociationFieldContext } from './hooks';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -43,22 +43,47 @@ const Cascade = connect((props) => {
 | 
				
			|||||||
  const field: any = useField();
 | 
					  const field: any = useField();
 | 
				
			||||||
  const [selectedOptions, setSelectedOptions] = useState([]);
 | 
					  const [selectedOptions, setSelectedOptions] = useState([]);
 | 
				
			||||||
  const [chang, setChang] = useState(false);
 | 
					  const [chang, setChang] = useState(false);
 | 
				
			||||||
 | 
					  const [dataList, setDataList] = useState({});
 | 
				
			||||||
  useEffect(() => {
 | 
					  useEffect(() => {
 | 
				
			||||||
    const propsValue = props.value || fieldSchema['x-component-props'].value;
 | 
					    const propsValue = props.value || fieldSchema['x-component-props'].value;
 | 
				
			||||||
    if (!chang) {
 | 
					    if (!chang && propsValue) {
 | 
				
			||||||
      const values = Array.isArray(propsValue)
 | 
					      if (!propsValue.parent && !Object.keys(dataList).length) {
 | 
				
			||||||
 | 
					        resource
 | 
				
			||||||
 | 
					          .list({
 | 
				
			||||||
 | 
					            pageSize: 9999,
 | 
				
			||||||
 | 
					            filter: { id: { $eq: propsValue.id } },
 | 
				
			||||||
 | 
					            sort,
 | 
				
			||||||
 | 
					            tree: true,
 | 
				
			||||||
 | 
					          })
 | 
				
			||||||
 | 
					          .then((res) => {
 | 
				
			||||||
 | 
					            setDataList(res.data?.data[0]);
 | 
				
			||||||
 | 
					          })
 | 
				
			||||||
 | 
					          .catch(() => {});
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        const values = [];
 | 
				
			||||||
 | 
					        if (!propsValue.parent && Object.keys(dataList).length) {
 | 
				
			||||||
 | 
					          const defValue = transformChildrenData(dataList, [], propsValue.id);
 | 
				
			||||||
 | 
					          values.push(...defValue);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          const defValue = Array.isArray(propsValue)
 | 
				
			||||||
            ? extractLastNonNullValueObjects(
 | 
					            ? extractLastNonNullValueObjects(
 | 
				
			||||||
                propsValue?.filter((v) => v.value),
 | 
					                propsValue?.filter((v) => v.value),
 | 
				
			||||||
                true,
 | 
					                true,
 | 
				
			||||||
              )
 | 
					              )
 | 
				
			||||||
            : transformNestedData(propsValue);
 | 
					            : transformNestedData(propsValue);
 | 
				
			||||||
 | 
					          values.push(...defValue);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        const defaultData = values?.map?.((v) => {
 | 
					        const defaultData = values?.map?.((v) => {
 | 
				
			||||||
          return v.id;
 | 
					          return v.id;
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      setSelectedOptions(defaultData);
 | 
					 | 
				
			||||||
        onDropdownVisibleChange(true);
 | 
					        onDropdownVisibleChange(true);
 | 
				
			||||||
 | 
					        setSelectedOptions(defaultData);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
  }, [fieldSchema['x-component-props'].value, fieldSchema['x-component-props']?.changOnSelect]);
 | 
					    }
 | 
				
			||||||
 | 
					  }, [fieldSchema['x-component-props'].value, fieldSchema['x-component-props']?.changOnSelect, dataList]);
 | 
				
			||||||
 | 
					  useEffect(() => {
 | 
				
			||||||
 | 
					    onDropdownVisibleChange(true);
 | 
				
			||||||
 | 
					  }, [fieldFilter]);
 | 
				
			||||||
  const handleGetOptions = async () => {
 | 
					  const handleGetOptions = async () => {
 | 
				
			||||||
    const response = await resource.list({
 | 
					    const response = await resource.list({
 | 
				
			||||||
      pageSize: 9999,
 | 
					      pageSize: 9999,
 | 
				
			||||||
@ -328,3 +353,14 @@ export function transformNestedData(inputData) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  return resultArray;
 | 
					  return resultArray;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const transformChildrenData = (inputData, result, itemId) => {
 | 
				
			||||||
 | 
					  const { children, ...other } = inputData;
 | 
				
			||||||
 | 
					  result.push(other);
 | 
				
			||||||
 | 
					  if (children && inputData?.id !== itemId && children.length) {
 | 
				
			||||||
 | 
					    const { children } = inputData;
 | 
				
			||||||
 | 
					    return transformChildrenData(children[0], result, itemId);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,9 @@ const ReadPrettyAssociationField = observer(
 | 
				
			|||||||
    const { currentMode } = useAssociationFieldContext();
 | 
					    const { currentMode } = useAssociationFieldContext();
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      <>
 | 
					      <>
 | 
				
			||||||
        {['Select', 'Picker', 'CascadeSelect'].includes(currentMode) && <ReadPrettyInternalViewer {...props} />}
 | 
					        {['Select', 'Picker', 'CascadeSelect', 'Cascader'].includes(currentMode) && (
 | 
				
			||||||
 | 
					          <ReadPrettyInternalViewer {...props} />
 | 
				
			||||||
 | 
					        )}
 | 
				
			||||||
        {currentMode === 'Tag' && <ReadPrettyInternalTag {...props} />}
 | 
					        {currentMode === 'Tag' && <ReadPrettyInternalTag {...props} />}
 | 
				
			||||||
        {currentMode === 'Nester' && <InternalNester {...props} />}
 | 
					        {currentMode === 'Nester' && <InternalNester {...props} />}
 | 
				
			||||||
        {currentMode === 'SubTable' && <InternalSubTable {...props} />}
 | 
					        {currentMode === 'SubTable' && <InternalSubTable {...props} />}
 | 
				
			||||||
 | 
				
			|||||||
@ -43,7 +43,7 @@ export const RecordDetails: CustomFunctionComponent = () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const feeItems = {};
 | 
					  const feeItems = {};
 | 
				
			||||||
  // 根据关联产品名称来合并赔偿
 | 
					  // 根据关联产品名称来合并赔偿
 | 
				
			||||||
  if (reqRecordItemFeeItems.data) {
 | 
					  if (reqRecordItemFeeItems.data && products) {
 | 
				
			||||||
    reqRecordItemFeeItems.data.data?.forEach((contract, index) => {
 | 
					    reqRecordItemFeeItems.data.data?.forEach((contract, index) => {
 | 
				
			||||||
      if (!contract.fees.length) return;
 | 
					      if (!contract.fees.length) return;
 | 
				
			||||||
      const movement = contract.movement === '-1' ? '出库合同' : '入库合同';
 | 
					      const movement = contract.movement === '-1' ? '出库合同' : '入库合同';
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user