diff --git a/package.json b/package.json index 4f2fbd9..c4177cf 100644 --- a/package.json +++ b/package.json @@ -25,11 +25,12 @@ "@cqsjjb/jjb-dva-runtime": "latest", "@cqsjjb/jjb-react-admin-component": "latest", "ahooks": "^3.9.5", - "antd": "latest", + "antd": "^5.27.6", "dayjs": "^1.11.7", "lodash-es": "^4.17.21", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-to-print": "^3.2.0", "zy-react-library": "latest" }, "devDependencies": { diff --git a/src/api/commitment/index.js b/src/api/commitment/index.js new file mode 100644 index 0000000..f6f8044 --- /dev/null +++ b/src/api/commitment/index.js @@ -0,0 +1,28 @@ +import { declareRequest } from "@cqsjjb/jjb-dva-runtime"; + +export const busPromiseTemplateList = declareRequest( + "commitmentLoading", + "Post > @/promise/busPromiseTemplate/list", +); +export const busPromiseTemplateAdd = declareRequest( + "commitmentLoading", + "Post > @/promise/busPromiseTemplate/save", +); +export const busPromiseTemplateEdit = declareRequest( + "commitmentLoading", + "Put > @/promise/busPromiseTemplate/edit", +); + +export const busPromiseTemplateView = declareRequest( + "commitmentLoading", + `Get > /promise/busPromiseTemplate/{id}`, +); +export const busPromiseTemplateDelete = declareRequest( + "commitmentLoading", + `Delete > @/promise/busPromiseTemplate/{id}`, +); + +export const busPromiseTemplateUpdate = declareRequest( + "commitmentLoading", + `Put > @/promise/busPromiseTemplate/updateStatus`, +); diff --git a/src/enumerate/namespace/index.js b/src/enumerate/namespace/index.js index b392d90..4c60ffa 100644 --- a/src/enumerate/namespace/index.js +++ b/src/enumerate/namespace/index.js @@ -5,3 +5,4 @@ import { defineNamespace } from "@cqsjjb/jjb-dva-runtime"; export const NS_GLOBAL = defineNamespace("global"); +export const NS_COMMITMENT = defineNamespace("commitment"); \ No newline at end of file diff --git a/src/pages/Container/Supervise/BusPromiseTemplate/Add/index.js b/src/pages/Container/Supervise/BusPromiseTemplate/Add/index.js new file mode 100644 index 0000000..ebf220c --- /dev/null +++ b/src/pages/Container/Supervise/BusPromiseTemplate/Add/index.js @@ -0,0 +1,101 @@ +import { Connect } from "@cqsjjb/jjb-dva-runtime"; +import { Button, Col, Form, Input, message, Row } from "antd"; +import { useEffect } from "react"; +import FormBuilder from "zy-react-library/components/FormBuilder"; +import HeaderBack from "zy-react-library/components/HeaderBack"; +import DictionarySelect from "zy-react-library/components/Select/Dictionary"; +import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender"; +import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery"; +import { NS_COMMITMENT } from "~/enumerate/namespace"; + +function Add(props) { + const query = useGetUrlQuery(); + const [form] = Form.useForm(); + const getData = async () => { + if (query.id) { + const { data } = await props["busPromiseTemplateView"]({ id: query.id }); + const values = { + ...data, + }; + form.setFieldsValue({ + ...values, + }); + } + }; + useEffect(() => { + getData(); + }, []); + const onSubmit = async (values) => { + const { success } = await props[!query.id ? "busPromiseTemplateAdd" : "busPromiseTemplateEdit"]({ + ...values, + id: query.id, + promiseId: query.promiseId, + isRegulatory: 0, + }); + if (success) { + message.success("操作成功"); + props.history.goBack(); + } + }; + return ( +
+ +
+ form.setFieldValue("levelName", label)} />) }, + { name: "levelName", label: "承诺书级别", onlyForLabel: true }, + { name: "promiseText", label: "正文", span: 24, render: FORM_ITEM_RENDER_ENUM.TEXTAREA }, + { key: "templateDetails", span: 24, customizeRender: true, render: ( + <> + + {(fields, { add, remove }) => ( + <> + {fields.map((field, index) => ( + + + +
+ + + + { + index >= 1 + ? + : + } +
+
+ + +
+ ))} + + )} +
+ + ) }, + + ]} + /> +
+
+ ); +} + +export default Connect([NS_COMMITMENT], true)(Add); diff --git a/src/pages/Container/Supervise/BusPromiseTemplate/List/index.js b/src/pages/Container/Supervise/BusPromiseTemplate/List/index.js new file mode 100644 index 0000000..3f914b0 --- /dev/null +++ b/src/pages/Container/Supervise/BusPromiseTemplate/List/index.js @@ -0,0 +1,120 @@ +import { Connect } from "@cqsjjb/jjb-dva-runtime"; +import { Button, Form, message, Modal, Space } from "antd"; +import { useState } from "react"; +import AddIcon from "zy-react-library/components/Icon/AddIcon"; +import Search from "zy-react-library/components/Search"; +import Table from "zy-react-library/components/Table"; +import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender"; +import useTable from "zy-react-library/hooks/useTable"; +import { getLabelName } from "zy-react-library/utils"; +import { NS_COMMITMENT } from "~/enumerate/namespace"; +import DetailModal from "~/pages/Container/Supervise/Components/DetailModal"; + +const typeList = [{ name: "承诺书", bianma: "0" }, { name: "责任书", bianma: "1" }]; + +function List(props) { + const [form] = Form.useForm(); + const { tableProps, getData } = useTable(props["busPromiseTemplateList"], { + form, + }); + const [busPromiseTemplateModalOpen, setBusPromiseTemplateModalOpen] = useState(false); + const [id, setId] = useState(""); + const onDelete = (id) => { + Modal.confirm({ + title: "删除确认", + content: "确定要删除吗?", + onOk: async () => { + const { success } = await props["busPromiseTemplateDelete"]({ id }); + if (success) { + message.success("删除成功"); + getData(); + } + }, + }); + }; + const updatate = (id, state) => { + const stateValue = state === 0 ? 1 : 0; + Modal.confirm({ + title: "提示", + content: `确定要${state === 0 ? "禁用" : "启用"}当前承诺书吗?`, + onOk: async () => { + const { success } = await props["busPromiseTemplateUpdate"]({ id, state: stateValue }); + if (success) { + message.success("更新成功"); + getData(); + } + }, + }); + }; + return ( +
+ + ( + <> + + + )} + columns={[ + { title: "公司名称", dataIndex: "corpName" }, + { title: "模板名称", dataIndex: "promiseName" }, + { title: "承诺书级别", dataIndex: "levelName" }, + { title: "类型", dataIndex: "promiseType", render: (_, record) => getLabelName({ list: typeList, status: record.promiseType }) }, + { title: "添加时间", dataIndex: "createTime" }, + { title: "状态", render: (_, record) => getLabelName({ list: [{ name: "启用", bianma: "0" }, { name: "禁用", bianma: "1" }], status: record.state }) }, + { + title: "操作", + width: 150, + fixed: "right", + render: (_, record) => ( + + + + + + + + ), + }, + ]} + {...tableProps} + /> + {busPromiseTemplateModalOpen && setBusPromiseTemplateModalOpen(false)} id={id} />} + + ); +} + +export default Connect([NS_COMMITMENT], true)(List); diff --git a/src/pages/Container/Supervise/BusPromiseTemplate/index.js b/src/pages/Container/Supervise/BusPromiseTemplate/index.js new file mode 100644 index 0000000..5656523 --- /dev/null +++ b/src/pages/Container/Supervise/BusPromiseTemplate/index.js @@ -0,0 +1,9 @@ +function BusPromiseTemplate(props) { + return ( +
+ {props.children} +
+ ); +} + +export default BusPromiseTemplate; diff --git a/src/pages/Container/Supervise/components/DetailModal/index.js b/src/pages/Container/Supervise/components/DetailModal/index.js new file mode 100644 index 0000000..2e432c1 --- /dev/null +++ b/src/pages/Container/Supervise/components/DetailModal/index.js @@ -0,0 +1,125 @@ +import { Connect } from "@cqsjjb/jjb-dva-runtime"; +import { Image, Modal } from "antd"; +import dayjs from "dayjs"; +import { useEffect, useRef, useState } from "react"; +import { useReactToPrint } from "react-to-print"; +import { getFileUrl } from "zy-react-library/utils"; +import { NS_COMMITMENT } from "~/enumerate/namespace"; +// Info.jsx +import "./index.less"; + +const Info = (props) => { + const [form, setForm] = useState({}); + const getData = async () => { + if (props.id) { + const { data } = await props["busPromiseTemplateView"]({ id: props.id }); + setForm(data); + } + }; + useEffect(() => { + props.id && getData(); + }, []); + const contentRef = useRef(null); + const handlePrint = useReactToPrint({ + contentRef, + pageStyle: `@page { + margin: 0mm; + } + @media print { + body { + margin: 10px; + padding: 10px; + } + } + `, + documentTitle: "", + }); + return ( + <> + +
+
+

{form.promiseType === 0 ? "安全生产承诺书" : "安全生产责任状"}

+
+
河 北 港 口 集 团 有 限 公 司
+
+ ( + {form.createTime ? dayjs(form.createTime).format("YYYY年") : ""} + ) +
+
+
+ +

{form.promiseType === 0 ? "安全生产承诺书" : "安全生产责任状"}

+ + {form.promiseType === 0 && ( +
+ {`${form.name}:` || ""} +
+ )} + +
{form.promiseText}
+ +
+ {form.templateDetails?.map((item, index) => ( +
{item.collateral}
+ ))} +
+ +
+ {form.promiseType === 0 + ? ( +
若违反上述承诺和未履行安全生产职责,或发生责任事故的,接受政府或公司事故调查组做出的处罚决定。
+ ) + : ( +
若未履行安全生产职责,或发生生产安全事故的,接受公司或政府事故调查组做出的处罚。
+ )} +
+ +
+ {form.promiseType === 1 && ( +
+ {!form?.ORDER?.FILEPATH + ? ( +
+ 发状人: + {form.COVERPEOPLE} +
+ ) + : ( +
+ : + + 发状人: + + +
+ )} +
+ )} + +
+
+
+ + {form.promiseType === 0 ? "承诺人(本人签字)" : "受状人"} + : + +
+
+
+
+
+
+ + + ); +}; +export default Connect([NS_COMMITMENT], true)(Info); diff --git a/src/pages/Container/Supervise/components/DetailModal/index.less b/src/pages/Container/Supervise/components/DetailModal/index.less new file mode 100644 index 0000000..1062295 --- /dev/null +++ b/src/pages/Container/Supervise/components/DetailModal/index.less @@ -0,0 +1,72 @@ +.dialogContent { + padding: 50px; + font-size: 16px; + + .cover { + height: 841pt; + text-align: center; + position: relative; + display: none; + + h1 { + padding-top: 300px; + } + + > div { + position: absolute; + bottom: 100px; + left: 50%; + transform: translateX(-50%); + } + } + + @media print { + .cover { + display: block; + } + } + + .title { + text-align: center; + } + + .text { + text-indent: 35px; + line-height: 26px; + letter-spacing: 2px; + text-align: justify; + } + + .collateral { + text-indent: 35px; + line-height: 26px; + letter-spacing: 2px; + text-align: justify; + } + + .footer { + text-indent: 35px; + margin-top: 30px; + display: flex; + justify-content: space-between; + } + + .respondent, + .hairdresser { + .promiser { + display: flex; + align-items: flex-end; + + img { + margin-left: 30px; + width: 200px; + height: 100px; + } + } + + .time { + margin-top: 30px; + margin-left: 65px; + } + } +} diff --git a/src/pages/Container/Supervise/index.js b/src/pages/Container/Supervise/index.js new file mode 100644 index 0000000..7410828 --- /dev/null +++ b/src/pages/Container/Supervise/index.js @@ -0,0 +1,9 @@ +function Supervise(props) { + return ( +
+ {props.children} +
+ ); +} + +export default Supervise;