fix(api):update store
This commit is contained in:
parent
dc86692261
commit
836806a12c
|
@ -10,12 +10,14 @@ export enum FormType {
|
|||
cehckbox = "checkbox",
|
||||
password = "password",
|
||||
}
|
||||
|
||||
export interface FormDatas {
|
||||
type: string,
|
||||
label: string,
|
||||
name: string,
|
||||
value: any,
|
||||
selectUrl?: string,
|
||||
selectList?: Array<selectItem>
|
||||
rules: Array<rules>
|
||||
}
|
||||
|
||||
|
@ -37,3 +39,9 @@ export interface rules {
|
|||
required: boolean,
|
||||
message: string,
|
||||
}
|
||||
|
||||
|
||||
export interface selectItem {
|
||||
name: string,
|
||||
id: number,
|
||||
}
|
|
@ -4,21 +4,23 @@ import { useEffect, useState } from "react";
|
|||
import baseHttp from "@/service/base";
|
||||
const { Option } = Select;
|
||||
export const FormSelect = (v: FormDatas) => {
|
||||
const [list, setList] = useState([]);
|
||||
const [list, setList] = useState<any>([]);
|
||||
useEffect(() => {
|
||||
baseHttp
|
||||
.get(`${v.selectUrl}/?size=100&offset=1` ?? "", "")
|
||||
.then((res) => {
|
||||
if (v.selectList && v.selectList.length > 0) {
|
||||
setList(v.selectList);
|
||||
} else {
|
||||
baseHttp.get(`${v.selectUrl}/?size=50&offset=1` ?? "", "").then((res) => {
|
||||
setList(res.data.record ?? []);
|
||||
});
|
||||
}, [v.selectUrl]);
|
||||
}
|
||||
}, [v.selectUrl, v.selectList]);
|
||||
return (
|
||||
<Form.Item key={v.label} label={v.label} name={v.name} rules={v.rules}>
|
||||
<Select placeholder="">
|
||||
{list?.map((v: any) => {
|
||||
return (
|
||||
<Option key={v.id} value={v.id}>
|
||||
{v.dep_name}
|
||||
{v.name}
|
||||
</Option>
|
||||
);
|
||||
})}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Content, Header } from "antd/es/layout/layout";
|
|||
import "./layout.less";
|
||||
import { Menu } from "antd";
|
||||
import { Footer } from "antd/lib/layout/layout";
|
||||
import { Outlet, useNavigate } from "react-router";
|
||||
import { Outlet, useLocation, useNavigate } from "react-router";
|
||||
import { HomeTwoTone } from "@ant-design/icons";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { Store } from "antd/es/form/interface";
|
||||
|
@ -10,11 +10,14 @@ import { useEffect } from "react";
|
|||
const LayOut = (props: Store) => {
|
||||
const { usrStore } = props;
|
||||
const nav = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
if (usrStore.isNeedLogin) {
|
||||
nav("/login");
|
||||
}
|
||||
}, [usrStore,nav]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [usrStore.isNeedLogin]);
|
||||
const items = [
|
||||
{
|
||||
key: "/admin/user",
|
||||
|
@ -29,9 +32,13 @@ const LayOut = (props: Store) => {
|
|||
label: `档案管理`,
|
||||
},
|
||||
{
|
||||
key: "/admin/whseMgmt",
|
||||
key: "/admin/whse/whseMgmt",
|
||||
label: `仓库管理`,
|
||||
},
|
||||
{
|
||||
key: "/admin/materialMgmt",
|
||||
label: `物资管理`,
|
||||
},
|
||||
{
|
||||
key: "/admin/leaveApproval",
|
||||
label: `请假审批`,
|
||||
|
@ -44,10 +51,7 @@ const LayOut = (props: Store) => {
|
|||
key: `/admin/polRegulations`,
|
||||
label: `政治法规管理`,
|
||||
},
|
||||
{
|
||||
key: "/admin/materialMgmt",
|
||||
label: `物资管理`,
|
||||
},
|
||||
|
||||
{
|
||||
key: "/admin/teamMgmt",
|
||||
label: `队伍属性管理`,
|
||||
|
@ -68,6 +72,7 @@ const LayOut = (props: Store) => {
|
|||
display: "flex",
|
||||
alignItems: "center",
|
||||
padding: "0 10px",
|
||||
boxSizing: "border-box"
|
||||
}}
|
||||
>
|
||||
<HomeTwoTone
|
||||
|
@ -77,7 +82,7 @@ const LayOut = (props: Store) => {
|
|||
<Menu
|
||||
theme="dark"
|
||||
mode="horizontal"
|
||||
defaultSelectedKeys={["/admin/user"]}
|
||||
defaultSelectedKeys={[location.pathname]}
|
||||
items={items}
|
||||
onClick={(e) => {
|
||||
nav(e.key);
|
||||
|
|
|
@ -8,11 +8,12 @@ const Login = (props) => {
|
|||
const { usrStore } = props;
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
const navigate = useNavigate();
|
||||
const onFinish = (values: any) => {
|
||||
usrStore.login({
|
||||
const onFinish = async (values: any) => {
|
||||
await usrStore.login({
|
||||
userName: values.account,
|
||||
passWord: values.password,
|
||||
});
|
||||
usrStore.closeLoginDilog()
|
||||
navigate("/admin/user", { replace: true });
|
||||
};
|
||||
const onFinishFailed = () => {};
|
||||
|
|
|
@ -1,7 +1,26 @@
|
|||
import { Tabs, TabsProps } from "antd";
|
||||
import MaterialCat from "./materialCat";
|
||||
import Material from "./material";
|
||||
|
||||
const MaterialMgmt = () => {
|
||||
const onChange = (key: string) => {
|
||||
console.log(key);
|
||||
};
|
||||
const items: TabsProps['items'] = [
|
||||
{
|
||||
key: '1',
|
||||
label: '物资分类管理',
|
||||
children: <MaterialCat />,
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '物资管理',
|
||||
children: <Material />
|
||||
},
|
||||
];
|
||||
return (
|
||||
<>
|
||||
<p>MaterialMgmt</p>
|
||||
<Tabs defaultActiveKey="1" items={items} onChange={onChange} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
import { Button, Space, Modal, FormInstance } from "antd";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import BTable from "@/components/b_table";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Store } from "antd/lib/form/interface";
|
||||
import SimpleForm from "@/components/form/simple_form";
|
||||
import React from "react";
|
||||
import { columns, defaultConfig } from "./material_column";
|
||||
|
||||
const Material = (props: Store) => {
|
||||
const { materialStore } = props;
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const [projectConfig, setProjectConfig] = useState<any>([]);
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
const [record, setRecord] = useState<any>(null);
|
||||
useEffect(() => {
|
||||
materialStore.getlist();
|
||||
setProjectConfig(defaultConfig);
|
||||
}, [materialStore]);
|
||||
const column_widget = (any, record) => {
|
||||
return (
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="dashed"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
edit(record);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="dashed"
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => {
|
||||
materialStore.deleteItem(record.id);
|
||||
}}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
const edit = (record) => {
|
||||
setIsModalOpen(true);
|
||||
setRecord(record);
|
||||
};
|
||||
const onFinish = (values: any) => {
|
||||
let data = {
|
||||
...values,
|
||||
pid:values.pid??0
|
||||
};
|
||||
if (!record?.id) {
|
||||
materialStore.add(data);
|
||||
} else {
|
||||
materialStore.putItem(record.id, data);
|
||||
}
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
|
||||
const onFinishFailed = () => {};
|
||||
return (
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<Space direction="horizontal" size={"middle"}>
|
||||
<Button
|
||||
type="default"
|
||||
onClick={() => {
|
||||
setRecord(null);
|
||||
setProjectConfig(defaultConfig);
|
||||
setIsModalOpen(true);
|
||||
}}
|
||||
>
|
||||
添加物资
|
||||
</Button>
|
||||
</Space>
|
||||
<BTable
|
||||
store={materialStore}
|
||||
columns={[
|
||||
...columns,
|
||||
{
|
||||
title: "操作",
|
||||
dataIndex: "id",
|
||||
ellipsis: {
|
||||
showTitle: false,
|
||||
},
|
||||
render: (any, record) => column_widget(any, record),
|
||||
},
|
||||
]}
|
||||
dataSource={materialStore.list}
|
||||
/>
|
||||
<Modal
|
||||
title={!record?.id ? "添加物资" : "编辑物资"}
|
||||
width={1200}
|
||||
open={isModalOpen}
|
||||
afterClose={() => formRef.current?.resetFields()}
|
||||
onOk={() => formRef.current?.submit()}
|
||||
onCancel={() => {
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<SimpleForm
|
||||
formRef={formRef}
|
||||
createCallback={() => {
|
||||
if (record?.id) {
|
||||
formRef.current?.setFieldsValue(record);
|
||||
} else {
|
||||
formRef.current?.setFieldsValue(null);
|
||||
}
|
||||
}}
|
||||
formName="card_basic"
|
||||
colProps={25}
|
||||
subBtnName="提交"
|
||||
formDatas={projectConfig}
|
||||
onFinish={onFinish}
|
||||
initialValues={true}
|
||||
onFinishFailed={onFinishFailed}
|
||||
/>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject("materialStore")(observer(Material));
|
|
@ -0,0 +1,127 @@
|
|||
import { Button, Space, Modal, FormInstance } from "antd";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import BTable from "@/components/b_table";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Store } from "antd/lib/form/interface";
|
||||
import SimpleForm from "@/components/form/simple_form";
|
||||
import React from "react";
|
||||
import { columns, defaultConfig } from "./mcat_column";
|
||||
|
||||
const MaterialCat = (props: Store) => {
|
||||
const { materialCatStore } = props;
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const [projectConfig, setProjectConfig] = useState<any>([]);
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
const [record, setRecord] = useState<any>(null);
|
||||
useEffect(() => {
|
||||
materialCatStore.getlist();
|
||||
setProjectConfig(defaultConfig);
|
||||
}, [materialCatStore]);
|
||||
const column_widget = (any, record) => {
|
||||
return (
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="dashed"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
edit(record);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="dashed"
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => {
|
||||
materialCatStore.deleteItem(record.id);
|
||||
}}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
const edit = (record) => {
|
||||
setIsModalOpen(true);
|
||||
setRecord(record);
|
||||
};
|
||||
const onFinish = (values: any) => {
|
||||
let data = {
|
||||
...values,
|
||||
pid:values.pid??0
|
||||
};
|
||||
if (!record?.id) {
|
||||
materialCatStore.add(data);
|
||||
} else {
|
||||
materialCatStore.putItem(record.id, data);
|
||||
}
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
|
||||
const onFinishFailed = () => {};
|
||||
return (
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<Space direction="horizontal" size={"middle"}>
|
||||
<Button
|
||||
type="default"
|
||||
onClick={() => {
|
||||
setRecord(null);
|
||||
setProjectConfig(defaultConfig);
|
||||
setIsModalOpen(true);
|
||||
}}
|
||||
>
|
||||
添加物资分类
|
||||
</Button>
|
||||
</Space>
|
||||
<BTable
|
||||
store={materialCatStore}
|
||||
columns={[
|
||||
...columns,
|
||||
{
|
||||
title: "操作",
|
||||
dataIndex: "id",
|
||||
ellipsis: {
|
||||
showTitle: false,
|
||||
},
|
||||
render: (any, record) => column_widget(any, record),
|
||||
},
|
||||
]}
|
||||
dataSource={materialCatStore.list}
|
||||
/>
|
||||
<Modal
|
||||
title={!record?.id ? "添加个人属性" : "编辑个人属性"}
|
||||
width={1200}
|
||||
open={isModalOpen}
|
||||
afterClose={() => formRef.current?.resetFields()}
|
||||
onOk={() => formRef.current?.submit()}
|
||||
onCancel={() => {
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<SimpleForm
|
||||
formRef={formRef}
|
||||
createCallback={() => {
|
||||
if (record?.id) {
|
||||
formRef.current?.setFieldsValue(record);
|
||||
} else {
|
||||
formRef.current?.setFieldsValue(null);
|
||||
}
|
||||
}}
|
||||
formName="card_basic"
|
||||
colProps={25}
|
||||
subBtnName="提交"
|
||||
formDatas={projectConfig}
|
||||
onFinish={onFinish}
|
||||
initialValues={true}
|
||||
onFinishFailed={onFinishFailed}
|
||||
/>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject("materialCatStore")(observer(MaterialCat));
|
|
@ -0,0 +1,89 @@
|
|||
import { FormType } from "@/components/form/interface";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ColumnsType } from "antd/lib/table";
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
{
|
||||
title: "物资名称",
|
||||
dataIndex: "name",
|
||||
},
|
||||
{
|
||||
title: "物资描述",
|
||||
dataIndex: "desc",
|
||||
},
|
||||
{
|
||||
title: "过期时间",
|
||||
dataIndex: "storage_identity",
|
||||
},
|
||||
{
|
||||
title: "货架名称",
|
||||
dataIndex: "expiry_date",
|
||||
},
|
||||
{
|
||||
title: "货架位置",
|
||||
dataIndex: "storage_cloumn",
|
||||
},
|
||||
{
|
||||
title: "所属仓库",
|
||||
dataIndex: "expiry_date",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig = [
|
||||
{
|
||||
type: FormType.select,
|
||||
label: "所属仓库",
|
||||
name: "stash_identity",
|
||||
value: "",
|
||||
selectUrl:"storage/list",
|
||||
rules: [{ required: true, message: "请输入物资名称!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "所属货架",
|
||||
name: "storage_identity",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请选择货架!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "货架位置",
|
||||
name: "storage_cloumn",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请选择货架位置!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.select,
|
||||
label: "物资分类",
|
||||
name: "catory_identity",
|
||||
value: 0,
|
||||
selectUrl:"suppliesCat/list",
|
||||
rules: [{ required: true, message: "请选择物资分类!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "物资名称",
|
||||
name: "name",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入物资名称!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "物资描述",
|
||||
name: "desc",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入物资描述!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.date,
|
||||
label: "过期时间",
|
||||
name: "expiry_date",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请选择过期时间!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.upload,
|
||||
label: "物资图片",
|
||||
name: "supplie_piker",
|
||||
value: "",
|
||||
},
|
||||
];
|
|
@ -0,0 +1,38 @@
|
|||
import { FormType } from "@/components/form/interface";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ColumnsType } from "antd/lib/table";
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
{
|
||||
title: "分类名称",
|
||||
dataIndex: "name",
|
||||
},
|
||||
{
|
||||
title: "分类描述",
|
||||
dataIndex: "desc",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig = [
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "分类名称",
|
||||
name: "name",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入仓库名称!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.select,
|
||||
label: "上级分类",
|
||||
name: "pid",
|
||||
value: 0,
|
||||
selectUrl:"suppliesCat/list",
|
||||
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "分类描述",
|
||||
name: "desc",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入仓库位置信息!" }],
|
||||
},
|
||||
];
|
|
@ -1,10 +1,128 @@
|
|||
const PersMgmt = () => {
|
||||
import { Button, Space, Modal, FormInstance } from "antd";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import BTable from "@/components/b_table";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Store } from "antd/lib/form/interface";
|
||||
import SimpleForm from "@/components/form/simple_form";
|
||||
import React from "react";
|
||||
import { columns, defaultConfig } from "./pers_column";
|
||||
|
||||
const PersMgmt = (props: Store) => {
|
||||
const { persMgmtStore } = props;
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const [projectConfig, setProjectConfig] = useState<any>([]);
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
const [record, setRecord] = useState<any>(null);
|
||||
useEffect(() => {
|
||||
persMgmtStore.getlist();
|
||||
setProjectConfig(defaultConfig);
|
||||
}, [persMgmtStore]);
|
||||
const column_widget = (any, record) => {
|
||||
return (
|
||||
<>
|
||||
<p>PersMgmt</p>
|
||||
</>
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="dashed"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
edit(record);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="dashed"
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => {
|
||||
persMgmtStore.deleteItem(record.id);
|
||||
}}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
const edit = (record) => {
|
||||
setIsModalOpen(true);
|
||||
setRecord(record);
|
||||
};
|
||||
const onFinish = (values: any) => {
|
||||
let data = {
|
||||
...values,
|
||||
score: Number(values.score),
|
||||
};
|
||||
data.file_url = "";
|
||||
if (!record?.id) {
|
||||
persMgmtStore.add(data);
|
||||
} else {
|
||||
persMgmtStore.putItem(record.id, data);
|
||||
}
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
|
||||
const onFinishFailed = () => {};
|
||||
return (
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<Space direction="horizontal" size={"middle"}>
|
||||
<Button
|
||||
type="default"
|
||||
onClick={() => {
|
||||
setRecord(null);
|
||||
setProjectConfig(defaultConfig);
|
||||
setIsModalOpen(true);
|
||||
}}
|
||||
>
|
||||
添加个人属性
|
||||
</Button>
|
||||
</Space>
|
||||
<BTable
|
||||
store={persMgmtStore}
|
||||
columns={[
|
||||
...columns,
|
||||
{
|
||||
title: "操作",
|
||||
dataIndex: "id",
|
||||
ellipsis: {
|
||||
showTitle: false,
|
||||
},
|
||||
render: (any, record) => column_widget(any, record),
|
||||
},
|
||||
]}
|
||||
dataSource={persMgmtStore.list}
|
||||
/>
|
||||
<Modal
|
||||
title={!record?.id ? "添加个人属性" : "编辑个人属性"}
|
||||
width={1200}
|
||||
open={isModalOpen}
|
||||
afterClose={() => formRef.current?.resetFields()}
|
||||
onOk={() => formRef.current?.submit()}
|
||||
onCancel={() => {
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<SimpleForm
|
||||
formRef={formRef}
|
||||
createCallback={() => {
|
||||
if (record?.id) {
|
||||
formRef.current?.setFieldsValue(record);
|
||||
} else {
|
||||
formRef.current?.setFieldsValue(null);
|
||||
}
|
||||
}}
|
||||
formName="card_basic"
|
||||
colProps={25}
|
||||
subBtnName="提交"
|
||||
formDatas={projectConfig}
|
||||
onFinish={onFinish}
|
||||
initialValues={true}
|
||||
onFinishFailed={onFinishFailed}
|
||||
/>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PersMgmt;
|
||||
|
||||
export default inject("persMgmtStore")(observer(PersMgmt));
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import { FormType } from "@/components/form/interface";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ColumnsType } from "antd/lib/table";
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
{
|
||||
title: "个人属性名称",
|
||||
dataIndex: "name",
|
||||
},
|
||||
{
|
||||
title: "个人属性描述",
|
||||
dataIndex: "desc",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig = [
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "个人属性名称",
|
||||
name: "name",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入仓库名称!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "个人属性描述",
|
||||
name: "desc",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入仓库位置信息!" }],
|
||||
},
|
||||
];
|
|
@ -0,0 +1,130 @@
|
|||
import { Button, Space, Modal, FormInstance } from "antd";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import BTable from "@/components/b_table";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Store } from "antd/lib/form/interface";
|
||||
import SimpleForm from "@/components/form/simple_form";
|
||||
import React from "react";
|
||||
import { columns, defaultConfig } from "./storage_column";
|
||||
import { useParams } from "react-router";
|
||||
|
||||
const Storage = (props: Store) => {
|
||||
const { storageStore } = props;
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const [projectConfig, setProjectConfig] = useState<any>([]);
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
const [record, setRecord] = useState<any>(null);
|
||||
const { id } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
storageStore.getlist({ stash_identity: id });
|
||||
}, [id, storageStore]);
|
||||
const column_widget = (any, record) => {
|
||||
return (
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="dashed"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
edit(record);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="dashed"
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => {
|
||||
storageStore.deleteItem(record.id);
|
||||
}}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
const edit = (record) => {
|
||||
setIsModalOpen(true);
|
||||
setRecord(record);
|
||||
};
|
||||
const onFinish = (values: any) => {
|
||||
let data = {
|
||||
...values,
|
||||
column_all_num: Number(values.column_all_num),
|
||||
stash_identity: id,
|
||||
};
|
||||
if (!record?.id) {
|
||||
storageStore.add(data,{stash_identity:id});
|
||||
} else {
|
||||
storageStore.putItem(record.id, data,{stash_identity:id});
|
||||
}
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
|
||||
const onFinishFailed = () => {};
|
||||
return (
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<Space direction="horizontal" size={"middle"}>
|
||||
<Button
|
||||
type="default"
|
||||
onClick={() => {
|
||||
setRecord(null);
|
||||
setProjectConfig(defaultConfig);
|
||||
setIsModalOpen(true);
|
||||
}}
|
||||
>
|
||||
添加货架
|
||||
</Button>
|
||||
</Space>
|
||||
<BTable
|
||||
store={storageStore}
|
||||
columns={[
|
||||
...columns,
|
||||
{
|
||||
title: "操作",
|
||||
dataIndex: "id",
|
||||
ellipsis: {
|
||||
showTitle: false,
|
||||
},
|
||||
render: (any, record) => column_widget(any, record),
|
||||
},
|
||||
]}
|
||||
dataSource={storageStore.list}
|
||||
/>
|
||||
<Modal
|
||||
title={!record?.id ? "添加个人属性" : "编辑个人属性"}
|
||||
width={1200}
|
||||
open={isModalOpen}
|
||||
afterClose={() => formRef.current?.resetFields()}
|
||||
onOk={() => formRef.current?.submit()}
|
||||
onCancel={() => {
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<SimpleForm
|
||||
formRef={formRef}
|
||||
createCallback={() => {
|
||||
if (record?.id) {
|
||||
formRef.current?.setFieldsValue(record);
|
||||
} else {
|
||||
formRef.current?.setFieldsValue(null);
|
||||
}
|
||||
}}
|
||||
formName="card_basic"
|
||||
colProps={25}
|
||||
subBtnName="提交"
|
||||
formDatas={projectConfig}
|
||||
onFinish={onFinish}
|
||||
initialValues={true}
|
||||
onFinishFailed={onFinishFailed}
|
||||
/>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject("storageStore")(observer(Storage));
|
|
@ -0,0 +1,41 @@
|
|||
import { FormType } from "@/components/form/interface";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ColumnsType } from "antd/lib/table";
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
{
|
||||
title: "货架名称",
|
||||
dataIndex: "name",
|
||||
},
|
||||
{
|
||||
title: "货架描述",
|
||||
dataIndex: "desc",
|
||||
},
|
||||
{
|
||||
title: "货架总层数",
|
||||
dataIndex: "column_all_num",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig = [
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "货架名称",
|
||||
name: "name",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入货架名称!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "货架描述",
|
||||
name: "desc",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入货架描述!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "货架总层数",
|
||||
name: "column_all_num",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入货架总层数!" }],
|
||||
},
|
||||
];
|
|
@ -1,10 +1,128 @@
|
|||
const TeamMgmt = () => {
|
||||
import { Button, Space, Modal, FormInstance } from "antd";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import BTable from "@/components/b_table";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Store } from "antd/lib/form/interface";
|
||||
import SimpleForm from "@/components/form/simple_form";
|
||||
import React from "react";
|
||||
import { columns, defaultConfig } from "./team_column";
|
||||
|
||||
const TeamMgmt = (props: Store) => {
|
||||
const { teamStore } = props;
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const [projectConfig, setProjectConfig] = useState<any>([]);
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
const [record, setRecord] = useState<any>(null);
|
||||
useEffect(() => {
|
||||
teamStore.getlist();
|
||||
setProjectConfig(defaultConfig);
|
||||
}, [teamStore]);
|
||||
const column_widget = (any, record) => {
|
||||
return (
|
||||
<>
|
||||
<p>TeamMgmt</p>
|
||||
</>
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="dashed"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
edit(record);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type="dashed"
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => {
|
||||
teamStore.deleteItem(record.id);
|
||||
}}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
const edit = (record) => {
|
||||
setIsModalOpen(true);
|
||||
setRecord(record);
|
||||
};
|
||||
const onFinish = (values: any) => {
|
||||
let data = {
|
||||
...values,
|
||||
score: Number(values.score),
|
||||
};
|
||||
data.file_url = "";
|
||||
if (!record?.id) {
|
||||
teamStore.add(data);
|
||||
} else {
|
||||
teamStore.putItem(record.id, data);
|
||||
}
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
|
||||
const onFinishFailed = () => {};
|
||||
return (
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<Space direction="horizontal" size={"middle"}>
|
||||
<Button
|
||||
type="default"
|
||||
onClick={() => {
|
||||
setRecord(null);
|
||||
setProjectConfig(defaultConfig);
|
||||
setIsModalOpen(true);
|
||||
}}
|
||||
>
|
||||
新增团队
|
||||
</Button>
|
||||
</Space>
|
||||
<BTable
|
||||
store={teamStore}
|
||||
columns={[
|
||||
...columns,
|
||||
{
|
||||
title: "操作",
|
||||
dataIndex: "id",
|
||||
ellipsis: {
|
||||
showTitle: false,
|
||||
},
|
||||
render: (any, record) => column_widget(any, record),
|
||||
},
|
||||
]}
|
||||
dataSource={teamStore.list}
|
||||
/>
|
||||
<Modal
|
||||
title={!record?.id ? "添加团队" : "编辑团队"}
|
||||
width={1200}
|
||||
open={isModalOpen}
|
||||
afterClose={() => formRef.current?.resetFields()}
|
||||
onOk={() => formRef.current?.submit()}
|
||||
onCancel={() => {
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<SimpleForm
|
||||
formRef={formRef}
|
||||
createCallback={() => {
|
||||
if (record?.id) {
|
||||
formRef.current?.setFieldsValue(record);
|
||||
} else {
|
||||
formRef.current?.setFieldsValue(null);
|
||||
}
|
||||
}}
|
||||
formName="card_basic"
|
||||
colProps={25}
|
||||
subBtnName="提交"
|
||||
formDatas={projectConfig}
|
||||
onFinish={onFinish}
|
||||
initialValues={true}
|
||||
onFinishFailed={onFinishFailed}
|
||||
/>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TeamMgmt;
|
||||
|
||||
export default inject("teamStore")(observer(TeamMgmt));
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import { FormType } from "@/components/form/interface";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ColumnsType } from "antd/lib/table";
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
{
|
||||
title: "团队属性名称",
|
||||
dataIndex: "name",
|
||||
},
|
||||
{
|
||||
title: "团队属性描述",
|
||||
dataIndex: "desc",
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultConfig = [
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "团队属性名称",
|
||||
name: "name",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入仓库名称!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "团队属性描述",
|
||||
name: "desc",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入仓库位置信息!" }],
|
||||
},
|
||||
];
|
|
@ -6,9 +6,11 @@ import { Store } from "antd/lib/form/interface";
|
|||
import SimpleForm from "@/components/form/simple_form";
|
||||
import React from "react";
|
||||
import { columns, defaultConfig } from "./whseMgmt_column";
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
const WhseMgmt = (props: Store) => {
|
||||
const { stashStore } = props;
|
||||
const nav = useNavigate();
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const [projectConfig, setProjectConfig] = useState<any>([]);
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
|
@ -20,10 +22,22 @@ const WhseMgmt = (props: Store) => {
|
|||
const column_widget = (any, record) => {
|
||||
return (
|
||||
<Space wrap>
|
||||
<Button type="dashed" size="small" onClick={() => {}}>
|
||||
<Button
|
||||
type="dashed"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
nav("/admin/whse/storage/" + record.identity);
|
||||
}}
|
||||
>
|
||||
货架管理
|
||||
</Button>
|
||||
<Button type="dashed" size="small" onClick={()=>{edit(record)}}>
|
||||
<Button
|
||||
type="dashed"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
edit(record);
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
|
||||
|
@ -90,7 +104,7 @@ const WhseMgmt = (props: Store) => {
|
|||
dataSource={stashStore.list}
|
||||
/>
|
||||
<Modal
|
||||
title={!record?.id ? "添加文章" : "编辑文章"}
|
||||
title={!record?.id ? "添加仓库" : "编辑仓库"}
|
||||
width={1200}
|
||||
open={isModalOpen}
|
||||
afterClose={() => formRef.current?.resetFields()}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import { Outlet } from "react-router";
|
||||
|
||||
const WhseMgmtRoute = () => {
|
||||
return (
|
||||
<>
|
||||
<Outlet />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default WhseMgmtRoute
|
|
@ -11,6 +11,8 @@ import Tag from "@/pages/tag/tag";
|
|||
import TeamMgmt from "@/pages/teamMgmt";
|
||||
import User from "@/pages/user/user";
|
||||
import WhseMgmt from "@/pages/whseMgmt";
|
||||
import Storage from "@/pages/storage";
|
||||
import WhseMgmtRoute from "@/pages/whseMgmt/whseMgmt_route";
|
||||
export const homeRouter = [
|
||||
{
|
||||
path: "/",
|
||||
|
@ -77,10 +79,22 @@ export const homeRouter = [
|
|||
element: <TeamMgmt />,
|
||||
},
|
||||
{
|
||||
path: "/admin/whseMgmt",
|
||||
path: "/admin/whse",
|
||||
element: <WhseMgmtRoute />,
|
||||
children:[
|
||||
{
|
||||
path: "/admin/whse/whseMgmt",
|
||||
index: true,
|
||||
element: <WhseMgmt />,
|
||||
},
|
||||
{
|
||||
path: "/admin/whse/storage/:id",
|
||||
index: true,
|
||||
element: <Storage />,
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -24,6 +24,7 @@ axios.interceptors.response.use((res: AxiosResponse) => {
|
|||
}
|
||||
return res;
|
||||
}, (err) => {
|
||||
console.log(err.status===401);
|
||||
if (err.status === 401) {
|
||||
store.usrStore.openLoginDilog()
|
||||
store.usrStore.logOut()
|
||||
|
|
|
@ -38,7 +38,7 @@ class BaseStore<B> implements BaseStoreInterface<B> {
|
|||
await baseHttp.delete(this.urlConfig.DELETE + "/" + id, {})
|
||||
this.getlist()
|
||||
} catch (error) {
|
||||
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
// 分页
|
||||
|
@ -47,32 +47,33 @@ class BaseStore<B> implements BaseStoreInterface<B> {
|
|||
this.getlist()
|
||||
}
|
||||
// 添加
|
||||
async add(param: any) {
|
||||
async add(param: any,listParam?:any) {
|
||||
try {
|
||||
await baseHttp.post(this.urlConfig.ADD, param)
|
||||
this.getlist()
|
||||
this.getlist(listParam)
|
||||
} catch (error) {
|
||||
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新
|
||||
async putItem(id: string, param: any) {
|
||||
async putItem(id: string, param: any,listParam?:any) {
|
||||
try {
|
||||
await baseHttp.put(this.urlConfig.EDIT + "/" + id, param)
|
||||
this.getlist()
|
||||
this.getlist(listParam)
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 获取列表
|
||||
async getlist() {
|
||||
async getlist(params?: any) {
|
||||
this.listStatus = true;
|
||||
try {
|
||||
let res = await baseHttp.get(this.urlConfig.LIST, {
|
||||
size: this.page?.Size | 20,
|
||||
offset: this.page?.Offset | 1,
|
||||
...params
|
||||
});
|
||||
let data: Array<B> = []
|
||||
if (!res?.data?.record) {
|
||||
|
|
|
@ -6,6 +6,11 @@ import folderStore from '@/store/folder';
|
|||
import { acStore } from '@/store/archives_category';
|
||||
import { politicalStudyStore } from "./political_study";
|
||||
import { stashStore } from "@/store/stash"
|
||||
import { teamStore } from './team';
|
||||
import { persMgmtStore } from './persMgmt';
|
||||
import { storageStore } from './storage';
|
||||
import { materialCatStore } from './materialCat';
|
||||
import { materialStore } from './materialStore';
|
||||
|
||||
const store = {
|
||||
usrStore,
|
||||
|
@ -15,7 +20,12 @@ const store = {
|
|||
folderStore,
|
||||
acStore,
|
||||
politicalStudyStore,
|
||||
stashStore
|
||||
stashStore,
|
||||
teamStore,
|
||||
persMgmtStore,
|
||||
storageStore,
|
||||
materialCatStore,
|
||||
materialStore,
|
||||
};
|
||||
|
||||
export default store;
|
|
@ -0,0 +1,19 @@
|
|||
import { makeObservable } from "mobx";
|
||||
// 用户信息
|
||||
import BaseStore from "./baseStore";
|
||||
import { TagDataType } from "@/model/userModel";
|
||||
|
||||
class MaterialCatConfig {
|
||||
static LIST: string = "suppliesCat/list"
|
||||
static ADD: string = "suppliesCat"
|
||||
static DELETE: string = "suppliesCat"
|
||||
static EDIT: string = "suppliesCat"
|
||||
}
|
||||
class MaterialCatStore extends BaseStore<TagDataType> {
|
||||
constructor() {
|
||||
super(MaterialCatConfig)
|
||||
makeObservable(this, {})
|
||||
}
|
||||
}
|
||||
|
||||
export const materialCatStore = new MaterialCatStore();
|
|
@ -0,0 +1,20 @@
|
|||
import { makeObservable } from "mobx";
|
||||
// 用户信息
|
||||
import BaseStore from "./baseStore";
|
||||
import { TagDataType } from "@/model/userModel";
|
||||
|
||||
class MaterialConfig {
|
||||
static LIST: string = "supplies/list"
|
||||
static ADD: string = "supplies"
|
||||
static DELETE: string = "supplies"
|
||||
static EDIT: string = "supplies"
|
||||
}
|
||||
class MaterialStore extends BaseStore<TagDataType> {
|
||||
constructor() {
|
||||
super(MaterialConfig)
|
||||
makeObservable(this, {})
|
||||
}
|
||||
}
|
||||
|
||||
export const materialStore = new MaterialStore();
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import { makeObservable } from "mobx";
|
||||
// 用户信息
|
||||
import BaseStore from "./baseStore";
|
||||
import { TagDataType } from "@/model/userModel";
|
||||
|
||||
class PersMgmtConfig {
|
||||
static LIST: string = "persMgmt/list"
|
||||
static ADD: string = "persMgmt"
|
||||
static DELETE: string = "persMgmt"
|
||||
static EDIT: string = "persMgmt"
|
||||
}
|
||||
class PersMgmtStore extends BaseStore<TagDataType> {
|
||||
constructor() {
|
||||
super(PersMgmtConfig)
|
||||
makeObservable(this, {})
|
||||
}
|
||||
}
|
||||
|
||||
export const persMgmtStore = new PersMgmtStore();
|
|
@ -0,0 +1,19 @@
|
|||
import { makeObservable } from "mobx";
|
||||
// 用户信息
|
||||
import BaseStore from "./baseStore";
|
||||
import { TagDataType } from "@/model/userModel";
|
||||
|
||||
class StoreageConfig {
|
||||
static LIST: string = "storage/list"
|
||||
static ADD: string = "storage"
|
||||
static DELETE: string = "storage"
|
||||
static EDIT: string = "storage"
|
||||
}
|
||||
class StorageStore extends BaseStore<TagDataType> {
|
||||
constructor() {
|
||||
super(StoreageConfig)
|
||||
makeObservable(this, {})
|
||||
}
|
||||
}
|
||||
|
||||
export const storageStore = new StorageStore();
|
|
@ -0,0 +1,19 @@
|
|||
import { makeObservable } from "mobx";
|
||||
// 用户信息
|
||||
import BaseStore from "./baseStore";
|
||||
import { TagDataType } from "@/model/userModel";
|
||||
|
||||
class TeamConfig {
|
||||
static LIST: string = "team/list"
|
||||
static ADD: string = "team"
|
||||
static DELETE: string = "team"
|
||||
static EDIT: string = "team"
|
||||
}
|
||||
class TeamStore extends BaseStore<TagDataType> {
|
||||
constructor() {
|
||||
super(TeamConfig)
|
||||
makeObservable(this, {})
|
||||
}
|
||||
}
|
||||
|
||||
export const teamStore = new TeamStore();
|
Loading…
Reference in New Issue