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

This commit is contained in:
ylj20011123 2025-04-24 21:27:20 +08:00
parent e94956b778
commit c3e2c371bb
11 changed files with 437 additions and 123 deletions

View File

@ -50,8 +50,8 @@ const LeftSelectTree = ({ setSelectedId, reload, actionRef, currentUser, width,
code: '510000' code: '510000'
} }
data = await handleGetAllServicePart(req) data = await handleGetAllServicePart(req)
data.data.list[0].key = data.data.list[0].id // data.data.list[0].key = data.data.list[0].id
data = data.data.list // data = data.data.list
} }
console.log('datatree', data); console.log('datatree', data);

View File

@ -60,13 +60,13 @@ export async function handleGetServerpartDDL(params: any) {
} }
import requestNew from "@/utils/request" import requestNew from "@/utils/requestJava"
// 新的拿到服务区的树的接口
// 新的拿到服务区的树的接口
export async function handleGetAllServicePart(params?: any) { export async function handleGetAllServicePart(params?: any) {
const data = await requestNew.get('/server-part/provinces', params) const data = await requestNew.get('/server-part/provinces', params)
if (data.code === 200) { if (data.Result_Code === 100) {
return data.data return data.Result_Data.List
} }
return [] return []
} }

View File

@ -1,5 +1,5 @@
import LeftSelectTree from "@/components/leftSelectTree/leftSelectTree"; import LeftSelectTree from "@/components/leftSelectTree/leftSelectTree";
import { handleGetServerpartDDL } from "@/components/leftSelectTree/service"; import { handleGetAllServicePart, handleGetServerpartDDL } from "@/components/leftSelectTree/service";
import { ActionType, FormInstance, ProCard, ProForm, ProFormDigit, ProFormList, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextArea, ProTable } from "@ant-design/pro-components"; import { ActionType, FormInstance, ProCard, ProForm, ProFormDigit, ProFormList, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextArea, ProTable } from "@ant-design/pro-components";
import { Button, Col, message, Modal, Popconfirm, Row, Space, Image, Drawer } from "antd"; import { Button, Col, message, Modal, Popconfirm, Row, Space, Image, Drawer } from "antd";
import moment from "moment"; import moment from "moment";
@ -52,6 +52,10 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
const [selectedQuestionDetail, setSelectedQuestionDetail] = useState<any>() const [selectedQuestionDetail, setSelectedQuestionDetail] = useState<any>()
// 选择的问题列表的id // 选择的问题列表的id
const [selectedQuestionId, setSelectedQuestionId] = useState<any>() const [selectedQuestionId, setSelectedQuestionId] = useState<any>()
// 选择克隆的服务区数据 key数组
const [selectCloneServiceList, setSelectCloneServiceList] = useState<any>()
// 选择批量克隆的服务区数据 详情数组
const [selectCloneServiceDetail, setSelectCloneServiceDetail] = useState<any>()
// 显示的附件数据 // 显示的附件数据
const [showImgList, setShowImgList] = useState<string[]>([]) const [showImgList, setShowImgList] = useState<string[]>([])
@ -81,6 +85,8 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
const [showBatchCloneModal, setshowBatchCloneModal] = useState<boolean>(false) const [showBatchCloneModal, setshowBatchCloneModal] = useState<boolean>(false)
// 批量克隆的loading效果 // 批量克隆的loading效果
const [batchLoading, setBatchLoading] = useState<boolean>(false) const [batchLoading, setBatchLoading] = useState<boolean>(false)
// 悬浮框的点击确定之后的加载效果
const [modalLoading, setModalLoading] = useState<boolean>(false)
const columns: any = [ const columns: any = [
// { // {
@ -352,7 +358,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
columns={columns} columns={columns}
bordered bordered
expandable={{ expandable={{
expandRowByClick: true // expandRowByClick: true
}} }}
rowKey={(record) => { rowKey={(record) => {
return `${record?.id}` return `${record?.id}`
@ -421,6 +427,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
title={`${currentRow?.id ? '编辑' : '创建'}点位`} title={`${currentRow?.id ? '编辑' : '创建'}点位`}
open={showPlaceModal} open={showPlaceModal}
destroyOnClose destroyOnClose
confirmLoading={modalLoading}
onOk={() => { onOk={() => {
modalRef.current?.validateFields().then(async (res) => { modalRef.current?.validateFields().then(async (res) => {
console.log('res', res); console.log('res', res);
@ -428,50 +435,60 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
console.log('selectedQuestionDetail', selectedQuestionDetail); console.log('selectedQuestionDetail', selectedQuestionDetail);
let req = {} let req = {}
let data = {} let data = {}
setModalLoading(true)
if (currentRow?.id) { if (currentRow?.id) {
let questions: any = [] let questions: any = []
if (selectedQuestionDetail && selectedQuestionDetail.length > 0) { if (res.questions && res.questions.length > 0) {
selectedQuestionDetail.forEach((item) => { res.questions.forEach((item: any) => {
questions.push({ questions.push({
questionId: item.id, questionId: item.questionId || item.id,
isRequired: item.required, isRequired: item.isRequired || item.required,
sortOrder: item.sortOrder sortOrder: item.sortOrder
}) })
}) })
} else { }
// 判断是否有改动 一样 说明没改动 那么把老的拿进去就行 // if (selectedQuestionDetail && selectedQuestionDetail.length > 0) {
// if (currentRow?.questionnaireTemplateQuestions.length === res.questions.length) { // selectedQuestionDetail.forEach((item) => {
// if (currentRow?.questionnaireTemplateQuestions && currentRow?.questionnaireTemplateQuestions.length > 0) {
// currentRow?.questionnaireTemplateQuestions.forEach((item) => {
// questions.push({
// questionId: item.question.id,
// isRequired: item.question.required,
// sortOrder: item.question.sortOrder
// })
// })
// }
// } else {
// // 不一样 说明有删除 不然走的是第一个
// if (res.questions && res.questions.length > 0) {
// res.questions.forEach((item) => {
// questions.push({ // questions.push({
// questionId: item.id, // questionId: item.id,
// isRequired: item.required, // isRequired: item.required,
// sortOrder: item.sortOrder // sortOrder: item.sortOrder
// }) // })
// }) // })
// } else {
// // 判断是否有改动 一样 说明没改动 那么把老的拿进去就行
// // if (currentRow?.questionnaireTemplateQuestions.length === res.questions.length) {
// // if (currentRow?.questionnaireTemplateQuestions && currentRow?.questionnaireTemplateQuestions.length > 0) {
// // currentRow?.questionnaireTemplateQuestions.forEach((item) => {
// // questions.push({
// // questionId: item.question.id,
// // isRequired: item.question.required,
// // sortOrder: item.question.sortOrder
// // })
// // })
// // }
// // } else {
// // // 不一样 说明有删除 不然走的是第一个
// // if (res.questions && res.questions.length > 0) {
// // res.questions.forEach((item) => {
// // questions.push({
// // questionId: item.id,
// // isRequired: item.required,
// // sortOrder: item.sortOrder
// // })
// // })
// // }
// // }
// if (res.questions && res.questions.length > 0) {
// res.questions.forEach((item: any) => {
// questions.push({
// questionId: item.questionId,
// isRequired: item.isRequired,
// sortOrder: item.sortOrder
// })
// })
// } // }
// } // }
if (res.questions && res.questions.length > 0) {
res.questions.forEach((item: any) => {
questions.push({
questionId: item.questionId,
isRequired: item.isRequired,
sortOrder: item.sortOrder
})
})
}
}
req = { req = {
...currentRow, ...currentRow,
@ -485,12 +502,12 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
status: res.status, status: res.status,
description: res.description description: res.description
} }
console.log('req', req); console.log('reqadd', req);
data = await handleUpdateTemplates(req) data = await handleUpdateTemplates(req)
} else { } else {
let questions: any = [] let questions: any = []
if (selectedQuestionDetail && selectedQuestionDetail.length > 0) { if (res.questions && res.questions.length > 0) {
selectedQuestionDetail.forEach((item: any, index: number) => { res.questions.forEach((item: any, index: number) => {
questions.push({ questions.push({
questionId: item.id, questionId: item.id,
isRequired: item.required, isRequired: item.required,
@ -498,6 +515,15 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
}) })
}) })
} }
// if (selectedQuestionDetail && selectedQuestionDetail.length > 0) {
// selectedQuestionDetail.forEach((item: any, index: number) => {
// questions.push({
// questionId: item.id,
// isRequired: item.required,
// sortOrder: index + 1
// })
// })
// }
req = { req = {
title: res.title, title: res.title,
@ -515,32 +541,37 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
} }
console.log('reqreqreqreqreq', req); console.log('reqreqreqreqreq', req);
data = await handleAddTemplates(req) data = await handleAddTemplates(req)
console.log('datadsadsa1', data); // console.log('datadsadsa1', data);
const myQRCodeDataUrl = await QRCode.toDataURL(`pages/walkAroundManager/index?id=${data.Result_Data.id}`); // const myQRCodeDataUrl = await QRCode.toDataURL(`pages/walkAroundManager/index?id=${data.Result_Data.id}`);
const file = base64ToFile(myQRCodeDataUrl, `wenjuan${data.Result_Data.id}.png`); // const file = base64ToFile(myQRCodeDataUrl, `wenjuan${data.Result_Data.id}.png`);
console.log('file', file); // console.log('file', file);
const formData = new FormData(); // const formData = new FormData();
formData.append("file", file, `wenjuan${data.Result_Data.id}.png`); // 确保文件名也传递 // formData.append("file", file, `wenjuan${data.Result_Data.id}.png`); // 确保文件名也传递
const fileData = await handleUploadFile(formData) // const fileData = await handleUploadFile(formData)
console.log('fileData', fileData); // console.log('fileData', fileData);
let imgUrl: string = `https://es.eshangtech.com/${fileData.data.path}` // let imgUrl: string = `https://es.eshangtech.com/${fileData.data.path}`
await handleUpdateTemplates({ // await handleUpdateTemplates({
...data.Result_Data, // ...data.Result_Data,
qrUrl: imgUrl // qrUrl: imgUrl
}) // })
setQrCodeUrl(imgUrl)
setQrCodeUrl(data.Result_Data.qrUrl || '')
// setQrCodeUrl(myQRCodeDataUrl) // setQrCodeUrl(myQRCodeDataUrl)
} }
console.log('datadsadsa', data); console.log('datadsadsa', data);
setModalLoading(true)
if (data.Result_Code === 100) { if (data.Result_Code === 100) {
modalRef.current?.resetFields() modalRef.current?.resetFields()
message.success('新增成功!') message.success('新增成功!')
setShowPlaceModal(false) setShowPlaceModal(false)
actionRef.current?.reload() actionRef.current?.reload()
setCurrentRow(undefined) setCurrentRow(undefined)
setSelectedQuestionDetail(undefined)
setSelectedQuestionId(undefined)
setModalLoading(false)
} else { } else {
message.error(data.Result_Desc) message.error(data.Result_Desc)
} }
@ -552,6 +583,9 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
setShowPlaceModal(false) setShowPlaceModal(false)
setCurrentRow(undefined) setCurrentRow(undefined)
setQrCodeUrl(undefined) setQrCodeUrl(undefined)
setModalLoading(false)
setSelectedQuestionDetail(undefined)
setSelectedQuestionId(undefined)
}} }}
> >
<ProForm formRef={modalRef} submitter={false} request={async () => { <ProForm formRef={modalRef} submitter={false} request={async () => {
@ -574,7 +608,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
// obj.text = obj.title // obj.text = obj.title
// obj.mark = JSON.stringify(obj.options) // obj.mark = JSON.stringify(obj.options)
// obj.showText = str // obj.showText = str
keyList.push(obj.id) keyList.push(obj.id.toString())
// questionsList.push(obj) // questionsList.push(obj)
@ -606,6 +640,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
setSelectedQuestionId(keyList) setSelectedQuestionId(keyList)
console.log('questionsList', questionsList); console.log('questionsList', questionsList);
console.log('keyList', keyList);
return { return {
...currentRow, ...currentRow,
serverPartId: currentRow.serverPartId.toString(), serverPartId: currentRow.serverPartId.toString(),
@ -674,6 +709,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
{ label: "每日任务", value: 1 }, { label: "每日任务", value: 1 },
{ label: "每月任务", value: 2 } { label: "每月任务", value: 2 }
]} ]}
initialValue={1}
/> />
</Col> </Col>
<Col span={8}> <Col span={8}>
@ -709,7 +745,6 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
alignItems: 'flex-start', alignItems: 'flex-start',
marginBottom: '10px', marginBottom: '10px',
padding: '12px', padding: '12px',
backgroundColor: '#fafafa',
borderRadius: '4px' borderRadius: '4px'
}}> }}>
<div style={{ flex: 1, width: '100%' }}>{listDom}</div> <div style={{ flex: 1, width: '100%' }}>{listDom}</div>
@ -786,12 +821,14 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
fieldProps={{ fieldProps={{
style: { width: '100%' } style: { width: '100%' }
}} }}
readonly
/> />
</Col> </Col>
<Col span={16}> <Col span={16}>
<ProFormTextArea <ProFormTextArea
name="showText" name="showText"
label="考核标准" label="考核标准"
readonly
/> />
</Col> </Col>
</Row> </Row>
@ -845,7 +882,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
str += `${index > 0 ? '' : ''}选项${index + 1}${item.text}` str += `${index > 0 ? '' : ''}选项${index + 1}${item.text}`
}) })
} }
showQuestion.push({ text: item.title, showText: str, mark: item.options ? JSON.stringify(item.options) : "" }) showQuestion.push({ text: item.title, showText: str, mark: item.options ? JSON.stringify(item.options) : "", id: item.id, required: item.required })
}) })
} }
console.log('showQuestion', showQuestion); console.log('showQuestion', showQuestion);
@ -868,11 +905,11 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
}} }}
scroll={{ y: 'calc(100vh - 500px)' }} scroll={{ y: 'calc(100vh - 500px)' }}
request={async (params) => { request={async (params) => {
console.log('查询参数:', params);
const req: any = { const req: any = {
categoryId: params.id categoryId: params.id
} }
const data = await handleGetQuestionList(req) const data = await handleGetQuestionList(req)
console.log('问题列表:', data);
if (data && data.length > 0) { if (data && data.length > 0) {
return { data, success: true } return { data, success: true }
} }
@ -922,7 +959,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
if (list && list.length > 0) { if (list && list.length > 0) {
list.forEach((item: any) => { list.forEach((item: any) => {
detailList.push(item) detailList.push(item)
idList.push(item.question.id.toString()) idList.push(item.questionId.toString())
if (item.question) { if (item.question) {
let obj = JSON.parse(JSON.stringify(item.question)) let obj = JSON.parse(JSON.stringify(item.question))
@ -943,6 +980,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
setSelectedQuestionDetail(detailList) setSelectedQuestionDetail(detailList)
console.log('idList', idList); console.log('idList', idList);
console.log('res', res);
setSelectedQuestionId(idList) setSelectedQuestionId(idList)
@ -1085,28 +1123,27 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
{/* 批量克隆点位 */} {/* 批量克隆点位 */}
<Modal <Modal
width={400} width={500}
title={"批量克隆"} title={"批量克隆"}
open={showBatchCloneModal} open={showBatchCloneModal}
confirmLoading={batchLoading} confirmLoading={batchLoading}
onOk={() => { onOk={async () => {
batchCloneForm.current?.validateFields().then(async (res: any) => {
console.log('res', res);
console.log('currentRow', currentRow);
console.log('currentUser', currentUser);
console.log('serviceObj', serviceObj);
console.log('selectCloneServiceList', selectCloneServiceList);
console.log('selectCloneServiceDetail', selectCloneServiceDetail);
let list: any = res.serviceList // 判断有没有选择了服务区
if (selectCloneServiceDetail && selectCloneServiceDetail.length > 0) {
setBatchLoading(true)
let serverParts: any = [] let serverParts: any = []
if (list && list.length > 0) {
list.forEach((item: any) => { selectCloneServiceDetail.forEach((item: any) => {
serverParts.push({ serverParts.push({
serverPartName: serviceObj[item], serverPartName: item.name,
serverPartId: item serverPartId: item.id
}) })
}) })
}
let question: any = [] let question: any = []
if (currentRow?.questionnaireTemplateQuestions && currentRow?.questionnaireTemplateQuestions.length > 0) { if (currentRow?.questionnaireTemplateQuestions && currentRow?.questionnaireTemplateQuestions.length > 0) {
currentRow.questionnaireTemplateQuestions.forEach((item: any) => { currentRow.questionnaireTemplateQuestions.forEach((item: any) => {
@ -1130,6 +1167,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
} }
console.log('req', req); console.log('req', req);
const data = await handleBatchService(req) const data = await handleBatchService(req)
setBatchLoading(false)
console.log('datadatadatadata', data); console.log('datadatadatadata', data);
if (data.Result_Code === 100) { if (data.Result_Code === 100) {
message.success('批量克隆成功!') message.success('批量克隆成功!')
@ -1140,7 +1178,57 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
} else { } else {
message.error(data.Result_Desc) message.error(data.Result_Desc)
} }
}) } else {
message.error('请选择要克隆到的服务区')
}
// batchCloneForm.current?.validateFields().then(async (res: any) => {
// let list: any = res.serviceList
// let serverParts: any = []
// // if (list && list.length > 0) {
// // list.forEach((item: any) => {
// // serverParts.push({
// // serverPartName: serviceObj[item],
// // serverPartId: item
// // })
// // })
// // }
// let question: any = []
// if (currentRow?.questionnaireTemplateQuestions && currentRow?.questionnaireTemplateQuestions.length > 0) {
// currentRow.questionnaireTemplateQuestions.forEach((item: any) => {
// question.push({
// questionId: item.questionId,
// isRequired: item.isRequired,
// sortOrder: item.sortOrder
// })
// })
// }
// let req: any = {
// title: currentRow?.title,
// placeName: currentRow?.placeName,
// placeId: currentRow?.placeId,
// serverParts: serverParts,
// questions: question,
// operator: currentUser?.operator,
// status: currentRow?.status,
// description: currentRow?.description
// }
// console.log('req', req);
// const data = await handleBatchService(req)
// console.log('datadatadatadata', data);
// if (data.Result_Code === 100) {
// message.success('批量克隆成功!')
// actionRef.current?.reload()
// batchCloneForm.current?.resetFields()
// setshowBatchCloneModal(false)
// setCurrentRow(undefined)
// } else {
// message.error(data.Result_Desc)
// }
// })
// setshowBatchCloneModal(false) // setshowBatchCloneModal(false)
}} }}
onCancel={() => { onCancel={() => {
@ -1148,7 +1236,53 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
batchCloneForm.current?.resetFields() batchCloneForm.current?.resetFields()
}} }}
> >
<ProForm
<ProTable
search={false}
options={false}
pagination={false}
scroll={{ x: '100%', y: '500px' }}
rowKey={(record) => {
return `${record?.id}-${record?.type}`
}}
request={async (params) => {
let req: any = {
page: 1,
limit: 999,
sortBy: 'sort',
sortOrder: 'ASC',
code: '510000'
}
const data = await handleGetAllServicePart(req)
let list: any = data[0].children
if (list && list.length > 0) {
return { data: list, success: true }
}
return { data: [], success: true }
}}
columns={[
{
title: "片区/服务区名称",
dataIndex: "name"
}
]}
rowSelection={{
type: "radio",
defaultSelectedRowKeys: selectCloneServiceList,
getCheckboxProps: (record) => ({
disabled: record.type === "district",
// || record.type === "servicePart"
}),
onChange: (selectedRowKeys, selectedRows) => {
setSelectCloneServiceDetail(selectedRows)
setSelectCloneServiceList(selectedRowKeys)
}
}}
>
</ProTable>
{/* <ProForm
formRef={batchCloneForm} formRef={batchCloneForm}
submitter={false} submitter={false}
> >
@ -1190,7 +1324,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
/> />
</Col> </Col>
</Row> </Row>
</ProForm> </ProForm> */}
</Modal> </Modal>
</div > </div >
) )

View File

@ -39,8 +39,24 @@ const addQuestion = ({ parentRow, onRef, currentUser, showQuestionModal, setShow
destroyOnClose destroyOnClose
onOk={() => { onOk={() => {
modalRef.current?.validateFields().then(async (res) => { modalRef.current?.validateFields().then(async (res) => {
console.log('res', res);
// 先判断一下 问题列表是否都完善了
let allAnwersOk: boolean = true
if (res.options && res.options.length > 0) {
res.options.forEach((item: any) => {
if (!item.text) {
allAnwersOk = false
}
})
}
if (!allAnwersOk) {
message.error('请先完善选项列表!')
return
}
let req = {} let req = {}
let data = {} let data = {}
if (parentRow?.id) { if (parentRow?.id) {
req = { req = {
...parentRow, ...parentRow,

View File

@ -3,7 +3,7 @@ import request from "@/utils/requestJava"
// 拿到问题列表接口 // 拿到问题列表接口
export async function handleGetQuestionList(params?: any) { export async function handleGetQuestionList(params?: any) {
const data = await request.post('/questions/search/many', params) const data = await request.get('/questions/getList', params)
if (data.Result_Code === 100) { if (data.Result_Code === 100) {
return data.Result_Data.List return data.Result_Data.List
} }

View File

@ -102,6 +102,7 @@ const RecordDetail = ({ parentRow, show, detailType, currentUser, onRef, showErr
...parentRow, ...parentRow,
...extendObj, ...extendObj,
placeName: parentRow.template?.title || '', placeName: parentRow.template?.title || '',
serverPartName: parentRow.template?.serverPartName,
submittedAt: moment(parentRow?.submittedAt).format('YYYY-MM-DD HH:mm:ss') submittedAt: moment(parentRow?.submittedAt).format('YYYY-MM-DD HH:mm:ss')
} }
console.log('formRes', obj); console.log('formRes', obj);

View File

@ -118,8 +118,8 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
align: 'center', align: 'center',
ellipsis: true, ellipsis: true,
render: (_, record) => { render: (_, record) => {
let res: any = record.extend ? JSON.parse(record.extend) : "-" // let res: any = record.extend ? JSON.parse(record.extend) : "-"
return <span style={{ color: res.situation === 1 ? "red" : "" }}>{res.situation === 1 ? '异常' : res.situation === 0 ? '正常' : ''}</span> return <span style={{ color: record.situation === 1 ? "red" : "" }}>{record.situation === 1 ? '异常' : record.situation === 0 ? '正常' : ''}</span>
} }
}, },
{ {
@ -129,8 +129,8 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
width: 200, width: 200,
ellipsis: true, ellipsis: true,
render: (_, record) => { render: (_, record) => {
let extendObj = record?.extend ? JSON.parse(record?.extend) : "" // let extendObj = record?.extend ? JSON.parse(record?.extend) : ""
return extendObj?.uploadResult ? extendObj?.uploadResult : "-" return record?.uploadResult ? record?.uploadResult : "-"
} }
}, },
{ {
@ -190,13 +190,13 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
ellipsis: true, ellipsis: true,
align: 'center', align: 'center',
render: (_, record) => { render: (_, record) => {
let res: any = record.extend ? JSON.parse(record.extend) : "-" // let res: any = record.extend ? JSON.parse(record.extend) : "-"
return <span style={{ color: res.errorStatus === 0 ? "red" : res.errorStatus === 1 ? "#1677ff" : "" }}>{ return <span style={{ color: record.errorStatus === 0 ? "red" : record.errorStatus === 1 ? "#1677ff" : "" }}>{
res.errorStatus === 0 record.errorStatus === 0
? "待处理" ? "待处理"
: res.errorStatus === 1 : record.errorStatus === 1
? "处理中" ? "处理中"
: res.errorStatus === 2 : record.errorStatus === 2
? "已处理" ? "已处理"
: "-" : "-"
}</span> }</span>
@ -210,8 +210,8 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
ellipsis: true, ellipsis: true,
align: 'center', align: 'center',
render: (_, record) => { render: (_, record) => {
let extendObj = record?.extend ? JSON.parse(record?.extend) : "" // let extendObj = record?.extend ? JSON.parse(record?.extend) : ""
let imgList = extendObj.imgsList let imgList = record.imgsList
return imgList && imgList.length > 0 ? return imgList && imgList.length > 0 ?
<Button type="primary" onClick={() => { <Button type="primary" onClick={() => {
setShowImgList(imgList) setShowImgList(imgList)
@ -227,31 +227,29 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
hideInSearch: true, hideInSearch: true,
width: 150, width: 150,
render: (_: any, record: any) => { render: (_: any, record: any) => {
let res: any = record.extend ? JSON.parse(record.extend) : "-" // let res: any = record.extend ? JSON.parse(record.extend) : "-"
return record?.type === 'district' || record?.type === 'servicePart' ? '' : <Space> return record?.type === 'district' || record?.type === 'servicePart' ? '' : <Space>
{ {
res.situation === 1 ? record.situation === 1 ?
<a onClick={ <a onClick={
() => { () => {
setCurrentRow({ setCurrentRow({
...record, ...record,
...res
}) })
setShowAbnormal(true) setShowAbnormal(true)
setShowDetail(true) setShowDetail(true)
} }
}></a> : "" }></a> : < a onClick={() => {
}
< a onClick={() => {
setCurrentRow({ setCurrentRow({
...record, ...record,
...res
}) })
setShowDetail(true) setShowDetail(true)
}}> }}>
</a > </a >
}
<Popconfirm <Popconfirm
title={"确认删除?"} title={"确认删除?"}
onConfirm={async () => { onConfirm={async () => {
@ -296,7 +294,7 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
expandRowByClick: true expandRowByClick: true
}} }}
rowKey={(record) => { rowKey={(record) => {
return `${record?.id}-${record?.code}` return `${record?.id}-${record?.code}-${record?.templateId}`
}} }}
scroll={{ x: "100%", y: 'calc(100vh - 400px)' }} scroll={{ x: "100%", y: 'calc(100vh - 400px)' }}
headerTitle={<span style={{ color: "#1890ff", fontSize: 14, fontWeight: 600 }}></span>} headerTitle={<span style={{ color: "#1890ff", fontSize: 14, fontWeight: 600 }}></span>}

View File

@ -361,7 +361,7 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
defaultExpandAllRows: true defaultExpandAllRows: true
}} }}
rowKey={(record) => { rowKey={(record) => {
return `${record?.id}-${record?.code}` return `${record?.id}-${record?.code}-${record?.template.id}`
}} }}
scroll={{ x: "100%", y: 'calc(100vh - 400px)' }} scroll={{ x: "100%", y: 'calc(100vh - 400px)' }}
headerTitle={<span style={{ color: "#1890ff", fontSize: 14, fontWeight: 600 }}></span>} headerTitle={<span style={{ color: "#1890ff", fontSize: 14, fontWeight: 600 }}></span>}
@ -486,9 +486,15 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
let allSubItemDaySum: number = 0 let allSubItemDaySum: number = 0
if (subItem.children && subItem.children.length > 0) { if (subItem.children && subItem.children.length > 0) {
subItem.children.forEach((thirdItem: any) => { subItem.children.forEach((thirdItem: any) => {
thirdItem.allDay = allDay // thirdItem.allDay = allDay
allSubItemDaySum += thirdItem.allDay // allSubItemDaySum += thirdItem.allDay
inspectionNumberSum += thirdItem.inspectionNumber thirdItem.allDay = thirdItem.template.patrolTotal
allSubItemDaySum += thirdItem.template.patrolTotal
// inspectionNumberSum += thirdItem.inspectionNumber
inspectionNumberSum += thirdItem.template.patrolNumber
thirdItem.inspectionNumber = thirdItem.template.patrolNumber
normalNumberSum += thirdItem.normalNumber normalNumberSum += thirdItem.normalNumber
errorNumberSum += thirdItem.errorNumber errorNumberSum += thirdItem.errorNumber
pendingProcessNumberSum += thirdItem.pendingProcessNumber pendingProcessNumberSum += thirdItem.pendingProcessNumber

View File

@ -44,10 +44,10 @@ instance.interceptors.response.use(
(response) => { (response) => {
const { data } = response; const { data } = response;
if (data.code !== 200) { if (data.Result_Code !== 200) {
notification.error({ // notification.error({
message: data.message, // message: data.message,
}); // });
} }
const timestamp = getFormattedDate() const timestamp = getFormattedDate()

View File

@ -14,7 +14,10 @@ const { UMI_APP_BASEURL } = process.env;
// 修改baseURL为完整的API地址确保在生产环境中正确访问 // 修改baseURL为完整的API地址确保在生产环境中正确访问
// const instance = axios.create({ baseURL: 'https://es.robot-z.cn' }); // const instance = axios.create({ baseURL: 'https://es.robot-z.cn' });
const instance = axios.create({ baseURL: 'http://10.104.1.161:8070/platform' }); // const instance = axios.create({ baseURL: 'http://10.104.1.161:8070/platform' });
const instance = axios.create({ baseURL: 'http://10.104.1.175:8070/platform' });
instance.interceptors.request.use( instance.interceptors.request.use(
(config) => { (config) => {
@ -44,9 +47,9 @@ instance.interceptors.response.use(
const { data } = response; const { data } = response;
if (data.Result_Code !== 100) { if (data.Result_Code !== 100) {
notification.error({ // notification.error({
message: data.message, // message: data.message,
}); // });
} }
const timestamp = getFormattedDate() const timestamp = getFormattedDate()

156
src/utils/requestTest.ts Normal file
View File

@ -0,0 +1,156 @@
import axios from 'axios';
import { getDvaApp } from 'umi';
import { notification } from 'antd';
import type { AxiosRequestHeaders } from 'axios/index';
import CryptoJS from "crypto-js";
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' });
const instance = axios.create({ baseURL: 'http://10.104.1.175:8070/platform' });
instance.interceptors.request.use(
(config) => {
// 对data数据进行加密
// if (config.data) {
// config.data = preprocessData(JSON.stringify(config.data)); // 调用预处理函数
// }
const isUpload = config.url?.includes("/oss/upload");
config.headers = {
...config.headers,
Authorization: `Bearer ${localStorage.getItem('Authorization') || ''}`,
"Content-Type": isUpload ? "multipart/form-data" : "application/json;charset=utf-8",
} as AxiosRequestHeaders;
return config;
},
(error) => Promise.reject(error),
);
instance.interceptors.response.use(
//状态码为2xx的时候执行
(response) => {
const { data } = response;
if (data.Result_Code !== 100) {
notification.error({
message: data.message,
});
}
const timestamp = getFormattedDate()
return data
},
//状态码不是2xx的时候执行
(error) => {
const { response } = error;
if (response && response.status === 401) {
// // 清除本地存储的token
// localStorage.removeItem('Authorization');
// // 重定向到登录页
// window.location.href = '/user/login';
// notification.error({
// message: response?.data?.message || '请求失败',
// description: error.message
// });
} else {
notification.error({
message: response?.data?.message || '请求失败',
description: error.message
});
}
return Promise.reject({
Result_Code: response?.status || 500,
message: response?.data?.message || '请求失败'
});
},
);
// 加密
const encryptAESECB = (data: string, key: string) => {
// const cipher = CryptoJS.createCipheriv('aes-128-ecb', key, null); // ECB 模式不需要 IV
const newKey = CryptoJS.enc.Utf8.parse(key); // 密钥必须是 16 字节
const cipher = CryptoJS.AES.encrypt(data, newKey, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
let encrypted = cipher.ciphertext.toString(CryptoJS.enc.Hex);
// let encrypted = cipher.update(data, 'utf8', 'hex');
// encrypted += cipher.final('hex');
return encrypted;
}
// 解密
const decryptAESECB = (data: string, key: string) => {
// const decipher = CryptoJS.createDecipheriv('aes-128-ecb', key, null);
// let decrypted = decipher.update(data, 'hex', 'utf8');
// decrypted += decipher.final('utf8');
const newKey = CryptoJS.enc.Utf8.parse(key);
const encryptedData = CryptoJS.enc.Hex.parse(data);
// 解密操作
const decrypted = CryptoJS.AES.decrypt({ ciphertext: encryptedData }, newKey, {
mode: CryptoJS.mode.ECB, // ECB 模式
padding: CryptoJS.pad.Pkcs7 // PKCS7 填充方式
});
// 将解密后的结果转为 UTF-8 字符串
const decryptedText = decrypted.toString(CryptoJS.enc.Utf8);
return decryptedText;
}
// md5 签名
const md5 = (key: string, data: string, timestamp: string) => {
const text = "s" + key + data + timestamp;
return CryptoJS.MD5(text).toString(CryptoJS.enc.Hex);
}
// 生成签名戳
const getFormattedDate = () => {
const date = new Date();
const year = date.getFullYear(); // 获取年份 (yyyy)
const month = String(date.getMonth() + 1).padStart(2, '0'); // 获取月份 (MM)
const day = String(date.getDate()).padStart(2, '0'); // 获取日期 (dd)
const hours = String(date.getHours()).padStart(2, '0'); // 获取小时 (HH)
return `es0${year}${month}${day}${hours}0es`; // 拼接成 yyyyMMddHH 格式
}
// 加密方法
const preprocessData = (data: string) => {
console.log('data', data);
// YYYYMMDD
let timestamp = getFormattedDate()
console.log('timestamp', timestamp);
// 秒为单位的时间戳
let timeSecond = parseInt((new Date().getTime() / 1000).toString())
console.log('timeSecond', timeSecond);
// 数据的加密
let encryptionData = encryptAESECB(data, timestamp)
console.log('encryptionData', encryptionData);
// md5签名方法
let md5Data = md5(timestamp, encryptionData, timestamp)
console.log('md5Data', md5Data);
let res = {
data: encryptionData,
timestamp: timeSecond,
sign: md5Data
}
console.log('res', res);
return res
}
export default instance;