Commit d96a8d96 authored by zhangwenshuai's avatar zhangwenshuai

update apolloTable link

parent 8618ab6d
...@@ -16,6 +16,10 @@ export const GetFormatter = { ...@@ -16,6 +16,10 @@ export const GetFormatter = {
const obj = Array.isArray(val) && val.length > 0 ? val[0] : {}; const obj = Array.isArray(val) && val.length > 0 ? val[0] : {};
return obj.value; return obj.value;
}, },
TEXTLINK: (val) => {
const obj = Array.isArray(val) && val.length > 0 ? val[0] : {};
return obj.value;
},
UPLOAD: (val) => { UPLOAD: (val) => {
if (!Array.isArray(val)) return undefined; if (!Array.isArray(val)) return undefined;
return val.map((item) => { return val.map((item) => {
......
...@@ -17,6 +17,12 @@ export const SetFormatter = { ...@@ -17,6 +17,12 @@ export const SetFormatter = {
} }
return [{ value, text: value }]; return [{ value, text: value }];
}, },
TEXTLINK: (value) => {
if (!value) {
return emptyModel;
}
return [{ value, text: value }];
},
UPLOAD: (val) => { UPLOAD: (val) => {
if (!val) return emptyModel; if (!val) return emptyModel;
return val.map((item) => { return val.map((item) => {
......
...@@ -39,6 +39,7 @@ import { ...@@ -39,6 +39,7 @@ import {
ApolloTreeSelectDetail, ApolloTreeSelectDetail,
ApolloUploadDetail, ApolloUploadDetail,
ApolloDateRangeDetail, ApolloDateRangeDetail,
ApolloTextLinkDetail,
} from './detail'; } from './detail';
import CellContainer from './edit/container'; import CellContainer from './edit/container';
...@@ -55,13 +56,22 @@ export const config: any = { ...@@ -55,13 +56,22 @@ export const config: any = {
detailComp: ApolloInputDetail, detailComp: ApolloInputDetail,
icon: 'iconziduan-danhangwenben', icon: 'iconziduan-danhangwenben',
}, },
// 2: {
// name: '超链接',
// editComp: ApolloLink,
// cellComp: CellContainer(ApolloLink),
// getFormatter: GetFormatter.LINK,
// setFormatter: SetFormatter.LINK,
// detailComp: ApolloLinkDetail,
// icon: 'iconziduan-chaolianjie',
// },
2: { 2: {
name: '超链接', name: '超链接',
editComp: ApolloLink, editComp: ApolloTextArea,
cellComp: CellContainer(ApolloLink), cellComp: CellContainer(ApolloTextArea),
getFormatter: GetFormatter.LINK, getFormatter: GetFormatter.TEXTLINK,
setFormatter: SetFormatter.LINK, setFormatter: SetFormatter.TEXTLINK,
detailComp: ApolloLinkDetail, detailComp: ApolloTextLinkDetail,
icon: 'iconziduan-chaolianjie', icon: 'iconziduan-chaolianjie',
}, },
3: { 3: {
......
...@@ -15,6 +15,7 @@ import { ApolloTextAreaDetail } from './textarea'; ...@@ -15,6 +15,7 @@ import { ApolloTextAreaDetail } from './textarea';
import { ApolloTreeSelectDetail } from './tree-select'; import { ApolloTreeSelectDetail } from './tree-select';
import { ApolloUploadDetail } from './upload'; import { ApolloUploadDetail } from './upload';
import { ApolloDateRangeDetail } from './dateRange'; import { ApolloDateRangeDetail } from './dateRange';
import { ApolloTextLinkDetail } from './text-link';
export { export {
ApolloInputDetail, ApolloInputDetail,
...@@ -34,4 +35,5 @@ export { ...@@ -34,4 +35,5 @@ export {
ApolloTreeSelectDetail, ApolloTreeSelectDetail,
ApolloUploadDetail, ApolloUploadDetail,
ApolloDateRangeDetail, ApolloDateRangeDetail,
ApolloTextLinkDetail,
}; };
@import '../../../../common';
.container {
position: relative;
display: flex;
width: 100%;
height: 100%;
align-items: center;
.outContainer {
display: flex;
width: calc(100% - 30px);
overflow: hidden;
.innerContainer {
display: flex;
.item {
margin-right: 10px;
//background: #e9eef9;
border-radius: 12px;
&.multi {
border-radius: @borderRadius;
}
.itemBgTxt {
height: 24px;
padding: 5px 10px;
line-height: 1;
font-size: 14px;
color: @textGeneralColor;
}
&:last-child {
margin-right: 0;
}
}
}
}
.moreBtn {
width: 30px;
font-size: 12px;
cursor: pointer;
text-align: center;
.extend {
width: 14px;
border-radius: 50%;
}
}
}
.popContainer{
width: 200px;
:global(.ant-popover-inner-content){
padding: 0;
}
.popContent{
padding: @paddingGen;
}
}
.popItem {
border-radius: @borderRadius;
margin-bottom: @marginSm;
background: #e9eef9;
padding: @paddingSmX;
display: flex;
.popItemBgTxt {
word-break: break-all;
height: 24px;
padding: 5px 10px;
line-height: 1;
font-size: 14px;
}
}
import React, { useState, useRef, useEffect } from 'react';
import { Popover } from 'antd';
import classNames from 'classnames';
import s from './index.less';
import extendIcon from '../../../../assets/extend.png';
export const ApolloTextLinkDetail = (props: any) => {
const { value, origin, formatter } = props;
const newValue = formatter ? formatter(value) : value;
if (!newValue) return null;
const arr = newValue.split(',');
const [dotVisible, setDotVisible] = useState(false);
const outer = useRef(null);
const inner = useRef(null);
useEffect(() => {
const outerTarget: any = outer.current;
const innerTarget: any = inner.current;
if (outerTarget && innerTarget && origin !== 'detailForm') {
if (innerTarget.clientWidth > outerTarget.clientWidth) {
setDotVisible(true);
} else {
setDotVisible(false);
}
}
}, [value]);
const outStyle: any = {};
const innerStyle: any = {};
const itemStyle: any = {};
if (origin === 'detailForm') {
outStyle.width = 'auto';
innerStyle.flexWrap = 'wrap';
itemStyle.marginBottom = '5px';
itemStyle.wordBreak = 'break-all';
}
return (
<div className={s.container}>
<div className={s.outContainer} ref={outer} style={outStyle}>
<div className={s.innerContainer} ref={inner} style={innerStyle}>
{arr.map((item, i) => {
return (
<a
key={i}
target="_blank"
href={item}
className={s.item}
style={itemStyle}
rel="noopener noreferrer"
>
{item}
</a>
);
})}
</div>
</div>
{dotVisible && (
<Popover
trigger="click"
onClick={(e) => {
e.stopPropagation();
}}
placement="left"
overlayClassName={s.popContainer}
content={
<div
className={s.popContent}
onClick={(e) => {
e.stopPropagation();
}}
>
{arr.map((item, i) => {
return (
<a
key={i}
target="_blank"
href={item}
className={s.popItem}
style={itemStyle}
rel="noopener noreferrer"
>
{item}
</a>
);
})}
</div>
}
>
<div className={s.moreBtn}>
<img alt="" className={s.extend} src={extendIcon} />
</div>
</Popover>
)}
</div>
);
};
...@@ -8,7 +8,7 @@ import { floatNumberReg, intNumberReg } from '../../../../utils/reg'; ...@@ -8,7 +8,7 @@ import { floatNumberReg, intNumberReg } from '../../../../utils/reg';
export const ApolloNumber = (props: ApolloNumberProps) => { export const ApolloNumber = (props: ApolloNumberProps) => {
const { onChange, columnConfig }: any = props; const { onChange, columnConfig }: any = props;
const { columnAttrObj = {} } = columnConfig; const { columnAttrObj = {} } = columnConfig;
const { precision, dataType } = columnAttrObj; const { dataType } = columnAttrObj;
const selfProps = antiAssign(props, ['columnConfig', 'onChange']); const selfProps = antiAssign(props, ['columnConfig', 'onChange']);
const changeValue = (newValue: any) => { const changeValue = (newValue: any) => {
if (dataType === 'INT') { if (dataType === 'INT') {
...@@ -30,7 +30,6 @@ export const ApolloNumber = (props: ApolloNumberProps) => { ...@@ -30,7 +30,6 @@ export const ApolloNumber = (props: ApolloNumberProps) => {
<InputNumber <InputNumber
className={styles.number} className={styles.number}
{...o} {...o}
precision={precision}
onChange={changeValue} onChange={changeValue}
/> />
); );
......
import React from 'react'; import React from 'react';
import { Spin, Select } from 'antd'; import { Spin, Select } from 'antd';
import lodash from 'lodash'; import lodash from 'lodash';
import { Consumer } from '../../../context';
import s from './index.less'; import s from './index.less';
interface Props { interface Props {
...@@ -206,17 +207,13 @@ class AssociationSearch extends React.Component<Props, State> { ...@@ -206,17 +207,13 @@ class AssociationSearch extends React.Component<Props, State> {
} }
}; };
notFoundContent = () => { notFoundContent = (locale) => {
const { data, fetching, value } = this.state; const { data, fetching, value } = this.state;
if (fetching) { if (fetching) {
return <Spin size="small" />; return <Spin size="small" />;
} }
if (!data || data.length === 0) { if (!data || data.length === 0) {
return ( return <span style={{ fontSize: '12px' }}>{locale.notFoundContent}</span>;
<span style={{ fontSize: '12px' }}>
Sorry, the data you queried does not exist or has been deleted.
</span>
);
} }
return null; return null;
}; };
...@@ -224,6 +221,9 @@ class AssociationSearch extends React.Component<Props, State> { ...@@ -224,6 +221,9 @@ class AssociationSearch extends React.Component<Props, State> {
render() { render() {
const { data, fetching, value } = this.state; const { data, fetching, value } = this.state;
const { selfCom, autoFocus, onChange, ...rest } = this.props; const { selfCom, autoFocus, onChange, ...rest } = this.props;
return (
<Consumer>
{({ locale }) => {
return ( return (
<Select <Select
filterOption={false} filterOption={false}
...@@ -231,7 +231,7 @@ class AssociationSearch extends React.Component<Props, State> { ...@@ -231,7 +231,7 @@ class AssociationSearch extends React.Component<Props, State> {
value={value} value={value}
showSearch={true} showSearch={true}
labelInValue={true} labelInValue={true}
notFoundContent={this.notFoundContent()} notFoundContent={this.notFoundContent(locale)}
onSearch={this.onSearch} onSearch={this.onSearch}
onChange={this.handleChange} onChange={this.handleChange}
onFocus={this.onFocus} onFocus={this.onFocus}
...@@ -246,6 +246,9 @@ class AssociationSearch extends React.Component<Props, State> { ...@@ -246,6 +246,9 @@ class AssociationSearch extends React.Component<Props, State> {
})} })}
</Select> </Select>
); );
}}
</Consumer>
);
} }
} }
......
...@@ -22,6 +22,7 @@ export const defaultLocale: any = { ...@@ -22,6 +22,7 @@ export const defaultLocale: any = {
alreadyInput: '已输入', alreadyInput: '已输入',
linkText: '文本:', linkText: '文本:',
linkUrl: 'url:', linkUrl: 'url:',
notFoundContent: '对不起,您查询的数据不存在或已被删除',
}, },
en: { en: {
empty: 'It’s empty here.', empty: 'It’s empty here.',
...@@ -46,5 +47,6 @@ export const defaultLocale: any = { ...@@ -46,5 +47,6 @@ export const defaultLocale: any = {
alreadyInput: 'Entered', alreadyInput: 'Entered',
linkText: 'text:', linkText: 'text:',
linkUrl: 'url:', linkUrl: 'url:',
notFoundContent: 'Sorry, the data you queried does not exist or has been deleted.',
}, },
}; };
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