diff --git a/src/components/DataStandard/WorkForm/Design/config/form.tsx b/src/components/DataStandard/WorkForm/Design/config/form.tsx index b1a56f32070a749e527d1161f0e875b4cc77b3a4..9116eda753901f6cb290fca8bbc881537ab157fb 100644 --- a/src/components/DataStandard/WorkForm/Design/config/form.tsx +++ b/src/components/DataStandard/WorkForm/Design/config/form.tsx @@ -35,6 +35,7 @@ const FormConfig: React.FC = ({ notifyEmitter, current }) => { parentId: null, }; const [conditionText, setConditionText] = useState('[]'); + const [redRowRule, setRedRowRule] = useState('[]'); const [classifyDisplay, setClassifyDisplay] = useState(emptyData); const [authDisplay, setAuthDisplay] = useState('[]'); const [groupDisplay, setGroupDisplay] = useState('[]'); @@ -57,6 +58,18 @@ const FormConfig: React.FC = ({ notifyEmitter, current }) => { } }; + const setFilterRedRow = (value: string, text: string) => { + if (!current.metadata.options?.dataRange) { + current.metadata.options!.dataRange = {}; + } + if (tryParseJson(value)) { + current.metadata.options!.dataRange!.filterRedRowExp = value; + current.metadata.options!.dataRange!.filterRedRow = text; + } else { + current.metadata.options!.dataRange!.filterRedRowExp = undefined; + current.metadata.options!.dataRange!.filterRedRow = undefined; + } + }; const setAuthCondition = (value: string, text: string) => { if (!current.metadata.options?.dataRange) { current.metadata.options!.dataRange = {}; @@ -107,7 +120,11 @@ const FormConfig: React.FC = ({ notifyEmitter, current }) => { if (filterDisplay) { setConditionText(JSON.stringify(filterDisplay)); } - + + const filterRedRow = tryParseJson(current.metadata.options.dataRange?.filterRedRow); + if (filterRedRow) { + setRedRowRule(JSON.stringify(filterRedRow)); + } const classifyDisplay = tryParseJson( current.metadata.options.dataRange?.classifyDisplay, ); @@ -252,6 +269,20 @@ const FormConfig: React.FC = ({ notifyEmitter, current }) => { ) } /> + + loaded && ( + { + setFilterRedRow(value, text); + }} + /> + ) + } + /> diff --git a/src/executor/open/form/dictFormView.tsx b/src/executor/open/form/dictFormView.tsx index 143543b2dc2d30347fe65789f4e4311e601f2e71..ebaa24d79cf19052ac35ba0e01eacea76997fcaf 100644 --- a/src/executor/open/form/dictFormView.tsx +++ b/src/executor/open/form/dictFormView.tsx @@ -22,6 +22,7 @@ import { Form } from '@/ts/core/thing/standard/form'; import Sider from 'antd/lib/layout/Sider'; import { TreeViewTypes } from 'devextreme-react/cjs/tree-view'; import { userFormatFilter } from '@/utils/tools'; +import ArrayStore from 'devextreme/data/array_store'; interface IProps { form: schema.XForm; @@ -32,6 +33,8 @@ interface IProps { /** 表单查看--字典项过多 */ const DictFormView: React.FC = ({ form, directory, finished }) => { const [fields, setFields] = useState([]); + const [showHighLight, setShowHlighLight] = useState(false); + const [hasRedRowRule, setHasRedRowRule] = useState(false); const metaForm: IForm = new Form(form, directory); const [loaded] = useAsyncLoad(async () => { setFields(await metaForm.loadFields()); @@ -105,8 +108,14 @@ const DictFormView: React.FC = ({ form, directory, finished }) => { new CustomStore({ key: 'id', async load(loadOptions: any) { + const redRowRule = metaForm.parseRedRow(); + if (redRowRule) { + setHasRedRowRule(true); + } loadOptions.filter = await userFormatFilter(loadOptions.filter, metaForm); - loadOptions.filter = metaForm.parseFilter(loadOptions.filter); + // 显示高亮时判断过滤条件 + const filtter = showHighLight ? redRowRule : loadOptions.filter; + loadOptions.filter = metaForm.parseFilter(filtter); const classify = metaForm.parseClassify(); if (loadOptions.filter.length == 0 && Object.keys(classify).length == 0) { return { data: [], totalCount: 0 }; @@ -119,7 +128,21 @@ const DictFormView: React.FC = ({ form, directory, finished }) => { loadOptions.options.match = loadOptions.options.match || {}; loadOptions.options.match[selectMenu.item.code] = { _exists_: true }; } - return await metaForm.loadThing(loadOptions); + // return await metaForm.loadThing(loadOptions); + const res = await metaForm.loadThing(loadOptions); + const { data = [] } = res; + if (data && data.length > 0 && redRowRule) { + const flags = await new ArrayStore({ data }).load({ + filter: redRowRule, + }); + flags.forEach((item) => { + const index = data.findIndex((j) => j.id === item.id); + if (index > -1) { + data[index]['redRowFlag'] = true; + } + }); + } + return res; }, }) } @@ -140,6 +163,19 @@ const DictFormView: React.FC = ({ form, directory, finished }) => { toolbar={{ visible: true, items: [ + { + name: 'highlightButton', // 新增的按钮名称 + location: 'after', + visible:hasRedRowRule, + widget: 'dxButton', + options: { + text: showHighLight ? '显示全部' : '显示高亮', + onClick: () => { + // 这里添加您的点击事件逻辑 + setShowHlighLight(!showHighLight); + }, + }, + }, { name: 'print', location: 'after', diff --git a/src/executor/tools/generate/thingTable.tsx b/src/executor/tools/generate/thingTable.tsx index eea3233089a37e7571e68b97cd2914f142dc2bf0..4c49ceae485043c0fea8d32e067f0e32da071258 100644 --- a/src/executor/tools/generate/thingTable.tsx +++ b/src/executor/tools/generate/thingTable.tsx @@ -45,6 +45,14 @@ const GenerateThingTable = (props: IProps) => { item.options!.visible = false; } }); + + // 整行渲染设置 + const onRowPrepared = (e: any) => { + if(e.data?.redRowFlag){ + // 整行字体标红 + e.rowElement.style.color = 'red'; + } + }; return ( keyExpr="id" @@ -53,6 +61,7 @@ const GenerateThingTable = (props: IProps) => { height={props.height ?? '100%'} columnMinWidth={props.columnMinWidth ?? 80} focusedRowEnabled + onRowPrepared={onRowPrepared} allowColumnReordering allowColumnResizing columnAutoWidth @@ -106,7 +115,7 @@ const GenerateThingTable = (props: IProps) => { } else { let data = result.data; const userTypeList = fields.filter((i) => i.valueType === '用户型'); - data.forEach((item: any) => { + data.forEach((item: any, rowIndex) => { for (const column of columns) { const valueMap = (column.lookup as any)?.valueMap; if (valueMap && column.dataField) { @@ -123,6 +132,13 @@ const GenerateThingTable = (props: IProps) => { } } worksheet.addRow(item); + if (item.redRowFlag) { + // 在这里添加条件判断并设置字体颜色 + for (let colIndex = 0; colIndex < columns.length; colIndex++) { + const cell = worksheet.getCell(rowIndex+2, colIndex +1); + cell.font = { color: { argb: 'FF0000' } }; + } + } }); skip += result.data.length; if (e.selectedRowsOnly) { diff --git a/src/global.less b/src/global.less index 9f85fe99b7bba252692ba092e909f8ba42ec7bb2..25b02e8db7ffb761d5353866af84c3bc1c3067d1 100644 --- a/src/global.less +++ b/src/global.less @@ -340,6 +340,10 @@ h3 { border-top: 1px solid @border-color; } +.dx-auto-width .dx-texteditor-input { + max-width: 50px; +} + // 视频播放 .JoL-player-container { display: flex; diff --git a/src/ts/base/schema.ts b/src/ts/base/schema.ts index 6f097d539b65cf1030caa097d9616f9b95029ce3..3cab42b86d4ab4e6d7613262312ad14bebafabe9 100644 --- a/src/ts/base/schema.ts +++ b/src/ts/base/schema.ts @@ -304,6 +304,8 @@ export type XDefinedColl = { } & Xbase; export type XFormFilter = { + filterRedRow?: string; + filterRedRowExp?: string; filterExp?: string; filterDisplay?: string; classifyExp?: string; diff --git a/src/ts/core/thing/standard/form.ts b/src/ts/core/thing/standard/form.ts index 4e150b29068a980650e560f6faa74eb1366e83e4..09d613f91d9aeb05fe9d0d80593fa609abb8d335 100644 --- a/src/ts/core/thing/standard/form.ts +++ b/src/ts/core/thing/standard/form.ts @@ -65,6 +65,8 @@ export interface IForm extends IStandardFileInfo { parseFilter(filters?: any[]): any[]; /** 分类条件解析 */ parseClassify(): any; + /** 高亮设置解析 */ + parseRedRow(): any; /** 拼接查询条件 */ combineFilter(origin: any[], filters?: any[], isAuth?: boolean): any[]; /** 查询资产分类汇总数据 */ @@ -257,7 +259,7 @@ export class Form extends StandardFileInfo implements IForm { remark: i.remark, parentId: i.parentId, relevanceId: i.relevanceId, - propertyId: attr.property!.id + propertyId: attr.property!.id, }; }); } @@ -663,6 +665,20 @@ export class Form extends StandardFileInfo implements IForm { } return {}; } + + parseRedRow() { + const filterRedRowExp = this.metadata.options?.dataRange?.filterRedRowExp; + try { + if (filterRedRowExp) { + return JSON.parse(filterRedRowExp); + } + } catch (error) { + if (error instanceof Error) { + console.error(error.message); + } + } + return ''; + } parseFilter(filters: any[]) { try { let result: any[] = []; @@ -677,8 +693,8 @@ export class Form extends StandardFileInfo implements IForm { tableIdIndex >= 0 ? filterExpData[tableIdIndex] : filterExpData.filter( - (a: string | string[]) => Array.isArray(a) && a.indexOf('person') >= 0, - )[0]?.[0]; + (a: string | string[]) => Array.isArray(a) && a.indexOf('person') >= 0, + )[0]?.[0]; if (value && this.fields) { const lookups = this.fields.find((a) => a.code === value)?.lookups; const dictId = lookups?.find((a) => a.code === orgCtrl.user.code)?.id;