From 7d7968a6bcdf6dedc9a1935f9fb87d0362188239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BD=B3=E9=91=AB?= <695997094@qq.com> Date: Tue, 26 Nov 2024 14:09:31 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/Components/Button/ButtonModal.tsx | 13 +- src/components/Directory/index.tsx | 1 + src/executor/open/form/detail/index.tsx | 1 + src/executor/tools/editModal/index.tsx | 4 +- .../tools/editModal/workSelectModal.tsx | 114 ++++++++++++++++++ src/executor/tools/task/start/default.tsx | 36 +++++- src/executor/tools/workForm/detail.tsx | 22 ++++ src/executor/tools/workForm/index.tsx | 3 + src/executor/tools/workForm/primary.tsx | 53 +++++++- src/ts/base/model.ts | 2 +- src/ts/core/thing/standard/form.ts | 1 + 11 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 src/executor/tools/editModal/workSelectModal.tsx diff --git a/src/components/Common/FlowDesign/Config/Components/Button/ButtonModal.tsx b/src/components/Common/FlowDesign/Config/Components/Button/ButtonModal.tsx index 85319ab65..a7c4770ac 100644 --- a/src/components/Common/FlowDesign/Config/Components/Button/ButtonModal.tsx +++ b/src/components/Common/FlowDesign/Config/Components/Button/ButtonModal.tsx @@ -170,11 +170,12 @@ const ButtonModal: React.FC = (props) => { options={[ { label: '手动规则', value: 'rule' }, { label: '手动执行器', value: 'executor' }, + { label: '获取办事数据', value: 'getWorkData' }, ]} onSelect={setType} /> - {type == 'rule' ? ( + {type === 'rule' ? ( ({ - label: r.funcName, - value: r.id, + options={executors.map((e) => ({ + label: e.funcName, + value: e.id, }))} /> - )} + ) : null} )} diff --git a/src/components/Directory/index.tsx b/src/components/Directory/index.tsx index 2f983803e..2928ed17c 100644 --- a/src/components/Directory/index.tsx +++ b/src/components/Directory/index.tsx @@ -57,6 +57,7 @@ const Directory: React.FC = ({ root }) => { } return true; }); + console.log(data, 'data===>'); if (file.key === directory.key) { setLoaded(true); setContent(data); diff --git a/src/executor/open/form/detail/index.tsx b/src/executor/open/form/detail/index.tsx index f66e5db11..fb3c23877 100644 --- a/src/executor/open/form/detail/index.tsx +++ b/src/executor/open/form/detail/index.tsx @@ -18,6 +18,7 @@ interface IProps { * @returns */ const ThingView: React.FC = (props) => { + console.log(props, 'props=====>'); const ThingActive = localStorage.getItem('activeView'); const [activeTabKey, setActiveTabKey] = useState(ThingActive ? ThingActive : 'card'); diff --git a/src/executor/tools/editModal/index.tsx b/src/executor/tools/editModal/index.tsx index 65eb456e8..cf05266ed 100644 --- a/src/executor/tools/editModal/index.tsx +++ b/src/executor/tools/editModal/index.tsx @@ -2,10 +2,12 @@ import FormEditModal from './formEditModal'; import FormSelectModal from './formSelectModal'; import SummaryFormModal from './summaryFormModal'; import MapSelectModal from './mapSelectModal'; +import WorkSelectModal from './workSelectModal'; export const EditModal = { showFormEdit: FormEditModal, showFormSelect: FormSelectModal, SummaryFormModal: SummaryFormModal, - mapSelectModal: MapSelectModal + mapSelectModal: MapSelectModal, + workSelectModal: WorkSelectModal, }; diff --git a/src/executor/tools/editModal/workSelectModal.tsx b/src/executor/tools/editModal/workSelectModal.tsx new file mode 100644 index 000000000..56575b7e4 --- /dev/null +++ b/src/executor/tools/editModal/workSelectModal.tsx @@ -0,0 +1,114 @@ +import EntityIcon from '@/components/Common/GlobalComps/entityIcon'; +import GenerateThingTable from '@/executor/tools/generate/thingTable'; +import { model, schema } from '@/ts/base'; +import { IBelong } from '@/ts/core'; +import { message, Modal } from 'antd'; +import CustomStore from 'devextreme/data/custom_store'; +import React, { useState } from 'react'; +import * as config from '../../open/form/config'; +import { Form } from '@/ts/core/thing/standard/form'; +import useAsyncLoad from '@/hooks/useAsyncLoad'; +import { userFormatFilter } from '@/utils/tools'; +import orgCtrl from '@/ts/controller'; + +interface IProps { + form: schema.XForm; + belong: IBelong; + onSave: (values: model.InstanceDataModel | undefined) => void; +} + +/** 获取办事信息 */ +const WorkSelectModal = ({ form, belong, onSave }: IProps) => { + const editData: { rows: schema.XThing[] } = { rows: [] }; + let instanceData: model.InstanceDataModel | undefined = undefined; + const metaForm = new Form(form, belong.directory); + + const FormBrower: React.FC = () => { + const [selectMenu, setSelectMenu] = useState(); + + const [loaded] = useAsyncLoad(async () => { + await metaForm.loadFields(); + const menuData = config.loadSpeciesItemMenu(metaForm); + setSelectMenu(menuData); + }); + + if (!selectMenu && !loaded) return <>; + + const loadContent = () => { + return ( + { + editData.rows = e.selectedRowsData; + }} + onRowDblClick={async (e: any) => { + const instance = Object.values(e.data?.archives).at( + -1, + ) as unknown as schema.XWorkInstance; + const detail = await orgCtrl.work.loadInstanceDetail( + instance.id, + instance.shareId, + instance.belongId, + ); + if (detail) { + const data = JSON.parse(detail?.data || '{}'); + instanceData = data; + } else { + message.warning('未查询到办事信息!'); + } + }} + dataSource={ + new CustomStore({ + key: 'id', + async load(loadOptions: any) { + loadOptions.filter = await userFormatFilter(loadOptions.filter, metaForm); + loadOptions.filter = metaForm.parseFilter(loadOptions.filter); + loadOptions.userData = []; + if (selectMenu?.item?.value) { + loadOptions.userData.push(selectMenu?.item.value); + } else if (selectMenu?.item?.code) { + loadOptions.options = loadOptions.options || {}; + loadOptions.options.match = loadOptions.options.match || {}; + loadOptions.options.match[selectMenu?.item.code] = { _exists_: true }; + } + return await metaForm.loadThing(loadOptions); + }, + }) + } + remoteOperations={true} + toolbar={{ + visible: true, + items: [], + }} + /> + ); + }; + return {loadContent()}; + }; + + const modal = Modal.confirm({ + icon: , + width: '90vw', + okText: `确认选择`, + className: 'selects-modal', + cancelText: '关闭', + onCancel: () => modal.destroy(), + content: , + onOk: () => { + modal.destroy(); + onSave(instanceData); + }, + }); +}; + +export default WorkSelectModal; diff --git a/src/executor/tools/task/start/default.tsx b/src/executor/tools/task/start/default.tsx index aca6c5d7e..aee515db5 100644 --- a/src/executor/tools/task/start/default.tsx +++ b/src/executor/tools/task/start/default.tsx @@ -3,7 +3,7 @@ import FormValidateMessage from '@/components/Common/Validate/FormValidateMessag import FormItem from '@/components/DataStandard/WorkForm/Viewer/formItem'; import Confirm from '@/executor/open/reconfirm'; import WorkForm from '@/executor/tools/workForm'; -import { command } from '@/ts/base'; +import { command, model, schema } from '@/ts/base'; import { FieldModel, NodeCodeRule, @@ -36,6 +36,7 @@ import { CloseOutlined, DownOutlined } from '@ant-design/icons'; import PrintConfigModal from '@/components/Common/FlowDesign/Config/Components/PrintNode/PrintModal'; import { createRoot } from 'react-dom/client'; import PrintTemplate from '@/components/Common/FlowDesign/Config/Components/PrintNode/printTemplate'; +import { EditModal } from '../../editModal'; // 卡片渲染 interface IProps { @@ -73,6 +74,7 @@ const DefaultWayStart: React.FC = ({ const [resource, setResource] = useState(); const [ser, setSer] = useState(); const [printModal, setPrintModal] = useState(false); + const [instanceData, setInstanceData] = useState(); const service = useRef( new WorkFormService(apply.target, apply.instanceData, true, apply.reception), ); @@ -127,6 +129,15 @@ const DefaultWayStart: React.FC = ({ return reception.metadata.content; }, [reception]); + function updateData(obj1: schema.XThing, obj2: schema.XThing) { + for (let key in obj2) { + if (obj1.hasOwnProperty(key)) { + obj1[key] = obj2[key]; + } + } + return obj1; + } + async function handleClick(current: WorkNodeButton) { const node = apply.instanceData.node; try { @@ -146,6 +157,21 @@ const DefaultWayStart: React.FC = ({ console.warn('不支持规则 ' + rule.type); return; } + } else if (current.type == 'getWorkData') { + EditModal.workSelectModal({ + form: current.form?.metadata!, + belong: apply.target.space, + onSave: (values: model.InstanceDataModel | undefined) => { + if (values) { + const res = updateData( + apply.instanceData.data[apply.primaryForms[0].id][0].after.at(-1)!, + values.data[values.node.primaryForms[0].id][0].after.at(-1)!, + ); + apply.instanceData.data[apply.primaryForms[0].id][0].after[0] = res; + setInstanceData(values); + } + }, + }); } else { message.warn('暂不支持执行器'); } @@ -313,6 +339,7 @@ const DefaultWayStart: React.FC = ({ nodeId={apply.instanceData.node.id} service={service.current} splitDetailFormId={splitDetailFormId} + instanceData={instanceData} /> @@ -566,12 +593,15 @@ const DefaultWayStart: React.FC = ({