Commit c64cfb4d authored by TZW's avatar TZW

11

parent 0c3adabd
...@@ -30,7 +30,7 @@ import { ...@@ -30,7 +30,7 @@ import {
import ImgCrop from 'antd-img-crop'; import ImgCrop from 'antd-img-crop';
import { doFetch } from '@/utils/doFetch'; import { doFetch } from '@/utils/doFetch';
import moment from 'moment'; import moment from 'moment';
import { useAsyncEffect } from 'ahooks'; import { useAsyncEffect, useRequest } from 'ahooks';
import * as Antd from 'antd'; import * as Antd from 'antd';
import { PlusOutlined, DownOutlined, CloseOutlined, RedoOutlined } from '@ant-design/icons'; import { PlusOutlined, DownOutlined, CloseOutlined, RedoOutlined } from '@ant-design/icons';
import BraftEditor from 'braft-editor'; import BraftEditor from 'braft-editor';
...@@ -38,8 +38,20 @@ import EditTable from './EditTable'; ...@@ -38,8 +38,20 @@ import EditTable from './EditTable';
import EditorItem from './EditorItem'; import EditorItem from './EditorItem';
import Diyrule from './Diyrule'; import Diyrule from './Diyrule';
import defaultSetting from '../../../config/defaultSettings'; import defaultSetting from '../../../config/defaultSettings';
const {
const { Image, Form, Upload, Col, Pagination, Avatar, Dropdown, Menu, Tabs, message } = Antd; Image,
Form,
Upload,
Col,
Pagination,
Avatar,
Dropdown,
Menu,
Tabs,
message,
AutoComplete,
Row,
} = Antd;
const AntdCheckBox = Antd.Checkbox; const AntdCheckBox = Antd.Checkbox;
const FormItems = { const FormItems = {
...@@ -76,6 +88,7 @@ const FormItems = { ...@@ -76,6 +88,7 @@ const FormItems = {
FormSelectList, FormSelectList,
CheckboxItem, CheckboxItem,
RadioItem, RadioItem,
MyAutoComplete,
}; };
function upperCase(str) { function upperCase(str) {
const newStr = str.slice(0, 1).toUpperCase() + str.slice(1); const newStr = str.slice(0, 1).toUpperCase() + str.slice(1);
...@@ -190,6 +203,60 @@ function Input({ item, colProps }) { ...@@ -190,6 +203,60 @@ function Input({ item, colProps }) {
</> </>
); );
} }
function MyAutoComplete({ item, colProps, formRef }) {
const [options, setoptions] = useState([]);
const [username, setusername] = useState();
const { data, run, runAsync } = useRequest(
async () => {
let res = await doFetch({
url: '/auth/sysUser/queryLikeIotUsername',
params: { username },
});
return res?.data?.dataList;
},
{
manual: true,
},
);
useEffect(() => {
console.log(username);
runAsync()
.then((data) => {
const options = data?.map((it) => ({
...it,
label: `${it?.username}-${it?.fullName}`,
value: `${it?.username}-${it?.fullName}`,
}));
setoptions(options);
})
.catch((error) => {
console.log(error);
});
}, [username]);
let col = item.colProps ?? colProps;
let curkey = item.key ?? item.dataIndex;
return (
<Col span={12}>
<ProForm.Item name={curkey} label={item.title} {...item.formItemProps}>
<AutoComplete
formRef={formRef}
allowClear={true}
style={{ width: '100%' }}
fieldProps={item?.fieldProps}
disabled={item?.disabled}
colProps={item.colProps ?? colProps}
onSearch={(e) => {
setusername(e);
}}
options={options}
onSelect={item?.onSelect}
/>
</ProForm.Item>
</Col>
);
}
//pwd //pwd
function Password({ item, colProps }) { function Password({ item, colProps }) {
return ( return (
......
...@@ -2,12 +2,11 @@ import { doFetch } from '@/utils/doFetch'; ...@@ -2,12 +2,11 @@ import { doFetch } from '@/utils/doFetch';
import { Image } from 'antd'; import { Image } from 'antd';
import fieldsDetail from '@/utils/fieldsDetail'; import fieldsDetail from '@/utils/fieldsDetail';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
function getcolumns(setDrawer, usermsg) { function getcolumns(ifs, formRef) {
const options = usermsg?.map((it) => ({ // const options = usermsg?.map((it) => ({
label: `${it?.username}-${it?.fullName}`, // label: `${it?.username}-${it?.fullName}`,
value: it?.id, // value: it?.id,
})); // }));
console.log(options);
return [ return [
{ {
title: '用户名', title: '用户名',
...@@ -15,9 +14,24 @@ function getcolumns(setDrawer, usermsg) { ...@@ -15,9 +14,24 @@ function getcolumns(setDrawer, usermsg) {
width: 120, width: 120,
key: 'username', key: 'username',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] }, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
valueType: 'select', valueType: 'MyAutoComplete',
options, onSelect: (value, option) => {
}, formRef.current.setFieldValue('telephone', option?.phone);
formRef.current.setFieldValue('fullName', option?.fullName);
formRef.current.setFieldValue('mailNo', option?.mailbox);
formRef.current.setFieldValue('status', option?.enabled);
},
disabled: ifs,
},
// {
// title: '用户名',
// dataIndex: 'username',
// width: 120,
// key: 'username',
// formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
// valueType: 'select',
// options,
// },
{ {
title: '姓名', title: '姓名',
dataIndex: 'fullName', dataIndex: 'fullName',
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: Li Hanlin * @Author: Li Hanlin
* @Date: 2022-11-09 14:44:44 * @Date: 2022-11-09 14:44:44
* @Last Modified by: Li Hanlin * @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-16 16:57:18 * @Last Modified time: 2022-12-16 20:20:17
*/ */
import * as React from 'react'; import * as React from 'react';
...@@ -17,18 +17,12 @@ import { message, AutoComplete } from 'antd'; ...@@ -17,18 +17,12 @@ import { message, AutoComplete } from 'antd';
import ExtendField from '@/components/ExtendField'; import ExtendField from '@/components/ExtendField';
import { useModel } from 'umi'; import { useModel } from 'umi';
import { useRequest } from 'ahooks'; import { useRequest } from 'ahooks';
import { indexOf } from 'lodash';
function User(props) { function User(props) {
const { initialState, loading, error, refresh, setInitialState } = useModel('@@initialState'); const { initialState, loading, error, refresh, setInitialState } = useModel('@@initialState');
const [username, setusername] = useState(null); const [username, setusername] = useState(null);
const { data } = useRequest(async () => {
let res = await doFetch({
url: '/auth/sysUser/queryLikeIotUsername',
params: { username: initialState?.currentUser?.username },
});
return res?.data?.dataList;
});
console.log(data);
const actionRef = useRef(), const actionRef = useRef(),
formRef = useRef(); formRef = useRef();
const [drawer, setDrawer] = useState({ const [drawer, setDrawer] = useState({
...@@ -149,14 +143,14 @@ function User(props) { ...@@ -149,14 +143,14 @@ function User(props) {
}; };
const columns = useMemo(() => { const columns = useMemo(() => {
let defcolumn = getcolumns(setDrawer, data); let defcolumn = getcolumns(setDrawer, formRef);
return defcolumn.concat({ return defcolumn.concat({
title: '操作', title: '操作',
valueType: 'option', valueType: 'option',
width: 150, width: 150,
render: (text, row, _, action) => [edit(text, row, _, action), remove(text, row, _, action)], render: (text, row, _, action) => [edit(text, row, _, action), remove(text, row, _, action)],
}); });
}, [data]); }, []);
function selectType(type) { function selectType(type) {
switch (type) { switch (type) {
...@@ -182,6 +176,7 @@ function User(props) { ...@@ -182,6 +176,7 @@ function User(props) {
} }
let params = { let params = {
...vals, ...vals,
username: vals?.username.slice(0, vals?.username?.indexOf('-')),
id: drawer?.title == '编辑' ? drawer?.item?.id : '', id: drawer?.title == '编辑' ? drawer?.item?.id : '',
userCharReqList, userCharReqList,
}; };
...@@ -205,16 +200,12 @@ function User(props) { ...@@ -205,16 +200,12 @@ function User(props) {
} }
}} }}
defaultFormValue={drawer.item} defaultFormValue={drawer.item}
onValuesChange={(changedValues, allValues) => { // onValuesChange={(changedValues, allValues) => {
if (changedValues['username']) { // console.log(changedValues, allValues);
let item = data?.filter((it) => { // if (changedValues['username']) {
return it?.id == ; // console.log(changedValues, allValues);
}); // }
console.log(item); // }}
console.log(changedValues, allValues);
formRef.current.setFieldValue('telephone', '123123');
}
}}
/> />
); );
...@@ -224,7 +215,7 @@ function User(props) { ...@@ -224,7 +215,7 @@ function User(props) {
setDrawer={setDrawer} setDrawer={setDrawer}
drawer={drawer} drawer={drawer}
actionRef={actionRef} actionRef={actionRef}
columns={columns} columns={getcolumns(true, formRef)}
formId={'1'} formId={'1'}
urlParams={urlParams} urlParams={urlParams}
onFinish={async (vals) => { onFinish={async (vals) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment