diff --git a/src/components/detail/common.tsx b/src/components/detail/common.tsx index 81eed866f62242fab0f3e7253ee5a6db563bc0ed..3c830feeecf449e1e7a4377317f0f1babf5c443e 100644 --- a/src/components/detail/common.tsx +++ b/src/components/detail/common.tsx @@ -3,7 +3,7 @@ import { ColumnsConfig, ParamConfig } from '../../interface' import { DetailFieldConfigs as getFieldConfigs } from './' import ParamHelper from '../../util/param' -import { CCMSConfig } from '../../main' +import { CCMSConfig, PageListItem } from '../../main' /** * 详情页表单项基类配置文件格式定义 @@ -93,6 +93,7 @@ export interface DetailFieldProps { baseRoute: string, loadDomain: (domain: string) => Promise loadPageConfig: (pageID: any) => Promise + loadPageList: () => Promise> handlePageRedirect: (path: string) => void checkPageAuth: (pageID: any) => Promise onUnmount: (reload?: boolean, data?: any) => Promise diff --git a/src/components/detail/group/index.tsx b/src/components/detail/group/index.tsx index 3858b556db6b3b6200d739e4db82a8245088eb42..c80378a3083a861dce1735c5bb9e8cb1a4bb05b7 100644 --- a/src/components/detail/group/index.tsx +++ b/src/components/detail/group/index.tsx @@ -204,6 +204,7 @@ export default class GroupField extends DetailField Promise} loadPageFrameURL={this.props.loadPageFrameURL as (pageID: any) => Promise} loadPageConfig={this.props.loadPageConfig as (pageID: any) => Promise} + loadPageList={this.props.loadPageList} loadDomain={this.props.loadDomain} handlePageRedirect={this.props.handlePageRedirect} onMount={() => { diff --git a/src/components/formFields/any/index.tsx b/src/components/formFields/any/index.tsx index 996a04cb568c22e55b091f4f459472d41bf28609..e7a4a8ae3e5e96ec3ffefb4d91b60dfcef8c9554 100644 --- a/src/components/formFields/any/index.tsx +++ b/src/components/formFields/any/index.tsx @@ -100,6 +100,7 @@ export default class AnyField extends Field : ( type === 'number' @@ -121,6 +122,7 @@ export default class AnyField extends Field : {}} @@ -140,6 +142,7 @@ export default class AnyField extends Field) })} diff --git a/src/components/formFields/common.tsx b/src/components/formFields/common.tsx index ae388d79f1ec6f0f09fb6f2a0b176d6dffd97245..3bc88d361158dc56e79381a519e1ef4936722f45 100644 --- a/src/components/formFields/common.tsx +++ b/src/components/formFields/common.tsx @@ -6,6 +6,7 @@ import ParamHelper from '../../util/param' import { updateCommonPrefixItem } from '../../util/value' import { ConditionConfig } from '../../util/condition' import { StatementConfig } from '../../util/statement' +import { PageListItem } from '../../main' import { isEqual, get } from 'lodash' /** @@ -99,6 +100,7 @@ export interface FieldProps { onReportFields?: (field: string) => Promise // 向父组件上报依赖字段 1.3.0新增 step: { [field: string]: any } // 传递formValue loadDomain: (domain: string) => Promise + loadPageList: () => Promise> } /** @@ -190,10 +192,7 @@ export class Field extends React.Component< } shouldComponentUpdate (nextProps: FieldProps, nextState: S) { - // console.log('nextProps', nextProps, this.props, nextProps.value == this.props.value); - const dependentFieldsArr = this.dependentFields - // console.log('dependentFieldsArr',dependentFieldsArr); let dependentIsChange = false if (dependentFieldsArr && dependentFieldsArr.length) { for (let i = dependentFieldsArr.length; i >= 0; i--) { @@ -212,7 +211,6 @@ export class Field extends React.Component< * record也不比较,需要比较的话就在dependentFieldsArr取出record绝对路径 * */ if (!dependentIsChange && isEqual(this.state, nextState) && nextProps.value === this.props.value && this.props.config === nextProps.config) { - // console.log('no update' ); return false } return true diff --git a/src/components/formFields/custom/index.tsx b/src/components/formFields/custom/index.tsx index 672607ee94060c76da248c1a81ade4a1713f2511..fcbafa767a9da4f23713bd7b4442b8e723d1ba53 100644 --- a/src/components/formFields/custom/index.tsx +++ b/src/components/formFields/custom/index.tsx @@ -64,9 +64,10 @@ export default class CustomField extends Field imple onValueListSplice: this.props.onValueListSplice, base: this.props.baseRoute, loadDomain: this.props.loadDomain, + loadPageList: this.props.loadPageList, bindValidate: this.bindValidate, bindGet: this.bindGet - }); + }) } } } @@ -93,6 +94,7 @@ export default class CustomField extends Field imple onValueListSplice: this.props.onValueListSplice, base: this.props.baseRoute, loadDomain: this.props.loadDomain, + loadPageList: this.props.loadPageList, bindValidate: this.bindValidate, bindGet: this.bindGet } diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index cbf19b9c7e0fa481d653b6c9415101148b92fe8f..f5c0f57d2e7b0b2f7b0a219cfc451f0fbfaf6cff 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -521,6 +521,7 @@ export default class FormField extends Field await this.props.loadDomain(domain)} containerPath={getChainPath(this.props.containerPath, this.props.config.field, index)} onReportFields={async (field: string) => await this.handleReportFields(field)} + loadPageList={async () => await this.props.loadPageList()} /> ) }) diff --git a/src/components/formFields/group/index.tsx b/src/components/formFields/group/index.tsx index d5fc658862e5d60f0771dc4cc7cff08b156065e1..91144e9b6654983b76267d34798791436aef76f9 100644 --- a/src/components/formFields/group/index.tsx +++ b/src/components/formFields/group/index.tsx @@ -342,6 +342,7 @@ export default class GroupField extends Field this.handleValueListSort(formFieldIndex, path, index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} + loadPageList={async () => await this.props.loadPageList()} containerPath={getChainPath(this.props.containerPath, this.props.config.field)} onReportFields={async (field: string) => await this.handleReportFields(field)} /> diff --git a/src/components/formFields/importSubform/index.tsx b/src/components/formFields/importSubform/index.tsx index f2e7feda25c1b4d7e9fa1a9a18ce8d68d9fdf828..c0813c905ad7994b2d87526073195df679fbf849 100644 --- a/src/components/formFields/importSubform/index.tsx +++ b/src/components/formFields/importSubform/index.tsx @@ -571,6 +571,7 @@ export default class ImportSubformField } baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} + loadPageList={async () => await this.props.loadPageList()} containerPath={getChainPath(this.props.containerPath, this.props.config.field)} onReportFields={async (field: string) => await this.handleReportFields(field)} /> diff --git a/src/components/formFields/object/index.tsx b/src/components/formFields/object/index.tsx index b43626a93394c59256544e5aac9de56e05646aba..350d728d240c3ea681790d164dad2eebbec8331f 100644 --- a/src/components/formFields/object/index.tsx +++ b/src/components/formFields/object/index.tsx @@ -483,6 +483,7 @@ export default class ObjectField extends Field this.handleValueListSort(key, formFieldIndex, path, _index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => this.props.loadDomain(domain)} + loadPageList={async () => await this.props.loadPageList()} containerPath={getChainPath(this.props.containerPath, this.props.config.field, key)} onReportFields={async (field: string) => await this.handleReportFields(field)} /> diff --git a/src/components/formFields/tabs/index.tsx b/src/components/formFields/tabs/index.tsx index 8993b5e2a94290eed8c34619776aa684f04545d9..b6316cb0acf2b8c21bb78e9a8935a2d6b4a81ce2 100644 --- a/src/components/formFields/tabs/index.tsx +++ b/src/components/formFields/tabs/index.tsx @@ -398,6 +398,7 @@ export default class TabsField extends Field await this.props.loadDomain(domain)} containerPath={getChainPath(this.props.containerPath, this.props.config.field, tab.field)} onReportFields={async (field: string) => await this.handleReportFields(field)} + loadPageList={async () => await this.props.loadPageList()} /> ) })} diff --git a/src/main.tsx b/src/main.tsx index 9097913b4d96177a8f23eb82f89673b343e6d7a6..2aadfb63031b4097292ea51c7dd6cafb0a18e3b9 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -3,6 +3,7 @@ import marked from 'marked' import Step, { StepProps } from './steps/common' import StepComponents, { StepConfigs } from './steps' import { RichStringConfig } from './interface' + /** * 页面配置文件格式定义 * - basic: 页面基本配置 @@ -45,6 +46,7 @@ export interface CCMSProps { loadPageURL: (pageID: any) => Promise loadPageFrameURL: (pageID: any) => Promise loadPageConfig: (pageID: any) => Promise + loadPageList: () => Promise> loadDomain: (domain: string) => Promise handlePageRedirect?: (path: string, replaceHistory: boolean) => void callback: (success: boolean) => void @@ -64,6 +66,20 @@ export interface CCMSState { data: any[] } +/** + * 页面列表项 + * - key: 此项必须设置(其值在整个树范围内唯一) + * - value: 默认根据此属性值进行筛选(其值在整个树范围内唯一) + * - title: 树节点显示的内容 + * - children: 子节点 + */ + export interface PageListItem { + key: string | number + value: string | number + title: string + children?: Array +} + /** * 页面组件 */ @@ -233,6 +249,7 @@ export default class CCMS extends React.Component { loadPageURL, loadPageFrameURL, loadPageConfig, + loadPageList, loadDomain, handlePageRedirect } = this.props @@ -275,6 +292,7 @@ export default class CCMS extends React.Component { loadPageURL, loadPageFrameURL, loadPageConfig, + loadPageList, loadDomain, handlePageRedirect, handleFormValue diff --git a/src/steps/common.tsx b/src/steps/common.tsx index a9a0d61618d530762c94b511b46aa3054a649ad3..d7bb160b658c66006c2315307f5d89ce96ad2eb2 100644 --- a/src/steps/common.tsx +++ b/src/steps/common.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { CCMSConfig } from '../main' +import { CCMSConfig, PageListItem } from '../main' /** * 页面流转步骤基类配置定义 @@ -30,6 +30,7 @@ export interface StepProps { loadPageURL: (pageID: any) => Promise loadPageFrameURL: (pageID: any) => Promise loadPageConfig: (pageID: any) => Promise + loadPageList: () => Promise> baseRoute: string loadDomain: (domain: string) => Promise handlePageRedirect?: (path: string, replaceHistory: boolean) => void diff --git a/src/steps/detail/index.tsx b/src/steps/detail/index.tsx index 7545e8b90ca938e9e8fa13ef1d5575ffff1b48b3..232a28ef83caf7f5a329d3213817107a31fb89e8 100644 --- a/src/steps/detail/index.tsx +++ b/src/steps/detail/index.tsx @@ -384,6 +384,7 @@ export default class DetailStep extends Step { onUnmount={this.props.onUnmount} checkPageAuth={this.props.checkPageAuth} loadPageConfig={this.props.loadPageConfig} + loadPageList={this.props.loadPageList} loadPageURL={this.props.loadPageURL} loadPageFrameURL={this.props.loadPageFrameURL} handlePageRedirect={() => this.props.handlePageRedirect} diff --git a/src/steps/filter/index.tsx b/src/steps/filter/index.tsx index e6aad5ee0b9d9ff0aaa5d06ec802b40dc36040f8..6d4c8bc83fce7aea4dd96dfca77cd1712def3f99 100644 --- a/src/steps/filter/index.tsx +++ b/src/steps/filter/index.tsx @@ -506,6 +506,7 @@ export default class FilterStep extends Step { onValueListSort={async (path, index, sortType, validation, options) => await this.handleValueListSort(formFieldIndex, path, index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} + loadPageList={async () => await this.props.loadPageList()} containerPath={''} /> ) diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index 45d0e8536bb8a2c01c7ffee1ac5cdf370c4ff451..cd077f19bf51e281df6548f347ab3b12cf7d3578 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -625,6 +625,7 @@ export default class FormStep extends Step { // ts对clas loadPageURL={this.props.loadPageURL} loadPageFrameURL={this.props.loadPageFrameURL} loadPageConfig={this.props.loadPageConfig} + loadPageList={this.props.loadPageList} baseRoute={this.props.baseRoute} loadDomain={this.props.loadDomain} handlePageRedirect={this.props.handlePageRedirect} @@ -738,6 +739,7 @@ export default class FormStep extends Step { // ts对clas onValueListSort={async (path, index, sortType, validation, options) => await this.handleValueListSort(formFieldIndex, path, index, sortType, validation, options)} baseRoute={this.props.baseRoute} loadDomain={async (domain: string) => await this.props.loadDomain(domain)} + loadPageList={async () => await this.props.loadPageList()} containerPath={''} /> ) diff --git a/src/steps/header/index.tsx b/src/steps/header/index.tsx index 8e8861f30f1ae5a59358c622623a184f6830d3cd..78cd9c5c278f884ef3898802557bf9b44f29f595 100644 --- a/src/steps/header/index.tsx +++ b/src/steps/header/index.tsx @@ -234,6 +234,7 @@ export default class HeaderStep extends Step { loadPageURL={this.props.loadPageURL} loadPageFrameURL={this.props.loadPageFrameURL} loadPageConfig={this.props.loadPageConfig} + loadPageList={this.props.loadPageList} loadDomain={this.props.loadDomain} handlePageRedirect={this.props.handlePageRedirect} /> @@ -306,6 +307,7 @@ export default class HeaderStep extends Step { loadPageURL={this.props.loadPageURL} loadPageFrameURL={this.props.loadPageFrameURL} loadPageConfig={this.props.loadPageConfig} + loadPageList={this.props.loadPageList} baseRoute={this.props.baseRoute} loadDomain={this.props.loadDomain} handlePageRedirect={this.props.handlePageRedirect} diff --git a/src/steps/table/index.tsx b/src/steps/table/index.tsx index cb1c73d2aaa9978386d2e8fe0c2dabadc2d3a00d..b47104ff94c23fe5359d1c485812bd2d161ae3db 100644 --- a/src/steps/table/index.tsx +++ b/src/steps/table/index.tsx @@ -892,6 +892,7 @@ export default class TableStep extends Step { loadPageURL={this.props.loadPageURL} loadPageFrameURL={this.props.loadPageFrameURL} loadPageConfig={this.props.loadPageConfig} + loadPageList={this.props.loadPageList} loadDomain={this.props.loadDomain} handlePageRedirect={this.props.handlePageRedirect} onMount={() => { @@ -931,6 +932,7 @@ export default class TableStep extends Step { loadPageURL={this.props.loadPageURL} loadPageFrameURL={this.props.loadPageFrameURL} loadPageConfig={this.props.loadPageConfig} + loadPageList={this.props.loadPageList} loadDomain={this.props.loadDomain} handlePageRedirect={this.props.handlePageRedirect} onMount={() => { diff --git a/src/util/operation.tsx b/src/util/operation.tsx index 0aae17251e39eeb5fc531b8bd1153579d4d429eb..d7e7018d25be7bf04793b4702675996dd55000b3 100644 --- a/src/util/operation.tsx +++ b/src/util/operation.tsx @@ -1,9 +1,8 @@ import React from 'react' import queryString from 'query-string' -// import { set } from "lodash"; import { set } from '../util/produce' import { ParamConfig } from '../interface' -import { CCMSConfig, CCMSProps } from '../main' +import { CCMSConfig, CCMSProps, PageListItem } from '../main' import { getParam } from './value' export type OperationConfig = CCMSOperationConfig @@ -57,6 +56,7 @@ interface OperationHelperProps { loadPageURL: (pageID: any) => Promise, loadPageFrameURL: (pageID: any) => Promise, loadPageConfig: (pageID: any) => Promise, + loadPageList: () => Promise>, baseRoute: string, loadDomain: (domain: string) => Promise handlePageRedirect?: (path: string, replaceHistory: boolean) => void @@ -97,6 +97,7 @@ export default class OperationHelper extends React.Component { @@ -152,6 +153,7 @@ export default class OperationHelper extends React.Component { @@ -180,6 +182,7 @@ export default class OperationHelper extends React.Component {