fix(amap):core

This commit is contained in:
wang_yp 2024-10-13 09:03:03 +08:00
parent c1db08709f
commit 144afd93f7
22 changed files with 1017 additions and 1049 deletions

View File

@ -1,7 +1,7 @@
import { Pagination, PaginationProps, Table } from "antd";
import { useState } from "react";
const BTable = (props: any) => {
const { store, dataSource ,selectCallback} = props;
const { store, dataSource, selectCallback, scroll } = props;
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const onSelectChange = (newSelectedRowKeys: React.Key[]) => {
setSelectedRowKeys(newSelectedRowKeys);
@ -29,7 +29,7 @@ const BTable = (props: any) => {
<Table
style={{ height: "100%", overflow: "auto" }}
pagination={false}
// scroll={{ x: 'max-content' }}
scroll={scroll }
loading={store.listStatus}
rowSelection={rowSelection}
columns={props.columns}

View File

@ -92,6 +92,7 @@ const LayOut = (props: Store) => {
label: `系统管理`,
children: [
{ label: "系统设置", key: "/admin/sys/setting" },
{ label: "光荣牌审核", key: "/admin/sys/gp" },
],
},
];
@ -101,7 +102,7 @@ const LayOut = (props: Store) => {
style={{
position: "sticky",
top: 0,
zIndex: 1,
zIndex: 9,
width: "100%",
display: "flex",
alignItems: "center",

View File

@ -16,7 +16,7 @@ export default function MapContainer() {
const Amap = await AMapLoader.load({
key: "d58999d072ed7e5897d3900a769cfda0", // 申请好的Web端开发者Key首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: ["AMap.Scale"],
plugins: ["AMap.Scale","AMap.MoveAnimation"],
});
amap = new Amap.Map("container", {
@ -32,30 +32,7 @@ export default function MapContainer() {
MapUtl.amap = amap;
amap.setFitView();
};
const addMaket = (m,mp) => {
const marker = new m.Marker({
position: new m.LngLat(103.55, 30.34),
title: "黄水",
});
var content = [
"<div><b>高德软件有限公司</b>",
"电话 : 010-84107000 邮编 : 100102",
"地址 : 北京市望京阜通东大街方恒国际中心A座16层</div>",
];
var infoWindow = new m.InfoWindow({
offset: new m.Pixel(0, -30),
autoMove: true,
content: content.join("<br/>"),
});
marker.on("click", (e) => {
infoWindow.open(mp, e.target.getPosition());
});
amap.add(marker);
MapUtl.makerList.push(marker);
MapUtl.amap = m;
};
return <div id="container" style={{ height: "100vh" }}></div>;
}

View File

@ -36,6 +36,37 @@ class MapUtl {
maker.setIcon(newIcon);
}
static polyline = (lineArr) => {
var marker = new MapUtl.loadMap.Marker({
map: MapUtl.amap,
position: [116.478935, 39.997761],
icon: "https://a.amap.com/jsapi_demos/static/demo-center-v2/car.png",
offset: new MapUtl.loadMap.Pixel(-13, -26),
});
new MapUtl.loadMap.Polyline({
map: MapUtl.amap,
path: lineArr,
showDir: true,
strokeColor: "#28F", //线颜色
strokeWeight: 6, //线宽
});
var passedPolyline = new MapUtl.loadMap.Polyline({
map: MapUtl.amap,
strokeColor: "#AF5", //线颜色
strokeWeight: 6, //线宽
});
marker.on('moving', function (e) {
passedPolyline.setPath(e.passedPath);
MapUtl.amap.setCenter(e.target.getPosition(), true)
});
MapUtl.amap.setFitView();
marker.moveAlong(lineArr, {
// 每一段的时长
duration: 500,//可根据实际采集时间间隔设置
// JSAPI2.0 是否延道路自动设置角度在 moveAlong 里设置
autoRotation: true,
});
}
}
export default MapUtl;

View File

@ -1,88 +1,160 @@
import { Store } from "antd/es/form/interface";
import "./org_chart.less";
import OrgChart from "@/components/org/OrgChart";
import { OrgChartNodeDataType } from "@/components/org";
import { inject, observer } from "mobx-react";
import { useEffect, useState } from "react";
import { orgData } from "./org_config";
const OrgChartSelf = (props: Store) => {
const { depStore } = props;
const [data, setOrgData] = useState([]);
useEffect(() => {
depStore.getOrg().then((res) => {
// setOrgData(res.data.record)
// setOrgData(orgData);
});
}, []);
const OrgChartSelf = () => {
const data: OrgChartNodeDataType = {
key: 0,
label: "黄水武装",
children: [
{
key: 1,
label: "武装部长",
children: [
{
key: 11,
label: "文物社区支部",
children: [
{
key: 21,
label: "wangpeng",
},
{
key: 22,
label: "wangpeng1",
},
],
},
{
key: 12,
label: "花龙村支部",
children: [
{
key: 22,
label: "一组",
},
{
key: 24,
label: "二组",
children: [
{
key: 23,
label: "王鹏",
},
{
key: 29,
label: "王鹏1",
},
]
},
],
},
{ key: 13, label: "云华社区支部", children: [
{
key: 26,
label: "一组",
},
{
key: 28,
label: "二组",
},
],},
],
},
{
key: 2,
label: "教导员",
children: [],
},
],
const getArrayDepth = (arr) => {
let maxDepth = 0;
let maxUser = 0;
function dfs(currentArr, currentDepth) {
currentDepth++;
for (let i = 0; i < currentArr.length; i++) {
if (Array.isArray(currentArr[i].children)) {
dfs(currentArr[i].children, currentDepth);
} else {
maxUser = Math.max(maxUser, currentArr[i].users.length);
maxDepth = Math.max(maxDepth, currentDepth);
}
}
}
dfs(arr, 0);
return maxUser;
};
return (
<>
<OrgChart
data={data}
direction={"horizontal"}
renderNode={(e) => {
return <div style={{textAlign:"center"}}>
<img width={70} height={70} src="https://ww3.sinaimg.cn/mw690/006i0nC8ly1hpzqtw0eibj31o01o0kd2.jpg" alt="" />
<span style={{ color: "#fff",display:"block" }}>{e.label}</span>
</div>
}}
/>
</>
);
// 示例代码
// const arr = [[1, 2, [3, 4]], [[5], 6], 7];
// console.log(getArrayDepth(arr)); // 输出: 3
const dc = (v) => {
let max = getArrayDepth(orgData);
if (v.depId === 1) {
return 70 * max - 40;
}
if (v.children.length > 0) {
return v.children?.length * 70 - 40;
}
};
const lf = (v) => {
let max = getArrayDepth(orgData);
if (v.depId === 1) {
return -30 * max + 20;
}
if (v.children?.length > 0) {
return -30 * v.children?.length + 10;
}
};
const renderTree = (list: Array<any>) => {
return (
<div className="orgsBox">
{list?.map((v, _) => {
if (v.children) {
return (
<div key={v.dep_name} className="orgs">
{v.depId !== 2 ? (
<span
style={{
display: "inline-block",
width: "20px",
marginLeft: 15,
color: "#fff",
}}
>
{v.dep_name}
</span>
) : null}
{v.depId === 1 ? (
<div className="userNameCont">
{v.users?.map((v1, _) => {
return (
<div key={v1.user_name} className="userNmaeBox">
<img
height={60}
style={{
border: "1px solid #fff",
backgroundColor: "#fff",
}}
width={50}
// src="https://img1.baidu.com/it/u=1746619441,3368766734&fm=253&fmt=auto&app=138&f=JPEG?w=400&h=400"
alt=""
/>
<span className="userNmae">{v1.user_name}</span>
</div>
);
})}
</div>
) : (
v.users?.map((v1, _) => {
return (
<div key={v1.user_name} className="userNmaeBox">
<img
height={60}
style={{
border: "1px solid #fff",
backgroundColor: "#fff",
}}
width={50}
// src="https://img1.baidu.com/it/u=1746619441,3368766734&fm=253&fmt=auto&app=138&f=JPEG?w=400&h=400"
alt=""
/>
<span className="userNmae">{v1.user_name}</span>
</div>
);
})
)}
{v.depId !== 2 ? (
<div className="lineBox" style={{ width: 80 }}>
<div className={"linLeft" + v.depId}></div>
<div
className={"linRight linRight" + v.depId}
style={{ width: dc(v), right: lf(v) }}
></div>
</div>
) : null}
{renderTree(v.children)}
</div>
);
}
return (
<div
className="userNameCont node"
key={v.dep_name}
style={{ paddingLeft: 20, display: "flex" }}
>
{v.users?.map((v1, _) => {
return (
<div key={v1.user_name} className="userNmaeBox">
<img
height={60}
style={{
border: "1px solid #fff",
backgroundColor: "#fff",
}}
width={50}
// src="https://img1.baidu.com/it/u=1746619441,3368766734&fm=253&fmt=auto&app=138&f=JPEG?w=400&h=400"
alt=""
/>
<span className="userNmae">{v1.user_name}</span>
</div>
);
})}
</div>
);
})}
</div>
);
};
return <div className="org_sc">{renderTree(orgData)}</div>;
};
export default OrgChartSelf;
// export default OrgChartSelf;
export default inject("depStore")(observer(OrgChartSelf));

334
src/pages/OrgChart_ot.tsx Normal file
View File

@ -0,0 +1,334 @@
import "./org_chart.less";
import OrgChart from "@/components/org/OrgChart";
import { OrgChartNodeDataType } from "@/components/org";
const OrgChartSelf = () => {
const data: OrgChartNodeDataType = {
key: 0,
label: "黄水武装",
children: [
{
key: 1,
label: "武装部长",
children: [
{
key: 11,
label: "文物社区支部",
children: [
{
key: 21,
label: "wangpeng",
},
{
key: 22,
label: "wangpeng1",
},
],
},
{
key: 12,
label: "花龙村支部",
children: [
{
key: 22,
label: "一组",
},
{
key: 24,
label: "二组",
children: [
{
key: 23,
label: "王鹏",
},
{
key: 29,
label: "王鹏1",
},
]
},
],
},
{ key: 13, label: "云华社区支部", children: [
{
key: 26,
label: "一组",
},
{
key: 28,
label: "二组",
},
],},
],
},
{
key: 2,
label: "教导员",
children: [],
},
],
};
return (
<>
<OrgChart
data={data}
direction={"horizontal"}
renderNode={(e) => {
return <div style={{textAlign:"center"}}>
<img width={70} height={70} src="https://ww3.sinaimg.cn/mw690/006i0nC8ly1hpzqtw0eibj31o01o0kd2.jpg" alt="" />
<span style={{ color: "#fff",display:"block" }}>{e.label}</span>
</div>
}}
/>
</>
);
};
const data = [
{
depName: "镇武装部党委",
depId: 1,
userList: [
{
position: "武装部长",
userName: "李部长",
userId: 1,
},
{
position: "教导员",
userName: "王教导",
userId: 2,
},
],
children: [
{
depName: " 武装力量党支部",
depId: 2,
children: [
{
depName: " 文武社区支部",
depId: 3,
children: [
{
depName: " 一小组",
depId: 6,
userList: [
{
position: "一小组长",
userName: "一小组长1",
userId: 6,
},
{
position: "二小组长12",
userName: "二小组长2",
userId: 8,
},
{
position: "战士",
userName: "王小三3",
userId: 11,
},
{
position: "战士",
userName: "王小四4",
userId: 12,
},
{
position: "二小组长34",
userName: "二小组长5",
userId: 8,
},
{
position: "战士",
userName: "王小三6",
userId: 11,
},
{
position: "战士",
userName: "王小四7",
userId: 13,
},
],
},
{
depName: " 二小组",
depId: 7,
userList: [
{
position: "二小组长8",
userName: "二小组长9",
userId: 7,
},
{
position: "二小组长10",
userName: "二小组长11",
userId: 8,
},
{
position: "战士",
userName: "王小三14",
userId: 11,
},
{
position: "战士",
userName: "王小四",
userId: 12,
},
],
},
],
userList: [
{
position: "文武社区支部书记",
userName: "书记名称",
userId: 3,
},
],
},
{
depName: " 花龙村支部",
depId: 4,
children: [
{
depName: " 一小组",
depId: 7,
userList: [
{
position: "一小组长",
userName: "一小组长",
userId: 7,
},
{
position: "二小组长2",
userName: "二小组长11",
userId: 8,
},
{
position: "战士",
userName: "王小三",
userId: 11,
},
{
position: "战士",
userName: "王小四12",
userId: 12,
},
{
position: "二小组长3",
userName: "二小组长",
userId: 8,
},
{
position: "战士",
userName: "王小四32",
userId: 12,
},
],
},
{
depName: " 二小组",
depId: 8,
userList: [
{
position: "二小组长4",
userName: "二小组长4",
userId: 8,
},
{
position: "战士",
userName: "王小三",
userId: 11,
},
{
position: "战士",
userName: "王小四12",
userId: 12,
},
{
position: "战士",
userName: "王小五",
userId: 13,
},
],
},
],
userList: [
{
position: "花龙村支部书记",
userName: "书记名称",
userId: 4,
},
],
},
{
depName: " 云华社区支部",
depId: 5,
children: [
{
depName: " 一小组",
depId: 8,
userList: [
{
position: "一小组长",
userName: "小组长",
userId: 8,
},
{
position: "战士",
userName: "王喜哦",
userId: 12,
},
{
position: "战士",
userName: "王喜吃",
userId: 13,
},
],
},
{
depName: " 二小组",
depId: 9,
userList: [
{
position: "二小组长5",
userName: "小组长",
userId: 9,
},
{
position: "战士",
userName: "王小二",
userId: 10,
},
{
position: "战士",
userName: "王小三",
userId: 11,
},
{
position: "战士",
userName: "王小四3",
userId: 12,
},
{
position: "战士",
userName: "王小五",
userId: 13,
},
],
},
],
userList: [
{
position: "云华社区支部书记",
userName: "书记名称",
userId: 5,
},
],
},
],
},
],
},
];
export default OrgChartSelf;

View File

@ -63,12 +63,10 @@ const Dep = (props: Store) => {
setId(record.id);
};
const onFinish = (values: any) => {
let data = values;
data.head_img = values.head_img[0].url;
if (!tagId) {
depStore.add(data);
depStore.add(values);
} else {
depStore.putItem(tagId, data);
depStore.putItem(tagId, values);
}
setIsModalOpen(false);
};
@ -109,13 +107,6 @@ const Dep = (props: Store) => {
value: "",
rules: [{ required: true, message: "请输入部门描述" }],
},
{
type: "upload",
label: "头像",
name: "head_img",
value: [],
rules: [{ required: false }],
},
];
const onFinishFailed = () => {};
return (

View File

@ -0,0 +1,47 @@
import BTable from "@/components/b_table";
import { UserDataType } from "@/model/userModel";
import { Button, Space } from "antd";
import { Store } from "antd/es/form/interface";
import { ColumnsType } from "antd/lib/table";
import { inject, observer } from "mobx-react";
import { useEffect } from "react";
const GloryPlaque = (props: Store) => {
const { gpStore } = props;
useEffect(() => {
gpStore.getlist();
}, [gpStore]);
const columns: ColumnsType<UserDataType> = [
{ title: "申请人", dataIndex: "user_name" },
{ title: "申请人手机号", dataIndex: "tel" },
{ title: "悬挂地址", dataIndex: "address" },
{ title: "申请时间", dataIndex: "created_at" },
{ title: "申请原因", dataIndex: "abbr",render: (abbr) => <span>{abbr===2?'更换':'悬挂'}</span> },
{ title: "申请描述", dataIndex: "desc" },
{
title: "操作",
dataIndex: "id",
render: (any, record) => (
<div>
<Space wrap>
<Button
type="dashed"
size="small"
onClick={() => {
// edit(record);
}}
>
</Button>
</Space>
</div>
),
},
];
return (
<div>
<BTable store={gpStore} columns={columns} dataSource={gpStore.list} />
</div>
);
};
export default inject("gpStore")(observer(GloryPlaque));

View File

@ -9,12 +9,14 @@ const Login = (props) => {
const formRef = React.useRef<FormInstance>(null);
const navigate = useNavigate();
const onFinish = async (values: any) => {
await usrStore.login({
let status = await usrStore.login({
userName: values.account,
passWord: values.password,
});
usrStore.closeLoginDilog()
navigate("/admin/user", { replace: true });
if (status) {
usrStore.closeLoginDilog();
navigate("/admin/user", { replace: true });
}
};
const onFinishFailed = () => {};
const loginForm = [

View File

@ -4,12 +4,8 @@
align-items: center;
position: relative;
}
.orgs::before{
.orgs::before {
position: absolute;
width: 80px;
left: -35px;
height: 1px;
background-color: black;
border-radius: 50%;
}
@ -27,57 +23,74 @@
padding: 5px 5px;
background: rgba(75, 176, 152, 0.2);
font-size: 13px;
color: #fff;
}
}
.lineBox {
position: relative;
height: 100%;
height: 1px;
width: 100%;
background-color: red;
background-color: white;
top: -5px;
.linLeft {
position: absolute;
width: 50%;
border: 1px solid;
left: 0;
right: 50%;
.linLeft1 {
width: 126px;
height: 1px;
background: #fff;
}
.linRight {
position: absolute;
width: 100%;
border: 1px solid;
border: 1px solid #fff;
height: 100%;
right: -5px;
transform: rotate(-90deg) rotateY(180deg);
box-sizing: border-box;
}
.linRight:after {
.linRight::after {
position: absolute;
left: -40px;
top: 40px;
width: 80px;
content: "";
height: 1px;
background-color: black;
background-color: #fff;
border-radius: 50%;
transform: rotate(-90deg) rotateY(180deg);
}
.linRight::before {
position: absolute;
left: 410px;
top: 40px;
width: 80px;
content: "";
height: 1px;
background-color: black;
background-color: #fff;
border-radius: 50%;
right: -40px;
transform: rotate(-90deg) rotateY(180deg);
}
.linRight1::after {
position: absolute;
top: 38px;
left: 408px;
width: 80px;
height: 1px;
content: "";
background-color: white;
border-radius: 50%;
transform: rotate(-90deg) rotateY(180deg);
}
.linRight1::before {
position: absolute;
content: "";
top: 38px;
left: -40px;
width: 80px;
height: 1px;
background-color: white;
border-radius: 50%;
transform: rotate(-90deg) rotateY(180deg);
}
}
.orgs:nth-of-type(1){
.orgs::before{
content: "";
width: 80px;
}
}

View File

@ -1,830 +0,0 @@
.orgchart {
box-sizing: border-box;
display: inline-block;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: linear-gradient(to top,rgba(200,0,0,.15) 5%,rgba(0,0,0,0) 5%),linear-gradient(to right,rgba(200,0,0,.15) 5%,rgba(0,0,0,0) 5%),linear-gradient(to bottom,rgba(200,0,0,.15) 5%,rgba(0,0,0,0) 5%),linear-gradient(to left,rgba(200,0,0,.15) 5%,rgba(0,0,0,0) 5%);
background-size: 10px 10px;
padding: 20px 20px 0 20px
}
.orgchart .hidden,.orgchart~.hidden {
display: none!important
}
.orgchart.b2t {
transform: rotate(180deg)
}
.orgchart.l2r {
position: absolute;
transform: rotate(-90deg) rotateY(180deg);
transform-origin: left top;
text-align: center
}
.orgchart.r2l {
position: absolute;
transform: rotate(90deg);
transform-origin: left top;
text-align: center
}
.orgchart~.mask {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 999;
text-align: center;
background-color: rgba(0,0,0,.3)
}
.orgchart~.mask .spinner {
position: absolute;
top: calc(50% - 50px);
left: calc(50% - 50px)
}
.orgchart>.spinner::before,.orgchart~.mask .spinner::before {
width: 100px;
height: 100px;
border-width: 10px;
border-radius: 50px;
border-top-color: rgba(68,157,68,.8);
border-bottom-color: rgba(68,157,68,.8);
border-left-color: rgba(68,157,68,.8)
}
.orgchart .nodes {
display: flex;
list-style: none;
padding-left: 0;
margin: 0
}
.orgchart .hierarchy {
position: relative
}
.orgchart .hierarchy::before {
content: "";
position: absolute;
top: -11px;
left: 0;
width: 100%;
border-top: 2px solid rgba(217,83,79,.8);
box-sizing: border-box
}
.orgchart .hierarchy.isSiblingsCollapsed.left-sibs::before,.orgchart .hierarchy:first-child::before {
left: calc(50% - 1px);
width: calc(50% + 1px);
}
.orgchart .hierarchy.isSiblingsCollapsed.right-sibs::before,.orgchart .hierarchy:last-child::before {
width: calc(50% + 1px)
}
.orgchart .hierarchy:not(.hidden):only-child::before {
width: 2px
}
.orgchart .isAncestorsCollapsed:only-child::before,.orgchart .isAncestorsCollapsed>.node::before,.orgchart .isChildrenCollapsed>.node:not(:only-child)::after,.orgchart .isCollapsedDescendant::before,.orgchart .isCollapsedDescendant>.node::after,.orgchart .isCollapsedDescendant>.node::before,.orgchart .isCollapsedSibling .hierarchy::before,.orgchart .isCollapsedSibling::before,.orgchart .isSiblingsCollapsed.left-sibs.right-sibs::before,.orgchart .isSiblingsCollapsed.left-sibs:last-child:before,.orgchart .isSiblingsCollapsed.right-sibs:first-child:before,.orgchart .isSiblingsCollapsed:not(.left-sibs):not(.right-sibs)::before,.orgchart>.nodes>.hierarchy::before {
content: none
}
.orgchart .node:not(:only-child)::after {
content: "";
position: absolute;
bottom: -12px;
left: calc(50% - 1px);
width: 2px;
height: 10px;
background-color: rgba(217,83,79,.8)
}
.orgchart ul li .node.allowedDrop {
border-color: rgba(68,157,68,.9)
}
.orgchart ul li .node.currentDropTarget {
background-color: rgba(68,157,68,.9)
}
.orgchart ul li .node.selected {
background-color: rgba(238,217,54,.5)
}
.orgchart ul li .node:hover {
background-color: rgba(238,217,54,.5)
}
.orgchart>ul>li>ul li>.node::before {
content: "";
position: absolute;
top: var(--top,-12px);
left: calc(50% - 1px);
width: 2px;
height: var(--height,10px);
background-color: rgba(217,83,79,.8)
}
.orgchart>ul>li>ul li.isSiblingsCollapsed>.node::before {
top: var(--top-cross-point,-12px);
height: var(--height-cross-point,10px)
}
.orgchart .node {
box-sizing: border-box;
display: inline-block;
position: relative;
margin: 0 0 20px 0;
padding: 3px;
border: 2px dashed transparent;
text-align: center
}
.orgchart.l2r .node,.orgchart.r2l .node {
width: 50px;
height: 140px
}
.orgchart .node:hover {
background-color: rgba(238,217,54,.5);
transition: .5s;
cursor: default;
z-index: 20
}
.orgchart .node.focused {
background-color: rgba(238,217,54,.5)
}
.orgchart .ghost-node {
position: fixed;
left: -10000px;
top: -10000px
}
.orgchart .ghost-node rect {
fill: #fff;
stroke: #bf0000
}
.orgchart .node.allowedDrop {
border-color: rgba(68,157,68,.9)
}
.orgchart .node>.spinner {
position: absolute;
top: calc(50% - 1rem);
left: calc(50% - 1rem)
}
.orgchart .node>.spinner::before {
width: 2rem;
height: 2rem;
border-width: .2rem;
border-radius: 1rem;
border-top-color: rgba(68,157,68,.8);
border-bottom-color: rgba(68,157,68,.8);
border-left-color: rgba(68,157,68,.8)
}
.orgchart .node .title {
box-sizing: border-box;
width: 130px;
text-align: center;
font-size: 12px;
font-weight: 700;
height: 20px;
line-height: 20px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
background-color: rgba(217,83,79,.8);
color: #fff;
border-radius: 4px 4px 0 0
}
.orgchart.b2t .node .title {
transform: rotate(-180deg);
transform-origin: center bottom
}
.orgchart.l2r .node .title {
transform: rotate(-90deg) translate(-45px,-45px) rotateY(180deg);
transform-origin: bottom center
}
.orgchart.r2l .node .title {
transform: rotate(-90deg) translate(-45px,-45px);
transform-origin: bottom center
}
.orgchart .node .title .parentNodeSymbol {
float: left
}
.orgchart .node .title .parentNodeSymbol::before {
color: #fff
}
.orgchart .node .title .parentNodeSymbol::after {
background-color: #fff
}
.orgchart .node .content {
box-sizing: border-box;
width: 130px;
height: 20px;
line-height: 20px;
font-size: 10px;
border: 1px solid rgba(217,83,79,.8);
border-width: 0 1px 1px 1px;
border-radius: 0 0 .25rem .25rem;
text-align: center;
background-color: #fff;
color: #333;
text-overflow: ellipsis;
white-space: nowrap
}
.orgchart.b2t .node .content {
transform: rotate(180deg);
transform-origin: center top
}
.orgchart.l2r .node .content {
transform: rotate(-90deg) translate(-45px,-45px) rotateY(180deg);
transform-origin: top center;
width: 130px
}
.orgchart.r2l .node .content {
transform: rotate(-90deg) translate(-45px,-45px);
transform-origin: top center;
width: 130px
}
.orgchart .node .edge {
position: absolute;
cursor: default;
transition: .2s
}
.orgchart .node .edge::before {
border-color: rgba(68,157,68,.5)
}
.orgchart.noncollapsable .node .edge {
display: none
}
.orgchart .node .edge:hover {
cursor: pointer
}
.orgchart .edge:hover::before {
border-color: #449d44
}
.orgchart .node .verticalEdge {
width: calc(100% - 6px);
height: 10px;
left: 3px
}
.orgchart .node .verticalEdge::before {
position: absolute;
left: calc(50% - 5px)
}
.orgchart .node .topEdge {
top: -2px
}
.orgchart .node .topEdge.oci-chevron-up::before {
top: 2px
}
.orgchart .node .topEdge.oci-chevron-down::before {
bottom: 3px
}
.orgchart .node .bottomEdge {
bottom: -2px
}
.orgchart .node .bottomEdge.oci-chevron-up::before {
bottom: -3px
}
.orgchart .node .bottomEdge.oci-chevron-down::before {
bottom: 1px
}
.orgchart .node .horizontalEdge {
width: 10px;
height: calc(100% - 6px);
top: 3px
}
.orgchart .node .rightEdge {
right: -2px
}
.orgchart .node .leftEdge {
left: -2px
}
.orgchart .node .horizontalEdge::before {
position: absolute;
top: calc(50% - 5px)
}
.orgchart .node .leftEdge.oci-chevron-right::before {
left: -3px
}
.orgchart .node .leftEdge.oci-chevron-left::before {
left: 1px
}
.orgchart .node .rightEdge.oci-chevron-left::before {
right: -3px
}
.orgchart .node .rightEdge.oci-chevron-right::before {
right: 1px
}
.orgchart .node .toggleBtn {
position: absolute;
left: -2px;
bottom: -2px;
width: 16px;
height: 16px
}
.orgchart .node .toggleBtn::before {
background-color: rgba(68,157,68,.6);
position: absolute;
left: 0;
bottom: 0
}
.orgchart .node .toggleBtn:hover::before {
background-color: #449d44
}
.oc-export-btn {
margin-left: .5rem;
padding: .5rem 1rem
}
.orgchart .node {
transition: transform .3s,opacity .3s
}
.orgchart .slide-down {
opacity: 0;
transform: translateY(40px)
}
.orgchart.l2r .node.slide-down,.orgchart.r2l .node.slide-down {
transform: translateY(130px)
}
.orgchart .slide-up {
opacity: 0;
transform: translateY(-40px)
}
.orgchart.l2r .node.slide-up,.orgchart.r2l .node.slide-up {
transform: translateY(-130px)
}
.orgchart .slide-right {
opacity: 0;
transform: translateX(130px)
}
.orgchart.l2r .node.slide-right,.orgchart.r2l .node.slide-right {
transform: translateX(40px)
}
.orgchart .slide-left {
opacity: 0;
transform: translateX(-130px)
}
.orgchart.l2r .node.slide-left,.orgchart.r2l .node.slide-left {
transform: translateX(-40px)
}
.orgchart .nodes.vertical {
display: block;
padding-left: 10px
}
.orgchart .nodes.vertical .nodes {
list-style: none;
display: block;
margin: 0;
padding-left: 10px;
text-align: left
}
.orgchart .nodes.vertical .node {
margin-bottom: 0
}
.orgchart .nodes.vertical .node::after,.orgchart .nodes.vertical .node::before {
content: none
}
.orgchart .nodes.vertical .hierarchy {
position: relative;
text-align: left
}
.orgchart .nodes.vertical .hierarchy::after,.orgchart .nodes.vertical .hierarchy::before {
box-sizing: border-box;
content: '';
position: absolute;
left: -6px;
border-color: rgba(217,83,79,.8);
border-style: solid;
border-width: 0 0 2px 2px
}
.orgchart .nodes.vertical .hierarchy::before {
top: 0;
height: 26px;
width: 11px
}
.orgchart .nodes.vertical .hierarchy::after {
bottom: 0;
height: calc(100% - 24px)
}
.orgchart .nodes.vertical .hierarchy:last-child::after {
border-width: 2px 0 0 0
}
.orgchart .nodes.vertical>.hierarchy:first-child::before {
box-sizing: border-box;
top: -11px;
height: 35px;
width: calc(50% + 2px);
border-width: 2px 0 0 2px
}
.orgchart .nodes.vertical>.hierarchy:first-child::after {
box-sizing: border-box;
top: 24px;
width: 11px;
border-width: 2px 0 0 2px
}
.orgchart .nodes.vertical>.hierarchy:first-child:last-child::after {
border-width: 2px 0 0 0
}
.orgchart .node.compact {
position: static;
display: grid;
width: 140px;
height: 50px;
background-color: #eee
}
.orgchart .node.compact.looseMode {
display: grid;
width: unset;
height: unset
}
.orgchart .node.compact>.node {
display: none
}
.orgchart .node.compact.looseMode>.node {
display: inline-block
}
.orgchart .node.compact>.node.compact {
position: relative
}
.orgchart .node.compact>.node.compact.looseMode {
display: grid
}
.orgchart .node.compact.even,.orgchart .node.compact.even:hover {
background-color: #eee
}
.orgchart .node.compact.odd,.orgchart .node.compact.odd:hover {
background-color: #fff
}
.orgchart .node.compact.even>.node.focused,.orgchart .node.compact.even>.node.selected,.orgchart .node.compact.even>.node:hover {
background-color: #fff
}
.orgchart .node.compact.odd>.node.focused,.orgchart .node.compact.odd>.node.selected,.orgchart .node.compact.odd>.node:hover {
background-color: #eee
}
.orgchart .node.compact::before {
top: var(--top-cross-point,-10px)
}
.orgchart .node.compact>.content {
position: absolute;
top: 25px;
left: 5px
}
.orgchart .node.compact.looseMode>.title {
margin-top: 5px;
margin-left: 5px
}
.orgchart .node.compact.looseMode>.content {
top: 30px;
left: 10px
}
.orgchart .node.compact>.node.compact.looseMode>.title {
margin-top: 5px;
margin-left: 5px
}
.orgchart .node.compact>.node.compact>.content {
position: absolute;
top: 23px;
left: 3px
}
.orgchart .node.compact>.node.compact.looseMode>.content {
top: 28px;
left: 8px
}
.orgchart .node.compact .node {
margin-bottom: 0
}
.orgchart .node.compact .node:not(:only-child)::after {
content: unset
}
.orgchart .backToCompactSymbol,.orgchart .backToLooseSymbol {
cursor: pointer
}
.orgchart .node.compact>.backToCompactSymbol {
position: absolute;
top: 5px;
left: 5px
}
.orgchart .node.compact.looseMode>.backToCompactSymbol {
top: 10px;
left: 10px
}
.orgchart .node.compact>.node.compact.looseMode>.backToCompactSymbol {
top: 8px;
left: 8px
}
.orgchart .node.compact>.node.compact>.backToCompactSymbol {
position: absolute;
top: 3px;
left: 3px
}
.orgchart .node.compact>.backToLooseSymbol {
position: absolute;
top: 25px;
right: 5px
}
.orgchart .node.compact>.node.compact>.backToLooseSymbol {
position: absolute;
top: 23px;
right: 3px
}
.orgchart .node.compact .backToCompactSymbol::before {
border-top-color: rgba(68,157,68,.6)
}
.orgchart .node.compact .backToLooseSymbol::before {
border-bottom-color: rgba(68,157,68,.6)
}
.orgchart .node.compact .backToCompactSymbol:hover::before {
border-top-color: #449d44
}
.orgchart .node.compact .backToLooseSymbol:hover::before {
border-bottom-color: #449d44
}
.oci {
display: inline-block;
position: relative;
font-style: normal;
font-family: Arial
}
.oci-menu::before {
content: "≡";
display: inline-block;
width: 1rem;
height: 1rem;
text-align: center;
line-height: 1rem;
color: #000;
font-size: 1rem
}
.oci-chevron-up::before {
content: "";
box-sizing: border-box;
width: 10px;
height: 10px;
display: inline-block;
border: 3px solid #000;
transform: rotate(45deg);
border-right: unset;
border-bottom: unset
}
.oci-chevron-down::before {
content: "";
box-sizing: border-box;
width: 10px;
height: 10px;
display: inline-block;
border: 3px solid #000;
transform: rotate(45deg);
border-top: unset;
border-left: unset
}
.oci-chevron-left::before {
content: "";
box-sizing: border-box;
width: 10px;
height: 10px;
display: inline-block;
border: 3px solid #000;
transform: rotate(45deg);
border-top: unset;
border-right: unset
}
.oci-chevron-right::before {
content: "";
box-sizing: border-box;
width: 10px;
height: 10px;
display: inline-block;
border: 3px solid #000;
transform: rotate(45deg);
border-left: unset;
border-bottom: unset
}
.oci-corner-top-left::before {
content: "";
display: inline-block;
border-top: 20px solid #000;
border-right: 20px solid transparent
}
.oci-corner-top-right::before {
content: "";
display: inline-block;
box-sizing: border-box;
width: 0;
height: 0;
border-top: 20px solid #000;
border-left: 20px solid transparent
}
.oci-corner-bottom-right::before {
content: "";
display: inline-block;
box-sizing: border-box;
width: 0;
height: 0;
border-bottom: 20px solid #000;
border-left: 20px solid transparent
}
.oci-corner-bottom-left::before {
content: "";
display: inline-block;
box-sizing: border-box;
width: 0;
height: 0;
border-bottom: 20px solid #000;
border-right: 20px solid transparent
}
.oci-plus-square::before {
content: "﹢";
display: inline-block;
width: 16px;
height: 16px;
text-align: center;
line-height: 16px;
background-color: #000;
color: #fff;
font-weight: 700
}
.oci-minus-square::before {
content: "﹣";
display: inline-block;
width: 16px;
height: 16px;
text-align: center;
line-height: 16px;
background-color: #000;
color: #fff;
font-weight: 700
}
.oci-arrow-square-up::before {
content: "⬆";
display: inline-block;
width: 1rem;
height: 1rem;
text-align: center;
line-height: 1rem;
background-color: #000;
color: #fff;
font-weight: 700
}
.oci-arrow-square-down::before {
content: "⬇";
display: inline-block;
width: 1rem;
height: 1rem;
text-align: center;
line-height: 1rem;
background-color: #000;
color: #fff;
font-weight: 700
}
.oci-info-circle::before {
content: "i";
display: inline-block;
width: 1rem;
height: 1rem;
border-radius: .5rem;
background-color: #000;
color: #fff;
text-align: center;
font-weight: 700
}
.oci-spinner::before {
content: "";
vertical-align: text-bottom;
display: inline-block;
box-sizing: border-box;
width: 1rem;
height: 1rem;
border: .1rem solid #000;
border-right-color: transparent;
border-radius: .625rem;
animation: oci-infinite-spinning .75s linear infinite
}
@keyframes oci-infinite-spinning {
from {
transform: rotate(0)
}
to {
transform: rotate(360deg)
}
}

247
src/pages/org_config.ts Normal file
View File

@ -0,0 +1,247 @@
export const orgData = [
{
dep_name: "镇武装部党委",
depId: 1,
users: [
{
position: "武装部长",
user_name: "李部长",
userId: 1,
},
{
position: "教导员",
user_name: "王教导",
userId: 2,
},
],
children: [
{
dep_name: " 武装力量党支部",
depId: 2,
children: [
{
dep_name: " 文武社区支部",
depId: 3,
children: [
{
dep_name: " 一小组",
depId: 6,
users: [
{
position: "一小组长",
user_name: "一小组长1",
userId: 6,
},
{
position: "二小组长12",
user_name: "二小组长2",
userId: 8,
},
{
position: "战士",
user_name: "王小三3",
userId: 11,
},
{
position: "战士",
user_name: "王小四4",
userId: 12,
},
{
position: "二小组长34",
user_name: "二小组长5",
userId: 8,
},
{
position: "战士",
user_name: "王小三6",
userId: 11,
},
{
position: "战士",
user_name: "王小四7",
userId: 13,
},
],
},
{
dep_name: " 二小组",
depId: 7,
users: [
{
position: "二小组长8",
user_name: "二小组长9",
userId: 7,
},
{
position: "二小组长10",
user_name: "二小组长11",
userId: 8,
},
{
position: "战士",
user_name: "王小三14",
userId: 11,
},
{
position: "战士",
user_name: "王小四",
userId: 12,
},
],
},
],
users: [
{
position: "文武社区支部书记",
user_name: "书记名称",
userId: 3,
},
],
},
{
dep_name: " 花龙村支部",
depId: 4,
children: [
{
dep_name: " 一小组",
depId: 7,
users: [
{
position: "一小组长",
user_name: "一小组长",
userId: 7,
},
{
position: "二小组长2",
user_name: "二小组长11",
userId: 8,
},
{
position: "战士",
user_name: "王小三",
userId: 11,
},
{
position: "战士",
user_name: "王小四12",
userId: 12,
},
{
position: "二小组长3",
user_name: "二小组长",
userId: 8,
},
{
position: "战士",
user_name: "王小四32",
userId: 12,
},
],
},
{
dep_name: " 二小组",
depId: 8,
users: [
{
position: "二小组长4",
user_name: "二小组长4",
userId: 8,
},
{
position: "战士",
user_name: "王小三",
userId: 11,
},
{
position: "战士",
user_name: "王小四12",
userId: 12,
},
{
position: "战士",
user_name: "王小五",
userId: 13,
},
],
},
],
users: [
{
position: "花龙村支部书记",
user_name: "书记名称",
userId: 4,
},
],
},
{
dep_name: " 云华社区支部",
depId: 5,
children: [
{
dep_name: " 一小组",
depId: 8,
users: [
{
position: "一小组长",
user_name: "小组长",
userId: 8,
},
{
position: "战士",
user_name: "王喜哦",
userId: 12,
},
{
position: "战士",
user_name: "王喜吃",
userId: 13,
},
],
},
{
dep_name: " 二小组",
depId: 9,
users: [
{
position: "二小组长5",
user_name: "小组长",
userId: 9,
},
{
position: "战士",
user_name: "王小二",
userId: 10,
},
{
position: "战士",
user_name: "王小三",
userId: 11,
},
{
position: "战士",
user_name: "王小四3",
userId: 12,
},
{
position: "战士",
user_name: "王小五",
userId: 13,
},
],
},
],
users: [
{
position: "云华社区支部书记",
user_name: "书记名称",
userId: 5,
},
],
},
],
},
],
},
];

View File

@ -5,7 +5,7 @@ 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 "./political_column";
import { studyColumns, defaultConfig } from "./political_column";
const PoliticalStudy = (props: Store) => {
const { politicalStudyStore } = props;
@ -82,13 +82,11 @@ const PoliticalStudy = (props: Store) => {
<BTable
store={politicalStudyStore}
columns={[
...columns,
...studyColumns,
{
title: "操作",
dataIndex: "id",
ellipsis: {
showTitle: false,
},
render: (any, record) => column_widget(any, record),
},
]}

View File

@ -1,6 +1,6 @@
import { UserDataType } from "@/model/userModel";
import { ColumnsType } from "antd/lib/table";
export const columns: ColumnsType<UserDataType> = [
export const studyColumns: ColumnsType<UserDataType> = [
{
title: "标题",
dataIndex: "title",

47
src/pages/user/move.tsx Normal file
View File

@ -0,0 +1,47 @@
import MapContainer from "@/components/map/MapComponent";
import MapUtl from "@/components/map/mapUtil";
import { Button, Modal } from "antd";
import { useState } from "react";
const Move = () => {
const [isOpen, setOpen] = useState<boolean>(false);
return (
<>
<Button
type="dashed"
size="small"
onClick={() => {
setOpen(true);
}}
>
</Button>
<Modal
title={"轨迹回放"}
width={1200}
open={isOpen}
okText="确定"
cancelText="取消"
footer={null}
onCancel={() => {
setOpen(false);
}}
>
<div>
<Button
type="dashed"
size="small"
onClick={() => {
MapUtl.polyline([[116.478935,39.997761],[116.478939,39.997825],[116.478912,39.998549],[116.478912,39.998549],[116.478998,39.998555],[116.478998,39.998555],[116.479282,39.99856],[116.479658,39.998528],[116.480151,39.998453],[116.480784,39.998302],[116.480784,39.998302],[116.481149,39.998184],[116.481573,39.997997],[116.481863,39.997846],[116.482072,39.997718],[116.482362,39.997718],[116.483633,39.998935],[116.48367,39.998968],[116.484648,39.999861]])
}}
>
</Button>
<div style={{ height: "10px" }}></div>
<MapContainer />
</div>
</Modal>
</>
);
};
export default Move;

View File

@ -7,10 +7,11 @@ import SimpleForm from "@/components/form/simple_form";
import React from "react";
import { columns, defaultConfig } from "./user_config";
import "./user.less";
import Move from "./move";
const { Option } = Select;
const User = (props: Store) => {
const { usrStore ,depStore} = props;
const { usrStore, depStore } = props;
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
const [projectConfig, setProjectConfig] = useState<any>([]);
const formRef = React.useRef<FormInstance>(null);
@ -19,39 +20,13 @@ const User = (props: Store) => {
const [per, setPer] = useState<any>(null);
const [userId, setId] = useState<Number | null>(null);
const [depList, setDeplist] = useState<any>([]);
const actionWidget = (any, record) => {
return (
<Space wrap>
<Button
type="dashed"
size="small"
onClick={() => {
edit(record);
}}
>
</Button>
<Button
type="dashed"
danger
size="small"
onClick={() => {
usrStore.deleteItem(record.id);
}}
>
</Button>
</Space>
);
};
const edit = (record) => {
record = {
...record,
imageUrl: [{ url: record.imageUrl }],
};
setProjectConfig(defaultConfig(team,per));
setProjectConfig(defaultConfig(team, per));
setIsModalOpen(true);
formRef.current?.setFieldsValue(record);
setRecord(record);
@ -61,9 +36,9 @@ const User = (props: Store) => {
let data = {
...values,
};
if(values.head_img && values.head_img.length>0){
if (values.head_img && values.head_img.length > 0) {
data.head_img = values.head_img[0].url;
}else{
} else {
data.head_img = "";
}
if (!userId) {
@ -75,30 +50,29 @@ const User = (props: Store) => {
useEffect(() => {
usrStore.getlist();
usrStore.getTeam().then((res) => {
let data =res.data?.record??[]
let data = res.data?.record ?? [];
for (let index = 0; index < data.length; index++) {
data[index].label = data[index].name;
data[index].value = data[index].identity;
data[index].label = data[index].name;
data[index].value = data[index].identity;
}
setTeam(data)
setTeam(data);
});
usrStore.getPer().then((res) => {
let data =res.data?.record??[]
let data = res.data?.record ?? [];
for (let index = 0; index < data.length; index++) {
data[index].label = data[index].name;
data[index].value = data[index].identity;
data[index].label = data[index].name;
data[index].value = data[index].identity;
}
setPer(data)
setPer(data);
});
depStore.getlist().then(() => {
setDeplist(depStore.list);
});
}, [usrStore,depStore]);
}, [usrStore, depStore]);
const addHandler = () => {
setProjectConfig(defaultConfig(team,per));
setProjectConfig(defaultConfig(team, per));
setId(null);
setIsModalOpen(true);
};
@ -113,18 +87,41 @@ const User = (props: Store) => {
</Space>
<BTable
store={usrStore}
scroll={{ x: "max-content" }}
columns={[
...columns,
{
title: "操作",
dataIndex: "id",
fixed: "right",
ellipsis: { showTitle: false },
render: (any, record) => actionWidget(any, record),
with: 200,
render: (any, record) => (
<Space wrap>
<Button
type="dashed"
size="small"
onClick={() => edit(record)}
>
</Button>
<Move />
<Button
type="dashed"
danger
size="small"
onClick={() => {
usrStore.deleteItem(record.id);
}}
>
</Button>
</Space>
),
},
]}
dataSource={usrStore.list}
/>
<Modal
title={!userId ? "添加民兵" : "编辑民兵"}
width={800}
@ -151,7 +148,7 @@ const User = (props: Store) => {
initialValues={true}
onFinishFailed={onFinishFailed}
>
<>
<>
<Form.Item
key="dep_identity"
label="部门选择"
@ -176,4 +173,4 @@ const User = (props: Store) => {
);
};
export default inject("usrStore","depStore")(observer(User));
export default inject("usrStore", "depStore")(observer(User));

View File

@ -10,6 +10,7 @@ export const defaultConfig =(team,per)=>
name: "user_name",
value: "",
rules: [{ required: true, message: "请输入用户名称!" }],
},
{
type: FormType.radio,
@ -305,7 +306,7 @@ export const columns: ColumnsType<UserDataType> = [
{
title: "用户名",
dataIndex: "user_name",
width: 150,
width: 200,
fixed: "left",
},
{
@ -313,7 +314,6 @@ export const columns: ColumnsType<UserDataType> = [
dataIndex: "sex",
width: 150,
render: (sex) => <span>{sex === "0" ? "男" : "女"}</span>,
fixed: "left",
},
{
title: "年龄",

View File

@ -22,6 +22,7 @@ import SystemPage from "@/pages/system";
import ArchiveBox from "@/pages/archives/index_box";
import FileListPage from "@/pages/archives/file_list";
import OrgChartSelf from "@/pages/OrgChart";
import GloryPlaque from "@/pages/glory_plaque";
export const homeRouter = [
{
path: "/",
@ -154,6 +155,11 @@ export const homeRouter = [
index: true,
element: <SystemPage />,
},
{
path: "/admin/sys/gp",
index: true,
element: <GloryPlaque />,
},
],
},
],

View File

@ -1,18 +1,25 @@
import { makeObservable } from "mobx";
import { action, makeObservable } from "mobx";
// 用户信息
import BaseStore from "./baseStore";
import { TagDataType } from "@/model/userModel";
import baseHttp from '@/service/base';
class DepConfig {
static LIST: string = "dep/list"
static ADD: string = "dep"
static DELETE: string = "dep"
static EDIT: string = "dep"
static ORG: string = "dep/org"
}
class DepStore extends BaseStore<TagDataType> {
constructor() {
super(DepConfig)
makeObservable(this, {})
makeObservable(this, {
getOrg:action
})
}
async getOrg(){
return await baseHttp.get(DepConfig.ORG,{})
}
}

19
src/store/gp.ts Normal file
View File

@ -0,0 +1,19 @@
import { makeObservable } from "mobx";
// 光荣牌
import BaseStore from "./baseStore";
import { TagDataType } from "@/model/userModel";
class GpConfig {
static LIST: string = "gplaque/list"
static ADD: string = "gplaque"
static DELETE: string = "gplaque"
static EDIT: string = "gplaque"
}
class GpStore extends BaseStore<TagDataType> {
constructor() {
super(GpConfig)
makeObservable(this, {})
}
}
const gpStore = new GpStore()
export default gpStore;

View File

@ -21,6 +21,8 @@ import { trainingStore } from './training';
import { trainingCatStore } from './trainingCat';
import { sysStore } from './sys';
import homeStore from './home';
import gpStore from './gp';
const store = {
usrStore,
@ -45,7 +47,8 @@ const store = {
trainingStore,
trainingCatStore,
sysStore,
homeStore
homeStore,
gpStore
};
export default store;

View File

@ -3,6 +3,7 @@ import { action, computed, makeObservable, observable } from "mobx";
import baseHttp from "@/service/base";
import BaseStore from "./baseStore";
import { UserDataType, UserInfos } from "@/model/userModel";
import { message } from "antd";
class UserConfig {
static LOGINURI: string = "anth/login"
static LIST: string = "user/list"
@ -12,23 +13,23 @@ class UserConfig {
static pover: string = "user/userPower"
static team: string = "team/list"
static per: string = "persMgmt/list"
}
class UserStore extends BaseStore<UserDataType> {
_userinfo: UserInfos = {}; // 用户信息
userDetail = {}
isNeedLogin: boolean = false; // 是否需要登录
poverDetail:boolean = false; // 是否展示民兵详情
poverDetail: boolean = false; // 是否展示民兵详情
constructor() {
super(UserConfig)
makeObservable(this, {
logOut: action,
login: action,
getTeam:action,
getPer:action,
setPoverDe:action,
setUserDetaul:action,
getTeam: action,
getPer: action,
setPoverDe: action,
setUserDetaul: action,
_userinfo: observable,
isNeedLogin: observable,
poverDetail: observable,
@ -37,20 +38,20 @@ class UserStore extends BaseStore<UserDataType> {
userInfo: computed,
})
}
async getTeam(){
async getTeam() {
return await baseHttp.get(UserConfig.team, null)
}
async getPer(){
async getPer() {
return await baseHttp.get(UserConfig.per, null)
}
async getPover(){
async getPover() {
return await baseHttp.get(UserConfig.pover, null)
}
get userInfo(): UserInfos {
if (!this._userinfo.token) {
let token = window.localStorage.getItem("token")
this._userinfo.token = token;
}
return this._userinfo;
}
@ -67,6 +68,11 @@ class UserStore extends BaseStore<UserDataType> {
}
try {
let data = await baseHttp.post(UserConfig.LOGINURI, param)
if (data.code !== 200) {
message.error(data.msg)
return false
}
window.localStorage.setItem("token", data.data.token ?? "");
return true
} catch (error) {
@ -80,10 +86,10 @@ class UserStore extends BaseStore<UserDataType> {
closeLoginDilog() {
this.isNeedLogin = false;
}
setPoverDe(status:boolean){
setPoverDe(status: boolean) {
this.poverDetail = status
}
setUserDetaul(data){
setUserDetaul(data) {
this.userDetail = data
}
}