💥 feat(模块): 添加了个很棒的功能
This commit is contained in:
parent
e94956b778
commit
c3e2c371bb
@ -50,8 +50,8 @@ const LeftSelectTree = ({ setSelectedId, reload, actionRef, currentUser, width,
|
||||
code: '510000'
|
||||
}
|
||||
data = await handleGetAllServicePart(req)
|
||||
data.data.list[0].key = data.data.list[0].id
|
||||
data = data.data.list
|
||||
// data.data.list[0].key = data.data.list[0].id
|
||||
// data = data.data.list
|
||||
}
|
||||
console.log('datatree', data);
|
||||
|
||||
|
||||
@ -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) {
|
||||
const data = await requestNew.get('/server-part/provinces', params)
|
||||
if (data.code === 200) {
|
||||
return data.data
|
||||
if (data.Result_Code === 100) {
|
||||
return data.Result_Data.List
|
||||
}
|
||||
return []
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
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 { Button, Col, message, Modal, Popconfirm, Row, Space, Image, Drawer } from "antd";
|
||||
import moment from "moment";
|
||||
@ -52,6 +52,10 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
const [selectedQuestionDetail, setSelectedQuestionDetail] = useState<any>()
|
||||
// 选择的问题列表的id
|
||||
const [selectedQuestionId, setSelectedQuestionId] = useState<any>()
|
||||
// 选择克隆的服务区数据 key数组
|
||||
const [selectCloneServiceList, setSelectCloneServiceList] = useState<any>()
|
||||
// 选择批量克隆的服务区数据 详情数组
|
||||
const [selectCloneServiceDetail, setSelectCloneServiceDetail] = useState<any>()
|
||||
|
||||
// 显示的附件数据
|
||||
const [showImgList, setShowImgList] = useState<string[]>([])
|
||||
@ -81,6 +85,8 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
const [showBatchCloneModal, setshowBatchCloneModal] = useState<boolean>(false)
|
||||
// 批量克隆的loading效果
|
||||
const [batchLoading, setBatchLoading] = useState<boolean>(false)
|
||||
// 悬浮框的点击确定之后的加载效果
|
||||
const [modalLoading, setModalLoading] = useState<boolean>(false)
|
||||
|
||||
const columns: any = [
|
||||
// {
|
||||
@ -352,7 +358,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
columns={columns}
|
||||
bordered
|
||||
expandable={{
|
||||
expandRowByClick: true
|
||||
// expandRowByClick: true
|
||||
}}
|
||||
rowKey={(record) => {
|
||||
return `${record?.id}`
|
||||
@ -421,6 +427,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
title={`${currentRow?.id ? '编辑' : '创建'}点位`}
|
||||
open={showPlaceModal}
|
||||
destroyOnClose
|
||||
confirmLoading={modalLoading}
|
||||
onOk={() => {
|
||||
modalRef.current?.validateFields().then(async (res) => {
|
||||
console.log('res', res);
|
||||
@ -428,50 +435,60 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
console.log('selectedQuestionDetail', selectedQuestionDetail);
|
||||
let req = {}
|
||||
let data = {}
|
||||
setModalLoading(true)
|
||||
if (currentRow?.id) {
|
||||
let questions: any = []
|
||||
if (selectedQuestionDetail && selectedQuestionDetail.length > 0) {
|
||||
selectedQuestionDetail.forEach((item) => {
|
||||
if (res.questions && res.questions.length > 0) {
|
||||
res.questions.forEach((item: any) => {
|
||||
questions.push({
|
||||
questionId: item.id,
|
||||
isRequired: item.required,
|
||||
questionId: item.questionId || item.id,
|
||||
isRequired: item.isRequired || item.required,
|
||||
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) => {
|
||||
}
|
||||
// if (selectedQuestionDetail && selectedQuestionDetail.length > 0) {
|
||||
// selectedQuestionDetail.forEach((item) => {
|
||||
// questions.push({
|
||||
// questionId: item.id,
|
||||
// isRequired: item.required,
|
||||
// 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 = {
|
||||
...currentRow,
|
||||
@ -485,12 +502,12 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
status: res.status,
|
||||
description: res.description
|
||||
}
|
||||
console.log('req', req);
|
||||
console.log('reqadd', req);
|
||||
data = await handleUpdateTemplates(req)
|
||||
} else {
|
||||
let questions: any = []
|
||||
if (selectedQuestionDetail && selectedQuestionDetail.length > 0) {
|
||||
selectedQuestionDetail.forEach((item: any, index: number) => {
|
||||
if (res.questions && res.questions.length > 0) {
|
||||
res.questions.forEach((item: any, index: number) => {
|
||||
questions.push({
|
||||
questionId: item.id,
|
||||
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 = {
|
||||
title: res.title,
|
||||
@ -515,32 +541,37 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
}
|
||||
console.log('reqreqreqreqreq', 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 file = base64ToFile(myQRCodeDataUrl, `wenjuan${data.Result_Data.id}.png`);
|
||||
console.log('file', file);
|
||||
const formData = new FormData();
|
||||
formData.append("file", file, `wenjuan${data.Result_Data.id}.png`); // 确保文件名也传递
|
||||
// const myQRCodeDataUrl = await QRCode.toDataURL(`pages/walkAroundManager/index?id=${data.Result_Data.id}`);
|
||||
// const file = base64ToFile(myQRCodeDataUrl, `wenjuan${data.Result_Data.id}.png`);
|
||||
// console.log('file', file);
|
||||
// const formData = new FormData();
|
||||
// formData.append("file", file, `wenjuan${data.Result_Data.id}.png`); // 确保文件名也传递
|
||||
|
||||
const fileData = await handleUploadFile(formData)
|
||||
console.log('fileData', fileData);
|
||||
let imgUrl: string = `https://es.eshangtech.com/${fileData.data.path}`
|
||||
await handleUpdateTemplates({
|
||||
...data.Result_Data,
|
||||
qrUrl: imgUrl
|
||||
})
|
||||
setQrCodeUrl(imgUrl)
|
||||
// const fileData = await handleUploadFile(formData)
|
||||
// console.log('fileData', fileData);
|
||||
// let imgUrl: string = `https://es.eshangtech.com/${fileData.data.path}`
|
||||
// await handleUpdateTemplates({
|
||||
// ...data.Result_Data,
|
||||
// qrUrl: imgUrl
|
||||
// })
|
||||
|
||||
setQrCodeUrl(data.Result_Data.qrUrl || '')
|
||||
|
||||
// setQrCodeUrl(myQRCodeDataUrl)
|
||||
}
|
||||
console.log('datadsadsa', data);
|
||||
setModalLoading(true)
|
||||
if (data.Result_Code === 100) {
|
||||
modalRef.current?.resetFields()
|
||||
message.success('新增成功!')
|
||||
setShowPlaceModal(false)
|
||||
actionRef.current?.reload()
|
||||
setCurrentRow(undefined)
|
||||
setSelectedQuestionDetail(undefined)
|
||||
setSelectedQuestionId(undefined)
|
||||
setModalLoading(false)
|
||||
} else {
|
||||
message.error(data.Result_Desc)
|
||||
}
|
||||
@ -552,6 +583,9 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
setShowPlaceModal(false)
|
||||
setCurrentRow(undefined)
|
||||
setQrCodeUrl(undefined)
|
||||
setModalLoading(false)
|
||||
setSelectedQuestionDetail(undefined)
|
||||
setSelectedQuestionId(undefined)
|
||||
}}
|
||||
>
|
||||
<ProForm formRef={modalRef} submitter={false} request={async () => {
|
||||
@ -574,7 +608,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
// obj.text = obj.title
|
||||
// obj.mark = JSON.stringify(obj.options)
|
||||
// obj.showText = str
|
||||
keyList.push(obj.id)
|
||||
keyList.push(obj.id.toString())
|
||||
// questionsList.push(obj)
|
||||
|
||||
|
||||
@ -606,6 +640,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
|
||||
setSelectedQuestionId(keyList)
|
||||
console.log('questionsList', questionsList);
|
||||
console.log('keyList', keyList);
|
||||
return {
|
||||
...currentRow,
|
||||
serverPartId: currentRow.serverPartId.toString(),
|
||||
@ -674,6 +709,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
{ label: "每日任务", value: 1 },
|
||||
{ label: "每月任务", value: 2 }
|
||||
]}
|
||||
initialValue={1}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
@ -709,7 +745,6 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
alignItems: 'flex-start',
|
||||
marginBottom: '10px',
|
||||
padding: '12px',
|
||||
backgroundColor: '#fafafa',
|
||||
borderRadius: '4px'
|
||||
}}>
|
||||
<div style={{ flex: 1, width: '100%' }}>{listDom}</div>
|
||||
@ -786,12 +821,14 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
fieldProps={{
|
||||
style: { width: '100%' }
|
||||
}}
|
||||
readonly
|
||||
/>
|
||||
</Col>
|
||||
<Col span={16}>
|
||||
<ProFormTextArea
|
||||
name="showText"
|
||||
label="考核标准"
|
||||
readonly
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
@ -845,7 +882,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
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);
|
||||
@ -868,11 +905,11 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
}}
|
||||
scroll={{ y: 'calc(100vh - 500px)' }}
|
||||
request={async (params) => {
|
||||
console.log('查询参数:', params);
|
||||
const req: any = {
|
||||
categoryId: params.id
|
||||
}
|
||||
const data = await handleGetQuestionList(req)
|
||||
console.log('问题列表:', data);
|
||||
if (data && data.length > 0) {
|
||||
return { data, success: true }
|
||||
}
|
||||
@ -922,7 +959,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
if (list && list.length > 0) {
|
||||
list.forEach((item: any) => {
|
||||
detailList.push(item)
|
||||
idList.push(item.question.id.toString())
|
||||
idList.push(item.questionId.toString())
|
||||
if (item.question) {
|
||||
let obj = JSON.parse(JSON.stringify(item.question))
|
||||
|
||||
@ -943,6 +980,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
|
||||
setSelectedQuestionDetail(detailList)
|
||||
console.log('idList', idList);
|
||||
console.log('res', res);
|
||||
|
||||
setSelectedQuestionId(idList)
|
||||
|
||||
@ -1085,28 +1123,27 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
|
||||
{/* 批量克隆点位 */}
|
||||
<Modal
|
||||
width={400}
|
||||
width={500}
|
||||
title={"批量克隆"}
|
||||
open={showBatchCloneModal}
|
||||
confirmLoading={batchLoading}
|
||||
onOk={() => {
|
||||
batchCloneForm.current?.validateFields().then(async (res: any) => {
|
||||
console.log('res', res);
|
||||
console.log('currentRow', currentRow);
|
||||
console.log('currentUser', currentUser);
|
||||
console.log('serviceObj', serviceObj);
|
||||
onOk={async () => {
|
||||
|
||||
console.log('selectCloneServiceList', selectCloneServiceList);
|
||||
console.log('selectCloneServiceDetail', selectCloneServiceDetail);
|
||||
|
||||
let list: any = res.serviceList
|
||||
// 判断有没有选择了服务区
|
||||
if (selectCloneServiceDetail && selectCloneServiceDetail.length > 0) {
|
||||
setBatchLoading(true)
|
||||
let serverParts: any = []
|
||||
if (list && list.length > 0) {
|
||||
list.forEach((item: any) => {
|
||||
|
||||
selectCloneServiceDetail.forEach((item: any) => {
|
||||
serverParts.push({
|
||||
serverPartName: serviceObj[item],
|
||||
serverPartId: item
|
||||
serverPartName: item.name,
|
||||
serverPartId: item.id
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
let question: any = []
|
||||
if (currentRow?.questionnaireTemplateQuestions && currentRow?.questionnaireTemplateQuestions.length > 0) {
|
||||
currentRow.questionnaireTemplateQuestions.forEach((item: any) => {
|
||||
@ -1130,6 +1167,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
}
|
||||
console.log('req', req);
|
||||
const data = await handleBatchService(req)
|
||||
setBatchLoading(false)
|
||||
console.log('datadatadatadata', data);
|
||||
if (data.Result_Code === 100) {
|
||||
message.success('批量克隆成功!')
|
||||
@ -1140,7 +1178,57 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
} else {
|
||||
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)
|
||||
}}
|
||||
onCancel={() => {
|
||||
@ -1148,7 +1236,53 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
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}
|
||||
submitter={false}
|
||||
>
|
||||
@ -1190,7 +1324,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</ProForm>
|
||||
</ProForm> */}
|
||||
</Modal>
|
||||
</div >
|
||||
)
|
||||
|
||||
@ -39,8 +39,24 @@ const addQuestion = ({ parentRow, onRef, currentUser, showQuestionModal, setShow
|
||||
destroyOnClose
|
||||
onOk={() => {
|
||||
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 data = {}
|
||||
|
||||
if (parentRow?.id) {
|
||||
req = {
|
||||
...parentRow,
|
||||
|
||||
@ -3,7 +3,7 @@ import request from "@/utils/requestJava"
|
||||
|
||||
// 拿到问题列表接口
|
||||
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) {
|
||||
return data.Result_Data.List
|
||||
}
|
||||
|
||||
@ -102,6 +102,7 @@ const RecordDetail = ({ parentRow, show, detailType, currentUser, onRef, showErr
|
||||
...parentRow,
|
||||
...extendObj,
|
||||
placeName: parentRow.template?.title || '',
|
||||
serverPartName: parentRow.template?.serverPartName,
|
||||
submittedAt: moment(parentRow?.submittedAt).format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
console.log('formRes', obj);
|
||||
|
||||
@ -118,8 +118,8 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
|
||||
align: 'center',
|
||||
ellipsis: true,
|
||||
render: (_, record) => {
|
||||
let res: any = record.extend ? JSON.parse(record.extend) : "-"
|
||||
return <span style={{ color: res.situation === 1 ? "red" : "" }}>{res.situation === 1 ? '异常' : res.situation === 0 ? '正常' : ''}</span>
|
||||
// let res: any = record.extend ? JSON.parse(record.extend) : "-"
|
||||
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,
|
||||
ellipsis: true,
|
||||
render: (_, record) => {
|
||||
let extendObj = record?.extend ? JSON.parse(record?.extend) : ""
|
||||
return extendObj?.uploadResult ? extendObj?.uploadResult : "-"
|
||||
// let extendObj = record?.extend ? JSON.parse(record?.extend) : ""
|
||||
return record?.uploadResult ? record?.uploadResult : "-"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -190,13 +190,13 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
|
||||
ellipsis: true,
|
||||
align: 'center',
|
||||
render: (_, record) => {
|
||||
let res: any = record.extend ? JSON.parse(record.extend) : "-"
|
||||
return <span style={{ color: res.errorStatus === 0 ? "red" : res.errorStatus === 1 ? "#1677ff" : "" }}>{
|
||||
res.errorStatus === 0
|
||||
// let res: any = record.extend ? JSON.parse(record.extend) : "-"
|
||||
return <span style={{ color: record.errorStatus === 0 ? "red" : record.errorStatus === 1 ? "#1677ff" : "" }}>{
|
||||
record.errorStatus === 0
|
||||
? "待处理"
|
||||
: res.errorStatus === 1
|
||||
: record.errorStatus === 1
|
||||
? "处理中"
|
||||
: res.errorStatus === 2
|
||||
: record.errorStatus === 2
|
||||
? "已处理"
|
||||
: "-"
|
||||
}</span>
|
||||
@ -210,8 +210,8 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
|
||||
ellipsis: true,
|
||||
align: 'center',
|
||||
render: (_, record) => {
|
||||
let extendObj = record?.extend ? JSON.parse(record?.extend) : ""
|
||||
let imgList = extendObj.imgsList
|
||||
// let extendObj = record?.extend ? JSON.parse(record?.extend) : ""
|
||||
let imgList = record.imgsList
|
||||
return imgList && imgList.length > 0 ?
|
||||
<Button type="primary" onClick={() => {
|
||||
setShowImgList(imgList)
|
||||
@ -227,31 +227,29 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
|
||||
hideInSearch: true,
|
||||
width: 150,
|
||||
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>
|
||||
{
|
||||
res.situation === 1 ?
|
||||
record.situation === 1 ?
|
||||
<a onClick={
|
||||
() => {
|
||||
setCurrentRow({
|
||||
...record,
|
||||
...res
|
||||
})
|
||||
setShowAbnormal(true)
|
||||
setShowDetail(true)
|
||||
}
|
||||
}>异常处理</a> : ""
|
||||
}
|
||||
< a onClick={() => {
|
||||
}>异常处理</a> : < a onClick={() => {
|
||||
setCurrentRow({
|
||||
...record,
|
||||
...res
|
||||
})
|
||||
setShowDetail(true)
|
||||
}}>
|
||||
详情
|
||||
}}> 详情
|
||||
</a >
|
||||
}
|
||||
|
||||
|
||||
<Popconfirm
|
||||
title={"确认删除?"}
|
||||
onConfirm={async () => {
|
||||
@ -296,7 +294,7 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
|
||||
expandRowByClick: true
|
||||
}}
|
||||
rowKey={(record) => {
|
||||
return `${record?.id}-${record?.code}`
|
||||
return `${record?.id}-${record?.code}-${record?.templateId}`
|
||||
}}
|
||||
scroll={{ x: "100%", y: 'calc(100vh - 400px)' }}
|
||||
headerTitle={<span style={{ color: "#1890ff", fontSize: 14, fontWeight: 600 }}>考核记录管理</span>}
|
||||
|
||||
@ -361,7 +361,7 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
||||
defaultExpandAllRows: true
|
||||
}}
|
||||
rowKey={(record) => {
|
||||
return `${record?.id}-${record?.code}`
|
||||
return `${record?.id}-${record?.code}-${record?.template.id}`
|
||||
}}
|
||||
scroll={{ x: "100%", y: 'calc(100vh - 400px)' }}
|
||||
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
|
||||
if (subItem.children && subItem.children.length > 0) {
|
||||
subItem.children.forEach((thirdItem: any) => {
|
||||
thirdItem.allDay = allDay
|
||||
allSubItemDaySum += thirdItem.allDay
|
||||
inspectionNumberSum += thirdItem.inspectionNumber
|
||||
// thirdItem.allDay = allDay
|
||||
// allSubItemDaySum += thirdItem.allDay
|
||||
thirdItem.allDay = thirdItem.template.patrolTotal
|
||||
allSubItemDaySum += thirdItem.template.patrolTotal
|
||||
|
||||
// inspectionNumberSum += thirdItem.inspectionNumber
|
||||
inspectionNumberSum += thirdItem.template.patrolNumber
|
||||
thirdItem.inspectionNumber = thirdItem.template.patrolNumber
|
||||
|
||||
normalNumberSum += thirdItem.normalNumber
|
||||
errorNumberSum += thirdItem.errorNumber
|
||||
pendingProcessNumberSum += thirdItem.pendingProcessNumber
|
||||
|
||||
@ -44,10 +44,10 @@ instance.interceptors.response.use(
|
||||
(response) => {
|
||||
const { data } = response;
|
||||
|
||||
if (data.code !== 200) {
|
||||
notification.error({
|
||||
message: data.message,
|
||||
});
|
||||
if (data.Result_Code !== 200) {
|
||||
// notification.error({
|
||||
// message: data.message,
|
||||
// });
|
||||
}
|
||||
|
||||
const timestamp = getFormattedDate()
|
||||
|
||||
@ -14,7 +14,10 @@ const { UMI_APP_BASEURL } = process.env;
|
||||
// 修改baseURL为完整的API地址,确保在生产环境中正确访问
|
||||
// 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(
|
||||
(config) => {
|
||||
@ -44,9 +47,9 @@ instance.interceptors.response.use(
|
||||
const { data } = response;
|
||||
|
||||
if (data.Result_Code !== 100) {
|
||||
notification.error({
|
||||
message: data.message,
|
||||
});
|
||||
// notification.error({
|
||||
// message: data.message,
|
||||
// });
|
||||
}
|
||||
|
||||
const timestamp = getFormattedDate()
|
||||
|
||||
156
src/utils/requestTest.ts
Normal file
156
src/utils/requestTest.ts
Normal 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;
|
||||
Loading…
x
Reference in New Issue
Block a user