Commit 5004ef0e authored by zhangwenshuai's avatar zhangwenshuai

修改模糊搜索、可输可选组件

parent ed397fd5
...@@ -32,7 +32,6 @@ const Cell = (props: CellProps) => { ...@@ -32,7 +32,6 @@ const Cell = (props: CellProps) => {
cellData.map((item) => { cellData.map((item) => {
temp.push({ text: item.text, value: item.value }); temp.push({ text: item.text, value: item.value });
}); });
debugger
if (_.isEqual(temp, changedValue)) { if (_.isEqual(temp, changedValue)) {
setStatus('detail'); setStatus('detail');
return; return;
......
...@@ -6,10 +6,8 @@ export const GetFormatter = { ...@@ -6,10 +6,8 @@ export const GetFormatter = {
return obj.value; return obj.value;
}, },
SEARCH: (val) => { SEARCH: (val) => {
if (!Array.isArray(val)) return void 0; if (!Array.isArray(val) || val.length === 0) return void 0;
return val return { value: val[0].value, label: val[0].text };
.map((item) => ({ value: item.value, label: item.text }))
.filter((item) => item.value || item.value === 0);
}, },
TEXTAREA: (val) => { TEXTAREA: (val) => {
const obj = Array.isArray(val) && val.length > 0 ? val[0] : {}; const obj = Array.isArray(val) && val.length > 0 ? val[0] : {};
...@@ -40,6 +38,7 @@ export const GetFormatter = { ...@@ -40,6 +38,7 @@ export const GetFormatter = {
}, },
SELECT: (val) => { SELECT: (val) => {
// 处理成[{}]结构 // 处理成[{}]结构
if (!Array.isArray(val) || val.length === 0) return undefined;
const obj = val[0] || {}; const obj = val[0] || {};
return { key: obj.value, label: obj.text }; return { key: obj.value, label: obj.text };
}, },
...@@ -48,6 +47,9 @@ export const GetFormatter = { ...@@ -48,6 +47,9 @@ export const GetFormatter = {
const obj = val[0] || {}; const obj = val[0] || {};
return { key: obj.value, label: obj.text }; return { key: obj.value, label: obj.text };
}, },
TEXT_SELECT: (val) => {
return GetFormatter.SELECT(val);
},
RATE: (val) => { RATE: (val) => {
const obj = Array.isArray(val) && val.length > 0 ? val[0] : {}; const obj = Array.isArray(val) && val.length > 0 ? val[0] : {};
return obj.value || 0; return obj.value || 0;
...@@ -65,25 +67,15 @@ export const GetFormatter = { ...@@ -65,25 +67,15 @@ export const GetFormatter = {
return obj.value ? moment(obj.value) : void 0; return obj.value ? moment(obj.value) : void 0;
}, },
LINK: (val) => { LINK: (val) => {
return Array.isArray(val) && val.length > 0 ? val : []; return Array.isArray(val) && val.length > 0 ? val : [];
}, },
MULTIPLE_SEARCH: (val) => { MULTIPLE_SEARCH: (val) => {
if (!Array.isArray(val)) return void 0; if (!Array.isArray(val)) return void 0;
return val return val.map((item) => ({ value: item.value, label: item.text }));
.map((item) => ({ value: item.value, label: item.text }))
.filter((item) => item.value || item.value === 0);
}, },
TREE_SELECT: (val) => { TREE_SELECT: (val) => {
debugger
if (!Array.isArray(val)) return void 0; if (!Array.isArray(val)) return void 0;
return val.map((item) => ({ value: item.value, label: item.text })); return val.map((item) => ({ value: item.value, label: item.text }));
}, },
TEXT_SELECT: (val) => {
if (!Array.isArray(val)) return void 0;
return val
.map((item) => ({
value: item.value,
label: item.text,
}))
.filter((item) => item.value || item.value === 0 || item.label);
},
}; };
import { isNumber } from '@/apollo-table/utils/utils';
export const formatStr = 'YYYY-MM-DD HH:mm:ss'; export const formatStr = 'YYYY-MM-DD HH:mm:ss';
export const emptyModel = [{ text: '', value: '' }]; export const emptyModel = [{ text: '', value: '' }];
...@@ -8,16 +10,6 @@ export const SetFormatter = { ...@@ -8,16 +10,6 @@ export const SetFormatter = {
} }
return [{ value: value, text: value }]; return [{ value: value, text: value }];
}, },
SEARCH: (val) => {
if (!val || typeof val !== 'object') return val;
if (typeof val === 'object') {
const values = Array.isArray(val) ? val : [val];
return values.map((item) => ({
value: item.fieldValueValue || item.key,
text: item.fieldValueName || item.label,
}));
}
},
TEXTAREA: (value) => { TEXTAREA: (value) => {
if (!value) { if (!value) {
return emptyModel; return emptyModel;
...@@ -41,26 +33,32 @@ export const SetFormatter = { ...@@ -41,26 +33,32 @@ export const SetFormatter = {
}, },
SELECT: (val) => { SELECT: (val) => {
// 处理成[{}]结构 // 处理成[{}]结构
if (!val) return val; if (!val || typeof val !== 'object') return emptyModel;
if (typeof val === 'object') { const values = Array.isArray(val) ? val : [val];
const values = Array.isArray(val) ? val : [val]; return values.map((item) => ({ value: item.key, text: item.label }));
return values.map((item) => ({ value: item.key, text: item.label }));
}
return val;
}, },
MULTIPLE_SELECT: (val) => { MULTIPLE_SELECT: (val) => {
// 处理成[{}]结构 return SetFormatter.SELECT(val);
if (!val) return val; },
if (typeof val === 'object') { TEXT_SELECT: (val) => {
const values = Array.isArray(val) ? val : [val]; return SetFormatter.SELECT(val);
return values.map((item) => ({ value: item.key, text: item.label })); },
} SEARCH: (val) => {
return val; if (!val || typeof val !== 'object') return emptyModel;
const values = Array.isArray(val) ? val : [val];
return values.map((item) => ({
value: item.fieldValueValue || item.key,
text: item.fieldValueName || item.label,
}));
},
MULTIPLE_SEARCH: (val) => {
return SetFormatter.SEARCH(val);
}, },
RATE: (val) => { RATE: (val) => {
return [{ value: val, text: val }]; return [{ value: val, text: val }];
}, },
NUMBER: (val) => { NUMBER: (val) => {
if (!isNumber(val)) return emptyModel;
return [{ value: val, text: val }]; return [{ value: val, text: val }];
}, },
PERCENTAGE: (event) => { PERCENTAGE: (event) => {
...@@ -87,16 +85,6 @@ export const SetFormatter = { ...@@ -87,16 +85,6 @@ export const SetFormatter = {
LINK: (val) => { LINK: (val) => {
return Array.isArray(val) && val.length > 0 ? val : [emptyModel]; return Array.isArray(val) && val.length > 0 ? val : [emptyModel];
}, },
MULTIPLE_SEARCH: (val) => {
if (!val || typeof val !== 'object') return val;
if (typeof val === 'object') {
const values = Array.isArray(val) ? val : [val];
return values.map((item) => ({
value: item.fieldValueValue || item.key,
text: item.fieldValueName || item.label,
}));
}
},
TREE_SELECT: (val) => { TREE_SELECT: (val) => {
if (!val || typeof val !== 'object') return val; if (!val || typeof val !== 'object') return val;
if (typeof val === 'object') { if (typeof val === 'object') {
...@@ -104,13 +92,4 @@ export const SetFormatter = { ...@@ -104,13 +92,4 @@ export const SetFormatter = {
return values.map((item) => ({ value: item.value, text: item.label })); return values.map((item) => ({ value: item.value, text: item.label }));
} }
}, },
TEXT_SELECT: (val) => {
// 处理成[{}]结构
if (!val) return val;
if (typeof val === 'object') {
const values = Array.isArray(val) ? val : [val];
return values.map((item) => ({ value: item.value, text: item.label }));
}
return val;
},
}; };
...@@ -133,17 +133,18 @@ export const config: any = { ...@@ -133,17 +133,18 @@ export const config: any = {
setFormatter: SetFormatter['MULTIPLE_SEARCH'], setFormatter: SetFormatter['MULTIPLE_SEARCH'],
componentAttr: { componentAttr: {
allowClear: true, allowClear: true,
emitTrigger: 'onBlur',
}, },
detail: require('./detail/multiple-search').default, detail: require('./detail/multiple-search').default,
}, },
// '14': { '14': {
// name: '树组件', name: '树组件',
// component: require('./edit/tree-select').default, component: require('./edit/tree-select').default,
// placeholder: '请选择', placeholder: '请选择',
// getFormatter: GetFormatter['TREE_SELECT'], getFormatter: GetFormatter['TREE_SELECT'],
// setFormatter: SetFormatter['TREE_SELECT'], setFormatter: SetFormatter['TREE_SELECT'],
// detail: require('./detail/tree-select').default, detail: require('./detail/tree-select').default,
// }, },
'15': { '15': {
name: '文本选择', name: '文本选择',
component: require('./edit/text-select').default, component: require('./edit/text-select').default,
...@@ -151,6 +152,7 @@ export const config: any = { ...@@ -151,6 +152,7 @@ export const config: any = {
setFormatter: SetFormatter['TEXT_SELECT'], setFormatter: SetFormatter['TEXT_SELECT'],
componentAttr: { componentAttr: {
allowClear: true, allowClear: true,
emitTrigger: 'onBlur',
}, },
detail: require('./detail/text-select').default, detail: require('./detail/text-select').default,
}, },
......
...@@ -42,10 +42,11 @@ const ApolloCheckboxGroup = (props: ApolloCheckboxGroupProps) => { ...@@ -42,10 +42,11 @@ const ApolloCheckboxGroup = (props: ApolloCheckboxGroupProps) => {
const { onChange, emitTrigger, onEmitChange } = props; const { onChange, emitTrigger, onEmitChange } = props;
const selfProps = antiAssign(props, ['value', 'onChange', 'emitTrigger', 'onEmitChange']); const selfProps = antiAssign(props, ['value', 'onChange', 'emitTrigger', 'onEmitChange']);
const [value, setValue] = useState(props.value); const [value, setValue] = useState(props.value);
const dom = useRef(value);
useEffect(() => { useEffect(() => {
setValue(props.value); setValue(props.value);
}, [props.value]); }, [props.value]);
const dom = useRef();
const changeValue = (value) => { const changeValue = (value) => {
setValue(value); setValue(value);
dom.current = value; dom.current = value;
......
...@@ -3,6 +3,7 @@ import { TextAreaProps, InputProps } from 'antd/es/input'; ...@@ -3,6 +3,7 @@ import { TextAreaProps, InputProps } from 'antd/es/input';
import { InputNumberProps } from 'antd/es/input-number'; import { InputNumberProps } from 'antd/es/input-number';
import { SelectProps } from 'antd/es/select'; import { SelectProps } from 'antd/es/select';
import { CheckboxProps, CheckboxGroupProps } from 'antd/es/checkbox'; import { CheckboxProps, CheckboxGroupProps } from 'antd/es/checkbox';
import { TreeSelectProps } from 'antd/es/tree-select';
export interface LinkData { export interface LinkData {
text?: string; text?: string;
...@@ -23,12 +24,15 @@ export interface ApolloLinkProps extends CommonProps { ...@@ -23,12 +24,15 @@ export interface ApolloLinkProps extends CommonProps {
export interface ApolloTextAreaProps extends TextAreaProps, CommonProps { export interface ApolloTextAreaProps extends TextAreaProps, CommonProps {
value: string | undefined; value: string | undefined;
} }
export interface SearchProps extends CommonProps { export interface ApolloSearchProps extends SelectProps, CommonProps {
type: string; type: string;
request: Function;
isMultiple?: boolean; isMultiple?: boolean;
maxCount?: number; maxCount?: number;
tableId?: number; }
paramsJson?: any; export interface ApolloInputSearchProps extends SelectProps, CommonProps {
type: string;
request: Function;
} }
export interface ApolloSelectProps extends SelectProps, CommonProps { export interface ApolloSelectProps extends SelectProps, CommonProps {
isMultiple?: boolean; isMultiple?: boolean;
...@@ -51,3 +55,8 @@ export interface ApolloCheckboxProps extends CheckboxProps, CommonProps { ...@@ -51,3 +55,8 @@ export interface ApolloCheckboxProps extends CheckboxProps, CommonProps {
label: string; label: string;
} }
export interface ApolloCheckboxGroupProps extends CheckboxGroupProps, CommonProps {} export interface ApolloCheckboxGroupProps extends CheckboxGroupProps, CommonProps {}
export interface ApolloTreeSelectProps extends CommonProps {
isMultiple?: boolean;
onChange: Function;
value: any;
}
.searchContainer { .searchContainer {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-size: 0;
.select {
width: 100%;
height: 100%;
border-radius: 0;
:global(.ant-select-selection--single) {
height: 100%;
border-radius: 0;
}
}
:global(.ant-select-selection--multiple .ant-select-selection__choice) { :global(.ant-select-selection--multiple .ant-select-selection__choice) {
background: rgb(233, 238, 249); background: rgb(233, 238, 249);
} }
......
import React from 'react'; import React, { useEffect, useState } from 'react';
import Search from '../../extra/associationSearch'; import Search from '../../extra/associationSearch';
import { approvalBusinessData } from '../../../../services/globalSearchApi';
import s from './index.less';
import { message } from 'antd'; import { message } from 'antd';
import { SearchProps } from '../editInterface'; import { ApolloSearchProps } from '../editInterface';
import { antiAssign } from '@/apollo-table/utils/utils';
import s from './index.less';
export default function(props: SearchProps) { const ApolloSearch = (props: ApolloSearchProps) => {
const { value = [], onChange, maxCount, isMultiple, paramsJson = {}, type, tableId } = props; const { onChange, maxCount, isMultiple, request, type, emitTrigger, onEmitChange } = props;
const changeValue = (...arg) => { const selfProps = antiAssign(props, [
const currentValue = arg[0] || []; 'columnConfig',
if (maxCount && maxCount <= value.length && currentValue.length > value.length) { 'value',
message.warn(`最多选择${maxCount}`); 'onChange',
'emitTrigger',
'onEmitChange',
'isMultiple',
'options',
'request',
]);
const [value, setValue] = useState(props.value);
useEffect(() => {
setValue(props.value);
}, [props.value]);
const changeValue = (value) => {
if (maxCount && maxCount < value.length) {
message.warn(`最多选择${maxCount}个`);
return; return;
} }
setValue(value);
if (typeof onChange === 'function') { if (typeof onChange === 'function') {
onChange(...arg); onChange(value, value);
}
if (!emitTrigger || emitTrigger === 'onChange') {
emitChange(value, value);
} }
}; };
if (tableId) { const emitChange = (value, option) => {
paramsJson.tableId = tableId; if (typeof onEmitChange === 'function') {
onEmitChange(value, option);
}
};
const onBlur = () => {
emitChange(value, value);
};
if (emitTrigger === 'onBlur') {
selfProps.onBlur = onBlur;
}
if (isMultiple) {
selfProps.mode = 'multiple';
} }
return ( return (
<div className={s.searchContainer}> <div className={s.searchContainer}>
<Search <Search
mode={isMultiple ? 'multiple' : undefined} className={s.select}
maxCount={2}
request={(val) => { request={(val) => {
return approvalBusinessData({ return request({ name: val, fieldValueName: type });
name: val,
fieldValueName: type,
paramsJson: JSON.stringify(paramsJson),
});
}} }}
fieldNames={{ value: 'fieldValueValue', label: 'fieldValueName' }} fieldNames={{ value: 'fieldValueValue', label: 'fieldValueName' }}
{...props} {...selfProps}
value={value}
onChange={changeValue} onChange={changeValue}
initDataType="onfocus" initDataType="onfocus"
/> />
</div> </div>
); );
} };
export default ApolloSearch;
.searchContainer {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-size: 0;
.select {
width: 100%;
height: 100%;
border-radius: 0;
:global(.ant-select-selection--single) {
height: 100%;
border-radius: 0;
}
}
:global(.ant-select-selection--multiple .ant-select-selection__choice) {
background: rgb(233, 238, 249);
}
}
import React from 'react'; import React, { useEffect, useRef, useState } from 'react';
import Search from '../../extra/dataEntry/textSelect'; import InputSearch from '../../extra/dataEntry/textSelect';
import { approvalBusinessData } from '../../../../services/globalSearchApi'; import { ApolloInputSearchProps } from '../editInterface';
export default function(props) { import { antiAssign } from '@/apollo-table/utils/utils';
const onChange = (...arg) => { import s from './index.less';
props.onChange && props.onChange(...arg);
const ApolloInputSearch = (props: ApolloInputSearchProps) => {
const { onChange, request, type, emitTrigger, onEmitChange } = props;
const selfProps = antiAssign(props, [
'columnConfig',
'value',
'onChange',
'emitTrigger',
'onEmitChange',
'request',
]);
const [value, setValue] = useState(props.value);
const dom = useRef(value);
useEffect(() => {
setValue(props.value);
}, [props.value]);
const changeValue = (value) => {
setValue(value);
dom.current = value;
if (typeof onChange === 'function') {
onChange(value, value);
}
if (!emitTrigger || emitTrigger === 'onChange') {
emitChange(value, value);
}
};
const emitChange = (value, option) => {
if (typeof onEmitChange === 'function') {
onEmitChange(value, option);
}
};
const onBlur = () => {
if (!dom.current) {
}
emitChange(dom.current, dom.current);
};
if (emitTrigger === 'onBlur') {
selfProps.onBlur = onBlur;
}
useEffect(() => {
document.addEventListener('click', onBlur, false);
return () => {
document.removeEventListener('click', onBlur, false);
};
}, []);
const onClick = (e) => {
e.stopPropagation(); //阻止事件冒泡
e.nativeEvent.stopImmediatePropagation();
}; };
return ( return (
<div> <div className={s.searchContainer} onClick={onClick}>
<Search <InputSearch
request={(val) => approvalBusinessData({ name: val, fieldValueName: props.type })} className={s.select}
request={(val) => request({ name: val, fieldValueName: type })}
fieldNames={{ value: 'fieldValueValue', label: 'fieldValueName' }} fieldNames={{ value: 'fieldValueValue', label: 'fieldValueName' }}
{...props} {...selfProps}
onChange={onChange} onChange={changeValue}
></Search> value={value}
initDataType="onfocus"
/>
</div> </div>
); );
} };
export default ApolloInputSearch;
.container {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-size: 0;
.search {
width: 100%;
height: 100%;
border-radius: 0;
:global(.ant-select-selection--single) {
height: 100%;
border-radius: 0;
}
}
:global(.ant-select-selection--multiple .ant-select-selection__choice) {
background: rgb(233, 238, 249);
}
}
import React from 'react'; import React, { useEffect, useRef, useState } from 'react';
import Search from '../../extra/orgTreeSelect'; import Search from '../../extra/orgTreeSelect';
import { ApolloTreeSelectProps } from '../editInterface';
import { antiAssign } from '@/apollo-table/utils/utils';
import s from './index.less';
export default function(props) { const ApolloTreeSelect = (props: ApolloTreeSelectProps) => {
const isMultiple = props.isMultiple || false; const { onChange, emitTrigger, onEmitChange, isMultiple } = props;
debugger
const selfProps = antiAssign(props, [
'columnConfig',
'value',
'onChange',
'emitTrigger',
'onEmitChange',
'isMultiple',
]);
const [value, setValue] = useState(props.value);
const dom = useRef(value);
useEffect(() => {
setValue(props.value);
}, [props.value]);
const changeValue = (value) => {
setValue(value);
dom.current = value;
if (typeof onChange === 'function') {
onChange(value, value);
}
if (!emitTrigger || emitTrigger === 'onChange') {
emitChange(value, value);
}
};
const emitChange = (value, option) => {
if (typeof onEmitChange === 'function') {
onEmitChange(value, option);
}
};
const onBlur = () => {
if (!dom.current) {
}
emitChange(dom.current, dom.current);
};
if (emitTrigger === 'onBlur') {
selfProps.onBlur = onBlur;
}
useEffect(() => {
document.addEventListener('click', onBlur, false);
return () => {
document.removeEventListener('click', onBlur, false);
};
}, []);
const onClick = (e) => {
e.stopPropagation(); //阻止事件冒泡
e.nativeEvent.stopImmediatePropagation();
};
return ( return (
<Search <div className={s.container} onClick={onClick}>
mode="org" <Search
dropdownStyle={{ width: props.width || 270, maxHeight: '300px' }} className={s.search}
multiple={isMultiple} multiple={isMultiple}
{...props} mode="org"
/> {...selfProps}
value={value}
onChange={changeValue}
initDataType="onfocus"
/>
</div>
); );
} };
export default ApolloTreeSelect;
...@@ -10,6 +10,7 @@ interface Props { ...@@ -10,6 +10,7 @@ interface Props {
selfCom?: any; selfCom?: any;
dataSource?: []; dataSource?: [];
onChange: Function; onChange: Function;
onBlur?: Function;
value?: any; value?: any;
autoFocus?: boolean; autoFocus?: boolean;
mode?: 'multiple' | 'tags' | undefined; mode?: 'multiple' | 'tags' | undefined;
...@@ -104,7 +105,11 @@ class AssociationSearch extends React.Component<Props> { ...@@ -104,7 +105,11 @@ class AssociationSearch extends React.Component<Props> {
}; };
onBlur = () => { onBlur = () => {
const { onBlur } = this.props;
this.setState({ searchStr: '', canFocus: true }); this.setState({ searchStr: '', canFocus: true });
if (typeof onBlur === 'function') {
onBlur();
}
}; };
formaterData = (data: any) => { formaterData = (data: any) => {
......
...@@ -28,8 +28,8 @@ interface State { ...@@ -28,8 +28,8 @@ interface State {
searchStr: string; searchStr: string;
list: any[]; list: any[];
loading: boolean; loading: boolean;
selected: any[] | undefined; selected: any;
tempSelected: any[] | undefined; tempSelected: any;
tempVisible: boolean; tempVisible: boolean;
} }
class TextSelect extends React.Component<Props, State> { class TextSelect extends React.Component<Props, State> {
...@@ -54,11 +54,11 @@ class TextSelect extends React.Component<Props, State> { ...@@ -54,11 +54,11 @@ class TextSelect extends React.Component<Props, State> {
static getDerivedStateFromProps(nextProps, prevState) { static getDerivedStateFromProps(nextProps, prevState) {
if (JSON.stringify(nextProps.value) !== JSON.stringify(prevState.tempSelected)) { if (JSON.stringify(nextProps.value) !== JSON.stringify(prevState.tempSelected)) {
const [first] = nextProps.value || []; const data = nextProps.value || {};
const searchStr = first ? first.label || first.text : ''; const searchStr = data.label || data.text;
return { return {
tempSelected: nextProps.value || [], tempSelected: data,
selected: nextProps.value, selected: data,
searchStr, searchStr,
}; };
} }
...@@ -106,7 +106,7 @@ class TextSelect extends React.Component<Props, State> { ...@@ -106,7 +106,7 @@ class TextSelect extends React.Component<Props, State> {
}; };
onResetValue = (searchStr) => { onResetValue = (searchStr) => {
return [{ value: '', label: searchStr }]; return { value: '', label: searchStr };
}; };
onSearch = (e) => { onSearch = (e) => {
...@@ -126,7 +126,7 @@ class TextSelect extends React.Component<Props, State> { ...@@ -126,7 +126,7 @@ class TextSelect extends React.Component<Props, State> {
onClickMenu = ({ item, key }) => { onClickMenu = ({ item, key }) => {
const { props } = item || {}; const { props } = item || {};
const { title } = props || {}; const { title } = props || {};
const selected = [{ label: title, value: key }]; const selected = { label: title, value: key };
this.setState({ selected, searchStr: title }); this.setState({ selected, searchStr: title });
this.onVisibleChange(false); this.onVisibleChange(false);
this.onChange(selected); this.onChange(selected);
...@@ -162,7 +162,7 @@ class TextSelect extends React.Component<Props, State> { ...@@ -162,7 +162,7 @@ class TextSelect extends React.Component<Props, State> {
<Menu <Menu
style={{ width: width || this.width }} style={{ width: width || this.width }}
onClick={this.onClickMenu} onClick={this.onClickMenu}
selectedKeys={selected ? [selected[0].value] : []} selectedKeys={selected ? [selected.value] : []}
> >
{list.map((item) => { {list.map((item) => {
return ( return (
......
...@@ -13,7 +13,7 @@ interface Props { ...@@ -13,7 +13,7 @@ interface Props {
dropdownStyle?: any dropdownStyle?: any
} }
class OrgTreeSelecte extends React.Component<Props> { class OrgTreeSelect extends React.Component<Props> {
state = { state = {
value: undefined, value: undefined,
} }
...@@ -67,4 +67,4 @@ class OrgTreeSelecte extends React.Component<Props> { ...@@ -67,4 +67,4 @@ class OrgTreeSelecte extends React.Component<Props> {
); );
} }
} }
export default OrgTreeSelecte export default OrgTreeSelect;
...@@ -66,11 +66,11 @@ export const config:any = { ...@@ -66,11 +66,11 @@ export const config:any = {
component: getComponent('13'), component: getComponent('13'),
icon: 'iconziduan-lianxiangduoxuan', icon: 'iconziduan-lianxiangduoxuan',
}, },
// '14': { '14': {
// name: '树结构', name: '树结构',
// component: getComponent('14'), component: getComponent('14'),
// icon: 'iconziduan-ren', icon: 'iconziduan-ren',
// }, },
'15': { '15': {
name: '文本搜索框', name: '文本搜索框',
component: getComponent('15'), component: getComponent('15'),
......
...@@ -119,3 +119,15 @@ export function getMergeStyle(style: any, mergeStyle: object | Function | undefi ...@@ -119,3 +119,15 @@ export function getMergeStyle(style: any, mergeStyle: object | Function | undefi
} }
return style; return style;
} }
/**
* 判断数值类型
* @param data 原数据
* @returns {boolean} 是否是数值
*/
export function isNumber(data) {
if (data === '' || data === null || Array.isArray(data)) {
return false;
}
// eslint-disable-next-line no-restricted-globals
return !isNaN(data);
}
import React, { useState, useEffect, useCallback } from 'react'; import React, { useState, useEffect, useCallback } from 'react';
import _ from 'lodash'; import _ from 'lodash';
import ApolloTable from '../apollo-table'; import ApolloTable from '../apollo-table';
import { getColumnConfig, getDataSource, addOrUpdateDataSource } from './serives'; import { getColumnConfig, getDataSource, addOrUpdateDataSource, approvalBusinessData } from './serives';
import { Input, message, DatePicker } from 'antd'; import { Input, message, DatePicker } from 'antd';
import moment from 'moment'; import moment from 'moment';
import s from './demo1.less'; import s from './demo1.less';
...@@ -32,7 +32,6 @@ const Demo1 = (props) => { ...@@ -32,7 +32,6 @@ const Demo1 = (props) => {
const res = await getColumnConfig({ tableId }); const res = await getColumnConfig({ tableId });
if (res && res.success && res.data) { if (res && res.success && res.data) {
let arr = Array.isArray(res.data) ? res.data : []; let arr = Array.isArray(res.data) ? res.data : [];
arr[0].columnType=2;
setColumns(formatColumns(arr)); setColumns(formatColumns(arr));
} }
}; };
...@@ -105,7 +104,7 @@ const Demo1 = (props) => { ...@@ -105,7 +104,7 @@ const Demo1 = (props) => {
const value = moment(cellData[0] && cellData[0].value); const value = moment(cellData[0] && cellData[0].value);
return ( return (
<div className={s.xxx}> <div className={s.xxx}>
<Input/> <Input />
</div> </div>
); );
} }
...@@ -116,6 +115,12 @@ const Demo1 = (props) => { ...@@ -116,6 +115,12 @@ const Demo1 = (props) => {
item.renderDetailCell = renderDetailCell; item.renderDetailCell = renderDetailCell;
// item.renderEditCell = renderEditCell; // item.renderEditCell = renderEditCell;
} }
if (Number(item.columnType) === 13 || Number(item.columnType) === 15) {
item.columnAttrObj.request = (data) => {
data.paramsJson = JSON.stringify({ tableId });
return approvalBusinessData(data);
};
}
return item; return item;
}); });
return columns; return columns;
......
...@@ -44,3 +44,11 @@ export async function delData({ data }) { ...@@ -44,3 +44,11 @@ export async function delData({ data }) {
export async function getDetail({ tableId, rowId }) { export async function getDetail({ tableId, rowId }) {
return request(`/follow/row/${tableId}/${rowId}`, { method: 'get', prefix: '/crmApi' }); return request(`/follow/row/${tableId}/${rowId}`, { method: 'get', prefix: '/crmApi' });
} }
// 通用审批 模糊搜索
export async function approvalBusinessData(params: any) {
return request('/approval/business', {
method: 'get',
params,
prefix: '/approvalApi',
});
}
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