• wuhao's avatar
    asder · 232589d0
    wuhao authored
    232589d0
index.jsx 2.05 KB
import React, { useEffect, useRef, useReducer } from "react";
import { Button, Popconfirm, Switch } from "antd";
import AutoTable from "@/components/AutoTable";
import getPrem from "@/utils/getPrem"; //权限判断fn
import { useRequest } from "umi";
import { doFetch } from "@/utils/doFetch";
const Specialset = (props) => {
  let actionRef = useRef(),
    ChildRef = null;
  function reload() {
    actionRef?.current?.reload();
    ChildRef?.onRefresh();
  }
  const { run, loading } = useRequest(doFetch, {
      manual: true,
      formatResult: (res) => res,
      onSuccess: (result, params) => {
        if (result.code == "0000") {
          reload();
        }
      },
    }),
    columns = [
      {
        title: "类别",
        dataIndex: "name",
        key: "name",
      },
      {
        title: "操作",
        dataIndex: "option_dataindex",
        key: "option_dataindex",
        valueType: "option",
        width: 120,
        render: (text, row, _, action) => {
          return (
            <Popconfirm
              title="是否开启或关闭?"
              onConfirm={() => {
                run({
                  url: "/ngic-base-business/bmSpecialSet/setUp",
                  params: { id: row.id, judge: row.judge == 1 ? 2 : 1 },
                });
              }}
              onCancel={() => {}}
              okText="确定"
              cancelText="取消"
              disabled={!getPrem("equipmentSupplier_updatestatus", "ifs")}
            >
              <Switch
                checked={row.judge == 1 ? true : false}
                checkedChildren="开启"
                unCheckedChildren="关闭"
                defaultChecked={false}
              />
            </Popconfirm>
          );
        },
      },
    ];
  return (
    <div>
      <AutoTable
        pagetitle={props.route.name} //页面标题
        columns={columns}
        path="/ngic-base-business/bmSpecialSet/queryList"
        actionRef={actionRef}
        onRef={(node) => (ChildRef = node)}
      ></AutoTable>
    </div>
  );
};
export default Specialset;