This commit is contained in:
wang_yp 2025-07-07 14:30:39 +08:00
parent dba87a4e99
commit 9f39ef3e21
8 changed files with 42 additions and 62 deletions

View File

@ -23,6 +23,7 @@ const BTable = (props: any) => {
onPageChange, onPageChange,
config, config,
btnText, btnText,
children
} = props; } = props;
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]); const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const formRef = React.useRef<FormInstance>(null); const formRef = React.useRef<FormInstance>(null);
@ -157,7 +158,9 @@ const BTable = (props: any) => {
formRef.current?.setFieldsValue(record); formRef.current?.setFieldsValue(record);
}} }}
formDatas={config} formDatas={config}
></SimpleForm> >
{children ?? null}
</SimpleForm>
</Modal> </Modal>
</Space> </Space>
); );

View File

@ -1,34 +1,27 @@
import { useState } from "react";
import DebounceSelect from "./featch_select"; import DebounceSelect from "./featch_select";
import { inject, observer } from "mobx-react"; import { base } from "@/service/base";
import { Store } from "antd/es/form/interface"; import SourceConfig from "@/service/source_config";
interface UserValue { interface UserValue {
label: string; label: string;
value: string; value: string;
} }
const Dumbselect = (props: Store) => { const Dumbselect = (props) => {
const { usrStore } = props;
const [value, setValue] = useState<UserValue[]>([]);
async function fetchUserList(username: string): Promise<UserValue[]> { async function fetchUserList(username: string): Promise<UserValue[]> {
return usrStore.serchUser(username).then((res) => { return base.get(SourceConfig.Searchs + "/?name=" + username, {}).then((res) => {
return res.data.record.map((item) => ({ return res.data.record.map((item) => ({
label: item.user_name, label: item.content,
value: item.identity, value: item.id_card,
})); }));
}); });
} }
return ( return (
<DebounceSelect <DebounceSelect
{...props}
mode="multiple" mode="multiple"
value={value}
placeholder="Select users"
fetchOptions={fetchUserList} fetchOptions={fetchUserList}
onChange={(newValue) => {
setValue(newValue as UserValue[]);
}}
style={{ width: "100%" }} style={{ width: "100%" }}
/> />
); );
}; };
export default inject("usrStore")(observer(Dumbselect)); export default Dumbselect;

View File

@ -46,12 +46,10 @@ const DebounceSelect = <
return ( return (
<Select <Select
labelInValue
filterOption={false} filterOption={false}
onSearch={debounceFetcher} onSearch={debounceFetcher}
notFoundContent={fetching ? <Spin size="small" /> : null} notFoundContent={fetching ? <Spin size="small" /> : null}
{...props} {...props}
options={options} options={options}
/> />
); );

View File

@ -1,4 +1,4 @@
import { Button, Checkbox, DatePicker, Form, Input, InputNumber, Radio, Space } from "antd"; import { Checkbox, DatePicker, Form, Input, InputNumber, Radio } from "antd";
import { useEffect } from "react"; import { useEffect } from "react";
import { FormType, SimpleFormData } from "./interface"; import { FormType, SimpleFormData } from "./interface";
import { FormSelect } from "./select"; import { FormSelect } from "./select";
@ -7,7 +7,8 @@ import MyEditor from "../edittor";
import MapFrom from "../map/MapFrom"; import MapFrom from "../map/MapFrom";
import { FormTreeSelect } from "./tree_select"; import { FormTreeSelect } from "./tree_select";
import { FormCheckBox } from "./checkbox"; import { FormCheckBox } from "./checkbox";
import { MinusCircleOutlined } from '@ant-design/icons'; import DumpSeleft from "./dump_seleft";
// import VideoSelect from "../video_select"; // import VideoSelect from "../video_select";
const { TextArea } = Input; const { TextArea } = Input;
@ -34,7 +35,6 @@ const SimpleForm = (props: SimpleFormData) => {
initialValues={{ menubar: true }} initialValues={{ menubar: true }}
onFinish={onFinish} onFinish={onFinish}
> >
{props.childrenPosi ? null : props.children ?? props.children}
{props.formDatas.map((v) => { {props.formDatas.map((v) => {
switch (v.type) { switch (v.type) {
case FormType.input: case FormType.input:
@ -192,36 +192,18 @@ const SimpleForm = (props: SimpleFormData) => {
</Form.Item> </Form.Item>
); );
case FormType.formList: case FormType.formList:
return <Form.List name="users"> return props.children
{(fields, { add, remove }) => ( case FormType.fetchList:
<> return (
{fields.map(({ key, name, ...restField }) => ( <Form.Item
<Space key={key} style={{ display: 'flex', marginBottom: 8 }} align="baseline"> key={v.label}
<Form.Item label={v.label}
{...restField} name={v.name}
name={[name, 'first']} rules={v.rules}
rules={[{ required: true, message: 'Missing first name' }]} >
> <DumpSeleft {...v} />
<Input placeholder="First Name" /> </Form.Item>
</Form.Item> )
<Form.Item
{...restField}
name={[name, 'last']}
rules={[{ required: true, message: 'Missing last name' }]}
>
<Input placeholder="Last Name" />
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)} />
</Space>
))}
<Form.Item>
<Button type="dashed" onClick={() => add()} block >
Add field
</Button>
</Form.Item>
</>
)}
</Form.List>
default: default:
return ( return (
<Form.Item <Form.Item
@ -235,7 +217,7 @@ const SimpleForm = (props: SimpleFormData) => {
); );
} }
})} })}
{props.childrenPosi ? props.children ?? props.children : null} {/* {props.childrenPosi ? props.children ?? props.children : null} */}
</Form> </Form>
); );
}; };

View File

@ -1,5 +1,6 @@
import { FormType } from "@/components/form/interface"; import { FormType } from "@/components/form/interface";
import { UserDataType } from "@/model/userModel"; import { UserDataType } from "@/model/userModel";
import SourceConfig from "@/service/source_config";
import { ColumnsType } from "antd/es/table"; import { ColumnsType } from "antd/es/table";
export const defaultConfig = [ export const defaultConfig = [
@ -73,13 +74,14 @@ export const defaultConfig = [
value: "", value: "",
rules: [{ required: true, message: "请输入负责人身份证!" }], rules: [{ required: true, message: "请输入负责人身份证!" }],
}, },
// { {
// type: FormType.select, type: FormType.fetchList,
// label: "参与人员选择", label: "参与人员选择",
// name: "users", name: "part_idCard",
// value: "", value: [],
// rules: [{ required: false, message: "请选择参与人员!" }], selectUrl: SourceConfig.Searchs,
// }, rules: [{ required: false, message: "请选择参与人员!" }],
},
{ {
type: FormType.select, type: FormType.select,
label: "事件等级", label: "事件等级",
@ -115,7 +117,6 @@ export const columns: ColumnsType<UserDataType> = [
dataIndex: "name", dataIndex: "name",
fixed: "left", fixed: "left",
}, },
{ {
title: "事件描述", title: "事件描述",
dataIndex: "desc", dataIndex: "desc",

View File

@ -16,9 +16,10 @@ const Event = (props: Store) => {
store={thingStore} store={thingStore}
scroll={{ x: "max-content" }} scroll={{ x: "max-content" }}
columns={columns} columns={columns}
dataSource={thingStore.list??[]} dataSource={thingStore.list ?? []}
config={defaultConfig} config={defaultConfig}
/> >
</BTable>
</div> </div>
} }

View File

@ -5,6 +5,7 @@ class SourceConfig {
static DELETE: string = "/desc"; static DELETE: string = "/desc";
static Headers: string = "/desc/header"; static Headers: string = "/desc/header";
static Content: string = "/desc/content"; static Content: string = "/desc/content";
static Searchs: string = "/desc/content/idcard";
} }
export default SourceConfig; export default SourceConfig;

View File

@ -44,6 +44,7 @@ class EventConfig {
static EDIT: string = "/thing"; static EDIT: string = "/thing";
static LIST: string = "/thing/list"; static LIST: string = "/thing/list";
static DELETE: string = "/thing"; static DELETE: string = "/thing";
} }