123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- import React from "react";
- import { useNavigate } from "react-router-dom";
- import { queryTable, queryDict } from "@/utils/request";
- import { ProTable } from "@ant-design/pro-components";
- import { Button, message, Popconfirm } from "antd";
- import Page from "@/components/Page";
- import { getSysPosition, deleteSysPosition } from "@/service/sysposition";
- import { getSysOrg } from "@/service/sysorg";
-
- const querySysPositionList = queryTable(getSysPosition);
- const queryOrg = queryDict(getSysOrg, { labelKey: 'name', valueKey: 'orgId' })
-
- export default (props) => {
- const actionRef = React.useRef();
- const navigate = useNavigate();
-
- // const updateStatus = (user) => {
- // const status = user.status === 1 ? 0 : 1;
- // const hide = message.loading("请稍候...", 0);
- // updateUserStatus(user.id, status)
- // .then((res) => {
- // hide();
- // actionRef.current.reload();
- // })
- // .catch(() => {
- // hide();
- // });
- // };
- const handleDelete = (id) => {
- if (id) {
- deleteSysPosition(id).then((res) => {
- actionRef.current.reload();
- });
- }
- };
-
- const columns = [
- {
- title: "岗位名称",
- dataIndex: "name",
- },
- {
- title: "所属单位",
- dataIndex: "orgId",
- valueType: 'select',
- request: queryOrg,
- },
-
- {
- title: "排序",
- dataIndex: "sortNum",
- },
- {
- title: "状态",
- dataIndex: "status",
- valueEnum: {
- 1: {
- text: "正常",
- status: "Processing",
- },
- 0: {
- text: "禁用",
- status: "Error",
- },
- },
- },
- {
- title: "操作",
- valueType: "option",
- width: 200,
- render: (_, record) => [
- // <Button
- // key={1}
- // style={{ padding: 0 }}
- // type="link"
- // onClick={() => {
- // updateStatus(record);
- // }}
- // >
- // {record.status === 1 ? "禁用" : "启用"}
- // </Button>,
- <Button
- key={2}
- style={{ padding: 0 }}
- type="link"
- onClick={() => {
- console.log(record, "]]");
- navigate(`/system/position/edit?id=${record.positionId}`);
- }}
- >
- 编辑
- </Button>,
- <Popconfirm
- key={3}
- title="您是否确认删除 ?"
- onConfirm={() => handleDelete(record.positionId)}
- okText="确定"
- cancelText="取消"
- >
- {/* manualPush */}
- <Button style={{ padding: 0 }} type="link">
- 删除
- </Button>
- </Popconfirm>,
- ],
- },
- ];
-
- return (
- <Page>
- <ProTable
- actionRef={actionRef}
- rowKey="positionId"
- search={false}
- toolBarRender={() => [
- <Button
- key="1"
- type="primary"
- onClick={() => {
- navigate("/system/position/edit");
- }}
- >
- 新增
- </Button>,
- ]}
- request={querySysPositionList}
- columns={columns}
- />
- </Page>
- );
- };
|