123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- import {
- getPurchaseList,
- getPurchaseDetail,
- savePurchase,
- updatePurchase,
- deletePurchase,
- } from "@/services/purchase";
- import { queryTable } from "@/utils/request";
- import { PageContainer, ProTable } from "@ant-design/pro-components";
- import { useNavigate } from "react-router-dom";
- import { Button, message, Popconfirm } from "antd";
- import { useRef, useState, useEffect } from "react";
- import { floatMultiply, floatDivide } from "@/utils/float";
-
- // type plan 采购计划 bill 采购账单 inStore 采购入库
- const StockList = (props) => {
- const { type } = props;
- const [showDetail, setShowDetail] = useState(false);
- const [activeKey, setActiveKey] = useState("");
- const actionRef = useRef();
- const navigate = useNavigate();
- // console.log(props, "props");
-
- useEffect(() => {
- actionRef.current.reload();
- }, [type]);
- const handleDelete = (id) => {
- if (id) {
- deletePurchase(id).then((res) => {
- actionRef.current.reload();
- });
- }
- };
-
- const columns = [
- {
- title: "采购计划",
- dataIndex: "title",
- },
-
- {
- title: "计划时间",
- dataIndex: "planDate",
- },
- {
- title: "采购项目",
- dataIndex: "items",
- search: false,
- },
-
- {
- title: "是否入库",
- dataIndex: "isInStore",
- valueEnum: {
- false: { text: "否", status: "Error" },
- true: { text: "是", status: "Success" },
- },
- search: false,
- },
-
- {
- title: "是否采购完成",
- dataIndex: "isCompleted",
- valueEnum: {
- false: { text: "否", status: "Error" },
- true: { text: "是", status: "Success" },
- },
- search: false,
- },
-
- {
- title: "操作",
- valueType: "option",
- width: 200,
- render: (_, record) => [
- type === "plan" ? (
- <Button
- key={2}
- style={{ padding: 0 }}
- type="link"
- onClick={() => {
- navigate(`/purchase/plan/edit?id=${record.id}`);
- }}
- >
- 修改
- </Button>
- ) : null,
-
- type === "bill" ? (
- <Button
- key={4}
- style={{ padding: 0 }}
- type="link"
- disabled={record?.isCompleted}
- onClick={() => {
- navigate(`/purchase/bill/edit?id=${record.id}`);
- }}
- >
- 采购
- </Button>
- ) : null,
-
- type === "inStore" ? (
- <Button
- key={5}
- style={{ padding: 0 }}
- type="link"
- disabled={record?.isInStore}
- onClick={() => {
- navigate(`/purchase/inStore/edit?id=${record.id}`);
- }}
- >
- 入库
- </Button>
- ) : null,
-
- type === "plan" ? (
- <Popconfirm
- key={3}
- title="您是否确认删除 ?"
- onConfirm={() => handleDelete(record.id)}
- okText="确定"
- cancelText="取消"
- >
- {/* manualPush */}
- <Button style={{ padding: 0 }} type="link">
- 删除
- </Button>
- </Popconfirm>
- ) : null,
- ],
- },
- ];
-
- return (
- <PageContainer>
- <ProTable
- actionRef={actionRef}
- rowKey="id"
- params={type === "inStore" ? { isCompleted: true } : {}}
- toolBarRender={() => [
- type === "plan" ? (
- <Button
- key="2"
- type="primary"
- onClick={() => {
- navigate("/purchase/plan/edit");
- }}
- >
- 新增
- </Button>
- ) : null,
- ]}
- // search={false}
- request={queryTable(getPurchaseList)}
- columns={columns}
- />
- </PageContainer>
- );
- };
-
- export default StockList;
|