diff --git a/src/pages/examine/index/components/addBigType.tsx b/src/pages/examine/index/components/addBigType.tsx new file mode 100644 index 0000000..855620a --- /dev/null +++ b/src/pages/examine/index/components/addBigType.tsx @@ -0,0 +1,147 @@ +import { ConnectState } from "@/models/global"; +import { FormInstance, ProForm, ProFormSwitch, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-components"; +import { useImperativeHandle, useRef } from "react"; +import { connect } from "umi"; +import { handleGetAddExamineType, handleGetEditExamineType, handleGetExamineTypeTreeList } from "../service"; +import { message, Modal } from "antd"; + + +type DetailProps = { + parentRow: any + onRef: any + openAddModal: boolean + currentUser?: any + setOpenAddModal?: any + parentActionRef?: any + setParentRow?: any + afterAdd?: any // 新增完之后 需要调用的方法 +} +const AddBigType = ({ parentRow, onRef, openAddModal, currentUser, setOpenAddModal, parentActionRef, setParentRow, afterAdd }: DetailProps) => { + + // 弹出框的表单实例 + const modalRef = useRef() + + + useImperativeHandle(onRef, () => ({ + modalRef + })); + + + return ( +
+ { + modalRef.current?.validateFields().then(async (res) => { + let req = {} + let data = {} + if (parentRow?.id) { + req = { + ...parentRow, + parentId: res.parentId, + name: res.name, + description: res.description, + status: res.status, + operator: currentUser?.operator + } + data = await handleGetEditExamineType(req) + } else { + req = { + parentId: res.parentId, + name: res.name, + description: res.description, + sortOrder: "1", + status: res.status, + operator: currentUser?.operator + } + data = await handleGetAddExamineType(req) + } + console.log('req', req); + console.log('data', data); + if (data.code === 200) { + modalRef.current?.resetFields() + message.success(data.message) + setOpenAddModal(false) + if (parentActionRef) { + parentActionRef.current?.reload() + } + if (setParentRow) { + setParentRow(undefined) + } + + if (afterAdd) { + afterAdd() + } + } else { + message.error(data.message) + } + }) + }} + onCancel={() => { + modalRef.current?.setFieldsValue({}) + if (setParentRow) { + setParentRow(undefined) + } + setOpenAddModal(false) + }} + > + { + console.log('parentRow', parentRow); + return { ...parentRow } + }}> + { + const req = {} + const data = await handleGetExamineTypeTreeList(req) + console.log('dsadas', data); + let res = [ + { + name: '/', + id: 0, + children: data + } + ] + return res + }} + fieldProps={{ + treeDefaultExpandedKeys: [0], + fieldNames: { + label: "name", + value: "id" + }, + }} + rules={[ + { required: true, message: '请选择类别层级!' } + ]} + /> + + + + + + + +
+ ) +} + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.data +}))(AddBigType); diff --git a/src/pages/examine/index/index.tsx b/src/pages/examine/index/index.tsx index 54536e0..28ef6d8 100644 --- a/src/pages/examine/index/index.tsx +++ b/src/pages/examine/index/index.tsx @@ -7,6 +7,7 @@ import moment from "moment"; import LeftSelectTree from "@/components/leftSelectTree/leftSelectTree"; import { handleGetAddExamineType, handleGetDeleteExamineType, handleGetEditExamineType, handleGetExamineTypeList, handleGetExamineTypeTreeList } from "./service"; import { ProForm, ProFormSwitch, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-components"; +import AddBigType from "./components/addBigType"; const examineIndex: React.FC<{ currentUser: any }> = (props) => { @@ -190,104 +191,13 @@ const examineIndex: React.FC<{ currentUser: any }> = (props) => { - { - modalRef.current?.validateFields().then(async (res) => { - let req = {} - let data = {} - if (currentRow?.id) { - req = { - ...currentRow, - parentId: res.parentId, - name: res.name, - description: res.description, - status: res.status, - operator: currentUser?.operator - } - data = await handleGetEditExamineType(req) - } else { - req = { - parentId: res.parentId, - name: res.name, - description: res.description, - sortOrder: "1", - status: res.status, - operator: currentUser?.operator - } - data = await handleGetAddExamineType(req) - } - console.log('req', req); - console.log('data', data); - if (data.code === 200) { - modalRef.current?.resetFields() - message.success(data.message) - setOpenAddModal(false) - actionRef.current?.reload() - setCurrentRow(undefined) - } else { - message.error(data.message) - } - }) - }} - onCancel={() => { - modalRef.current?.setFieldsValue({}) - setCurrentRow(undefined) - setOpenAddModal(false) - }} - > - { - console.log('currentRow', currentRow); - return { ...currentRow } - }}> - { - const req = {} - const data = await handleGetExamineTypeList(req) - console.log('dsadas', data); - let res = [ - { - name: '/', - id: 0, - children: data - } - ] - return res - }} - fieldProps={{ - treeDefaultExpandedKeys: [0], - fieldNames: { - label: "name", - value: "id" - }, - }} - rules={[ - { required: true, message: '请选择类别层级!' } - ]} - /> - - - - - + + + ) } diff --git a/src/pages/examine/modal/index.tsx b/src/pages/examine/modal/index.tsx index b9d03b6..a78aa1d 100644 --- a/src/pages/examine/modal/index.tsx +++ b/src/pages/examine/modal/index.tsx @@ -3,13 +3,15 @@ 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, Drawer } from "antd"; import moment from "moment"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { connect } from "umi"; import { handleAddTemplates, handleDeleteTemplates, handleGetQuestionList, handleGetTemplatesList, handleUpdateTemplates, handleUploadFile } from "./service"; import { handleGetExamineTypeTreeList } from "../index/service"; import QRCode from 'qrcode'; import { base64ToFile } from "@/utils/publicMethods"; import RecordDetail from "../record/components/recordDetail"; +import AddBigType from "../index/components/addBigType"; +import AddQuestion from "../question/components/addQuestion"; const examineModal: React.FC<{ currentUser: any }> = (props) => { @@ -56,6 +58,12 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { createdAt: { show: false }, operator: { show: false }, }) + // 显示新增大类的抽屉 + const [openAddBigType, setOpenAddBigType] = useState(false) + // 显示 新增问题的抽屉 + const [openAddQuestion, setOpenAddQuestion] = useState(false) + // 拿到protable的问题分类 + const [bigTypeList, setBigTypeList] = useState() const columns: any = [ { @@ -171,10 +179,10 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { setCurrentRow(record) setShowPlaceModal(true) }}>编辑 - { + {/* { setCurrentRow(record) handleShowDetail(true) - }}>详情 + }}>详情 */} { @@ -196,25 +204,26 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { dataIndex: "id", hideInTable: true, valueType: 'treeSelect', - request: async () => { - const data = await handleGetExamineTypeTreeList() - console.log('data', data); - return data && data.length > 0 ? data.map(item => ({ - title: item.name, - value: item.id, - children: item.children?.map((child: any) => ({ - title: child.name, - value: child.id, - children: child.children || [] - })) || [] - })) : [] - }, + // request: async () => { + // const data = await handleGetExamineTypeTreeList() + // console.log('data', data); + // return data && data.length > 0 ? data.map(item => ({ + // title: item.name, + // value: item.id, + // children: item.children?.map((child: any) => ({ + // title: child.name, + // value: child.id, + // children: child.children || [] + // })) || [] + // })) : [] + // }, fieldProps: { multiple: false, treeDefaultExpandAll: true, showSearch: true, treeNodeFilterProp: 'title', - placeholder: '请选择问题分类' + placeholder: '请选择问题分类', + options: bigTypeList } }, { @@ -252,6 +261,29 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { } } + // 新增完类型之后的刷新 + const handleReloadSearchList = async () => { + modalActionRef.current?.reload(); + fetchTreeData() + } + + const fetchTreeData = async () => { + const data = await handleGetExamineTypeTreeList(); + const formattedData = data?.length ? data.map(item => ({ + title: item.name, + value: item.id, + children: item.children?.map(child => ({ + title: child.name, + value: child.id, + children: child.children || [] + })) || [] + })) : []; + setBigTypeList(formattedData); + }; + useEffect(() => { + fetchTreeData() + }, []) + return (
{/* */} @@ -276,7 +308,6 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { search={{ span: 6 }} request={async () => { const req: any = { - } const data = await handleGetTemplatesList() if (data && data.length > 0) { @@ -654,6 +685,21 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { setSelectedQuestionId(selectedRowKeys) } }} + + toolbar={{ + actions: [ + , + + ] + }} />
@@ -671,6 +717,13 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { > + + + + + + + ) } diff --git a/src/pages/examine/question/components/addQuestion.tsx b/src/pages/examine/question/components/addQuestion.tsx new file mode 100644 index 0000000..d0b25a9 --- /dev/null +++ b/src/pages/examine/question/components/addQuestion.tsx @@ -0,0 +1,246 @@ +import { ConnectState } from "@/models/global"; +import { FormInstance, ProForm, ProFormDigit, ProFormList, ProFormRadio, ProFormSwitch, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-components"; +import { useImperativeHandle, useRef, useState } from "react"; +import { connect } from "umi"; +import { Col, message, Modal, Row } from "antd"; +import { handleGetExamineTypeList, handleGetExamineTypeTreeList } from "../../index/service"; +import { handleAddQuestion, handleEditQuestion } from "../service"; + + +type DetailProps = { + parentRow: any + onRef: any + currentUser?: any + showQuestionModal: boolean + setShowQuestionModal?: any + parentActionRef?: any + setCurrentRow?: any + afterAdd?: any +} +const addQuestion = ({ parentRow, onRef, currentUser, showQuestionModal, setShowQuestionModal, parentActionRef, setCurrentRow, afterAdd }: DetailProps) => { + + // 弹出框的表单实例 + const modalRef = useRef() + const [categoryIdObj, setCategoryIdObj] = useState() + + + useImperativeHandle(onRef, () => ({ + modalRef, + categoryIdObj + })); + + + return ( +
+ { + modalRef.current?.validateFields().then(async (res) => { + let req = {} + let data = {} + if (parentRow?.id) { + req = { + ...parentRow, + categoryId: res.categoryId,// 题目id + type: `${res.selectType === 1 ? 'radio' : 'checked'}_choice`,// 题目类型 + title: res.title,// 问题内容 + required: res.required,// 是否必填 + options: res.options, + status: res.status, + operator: currentUser?.operator, + description: `${res.categoryId && categoryIdObj ? categoryIdObj[res.categoryId] : ''}` + } + data = await handleEditQuestion(req) + } else { + req = { + categoryId: res.categoryId,// 题目id + type: `${res.selectType === 1 ? 'radio' : 'checked'}_choice`,// 题目类型 + title: res.title,// 问题内容 + required: res.required,// 是否必填 + options: res.options, + sortOrder: 1, + status: res.status, + operator: currentUser?.operator, + defaultScore: 0, + images: [], + description: `${res.categoryId && categoryIdObj ? categoryIdObj[res.categoryId] : ''}` + } + data = await handleAddQuestion(req) + } + console.log('datadsadsa', data); + if (data.code === 200) { + if (modalRef) { + modalRef.current?.resetFields() + } + message.success(data.message) + setShowQuestionModal(false) + if (parentActionRef) { + parentActionRef.current?.reload() + } + if (setCurrentRow) { + setCurrentRow(undefined) + } + if (afterAdd) { + afterAdd() + } + } else { + message.error(data.message) + } + + }) + + }} + onCancel={() => { + if (modalRef) { + modalRef.current?.resetFields() + } + setShowQuestionModal(false) + if (setCurrentRow) { + setCurrentRow(undefined) + } + }} + > + { + console.log('currentRow', parentRow); + return { + ...parentRow, + selectType: parentRow.type.split('_')[0] === 'checked' ? 2 : 1 + } + }}> + + + { + + + const req = {} + const data = await handleGetExamineTypeTreeList(req) + console.log('dsadas', data); + let res = [ + { + name: '/', + id: 0, + children: data + } + ] + let obj: any = {} + const labelList = await handleGetExamineTypeList() + if (labelList && labelList.length > 0) { + labelList.forEach((item) => { + obj[item.id] = item.name + }) + } + setCategoryIdObj(obj) + return data + }} + fieldProps={{ + treeDefaultExpandedKeys: [0], + fieldNames: { + label: "name", + value: "id" + }, + showSearch: true, + filterTreeNode: (input, treeNode) => { + return (treeNode?.name ?? '').toLowerCase().indexOf(input.toLowerCase()) >= 0; + }, + treeNodeFilterProp: 'name' + }} + /> + + + + + + + + + + + + + + + + ( +
+
{listDom}
+
{action}
+
+ )} + > + + + + + + + + +
+ +
+
+
+ + + +
+ ) +} + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.data +}))(addQuestion); diff --git a/src/pages/examine/question/index.tsx b/src/pages/examine/question/index.tsx index 53c5487..3550560 100644 --- a/src/pages/examine/question/index.tsx +++ b/src/pages/examine/question/index.tsx @@ -6,12 +6,15 @@ import { connect } from "umi"; import { handleAddQuestion, handleDeleteQuestion, handleEditQuestion, handleGetQuestionList } from "./service"; import { handleGetExamineTypeList, handleGetExamineTypeTreeList } from "../index/service"; import moment from "moment"; +import AddQuestion from "./components/addQuestion"; const examineQuestion: React.FC<{ currentUser: any }> = (props) => { const { currentUser } = props const actionRef = useRef(); const formRef = useRef(); + + const addQuestionRef = useRef() // 显示新增问题的悬浮框 const [showQuestionModal, setShowQuestionModal] = useState(false) // 当前点击选中的问题行 @@ -27,6 +30,11 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { const columns: any = [ + { + title: "问题内容", + dataIndex: "title", + hideInTable: true, + }, { title:
问题分类
, dataIndex: "description", @@ -191,196 +199,14 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { /> - - { - modalRef.current?.validateFields().then(async (res) => { - let req = {} - let data = {} - if (currentRow?.id) { - req = { - ...currentRow, - categoryId: res.categoryId,// 题目id - type: `${res.selectType === 1 ? 'radio' : 'checked'}_choice`,// 题目类型 - title: res.title,// 问题内容 - required: res.required,// 是否必填 - options: res.options, - status: res.status, - operator: currentUser?.operator, - description: `${res.categoryId ? categoryIdObj[res.categoryId] : ''}` - } - data = await handleEditQuestion(req) - } else { - req = { - categoryId: res.categoryId,// 题目id - type: `${res.selectType === 1 ? 'radio' : 'checked'}_choice`,// 题目类型 - title: res.title,// 问题内容 - required: res.required,// 是否必填 - options: res.options, - sortOrder: 1, - status: res.status, - operator: currentUser?.operator, - defaultScore: 0, - images: [], - description: `${res.categoryId ? categoryIdObj[res.categoryId] : ''}` - } - data = await handleAddQuestion(req) - } - console.log('datadsadsa', data); - if (data.code === 200) { - modalRef.current?.resetFields() - message.success(data.message) - setShowQuestionModal(false) - actionRef.current?.reload() - setCurrentRow(undefined) - } else { - message.error(data.message) - } - - }) - - }} - onCancel={() => { - modalRef.current?.resetFields() - setShowQuestionModal(false) - setCurrentRow(undefined) - }} - > - { - console.log('currentRow', currentRow); - return { - ...currentRow, - selectType: currentRow.type.split('_')[0] === 'checked' ? 2 : 1 - } - }}> - - - { + - const req = {} - const data = await handleGetExamineTypeTreeList(req) - console.log('dsadas', data); - let res = [ - { - name: '/', - id: 0, - children: data - } - ] - let obj: any = {} - const labelList = await handleGetExamineTypeList() - if (labelList && labelList.length > 0) { - labelList.forEach((item) => { - obj[item.id] = item.name - }) - } - setCategoryIdObj(obj) - return res - }} - fieldProps={{ - treeDefaultExpandedKeys: [0], - fieldNames: { - label: "name", - value: "id" - }, - showSearch: true, - filterTreeNode: (input, treeNode) => { - return (treeNode?.name ?? '').toLowerCase().indexOf(input.toLowerCase()) >= 0; - }, - treeNodeFilterProp: 'name' - }} - /> - - - - - - - - - - - - - - - - ( -
-
{listDom}
-
{action}
-
- )} - > - - - - - - - - -
- -
-
-
) } diff --git a/src/pages/examine/record/components/recordDetail.tsx b/src/pages/examine/record/components/recordDetail.tsx index 68133fe..0c8be7b 100644 --- a/src/pages/examine/record/components/recordDetail.tsx +++ b/src/pages/examine/record/components/recordDetail.tsx @@ -1,27 +1,36 @@ import { ConnectState } from "@/models/global"; import { ActionType, ProTable } from "@ant-design/pro-components"; -import ProForm, { FormInstance, ProFormList, ProFormText } from "@ant-design/pro-form"; +import ProForm, { FormInstance, ProFormList, ProFormSelect, ProFormText, ProFormTextArea, ProFormUploadButton } from "@ant-design/pro-form"; import { Col, Row, Image, Button, Input, Modal } from "antd"; import moment from "moment"; -import { useEffect, useRef, useState } from "react"; +import { useEffect, useImperativeHandle, useRef, useState } from "react"; import { connect } from "umi"; import { handleGetExamineTypeTreeList } from "../../index/service"; import session from "@/utils/session"; import { TextAreaRef } from "antd/lib/input/TextArea"; import './printStyle.css'; +import { handleGetDealerList, handleUploadFile } from "../service"; type DetailProps = { parentRow: any; // 父级数据 show: boolean;// 抽屉是否显示 detailType: string; // 详情的类型 + currentUser: any + onRef?: any + showError: boolean;// 是不是处理异常 } -const RecordDetail = ({ parentRow, show, detailType }: DetailProps) => { +const RecordDetail = ({ parentRow, show, detailType, currentUser, onRef, showError }: DetailProps) => { const formRef = useRef(); + console.log('currentUser', currentUser); + const actionRef = useRef(); const tableFormRef = useRef(); + + const errorStatusFormRef = useRef(); + const errorStatusFormReflast = useRef(); // 表格数据 const [proTableData, setTableData] = useState([]) @@ -34,6 +43,10 @@ const RecordDetail = ({ parentRow, show, detailType }: DetailProps) => { const footerRef = useRef(null) // 考核分类的对象格式 const [examineObj, setExamineObj] = useState() + // 文件列表 + const [fileList, setFileList] = useState() + // 选人的列表数据 + const [selectPersonList, setSelectPersonList] = useState() const columns: any = [ { @@ -90,6 +103,8 @@ const RecordDetail = ({ parentRow, show, detailType }: DetailProps) => { placeName: parentRow.template?.title || '', submittedAt: moment(parentRow?.submittedAt).format('YYYY-MM-DD HH:mm:ss') } + console.log('formRes', obj); + setFormRes(obj) formRef.current?.setFieldsValue(obj) } @@ -334,11 +349,11 @@ const RecordDetail = ({ parentRow, show, detailType }: DetailProps) => {
走动式管理巡查记录
-
巡查内容:
-
服务区区域:${parentRow?.title || '-'}
+
巡查内容:${formRes?.uploadResult || '-'}
+
服务区区域:${formRes?.placeName || '-'}
-
巡检人员:${parentRow?.operator || '-'}
+
巡检人员:${parentRow?.userName || '-'}
巡检时间:${parentRow?.createdAt ? moment(parentRow?.createdAt).format('YYYY-MM-DD HH:mm:ss') : '-'}
` @@ -366,42 +381,65 @@ const RecordDetail = ({ parentRow, show, detailType }: DetailProps) => { if (record._categoryMerged) { // 如果已合并,不显示单元格 } else { - printContent += ` 1 ? `rowspan="${record._categoryRowSpan}"` : ''}>${record.parentName || ''}`; + printContent += ` 1 ? `rowspan="${record._categoryRowSpan}"` : ''}>${record.parentName || ''}`; } // 考核子类列 - 处理合并单元格 if (record._subCategoryMerged) { // 如果已合并,不显示单元格 } else { - printContent += ` 1 ? `rowspan="${record._subCategoryRowSpan}"` : ''}>${record.question?.title || ''}`; + printContent += ` 1 ? `rowspan="${record._subCategoryRowSpan}"` : ''}>${record.question?.title || ''}`; } // 考核结果列 let resultStr = ''; if (record.choiceResponse && record.choiceResponse.length > 0) { record.choiceResponse.forEach((item: any, index: number) => { - resultStr += `${index > 0 ? ',' : ''}答案${index + 1}:${item}`; + resultStr += `${index > 0 ? ',' : ''}结果${index + 1}:${item}`; }); } - printContent += `${resultStr || ''}`; + printContent += `${resultStr || ''}`; printContent += ''; }); - + // if (parentRow?.situation !== 1) { // 加一个页脚 - // printContent += ` - // - // - // - // - // - // - // - // - // - //
巡检人员巡检时间
- // ` + printContent += ` + + + ${formRes.errorStatus >= 1 ? ` + + + + + + + + + `: "" + } + ${formRes.errorStatus === 2 ? ` + + + + + + + + + + + `: + "" + } + + +
值班经理${formRes.suggestPerson.STAFF_NAME || '-'}确认时间${formRes.suggestTime || '-'}
经理意见${formRes.suggestion || '-'}
处理人员${formRes.person.STAFF_NAME || '-'}反馈时间${formRes.feedbackTime || '-'}
反馈内容${formRes.feedbackContent || '-'}
+ ` + // } + + @@ -442,6 +480,14 @@ const RecordDetail = ({ parentRow, show, detailType }: DetailProps) => { } }; + useImperativeHandle(onRef, () => ({ + errorStatusFormRef, + errorStatusFormReflast, + formRes, + selectPersonList, + fileList + })); + return (
{ + { + showError && formRes && formRes.errorStatus >= 0 ? + { + console.log('formRes', formRes); + + return { + ...formRes, + personIndex: formRes.person.STAFF_ID + } + }} + > + + + { + const req = { + SERVERPART_ID: formRes.serverPartId, + PROVINCE_CODE: currentUser.provinceCode, + } + const data = await handleGetDealerList(req) + console.log('data', data) + let res = data.Data.List + setSelectPersonList(res) + return res + }} + rules={[ + { required: true, message: "请选择处理人" } + ]} + fieldProps={{ + fieldNames: { + "label": "STAFF_NAME", + "value": "STAFF_ID" + } + }} + disabled={formRes.errorStatus > 0} + /> + + + + 0} + /> + + + + : "" + } + { + showError && formRes && formRes.errorStatus >= 1 ? + { + console.log('formRes', formRes); + let list: any = [] + if (formRes.feedbackImgList && formRes.feedbackImgList.length > 0) { + formRes.feedbackImgList.forEach((item: string, index: number) => { + list.push({ + uid: '', + name: `image${index}.png`, + status: 'done', + url: item, + }) + }) + } + setFileList(list) + return { + ...formRes, + } + }} + > + + + 1} + fieldProps={{ + customRequest: async (info: any) => { + console.log('info', info); + const formData = new FormData(); + formData.append('file', info.file, typeof info.file !== 'string' ? info.file?.name : ''); + const data = await handleUploadFile(formData) + console.log('data', data); + let url = `https://es.robot-z.cn/${data.data.path}` + let file = JSON.parse(JSON.stringify(fileList)) + file.push({ + uid: '', + name: `${data.data.filename}.png`, + status: 'done', + url: url, + }) + setFileList(file) + }, + onChange: (info: any) => { + if (info.file.status === 'removed') { + console.log('info', info); + setFileList(info.fileList) + } + } + }} + /> + + + + + 1} + /> + + + : "" + } + { {/* 移除打印设置弹窗 */} -
+ ) } diff --git a/src/pages/examine/record/index.tsx b/src/pages/examine/record/index.tsx index 88f0057..02a9bda 100644 --- a/src/pages/examine/record/index.tsx +++ b/src/pages/examine/record/index.tsx @@ -2,7 +2,7 @@ import { ConnectState } from "@/models/global"; import { ActionType, FormInstance, ProTable } from "@ant-design/pro-components"; import { useRef, useState } from "react"; import { connect } from "umi"; -import { handleDeleteRecord, handleGetRecordList } from "./service"; +import { handleDeleteRecord, handleGetRecordList, handleUpdateExtend } from "./service"; import moment from "moment"; import { Button, Drawer, Image, message, Popconfirm, Space } from "antd"; import { handleGetServerpartDDL } from "@/components/leftSelectTree/service"; @@ -13,6 +13,7 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { const actionRef = useRef(); const formRef = useRef(); + const recordDetailRef = useRef() // 显示的附件数据 const [showImgList, setShowImgList] = useState([]) // 预览图片 @@ -23,6 +24,8 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { const [currentRow, setCurrentRow] = useState() // 显示详情抽屉 const [showDetail, setShowDetail] = useState(false) + // 判断是否点了出现的是异常处理的抽屉 + const [showAbnormal, setShowAbnormal] = useState(false) const columns: any = [ { @@ -58,6 +61,17 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { return data } }, + + { + title: "巡查类型", + dataIndex: "inspectionType", + hideInTable: true, + valueType: "select", + valueEnum: { + "1": '异常', + "0": "正常" + } + }, { title:
服务区名称
, dataIndex: "serverPartName", @@ -78,6 +92,18 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { return record?.template.title ? record?.template.title : "-" } }, + { + title:
巡查类型
, + dataIndex: "placeName", + hideInSearch: true, + width: 100, + align: 'center', + ellipsis: true, + render: (_, record) => { + let res: any = record.extend ? JSON.parse(record.extend) : "-" + return {res.situation === 1 ? '异常' : res.situation === 0 ? '正常' : ''} + } + }, { title:
巡查内容
, dataIndex: "uploadResult", @@ -130,6 +156,26 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { ellipsis: true, align: 'center', }, + { + title:
处理状态
, + dataIndex: "errorStatus", + hideInSearch: true, + width: 100, + ellipsis: true, + align: 'center', + render: (_, record) => { + let res: any = record.extend ? JSON.parse(record.extend) : "-" + return { + res.errorStatus === 0 + ? "待处理" + : res.errorStatus === 1 + ? "处理中" + : res.errorStatus === 2 + ? "已处理" + : "-" + } + } + }, { title:
现场图片
, dataIndex: "placeName", @@ -153,15 +199,33 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { align: 'center', fixed: "right", hideInSearch: true, - width: 100, + width: 150, render: (_: any, record: any) => { + let res: any = record.extend ? JSON.parse(record.extend) : "-" + return - { - setCurrentRow(record) + { + res.situation === 1 ? + { + setCurrentRow({ + ...record, + ...res + }) + setShowAbnormal(true) + setShowDetail(true) + } + }>异常处理 : "" + } + < a onClick={() => { + setCurrentRow({ + ...record, + ...res + }) setShowDetail(true) }}> 详情 - + { @@ -171,7 +235,7 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { 删除 - + } } ] @@ -211,7 +275,12 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { const req: any = { startTime: params?.startTime ? `${params?.startTime}T00:00:00` : "", endTime: params?.endTime ? `${params?.endTime}T23:59:59` : "", - serverPartId: params?.serverPartId ? params?.serverPartId : "" + serverPartId: params?.serverPartId ? params?.serverPartId : undefined, + extend: params?.inspectionType ? [{ + key: "situation", + value: params?.inspectionType + }] : undefined + } console.log('req', req); const data = await handleGetRecordList(req) @@ -258,12 +327,92 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { closeIcon={false} onClose={() => { setShowDetail(false) + setShowAbnormal(false) }} open={showDetail} destroyOnClose width={'60%'} + footer={showAbnormal && currentRow?.errorStatus !== 2 ?
+ +
: false} > - + ) diff --git a/src/pages/examine/record/service.ts b/src/pages/examine/record/service.ts index 38e6d35..2000d4b 100644 --- a/src/pages/examine/record/service.ts +++ b/src/pages/examine/record/service.ts @@ -1,8 +1,9 @@ import request from "@/utils/request" +import requestMap from '@/utils/requestMap' // 拿到记录 export async function handleGetRecordList(params?: any) { - const data = await request.post('/questionnaire-templates/search/many', params) + const data = await request.post('/questionnaire-responses/search/many', params) if (data.code === 200) { return data.data } @@ -17,5 +18,23 @@ export async function handleDeleteRecord(params?: any) { } +// 拿到处理人列表 +export async function handleGetDealerList(params?: any) { + const data = await requestMap.get(`handler_ajax.ashx?SERVERPART_ID=${params?.SERVERPART_ID}&PROVINCE_CODE=${params?.PROVINCE_CODE}&action_type=GetDealerList`) + return data +} + +// 删除记录 +export async function handleUpdateExtend(id: any, params?: any) { + const data = await request.post(`questionnaire-responses/${id}/extend`, params) + return data +} + + +// 上传图片 +export async function handleUploadFile(params?: any) { + const data = await request.post(`/oss/upload`, params) + return data +} diff --git a/src/utils/requestMap.ts b/src/utils/requestMap.ts new file mode 100644 index 0000000..de3db4e --- /dev/null +++ b/src/utils/requestMap.ts @@ -0,0 +1,158 @@ +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://mp.eshangtech.com/Coop.Merchant/Handler/' }); + + + +instance.interceptors.request.use( + (config) => { + // 对data数据进行加密 + // if (config.data) { + // config.data = preprocessData(JSON.stringify(config.data)); // 调用预处理函数 + // } + console.log('config', config); + + const isUpload = config.url?.includes("/oss/upload"); + + config.headers = { + ...config.headers, + Authorization: `Bearer ${localStorage.getItem('Authorization') || ''}`, + "Content-Type": "text/plain; charset=utf-8", + } as AxiosRequestHeaders; + + return config; + }, + (error) => Promise.reject(error), +); + +instance.interceptors.response.use( + //状态码为2xx的时候执行 + (response) => { + const { data } = response; + + if (data.code !== 200) { + // 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({ + 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;