123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import React, { useEffect, useRef, useState } from "react";
  2. import {
  3. Button,
  4. Select,
  5. Row,
  6. Col,
  7. Form,
  8. Descriptions,
  9. Input,
  10. Card,
  11. Space,
  12. } from "antd";
  13. import {
  14. ProForm,
  15. ProFormText,
  16. ProFormTextArea,
  17. } from "@ant-design/pro-components";
  18. import { useSearchParams } from "react-router-dom";
  19. import { useNavigate } from "react-router-dom";
  20. import { getTaMessageById, putTaMessage } from "@/service/taMessage";
  21. import { postTaRotation } from "@/service/taRotation";
  22. import Page from "@/components/Page";
  23. export default (props) => {
  24. const [searchParams] = useSearchParams();
  25. const id = searchParams.get("id");
  26. const [form] = Form.useForm();
  27. const navigate = useNavigate();
  28. useEffect(() => {
  29. form.resetFields();
  30. getTaMessageById(id).then((res) => {
  31. form.setFieldsValue(res);
  32. });
  33. }, []);
  34. const onFinish = (values) => {
  35. const sourceName = form.getFieldValue("sourceName");
  36. const data = {
  37. ...values,
  38. sourceName: sourceName,
  39. };
  40. putTaMessage(id, data).then((res) => {
  41. navigate(-1);
  42. });
  43. };
  44. const onRatation = () => {
  45. const sourceName = form.getFieldValue("sourceName");
  46. const sourceId = form.getFieldValue("sourceId");
  47. if (sourceName == "taRotation") {
  48. navigate(
  49. `/rotationMange/rotationList/edit?id=${sourceId}&disabled={true}`
  50. );
  51. } else {
  52. navigate(
  53. `/mandatoryLeaveMange/mandatoryleave/edit?id=${sourceId}&disabled={true}`
  54. );
  55. }
  56. };
  57. return (
  58. <Page>
  59. <Card>
  60. <ProForm
  61. style={{ marginTop: "24px" }}
  62. form={form}
  63. onFinish={onFinish}
  64. layout="horizontal"
  65. labelCol={{ span: 2 }}
  66. wrapperCol={{ span: 8 }}
  67. submitter={false}
  68. >
  69. <ProFormTextArea label="消息内容" name="contentSent" readonly />
  70. <ProForm.Item noStyle shouldUpdate>
  71. {({ getFieldValue }) => {
  72. const waringType = getFieldValue("waringType");
  73. const sourceName = getFieldValue("sourceName");
  74. return (
  75. <>
  76. <Form.Item label="查看按钮">
  77. <Button type="link" onClick={onRatation}>
  78. {sourceName == "taRotation"
  79. ? "点击查看轮岗详情"
  80. : "点击查看强制休假详情"}
  81. </Button>
  82. </Form.Item>
  83. {sourceName && sourceName == "taMandatoryLeave" ? null : (
  84. <>
  85. <ProFormTextArea
  86. label="核查反馈"
  87. name="remark"
  88. disabled={waringType == "prompt"}
  89. />
  90. <Form.Item>
  91. <Row>
  92. <Col offset={15}>
  93. <Button
  94. type="primary"
  95. htmlType="submit"
  96. disabled={waringType == "prompt"}
  97. >
  98. 提交
  99. </Button>
  100. </Col>
  101. </Row>
  102. </Form.Item>
  103. </>
  104. )}
  105. </>
  106. );
  107. }}
  108. </ProForm.Item>
  109. </ProForm>
  110. </Card>
  111. </Page>
  112. );
  113. };