供应商退出详情问题修改
This commit is contained in:
@ -1,14 +1,14 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Modal, message } from 'antd';
|
import { Modal, message } from 'antd';
|
||||||
import SupplierDetail from './SupplierDetail';
|
import SupplierDetail from './SupplierDetail';
|
||||||
|
import { useIntl } from 'umi';
|
||||||
const SupplierDetailModalContext = React.createContext<((id: string) => void) | null>(null);
|
const SupplierDetailModalContext = React.createContext<((id: string) => void) | null>(null);
|
||||||
export const useSupplierDetailModal = () => React.useContext(SupplierDetailModalContext);
|
export const useSupplierDetailModal = () => React.useContext(SupplierDetailModalContext);
|
||||||
|
|
||||||
export const SupplierDetailModalProvider = ({ children }: { children: React.ReactNode }) => {
|
export const SupplierDetailModalProvider = ({ children }: { children: React.ReactNode }) => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [supplierId, setSupplierId] = useState<string | null>(null);
|
const [supplierId, setSupplierId] = useState<string | null>(null);
|
||||||
|
const intl = useIntl();
|
||||||
const showSupplierDetail = (id: string) => {
|
const showSupplierDetail = (id: string) => {
|
||||||
if (!id) return message.error('此供应商信息缺失,请联系管理员');
|
if (!id) return message.error('此供应商信息缺失,请联系管理员');
|
||||||
setSupplierId(id);
|
setSupplierId(id);
|
||||||
@ -18,7 +18,11 @@ export const SupplierDetailModalProvider = ({ children }: { children: React.Reac
|
|||||||
return (
|
return (
|
||||||
<SupplierDetailModalContext.Provider value={showSupplierDetail}>
|
<SupplierDetailModalContext.Provider value={showSupplierDetail}>
|
||||||
{children}
|
{children}
|
||||||
<Modal visible={visible} onCancel={() => setVisible(false)} footer={null} width="90%">
|
<Modal visible={visible} onCancel={() => setVisible(false)} footer={null} width="90%" title={
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'flex-start', alignItems: 'center' }}>
|
||||||
|
<span>{intl.formatMessage({ id: 'component.globalModal.title' })}</span>
|
||||||
|
</div>
|
||||||
|
}>
|
||||||
<SupplierDetail supplierId={supplierId} />
|
<SupplierDetail supplierId={supplierId} />
|
||||||
</Modal>
|
</Modal>
|
||||||
</SupplierDetailModalContext.Provider>
|
</SupplierDetailModalContext.Provider>
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import React, { useEffect , useState } from "react";
|
import React, { useEffect , useState } from "react";
|
||||||
import { Modal, Button, Select, Input, Table, message, Form } from "antd";
|
import { Modal, Button, Input, Table, message, Form } from "antd";
|
||||||
import SupplierSelectModal from "./SupplierSelectModal";
|
|
||||||
import { add } from "../services";
|
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
const { Option } = Select;
|
//组件
|
||||||
|
import SupplierSelectModal from "./SupplierSelectModal";
|
||||||
|
import AccessDepartmentSelect from "@/components/AccessDepartmentSelect"
|
||||||
|
//接口
|
||||||
|
import { add } from "../services";
|
||||||
|
|
||||||
interface Supplier {
|
interface Supplier {
|
||||||
id: number; // 作为 rowKey 用于唯一标识
|
id: number; // 作为 rowKey 用于唯一标识
|
||||||
supplierName: string; // 供应商名称
|
supplierName: string; // 供应商名称
|
||||||
@ -22,29 +25,31 @@ interface CreateBlacklistModalProps {
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEPT_OPTIONS = [
|
|
||||||
{ value: "DEPT001", label: "部门A" },
|
|
||||||
{ value: "DEPT002", label: "部门B" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
||||||
visible,
|
visible,
|
||||||
onOk,
|
onOk,
|
||||||
onCancel,
|
onCancel,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
// 供应商开启与选中
|
||||||
const [selectVisible, setSelectVisible] = useState(false);
|
const [selectVisible, setSelectVisible] = useState(false);
|
||||||
const [suppliers, setSuppliers] = useState<Supplier[]>([]);
|
const [suppliers, setSuppliers] = useState<Supplier[]>([]);
|
||||||
const [form] = Form.useForm();
|
// 获取缓存 用户单位ID
|
||||||
|
const [userDeptId, setUserDeptId] = useState('');
|
||||||
|
const currentUserStr = sessionStorage.getItem('currentUser');
|
||||||
|
const currentUser = currentUserStr ? JSON.parse(currentUserStr) : null;
|
||||||
|
|
||||||
|
//移除已选供应商
|
||||||
const removeSupplier = (id: number) => {
|
const removeSupplier = (id: number) => {
|
||||||
setSuppliers(suppliers.filter((s) => s.id !== id));
|
setSuppliers(suppliers.filter((s) => s.id !== id));
|
||||||
};
|
};
|
||||||
|
// 供应商回调
|
||||||
const handleSelectOk = (selected: Supplier[]) => {
|
const handleSelectOk = (selected: Supplier[]) => {
|
||||||
setSuppliers(selected);
|
setSuppliers(selected);
|
||||||
setSelectVisible(false);
|
setSelectVisible(false);
|
||||||
};
|
};
|
||||||
|
//提交
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const values = await form.validateFields();
|
const values = await form.validateFields();
|
||||||
@ -75,15 +80,19 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
|||||||
message.error("提交失败");
|
message.error("提交失败");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// 校验失败
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
setSuppliers([]);
|
setSuppliers([]);
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
setUserDeptId(currentUser?.user?.orgId || '');
|
||||||
|
// 设置表单的初始单位
|
||||||
|
form.setFieldsValue({ deptId: currentUser?.user?.orgId || '' });
|
||||||
|
|
||||||
}
|
}
|
||||||
}, [visible]);
|
}, [visible]);
|
||||||
|
//列表头
|
||||||
const columns: ColumnsType<Supplier> = [
|
const columns: ColumnsType<Supplier> = [
|
||||||
{ title: "供应商名称", dataIndex: "supplierName", align: "center" },
|
{ title: "供应商名称", dataIndex: "supplierName", align: "center" },
|
||||||
{ title: "准入部门", dataIndex: "deptId", align: "center" },
|
{ title: "准入部门", dataIndex: "deptId", align: "center" },
|
||||||
@ -127,8 +136,8 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
|||||||
<div style={{ marginTop: 24 }}>
|
<div style={{ marginTop: 24 }}>
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
labelCol={{ flex: '100px' }} // label 固定宽度(也可写 'none')
|
labelCol={{ flex: '100px' }}
|
||||||
wrapperCol={{ flex: 1 }} // 输入框区域自适应剩余空间
|
wrapperCol={{ flex: 1 }}
|
||||||
layout="horizontal"
|
layout="horizontal"
|
||||||
>
|
>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@ -140,15 +149,11 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="发起部门"
|
label="发起单位"
|
||||||
name="deptId"
|
name="deptId"
|
||||||
rules={[{ required: true, message: '请选择发起部门' }]}
|
rules={[{ required: true, message: '请选择发起单位' }]}
|
||||||
>
|
>
|
||||||
<Select placeholder="请选择发起部门">
|
<AccessDepartmentSelect value={userDeptId} placeholder={'请选择发起单位'} />
|
||||||
{DEPT_OPTIONS.map((opt) => (
|
|
||||||
<Option key={opt.value} value={opt.value}>{opt.label}</Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Modal, Button, Table, Descriptions, Spin, message } from "antd";
|
import { Modal, Button, Table, Descriptions, Spin, message, Tooltip } from "antd";
|
||||||
import {coscoSupplierexit } from "../services"; // 假设的接口
|
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
//umi 相关
|
||||||
|
import { connect } from 'umi';
|
||||||
|
//接口
|
||||||
|
import { coscoSupplierexit } from "../services"; // 假设的接口
|
||||||
|
import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext';
|
||||||
interface Supplier {
|
interface Supplier {
|
||||||
id: number; // 作为 rowKey 用于唯一标识
|
id: string; // 作为 rowKey 用于唯一标识
|
||||||
supplierName: string; // 供应商名称
|
supplierName: string; // 供应商名称
|
||||||
unit: string; // 准入部门
|
unit: string; // 准入部门
|
||||||
accessTime: string; // 准入时间
|
accessTime: string; // 准入时间
|
||||||
categoryName: string; // 准入品类
|
categoryName: string; // 准入品类
|
||||||
lastEval: string; // 最近一次评价
|
lastEval: string; // 最近一次评价
|
||||||
lastEvalDate: string; // 评价时间
|
lastEvalDate: string; // 评价时间
|
||||||
supplierId: string;
|
supplierId: string;
|
||||||
categoryId: string;
|
categoryId: string;
|
||||||
}
|
}
|
||||||
interface DetailData {
|
interface DetailData {
|
||||||
exitTheme: string;
|
exitTheme: string;
|
||||||
deptName: string;
|
deptName: string;
|
||||||
@ -35,11 +38,11 @@ const ViewBlacklistModal: React.FC<ViewBlacklistModalProps> = ({
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [detail, setDetail] = useState<DetailData | null>(null);
|
const [detail, setDetail] = useState<DetailData | null>(null);
|
||||||
const [suppliers, setSuppliers] = useState<Supplier[]>([]);
|
const [suppliers, setSuppliers] = useState<Supplier[]>([]);
|
||||||
|
const supplierDetailModal = useSupplierDetailModal();
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const { code, data } = await coscoSupplierexit(recordId)
|
const { code, data } = await coscoSupplierexit(recordId)
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
setDetail(data.coscoSupplierexit);
|
setDetail(data.coscoSupplierexit);
|
||||||
} else {
|
} else {
|
||||||
@ -64,13 +67,21 @@ const ViewBlacklistModal: React.FC<ViewBlacklistModalProps> = ({
|
|||||||
}
|
}
|
||||||
}, [visible, recordId]);
|
}, [visible, recordId]);
|
||||||
|
|
||||||
const columns:ColumnsType<Supplier> = [
|
const columns: ColumnsType<Supplier> = [
|
||||||
{ title: "供应商名称", dataIndex: "supplierName", align: "center" },
|
{
|
||||||
{ title: "准入部门", dataIndex: "deptId", align: "center" },
|
title: "供应商名称", dataIndex: "supplierName", align: "left",
|
||||||
// { title: "准入时间", dataIndex: "accessTime", align: "center" },
|
width: 360,
|
||||||
{ title: "退出品类", dataIndex: "categoryName", align: "center" },
|
ellipsis: true,
|
||||||
// { title: "最近一次评价", dataIndex: "lastEval", align: "center" },
|
render: (dom, record) => {
|
||||||
// { title: "评价时间", dataIndex: "lastEvalDate", align: "center" },
|
return (
|
||||||
|
<Tooltip>
|
||||||
|
<a onClick={() => supplierDetailModal?.(record.supplierId)}>{record.supplierName || ''}</a>
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ title: "准入部门", dataIndex: "deptId", align: "center", width: 160 },
|
||||||
|
{ title: "退出品类", dataIndex: "categoryName", align: "center", width: 160 },
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -78,7 +89,7 @@ const ViewBlacklistModal: React.FC<ViewBlacklistModalProps> = ({
|
|||||||
title="供应商退出详情"
|
title="供应商退出详情"
|
||||||
visible={visible}
|
visible={visible}
|
||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
width={900}
|
width='80%'
|
||||||
footer={<Button onClick={onCancel}>关闭</Button>}
|
footer={<Button onClick={onCancel}>关闭</Button>}
|
||||||
destroyOnClose
|
destroyOnClose
|
||||||
bodyStyle={{ padding: "36px 36px 16px" }}
|
bodyStyle={{ padding: "36px 36px 16px" }}
|
||||||
@ -103,7 +114,7 @@ const ViewBlacklistModal: React.FC<ViewBlacklistModalProps> = ({
|
|||||||
rowKey="id"
|
rowKey="id"
|
||||||
bordered
|
bordered
|
||||||
pagination={false}
|
pagination={false}
|
||||||
style={{ flex: 1, minHeight: 0 }}
|
style={{ flex: 1, minHeight: 'calc(100vh - 650px)' }}
|
||||||
scroll={{ y: 'calc(100vh - 650px)' }}
|
scroll={{ y: 'calc(100vh - 650px)' }}
|
||||||
/>
|
/>
|
||||||
</Spin>
|
</Spin>
|
||||||
@ -111,4 +122,4 @@ const ViewBlacklistModal: React.FC<ViewBlacklistModalProps> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ViewBlacklistModal;
|
export default connect()(ViewBlacklistModal);
|
||||||
|
@ -5,6 +5,7 @@ import type { ColumnsType } from 'antd/es/table';
|
|||||||
//组件
|
//组件
|
||||||
import CreateBlacklistModal from './components/CreateBlacklistModal'
|
import CreateBlacklistModal from './components/CreateBlacklistModal'
|
||||||
import ViewBlacklistModal from './components/ViewBlacklistModal';
|
import ViewBlacklistModal from './components/ViewBlacklistModal';
|
||||||
|
import AccessDepartmentSelect from "@/components/AccessDepartmentSelect"
|
||||||
//接口
|
//接口
|
||||||
import { getDictList } from '@/servers/api/dicts'
|
import { getDictList } from '@/servers/api/dicts'
|
||||||
import { getPage } from './services'
|
import { getPage } from './services'
|
||||||
@ -122,6 +123,7 @@ const supplierExitManage: React.FC = () => {
|
|||||||
<Input placeholder="请输入供应商名称关键字" style={{ width: 150 }} allowClear maxLength={50} />
|
<Input placeholder="请输入供应商名称关键字" style={{ width: 150 }} allowClear maxLength={50} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="deptId" label="发起单位">
|
<Form.Item name="deptId" label="发起单位">
|
||||||
|
<AccessDepartmentSelect placeholder={'请选择发起单位'} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="approveStatus" label="审批记录状态">
|
<Form.Item name="approveStatus" label="审批记录状态">
|
||||||
<Select style={{ width: 150 }} placeholder="请选择审批记录状态" allowClear>
|
<Select style={{ width: 150 }} placeholder="请选择审批记录状态" allowClear>
|
||||||
@ -130,12 +132,9 @@ const supplierExitManage: React.FC = () => {
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item name="time" label="发起时间">
|
<Form.Item name="time" label="发起时间">
|
||||||
<DatePicker.RangePicker style={{ width: 220 }} allowClear />
|
<DatePicker.RangePicker style={{ width: 220 }} allowClear />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
|
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button className="buttonSubmit" type="primary" htmlType="submit" icon={<SearchOutlined />} onClick={handleSearch} >
|
<Button className="buttonSubmit" type="primary" htmlType="submit" icon={<SearchOutlined />} onClick={handleSearch} >
|
||||||
搜索
|
搜索
|
||||||
@ -144,7 +143,6 @@ const supplierExitManage: React.FC = () => {
|
|||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button className="buttonReset" icon={<DeleteOutlined />} onClick={handleReset} >重置</Button>
|
<Button className="buttonReset" icon={<DeleteOutlined />} onClick={handleReset} >重置</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item style={{ marginLeft: 'auto' }}>
|
<Form.Item style={{ marginLeft: 'auto' }}>
|
||||||
<Button className="buttonFunctionBlock" type="primary" onClick={handleApply} >
|
<Button className="buttonFunctionBlock" type="primary" onClick={handleApply} >
|
||||||
发起申请
|
发起申请
|
||||||
|
Reference in New Issue
Block a user