全部文档
文档中心页面操作页面2.0自定义JS帮助文档

页面2.0自定义JS帮助文档

Copy
import React from '/package-base/react.mjs';
// import { getAppSpace } from '@deepfos/help/es/app/appInfo';
// import useAppEasyInfo from '@deepfos/store/es/app/useAppEasyInfo';
import { notification } from '/package-base/antd4.mjs';

class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }


  componentWillMount() { // 预装载函数
    console.log(8888)
  }

  componentDidMount() { // 组件装载之后调用,此时可以获取到DOM节点并操作
    const {
      getFieldValueByComponentId,
      addEventByComponentId,
      getComponentInfoByComponentId,
      setPropsByComponentId,
      setPropsByCode,
      getPropsByComponentId,
      setFieldValueByCode,
      getAreaChildrenListByComponentId,
      getInteractivesInfo,
      setInteractivesInfo
    } = this.props;






    const runSomeGetFn = () => {
      // 通过componentId获取
      console.log(getAreaChildrenListByComponentId('Card_1655705477914_175'))
      console.log(getComponentInfoByComponentId('Text_1655377280005_300'));
      console.log(getPropsByComponentId('Text_1655377494282_134', 'textContent'))



      // 通过code获取
      // console.log(getComponentInfoByCode('Text_61da207e3'));
      // console.log(getPropsByCode('Text_c2fe44947', 'textContent'))
      // console.log(getPropsByCode('Image_22f8f4613', 'url'))
    }

    const runGetDomFn = () => {
      const componentId = 'Text_1655377280005_300'; // dashboard 最外层dom节点、每个区域的dom信息   
      console.log(document.querySelector(`div[data-id=${componentId}]`))
    }


    const runSetSomeFn = () => {
      // 更改文本和维度筛选器参数
      setPropsByComponentId([
        {
          componentId: 'Text_1655377280005_300',
          properties: {
            textContent: `你你你你自定义js设置的内容`,
          },
        },
        {
          componentId: 'FilterDimension_1655957559031_228',
          properties: {
            dimensionExpression: `valueKey8888`,// 更改维度表达式
            interactives: { // 设置这个筛选器的交互动作
              to_new_page: [{
                "id": "INTERACTIVE_1655958616597_296",
                "name": "entity调整清单表",
                "triggerComponentId": "FilterDimension_1655957559031_228",
                "triggerAction": "to_new_page",
                "targetComponentId": null,
                "jumpElementDetail": {
                  "elementName": "llllll",
                  "folderId": "DIRb8b0beaf0392",
                  "path": "\\karl\\ListTable\\",
                  "elementType": "LST",
                  "serverName": "list-table-server1-2",
                  "relativePath": null,
                  "absoluteTag": true,
                  "id": "177ba267-dd69-4774-b9fb-c848c996e1a2",
                  "description": {},
                }
              }]
            }
          },
        },
      ]);

      // 修改富文本中表格的数据
      setPropsByCode([
        {
          code: 'ImageText_755266326',
          properties: {
            richTextContent: `<p>图文展示</p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\"><colgroup><col style=\"width: 33.2402%;\"><col style=\"width: 33.2402%;\"><col style=\"width: 33.2402%;\"></colgroup>\n
          <tbody>\n
          <tr onclick="alert(8888)">\n<td>A1</td>\n<td>A2</td>\n<td>A3</td>\n</tr>\n
          <tr>\n<td>1</td>\n<td>内容</td>\n<td>111</td>\n</tr>\n
          <tr>\n<td>2</td>\n<td>22</td>\n<td>222</td>\n</tr>
          \n</tbody>\n</table>`,
          },
        },
      ]);


      setFieldValueByCode('Text_61da207e3', '设置成功了吗888')
      // setFieldValueByComponentId('Text_1655377280005_300', '设置成功了吗')



    }


    const runRefGetChartInfo = () => {
      // 当前图表的所有信息
      // const chart = getComponentInfoByComponentId('RefBIChart_1655803992804_136') // 要获取的图表componentId

      const refElementParams = getPropsByComponentId('RefBIChart_1655803992804_136', 'refElementParams') // 引用元素内部信息
      // chart?.customInfo?.refElementParams?.commonFn?.onSearch({Period:"a4",Year:'as'})
      refElementParams?.refElementInfo?.chartRef?.on('click', (info) => {
        console.log(info)
      })
    }


    const runInteractive = () => {

      // console.log(getInteractivesInfo(), '整个交互动作') // 获取整个dashboard的交互动作
      // setInteractivesInfo([])  // 设置整个dashboard的交互动作

      // 获取某个元素交互动作
      console.log(getPropsByComponentId('RefBIChart_1655708047946_214', 'interactives'));
      // 设置某个元素的交互动作
      setPropsByComponentId([
        {
          componentId: 'FilterDimension_1655957559031_228',
          properties: {
            dimensionExpression: `valueKey8888`,// 更改维度表达式
            interactives: { // 设置这个筛选器的交互动作
              to_new_page: [{
                "id": "INTERACTIVE_1655958616597_296",
                "name": "entity调整清单表",
                "triggerComponentId": "FilterDimension_1655957559031_228",
                "triggerAction": "to_new_page",
                "targetComponentId": null,
                "jumpElementDetail": {
                  "elementName": "llllll",
                  "folderId": "DIRb8b0beaf0392",
                  "path": "\\karl\\ListTable\\",
                  "elementType": "LST",
                  "serverName": "list-table-server1-2",
                  "relativePath": null,
                  "absoluteTag": true,
                  "id": "177ba267-dd69-4774-b9fb-c848c996e1a2",
                  "description": {},
                }
              }]
            }
          },
        },
      ]);


    }
    // 获取控件参数的方法
    // runSomeGetFn()

    // 获取dom的方法
    // runGetDomFn()

    // 设置控件参数
    // runSetSomeFn()

    // 获取引用元素的信息方法
    // runRefGetChartInfo()


    // 交互动作
    runInteractive();


    //警告 todo 触发
    notification.warn({
      message: '测试',
      description: '测试内容',
    });



    // 标签页切换某个tab 获取某个图表的内部方法
    addEventByComponentId('TabCard_1655377485839_132', 'onClick', () => {
      // 方法1
      alert(876);
      // 当前图表的所有信息
      // const chart = getComponentInfoByComponentId('RefBIChart_1655803992804_136') // 要获取的图表componentId

      //  带参刷新---》 调用图表内部的查询方法
      const refElementParams = getPropsByComponentId('RefBIChart_1655708047946_214', 'refElementParams') // 引用信息
      // refElementParams?.commonFn?.onSearch({ Account: "a4888" })
      // 空刷
      refElementParams?.commonFn?.onSearch()
    });





    // 维度筛选器的change操作
    addEventByComponentId('FilterDimension_1655458599421_131', 'onChange', () => {
      alert('onChange');
    });








    // 注释    updateInfo兜底的更新方法
    // updateInfo([
    //   {
    //     id: 'RefBIChart_1655708047946_214',
    //     value: {
    //       ...chart,
    //       customInfo: {
    //         ...chart?.customInfo,
    //         queryDataFlag: Math.random(),
    //         filters: [{
    //           name: 'Account',
    //           value: 'aaa'
    //         }],
    //       },
    //     },
    //   },
    // ]);




  }

  render() {
    return null;
  }
}

export default Demo;

Copy
import type {
  ComponentTypes,
  NodePositionEnum,
  TipWithErrorMsg,
  TextStyleEnum,
  enumImageSource,
  enumImageDisplayType,
} from '@/common/types';
import type { SaveDashboardInfo } from '@/service/dashboard';
import type { ICustomJS } from '@/service/upload';
import type { ElementBaseInfo, IElementInfoNode } from '@deepfos-materials/element-select/es/types';
import type { IGetRoleInfo } from '@deepfos-materials/services/es/role';
import type { ValueTypeItem } from '@deepfos-materials/value-type-form-item/es/types';
import type { IInteractive } from '../hooks/useDashboard';
import type { EditComponentInfo } from './EditComponentInfo';
import type { StandardAreaProps } from '@deepfos/pact/es/ElementDashboard/dashboard-2-0-0';

/**
 * 编辑视图组件基础属性
 */
export type EditComponentBaseInfo = {
  componentId: string; // 主键id
  componentType: ComponentTypes; // 组件类型 componentType+widgetType 组成一个类型
  widgetType?: string; // s类型
  cssProps?: string; // css
  level?: number; // level
  parentComponentId: string | null; // 父id
  position: NodePositionEnum;
  sort?: number; // 排序 就安逸
  checkResult?: TipWithErrorMsg; // 字段错误信息
};

/**
 * 编辑视图组件基础显示属性
 */
export type DisplayProps = {
  // 标题图标
  icon?: string;
  // 图标颜色
  iconColor?: string;
  // 按钮颜色
  btnColor?: string;
  // 允许收起
  allowCollapse?: boolean;
  // 默认收起
  defaultCollapse?: boolean;
  // 隐藏标题文字
  hideHeaderTitle?: boolean;
  // 隐藏标题栏
  hideHeader?: boolean;
  // 宽度
  columnWidth?: 6 | 12 | 18 | 24;
  // 显示icon
  showIcon?: boolean;
  // 显示固定列宽
  showColumnWidth?: boolean;
  // 列宽
  fixColumnWidth?: number;
  // 宽度(目前仅图片用)
  width?: string;
  // 高度(目前仅图片用)
  height?: string;
};

/**
 * 所有控件基础customInfo
 *
 * @export
 * @interface IBaseComponent
 */
export interface IBaseComponent {
  code?: string;
  description: Record<string, string>;
}

/**
 * 编辑视图区域类型通用类型
 */
export type IBaseModule = IBaseComponent &
  DisplayProps & {
    enablePartCss?: boolean;
    partCss?: string;
    hidden?: boolean;
    readOnly?: boolean;
    dataTableElementDetail?: ElementBaseInfo;
    isEx?: boolean;
    sortColumnList?: {
      sort: number;
      columnName: string;
      sortDescend: boolean;
    }[];
    selectType?: 1 | 2;
  };

// 字段类型
export interface IBaseField extends IBaseComponent {
  readOnly?: boolean;
  hidden?: boolean;
  defaultValue?: string;
  segName?: string;
  dimensionDisplay?: number;
  dataTableElementDetail?: ElementBaseInfo;
  // 是否启用悬停提示
  enableTitle?: boolean;
  smartListDisplay?: number;
  logicTableColumnInfo: {
    logicInfo: LogicInfo;
    description: Record<string, string>;
    name: string;
  };
  valueKey?: string;
  defaultValueDesc?: string;
  // 元素
  elementDetail?: IElementInfoNode;
  // 角色角色组
  roleScript: IGetRoleInfo;
  // 角色方案
  rsElementDetail: IElementInfoNode;
  // 是否显示树形结构
  treeView: boolean;
  rsMapping: string;
}

/**
 * 按钮类型
 */
export interface IButton extends IBaseComponent, DisplayProps {
  disabled?: boolean;
  title?: Record<string, string>;
  readOnly?: boolean;
  hidden?: boolean;
  jsOnclick: string;
  isEx?: boolean;
  // 是否启用悬停提示
  enableTitle?: boolean;
}

export interface IBaseDivider extends IBaseComponent {
  disabled?: boolean;
  hidden?: boolean;
  titlePosition?: string;
  showTitleText?: boolean;
  showDivider?: boolean;
  isEx?: boolean;
  // 标题文字
  titleText?: string;
}

export interface IGrid extends IBaseComponent {
  // 列比例分配
  columnRatio: string;
  // 列间距
  columnGap: string | undefined;
}

export interface IGridColumn extends IBaseComponent {
  // 列比例
  proportion: number;
}

export interface ITextProp extends IBaseComponent {
  // 文本样式
  textStyle: TextStyleEnum;
  // 文本内容
  textContent: string;
}

export interface IImage extends IBaseComponent, Pick<DisplayProps, 'width' | 'height'> {
  // 来源
  source: enumImageSource;
  // 图片url
  url: string;
  // 显示方式
  displayType: enumImageDisplayType;
  // 宽度单位,留作备用
  widthUnit: 'px';
  // 高度单位,留作备用
  heightUnit: 'px';
}

export interface IIconProp extends IBaseComponent {
  // 图标大小
  fontSize: string;
  // 颜色
  iconColor: string;
  // 图标
  icon: string;
}

export interface IImageTextProp extends IBaseComponent {
  // 富文本编辑器内容
  content: string;
}

export interface IRefElement
  extends IBaseComponent,
    Pick<StandardAreaProps, 'queryDataFlag' | 'filters'> {
  // 关联元素信息
  elementDetail?: ElementBaseInfo;
  // 引用区域高度
  height: number;
}

/**
 * 编辑视图组件扩展属性
 */
// export type EditComponentCustomInfo = Record<string, unknown>;
export type EditComponentCustomInfo =
  | IBaseModule
  | IBaseField
  | IButton
  | IBaseDivider
  | IGrid
  | IGridColumn
  | ITextProp
  | IImage
  | IRefElement;

/**
 * 编辑视图 页面表单部分详情
 */
export type EditFormInfo = {
  description: Record<string, any>; // 描述+多语言
  errorInfo: TipWithErrorMsg & {
    haveLogicTable: boolean; // 是否关联了业务模型
    popupErrorTag: boolean; // 是否有弹窗错误
  }; // 错误信息
  elementName: string; // 页面名称
  path: string; // 路径
  folderId: string; // 文件夹id
  isEx?: boolean;
  jsFile?: string;
  enableCustomJs?: boolean;
  jsCode?: string;
};

export type EditComponentServerInfo = EditComponentBaseInfo & EditComponentCustomInfo;

/**
 * 编辑视图详情
 */
export type EditServerInfo = {
  components: EditComponentServerInfo[]; //
  baseInfo: EditFormInfo;
  customJs?: ICustomJS;
  interactives: IInteractive[] | undefined | null;
  componentCheckResult?: SaveDashboardInfo['componentCheckResult'];
  dashboardCheckResult?: SaveDashboardInfo['dashboardCheckResult'];
  interactionCheckResult?: SaveDashboardInfo['interactionCheckResult'];
};

export type SaveComponentsInfo = Omit<EditComponentInfo, 'componentId'>;

export type BaseError = {
  // tipType为prop有效,用来找哪个属性
  tipKey?: string;
  // clazz为控件本身错误,prop为控件属性错误
  tipType?: string;
  // 展示在控件上或者属性上的简略提示
  tipValue?: string;
  // 展示在表格上的错误编码
  tipCode?: string;
  // 展示在表格上的详细提示
  tipText?: string;
  // 展示在表格上的属性
  tipProp?: string;
};

export interface ErrorWithPath extends BaseError {
  tipKeyPath: (string | number)[];
}

export type EditErrorInfo = {
  errorTag?: boolean;
  errorList?: BaseError[];
  warningList?: BaseError[];
  warningTag?: boolean;
  id?: string; // 主键id
  type?: 'form' | 'interaction';
};

export interface EditErrorWithPathInfo extends EditErrorInfo {
  errorList?: ErrorWithPath[];
  warningList?: ErrorWithPath[];
}

export interface LogicInfo extends Omit<ValueTypeItem, 'valueKey'> {
  valueType: number;
  length: number;
  valueKey: number | string;
}

Copy
export type typeCustomTodo = {
  // 更新数据详情+模板详情
  updateInfo?: (params: UpdateEntity | UpdateEntity[]) => void;
  // 删除id
  deleteItemByComponentId?: (componentId: string | string[]) => void;
  // 获取所有子级
  getChildrenIdsByIdAndPosition?: (id: string, position?: NodePositionEnum) => string[];
  // 获取页面详情
  getStoreInfo?: <K extends keyof DashboardViewStore>(path: K) => DashboardViewStore[K];
  // 根据模板id     添加指定   自定义事件
  addEventByComponentId?: (componentId: string, eventType: CustomEventType, fun: FnCustom) => void;
  // 根据模板code   添加指定    自定义事件
  addEventByComponentCode?: (
    componentCode: string,
    eventType: CustomEventType,
    fun: FnCustom,
  ) => void;
  // 根据模板code   添加指定    自定义事件
  addEventByCode?: (componentCode: string, eventType: CustomEventType, fun: FnCustom) => void;
  // 根据模板id     删除指定   自定义事件
  removeEventByComponentId?: (
    componentId: string,
    eventType: CustomEventType,
    fun: FnCustom,
  ) => void;
  // 根据模板code   删除指定   自定义事件
  removeEventByComponentCode?: (
    componentCode: string,
    eventType: CustomEventType,
    fun: FnCustom,
  ) => void;
  // 根据模板id     清空所有   自定义事件
  cleanEventByComponentId?: (componentId: string) => void;
  // 根据模板code   清空所有    自定义事件
  cleanEventByComponentCode?: (componentCode: string) => void;

  
  //   获取所有子集的
  getChildrenList?: (id: string) => string[] | undefined;
  //   获取第一层的子集
  getRelationChildren: (id: string) => string[] | undefined;

  //  根据componentId-------->ComponentInfo
  getComponentInfoByComponentId: (componentId: string) => EditComponentInfo | undefined;
  //  code-------->ComponentInfo
  getComponentInfoByCode: (code: string) => EditComponentInfo | undefined;
  //  code-------->value
  getFieldValueByCode: (code: string) => void;
  //  componentId-------->value
  getFieldValueByComponentId: (componentId: string) => void;
  //  code type-------->拿到对应的属性
  getPropsByCode: (code: string, type: string) => void;
  //  componentId type-------->拿到对应的属性
  getPropsByComponentId: (componentId: string, type: string) => void;
  //  componentId   -------->拿到区域的子集
  getAreaChildrenListByComponentId: (componentId: string) => void;
  //  code   -------->拿到区域的子集
  getAreaChildrenListByCode: (code: string) => void;
  // 设置value通过componentId
  setFieldValueByComponentId: (componentId: string, value: string) => void;
  // 设置value通过code
  setFieldValueByCode: (code: string, value: string) => void;
  // 设置属性通过componentId
  setPropsByComponentId: (
    arrayData: {
      componentId: string;
      properties: Record<string, unknown>;
    }[],
  ) => void;
  // 设置属性通过code
  setPropsByCode: (
    arrayData: {
      code: string;
      properties: Record<string, unknown>;
    }[],
  ) => void;
  // dashboard信息
  getDashboardInfo: () => UseFormInfo | undefined;
  // 获取交互动作
  getInteractivesInfo: () => IInteractiveImplement | undefined;
  // 设置交互动作
  setInteractivesInfo: (value: IInteractiveImplement | undefined) => void;
   // 接口以及用户信息
  params: Record<string, unknown>;
};

Copy
{
  "textContent": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.textContent"
  },
  "richTextContent": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.content"
  },
  "dimensionExpression": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.valueKey"
  },
  "dimensionValue": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.value"
  },
  "iconContent": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.cssProps"
  },
  "imageUrl": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.url"
  },
  "queryDataFlag": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.queryDataFlag"
  },
  "filters": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.filters"
  },
  "refElementParams": {
    "reducerKey": "itemDataMap",
    "path": "customInfo.refElementParams"
  },
  "interactives": {
    "reducerKey": "interactivesImplement",
    "path": ""
  }
}

Copy
class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const { setInteractivesInfo, getInteractivesInfo,getComponentInfoByComponentId, getPropsByComponentId,setPropsByComponentId } = this.props;
   // 当前图表的所有信息
      // const chart = getComponentInfoByComponentId('RefBIChart_1655803992804_136') // 要获取的图表componentId
// { dataSource , commonFn: { onSearch }, refElementInfo: { options, config, chartRef } }
    // 图表的引用元素内部信息
      const refElementParams = getPropsByComponentId('RefBIChart_1655803992804_136', 'refElementParams')
      // 搜索时注意 字段名拼接方式:`${item.tableAlias}${item.columnName}`
      // chart?.customInfo?.refElementParams?.commonFn?.onSearch({ `${item.tableAlias}${item.columnName}`:"a4",Year:'as'})
      refElementParams?.refElementInfo?.chartRef?.on('click', (info) => {
        console.log(info)
      })
    // 清单表的js方法在页面中使用
    // console.log(refElementInfo?.jsParam?.tableFn?.getSelectData())

  }
  render() {
    return null;
  }
}

export default Demo;
Copy
class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const { setInteractivesInfo, getInteractivesInfo,getComponentInfoByComponentId, getPropsByComponentId,setPropsByComponentId } = this.props;
   // console.log(getInteractivesInfo(), '整个交互动作') // 获取整个dashboard的交互动作
      // setInteractivesInfo([])  // 设置整个dashboard的交互动作

      // 获取某个元素交互动作
      console.log(getPropsByComponentId('RefBIChart_1655708047946_214', 'interactives'));
      // 设置某个元素的交互动作
      setPropsByComponentId([
        {
          componentId: 'FilterDimension_1655957559031_228',
          properties: {
            dimensionExpression: `valueKey8888`,// 更改维度表达式
            interactives: { // 设置这个筛选器的交互动作
              to_new_page: [{
                "id": "INTERACTIVE_1655958616597_296",
                "name": "entity调整清单表",
                "triggerComponentId": "FilterDimension_1655957559031_228",
                "triggerAction": "to_new_page",
                "targetComponentId": null,
                "jumpElementDetail": {
                  "elementName": "llllll",
                  "folderId": "DIRb8b0beaf0392",
                  "path": "\\karl\\ListTable\\",
                  "elementType": "LST",
                  "serverName": "list-table-server1-2",
                  "relativePath": null,
                  "absoluteTag": true,
                  "id": "177ba267-dd69-4774-b9fb-c848c996e1a2",
                  "description": {},
                }
              }]
            }
          },
        },
      ]);

  }
  render() {
    return null;
  }
}

export default Demo;
Copy
class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const { getComponentInfoByComponentId, getComponentInfoByCode } = this.props;
   const dataId = 'Text_1655377280005_300'; // dashboard 最外层dom节点、每个区域的dom信息  dataId为componentId
    console.log(document.querySelector(`div[data-id=${dataId}]`))
  }
  render() {
    return null;
  }
}

export default Demo;

富文本

Copy
class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const { getComponentInfoByComponentId, getPropsByComponentId, setPropsByCode } = this.props;
    // 获取富文本元素的信息
    console.log(getPropsByComponentId('Text_1655377494282_134', 'richTextContent'))
    // 修改富文本中表格的数据
    setPropsByCode([
      {
        code: 'ImageText_755266326',
        properties: {
          richTextContent: `<p>图文展示</p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\"><colgroup><col style=\"width: 33.2402%;\"><col style=\"width: 33.2402%;\"><col style=\"width: 33.2402%;\"></colgroup>\n
    <tbody>\n
    <tr onclick="alert(8888)">\n<td>A1</td>\n<td>A2</td>\n<td>A3</td>\n</tr>\n
    <tr>\n<td>1</td>\n<td>内容</td>\n<td>111</td>\n</tr>\n
    <tr>\n<td>2</td>\n<td>22</td>\n<td>222</td>\n</tr>
    \n</tbody>\n</table>`,
        },
      },
    ]);
  }
  render() {
    return null;
  }
}

export default Demo;

getComponentInfoByComponentId:(componentId:string) => EditComponentInfo |undefined getComponentInfoByCode:(code:string) => EditComponentInfo |undefined

Copy
class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const { getComponentInfoByComponentId, getComponentInfoByCode } = this.props;
   console.log(getComponentInfoByComponentId('Text_1655377280005_300'));
    console.log(getComponentInfoByCode('Text_61da207e3'));
  }
  render() {
    return null;
  }
}

export default Demo;

getFieldValueByComponentId:(componentId:string) => string|undefined getFieldValueByCode:(code:string) => string|undefined

Copy
class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const { getFieldValueByComponentId,getFieldValueByCode } = this.props;
    console.log(getFieldValueByComponentId('Text_1655377280005_300'), '哈哈哈哈');
  }
  render() {
    return null;
  }
}

export default Demo;

getPropsByComponentId:(componentId: string, type: string) => string|undefined getPropsByCode:(code: string, type: string) => string|undefined

Copy
class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const { getPropsByComponentId,    getPropsByCode } = this.props;
   console.log(getPropsByComponentId('Text_1655377494282_134', 'textContent'))
    console.log(getPropsByCode('Text_c2fe44947', 'textContent'))
  }
  render() {
    return null;
  }
}

export default Demo;

setFieldValueByComponentId:(componentId: string, value:string[]) => void setFieldValueByCode:(code: string, value:string[]) => void

Copy
class Demo extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const {setFieldValueByComponentId ,  setFieldValueByCode } = this.props;
     setFieldValueByCode('Text_61da207e3', '设置成功了吗888')
    // setFieldValueByComponentId('Text_1655377280005_300', '设置成功了吗')
  }
  render() {
    return null;
  }
}

export default Demo;

setPropsByComponentId:(componentId: string; property: Record<string, unknown>;) => void setPropsByCode:(code: string; property: Record<string, unknown>;) => void

Copy
class Demo extends React.PureComponent {    c
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const {setPropsByComponentId  , setPropsByCode } = this.props;
      // setPropsByCode([
    //   {
    //     code: 'Text_61da207e3',
    //     properties: {
    //       textContent: `你你你你自定义js设置的内容`,
    //     },
    //   },
    //   {
    //     code: 'Account1',
    //     properties: {
    //       dimensionExpression: `valueKey8888`,
    //     },
    //   },
    // ]);
    
  }
  render() {
    return null;
  }
}

export default Demo;

|

html标准事件

onClick

onBlur

onChange

预设事件

onClickBefore

onClickAfter

预设事件返回数据 | return (continue,params) | | | continue:是否继续下一步 ; params带入下一步的数据 | | | continue === false ,则不执行后续逻辑 | | | params,则将该数据带入下一步操作中(需对应的业务逻辑支持) |

addEventByCode: (componentCode, eventType, fun) => void; addEventByComponentId: (componentCode, eventType, fun) => void;

Copy
// 预设事件:onClickBefore 点击前;onClickAfter 点击后;
addEventByComponentId('Button_9fe9bf13a', 'onClickBefore', (event, info) => {
      ...
});
  
// html标准事件 绑定
addEventByComponentId('Button_9fe9bf13a', 'onClick', (event, info) => {
      ...
});
addEventByComponentId('Button_9fe9bf13a', 'onBlur', (event, info) => {
      ...
});
addEventByComponentId('Button_9fe9bf13a', 'onChange', (event, info) => {
      ...
});

此方法为兜底方案,如果以上介绍的api不能满足需求时可以考虑使用。

参数

说明

类型

默认值

params

更新的数据信息

array || object

-

key

唯一标识,数据id

string

-

path

目标属性key,类似value、valueType…

string

-

value

目标属性的值

unknown

options

自定义特殊属性

object

hasSaveData

是否有保存到服务区的数据更新

boolean

Copy
 onUpInfo: (
    params: UpdateEntity | UpdateEntity[],
    options?: {
      hasSaveData?: boolean; // 是否有保存到服务区的数据更新
    },
  ) => void;
Copy
updateInfo({
      id: 'componentId',
      path: 'customInfo.aaa',
      value:'aaa',
    });

回到顶部

咨询热线

400-821-9199

我们使用 ChatGPT,基于文档中心的内容以及对话上下文回答您的问题。

ctrl+Enter to send