lx-admin-frontend/src/bpmn/hooks/useParseElement.ts

35 lines
650 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { ModdleElement } from 'bpmn';
interface Options {
element: ModdleElement;
}
interface Data {
id: string;
}
export default (ops: Options) => {
const { element } = ops;
const parseData = <T>(): T => {
const result = {
...element.businessObject,
...element.businessObject.$attrs
};
// 移除flowable前缀格式化数组
for (const key in result) {
if (key.indexOf('flowable:') === 0) {
const newKey = key.replace('flowable:', '');
result[newKey] = result[key];
delete result[key];
}
}
return { ...result } as T;
};
return {
parseData
};
};