index.jsx 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import React from "react";
  2. import { useNavigate } from "react-router-dom";
  3. import { queryTable, queryDict } from "@/utils/request";
  4. import { ProTable } from "@ant-design/pro-components";
  5. import { Button, message, Popconfirm } from "antd";
  6. import Page from "@/components/Page";
  7. import { getSysPosition, deleteSysPosition } from "@/service/sysposition";
  8. import { getSysOrg } from "@/service/sysorg";
  9. const querySysPositionList = queryTable(getSysPosition);
  10. const queryOrg = queryDict(getSysOrg, { labelKey: 'name', valueKey: 'orgId' })
  11. export default (props) => {
  12. const actionRef = React.useRef();
  13. const navigate = useNavigate();
  14. // const updateStatus = (user) => {
  15. // const status = user.status === 1 ? 0 : 1;
  16. // const hide = message.loading("请稍候...", 0);
  17. // updateUserStatus(user.id, status)
  18. // .then((res) => {
  19. // hide();
  20. // actionRef.current.reload();
  21. // })
  22. // .catch(() => {
  23. // hide();
  24. // });
  25. // };
  26. const handleDelete = (id) => {
  27. if (id) {
  28. deleteSysPosition(id).then((res) => {
  29. actionRef.current.reload();
  30. });
  31. }
  32. };
  33. const columns = [
  34. {
  35. title: "岗位名称",
  36. dataIndex: "name",
  37. },
  38. {
  39. title: "所属单位",
  40. dataIndex: "orgId",
  41. valueType: 'select',
  42. request: queryOrg,
  43. },
  44. {
  45. title: "排序",
  46. dataIndex: "sortNum",
  47. },
  48. {
  49. title: "状态",
  50. dataIndex: "status",
  51. valueEnum: {
  52. 1: {
  53. text: "正常",
  54. status: "Processing",
  55. },
  56. 0: {
  57. text: "禁用",
  58. status: "Error",
  59. },
  60. },
  61. },
  62. {
  63. title: "操作",
  64. valueType: "option",
  65. width: 200,
  66. render: (_, record) => [
  67. // <Button
  68. // key={1}
  69. // style={{ padding: 0 }}
  70. // type="link"
  71. // onClick={() => {
  72. // updateStatus(record);
  73. // }}
  74. // >
  75. // {record.status === 1 ? "禁用" : "启用"}
  76. // </Button>,
  77. <Button
  78. key={2}
  79. style={{ padding: 0 }}
  80. type="link"
  81. onClick={() => {
  82. console.log(record, "]]");
  83. navigate(`/system/position/edit?id=${record.positionId}`);
  84. }}
  85. >
  86. 编辑
  87. </Button>,
  88. <Popconfirm
  89. key={3}
  90. title="您是否确认删除 ?"
  91. onConfirm={() => handleDelete(record.positionId)}
  92. okText="确定"
  93. cancelText="取消"
  94. >
  95. {/* manualPush */}
  96. <Button style={{ padding: 0 }} type="link">
  97. 删除
  98. </Button>
  99. </Popconfirm>,
  100. ],
  101. },
  102. ];
  103. return (
  104. <Page>
  105. <ProTable
  106. actionRef={actionRef}
  107. rowKey="positionId"
  108. search={false}
  109. toolBarRender={() => [
  110. <Button
  111. key="1"
  112. type="primary"
  113. onClick={() => {
  114. navigate("/system/position/edit");
  115. }}
  116. >
  117. 新增
  118. </Button>,
  119. ]}
  120. request={querySysPositionList}
  121. columns={columns}
  122. />
  123. </Page>
  124. );
  125. };