diff --git a/src/executor/index.tsx b/src/executor/index.tsx index 550e1e77f2686d5f0d0e084c81915f40ff75951d..be7aa6708440d6f237ee3dca5dafc583861e3428 100644 --- a/src/executor/index.tsx +++ b/src/executor/index.tsx @@ -87,6 +87,7 @@ const Executor: React.FC = () => { setPreview(<>)} />, ); diff --git a/src/executor/open/form/detail/rfidprint/dasprint.tsx b/src/executor/open/form/detail/rfidprint/dasprint.tsx index f87fe16d17b9f270b8f001d4011fb2552dc6c73f..850533c0e32b01f6bc99d9111f76813be6699469 100644 --- a/src/executor/open/form/detail/rfidprint/dasprint.tsx +++ b/src/executor/open/form/detail/rfidprint/dasprint.tsx @@ -1,9 +1,11 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { schema } from '@/ts/base'; import FullScreenModal from '@/components/Common/fullScreen'; import { Button, Form as FormAntd, InputNumber, Radio, message } from 'antd'; +import { IForm } from '@/ts/core'; interface Iprops { things: schema.XThing[]; + form: IForm; configData: { itemKey: string; itemName: string; @@ -28,7 +30,14 @@ let printForm = { }; let dsChoose: string = 'yes'; let port; -export const DasPrint: React.FC = ({ things, configData, finished }) => { +export const DasPrint: React.FC = ({form, things, configData, finished }) => { + // 读取配置 + useEffect(()=>{ + if(form.metadata.DSRFIDConfig){ + printForm = form.metadata.DSRFIDConfig + console.log(printForm); + } + },[]) // 得实打印 // 启动打印服务 const getDSInitService = () => { @@ -204,10 +213,15 @@ export const DasPrint: React.FC = ({ things, configData, finished }) => 已安装得实打印助手并启动 未安装得实打印助手并启动 + { const value = e; if (value) { @@ -218,7 +232,7 @@ export const DasPrint: React.FC = ({ things, configData, finished }) => { const value = e; if (value) { @@ -229,7 +243,7 @@ export const DasPrint: React.FC = ({ things, configData, finished }) => { const value = e; if (value) { @@ -240,7 +254,7 @@ export const DasPrint: React.FC = ({ things, configData, finished }) => { const value = e; if (value) { @@ -251,7 +265,7 @@ export const DasPrint: React.FC = ({ things, configData, finished }) => { const value = e; if (value) { @@ -262,7 +276,7 @@ export const DasPrint: React.FC = ({ things, configData, finished }) => { const value = e; if (value) { @@ -273,7 +287,7 @@ export const DasPrint: React.FC = ({ things, configData, finished }) => { const value = e; if (value) { @@ -284,7 +298,7 @@ export const DasPrint: React.FC = ({ things, configData, finished }) => { const value = e; if (value) { diff --git a/src/executor/open/form/index.tsx b/src/executor/open/form/index.tsx index 1bfc34fbe9feb736aad5a6ea0af3db0ac2965b05..de752b34eb551982ff73c00387908e94e3a75022 100644 --- a/src/executor/open/form/index.tsx +++ b/src/executor/open/form/index.tsx @@ -107,8 +107,9 @@ const FormView: React.FC = ({ form, finished }) => { const [service, setService] = useState(null!); const [fieldModalVisible, setFieldModalVisible] = useState(false); const [selectedFields, setSelectedFields] = useState( - // 字段选择状态 - configData.map((configData) => configData.itemKey), + form.metadata?.DSRFIDFields?.length > 0 + ? form.metadata.DSRFIDFields + : configData.map((configData) => configData.itemKey) ); async function showDocumentConfig(row: schema.XThing, config: WorkDocumentConfig) { let data = { ...row }; @@ -393,16 +394,31 @@ const FormView: React.FC = ({ form, finished }) => { case 'Das': console.log(form.fields); fieldData = []; - fieldData.push(...configData); + if(form.metadata.DSRFIDFields && form.metadata.DSRFIDFields.length > 0){ + for(const item of form.metadata.DSRFIDFields){ + let target = form.fields.find(part => part.propId == item) + if(target){ + fieldData.push({itemKey: target.propId,itemName: target.name}) + } else { + if (item == 'id') { + fieldData.push({ itemKey: item, itemName: '资产唯一标识' }); + } else if (item == 'belongId') { + fieldData.push({ itemKey: item, itemName: '归属' }); + } + } + } + } else { + fieldData.push(...configData); + } for (const item of form.fields) { - let isExists = configData.find( - (part) => part.itemKey == item.id, + let isExists = fieldData.find( + (part) => part.itemKey == item.propId, ); if (isExists) { continue; } else { fieldData.push({ - itemKey: item.id, + itemKey: item.propId, itemName: item.name, }); } @@ -575,6 +591,7 @@ const FormView: React.FC = ({ form, finished }) => { console.log(selectedFields); const formattedData = await Promise.all( editData.rows.map(async (row) => { + console.log(row); const formattedRow: FormattedRow = {}; for (const item of selectedFields) { if (item === 'belongId') { @@ -582,6 +599,8 @@ const FormView: React.FC = ({ form, finished }) => { id: row[item], }); formattedRow[item] = result.data.name; + } else if(item == 'id') { + formattedRow[item] = row[item]; } else { formattedRow[item] = row[item]; } @@ -592,9 +611,17 @@ const FormView: React.FC = ({ form, finished }) => { console.log(formattedData); let printFields = []; for (const item of selectedFields) { - let target = form.fields.find((part) => part.id == item); + let target = form.fields.find((part) => part.propId == item); if (target) { - printFields.push({ itemKey: target.id, itemName: target.name }); + printFields.push({ itemKey: target.propId, itemName: target.name }); + if(target.lookups && target.lookups.length > 0){ + for(const item of formattedData){ + let findres = target.lookups.find(part => part.value == item[target.propId]) + if(findres){ + item[target.propId] = findres.text; + } + } + } } else { if (item == 'id') { printFields.push({ itemKey: item, itemName: '资产唯一标识' }); @@ -607,6 +634,7 @@ const FormView: React.FC = ({ form, finished }) => { printData: formattedData, printField: printFields, }; + console.log(datas); command.emitter('executor', 'RFIDPrint', form, 'Das', datas); setFieldModalVisible(false); }; @@ -629,7 +657,19 @@ const FormView: React.FC = ({ form, finished }) => { cancelText="取消" onOk={handleDasPrint} onCancel={() => setFieldModalVisible(false)}> -

请勾选需要打印的字段(可拖动调整顺序):

+

请勾选需要打印的字段:

+ ({ key: config.itemKey,