添加安全承诺书模板管理
parent
bdd27e4afb
commit
c05c17360d
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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`,
|
||||
);
|
||||
|
|
@ -5,3 +5,4 @@
|
|||
import { defineNamespace } from "@cqsjjb/jjb-dva-runtime";
|
||||
|
||||
export const NS_GLOBAL = defineNamespace("global");
|
||||
export const NS_COMMITMENT = defineNamespace("commitment");
|
||||
|
|
@ -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 (
|
||||
<div>
|
||||
<HeaderBack title={query.id ? "编辑" : "新增"} />
|
||||
<div style={{ paddingBottom: 10 }}>
|
||||
<FormBuilder
|
||||
form={form}
|
||||
values={{
|
||||
templateDetails: [{}],
|
||||
}}
|
||||
onFinish={onSubmit}
|
||||
options={[
|
||||
{ name: "promiseName", label: "承诺书名称", span: 24 },
|
||||
{ name: "promiseType", label: "承诺书类型", render: FORM_ITEM_RENDER_ENUM.SELECT, items: [{ name: "承诺书", bianma: 0 }, { name: "责任书", bianma: 1 }] },
|
||||
{ name: "level", label: "承诺书级别", render: (<DictionarySelect dictValue="PROMISE_LEVEL" onGetLabel={label => 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: (
|
||||
<>
|
||||
<Form.List name="templateDetails">
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
{fields.map((field, index) => (
|
||||
<Row gutter={24} key={field.key}>
|
||||
<Col span={24}>
|
||||
<Form.Item label="副文" required labelCol={{ span: 2 }} wrapperCol={{ span: 22 }}>
|
||||
<div style={{ display: "flex", gap: 10 }}>
|
||||
<Form.Item
|
||||
noStyle
|
||||
rules={
|
||||
[
|
||||
{ required: true, message: "请输入副文" },
|
||||
]
|
||||
}
|
||||
name={[field.name, "collateral"]}
|
||||
>
|
||||
<Input.TextArea placeholder="请输入副文" rows={4} maxLength={500} />
|
||||
</Form.Item>
|
||||
{
|
||||
index >= 1
|
||||
? <Button type="primary" danger onClick={() => remove(field.name)}>删除</Button>
|
||||
: <Button type="primary" onClick={() => add({ deptId: undefined, deptName: undefined, userId: undefined, userName: undefined, type: 300 })}>新增</Button>
|
||||
}
|
||||
</div>
|
||||
</Form.Item>
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</Form.List>
|
||||
</>
|
||||
) },
|
||||
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Connect([NS_COMMITMENT], true)(Add);
|
||||
|
|
@ -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 (
|
||||
<div style={{ padding: 20 }}>
|
||||
<Search
|
||||
labelCol={{ span: 8 }}
|
||||
form={form}
|
||||
options={[
|
||||
{ name: "hiddenDesc", label: "模板名称" },
|
||||
{ name: "promiseType", label: "承诺书类型", render: FORM_ITEM_RENDER_ENUM.SELECT, items: typeList },
|
||||
]}
|
||||
onFinish={getData}
|
||||
/>
|
||||
<Table
|
||||
toolBarRender={() => (
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<AddIcon />}
|
||||
onClick={() => {
|
||||
props.history.push("./add");
|
||||
}}
|
||||
>
|
||||
新增
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
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) => (
|
||||
<Space>
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
setBusPromiseTemplateModalOpen(true);
|
||||
setId(record.id);
|
||||
}}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
<Button type="link" onClick={() => updatate(record.id, record.state)}>
|
||||
{record.state === 0 ? "禁用" : "启用"}
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
props.history.push(`./add?id=${record.id}`);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
|
||||
<Button type="link" danger onClick={() => onDelete(record.id)}>删除</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
{...tableProps}
|
||||
/>
|
||||
{busPromiseTemplateModalOpen && <DetailModal onCancel={() => setBusPromiseTemplateModalOpen(false)} id={id} />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Connect([NS_COMMITMENT], true)(List);
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
function BusPromiseTemplate(props) {
|
||||
return (
|
||||
<div>
|
||||
{props.children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default BusPromiseTemplate;
|
||||
|
|
@ -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 (
|
||||
<>
|
||||
<Modal
|
||||
title={form.promiseType === 0 ? "安全生产承诺书" : "安全生产责任状"}
|
||||
open
|
||||
onCancel={props.onCancel}
|
||||
okText="打印"
|
||||
onOk={handlePrint}
|
||||
width={800}
|
||||
>
|
||||
<div ref={contentRef} className="dialogContent">
|
||||
<div className="cover print_use">
|
||||
<h1>{form.promiseType === 0 ? "安全生产承诺书" : "安全生产责任状"}</h1>
|
||||
<div>
|
||||
<div>河 北 港 口 集 团 有 限 公 司</div>
|
||||
<div>
|
||||
(
|
||||
{form.createTime ? dayjs(form.createTime).format("YYYY年") : ""}
|
||||
)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1 className="title">{form.promiseType === 0 ? "安全生产承诺书" : "安全生产责任状"}</h1>
|
||||
|
||||
{form.promiseType === 0 && (
|
||||
<div>
|
||||
{`${form.name}:` || ""}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="text">{form.promiseText}</div>
|
||||
|
||||
<div className="collateral">
|
||||
{form.templateDetails?.map((item, index) => (
|
||||
<div key={index} className="item">{item.collateral}</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="text">
|
||||
{form.promiseType === 0
|
||||
? (
|
||||
<div>若违反上述承诺和未履行安全生产职责,或发生责任事故的,接受政府或公司事故调查组做出的处罚决定。</div>
|
||||
)
|
||||
: (
|
||||
<div>若未履行安全生产职责,或发生生产安全事故的,接受公司或政府事故调查组做出的处罚。</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div style={{ alignItems: form.FILEPATH ? "flex-end" : "flex-start" }}>
|
||||
{form.promiseType === 1 && (
|
||||
<div className="hairdresser">
|
||||
{!form?.ORDER?.FILEPATH
|
||||
? (
|
||||
<div className="promiser">
|
||||
发状人:
|
||||
{form.COVERPEOPLE}
|
||||
</div>
|
||||
)
|
||||
: (
|
||||
<div className="promiser">
|
||||
:
|
||||
<span style={{ marginRight: form?.ORDER?.FILEPATH ? "0px" : "105px" }}>
|
||||
发状人:
|
||||
<Image src={getFileUrl() + form.FILEPATH} alt="sign" width={100} height={100} />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="footer">
|
||||
<div className="respondent">
|
||||
<div className="promiser">
|
||||
<span style={{ marginRight: form.FILEPATH ? "0px" : "105px" }}>
|
||||
{form.promiseType === 0 ? "承诺人(本人签字)" : "受状人"}
|
||||
:
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Connect([NS_COMMITMENT], true)(Info);
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
function Supervise(props) {
|
||||
return (
|
||||
<div>
|
||||
{props.children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Supervise;
|
||||
Loading…
Reference in New Issue