diff --git a/src/pages/examine/modal/index.tsx b/src/pages/examine/modal/index.tsx index 860764e..b9d03b6 100644 --- a/src/pages/examine/modal/index.tsx +++ b/src/pages/examine/modal/index.tsx @@ -1,7 +1,7 @@ import LeftSelectTree from "@/components/leftSelectTree/leftSelectTree"; import { handleGetServerpartDDL } from "@/components/leftSelectTree/service"; import { ActionType, FormInstance, ProCard, ProForm, ProFormList, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextArea, ProTable } from "@ant-design/pro-components"; -import { Button, Col, message, Modal, Popconfirm, Row, Space, Image } from "antd"; +import { Button, Col, message, Modal, Popconfirm, Row, Space, Image, Drawer } from "antd"; import moment from "moment"; import { useRef, useState } from "react"; import { connect } from "umi"; @@ -9,6 +9,7 @@ import { handleAddTemplates, handleDeleteTemplates, handleGetQuestionList, handl import { handleGetExamineTypeTreeList } from "../index/service"; import QRCode from 'qrcode'; import { base64ToFile } from "@/utils/publicMethods"; +import RecordDetail from "../record/components/recordDetail"; const examineModal: React.FC<{ currentUser: any }> = (props) => { @@ -29,6 +30,8 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { // 显示新增点位的悬浮框 const [showPlaceModal, setShowPlaceModal] = useState(false) + // 显示详情 + const [showDetail, handleShowDetail] = useState(false) // 当前点击选中的问题行 const [currentRow, setCurrentRow] = useState() // 服务区的枚举 @@ -160,7 +163,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { align: 'center', hideInSearch: true, fixed: "right", - width: 100, + width: 120, render: (_: any, record: any) => { return { @@ -168,6 +171,10 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { setCurrentRow(record) setShowPlaceModal(true) }}>编辑 + { + setCurrentRow(record) + handleShowDetail(true) + }}>详情 { @@ -650,6 +657,20 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { /> + + + { + handleShowDetail(false) + }} + open={showDetail} + destroyOnClose + width={'60%'} + > + + ) } diff --git a/src/pages/examine/record/components/recordDetail.tsx b/src/pages/examine/record/components/recordDetail.tsx index 478e800..b877485 100644 --- a/src/pages/examine/record/components/recordDetail.tsx +++ b/src/pages/examine/record/components/recordDetail.tsx @@ -14,8 +14,9 @@ import './printStyle.css'; type DetailProps = { parentRow: any; // 父级数据 show: boolean;// 抽屉是否显示 + detailType: string; // 详情的类型 } -const RecordDetail = ({ parentRow, show }: DetailProps) => { +const RecordDetail = ({ parentRow, show, detailType }: DetailProps) => { const formRef = useRef(); @@ -31,11 +32,13 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { const [footerContent, setFooterContent] = useState('') const headerRef = useRef(null) const footerRef = useRef(null) + // 考核分类的对象格式 + const [examineObj, setExamineObj] = useState() const columns: any = [ { title: "考核分类", - dataIndex: "" + dataIndex: "name" }, { title: "考核子类", @@ -47,6 +50,21 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { { title: "考核结果", dataIndex: "title", + hideInTable: detailType === 'modal', + render: (_, record) => { + let str: string = '' + if (record.choiceResponse && record?.choiceResponse.length > 0) { + record.choiceResponse.forEach((item: any, index: number) => { + str += `${index > 0 ? ',' : ''}答案${index + 1}:${item}` + }) + } + return str || "" + } + }, + { + title: "考核选项", + dataIndex: "title", + hideInTable: detailType !== 'modal', render: (_, record) => { let str: string = '' if (record.choiceResponse && record?.choiceResponse.length > 0) { @@ -69,7 +87,7 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { let obj = { ...parentRow, ...extendObj, - placeName: parentRow.template.title, + placeName: parentRow.template?.title || '', submittedAt: moment(parentRow?.submittedAt).format('YYYY-MM-DD HH:mm:ss') } setFormRes(obj) @@ -104,13 +122,18 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { // 把需要打印的数组拿到一层中来 const handleGetTableRes = (list: any) => { + console.log('list', list); + let res: any = []; if (list && list.length > 0) { list.forEach((item: any) => { if (item.question && item.question.length > 0) { // 如果当前项有question字段且不为空,将其添加到结果数组 item.question.forEach((questionItem: any) => { - res.push(questionItem); + res.push({ + ...questionItem, + parentId: item.parentId ? item.parentId : "-" + }); }); } if (item.children && item.children.length > 0) { @@ -131,6 +154,7 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { // 深拷贝数据,避免修改原始数据 const processedData = JSON.parse(JSON.stringify(data)); + console.log('processedData', processedData); // 添加分类信息 processedData.forEach((item: any) => { @@ -138,9 +162,10 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { if (item.question && item.question.categoryId) { // 这里需要根据实际情况获取分类名称 // 可以从缓存或其他地方获取 - const categoryInfo = getCategoryInfo(item.question.categoryId); - item.categoryName = categoryInfo?.name || ''; - item.parentCategoryName = categoryInfo?.parentName || ''; + // const categoryInfo = getCategoryInfo(item.question.categoryId); + item.name = examineObj && item.parentId ? examineObj[item.parentId] : "" + item.categoryName = item?.question.title || ''; + item.parentCategoryName = item?.name || ''; } }); @@ -395,54 +420,59 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { readonly /> - - - - - - - - - - - ( -
-
{listDom}
-
{action}
-
- )} - > -
- { - formRes?.imgsList && formRes?.imgsList.length > 0 ? - formRes?.imgsList.map((item: string) => { - return - }) - : '' - } -
-
- + { + detailType === 'modal' ? '' : + <> + + + + + + + + + + + ( +
+
{listDom}
+
{action}
+
+ )} + > +
+ { + formRes?.imgsList && formRes?.imgsList.length > 0 ? + formRes?.imgsList.map((item: string) => { + return + }) + : '' + } +
+
+ + + } @@ -460,23 +490,28 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { ] }} + scroll={{ x: "100%", y: 'calc(100vh - 400px)' }} + pagination={false} options={false} request={async () => { - let res = parentRow?.questionResponses || [] + let res = detailType === 'modal' ? parentRow?.questionnaireTemplateQuestions + || [] : parentRow?.questionResponses || [] console.log('res', res); - + let obj: any = {} let typeData = await handleGetExamineTypeTreeList({}) console.log('typeData', typeData); if (typeData && typeData.length > 0) { typeData.forEach((item: any) => { + obj[item.id] = item.name if (item.children && item.children.length > 0) { item.children.forEach((subItem: any) => { - + obj[subItem.id] = subItem.name }) } }) } + setExamineObj(obj) let tableData = await handeGetTableData(typeData, res) console.log('tableData', tableData); @@ -487,6 +522,7 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => { // 处理表格数据,为合并单元格做准备 let processedData = processTableDataForMerge(tableRes); setTableData(processedData) + if (processedData && processedData.length > 0) { return { data: processedData, success: true } } diff --git a/src/pages/examine/record/index.tsx b/src/pages/examine/record/index.tsx index 4e4115a..88f0057 100644 --- a/src/pages/examine/record/index.tsx +++ b/src/pages/examine/record/index.tsx @@ -29,13 +29,13 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { title: "统计日期", dataIndex: "staticDate", hideInTable: true, - valueType: "date", - initialValue: [moment().format('YYYY-MM-DD')], + valueType: "dateRange", + initialValue: [moment().startOf('M'), moment()], search: { transform: (value: any) => { return { - startTime: value, - endTime: value + startTime: moment(value[0]).format('YYYY-MM-DD'), + endTime: moment(value[1]).format('YYYY-MM-DD') }; }, }, diff --git a/src/pages/examine/record/service.ts b/src/pages/examine/record/service.ts index 224a8e6..7e7cc8b 100644 --- a/src/pages/examine/record/service.ts +++ b/src/pages/examine/record/service.ts @@ -2,7 +2,7 @@ import request from "@/utils/request" // 拿到记录 export async function handleGetRecordList(params?: any) { - const data = await request.get('/questionnaire-responses', { params }) + const data = await request.post('/questionnaire-templates/search', params) if (data.code === 200) { return data.data } diff --git a/src/utils/request.ts b/src/utils/request.ts index 8447b35..e18de99 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -8,6 +8,9 @@ const { UMI_APP_BASEURL } = process.env; // const instance = axios.create({ baseURL: UMI_APP_BASEURL }); // const instance = axios.create({ baseURL: 'https://api.eshangtech.com/EShangApiMain' }); + + +// const instance = axios.create({ baseURL: 'http://home.robot-z.cn:7001/' }); // 修改baseURL为完整的API地址,确保在生产环境中正确访问 const instance = axios.create({ baseURL: 'https://es.robot-z.cn' });