💥 feat(模块): 添加了个很棒的功能

This commit is contained in:
cclu 2025-03-17 17:21:21 +08:00
parent 230cbb8434
commit 1d35b458fa
5 changed files with 125 additions and 65 deletions

View File

@ -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<boolean>(false)
// 显示详情
const [showDetail, handleShowDetail] = useState<boolean>(false)
// 当前点击选中的问题行
const [currentRow, setCurrentRow] = useState<any>()
// 服务区的枚举
@ -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 <Space>
<a onClick={() => {
@ -168,6 +171,10 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
setCurrentRow(record)
setShowPlaceModal(true)
}}></a>
<a onClick={() => {
setCurrentRow(record)
handleShowDetail(true)
}}></a>
<Popconfirm
title={"确认删除?"}
onConfirm={async () => {
@ -650,6 +657,20 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
/>
</Modal>
</div>
<Drawer
title={false}
closeIcon={false}
onClose={() => {
handleShowDetail(false)
}}
open={showDetail}
destroyOnClose
width={'60%'}
>
<RecordDetail parentRow={currentRow} show={showDetail} detailType={'modal'} />
</Drawer>
</div >
)
}

View File

@ -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<FormInstance>();
@ -31,11 +32,13 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => {
const [footerContent, setFooterContent] = useState<string>('')
const headerRef = useRef<TextAreaRef>(null)
const footerRef = useRef<TextAreaRef>(null)
// 考核分类的对象格式
const [examineObj, setExamineObj] = useState<any>()
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
/>
</Col>
<Col span={8}>
<ProFormText
label={"巡查内容"}
name={"uploadResult"}
readonly
/>
</Col>
<Col span={8}>
<ProFormText
label={"巡查人员"}
name={"userName"}
readonly
/>
</Col>
<Col span={8}>
<ProFormText
label={"巡查时间"}
name={"submittedAt"}
readonly
/>
</Col>
<Col span={16}>
<ProFormList
label={"附件列表"}
name={"imgsList"}
copyIconProps={false}
deleteIconProps={false}
readonly
style={{ width: '100%' }}
itemContainerStyle={{ width: '100%' }}
itemRender={({ listDom, action }, { record, index }) => (
<div style={{ width: '100%', display: 'flex', alignItems: 'flex-start', marginBottom: '10px' }}>
<div style={{ flex: 1, width: '100%' }}>{listDom}</div>
<div style={{ marginLeft: '8px', marginTop: '30px' }}>{action}</div>
</div>
)}
>
<div style={{ width: "300px", height: '170px', overflowX: "auto", display: 'flex', alignItems: 'center' }}>
{
formRes?.imgsList && formRes?.imgsList.length > 0 ?
formRes?.imgsList.map((item: string) => {
return <Image style={{ width: "150px", height: "150px", marginRight: "12px" }} src={item} />
})
: ''
}
</div>
</ProFormList>
</Col>
{
detailType === 'modal' ? '' :
<>
<Col span={8}>
<ProFormText
label={"巡查内容"}
name={"uploadResult"}
readonly
/>
</Col>
<Col span={8}>
<ProFormText
label={"巡查人员"}
name={"userName"}
readonly
/>
</Col>
<Col span={8}>
<ProFormText
label={"巡查时间"}
name={"submittedAt"}
readonly
/>
</Col>
<Col span={16}>
<ProFormList
label={"附件列表"}
name={"imgsList"}
copyIconProps={false}
deleteIconProps={false}
readonly
style={{ width: '100%' }}
itemContainerStyle={{ width: '100%' }}
itemRender={({ listDom, action }, { record, index }) => (
<div style={{ width: '100%', display: 'flex', alignItems: 'flex-start', marginBottom: '10px' }}>
<div style={{ flex: 1, width: '100%' }}>{listDom}</div>
<div style={{ marginLeft: '8px', marginTop: '30px' }}>{action}</div>
</div>
)}
>
<div style={{ width: "300px", height: '170px', overflowX: "auto", display: 'flex', alignItems: 'center' }}>
{
formRes?.imgsList && formRes?.imgsList.length > 0 ?
formRes?.imgsList.map((item: string) => {
return <Image style={{ width: "150px", height: "150px", marginRight: "12px" }} src={item} />
})
: ''
}
</div>
</ProFormList>
</Col>
</>
}
</Row>
</ProForm>
@ -460,23 +490,28 @@ const RecordDetail = ({ parentRow, show }: DetailProps) => {
</Button>
]
}}
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 }
}

View File

@ -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')
};
},
},

View File

@ -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
}

View File

@ -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' });