diff --git a/jjb.config.js b/jjb.config.js index 5336dea..df4cc10 100644 --- a/jjb.config.js +++ b/jjb.config.js @@ -12,9 +12,9 @@ module.exports = { // 可通过环境变量覆盖: SAFETY_EVAL_API_HOST=http://192.168.x.x:8095 //API_HOST: "http://localhost:80", - // API_HOST: "http://192.168.0.134", + API_HOST: "http://192.168.0.134", // API_HOST: "http://192.168.0.150", //太浅 - API_HOST: "https://gbs-gateway.qhdsafety.com", + // API_HOST: "https://gbs-gateway.qhdsafety.com", // API_HOST: "http://192.168.0.103", //huwei }, production: { diff --git a/src/components/AttachmentUpload/index.js b/src/components/AttachmentUpload/index.js index 1af5035..397d81c 100644 --- a/src/components/AttachmentUpload/index.js +++ b/src/components/AttachmentUpload/index.js @@ -1,11 +1,61 @@ import { Form, Image, Upload, message } from "antd"; -import { useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { PlusOutlined } from "@ant-design/icons"; + +/** 批量上传接口:一次请求上传 1~N 个文件,表单字段名为 files */ +const BATCH_UPLOAD_ACTION = `${window.process.env.app.API_HOST}/safetyEval/file/upload/batch`; + const isImage = (url) => /\.(png|jpe?g|gif|bmp|webp|svg)(\?.*)?$/i.test(url || ""); export default function AttachmentUpload({ name, label, disabled, maxCount, accept, extra ,rules, style, keepOriginFile }) { const [previewImage, setPreviewImage] = useState(""); + // 同一次选择的文件先入队,等微任务结束后合并为一个批量请求 + const queueRef = useRef([]); + const timerRef = useRef(null); + + const flushUpload = () => { + timerRef.current = null; + const batch = queueRef.current.splice(0); + if (!batch.length) return; + const failAll = (msg) => { + message.error(msg); + batch.forEach(({ file, onError }) => onError(new Error(msg))); + }; + const formData = new FormData(); + batch.forEach(({ file }) => formData.append("files", file)); + fetch(BATCH_UPLOAD_ACTION, { + method: "POST", + headers: { token: sessionStorage.getItem("token") || "" }, + body: formData, + }) + .then((res) => res.json()) + .then((json) => { + if (json?.success === false) { + failAll(json.errMessage || json.message || "附件上传失败"); + return; + } + const list = json?.data || []; + // 后端保证响应数组与请求文件顺序一致,按下标一一对应 + batch.forEach(({ file, onDone, onError }, index) => { + const item = list[index]; + if (!item) { + onError(new Error(`${file.name} 上传失败`)); + return; + } + // 保留 { data } 结构,兼容表单取值 file.response?.data?.url + onDone({ data: item }, file); + }); + }) + .catch((err) => failAll(err?.message || "附件上传失败")); + }; + + useEffect(() => () => clearTimeout(timerRef.current), []); + + const customRequest = ({ file, onSuccess: onDone, onError }) => { + queueRef.current.push({ file, onDone, onError }); + if (!timerRef.current) timerRef.current = setTimeout(flushUpload, 0); + }; return ( <> @@ -55,12 +105,11 @@ export default function AttachmentUpload({ name, label, disabled, maxCount, acce 1} + customRequest={customRequest} maxCount={maxCount} accept={accept} - action={`${window.process.env.app.API_HOST}/safetyEval/file/upload`} beforeUpload={(file) => { if (!accept) return true; const rules = accept.split(",").map((e) => e.trim().toLowerCase()); diff --git a/src/pages/Container/SafetyEvalBusiness/EvalProject/Create/index.js b/src/pages/Container/SafetyEvalBusiness/EvalProject/Create/index.js index cdd08fe..16186e8 100644 --- a/src/pages/Container/SafetyEvalBusiness/EvalProject/Create/index.js +++ b/src/pages/Container/SafetyEvalBusiness/EvalProject/Create/index.js @@ -21,6 +21,7 @@ import { Connect } from "@cqsjjb/jjb-dva-runtime"; import useIndustryOptions from "~/hooks/useIndustryOptions"; import BaiduMapPicker from "~/components/BaiduMapPicker"; import { district } from "~/enumerate/constant"; +import {REGISTER_ENGINEER_CATEGORY_OPTIONS} from '~/enumerate/enterpriseOptions'; import { phoneRule } from "~/utils/validators"; import { renderCapabilityList } from "~/utils"; import StaffPickerModal from "./StaffPickerModal"; @@ -52,6 +53,9 @@ const EvalProjectCreate = (props) => { } = props.safetyEvalBusiness; const industryOptions = useIndustryOptions(); + // 是否法定项目选“否”(仅机构内部管理)时,行业类型默认全选;编辑/查看模式不联动,避免覆盖回填数据 + const isStatutory = Form.useWatch("isStatutory", form); + useEffect(() => { props.customerPage({ current: 1, size: 999 }); @@ -326,11 +330,25 @@ const EvalProjectCreate = (props) => { + + + { + form.setFieldValue('industryCode', '') + }}> + 是,纳入监管端监管 + 否,仅机构内部管理 + + + ({ value: value ? String(value).split(",") : [], })} @@ -342,20 +360,13 @@ const EvalProjectCreate = (props) => { mode="multiple" placeholder="请选择" allowClear - options={industryOptions} + options={isStatutory?industryOptions:REGISTER_ENGINEER_CATEGORY_OPTIONS} /> - - - 是,纳入监管端监管 - 否,仅机构内部管理 - + + diff --git a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/RiskAnalysisContent.js b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/RiskAnalysisContent.js index bdf6bb1..77b76a2 100644 --- a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/RiskAnalysisContent.js +++ b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/RiskAnalysisContent.js @@ -32,7 +32,7 @@ const { router } = tools; const { TextArea } = Input; /** 风险分析记录表 docx 模板 */ -const RISK_TEMPLATE_URL = "https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a86d268e4b072649bfb8a84.docx"; +const RISK_TEMPLATE_URL = "https://gbs-cqaqpj.oss-cn-beijing.aliyuncs.com/jjb/6a8ffce69f4622759bcd7ba3.docx"; /** 两选项单选回显:1 勾选前者,2 勾选后者 */ const twoCheck = (val, yes, no) => @@ -233,6 +233,7 @@ const RiskAnalysisContent = ({ readOnly, ...props }) => { RISK_LEVEL_CHECK[values.riskLevelCode] || "□ 低度 □ 中度 □ 高度", signContractCheck: twoCheck(values.signContractCode, "签合同", "不签合同"), participantsText: signTokens.join(""), + controlledNumber: evalProjectDetailData.controlledNumber, }; try { await fillDocxTemplate(