fix(amap):core
This commit is contained in:
parent
ad9ce024d7
commit
9b3a268310
|
@ -0,0 +1,35 @@
|
|||
import { useState } from "react";
|
||||
import DebounceSelect from "./featch_select";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { Store } from "antd/es/form/interface";
|
||||
interface UserValue {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
const Dumbselect = (props: Store) => {
|
||||
const { usrStore } = props;
|
||||
const [value, setValue] = useState<UserValue[]>([]);
|
||||
|
||||
async function fetchUserList(username: string): Promise<UserValue[]> {
|
||||
return usrStore.serchUser(username).then((res) => {
|
||||
return res.data.record.map((item) => ({
|
||||
label: item.user_name,
|
||||
value: item.identity,
|
||||
}));
|
||||
});
|
||||
}
|
||||
return (
|
||||
<DebounceSelect
|
||||
mode="multiple"
|
||||
value={value}
|
||||
placeholder="Select users"
|
||||
fetchOptions={fetchUserList}
|
||||
onChange={(newValue) => {
|
||||
setValue(newValue as UserValue[]);
|
||||
}}
|
||||
style={{ width: "100%" }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject("usrStore")(observer(Dumbselect));
|
|
@ -0,0 +1,51 @@
|
|||
import React, { useMemo, useRef, useState } from 'react';
|
||||
import { Select, Spin } from 'antd';
|
||||
import type { SelectProps } from 'antd';
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
export interface DebounceSelectProps<ValueType = any>
|
||||
extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
|
||||
fetchOptions: (search: string) => Promise<ValueType[]>;
|
||||
debounceTimeout?: number;
|
||||
}
|
||||
|
||||
const DebounceSelect = <
|
||||
ValueType extends { key?: string; label: React.ReactNode; value: string | number } = any,
|
||||
>({ fetchOptions, debounceTimeout = 800, ...props }: DebounceSelectProps<ValueType>) =>{
|
||||
const [fetching, setFetching] = useState(false);
|
||||
const [options, setOptions] = useState<ValueType[]>([]);
|
||||
const fetchRef = useRef(0);
|
||||
|
||||
const debounceFetcher = useMemo(() => {
|
||||
const loadOptions = (value: string) => {
|
||||
fetchRef.current += 1;
|
||||
const fetchId = fetchRef.current;
|
||||
setOptions([]);
|
||||
setFetching(true);
|
||||
|
||||
fetchOptions(value).then((newOptions) => {
|
||||
if (fetchId !== fetchRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
setOptions(newOptions);
|
||||
setFetching(false);
|
||||
});
|
||||
};
|
||||
|
||||
return debounce(loadOptions, debounceTimeout);
|
||||
}, [fetchOptions, debounceTimeout]);
|
||||
|
||||
return (
|
||||
<Select
|
||||
labelInValue
|
||||
filterOption={false}
|
||||
onSearch={debounceFetcher}
|
||||
notFoundContent={fetching ? <Spin size="small" /> : null}
|
||||
{...props}
|
||||
options={options}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default DebounceSelect
|
|
@ -13,6 +13,7 @@ export enum FormType {
|
|||
cehckbox = "checkbox",
|
||||
cehckboxGroup = "checkboxGroup",
|
||||
password = "password",
|
||||
fetchList = "fetchList",
|
||||
}
|
||||
|
||||
export interface FormDatas {
|
||||
|
|
|
@ -5,6 +5,7 @@ import { FormSelect } from "./select";
|
|||
import AliUpload from "../ali_upload";
|
||||
import MyEditor from "../edittor";
|
||||
import MapFrom from "../map/MapFrom";
|
||||
import Dumbselect from "./dump_seleft";
|
||||
const { TextArea } = Input;
|
||||
const SimpleForm = (props: SimpleFormData) => {
|
||||
const [form] = Form.useForm();
|
||||
|
@ -54,6 +55,17 @@ const SimpleForm = (props: SimpleFormData) => {
|
|||
<InputNumber defaultValue={v.value} value={v.value} />
|
||||
</Form.Item>
|
||||
);
|
||||
// case FormType.fetchList:
|
||||
// return (
|
||||
// <Form.Item
|
||||
// key={v.label}
|
||||
// label={v.label}
|
||||
// name={v.name}
|
||||
// rules={v.rules}
|
||||
// >
|
||||
// <Dumbselect />
|
||||
// </Form.Item>
|
||||
// );
|
||||
case "password":
|
||||
return (
|
||||
<Form.Item
|
||||
|
@ -161,7 +173,9 @@ const SimpleForm = (props: SimpleFormData) => {
|
|||
>
|
||||
<Radio.Group>
|
||||
{v.radioData?.map((item) => (
|
||||
<Radio key={item.val} value={item.val}>{item.key}</Radio>
|
||||
<Radio key={item.val} value={item.val}>
|
||||
{item.key}
|
||||
</Radio>
|
||||
))}
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
|
|
|
@ -48,6 +48,10 @@ const LayOut = (props: Store) => {
|
|||
key: "/admin/grid",
|
||||
label: `网格管理`,
|
||||
},
|
||||
{
|
||||
key: "/admin/patrolBrigade",
|
||||
label: `巡防大队`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -137,7 +141,7 @@ const LayOut = (props: Store) => {
|
|||
<Outlet />
|
||||
</Content>
|
||||
<Footer style={{ textAlign: "center" }}>
|
||||
黄水武装部 ©{new Date().getFullYear()} Created
|
||||
双流区黄水镇人民政府 ©{new Date().getFullYear()} Created
|
||||
</Footer>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -1,11 +1,3 @@
|
|||
// const Patrol = ()=>{
|
||||
// return <>
|
||||
// <p>巡逻</p>
|
||||
// </>
|
||||
// }
|
||||
|
||||
// export default Patrol
|
||||
|
||||
import { Button, Space, Modal, FormInstance } from "antd";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import type { ColumnsType } from "antd/es/table";
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
import { FormType } from "@/components/form/interface";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ColumnsType } from "antd/lib/table";
|
||||
export const defaultConfig = () => [
|
||||
// {
|
||||
// type: FormType.fetchList,
|
||||
// label: "用户名",
|
||||
// name: "user_identity",
|
||||
// value: [],
|
||||
// rules: [{ required: true, message: "请输入用户名称!" }],
|
||||
// },
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "身份类别",
|
||||
name: "identity_type",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入用户名称!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "所属队伍",
|
||||
name: "assigned_team",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入所属队伍!" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "备注",
|
||||
name: "note",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入备注!" }],
|
||||
},
|
||||
];
|
||||
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
{
|
||||
title: "用户名",
|
||||
dataIndex: "user_name",
|
||||
fixed: "left",
|
||||
},
|
||||
{
|
||||
title: "性别",
|
||||
dataIndex: "sex",
|
||||
render: (sex) => <span>{sex === 1 ? "男" : "女"}</span>,
|
||||
},
|
||||
{
|
||||
title: "身份证",
|
||||
dataIndex: "id_card",
|
||||
},
|
||||
|
||||
{
|
||||
title: "联系电话",
|
||||
dataIndex: "tel",
|
||||
},
|
||||
{
|
||||
title: "备注",
|
||||
dataIndex: "note",
|
||||
},
|
||||
];
|
|
@ -0,0 +1,162 @@
|
|||
import { Button, Space, Modal, FormInstance, Form } 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 "./config";
|
||||
import dayjs from "dayjs";
|
||||
import DebounceSelect from "@/components/form/featch_select";
|
||||
interface UserValue {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
const PatrolBrigade = (props: Store) => {
|
||||
const { usrStore, patrolBrigadeStore } = 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 [userId, setId] = useState<Number | null>(null);
|
||||
const [value, setValue] = useState<UserValue[]>([]);
|
||||
const edit = (record) => {
|
||||
record = {
|
||||
...record,
|
||||
vet_in_time: dayjs(record.vet_in_time),
|
||||
vet_out_time: dayjs(record.vet_out_time),
|
||||
imageUrl: [{ url: record.imageUrl }],
|
||||
};
|
||||
setProjectConfig(defaultConfig());
|
||||
setIsModalOpen(true);
|
||||
setRecord(record);
|
||||
setId(record.id);
|
||||
};
|
||||
const onFinish = async (values: any) => {
|
||||
var list:any = []
|
||||
values.user_identity.forEach((item)=>{
|
||||
list.push({
|
||||
note:values.note,
|
||||
identity_type:values.identity_type,
|
||||
assigned_team:values.assigned_team,
|
||||
user_identity: item.value
|
||||
})
|
||||
})
|
||||
if (!userId) {
|
||||
let res = await patrolBrigadeStore.add({list:list});
|
||||
if (res) {
|
||||
setIsModalOpen(false);
|
||||
}
|
||||
} else {
|
||||
let res = await usrStore.putItem(userId, values);
|
||||
if (res) {
|
||||
setIsModalOpen(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
patrolBrigadeStore.getlist();
|
||||
}, [patrolBrigadeStore]);
|
||||
|
||||
const addHandler = () => {
|
||||
setProjectConfig(defaultConfig());
|
||||
setId(null);
|
||||
setRecord(null);
|
||||
setIsModalOpen(true);
|
||||
};
|
||||
|
||||
async function fetchUserList(username: string): Promise<UserValue[]> {
|
||||
return usrStore.serchUser(username).then((res) => {
|
||||
return res.data.record.map((item) => ({
|
||||
label: item.user_name,
|
||||
value: item.identity,
|
||||
}));
|
||||
});
|
||||
}
|
||||
const onFinishFailed = () => {};
|
||||
return (
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<Space direction="horizontal" size={"middle"}>
|
||||
<Button type="default" onClick={() => addHandler()}>
|
||||
绑定巡防成员
|
||||
</Button>
|
||||
</Space>
|
||||
<BTable
|
||||
store={usrStore}
|
||||
scroll={{ x: "max-content" }}
|
||||
columns={[
|
||||
...columns,
|
||||
{
|
||||
title: "操作",
|
||||
fixed: "right",
|
||||
with: 200,
|
||||
render: (any, record) => (
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="dashed"
|
||||
size="small"
|
||||
onClick={() => edit(record)}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
dataSource={patrolBrigadeStore.list}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title={"绑定巡防成员"}
|
||||
width={800}
|
||||
open={isModalOpen}
|
||||
afterClose={() => formRef.current?.resetFields()}
|
||||
onOk={() => formRef.current?.submit()}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
onCancel={() => {
|
||||
setId(null);
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<SimpleForm
|
||||
formRef={formRef}
|
||||
createCallback={() => {
|
||||
formRef.current?.setFieldsValue(record);
|
||||
}}
|
||||
formName="card_basic"
|
||||
colProps={25}
|
||||
subBtnName="提交"
|
||||
formDatas={projectConfig}
|
||||
onFinish={onFinish}
|
||||
initialValues={true}
|
||||
onFinishFailed={onFinishFailed}
|
||||
>
|
||||
<>
|
||||
<Form.Item
|
||||
key={"user_identity"}
|
||||
label={"用户名"}
|
||||
name={"user_identity"}
|
||||
rules={[{ required: true, message: "请输入用户名称!" }]}
|
||||
>
|
||||
<DebounceSelect
|
||||
mode="multiple"
|
||||
value={value}
|
||||
placeholder="输入搜索"
|
||||
fetchOptions={fetchUserList}
|
||||
style={{ width: "100%" }}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
</SimpleForm>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default inject(
|
||||
"usrStore",
|
||||
"patrolBrigadeStore"
|
||||
)(observer(PatrolBrigade));
|
|
@ -25,6 +25,7 @@ import OrgChartSelf from "@/pages/OrgChart";
|
|||
import GloryPlaque from "@/pages/glory_plaque";
|
||||
import Grid from "@/pages/grid";
|
||||
import Community from "@/pages/community";
|
||||
import PatrolBrigade from "@/pages/patrolBrigade";
|
||||
export const homeRouter = [
|
||||
{
|
||||
path: "/",
|
||||
|
@ -75,6 +76,11 @@ export const homeRouter = [
|
|||
index: true,
|
||||
element: <Grid />,
|
||||
},
|
||||
{
|
||||
path: "/admin/patrolBrigade",
|
||||
index: true,
|
||||
element: <PatrolBrigade />,
|
||||
},
|
||||
{
|
||||
path: "/admin/community",
|
||||
index: true,
|
||||
|
|
|
@ -24,6 +24,8 @@ import homeStore from './home';
|
|||
import gpStore from './gp';
|
||||
import { communityStore } from './community';
|
||||
import { gridStore } from './grid';
|
||||
import { patrolBrigadeStore } from './patrol_brigade';
|
||||
|
||||
|
||||
|
||||
const store = {
|
||||
|
@ -52,7 +54,8 @@ const store = {
|
|||
homeStore,
|
||||
gpStore,
|
||||
gridStore,
|
||||
communityStore
|
||||
communityStore,
|
||||
patrolBrigadeStore
|
||||
};
|
||||
|
||||
export default store;
|
|
@ -0,0 +1,18 @@
|
|||
import { makeObservable } from "mobx";
|
||||
// 用户信息
|
||||
import BaseStore from "./baseStore";
|
||||
import { TagDataType } from "@/model/userModel";
|
||||
|
||||
class PatrolBrigadeConfig {
|
||||
static LIST: string = "user/getPatrol"
|
||||
static ADD: string = "user/setPatrol"
|
||||
}
|
||||
class PatrolBrigadeStore extends BaseStore<TagDataType> {
|
||||
constructor() {
|
||||
super(PatrolBrigadeConfig)
|
||||
makeObservable(this, {})
|
||||
}
|
||||
}
|
||||
|
||||
export const patrolBrigadeStore = new PatrolBrigadeStore();
|
||||
|
|
@ -13,6 +13,9 @@ class UserConfig {
|
|||
static pover: string = "user/userPower"
|
||||
static team: string = "team/list"
|
||||
static per: string = "persMgmt/list"
|
||||
static serch: string = "user/serch"
|
||||
static getPatrol: string = "user/getPatrol"
|
||||
|
||||
|
||||
}
|
||||
class UserStore extends BaseStore<UserDataType> {
|
||||
|
@ -28,8 +31,10 @@ class UserStore extends BaseStore<UserDataType> {
|
|||
login: action,
|
||||
getTeam: action,
|
||||
getPer: action,
|
||||
serchUser: action,
|
||||
setPoverDe: action,
|
||||
setUserDetaul: action,
|
||||
getPatrol:action,
|
||||
_userinfo: observable,
|
||||
isNeedLogin: observable,
|
||||
poverDetail: observable,
|
||||
|
@ -47,6 +52,13 @@ class UserStore extends BaseStore<UserDataType> {
|
|||
async getPover() {
|
||||
return await baseHttp.get(UserConfig.pover, null)
|
||||
}
|
||||
async serchUser(params: any) {
|
||||
return await baseHttp.get(UserConfig.serch, {user_name:params})
|
||||
}
|
||||
async getPatrol() {
|
||||
return await baseHttp.get(UserConfig.getPatrol, {})
|
||||
}
|
||||
|
||||
get userInfo(): UserInfos {
|
||||
if (!this._userinfo.token) {
|
||||
let token = window.localStorage.getItem("token")
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
class Config {
|
||||
// static baseUrl = "https://rw.quwanya.cn/";
|
||||
// static uploadUrl = "https://rw.quwanya.cn/";
|
||||
// static ws = "wss://rw.quwanya.cn/wsadmin?id=admin";
|
||||
static baseUrl = "https://rw.quwanya.cn/";
|
||||
static uploadUrl = "https://rw.quwanya.cn/";
|
||||
static ws = "wss://rw.quwanya.cn/wsadmin?id=admin";
|
||||
static rtc = "wss://rw.quwanya.cn/ws";
|
||||
static ws = "ws://127.0.0.1:12214/ws?id=admin";
|
||||
static baseUrl = "http://127.0.0.1:12214/";
|
||||
static uploadUrl = "http://127.0.0.1:12214/";
|
||||
// static ws = "ws://127.0.0.1:12214/ws?id=admin";
|
||||
// static baseUrl = "http://127.0.0.1:12214/";
|
||||
// static uploadUrl = "http://127.0.0.1:12214/";
|
||||
|
||||
}
|
||||
export default Config;
|
||||
|
|
Loading…
Reference in New Issue