2024-01-21 18:13:15 +08:00
|
|
|
|
import { Ref } from 'vue';
|
|
|
|
|
import usePanel from '@/components/BpmnDesign/hooks/usePanel';
|
|
|
|
|
|
2024-01-21 15:59:33 +08:00
|
|
|
|
interface Options {
|
|
|
|
|
modeler: any;
|
|
|
|
|
element: any;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-21 18:13:15 +08:00
|
|
|
|
interface Data {
|
|
|
|
|
id: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default <T extends Data>(ops: Options) => {
|
|
|
|
|
const { modeler, element } = ops;
|
2024-01-21 15:59:33 +08:00
|
|
|
|
|
2024-01-21 18:13:15 +08:00
|
|
|
|
const formData = ref<any>({});
|
2024-01-21 15:59:33 +08:00
|
|
|
|
const parse = () => {
|
|
|
|
|
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];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ('documentation' in result) {
|
|
|
|
|
let str = '';
|
|
|
|
|
result.documentation.forEach((item: any) => {
|
|
|
|
|
str += item.text;
|
|
|
|
|
});
|
|
|
|
|
result.documentation = str;
|
|
|
|
|
}
|
|
|
|
|
formData.value = result;
|
|
|
|
|
return formData;
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-21 18:13:15 +08:00
|
|
|
|
onBeforeMount(() => {
|
|
|
|
|
parse();
|
|
|
|
|
});
|
|
|
|
|
|
2024-01-21 15:59:33 +08:00
|
|
|
|
return {
|
|
|
|
|
parse,
|
2024-01-21 18:13:15 +08:00
|
|
|
|
formData: formData as Ref<T>
|
2024-01-21 15:59:33 +08:00
|
|
|
|
};
|
|
|
|
|
};
|