fix(api):update store
This commit is contained in:
parent
193d88f09c
commit
53bb00191f
29
src/App.tsx
29
src/App.tsx
|
@ -1,8 +1,31 @@
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
import "antd/dist/antd.css";
|
import "antd/dist/antd.css";
|
||||||
import Home from "./pages/home/home";
|
// import Home from "./pages/home/home";
|
||||||
const App = (props: any) => {
|
import { Modal } from "antd";
|
||||||
return <Home />
|
import { Store } from "antd/lib/form/interface";
|
||||||
|
import { Outlet } from "react-router";
|
||||||
|
const App = (props: Store) => {
|
||||||
|
const { usrStore } = props;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Outlet/>
|
||||||
|
<Modal
|
||||||
|
title="登录"
|
||||||
|
className="owner_model"
|
||||||
|
width={"50%"}
|
||||||
|
open={usrStore.isNeedLogin}
|
||||||
|
afterClose={() => {}}
|
||||||
|
onOk={() => {
|
||||||
|
usrStore.closeLoginDilog();
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
usrStore.closeLoginDilog();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<p>cascsa</p>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default inject("usrStore")(observer(App));
|
export default inject("usrStore")(observer(App));
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import ossClie from "@/util/oss";
|
|
||||||
import Modal from "antd/lib/modal";
|
import Modal from "antd/lib/modal";
|
||||||
import { PlusOutlined } from "@ant-design/icons";
|
import { PlusOutlined } from "@ant-design/icons";
|
||||||
import Upload, { RcFile, UploadFile, UploadProps } from "antd/lib/upload";
|
import Upload, { RcFile, UploadFile, UploadProps } from "antd/lib/upload";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import baseHttp from "@/service/base";
|
|
||||||
import SystemConfig from "@/service/apiConfig/system_config";
|
|
||||||
|
|
||||||
interface UploadFileProps {
|
interface UploadFileProps {
|
||||||
imgList: Array<UploadFileEx>;
|
imgList: Array<UploadFileEx>;
|
||||||
|
@ -25,11 +22,11 @@ const getBase64 = (file: RcFile): Promise<string> =>
|
||||||
reader.onerror = (error) => reject(error);
|
reader.onerror = (error) => reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
const AliUpload = (props:UploadFileProps) => {
|
const AliUpload = (props: UploadFileProps) => {
|
||||||
const [previewOpen, setPreviewOpen] = useState(false);
|
const [previewOpen, setPreviewOpen] = useState(false);
|
||||||
const [previewImage, setPreviewImage] = useState("");
|
const [previewImage, setPreviewImage] = useState("");
|
||||||
const [previewTitle, setPreviewTitle] = useState("");
|
const [previewTitle, setPreviewTitle] = useState("");
|
||||||
const [fileList, setFileList] = useState<UploadFile[]>([]);
|
const [files, setFileList] = useState<UploadFile[]>([]);
|
||||||
const handleCancel = () => setPreviewOpen(false);
|
const handleCancel = () => setPreviewOpen(false);
|
||||||
const handlePreview = async (file: UploadFile) => {
|
const handlePreview = async (file: UploadFile) => {
|
||||||
if (!file.url && !file.preview) {
|
if (!file.url && !file.preview) {
|
||||||
|
@ -47,30 +44,7 @@ const AliUpload = (props:UploadFileProps) => {
|
||||||
}, [props.imgList]);
|
}, [props.imgList]);
|
||||||
|
|
||||||
const handleChange: UploadProps["onChange"] = ({ fileList: newFileList }) => {
|
const handleChange: UploadProps["onChange"] = ({ fileList: newFileList }) => {
|
||||||
let isChange: Boolean = false;
|
console.log(newFileList);
|
||||||
newFileList.forEach(async (item) => {
|
|
||||||
if (item.originFileObj) {
|
|
||||||
isChange = true;
|
|
||||||
await ossClie(newFileList[newFileList.length - 1].originFileObj).then(
|
|
||||||
(resUploadFileEx: UploadFileEx) => {
|
|
||||||
resUploadFileEx.uid = resUploadFileEx.name;
|
|
||||||
resUploadFileEx.bannerName = resUploadFileEx.name;
|
|
||||||
baseHttp.post( SystemConfig.AddImages, { url: resUploadFileEx.url }).then((resp)=>{
|
|
||||||
resUploadFileEx.systemImageId = resp.data.id;
|
|
||||||
resUploadFileEx.id = resp.data.id;
|
|
||||||
resUploadFileEx.redictUrl = "";
|
|
||||||
fileList.push(resUploadFileEx);
|
|
||||||
props.onChnage(fileList);
|
|
||||||
setFileList(fileList);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!isChange) {
|
|
||||||
props.onChnage(newFileList);
|
|
||||||
setFileList(newFileList);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const uploadButton = (
|
const uploadButton = (
|
||||||
<div>
|
<div>
|
||||||
|
@ -78,15 +52,17 @@ const AliUpload = (props:UploadFileProps) => {
|
||||||
<div style={{ marginTop: 8 }}>Upload</div>
|
<div style={{ marginTop: 8 }}>Upload</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ margin: 10 }}>
|
<div style={{ margin: 10 }}>
|
||||||
<Upload
|
<Upload
|
||||||
listType="picture-card"
|
listType="picture-card"
|
||||||
fileList={fileList}
|
fileList={files}
|
||||||
|
action={"http://127.0.0.1:12214/v1/public/fts/upload"}
|
||||||
onPreview={handlePreview}
|
onPreview={handlePreview}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
>
|
>
|
||||||
{fileList.length >= 4 ? null : uploadButton}
|
{files.length >= 4 ? null : uploadButton}
|
||||||
</Upload>
|
</Upload>
|
||||||
<Modal
|
<Modal
|
||||||
open={previewOpen}
|
open={previewOpen}
|
||||||
|
|
|
@ -9,7 +9,7 @@ export const FormSelect = (v: FormDatas) => {
|
||||||
baseHttp
|
baseHttp
|
||||||
.get(`${v.selectUrl}/?pageSize=100&pageNum=1` ?? "", "")
|
.get(`${v.selectUrl}/?pageSize=100&pageNum=1` ?? "", "")
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setList(res.data.list ?? []);
|
setList(res.data.record ?? []);
|
||||||
});
|
});
|
||||||
}, [v.selectUrl]);
|
}, [v.selectUrl]);
|
||||||
return (
|
return (
|
||||||
|
@ -18,7 +18,7 @@ export const FormSelect = (v: FormDatas) => {
|
||||||
{list?.map((v: any) => {
|
{list?.map((v: any) => {
|
||||||
return (
|
return (
|
||||||
<Option key={v.id} value={v.id}>
|
<Option key={v.id} value={v.id}>
|
||||||
{v.productTypeName}
|
{v.dep_name}
|
||||||
</Option>
|
</Option>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -31,13 +31,7 @@ const SimpleForm = (props: SimpleFormData) => {
|
||||||
switch (v.type) {
|
switch (v.type) {
|
||||||
case "input":
|
case "input":
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item key={v.label} label={v.label} name={v.name} rules={v.rules}>
|
||||||
key={v.label}
|
|
||||||
label={v.label}
|
|
||||||
name={v.name}
|
|
||||||
rules={v.rules}
|
|
||||||
|
|
||||||
>
|
|
||||||
<Input defaultValue={v.value} value={v.value} />
|
<Input defaultValue={v.value} value={v.value} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
|
@ -84,6 +78,7 @@ const SimpleForm = (props: SimpleFormData) => {
|
||||||
<AliUpload
|
<AliUpload
|
||||||
imgList={form.getFieldValue(v.name) ?? []}
|
imgList={form.getFieldValue(v.name) ?? []}
|
||||||
onChnage={(res) => {
|
onChnage={(res) => {
|
||||||
|
console.log(res);
|
||||||
form.setFieldValue(v.name, res);
|
form.setFieldValue(v.name, res);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -91,17 +86,8 @@ const SimpleForm = (props: SimpleFormData) => {
|
||||||
);
|
);
|
||||||
case "textArea":
|
case "textArea":
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item key={v.label} label={v.label} name={v.name} rules={v.rules}>
|
||||||
key={v.label}
|
<TextArea value={v.name} placeholder="Controlled autosize" autoSize={{ minRows: 3, maxRows: 5 }}/>
|
||||||
label={v.label}
|
|
||||||
name={v.name}
|
|
||||||
rules={v.rules}
|
|
||||||
>
|
|
||||||
<TextArea
|
|
||||||
value={v.name}
|
|
||||||
placeholder="Controlled autosize"
|
|
||||||
autoSize={{ minRows: 3, maxRows: 5 }}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
case "Radio":
|
case "Radio":
|
||||||
|
|
|
@ -3,8 +3,8 @@ let fileName = "test.tsx";
|
||||||
let path = "pages/test"
|
let path = "pages/test"
|
||||||
let storeName = "TestStore"
|
let storeName = "TestStore"
|
||||||
let className = "Test"
|
let className = "Test"
|
||||||
let str =
|
|
||||||
`
|
let str =`
|
||||||
import { Tooltip } from "antd";
|
import { Tooltip } from "antd";
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
|
|
@ -20,5 +20,13 @@ export interface UserDataType {
|
||||||
startTime: any;
|
startTime: any;
|
||||||
endTime: any;
|
endTime: any;
|
||||||
status: any;
|
status: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TagDataType {
|
||||||
|
key: React.Key;
|
||||||
|
tag_name: string;
|
||||||
|
tag_desc: string;
|
||||||
|
id: number;
|
||||||
|
status: any;
|
||||||
|
identity: string;
|
||||||
}
|
}
|
|
@ -0,0 +1,156 @@
|
||||||
|
import { Button, Space, Modal, FormInstance } from "antd";
|
||||||
|
import { inject, observer } from "mobx-react";
|
||||||
|
import type { ColumnsType } from "antd/es/table";
|
||||||
|
import BTable from "@/components/b_table";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import UserConfig from "@/service/apiConfig/user_config";
|
||||||
|
import { UserDataType } from "@/model/userModel";
|
||||||
|
import { Store } from "antd/lib/form/interface";
|
||||||
|
import SimpleForm from "@/components/form/simple_form";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const Dep = (props: Store) => {
|
||||||
|
const { depStore } = 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 [tagId, setId] = useState<Number | null>(null);
|
||||||
|
const columns: ColumnsType<UserDataType> = [
|
||||||
|
{ title: "部门名称", dataIndex: "dep_name" },
|
||||||
|
{ title: "部门描述", dataIndex: "remark" },
|
||||||
|
{
|
||||||
|
title: "操作",
|
||||||
|
dataIndex: "id",
|
||||||
|
render: (any, record) => (
|
||||||
|
<div>
|
||||||
|
<Space direction="vertical">
|
||||||
|
<Space wrap>
|
||||||
|
<Button
|
||||||
|
type="dashed"
|
||||||
|
size="small"
|
||||||
|
onClick={() => {
|
||||||
|
edit(record);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="dashed"
|
||||||
|
danger
|
||||||
|
size="small"
|
||||||
|
onClick={() => {
|
||||||
|
depStore.deleteItem(record.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const edit = (record) => {
|
||||||
|
record = {
|
||||||
|
...record,
|
||||||
|
imageUrl: [{ url: record.imageUrl }],
|
||||||
|
};
|
||||||
|
setProjectConfig(defaultConfig);
|
||||||
|
setIsModalOpen(true);
|
||||||
|
formRef.current?.setFieldsValue(record);
|
||||||
|
setRecord(record);
|
||||||
|
setId(record.id);
|
||||||
|
};
|
||||||
|
const onFinish = (values: any) => {
|
||||||
|
console.log(values);
|
||||||
|
if (!tagId) {
|
||||||
|
depStore.add(values);
|
||||||
|
} else {
|
||||||
|
depStore.putItem(tagId, values);
|
||||||
|
}
|
||||||
|
setIsModalOpen(false);
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
depStore.getlist(UserConfig.LIST);
|
||||||
|
}, [depStore]);
|
||||||
|
const defaultConfig = [
|
||||||
|
{
|
||||||
|
type: "select",
|
||||||
|
label: "上级部门名称",
|
||||||
|
name: "pdep_id",
|
||||||
|
value: "",
|
||||||
|
selectUrl: "dep/list",
|
||||||
|
rules: [{ required: false, message: "请输入上级部门!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "input",
|
||||||
|
label: "部门名称",
|
||||||
|
name: "dep_name",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入部门名称!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "input",
|
||||||
|
label: "部门描述",
|
||||||
|
name: "remark",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入部门描述" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "upload",
|
||||||
|
label: "头像",
|
||||||
|
name: "head_img",
|
||||||
|
value: [],
|
||||||
|
rules: [{ required: false }],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const onFinishFailed = () => {};
|
||||||
|
return (
|
||||||
|
<div className="contentBox">
|
||||||
|
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||||
|
<Space direction="horizontal" size={"middle"}>
|
||||||
|
<Button
|
||||||
|
type="default"
|
||||||
|
onClick={() => {
|
||||||
|
setProjectConfig(defaultConfig);
|
||||||
|
setId(null);
|
||||||
|
setIsModalOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
添加
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<BTable store={depStore} columns={columns} dataSource={depStore.list} />
|
||||||
|
<Modal
|
||||||
|
title={!tagId ? "添加部门" : "编辑部门"}
|
||||||
|
width={800}
|
||||||
|
open={isModalOpen}
|
||||||
|
afterClose={() => formRef.current?.resetFields()}
|
||||||
|
onOk={() => formRef.current?.submit()}
|
||||||
|
onCancel={() => {
|
||||||
|
setId(null);
|
||||||
|
setIsModalOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimpleForm
|
||||||
|
formRef={formRef}
|
||||||
|
createCallback={() => {
|
||||||
|
formRef.current?.setFieldsValue(record);
|
||||||
|
}}
|
||||||
|
formName="card_basic"
|
||||||
|
colProps={4}
|
||||||
|
subBtnName="提交"
|
||||||
|
formDatas={projectConfig}
|
||||||
|
onFinish={onFinish}
|
||||||
|
initialValues={true}
|
||||||
|
onFinishFailed={onFinishFailed}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default inject("depStore")(observer(Dep));
|
|
@ -1,11 +1,16 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Modal } from "antd";
|
import { Modal } from "antd";
|
||||||
import "./left.less";
|
import "./left.less";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
const HomeLeft = () => {
|
const HomeLeft = () => {
|
||||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||||
|
const navigate = useNavigate();
|
||||||
const openDispatch = () => {
|
const openDispatch = () => {
|
||||||
setIsModalOpen(true);
|
setIsModalOpen(true);
|
||||||
};
|
};
|
||||||
|
const jumpToUser = () => {
|
||||||
|
navigate("/user")
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="left_container">
|
<div className="left_container">
|
||||||
|
@ -14,7 +19,7 @@ const HomeLeft = () => {
|
||||||
<p>组织架构</p>
|
<p>组织架构</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div onClick={openDispatch} className="org">
|
<div onClick={jumpToUser} className="org">
|
||||||
<div className="org_head">
|
<div className="org_head">
|
||||||
<p>用户管理</p>
|
<p>用户管理</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,12 +29,6 @@ const HomeLeft = () => {
|
||||||
<p>HomeLeft</p>
|
<p>HomeLeft</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* <div onClick={openDispatch}>
|
|
||||||
用户管理
|
|
||||||
</div>
|
|
||||||
<div onClick={openDispatch}>
|
|
||||||
HomeLeft
|
|
||||||
</div> */}
|
|
||||||
<Modal
|
<Modal
|
||||||
title="组织架构"
|
title="组织架构"
|
||||||
className="owner_model"
|
className="owner_model"
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
import { Button, Space, Modal, FormInstance } from "antd";
|
||||||
|
import { inject, observer } from "mobx-react";
|
||||||
|
import type { ColumnsType } from "antd/es/table";
|
||||||
|
import BTable from "@/components/b_table";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import UserConfig from "@/service/apiConfig/user_config";
|
||||||
|
import { UserDataType } from "@/model/userModel";
|
||||||
|
import { Store } from "antd/lib/form/interface";
|
||||||
|
import SimpleForm from "@/components/form/simple_form";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const Tag = (props: Store) => {
|
||||||
|
const { tagStore } = 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 [tagId, setId] = useState<Number | null>(null);
|
||||||
|
const columns: ColumnsType<UserDataType> = [
|
||||||
|
{ title: "标签昵称", dataIndex: "tag_name" },
|
||||||
|
{ title: "标签描述", dataIndex: "tag_desc" },
|
||||||
|
{
|
||||||
|
title: "操作",
|
||||||
|
dataIndex: "id",
|
||||||
|
render: (any, record) => (
|
||||||
|
<div>
|
||||||
|
<Space direction="vertical">
|
||||||
|
<Space wrap>
|
||||||
|
<Button type="dashed" size="small" onClick={() => {edit(record);}}>编辑</Button>
|
||||||
|
<Button
|
||||||
|
type="dashed"
|
||||||
|
danger
|
||||||
|
size="small"
|
||||||
|
onClick={() => {
|
||||||
|
tagStore.deleteItem(record.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const edit = (record) => {
|
||||||
|
record = {
|
||||||
|
...record,
|
||||||
|
imageUrl: [{ url: record.imageUrl }],
|
||||||
|
};
|
||||||
|
setProjectConfig(defaultConfig);
|
||||||
|
setIsModalOpen(true);
|
||||||
|
formRef.current?.setFieldsValue(record);
|
||||||
|
setRecord(record);
|
||||||
|
setId(record.id);
|
||||||
|
};
|
||||||
|
const onFinish = (values: any) => {
|
||||||
|
if (!tagId) {
|
||||||
|
tagStore.add(values);
|
||||||
|
} else {
|
||||||
|
tagStore.putItem(tagId,values);
|
||||||
|
}
|
||||||
|
setIsModalOpen(false);
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
tagStore.getlist(UserConfig.LIST);
|
||||||
|
}, [tagStore]);
|
||||||
|
const defaultConfig = [
|
||||||
|
{
|
||||||
|
type: "input",
|
||||||
|
label: "标签名称",
|
||||||
|
name: "tag_name",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入标签名称!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "input",
|
||||||
|
label: "标签描述",
|
||||||
|
name: "tag_desc",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入标签描述" }],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const onFinishFailed = () => {};
|
||||||
|
return (
|
||||||
|
<div className="contentBox">
|
||||||
|
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||||
|
<Space direction="horizontal" size={"middle"}>
|
||||||
|
<Button
|
||||||
|
type="default"
|
||||||
|
onClick={() => {
|
||||||
|
setProjectConfig(defaultConfig);
|
||||||
|
setId(null);
|
||||||
|
setIsModalOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
添加
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<BTable store={tagStore} columns={columns} dataSource={tagStore.list} />
|
||||||
|
<Modal
|
||||||
|
title={!tagId ? "添加标签" : "编辑标签"}
|
||||||
|
width={800}
|
||||||
|
open={isModalOpen}
|
||||||
|
afterClose={() => formRef.current?.resetFields()}
|
||||||
|
onOk={() => formRef.current?.submit()}
|
||||||
|
onCancel={() => {
|
||||||
|
setId(null);
|
||||||
|
setIsModalOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimpleForm
|
||||||
|
formRef={formRef}
|
||||||
|
createCallback={() => {
|
||||||
|
formRef.current?.setFieldsValue(record);
|
||||||
|
}}
|
||||||
|
formName="card_basic"
|
||||||
|
colProps={4}
|
||||||
|
subBtnName="提交"
|
||||||
|
formDatas={projectConfig}
|
||||||
|
onFinish={onFinish}
|
||||||
|
initialValues={true}
|
||||||
|
onFinishFailed={onFinishFailed}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default inject("tagStore")(observer(Tag));
|
|
@ -1,4 +1,4 @@
|
||||||
import { Button, Tooltip, Image, Space, Modal, FormInstance } from "antd";
|
import { Button, Image, Space, Modal, FormInstance } from "antd";
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
import type { ColumnsType } from "antd/es/table";
|
import type { ColumnsType } from "antd/es/table";
|
||||||
import BTable from "@/components/b_table";
|
import BTable from "@/components/b_table";
|
||||||
|
@ -9,10 +9,12 @@ import { Store } from "antd/lib/form/interface";
|
||||||
import "./user.less";
|
import "./user.less";
|
||||||
import SimpleForm from "@/components/form/simple_form";
|
import SimpleForm from "@/components/form/simple_form";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
|
|
||||||
const User = (props: Store) => {
|
const User = (props: Store) => {
|
||||||
const { usrStore } = props;
|
const { usrStore } = props;
|
||||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||||
|
const nav = useNavigate()
|
||||||
const [projectConfig, setProjectConfig] = useState<any>([]);
|
const [projectConfig, setProjectConfig] = useState<any>([]);
|
||||||
const formRef = React.useRef<FormInstance>(null);
|
const formRef = React.useRef<FormInstance>(null);
|
||||||
const [record, setRecord] = useState<any>(null);
|
const [record, setRecord] = useState<any>(null);
|
||||||
|
@ -20,24 +22,12 @@ const User = (props: Store) => {
|
||||||
const columns: ColumnsType<UserDataType> = [
|
const columns: ColumnsType<UserDataType> = [
|
||||||
{
|
{
|
||||||
title: "用户名",
|
title: "用户名",
|
||||||
dataIndex: "acount",
|
dataIndex: "user_name",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "年龄",
|
title: "年龄",
|
||||||
dataIndex: "age",
|
dataIndex: "age",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "居住地",
|
|
||||||
dataIndex: "address",
|
|
||||||
ellipsis: {
|
|
||||||
showTitle: false,
|
|
||||||
},
|
|
||||||
render: (address) => (
|
|
||||||
<Tooltip placement="topLeft" title={address}>
|
|
||||||
{address}
|
|
||||||
</Tooltip>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "性别",
|
title: "性别",
|
||||||
dataIndex: "sex",
|
dataIndex: "sex",
|
||||||
|
@ -45,17 +35,16 @@ const User = (props: Store) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "头像",
|
title: "头像",
|
||||||
dataIndex: "headImg",
|
dataIndex: "head_img",
|
||||||
render: (headImg) => <Image src={headImg}></Image>,
|
render: (headImg) => <Image src={headImg}></Image>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "角色",
|
title: "职位",
|
||||||
dataIndex: "roleName",
|
dataIndex: "position",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "会员",
|
title: "备注",
|
||||||
dataIndex: "level",
|
dataIndex: "remark",
|
||||||
render: (level) => <span>{level === "0" ? "包年" : "超级会员"}</span>,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "操作",
|
title: "操作",
|
||||||
|
@ -77,9 +66,14 @@ const User = (props: Store) => {
|
||||||
编辑
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button type="dashed" danger size="small" onClick={() => {
|
<Button
|
||||||
usrStore.deleteItem(record.id)
|
type="dashed"
|
||||||
}}>
|
danger
|
||||||
|
size="small"
|
||||||
|
onClick={() => {
|
||||||
|
usrStore.deleteItem(record.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
删除
|
删除
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
|
@ -106,12 +100,11 @@ const User = (props: Store) => {
|
||||||
|
|
||||||
values = {
|
values = {
|
||||||
...values,
|
...values,
|
||||||
headImg:"cascas" //images.join(","),
|
headImg: "cascas", //images.join(","),
|
||||||
};
|
};
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
usrStore.add(values);
|
usrStore.add(values);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
setIsModalOpen(false);
|
setIsModalOpen(false);
|
||||||
};
|
};
|
||||||
|
@ -165,6 +158,7 @@ const User = (props: Store) => {
|
||||||
return (
|
return (
|
||||||
<div className="contentBox">
|
<div className="contentBox">
|
||||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||||
|
<Space direction="horizontal" size={"middle"}>
|
||||||
<Button
|
<Button
|
||||||
type="default"
|
type="default"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -175,6 +169,27 @@ const User = (props: Store) => {
|
||||||
>
|
>
|
||||||
添加用户
|
添加用户
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<Button type="default" onClick={() => {nav("/tag")}}>
|
||||||
|
标签管理
|
||||||
|
</Button>
|
||||||
|
<Button type="default" onClick={() => { nav("/dep")}}>
|
||||||
|
部门管理
|
||||||
|
</Button>
|
||||||
|
<Button type="default" onClick={() => {}}>
|
||||||
|
部门管理
|
||||||
|
</Button>
|
||||||
|
<Button type="default" onClick={() => {}}>
|
||||||
|
档案管理
|
||||||
|
</Button>
|
||||||
|
<Button type="default" onClick={() => {
|
||||||
|
nav("/warehouse")
|
||||||
|
}}>
|
||||||
|
仓库管理
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</Space>
|
||||||
|
|
||||||
<BTable store={usrStore} columns={columns} dataSource={usrStore.list} />
|
<BTable store={usrStore} columns={columns} dataSource={usrStore.list} />
|
||||||
<Modal
|
<Modal
|
||||||
title={!userId ? "添加用户" : "编辑用户"}
|
title={!userId ? "添加用户" : "编辑用户"}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
import Dep from "@/pages/dep";
|
||||||
import Home from "@/pages/home/home";
|
import Home from "@/pages/home/home";
|
||||||
|
import Tag from "@/pages/tag/tag";
|
||||||
|
import User from "@/pages/user/user";
|
||||||
export const homeRouter = [
|
export const homeRouter = [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
|
@ -11,4 +14,19 @@ export const homeRouter = [
|
||||||
index: false,
|
index: false,
|
||||||
element: <Home />
|
element: <Home />
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/user",
|
||||||
|
index: true,
|
||||||
|
element: <User />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/tag",
|
||||||
|
index: true,
|
||||||
|
element: <Tag />
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/dep",
|
||||||
|
index: true,
|
||||||
|
element: <Dep />
|
||||||
|
},
|
||||||
];
|
];
|
|
@ -1,6 +1,6 @@
|
||||||
class UserConfig {
|
class UserConfig {
|
||||||
static LOGINURI: string = "login"
|
static LOGINURI: string = "login"
|
||||||
static LIST: string = "user/list"
|
static LIST: string = "userMgmt/user/list"
|
||||||
static ADD: string = "user"
|
static ADD: string = "user"
|
||||||
static DELETE: string = "user"
|
static DELETE: string = "user"
|
||||||
static EDIT: string = "user"
|
static EDIT: string = "user"
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import axios, { AxiosResponse } from "axios";
|
import axios, { AxiosResponse } from "axios";
|
||||||
// 添加请求拦截器
|
// 添加请求拦截器
|
||||||
axios.defaults.headers.common["CommonType"] = "shouka";
|
// axios.defaults.headers.common["CommonType"] = "shouka";
|
||||||
axios.defaults.headers.common["Content-Type"] = "application/json; charset=utf8";
|
axios.defaults.headers.common["Content-Type"] = "application/json; charset=utf8";
|
||||||
|
// axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
|
||||||
axios.interceptors.request.use((config) => {
|
axios.interceptors.request.use((config) => {
|
||||||
config.baseURL = "http://quwanya.cn:8899/v1/api/";
|
config.baseURL = "http://127.0.0.1:12214/v1/";
|
||||||
config.timeout = 5000;
|
config.timeout = 5000;
|
||||||
let token = window.localStorage.getItem("token")
|
let token = window.localStorage.getItem("token")
|
||||||
config.headers.Authorization = 'Bearer ' + token
|
config.headers.Authorization = token
|
||||||
return config;
|
return config;
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
// 对请求错误做些什么
|
// 对请求错误做些什么
|
||||||
|
@ -17,10 +18,15 @@ axios.interceptors.request.use((config) => {
|
||||||
// 添加响应拦截器
|
// 添加响应拦截器
|
||||||
axios.interceptors.response.use((res: AxiosResponse) => {
|
axios.interceptors.response.use((res: AxiosResponse) => {
|
||||||
if (res.data.status === 401) {
|
if (res.data.status === 401) {
|
||||||
|
store.usrStore.openLoginDilog()
|
||||||
store.usrStore.logOut()
|
store.usrStore.logOut()
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
|
if (err.status === 401) {
|
||||||
|
store.usrStore.openLoginDilog()
|
||||||
|
store.usrStore.logOut()
|
||||||
|
}
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
});
|
});
|
||||||
class BaseHttp {
|
class BaseHttp {
|
||||||
|
@ -75,4 +81,5 @@ class BaseHttp {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-anonymous-default-export
|
||||||
export default new BaseHttp()
|
export default new BaseHttp()
|
|
@ -58,34 +58,31 @@ class BaseStore<B> implements BaseStoreInterface<B> {
|
||||||
async getlist() {
|
async getlist() {
|
||||||
this.listStatus = true;
|
this.listStatus = true;
|
||||||
let res = await baseHttp.get(this.urlConfig.LIST, {
|
let res = await baseHttp.get(this.urlConfig.LIST, {
|
||||||
size: this.page?.Size | 1,
|
size: this.page?.Size | 20,
|
||||||
offset: this.page?.Offset | 20,
|
offset: this.page?.Offset | 1,
|
||||||
isSelf:0
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.page = {
|
|
||||||
Offset: res.data?.pageNum,
|
|
||||||
Size: res.data?.pageSize
|
|
||||||
}
|
|
||||||
let data: Array<B> = []
|
let data: Array<B> = []
|
||||||
if (!res.data.list) {
|
if (!res.data.record) {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.list = data;
|
this.list = data;
|
||||||
})
|
})
|
||||||
this.listStatus = false;
|
this.listStatus = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < res.data.list.length; i++) {
|
console.log(res.data.record);
|
||||||
|
for (let i = 0; i < res.data.record.length; i++) {
|
||||||
data.push({
|
data.push({
|
||||||
key: res.data.list[i].id,
|
key: res.data.record[i].id,
|
||||||
...res.data.list[i]
|
...res.data.record[i]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.list = data;
|
this.list = data;
|
||||||
this.total = res.data.total | res.data.totals
|
this.total = res.data.count
|
||||||
})
|
})
|
||||||
|
console.log(this.list);
|
||||||
this.listStatus = false;
|
this.listStatus = false;
|
||||||
}
|
}
|
||||||
list!: Array<B>;
|
list!: Array<B>;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { makeObservable } from "mobx";
|
||||||
|
// 用户信息
|
||||||
|
import BaseStore from "./baseStore";
|
||||||
|
import { TagDataType } from "@/model/userModel";
|
||||||
|
|
||||||
|
class DepConfig {
|
||||||
|
static LIST: string = "dep/list"
|
||||||
|
static ADD: string = "dep"
|
||||||
|
static DELETE: string = "dep"
|
||||||
|
static EDIT: string = "dep"
|
||||||
|
}
|
||||||
|
class DepStore extends BaseStore<TagDataType> {
|
||||||
|
constructor() {
|
||||||
|
super(DepConfig)
|
||||||
|
makeObservable(this, {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-anonymous-default-export
|
||||||
|
export default new DepStore();
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
import usrStore from '@/store/user'
|
import usrStore from '@/store/user'
|
||||||
|
import tagStore from '@/store/tag'
|
||||||
|
import depStore from '@/store/dep'
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
usrStore,
|
usrStore,
|
||||||
|
tagStore,
|
||||||
|
depStore
|
||||||
};
|
};
|
||||||
|
|
||||||
export default store;
|
export default store;
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { makeObservable } from "mobx";
|
||||||
|
// 用户信息
|
||||||
|
import BaseStore from "./baseStore";
|
||||||
|
import { TagDataType } from "@/model/userModel";
|
||||||
|
|
||||||
|
class TagConfig {
|
||||||
|
static LIST: string = "tag/list"
|
||||||
|
static ADD: string = "tag"
|
||||||
|
static DELETE: string = "tag"
|
||||||
|
static EDIT: string = "tag"
|
||||||
|
}
|
||||||
|
class TagStore extends BaseStore<TagDataType> {
|
||||||
|
constructor() {
|
||||||
|
super(TagConfig)
|
||||||
|
makeObservable(this, {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-anonymous-default-export
|
||||||
|
export default new TagStore();
|
||||||
|
|
|
@ -7,12 +7,16 @@ import { UserDataType, UserInfos } from "@/model/userModel";
|
||||||
|
|
||||||
class UserStore extends BaseStore<UserDataType> {
|
class UserStore extends BaseStore<UserDataType> {
|
||||||
_userinfo: UserInfos = {}; // 用户信息
|
_userinfo: UserInfos = {}; // 用户信息
|
||||||
|
isNeedLogin: boolean = false; // 是否需要登录
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(UserConfig)
|
super(UserConfig)
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
logOut: action,
|
logOut: action,
|
||||||
login: action,
|
login: action,
|
||||||
_userinfo: observable,
|
_userinfo: observable,
|
||||||
|
isNeedLogin: observable,
|
||||||
|
openLoginDilog: action,
|
||||||
userInfo: computed,
|
userInfo: computed,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -43,6 +47,13 @@ class UserStore extends BaseStore<UserDataType> {
|
||||||
};
|
};
|
||||||
window.localStorage.setItem("token", data.data.token ?? "");
|
window.localStorage.setItem("token", data.data.token ?? "");
|
||||||
}
|
}
|
||||||
|
openLoginDilog(){
|
||||||
|
this.isNeedLogin = true;
|
||||||
|
}
|
||||||
|
closeLoginDilog(){
|
||||||
|
this.isNeedLogin = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line import/no-anonymous-default-export
|
||||||
export default new UserStore();
|
export default new UserStore();
|
Loading…
Reference in New Issue