提交 dfa4fcf0 authored 作者: 钟是志's avatar 钟是志

定位组件增加判断. 是否必填

上级 34905ef7
...@@ -81,7 +81,12 @@ const giveRender = (column = {}) => { ...@@ -81,7 +81,12 @@ const giveRender = (column = {}) => {
return column; return column;
}; };
@connect(({ DataColumn, SqlManageEntity, formList, loading }) => ({ @connect(({
DataColumn,
SqlManageEntity,
formList,
loading,
}) => ({
DataColumn, DataColumn,
SqlManageEntity, SqlManageEntity,
formList, formList,
...@@ -186,7 +191,12 @@ export default class tableCom extends Component { ...@@ -186,7 +191,12 @@ export default class tableCom extends Component {
}; };
getColumnSearchProps = (dataIndex, title) => ({ getColumnSearchProps = (dataIndex, title) => ({
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => ( filterDropdown: ({
setSelectedKeys,
selectedKeys,
confirm,
clearFilters,
}) => (
<div style={{ padding: 8 }}> <div style={{ padding: 8 }}>
<Input <Input
ref={node => { ref={node => {
...@@ -203,11 +213,11 @@ export default class tableCom extends Component { ...@@ -203,11 +213,11 @@ export default class tableCom extends Component {
}} }}
/> />
<Button <Button
type="primary" type='primary'
onClick={() => this.handleSearch(selectedKeys, confirm)} onClick={() => this.handleSearch(selectedKeys, confirm)}
icon="search" icon='search'
loading={this.props.loading} loading={this.props.loading}
size="small" size='small'
style={{ style={{
width: 90, width: 90,
marginRight: 8, marginRight: 8,
...@@ -218,14 +228,14 @@ export default class tableCom extends Component { ...@@ -218,14 +228,14 @@ export default class tableCom extends Component {
<Button <Button
loading={this.props.loading} loading={this.props.loading}
onClick={() => this.handleReset(clearFilters)} onClick={() => this.handleReset(clearFilters)}
size="small" size='small'
style={{ width: 90 }} style={{ width: 90 }}
> >
重置 重置
</Button> </Button>
</div> </div>
), ),
filterIcon: filtered => <Icon type="search" style={{ color: filtered ? '#1890ff' : 'red' }} />, filterIcon: filtered => <Icon type='search' style={{ color: filtered ? '#1890ff' : 'red' }} />,
onFilter: (value, record) => onFilter: (value, record) =>
record[dataIndex] record[dataIndex]
? record[dataIndex] ? record[dataIndex]
...@@ -273,7 +283,11 @@ export default class tableCom extends Component { ...@@ -273,7 +283,11 @@ export default class tableCom extends Component {
}; };
componentWillReceiveProps(props) { componentWillReceiveProps(props) {
const { json, mapData, obj } = props; const {
json,
mapData,
obj,
} = props;
if (json == null || this.props.safe) { if (json == null || this.props.safe) {
return; return;
} }
...@@ -391,7 +405,10 @@ export default class tableCom extends Component { ...@@ -391,7 +405,10 @@ export default class tableCom extends Component {
allValues = JSON.stringify(allValues); allValues = JSON.stringify(allValues);
if (json.comName === 'TableSelect') { if (json.comName === 'TableSelect') {
const { dispatch } = this.props; const { dispatch } = this.props;
const { sqlKey, optionType } = json; const {
sqlKey,
optionType,
} = json;
if (optionType === 'sql') { if (optionType === 'sql') {
dispatch({ dispatch({
type: 'SqlManageEntity/find', type: 'SqlManageEntity/find',
...@@ -413,7 +430,8 @@ export default class tableCom extends Component { ...@@ -413,7 +430,8 @@ export default class tableCom extends Component {
if ( if (
['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'].includes(datas[i].type) ['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'].includes(datas[i].type)
) { ) {
column.render = val => moment(val).format('YYYY-MM-DD HH:mm:ss'); column.render = val => moment(val)
.format('YYYY-MM-DD HH:mm:ss');
} }
column = giveRender(column); column = giveRender(column);
...@@ -450,7 +468,8 @@ export default class tableCom extends Component { ...@@ -450,7 +468,8 @@ export default class tableCom extends Component {
break; break;
} }
column.render = val => moment(parseInt(val)).format(ff); column.render = val => moment(parseInt(val))
.format(ff);
} }
if (cll[k].isQuery) { if (cll[k].isQuery) {
column = { column = {
...@@ -497,7 +516,8 @@ export default class tableCom extends Component { ...@@ -497,7 +516,8 @@ export default class tableCom extends Component {
column.title = datas[i].title; column.title = datas[i].title;
column.dataIndex = datas[i].name; column.dataIndex = datas[i].name;
if (['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'].includes(datas[i].type)) { if (['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'].includes(datas[i].type)) {
column.render = val => moment(val).format('YYYY-MM-DD HH:mm:ss'); column.render = val => moment(val)
.format('YYYY-MM-DD HH:mm:ss');
} }
column = giveRender(column); column = giveRender(column);
columns.push(column); columns.push(column);
...@@ -764,7 +784,8 @@ export default class tableCom extends Component { ...@@ -764,7 +784,8 @@ export default class tableCom extends Component {
data: requestParams, data: requestParams,
method: method, method: method,
requestType: 'form', requestType: 'form',
}).then(data => { })
.then(data => {
// if (!data || !Array.isArray(data)) { // if (!data || !Array.isArray(data)) {
// data = []; // data = [];
// } // }
...@@ -955,7 +976,8 @@ export default class tableCom extends Component { ...@@ -955,7 +976,8 @@ export default class tableCom extends Component {
if (getToken() != null) { if (getToken() != null) {
pp.token = getToken(); pp.token = getToken();
} }
uaaRequest(url, pp).then(data => { uaaRequest(url, pp)
.then(data => {
const { sqlKeys } = this.state; const { sqlKeys } = this.state;
sqlKeys[sqlKey].data = data; sqlKeys[sqlKey].data = data;
this.setState({ sqlKeys }); this.setState({ sqlKeys });
...@@ -1158,7 +1180,12 @@ export default class tableCom extends Component { ...@@ -1158,7 +1180,12 @@ export default class tableCom extends Component {
}; };
componentDidMount() { componentDidMount() {
const { json, mapData, obj, init } = this.props; const {
json,
mapData,
obj,
init,
} = this.props;
if (json == null) { if (json == null) {
return; return;
} }
...@@ -1406,7 +1433,10 @@ export default class tableCom extends Component { ...@@ -1406,7 +1433,10 @@ export default class tableCom extends Component {
} }
}; };
getColumn = key => { getColumn = key => {
let { mapData, json } = this.props; let {
mapData,
json,
} = this.props;
const columnIds = json.columnIds; const columnIds = json.columnIds;
...@@ -1449,8 +1479,20 @@ export default class tableCom extends Component { ...@@ -1449,8 +1479,20 @@ export default class tableCom extends Component {
getCellValue, getCellValue,
} = this.props; } = this.props;
// console.log(this.props.datas); // console.log(this.props.datas);
const { options, labels, selectDis, modalCode, modalTitle, modalInit, modalProps } = this.state; const {
const { getFieldDecorator, getFieldError, getFieldProps } = this.props.form; options,
labels,
selectDis,
modalCode,
modalTitle,
modalInit,
modalProps,
} = this.state;
const {
getFieldDecorator,
getFieldError,
getFieldProps,
} = this.props.form;
const disabled = json != null ? json.disabled : false; const disabled = json != null ? json.disabled : false;
const permRank = json != null ? (json.permRank != null ? json.permRank : 0) : 0; const permRank = json != null ? (json.permRank != null ? json.permRank : 0) : 0;
if (json?.label === '账号') { if (json?.label === '账号') {
...@@ -1504,7 +1546,7 @@ export default class tableCom extends Component { ...@@ -1504,7 +1546,7 @@ export default class tableCom extends Component {
<> <>
{this.props.form.getFieldDecorator(this.props.uuid, { {this.props.form.getFieldDecorator(this.props.uuid, {
initialValue: fk, initialValue: fk,
})(<Input type="hidden" />)}{' '} })(<Input type='hidden' />)}{' '}
<ZdyTable <ZdyTable
taskId={this.props.taskId} taskId={this.props.taskId}
importExcel={this.props.importExcel} importExcel={this.props.importExcel}
...@@ -1580,7 +1622,7 @@ export default class tableCom extends Component { ...@@ -1580,7 +1622,7 @@ export default class tableCom extends Component {
<> <>
{this.props.form.getFieldDecorator(uid, { {this.props.form.getFieldDecorator(uid, {
initialValue: obj[this.props.uuid] || json.initialValue, initialValue: obj[this.props.uuid] || json.initialValue,
})(<Input type="hidden" />)} })(<Input type='hidden' />)}
<span <span
style={{ style={{
fontWeight: get === 'mobile' ? 'bold' : '', fontWeight: get === 'mobile' ? 'bold' : '',
...@@ -1597,7 +1639,7 @@ export default class tableCom extends Component { ...@@ -1597,7 +1639,7 @@ export default class tableCom extends Component {
<> <>
{this.props.form.getFieldDecorator(uid, { {this.props.form.getFieldDecorator(uid, {
initialValue: this.props.form.getFieldsValue()[uid] || json.initialValue, initialValue: this.props.form.getFieldsValue()[uid] || json.initialValue,
})(<Input type="hidden" />)} })(<Input type='hidden' />)}
<span <span
style={{ style={{
fontWeight: get === 'mobile' ? 'bold' : '', fontWeight: get === 'mobile' ? 'bold' : '',
...@@ -1690,7 +1732,8 @@ export default class tableCom extends Component { ...@@ -1690,7 +1732,8 @@ export default class tableCom extends Component {
case 'DatePicker': case 'DatePicker':
cm = value ? ( cm = value ? (
<span> <span>
{moment(parseInt(value)).format('YYYY-MM-DD HH:mm:ss')} {moment(parseInt(value))
.format('YYYY-MM-DD HH:mm:ss')}
{get === 'mobile' ? <br /> : ''} {get === 'mobile' ? <br /> : ''}
</span> </span>
) : ( ) : (
...@@ -1706,7 +1749,7 @@ export default class tableCom extends Component { ...@@ -1706,7 +1749,7 @@ export default class tableCom extends Component {
{filesX.map((f, index2) => { {filesX.map((f, index2) => {
return ( return (
<li key={index2}> <li key={index2}>
<a target="_blank" key={f.path} href={queryApiActionPath() + f.path}> <a target='_blank' key={f.path} href={queryApiActionPath() + f.path}>
{f.name} {f.name}
</a> </a>
</li> </li>
...@@ -1726,7 +1769,7 @@ export default class tableCom extends Component { ...@@ -1726,7 +1769,7 @@ export default class tableCom extends Component {
{files.map((f, index2) => { {files.map((f, index2) => {
return ( return (
<li key={index2}> <li key={index2}>
<a target="_blank" key={f.path} href={queryApiActionPath() + f.path}> <a target='_blank' key={f.path} href={queryApiActionPath() + f.path}>
{f.name} {f.name}
</a> </a>
</li> </li>
...@@ -1819,7 +1862,7 @@ export default class tableCom extends Component { ...@@ -1819,7 +1862,7 @@ export default class tableCom extends Component {
</MobileItem> </MobileItem>
{this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, { {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
initialValue: value, initialValue: value,
})(<Input type="hidden" />)} })(<Input type='hidden' />)}
</> </>
); );
} }
...@@ -1832,7 +1875,7 @@ export default class tableCom extends Component { ...@@ -1832,7 +1875,7 @@ export default class tableCom extends Component {
{cm} {cm}
{this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, { {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
initialValue: value, initialValue: value,
})(<Input type="hidden" />)} })(<Input type='hidden' />)}
</> </>
); );
} }
...@@ -1926,7 +1969,7 @@ export default class tableCom extends Component { ...@@ -1926,7 +1969,7 @@ export default class tableCom extends Component {
</Form.Item> </Form.Item>
{this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, { {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
initialValue: value, initialValue: value,
})(<Input type="hidden" />)} })(<Input type='hidden' />)}
</> </>
); );
} }
...@@ -1939,7 +1982,7 @@ export default class tableCom extends Component { ...@@ -1939,7 +1982,7 @@ export default class tableCom extends Component {
{cm} {cm}
{this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, { {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
initialValue: value, initialValue: value,
})(<Input type="hidden" />)} })(<Input type='hidden' />)}
</> </>
); );
} }
...@@ -2124,7 +2167,7 @@ export default class tableCom extends Component { ...@@ -2124,7 +2167,7 @@ export default class tableCom extends Component {
<Table <Table
get={get} get={get}
columns={this.state.columns} columns={this.state.columns}
size="small" size='small'
dataSource={ds} dataSource={ds}
pagination={false} pagination={false}
/> />
...@@ -2157,11 +2200,13 @@ export default class tableCom extends Component { ...@@ -2157,11 +2200,13 @@ export default class tableCom extends Component {
} else { } else {
cm = ( cm = (
<span> <span>
{moment(parseInt(obj[begin.base52])).format( {moment(parseInt(obj[begin.base52]))
.format(
json.format ? json.format : 'YYYY-MM-DD HH:mm:ss', json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
)}{' '} )}{' '}
{' '} {' '}
{moment(parseInt(obj[end.base52])).format( {moment(parseInt(obj[end.base52]))
.format(
json.format ? json.format : 'YYYY-MM-DD HH:mm:ss', json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
)} )}
</span> </span>
...@@ -2176,7 +2221,8 @@ export default class tableCom extends Component { ...@@ -2176,7 +2221,8 @@ export default class tableCom extends Component {
if (obj[dataColumn.base52] && obj[dataColumn.base52].indexOf('-') === -1) { if (obj[dataColumn.base52] && obj[dataColumn.base52].indexOf('-') === -1) {
cm = ( cm = (
<span> <span>
{moment(parseInt(obj[dataColumn.base52])).format( {moment(parseInt(obj[dataColumn.base52]))
.format(
json.format ? json.format : 'YYYY-MM-DD HH:mm:ss', json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
)} )}
</span> </span>
...@@ -2185,7 +2231,8 @@ export default class tableCom extends Component { ...@@ -2185,7 +2231,8 @@ export default class tableCom extends Component {
cm = ( cm = (
<span> <span>
{obj[dataColumn.base52] {obj[dataColumn.base52]
? moment(+new Date(obj[dataColumn.base52])).format( ? moment(+new Date(obj[dataColumn.base52]))
.format(
json.format ? json.format : 'YYYY-MM-DD HH:mm:ss', json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
) )
: ''} : ''}
...@@ -2293,7 +2340,7 @@ export default class tableCom extends Component { ...@@ -2293,7 +2340,7 @@ export default class tableCom extends Component {
} }
return ( return (
<li key={index2}> <li key={index2}>
<a target="_blank" key={f.path} href={queryApiActionPath() + f.path}> <a target='_blank' key={f.path} href={queryApiActionPath() + f.path}>
{f.name} {f.name}
</a> </a>
</li> </li>
...@@ -2330,7 +2377,7 @@ export default class tableCom extends Component { ...@@ -2330,7 +2377,7 @@ export default class tableCom extends Component {
return ( return (
<li key={index2}> <li key={index2}>
<a <a
target="_blank" target='_blank'
key={f.filePath} key={f.filePath}
href={queryApiActionPath() + f.filePath} href={queryApiActionPath() + f.filePath}
> >
...@@ -2490,7 +2537,7 @@ export default class tableCom extends Component { ...@@ -2490,7 +2537,7 @@ export default class tableCom extends Component {
if (json.isLink) { if (json.isLink) {
cm = <a {...ev} />; cm = <a {...ev} />;
} else { } else {
cm = <Button loading={this.props.loading} type="primary" {...ev} />; cm = <Button loading={this.props.loading} type='primary' {...ev} />;
} }
} }
...@@ -2576,7 +2623,7 @@ export default class tableCom extends Component { ...@@ -2576,7 +2623,7 @@ export default class tableCom extends Component {
if (json.isLink) { if (json.isLink) {
cm = <a {...ev} />; cm = <a {...ev} />;
} else { } else {
cm = <Button loading={this.props.loading} type="primary" {...ev} />; cm = <Button loading={this.props.loading} type='primary' {...ev} />;
} }
} }
...@@ -2761,7 +2808,7 @@ export default class tableCom extends Component { ...@@ -2761,7 +2808,7 @@ export default class tableCom extends Component {
case 'InputHidden': case 'InputHidden':
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue, initialValue: initValue,
})(<Input type="hidden" />); })(<Input type='hidden' />);
break; break;
case 'InputNumber': case 'InputNumber':
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
...@@ -2849,7 +2896,7 @@ export default class tableCom extends Component { ...@@ -2849,7 +2896,7 @@ export default class tableCom extends Component {
case 'Checkbox': case 'Checkbox':
if (get === 'mobile') { if (get === 'mobile') {
cm = ( cm = (
<Flex direction="column" align="start"> <Flex direction='column' align='start'>
{getFieldDecorator(dataColumn.base52, { {getFieldDecorator(dataColumn.base52, {
initialValue: initValue, // 默认值 initialValue: initValue, // 默认值
rules: rules:
...@@ -2932,7 +2979,7 @@ export default class tableCom extends Component { ...@@ -2932,7 +2979,7 @@ export default class tableCom extends Component {
disabled={selectDis || disabled} disabled={selectDis || disabled}
placeholder={json.placeholder} placeholder={json.placeholder}
style={{ width: json.width }} style={{ width: json.width }}
optionFilterProp="children" optionFilterProp='children'
getPopupContainer={ getPopupContainer={
this.props.isDynamic && document.querySelector('#dynamic_div') this.props.isDynamic && document.querySelector('#dynamic_div')
? () => { ? () => {
...@@ -2959,7 +3006,8 @@ export default class tableCom extends Component { ...@@ -2959,7 +3006,8 @@ export default class tableCom extends Component {
}} }}
filterOption={(input, option) => filterOption={(input, option) =>
option option
? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 ? option.props.children.toLowerCase()
.indexOf(input.toLowerCase()) >= 0
: false : false
} }
{...otherProps} {...otherProps}
...@@ -3008,7 +3056,8 @@ export default class tableCom extends Component { ...@@ -3008,7 +3056,8 @@ export default class tableCom extends Component {
} }
const filterF = function filter(inputValue, path) { const filterF = function filter(inputValue, path) {
return path.some( return path.some(
option => option?.label?.toLowerCase()?.indexOf(inputValue.toLowerCase()) > -1, option => option?.label?.toLowerCase()
?.indexOf(inputValue.toLowerCase()) > -1,
); );
}; };
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
...@@ -3157,11 +3206,13 @@ export default class tableCom extends Component { ...@@ -3157,11 +3206,13 @@ export default class tableCom extends Component {
if (!isEdit) { if (!isEdit) {
cm = ( cm = (
<span> <span>
{moment(parseInt(obj[begin.base52])).format( {moment(parseInt(obj[begin.base52]))
.format(
json.format ? json.format : 'YYYY-MM-DD HH:mm:ss', json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
)}{' '} )}{' '}
{' '} {' '}
{moment(parseInt(obj[end.base52])).format( {moment(parseInt(obj[end.base52]))
.format(
json.format ? json.format : 'YYYY-MM-DD HH:mm:ss', json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
)} )}
</span> </span>
...@@ -3265,7 +3316,8 @@ export default class tableCom extends Component { ...@@ -3265,7 +3316,8 @@ export default class tableCom extends Component {
} }
}); });
} }
: () => {} : () => {
}
} }
format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'} format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'}
/>, />,
...@@ -3456,10 +3508,17 @@ export default class tableCom extends Component { ...@@ -3456,10 +3508,17 @@ export default class tableCom extends Component {
rules: rules:
json.vlds && json.vlds.length > 0 json.vlds && json.vlds.length > 0
? json.vlds ? json.vlds
: [ : [{
{ required,
required: required, message: '请获取定位信息',
message: '请进行定位', validator: (rule, valueThis, callback) => {
let errors = [];
console.log(valueThis);
if ((!valueThis || !JSON.stringify(valueThis).includes('address')) && required) {
errors.push(new Error('请获取定位信息', rule.field));
}
callback(errors);
},
}, },
], ],
})( })(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论