fix: cleanup
This commit is contained in:
		
							parent
							
								
									f7ce3f64cf
								
							
						
					
					
						commit
						8af19d2489
					
				@ -28,7 +28,6 @@ export const ScopeSelect = (props) => {
 | 
				
			|||||||
      }),
 | 
					      }),
 | 
				
			||||||
    [],
 | 
					    [],
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  console.log('props.value', props.value, form.values);
 | 
					 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <FormProvider form={form}>
 | 
					    <FormProvider form={form}>
 | 
				
			||||||
      <SchemaComponent
 | 
					      <SchemaComponent
 | 
				
			||||||
@ -36,7 +35,6 @@ export const ScopeSelect = (props) => {
 | 
				
			|||||||
        scope={{
 | 
					        scope={{
 | 
				
			||||||
          onChange(value) {
 | 
					          onChange(value) {
 | 
				
			||||||
            props?.onChange?.(value);
 | 
					            props?.onChange?.(value);
 | 
				
			||||||
            console.log('onChange', value);
 | 
					 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
        }}
 | 
					        }}
 | 
				
			||||||
        schema={scopesSchema}
 | 
					        schema={scopesSchema}
 | 
				
			||||||
 | 
				
			|||||||
@ -136,7 +136,6 @@ export const scopesSchema: ISchema = {
 | 
				
			|||||||
                // },
 | 
					                // },
 | 
				
			||||||
                useDataSource(options) {
 | 
					                useDataSource(options) {
 | 
				
			||||||
                  const record = useRecord();
 | 
					                  const record = useRecord();
 | 
				
			||||||
                  console.log('useRecord', record);
 | 
					 | 
				
			||||||
                  return useRequest(
 | 
					                  return useRequest(
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                      resource: 'rolesResourcesScopes',
 | 
					                      resource: 'rolesResourcesScopes',
 | 
				
			||||||
 | 
				
			|||||||
@ -25,7 +25,6 @@ const getSchema = (schema: IField): ISchema => {
 | 
				
			|||||||
    name: `f_${uid()}`,
 | 
					    name: `f_${uid()}`,
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
  initialValue.uiSchema.title = schema.title;
 | 
					  initialValue.uiSchema.title = schema.title;
 | 
				
			||||||
  console.log('initialValue', initialValue);
 | 
					 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
    type: 'object',
 | 
					    type: 'object',
 | 
				
			||||||
    properties: {
 | 
					    properties: {
 | 
				
			||||||
 | 
				
			|||||||
@ -102,7 +102,6 @@ export const Calendar: any = observer((props: any) => {
 | 
				
			|||||||
      refreshDeps: [props.dataSource],
 | 
					      refreshDeps: [props.dataSource],
 | 
				
			||||||
      onSuccess(data) {
 | 
					      onSuccess(data) {
 | 
				
			||||||
        const events = toEvents(data?.data, fieldNames);
 | 
					        const events = toEvents(data?.data, fieldNames);
 | 
				
			||||||
        console.log('events', events, data);
 | 
					 | 
				
			||||||
        setDataSource(events);
 | 
					        setDataSource(events);
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -114,7 +113,6 @@ export const Calendar: any = observer((props: any) => {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    return buf;
 | 
					    return buf;
 | 
				
			||||||
  }, null);
 | 
					  }, null);
 | 
				
			||||||
  console.log('field', field);
 | 
					 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <AsyncDataProvider value={result}>
 | 
					    <AsyncDataProvider value={result}>
 | 
				
			||||||
      <CalendarContext.Provider value={{ field, props, record }}>
 | 
					      <CalendarContext.Provider value={{ field, props, record }}>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
import { CheckOutlined, CloseOutlined } from '@ant-design/icons';
 | 
					import { CheckOutlined } from '@ant-design/icons';
 | 
				
			||||||
import { connect, mapProps, mapReadPretty, useField } from '@formily/react';
 | 
					import { connect, mapProps, mapReadPretty, useField } from '@formily/react';
 | 
				
			||||||
import { isValid } from '@formily/shared';
 | 
					import { isValid } from '@formily/shared';
 | 
				
			||||||
import { Checkbox as AntdCheckbox, Tag } from 'antd';
 | 
					import { Checkbox as AntdCheckbox, Tag } from 'antd';
 | 
				
			||||||
@ -29,11 +29,7 @@ export const Checkbox: ComposedCheckbox = connect(
 | 
				
			|||||||
    if (!isValid(props.value)) {
 | 
					    if (!isValid(props.value)) {
 | 
				
			||||||
      return <div></div>;
 | 
					      return <div></div>;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return props.value ? (
 | 
					    return props.value ? <CheckOutlined style={{ color: '#52c41a' }} /> : null;
 | 
				
			||||||
      <CheckOutlined style={{ color: '#52c41a' }} />
 | 
					 | 
				
			||||||
    ) : (
 | 
					 | 
				
			||||||
      <CloseOutlined style={{ color: '#f5222d' }} />
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
  }),
 | 
					  }),
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -30,7 +30,6 @@ Radio.Group = connect(
 | 
				
			|||||||
    const { options = [], value } = props;
 | 
					    const { options = [], value } = props;
 | 
				
			||||||
    const field = useField<any>();
 | 
					    const field = useField<any>();
 | 
				
			||||||
    const dataSource = field.dataSource || [];
 | 
					    const dataSource = field.dataSource || [];
 | 
				
			||||||
    console.log({ dataSource });
 | 
					 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      <div>
 | 
					      <div>
 | 
				
			||||||
        {dataSource
 | 
					        {dataSource
 | 
				
			||||||
 | 
				
			|||||||
@ -40,7 +40,6 @@ const useTableColumns = () => {
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
      } as TableColumnProps<any>;
 | 
					      } as TableColumnProps<any>;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  console.log(columns);
 | 
					 | 
				
			||||||
  if (!exists) {
 | 
					  if (!exists) {
 | 
				
			||||||
    return columns;
 | 
					    return columns;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,6 @@ type TableVoidProps = TableProps<any> & {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const usePaginationProps = (props: TableProps<any> & { request?: any }, service): TablePaginationConfig | false => {
 | 
					const usePaginationProps = (props: TableProps<any> & { request?: any }, service): TablePaginationConfig | false => {
 | 
				
			||||||
  console.log('f.componentProps.pagination', props);
 | 
					 | 
				
			||||||
  if (props.pagination === false) {
 | 
					  if (props.pagination === false) {
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -97,7 +96,6 @@ export const TableVoid: React.FC<TableVoidProps> = observer((props) => {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        field.componentProps.pagination.current = data?.meta?.page || 1;
 | 
					        field.componentProps.pagination.current = data?.meta?.page || 1;
 | 
				
			||||||
        field.componentProps.pagination.pageSize = data?.meta?.pageSize || 10;
 | 
					        field.componentProps.pagination.pageSize = data?.meta?.pageSize || 10;
 | 
				
			||||||
        console.log('f.componentProps.pagination', field.componentProps.pagination);
 | 
					 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    props,
 | 
					    props,
 | 
				
			||||||
 | 
				
			|||||||
@ -80,7 +80,6 @@ const designerCss = css`
 | 
				
			|||||||
Tabs.TabPane = observer((props: TabPaneProps) => {
 | 
					Tabs.TabPane = observer((props: TabPaneProps) => {
 | 
				
			||||||
  const Designer = useDesigner();
 | 
					  const Designer = useDesigner();
 | 
				
			||||||
  const field = useField();
 | 
					  const field = useField();
 | 
				
			||||||
  console.log('Designer', Designer);
 | 
					 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <SortableItem className={classNames('nb-action-link', designerCss, props.className)}>
 | 
					    <SortableItem className={classNames('nb-action-link', designerCss, props.className)}>
 | 
				
			||||||
      {props.tab || field.title}
 | 
					      {props.tab || field.title}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,6 @@ ReadPretty.Attachment = (props: UploadProps) => {
 | 
				
			|||||||
  const [photoIndex, setPhotoIndex] = useState(0);
 | 
					  const [photoIndex, setPhotoIndex] = useState(0);
 | 
				
			||||||
  const [visible, setVisible] = useState(false);
 | 
					  const [visible, setVisible] = useState(false);
 | 
				
			||||||
  const { size } = props;
 | 
					  const { size } = props;
 | 
				
			||||||
  console.log('field.value', field.value, images);
 | 
					 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
      <div className={cls('ant-upload-picture-card-wrapper nb-upload', size ? `nb-upload-${size}` : null)}>
 | 
					      <div className={cls('ant-upload-picture-card-wrapper nb-upload', size ? `nb-upload-${size}` : null)}>
 | 
				
			||||||
 | 
				
			|||||||
@ -38,6 +38,7 @@ Upload.Attachment = connect((props: UploadProps) => {
 | 
				
			|||||||
      setFileList(toFileList(value));
 | 
					      setFileList(toFileList(value));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }, [value, sync]);
 | 
					  }, [value, sync]);
 | 
				
			||||||
 | 
					  const uploadProps = useUploadProps({ ...props });
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
      <div className={cls('ant-upload-picture-card-wrapper nb-upload')}>
 | 
					      <div className={cls('ant-upload-picture-card-wrapper nb-upload')}>
 | 
				
			||||||
@ -126,7 +127,7 @@ Upload.Attachment = connect((props: UploadProps) => {
 | 
				
			|||||||
          {!disabled && (multiple || toArr(value).length < 1) && (
 | 
					          {!disabled && (multiple || toArr(value).length < 1) && (
 | 
				
			||||||
            <div className={'ant-upload-list-picture-card-container'}>
 | 
					            <div className={'ant-upload-list-picture-card-container'}>
 | 
				
			||||||
              <AntdUpload
 | 
					              <AntdUpload
 | 
				
			||||||
                {...useUploadProps({ ...props })}
 | 
					                {...uploadProps}
 | 
				
			||||||
                disabled={disabled}
 | 
					                disabled={disabled}
 | 
				
			||||||
                multiple={multiple}
 | 
					                multiple={multiple}
 | 
				
			||||||
                listType={'picture-card'}
 | 
					                listType={'picture-card'}
 | 
				
			||||||
@ -140,7 +141,6 @@ Upload.Attachment = connect((props: UploadProps) => {
 | 
				
			|||||||
                    setFileList(info.fileList.map(toItem));
 | 
					                    setFileList(info.fileList.map(toItem));
 | 
				
			||||||
                  } else {
 | 
					                  } else {
 | 
				
			||||||
                    if (info.file.status === 'done') {
 | 
					                    if (info.file.status === 'done') {
 | 
				
			||||||
                      console.log('field.value', info.file?.response?.data);
 | 
					 | 
				
			||||||
                      // TODO(BUG): object 的联动有问题,不响应,折中的办法先置空再赋值
 | 
					                      // TODO(BUG): object 的联动有问题,不响应,折中的办法先置空再赋值
 | 
				
			||||||
                      onChange(null);
 | 
					                      onChange(null);
 | 
				
			||||||
                      onChange(info.file?.response?.data);
 | 
					                      onChange(info.file?.response?.data);
 | 
				
			||||||
 | 
				
			|||||||
@ -2,10 +2,10 @@ import { Field } from '@formily/core';
 | 
				
			|||||||
import { useField } from '@formily/react';
 | 
					import { useField } from '@formily/react';
 | 
				
			||||||
import { reaction } from '@formily/reactive';
 | 
					import { reaction } from '@formily/reactive';
 | 
				
			||||||
import { isArr, isValid, toArr as toArray } from '@formily/shared';
 | 
					import { isArr, isValid, toArr as toArray } from '@formily/shared';
 | 
				
			||||||
import { useAPIClient } from '../../../api-client';
 | 
					 | 
				
			||||||
import { UploadChangeParam } from 'antd/lib/upload';
 | 
					import { UploadChangeParam } from 'antd/lib/upload';
 | 
				
			||||||
import { UploadFile } from 'antd/lib/upload/interface';
 | 
					import { UploadFile } from 'antd/lib/upload/interface';
 | 
				
			||||||
import { useEffect } from 'react';
 | 
					import { useEffect } from 'react';
 | 
				
			||||||
 | 
					import { useAPIClient } from '../../../api-client';
 | 
				
			||||||
import { UPLOAD_PLACEHOLDER } from './placeholder';
 | 
					import { UPLOAD_PLACEHOLDER } from './placeholder';
 | 
				
			||||||
import type { IUploadProps, UploadProps } from './type';
 | 
					import type { IUploadProps, UploadProps } from './type';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -28,7 +28,6 @@ export const toMap = (fileList: any) => {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    list = [fileList];
 | 
					    list = [fileList];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  console.log({ list, fileList });
 | 
					 | 
				
			||||||
  return list.map((item) => {
 | 
					  return list.map((item) => {
 | 
				
			||||||
    return [item.id || item.uid, toItem(item)];
 | 
					    return [item.id || item.uid, toItem(item)];
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,6 @@ import { ActionContext, SchemaComponent, useActionContext } from '../schema-comp
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const useCloseAction = () => {
 | 
					const useCloseAction = () => {
 | 
				
			||||||
  const { setVisible } = useActionContext();
 | 
					  const { setVisible } = useActionContext();
 | 
				
			||||||
  // const form = useForm();
 | 
					 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
    async run() {
 | 
					    async run() {
 | 
				
			||||||
      setVisible(false);
 | 
					      setVisible(false);
 | 
				
			||||||
@ -18,23 +17,28 @@ const useCloseAction = () => {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const useSystemSettingsValues = (options) => {
 | 
					const useSystemSettingsValues = (options) => {
 | 
				
			||||||
 | 
					  const { visible } = useActionContext();
 | 
				
			||||||
  const result = useSystemSettings();
 | 
					  const result = useSystemSettings();
 | 
				
			||||||
  return useRequest(() => Promise.resolve(result.data), {
 | 
					  return useRequest(() => Promise.resolve(result.data), {
 | 
				
			||||||
    ...options,
 | 
					    ...options,
 | 
				
			||||||
 | 
					    refreshDeps: [visible],
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const useSaveSystemSettingsValues = () => {
 | 
					const useSaveSystemSettingsValues = () => {
 | 
				
			||||||
  const { setVisible } = useActionContext();
 | 
					  const { setVisible } = useActionContext();
 | 
				
			||||||
  const form = useForm();
 | 
					  const form = useForm();
 | 
				
			||||||
  const { mutate } = useSystemSettings();
 | 
					  const { mutate, data } = useSystemSettings();
 | 
				
			||||||
  const api = useAPIClient();
 | 
					  const api = useAPIClient();
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
    async run() {
 | 
					    async run() {
 | 
				
			||||||
      await form.submit();
 | 
					      await form.submit();
 | 
				
			||||||
      setVisible(false);
 | 
					      setVisible(false);
 | 
				
			||||||
      mutate({
 | 
					      mutate({
 | 
				
			||||||
        data: form.values,
 | 
					        data: {
 | 
				
			||||||
 | 
					          ...data?.data,
 | 
				
			||||||
 | 
					          ...form.values,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      await api.request({
 | 
					      await api.request({
 | 
				
			||||||
        url: 'systemSettings:update/1',
 | 
					        url: 'systemSettings:update/1',
 | 
				
			||||||
@ -108,6 +112,7 @@ const schema: ISchema = {
 | 
				
			|||||||
              'x-component': 'Action',
 | 
					              'x-component': 'Action',
 | 
				
			||||||
              'x-component-props': {
 | 
					              'x-component-props': {
 | 
				
			||||||
                type: 'primary',
 | 
					                type: 'primary',
 | 
				
			||||||
 | 
					                htmlType: 'submit',
 | 
				
			||||||
                useAction: '{{ useSaveSystemSettingsValues }}',
 | 
					                useAction: '{{ useSaveSystemSettingsValues }}',
 | 
				
			||||||
              },
 | 
					              },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
 | 
				
			|||||||
@ -33,6 +33,7 @@ const schema: ISchema = {
 | 
				
			|||||||
          type: 'void',
 | 
					          type: 'void',
 | 
				
			||||||
          'x-component': 'Action',
 | 
					          'x-component': 'Action',
 | 
				
			||||||
          'x-component-props': {
 | 
					          'x-component-props': {
 | 
				
			||||||
 | 
					            htmlType: 'submit',
 | 
				
			||||||
            block: true,
 | 
					            block: true,
 | 
				
			||||||
            type: 'primary',
 | 
					            type: 'primary',
 | 
				
			||||||
            useAction: '{{ useSignin }}',
 | 
					            useAction: '{{ useSignin }}',
 | 
				
			||||||
 | 
				
			|||||||
@ -63,6 +63,7 @@ const schema: ISchema = {
 | 
				
			|||||||
          'x-component-props': {
 | 
					          'x-component-props': {
 | 
				
			||||||
            block: true,
 | 
					            block: true,
 | 
				
			||||||
            type: 'primary',
 | 
					            type: 'primary',
 | 
				
			||||||
 | 
					            htmlType: 'submit',
 | 
				
			||||||
            useAction: '{{ useSignup }}',
 | 
					            useAction: '{{ useSignup }}',
 | 
				
			||||||
            style: { width: '100%' },
 | 
					            style: { width: '100%' },
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user