From b021eff28ffbce96cb64ea7c8c38901c12c9bb28 Mon Sep 17 00:00:00 2001 From: cclu <1106109051@qq.com> Date: Thu, 17 Apr 2025 19:50:30 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A5=20feat(=E6=A8=A1=E5=9D=97):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=AA=E5=BE=88=E6=A3=92=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/index.tsx | 7 +- .../examine/index/components/addBigType.tsx | 6 +- src/pages/examine/index/index.tsx | 12 +- src/pages/examine/index/service.ts | 21 ++- src/pages/examine/modal/index.tsx | 90 +++++----- src/pages/examine/modal/service.ts | 27 +-- .../question/components/addQuestion.tsx | 13 +- src/pages/examine/question/index.tsx | 9 +- src/pages/examine/question/service.ts | 13 +- src/pages/examine/record/index.tsx | 16 +- src/pages/examine/record/service.ts | 11 +- src/pages/examine/recordSummary/index.tsx | 24 +-- src/utils/requestJava.ts | 159 ++++++++++++++++++ 13 files changed, 300 insertions(+), 108 deletions(-) create mode 100644 src/utils/requestJava.ts diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index e8b013c..a99971f 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -103,6 +103,8 @@ const BasicLayout: FC<{ user: UserModelState, global: ProfileModelState, dispatc : item.name, }), ); + console.log('consumableMenuconsumableMenuconsumableMenu', consumableMenu); + // const consumableMenu: MenuDataItem[] = [ // { // path: '/', @@ -213,6 +215,8 @@ const BasicLayout: FC<{ user: UserModelState, global: ProfileModelState, dispatc console.log('tabsRoutes', tabsRoutes); console.log('location', location); console.log('consumableMenu', consumableMenu); + console.log('oneFloorListoneFloorListoneFloorListoneFloorList', oneFloorList); + return ( @@ -280,10 +284,9 @@ const BasicLayout: FC<{ user: UserModelState, global: ProfileModelState, dispatc actionsRender={() => } onPageChange={(location) => { console.log('location', location); - if (location?.pathname && location?.pathname !== '/') { - const nextModule: any = oneFloorList.filter(n => location?.pathname === n?.path) + let title = '' if (nextModule && nextModule.length > 0) { title = nextModule[0].name diff --git a/src/pages/examine/index/components/addBigType.tsx b/src/pages/examine/index/components/addBigType.tsx index 855620a..7f4b5b5 100644 --- a/src/pages/examine/index/components/addBigType.tsx +++ b/src/pages/examine/index/components/addBigType.tsx @@ -60,9 +60,9 @@ const AddBigType = ({ parentRow, onRef, openAddModal, currentUser, setOpenAddMod } console.log('req', req); console.log('data', data); - if (data.code === 200) { + if (data.Result_Code === 100) { modalRef.current?.resetFields() - message.success(data.message) + message.success(`${parentRow?.id ? '编辑' : '新增'}成功!`) setOpenAddModal(false) if (parentActionRef) { parentActionRef.current?.reload() @@ -75,7 +75,7 @@ const AddBigType = ({ parentRow, onRef, openAddModal, currentUser, setOpenAddMod afterAdd() } } else { - message.error(data.message) + message.error(data.Result_Desc) } }) }} diff --git a/src/pages/examine/index/index.tsx b/src/pages/examine/index/index.tsx index 28ef6d8..35ee104 100644 --- a/src/pages/examine/index/index.tsx +++ b/src/pages/examine/index/index.tsx @@ -119,10 +119,16 @@ const examineIndex: React.FC<{ currentUser: any }> = (props) => { // 删除分类 const handleDeleteType = async (id: number) => { - const data = await handleGetDeleteExamineType(id) - if (data.code === 200) { - message.success(data.message) + let req: any = { + id: id + } + console.log('req', req); + const data = await handleGetDeleteExamineType(req) + if (data.Result_Code === 100) { + message.success('删除成功!') actionRef.current?.reload() + } else { + message.error(data.Result_Desc) } } diff --git a/src/pages/examine/index/service.ts b/src/pages/examine/index/service.ts index d0166ab..fa18a92 100644 --- a/src/pages/examine/index/service.ts +++ b/src/pages/examine/index/service.ts @@ -1,10 +1,13 @@ -import request from "@/utils/request" + +// import request from "@/utils/request" +import request from "@/utils/requestJava" + // 拿到类别列表接口 export async function handleGetExamineTypeList(params?: any) { - const data = await request.get('/question-categories', {params}) - if (data.code === 200) { - return data.data + const data = await request.get('/question-categories/getList', { params }) + if (data.Result_Code === 100) { + return data.Result_Data.list } return [] } @@ -12,26 +15,26 @@ export async function handleGetExamineTypeList(params?: any) { // 拿树形的 export async function handleGetExamineTypeTreeList(params?: any) { const data = await request.get('/question-categories/tree', params) - if (data.code === 200) { - return data.data + if (data.Result_Code === 100) { + return data.Result_Data.list } return [] } // 新增类别列表接口 export async function handleGetAddExamineType(params: any) { - const data = await request.post('/question-categories', params) + const data = await request.post('/question-categories/save', params) return data } // 删除类别接口 export async function handleGetDeleteExamineType(params: any) { - const data = await request.get(`/question-categories/delete/${params}`) + const data = await request.get(`/question-categories/delete`, { params }) return data } // 编辑分类接口 export async function handleGetEditExamineType(params: any) { - const data = await request.post(`/question-categories/${params.id}`, params) + const data = await request.post(`/question-categories/update`, params) return data } \ No newline at end of file diff --git a/src/pages/examine/modal/index.tsx b/src/pages/examine/modal/index.tsx index 685399b..deed22d 100644 --- a/src/pages/examine/modal/index.tsx +++ b/src/pages/examine/modal/index.tsx @@ -293,8 +293,8 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { // 删除模版 const deleteQuestion = async (id: number) => { const data = await handleDeleteTemplates({ id: id }) - if (data.code === 200) { - message.success(data.message) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) actionRef.current?.reload() } } @@ -316,6 +316,8 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { children: child.children || [] })) || [] })) : []; + console.log('formattedData', formattedData); + setBigTypeList(formattedData); }; @@ -413,6 +415,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { modalRef.current?.validateFields().then(async (res) => { console.log('res', res); console.log('currentRow', currentRow); + console.log('selectedQuestionDetail', selectedQuestionDetail); let req = {} let data = {} if (currentRow?.id) { @@ -467,7 +470,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { if (selectedQuestionDetail && selectedQuestionDetail.length > 0) { selectedQuestionDetail.forEach((item) => { questions.push({ - questionId: item.id, + questionId: item.questionId, isRequired: item.required, sortOrder: item.sortOrder }) @@ -481,38 +484,39 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { serverPartName: serviceObj ? serviceObj[res.serverPartId] : "", serverPartId: res.serverPartId, // qrUrl: "", - questions: questions && questions.length > 0 ? questions : "", + questions: questions && questions.length > 0 ? questions : [], operator: currentUser?.operator, status: res.status, description: res.description } data = await handleAddTemplates(req) - console.log('datadsadsa1', data.data); - const myQRCodeDataUrl = await QRCode.toDataURL(`pages/walkAroundManager/index?id=${data.data.id}`); - const file = base64ToFile(myQRCodeDataUrl, `wenjuan${data.data.id}.png`); + 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.data.id}.png`); // 确保文件名也传递 + 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.data, + ...data.Result_Data, qrUrl: imgUrl }) setQrCodeUrl(imgUrl) + // setQrCodeUrl(myQRCodeDataUrl) } console.log('datadsadsa', data); - if (data.code === 200) { + if (data.Result_Code === 100) { modalRef.current?.resetFields() - message.success(data.message) + message.success('新增成功!') setShowPlaceModal(false) actionRef.current?.reload() setCurrentRow(undefined) } else { - message.error(data.message) + message.error(data.Result_Desc) } }) @@ -771,42 +775,46 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { onOk={() => { console.log('selectedCloneId', selectedCloneId); console.log('selectedCloneDetail', selectedCloneDetail); + if (selectedCloneDetail && selectedCloneDetail.length > 0) { + let res: any = [] + let detailList: any = [] + let idList: any = [] + let list: any = selectedCloneDetail[0].questionnaireTemplateQuestions + if (list && list.length > 0) { + list.forEach((item: any) => { + detailList.push(item) + idList.push(item.question.id.toString()) + if (item.question) { + let obj = JSON.parse(JSON.stringify(item.question)) - let res: any = [] - let detailList: any = [] - let idList: any = [] - let list: any = selectedCloneDetail[0].questionnaireTemplateQuestions - if (list && list.length > 0) { - list.forEach((item: any) => { - detailList.push(item) - idList.push(item.question.id.toString()) - if (item.question) { - let obj = JSON.parse(JSON.stringify(item.question)) + let str: string = '' + if (obj.options && obj?.options.length > 0) { + obj.options.forEach((subItem: any, index: number) => { + str += `${index > 0 ? ',' : ''}选项${index + 1}:${subItem.text}` + }) + } - let str: string = '' - if (obj.options && obj?.options.length > 0) { - obj.options.forEach((subItem: any, index: number) => { - str += `${index > 0 ? ',' : ''}选项${index + 1}:${subItem.text}` - }) + obj.text = obj.title + obj.mark = JSON.stringify(obj.options) + obj.showText = str + res.push(obj) } + }) + } - obj.text = obj.title - obj.mark = JSON.stringify(obj.options) - obj.showText = str - res.push(obj) - } + setSelectedQuestionDetail(detailList) + console.log('idList', idList); + + setSelectedQuestionId(idList) + + modalRef.current?.setFieldsValue({ + questions: res }) + handleShowCloneModal(false) + } else { + handleShowCloneModal(false) } - setSelectedQuestionDetail(detailList) - console.log('idList', idList); - - setSelectedQuestionId(idList) - - modalRef.current?.setFieldsValue({ - questions: res - }) - handleShowCloneModal(false) }} onCancel={() => { handleShowCloneModal(false) diff --git a/src/pages/examine/modal/service.ts b/src/pages/examine/modal/service.ts index 7aa4e37..7fcafba 100644 --- a/src/pages/examine/modal/service.ts +++ b/src/pages/examine/modal/service.ts @@ -1,54 +1,55 @@ import requestOld from "@/utils/requestOld" -import request from "@/utils/request" - +// import request from "@/utils/request" +import requestNode from "@/utils/request" +import request from "@/utils/requestJava" // 拿到模版id列表 去绑定服务区的多个站点信息 的列表接口 export async function handleGetTemplatesList(params?: any) { const data = await request.get('/questionnaire-templates', { params }) - if (data.code === 200) { - return data.data + if (data.Result_Code === 200) { + return data.Result_Data.list } return [] } // 新建模版 export async function handleAddTemplates(params?: any) { - const data = await request.post('/questionnaire-templates', params) + const data = await request.post('/questionnaire-templates/save', params) return data } // 更新模版 export async function handleUpdateTemplates(params?: any) { - const data = await request.post(`/questionnaire-templates/${params.id}`, params) + const data = await request.post(`/questionnaire-templates/update`, params) return data } // 删除模版 export async function handleDeleteTemplates(params?: any) { - const data = await request.get(`/questionnaire-templates/delete/${params.id}`) + const data = await request.get(`/questionnaire-templates/delete`,{params}) return data } export async function handleGetQuestionList(params?: any) { - const data = await request.get(`/questions?categoryId=${params.categoryId}`,) - if (data.code === 200) { - return data.data + const data = await request.get('/questions/getList', params) + if (data.Result_Code === 100) { + return data.Result_Data.list } return [] } // 上传图片的oss接口 export async function handleUploadFile(params?: any) { - const data = await request.post(`/oss/upload`, params) + const data = await requestNode.post(`/oss/upload`, params) return data } // 模版树的查询 export async function handleSearchModalTree(params?: any) { const data = await request.post(`/questionnaire-templates/search/tree`, params) - if (data.code === 200) { - return data.data + if (data.Result_Code === 100) { + return data.Result_Data.list } return [] } diff --git a/src/pages/examine/question/components/addQuestion.tsx b/src/pages/examine/question/components/addQuestion.tsx index eff3725..465384f 100644 --- a/src/pages/examine/question/components/addQuestion.tsx +++ b/src/pages/examine/question/components/addQuestion.tsx @@ -51,7 +51,8 @@ const addQuestion = ({ parentRow, onRef, currentUser, showQuestionModal, setShow options: res.options, status: res.status, operator: currentUser?.operator, - description: `${res.categoryId && categoryIdObj ? categoryIdObj[res.categoryId] : ''}` + description: `${res.categoryId && categoryIdObj ? categoryIdObj[res.categoryId] : ''}`, + category: undefined } console.log('req', req); @@ -73,11 +74,11 @@ const addQuestion = ({ parentRow, onRef, currentUser, showQuestionModal, setShow data = await handleAddQuestion(req) } console.log('datadsadsa', data); - if (data.code === 200) { + if (data.Result_Code === 100) { if (modalRef) { modalRef.current?.resetFields() } - message.success(data.message) + message.success(data.Result_Desc) setShowQuestionModal(false) if (parentActionRef) { parentActionRef.current?.reload() @@ -89,7 +90,7 @@ const addQuestion = ({ parentRow, onRef, currentUser, showQuestionModal, setShow afterAdd() } } else { - message.error(data.message) + message.error(data.Result_Desc) } }) @@ -136,10 +137,12 @@ const addQuestion = ({ parentRow, onRef, currentUser, showQuestionModal, setShow let obj: any = {} const labelList = await handleGetExamineTypeList() if (labelList && labelList.length > 0) { - labelList.forEach((item) => { + labelList.forEach((item: any) => { obj[item.id] = item.name }) } + console.log('objobjobjobj', obj); + setCategoryIdObj(obj) return data }} diff --git a/src/pages/examine/question/index.tsx b/src/pages/examine/question/index.tsx index 3c9c538..2cc57e0 100644 --- a/src/pages/examine/question/index.tsx +++ b/src/pages/examine/question/index.tsx @@ -168,9 +168,11 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { // 删除分类 const deleteQuestion = async (id: number) => { const data = await handleDeleteQuestion({ id: id }) - if (data.code === 200) { - message.success(data.message) + if (data.Result_Code === 100) { + message.success('删除成功!') actionRef.current?.reload() + } else { + message.error(data.Result_Desc) } } @@ -193,6 +195,9 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { // 检查当前节点是否匹配list中的categoryId const matchedItems = itemsToInsert.filter(item => item.categoryId === node.id); + console.log('node', node); + + console.log('matchedItems', matchedItems); if (matchedItems.length > 0) { // 如果匹配到,初始化children数组(如果不存在) diff --git a/src/pages/examine/question/service.ts b/src/pages/examine/question/service.ts index 3a42a52..7b13f4e 100644 --- a/src/pages/examine/question/service.ts +++ b/src/pages/examine/question/service.ts @@ -1,29 +1,30 @@ -import request from "@/utils/request" +// import request from "@/utils/request" +import request from "@/utils/requestJava" // 拿到问题列表接口 export async function handleGetQuestionList(params?: any) { const data = await request.post('/questions/search/many', params) - if (data.code === 200) { - return data.data + if (data.Result_Code === 100) { + return data.Result_Data.list } return [] } // 新增问题接口 export async function handleAddQuestion(params?: any) { - const data = await request.post('/questions', params) + const data = await request.post('/questions/save', params) return data } // 编辑问题接口 export async function handleEditQuestion(params?: any) { - const data = await request.post(`/questions/${params.id}`, params) + const data = await request.post(`/questions/update`, params) return data } // 删除问题 export async function handleDeleteQuestion(params?: any) { - const data = await request.get(`/questions/delete/${params.id}`) + const data = await request.get(`/questions/delete`, { params }) return data } diff --git a/src/pages/examine/record/index.tsx b/src/pages/examine/record/index.tsx index d8cb11a..251b40b 100644 --- a/src/pages/examine/record/index.tsx +++ b/src/pages/examine/record/index.tsx @@ -269,8 +269,8 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { // 删除记录 const deleteRecord = async (id: any) => { const data = await handleDeleteRecord({ id: id }) - if (data.code === 200) { - message.success(data.message) + if (data.Result_Code === 100) { + message.success(data.Result_Desc) actionRef.current?.reload() } } @@ -311,8 +311,8 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { const req: any = { serverPartIds: selectedId && selectedId.length > 0 ? selectedId : [], - startTime: params?.staticDate ? `${params?.staticDate}T00:00:00` : "", - endTime: params?.staticDate ? `${params?.staticDate}T23:59:59` : "", + startTime: params?.staticDate ? `${params?.staticDate}` : "", + endTime: params?.staticDate ? `${params?.staticDate}` : "", // serverPartId: params?.serverPartId ? params?.serverPartId : undefined, extend: params?.inspectionType ? [{ key: "situation", @@ -406,14 +406,14 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { }; const data = await handleUpdateExtend(recordDetailRef.current?.formRes.id, { extend: JSON.stringify(req) }) - if (data.code === 200) { + if (data.Result_Code === 100) { message.success('提交成功') setShowDetail(false) setShowAbnormal(false) actionRef.current?.reload() setCurrentRow(undefined) } else { - message.error(data.message) + message.error(data.Result_Desc) } }) } @@ -439,14 +439,14 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { }; const data = await handleUpdateExtend(recordDetailRef.current?.formRes.id, { extend: JSON.stringify(req) }) - if (data.code === 200) { + if (data.Result_Code === 100) { message.success('提交成功') setShowDetail(false) setShowAbnormal(false) actionRef.current?.reload() setCurrentRow(undefined) } else { - message.error(data.message) + message.error(data.Result_Desc) } }) } diff --git a/src/pages/examine/record/service.ts b/src/pages/examine/record/service.ts index e535ea0..c5b4257 100644 --- a/src/pages/examine/record/service.ts +++ b/src/pages/examine/record/service.ts @@ -1,11 +1,12 @@ -import request from "@/utils/request" +// import request from "@/utils/request" +import request from "@/utils/requestJava" import requestMap from '@/utils/requestMap' // 拿到记录 export async function handleGetRecordList(params?: any) { const data = await request.post('/questionnaire-responses/search/many', params) - if (data.code === 200) { - return data.data + if (data.Result_Code === 100) { + return data.Result_Data.list } return [] } @@ -13,8 +14,8 @@ export async function handleGetRecordList(params?: any) { // 拿到记录的树型结构 export async function handleGetRecordTreeList(params?: any) { const data = await request.post('/questionnaire-responses/tree', params) - if (data.code === 200) { - return data.data + if (data.Result_Code === 100) { + return data.Result_Data.list } return [] } diff --git a/src/pages/examine/recordSummary/index.tsx b/src/pages/examine/recordSummary/index.tsx index 69369bf..4b24995 100644 --- a/src/pages/examine/recordSummary/index.tsx +++ b/src/pages/examine/recordSummary/index.tsx @@ -215,6 +215,18 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => { // "0": "正常" // } // }, + { + title: