diff --git a/config/config.ts b/config/config.ts index 6e067ab..ea63754 100644 --- a/config/config.ts +++ b/config/config.ts @@ -9,9 +9,15 @@ export default { ], proxy, dva: {}, - title: 'UMI4 Admin', + base: '/cloudNew/', + publicPath: '/cloudNew/', + outputPath: 'dist', // 打包输出目录,默认是dist + title: '驿商云平台', favicons: [ - '/favicon.svg' + '/favicon.ico' ], - routes: router + routes: router, + history: { + type: 'browser' // 使用browser history模式,配合IIS的URL重写规则 + } }; diff --git a/config/router.ts b/config/router.ts index 1f28796..fb1c12c 100644 --- a/config/router.ts +++ b/config/router.ts @@ -37,7 +37,7 @@ export default [ }, { path: '/examine/modal', - name: '考核模版管理', + name: '考核点位管理', component: "@/pages/examine/modal/index", }, { diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..afceb92 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/favicon.svg b/public/favicon.svg index e7f6c1b..afceb92 100644 Binary files a/public/favicon.svg and b/public/favicon.svg differ diff --git a/public/web.config b/public/web.config new file mode 100644 index 0000000..c7ecc11 --- /dev/null +++ b/public/web.config @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 914fa92..adcc110 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -191,7 +191,7 @@ const BasicLayout: FC<{ user: UserModelState, global: ProfileModelState, dispatc SYSTEMMODULE_DESC: "", guid: "4", hideInMenu: false, - name: "考核模版管理", + name: "考核点位管理", path: "/examine/modal", }, { diff --git a/src/models/user.ts b/src/models/user.ts index 68e1937..f84269d 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -211,39 +211,42 @@ const UserModel: UserModelType = { console.log('userInfoRes', userInfoRes); - menuRes.data = [{ - path: '/standard/index', - redirect: '', - name: '生成标准页面', - component: "@/pages/standard/index", - }, { - path: '/examine', - redirect: '', - name: '走动式管理', - children: [ - { - path: '/examine/index', - name: '考评分类管理', - component: "@/pages/examine/index", - }, - { - path: '/examine/question', - name: '考核问题管理', - component: "@/pages/examine/question", - }, - { - path: '/examine/modal', - name: '考核模版管理', - component: "@/pages/examine/modal", - }, - { - path: '/examine/record', - name: '考核记录管理', - component: "@/pages/examine/record", - } - ] + menuRes.data = [ + { + path: '/standard/index', + redirect: '', + name: '生成标准页面', + component: "@/pages/standard/index", + }, + { + path: '/examine', + redirect: '', + name: '走动式管理', + children: [ + { + path: '/examine/index', + name: '考评分类管理', + component: "@/pages/examine/index", + }, + { + path: '/examine/question', + name: '考核问题管理', + component: "@/pages/examine/question", + }, + { + path: '/examine/modal', + name: '考核模版管理', + component: "@/pages/examine/modal", + }, + { + path: '/examine/record', + name: '考核记录管理', + component: "@/pages/examine/record", + } + ] - },] + }, + ] let indexAllMenuItemByPath: any = [] let indexValidMenuItemByPath: any = [] if (menuRes.data && menuRes.data.length > 0) { @@ -254,7 +257,7 @@ const UserModel: UserModelType = { //在登录完获取菜单数据之后做是否需要重定向的操作 yield call( handleRedirect, - window.location.pathname === '/user/login', + window.location.pathname === '/cloudNew/user/login', indexAllMenuItemByPath, indexValidMenuItemByPath, ); @@ -307,7 +310,19 @@ const UserModel: UserModelType = { //当前页面不是登录页时,才进行重定向 if (window.location.pathname !== '/user/login') { - const redirectValue = `${window.location.pathname}${window.location.search}`; + // 只获取路径部分,不包含查询参数,避免redirect参数累积 + let redirectValue = window.location.pathname; + + // 检查是否有base路径重复问题 + if (redirectValue.startsWith('/') && redirectValue.indexOf('/', 1) !== -1) { + const firstSlashAfterRoot = redirectValue.indexOf('/', 1); + const possiblePrefix = redirectValue.substring(0, firstSlashAfterRoot); + // 检查是否有重复的路径前缀 + if (redirectValue.indexOf(possiblePrefix, firstSlashAfterRoot) === firstSlashAfterRoot) { + redirectValue = redirectValue.substring(firstSlashAfterRoot); + } + } + history.push(`/user/login?redirect=${encodeURIComponent(redirectValue)}`); } }, diff --git a/src/pages/examine/index/index.tsx b/src/pages/examine/index/index.tsx index 37a6968..54536e0 100644 --- a/src/pages/examine/index/index.tsx +++ b/src/pages/examine/index/index.tsx @@ -22,6 +22,9 @@ const examineIndex: React.FC<{ currentUser: any }> = (props) => { const [openAddModal, setOpenAddModal] = useState(false) // 当前行数据 const [currentRow, setCurrentRow] = useState() + const [columnsStateMap, setColumnsStateMap] = useState({ + operator: { show: false } + }) const columns: any = [ { @@ -73,10 +76,22 @@ const examineIndex: React.FC<{ currentUser: any }> = (props) => { return record?.updatedAt ? moment(record?.updatedAt).format('YYYY-MM-DD HH:mm:ss') : '-' } }, + { + title: "操作人", + dataIndex: "operator", + ellipsis: true, + align: 'center', + width: 200, + hideInSearch: true, + render: (_: any, record: { status: any; }) => { + return record?.operator ? record?.operator : '-' + } + }, { title: '操作', dataIndex: 'option', align: 'center', + fixed: "right", hideInSearch: true, width: 150, render: (_: any, record: any) => { @@ -144,7 +159,7 @@ const examineIndex: React.FC<{ currentUser: any }> = (props) => { rowKey={(record) => { return `${record?.id}` }} - scroll={{ y: 'calc(100vh - 400px)' }} + scroll={{ x: "100%", y: 'calc(100vh - 400px)' }} headerTitle={考评分类管理} search={{ span: 6 }} request={async (params) => { @@ -167,6 +182,10 @@ const examineIndex: React.FC<{ currentUser: any }> = (props) => { ] }} + columnsState={{ + value: columnsStateMap, + onChange: setColumnsStateMap, + }} /> diff --git a/src/pages/examine/index/service.ts b/src/pages/examine/index/service.ts index 1634c41..d0166ab 100644 --- a/src/pages/examine/index/service.ts +++ b/src/pages/examine/index/service.ts @@ -2,7 +2,7 @@ import request from "@/utils/request" // 拿到类别列表接口 export async function handleGetExamineTypeList(params?: any) { - const data = await request.get('/question-categories', params) + const data = await request.get('/question-categories', {params}) if (data.code === 200) { return data.data } diff --git a/src/pages/examine/modal/index.tsx b/src/pages/examine/modal/index.tsx index c440b64..860764e 100644 --- a/src/pages/examine/modal/index.tsx +++ b/src/pages/examine/modal/index.tsx @@ -1,7 +1,7 @@ import LeftSelectTree from "@/components/leftSelectTree/leftSelectTree"; import { handleGetServerpartDDL } from "@/components/leftSelectTree/service"; import { ActionType, FormInstance, ProCard, ProForm, ProFormList, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextArea, ProTable } from "@ant-design/pro-components"; -import { Button, Col, message, Modal, Popconfirm, Row, Space } from "antd"; +import { Button, Col, message, Modal, Popconfirm, Row, Space, Image } from "antd"; import moment from "moment"; import { useRef, useState } from "react"; import { connect } from "umi"; @@ -10,6 +10,7 @@ import { handleGetExamineTypeTreeList } from "../index/service"; import QRCode from 'qrcode'; import { base64ToFile } from "@/utils/publicMethods"; + const examineModal: React.FC<{ currentUser: any }> = (props) => { const { currentUser } = props @@ -41,13 +42,24 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { // 选择的问题列表的id const [selectedQuestionId, setSelectedQuestionId] = useState() + // 显示的附件数据 + const [showImgList, setShowImgList] = useState([]) + // 预览图片 + const [imagePreviewVisible, setImagePreviewVisible] = useState(false) + // 预览的索引 + const [previewIndex, setPreviewIndex] = useState(0) + const [columnsStateMap, setColumnsStateMap] = useState({ + updatedAt: { show: false }, + createdAt: { show: false }, + operator: { show: false }, + }) const columns: any = [ { title:
服务区名称
, dataIndex: "serverPartName", hideInSearch: true, - width: 200, + width: 150, ellipsis: true }, { @@ -57,6 +69,43 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { width: 200, ellipsis: true }, + { + title:
问题列表
, + dataIndex: "questions", + hideInSearch: true, + width: 400, + ellipsis: true, + render: (_, record) => { + let questionStr: string = "" + if (record?.questionnaireTemplateQuestions && record?.questionnaireTemplateQuestions.length > 0) { + record?.questionnaireTemplateQuestions.forEach((item: any, index: number) => { + let options: string = '' + if (item.question.options && item.question.options.length > 0) { + item.question.options.forEach((subItem: any, subIndex: number) => { + options += `${subIndex > 0 ? ',' : ''}选项${subIndex + 1}:${subItem.text}` + }) + } + questionStr += `${index > 0 ? ',' : ''}问题${index + 1}:${item.question.title},${options}` + }) + } + return questionStr || '' + // return record?.questions && record?.questions.length > 0 ? JSON.stringify(record?.questions) : '' + } + }, + { + title:
站点二维码
, + dataIndex: "qrUrl", + hideInSearch: true, + align: 'center', + width: 150, + ellipsis: true, + render: (_, record) => { + return record?.qrUrl ? : "-" + } + }, { title:
有效状态
, dataIndex: "status", @@ -68,6 +117,13 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { return record?.status ? '有效' : '无效' } }, + { + title:
备注说明
, + dataIndex: "description", + hideInSearch: true, + width: 200, + ellipsis: true + }, { title:
更新时间
, dataIndex: "updatedAt", @@ -80,28 +136,31 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { } }, { - title:
备注说明
, - dataIndex: "description", + title:
创建时间
, + dataIndex: "createdAt", hideInSearch: true, - width: 200, - ellipsis: true - }, - { - title:
问题列表
, - dataIndex: "questions", - hideInSearch: true, - width: 200, + align: 'center', + width: 150, ellipsis: true, render: (_, record) => { - return record?.questions && record?.questions.length > 0 ? JSON.stringify(record?.questions) : '' + return record?.createdAt ? moment(record?.createdAt).format('YYYY-MM-DD HH:mm:ss') : '' } }, + { + title:
操作人
, + dataIndex: "operator", + hideInSearch: true, + align: 'center', + width: 100, + ellipsis: true, + }, { title: '操作', dataIndex: 'option', align: 'center', hideInSearch: true, - width: 150, + fixed: "right", + width: 100, render: (_: any, record: any) => { return { @@ -165,7 +224,14 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { ellipsis: true, hideInSearch: true, render: (_, record) => { - return record?.options && record?.options.length > 0 ? JSON.stringify(record?.options) : "" + let str: string = '' + if (record.options && record?.options.length > 0) { + record.options.forEach((item: any, index: number) => { + str += `${index > 0 ? ',' : ''}选项${index + 1}:${item.text}` + }) + } + return str || '' + // return record?.options && record?.options.length > 0 ? JSON.stringify(record?.options) : "" } } ] @@ -198,6 +264,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { expandable={{ expandRowByClick: true }} + scroll={{ x: "100%", y: 'calc(100vh - 400px)' }} headerTitle={走动式点位管理} search={{ span: 6 }} request={async () => { @@ -219,9 +286,36 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { ] }} + columnsState={{ + value: columnsStateMap, + onChange: setColumnsStateMap, + }} > + { + showImgList && showImgList.length > 0 &&
+ + { + setImagePreviewVisible(vis) + }, + current: previewIndex + }}> + { + showImgList.map((n) => + + ) + } + + + +
+ } + = (props) => { destroyOnClose onOk={() => { modalRef.current?.validateFields().then(async (res) => { - console.log('res', res); console.log('currentRow', currentRow); - let req = {} let data = {} if (currentRow?.id) { @@ -326,11 +418,11 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { } console.log('datadsadsa', data); if (data.code === 200) { - // modalRef.current?.resetFields() + modalRef.current?.resetFields() message.success(data.message) - // setShowPlaceModal(false) + setShowPlaceModal(false) actionRef.current?.reload() - // setCurrentRow(undefined) + setCurrentRow(undefined) } else { message.error(data.message) } @@ -356,8 +448,17 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { console.log('2'); 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}` + }) + } + obj.text = obj.title obj.mark = JSON.stringify(obj.options) + obj.showText = str keyList.push(obj.id) questionsList.push(obj) } @@ -454,7 +555,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { @@ -502,7 +603,13 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => { let showQuestion: any = [] if (selectedQuestionDetail && selectedQuestionDetail.length > 0) { selectedQuestionDetail.forEach((item) => { - showQuestion.push({ text: item.title, mark: item.options ? JSON.stringify(item.options) : "" }) + let str: string = '' + if (item.options && item?.options.length > 0) { + item.options.forEach((item: any, index: number) => { + str += `${index > 0 ? ',' : ''}选项${index + 1}:${item.text}` + }) + } + showQuestion.push({ text: item.title, showText: str, mark: item.options ? JSON.stringify(item.options) : "" }) }) } modalRef.current?.setFieldsValue({ diff --git a/src/pages/examine/modal/service.ts b/src/pages/examine/modal/service.ts index 5f56f1c..4a96f92 100644 --- a/src/pages/examine/modal/service.ts +++ b/src/pages/examine/modal/service.ts @@ -4,7 +4,7 @@ import request from "@/utils/request" // 拿到模版id列表 去绑定服务区的多个站点信息 的列表接口 export async function handleGetTemplatesList(params?: any) { - const data = await request.get('/questionnaire-templates', params) + const data = await request.get('/questionnaire-templates', {params}) if (data.code === 200) { return data.data } diff --git a/src/pages/examine/question/index.tsx b/src/pages/examine/question/index.tsx index 29319b6..53c5487 100644 --- a/src/pages/examine/question/index.tsx +++ b/src/pages/examine/question/index.tsx @@ -20,12 +20,17 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { const modalRef = useRef() // 问题分类的枚举 const [categoryIdObj, setCategoryIdObj] = useState() + const [columnsStateMap, setColumnsStateMap] = useState({ + createdAt: { show: false } + }) + + const columns: any = [ { title:
问题分类
, dataIndex: "description", - width: 200, + width: 150, hideInSearch: true, ellipsis: true }, @@ -39,8 +44,9 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { { title:
问题类型
, dataIndex: "type", - width: 200, + width: 100, hideInSearch: true, + align: 'center', ellipsis: true, render: (_, record) => { let questionType: string = record?.type && record?.type.split('_') && record?.type.split('_').length > 0 ? record?.type.split('_')[0] : '' @@ -52,6 +58,7 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { dataIndex: "required", width: 100, hideInSearch: true, + align: 'center', ellipsis: true, render: (_, record) => { return record?.required ? '是' : "否" @@ -60,27 +67,46 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { { title:
选项内容
, dataIndex: "options", - width: 150, + width: 300, hideInSearch: true, ellipsis: true, render: (_, record) => { - return record?.options && record?.options.length > 0 ? JSON.stringify(record?.options) : '' + let str: string = '' + if (record.options && record?.options.length > 0) { + record.options.forEach((item: any, index: number) => { + str += `${index > 0 ? ',' : ''}选项${index + 1}:${item.text}` + }) + } + return str || '' } }, { title:
更新时间
, dataIndex: "updatedAt", width: 150, + align: 'center', hideInSearch: true, ellipsis: true, render: (_, record) => { return record?.updatedAt ? moment(record?.updatedAt).format('YYYY-MM-DD HH:mm:ss') : '' } }, + { + title:
创建时间
, + dataIndex: "createdAt", + width: 150, + align: 'center', + hideInSearch: true, + ellipsis: true, + render: (_, record) => { + return record?.createdAt ? moment(record?.createdAt).format('YYYY-MM-DD HH:mm:ss') : '' + } + }, { title:
操作人
, dataIndex: "operator", - width: 150, + width: 100, + align: 'center', hideInSearch: true, ellipsis: true }, @@ -88,8 +114,9 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { title: '操作', dataIndex: 'option', align: 'center', + fixed: "right", hideInSearch: true, - width: 150, + width: 100, render: (_: any, record: any) => { return
{ @@ -138,6 +165,7 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { }} headerTitle={考核问题管理} search={{ span: 6 }} + scroll={{ x: "100%", y: 'calc(100vh - 400px)' }} request={async (params) => { const data = await handleGetQuestionList() console.log('data', data); @@ -156,6 +184,10 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => { ] }} + columnsState={{ + value: columnsStateMap, + onChange: setColumnsStateMap, + }} /> diff --git a/src/pages/examine/question/service.ts b/src/pages/examine/question/service.ts index b8d91e7..8084414 100644 --- a/src/pages/examine/question/service.ts +++ b/src/pages/examine/question/service.ts @@ -2,7 +2,7 @@ import request from "@/utils/request" // 拿到问题列表接口 export async function handleGetQuestionList(params?: any) { - const data = await request.get('/questions', params) + const data = await request.get('/questions', {params}) if (data.code === 200) { return data.data } diff --git a/src/pages/examine/record/components/recordDetail.tsx b/src/pages/examine/record/components/recordDetail.tsx new file mode 100644 index 0000000..b2c3612 --- /dev/null +++ b/src/pages/examine/record/components/recordDetail.tsx @@ -0,0 +1,208 @@ +import { ConnectState } from "@/models/global"; +import { ActionType, ProTable } from "@ant-design/pro-components"; +import ProForm, { FormInstance, ProFormList, ProFormText } from "@ant-design/pro-form"; +import { Col, Row, Image, Button } from "antd"; +import moment from "moment"; +import { useEffect, useRef, useState } from "react"; +import { connect } from "umi"; +import { handleGetExamineTypeTreeList } from "../../index/service"; +import session from "@/utils/session"; + + +type DetailProps = { + parentRow: any; // 父级数据 + show: boolean;// 抽屉是否显示 +} +const RecordDetail = ({ parentRow, show }: DetailProps) => { + + const formRef = useRef(); + + const actionRef = useRef(); + const tableFormRef = useRef(); + + const [formRes, setFormRes] = useState() + + useEffect(() => { + if (show) { + console.log('parentRow', parentRow); + let extendObj = {} + if (parentRow?.extend) { + extendObj = JSON.parse(parentRow?.extend) + } + let obj = { + ...parentRow, + ...extendObj, + placeName: parentRow.template.title, + submittedAt: moment(parentRow?.submittedAt).format('YYYY-MM-DD HH:mm:ss') + } + setFormRes(obj) + formRef.current?.setFieldsValue(obj) + } + }, [show]) + + return ( +
+ + + + + + + + + + + + + + + + + + + ( +
+
{listDom}
+
{action}
+
+ )} + > +
+ { + formRes?.imgsList && formRes?.imgsList.length > 0 ? + formRes?.imgsList.map((item: string) => { + return + }) + : '' + } +
+
+ +
+
+ + { + }}> + 打印 + + ] + }} + options={false} + request={async () => { + let res = parentRow?.questionResponses || [] + console.log('res', res); + + + let typeData = await handleGetExamineTypeTreeList({}) + console.log('typeData', typeData); + if (typeData && typeData.length > 0) { + typeData.forEach((item: any) => { + if (item.children && item.children.length > 0) { + item.children.forEach((subItem: any) => { + + }) + } + }) + } + + + + // let categoriesObj: any = {} // 子父级关系的缓存对象 + // let categoriesTypeObj: any = {} // 类型的对象 + + // let categoriesIdObj = session.get('categoriesIdObj') + // let categoriesTypeSessionObj = session.get('categoriesTypeObj') + + // if (categoriesIdObj) { + // categoriesObj = categoriesIdObj + // categoriesTypeObj = categoriesTypeSessionObj + // } else { + // let typeData = await handleGetExamineTypeTreeList({}) + // // 走动式的大类包括小类的缓存 categoriesIdObj + // if (typeData && typeData.length > 0) { + // typeData.forEach((item: any) => { + // let list: any = [] + // categoriesTypeObj[item.id] = item.name + // if (item.children && item.children.length > 0) { + // item.children.forEach((subItem: any) => { + // list.push(subItem.id) + // categoriesTypeObj[subItem.id] = item.name + // }) + // } + // categoriesObj[item.id] = list + // }) + // } + + // session.set('categoriesIdObj', categoriesObj) + // session.set('categoriesTypeObj', categoriesTypeObj) + // } + + // console.log('categoriesObj', categoriesObj); + // console.log('categoriesTypeObj', categoriesTypeObj); + + // let res = parentRow?.questionResponses || [] + // // 在res的数组里面拿到最大一个类型的数据 + // if (res && res.length > 0) { + // res.forEach((item: any) => { + // for (let key in categoriesObj) { + // let list = categoriesObj[key] + // if (list && list.length > 0) { + // if (list.indexOf(Number(item.question.categoryId)) !== -1) { + // item.parentCategoryId = key + // } + // } + // } + + // }) + // } + // console.log('table', res); + + }} + /> + +
+ ) +} + + +export default connect(({ user }: ConnectState) => ({ + currentUser: user.data +}))(RecordDetail); diff --git a/src/pages/examine/record/index.tsx b/src/pages/examine/record/index.tsx index 73fa8c5..4e4115a 100644 --- a/src/pages/examine/record/index.tsx +++ b/src/pages/examine/record/index.tsx @@ -2,9 +2,11 @@ import { ConnectState } from "@/models/global"; import { ActionType, FormInstance, ProTable } from "@ant-design/pro-components"; import { useRef, useState } from "react"; import { connect } from "umi"; -import { handleGetRecordList } from "./service"; +import { handleDeleteRecord, handleGetRecordList } from "./service"; import moment from "moment"; -import { Button, Image } from "antd"; +import { Button, Drawer, Image, message, Popconfirm, Space } from "antd"; +import { handleGetServerpartDDL } from "@/components/leftSelectTree/service"; +import RecordDetail from "./components/recordDetail"; const examineRecord: React.FC<{ currentUser: any }> = (props) => { const { currentUser } = props @@ -17,8 +19,45 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { const [imagePreviewVisible, setImagePreviewVisible] = useState(false) // 预览的索引 const [previewIndex, setPreviewIndex] = useState(0) + // 当行数据 + const [currentRow, setCurrentRow] = useState() + // 显示详情抽屉 + const [showDetail, setShowDetail] = useState(false) const columns: any = [ + { + title: "统计日期", + dataIndex: "staticDate", + hideInTable: true, + valueType: "date", + initialValue: [moment().format('YYYY-MM-DD')], + search: { + transform: (value: any) => { + return { + startTime: value, + endTime: value + }; + }, + }, + fieldProps: { + picker: "day", + format: 'YYYY-MM-DD', + } + }, + { + title: "服务区", + dataIndex: "serverPartId", + hideInTable: true, + valueType: "select", + request: async () => { + const req = { + ProvinceCode: currentUser?.provinceCode, + StatisticsType: 1000 + } + const data = await handleGetServerpartDDL(req) + return data + } + }, { title:
服务区名称
, dataIndex: "serverPartName", @@ -57,13 +96,19 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { width: 350, ellipsis: true, render: (_, record) => { - let obj: any = {} + let str: string = '' if (record?.questionResponses && record?.questionResponses.length > 0) { - record?.questionResponses.forEach((item) => { - obj[item.question.title] = JSON.stringify(item.choiceResponse) + record?.questionResponses.forEach((item: any, index: number) => { + let anwers: string = '' + if (item.choiceResponse && item.choiceResponse.length > 0) { + item.choiceResponse.forEach((subItem: string, subIndex: number) => { + anwers += `${subIndex > 0 ? ',' : ''}${subItem}` + }) + } + str += `${index > 0 ? ',' : ''}考核内容:${item.question.title},考核结果:${anwers}` }) } - return obj ? JSON.stringify(obj) : "-" + return str || '' } }, { @@ -77,6 +122,14 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { return record?.createdAt ? moment(record?.createdAt).format('YYYY-MM-DD HH:mm:ss') : '-' } }, + { + title:
巡查人
, + dataIndex: "userName", + hideInSearch: true, + width: 100, + ellipsis: true, + align: 'center', + }, { title:
现场图片
, dataIndex: "placeName", @@ -93,9 +146,45 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => { setImagePreviewVisible(true) }}>查看附件 : "-" } + }, + { + title: '操作', + dataIndex: 'option', + align: 'center', + fixed: "right", + hideInSearch: true, + width: 100, + render: (_: any, record: any) => { + return +
{ + setCurrentRow(record) + setShowDetail(true) + }}> + 详情 + + { + deleteRecord(record?.id) + }} + > + 删除 + + +
+ } } ] + // 删除记录 + const deleteRecord = async (id: any) => { + const data = await handleDeleteRecord({ id: id }) + if (data.code === 200) { + message.success(data.message) + actionRef.current?.reload() + } + } + return (
= (props) => { expandable={{ expandRowByClick: true }} + scroll={{ x: "100%", y: 'calc(100vh - 400px)' }} headerTitle={考核记录管理} search={{ span: 6 }} - request={async () => { - const req: any = { + request={async (params) => { + console.log('params', params); + const req: any = { + startTime: params?.startTime ? `${params?.startTime}T00:00:00` : "", + endTime: params?.endTime ? `${params?.endTime}T23:59:59` : "", + serverPartId: params?.serverPartId ? params?.serverPartId : "" } - const data = await handleGetRecordList() + console.log('req', req); + const data = await handleGetRecordList(req) console.log('data', data); if (data && data.length > 0) { @@ -156,6 +251,20 @@ const examineRecord: React.FC<{ currentUser: any }> = (props) => {
} + + + { + setShowDetail(false) + }} + open={showDetail} + destroyOnClose + width={'60%'} + > + +
) } diff --git a/src/pages/examine/record/service.ts b/src/pages/examine/record/service.ts index 4b20aa9..224a8e6 100644 --- a/src/pages/examine/record/service.ts +++ b/src/pages/examine/record/service.ts @@ -1,8 +1,8 @@ import request from "@/utils/request" -// 拿到问题列表接口 +// 拿到记录 export async function handleGetRecordList(params?: any) { - const data = await request.get('/questionnaire-responses', params) + const data = await request.get('/questionnaire-responses', { params }) if (data.code === 200) { return data.data } @@ -10,4 +10,12 @@ export async function handleGetRecordList(params?: any) { } +// 删除记录 +export async function handleDeleteRecord(params?: any) { + const data = await request.get(`/questionnaire-responses/delete/${params.id}`) + return data +} + + + diff --git a/src/services/user.ts b/src/services/user.ts index 7e89907..baa3110 100644 --- a/src/services/user.ts +++ b/src/services/user.ts @@ -33,7 +33,43 @@ export async function retrieveUserAuthority(params: any) { //获取菜单数据 export async function retrieveMenuData(params: any) { const data = await request.get('/menus', params) - return data + // return data + return [ + { + path: '/standard/index', + redirect: '', + name: '生成标准页面', + component: "@/pages/standard/index", + }, + { + path: '/examine', + redirect: '', + name: '走动式管理', + children: [ + { + path: '/examine/index', + name: '考评分类管理', + component: "@/pages/examine/index", + }, + { + path: '/examine/question', + name: '考核问题管理', + component: "@/pages/examine/question", + }, + { + path: '/examine/modal', + name: '考核模版管理', + component: "@/pages/examine/modal", + }, + { + path: '/examine/record', + name: '考核记录管理', + component: "@/pages/examine/record", + } + ] + + }, + ] } // export const retrieveMenuData = (): Promise => ( // request.get('/api/user/menu') diff --git a/src/utils/handleRedirect.ts b/src/utils/handleRedirect.ts index 63827ea..6e2d4f8 100644 --- a/src/utils/handleRedirect.ts +++ b/src/utils/handleRedirect.ts @@ -17,34 +17,62 @@ const handleRedirect = ( indexValidMenuItemByPath: IndexValidMenuItemByPath, ): Promise => ( new Promise((resolve) => { - let routePath = Object.keys(indexValidMenuItemByPath)[0]; - + let routePath = '' + // Object.keys(indexValidMenuItemByPath)[0]; if (isLoginPage) { const queryString = window.location.search; - if (queryString) { const matchedRes = queryString.match(/redirect=(.*)/); - + if (matchedRes) { //还要考虑redirect参数是否有效 - const decodeRedirect = decodeURIComponent(matchedRes[1]); + let decodeRedirect = decodeURIComponent(matchedRes[1]); + if (decodeRedirect.indexOf('/cloudNew') !== -1) { + decodeRedirect = decodeRedirect.split('/cloudNew')[1] + } + + // 处理可能存在的路径问题,确保路径格式正确 + // 移除可能的重复前缀 + if (decodeRedirect.startsWith('/') && decodeRedirect.indexOf('/', 1) !== -1) { + + const firstSlashAfterRoot = decodeRedirect.indexOf('/', 1); + const possiblePrefix = decodeRedirect.substring(0, firstSlashAfterRoot); + // 检查是否有重复的路径前缀 + if (decodeRedirect.indexOf(possiblePrefix, firstSlashAfterRoot) === firstSlashAfterRoot) { + decodeRedirect = decodeRedirect.substring(firstSlashAfterRoot); + } + } + + // 避免重定向到登录页面本身 + if (decodeRedirect === '/user/login' || decodeRedirect.startsWith('/user/login?')) { + // 如果重定向目标是登录页面,则使用默认路由 + routePath = Object.keys(indexValidMenuItemByPath)[0]; + } //有效: 跳转 - if (indexValidMenuItemByPath[decodeRedirect]) { + else if (indexValidMenuItemByPath[decodeRedirect]) { routePath = decodeRedirect; } else if (indexAllMenuItemByPath[decodeRedirect]) { //无效 //有子路由: 跳子路由 routePath = indexAllMenuItemByPath[decodeRedirect].redirect; } else { + //无子路由: 还是要跳, 此时就是交由umi处理404的情况了 - routePath = decodeRedirect; + if (decodeRedirect === '/cloudNew/') { + routePath = '' + } else { + routePath = decodeRedirect; + } } } } } else { - const { + let { location: { search, pathname }, } = window; + if (pathname.indexOf('/cloudNew') !== -1) { + pathname = pathname.split('/cloudNew')[1] + } //考虑url上有查询字符串参数的情况 //有效 diff --git a/src/utils/request.ts b/src/utils/request.ts index c020c8f..8447b35 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -8,7 +8,8 @@ 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: '/auth' }); +// 修改baseURL为完整的API地址,确保在生产环境中正确访问 +const instance = axios.create({ baseURL: 'https://es.robot-z.cn' }); @@ -18,6 +19,7 @@ instance.interceptors.request.use( // if (config.data) { // config.data = preprocessData(JSON.stringify(config.data)); // 调用预处理函数 // } + console.log('config', config); const isUpload = config.url?.includes("/oss/upload"); diff --git a/umi4-admin-main.zip b/umi4-admin-main.zip index 789f25d..b8b1cae 100644 Binary files a/umi4-admin-main.zip and b/umi4-admin-main.zip differ