ProjectEdit.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import {
  2. ProForm,
  3. ProFormText,
  4. ProFormTextArea,
  5. } from "@ant-design/pro-components";
  6. import { message } from "antd";
  7. import type {
  8. IProjectData,
  9. IProjectResponse,
  10. IProjectUpdateRequest,
  11. } from "../../api/task";
  12. import { get, patch } from "../../request";
  13. import { useIntl } from "react-intl";
  14. import Publicity from "../studio/Publicity";
  15. interface IWidget {
  16. projectId?: string;
  17. studioName?: string;
  18. }
  19. const ProjectEdit = ({ projectId }: IWidget) => {
  20. const intl = useIntl();
  21. return (
  22. <ProForm<IProjectData>
  23. onFinish={async (values) => {
  24. const url = `/v2/project/${projectId}`;
  25. console.info("api request", url, values);
  26. const res = await patch<IProjectUpdateRequest, IProjectResponse>(
  27. url,
  28. values
  29. );
  30. console.log("api response", res);
  31. message.success("提交成功");
  32. }}
  33. params={{}}
  34. request={async () => {
  35. const url = `/v2/project/${projectId}`;
  36. console.info("api request", url);
  37. const res = await get<IProjectResponse>(url);
  38. console.log("api response", res);
  39. return res.data;
  40. }}
  41. >
  42. <ProForm.Group>
  43. <ProFormText
  44. width="md"
  45. name="title"
  46. label={intl.formatMessage({
  47. id: "forms.fields.title.label",
  48. })}
  49. />
  50. </ProForm.Group>
  51. <ProForm.Group>
  52. <ProFormText
  53. width="md"
  54. name="type"
  55. label={intl.formatMessage({
  56. id: "forms.fields.type.label",
  57. })}
  58. readonly
  59. />
  60. </ProForm.Group>
  61. <ProForm.Group>
  62. <Publicity
  63. name="privacy"
  64. disable={["disable", "public_no_list", "blocked"]}
  65. />
  66. </ProForm.Group>
  67. <ProForm.Group>
  68. <ProFormTextArea
  69. width="md"
  70. name="description"
  71. label={intl.formatMessage({
  72. id: "forms.fields.description.label",
  73. })}
  74. />
  75. </ProForm.Group>
  76. </ProForm>
  77. );
  78. };
  79. export default ProjectEdit;