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

28713 【弹出列表框】禁用优化

上级 b02d0411
import React from "react"; import React from 'react';
import { Button, message, Table, Tag } from "antd"; import { Button, message, Table, Tag } from 'antd';
import FormList from "./formList/index"; import FormList from './formList/index';
import { connect } from "dva"; import { connect } from 'dva';
import { getModal } from '@/webPublic/one_stop_public/utils/utils'; import { getModal } from '@/webPublic/one_stop_public/utils/utils';
import TableSelectNormal from '@/webPublic/one_stop_public/libs/Split/TableSelectNormal'; import TableSelectNormal from '@/webPublic/one_stop_public/libs/Split/TableSelectNormal';
import styles from './Split/styles.less'; import styles from './Split/styles.less';
const Modal = getModal(); const Modal = getModal();
@connect(({ DataColumn, SqlManageEntity, loading }) => ({ @connect(({
DataColumn,
SqlManageEntity,
loading
}) => ({
DataColumn, DataColumn,
SqlManageEntity, SqlManageEntity,
loading: loading.models.DataColumn || loading.models.SqlManageEntity, loading: loading.models.DataColumn || loading.models.SqlManageEntity,
...@@ -22,7 +27,7 @@ export default class TableSelect extends React.Component { ...@@ -22,7 +27,7 @@ export default class TableSelect extends React.Component {
try { try {
this.otherProps = new Function(props.json.otherProps)(); this.otherProps = new Function(props.json.otherProps)();
} catch (e) { } catch (e) {
console.log('TableSelect组件 otherProps 获取失败') console.log('TableSelect组件 otherProps 获取失败');
} }
} }
this.state = { this.state = {
...@@ -67,7 +72,10 @@ export default class TableSelect extends React.Component { ...@@ -67,7 +72,10 @@ export default class TableSelect extends React.Component {
select = (obj) => { select = (obj) => {
var { selects } = this.state; var { selects } = this.state;
const { const {
json: { isMultiple, optionType }, json: {
isMultiple,
optionType
},
} = this.props; } = this.props;
let valueName = this.props.json.valueName; let valueName = this.props.json.valueName;
...@@ -81,7 +89,12 @@ export default class TableSelect extends React.Component { ...@@ -81,7 +89,12 @@ export default class TableSelect extends React.Component {
return; return;
} }
if (!isMultiple) { if (!isMultiple) {
selects = { [kk]: { ...obj, selectKey: kk } }; selects = {
[kk]: {
...obj,
selectKey: kk
}
};
} else { } else {
selects[kk] = obj; selects[kk] = obj;
selects[kk].selectKey = kk; selects[kk].selectKey = kk;
...@@ -94,8 +107,14 @@ export default class TableSelect extends React.Component { ...@@ -94,8 +107,14 @@ export default class TableSelect extends React.Component {
selectAll = () => { selectAll = () => {
let { selects } = this.state; let { selects } = this.state;
const { dataSource, json } = this.props; const {
let { valueName, optionType } = json; dataSource,
json
} = this.props;
let {
valueName,
optionType
} = json;
const { list } = dataSource; const { list } = dataSource;
if (optionType == 'reference' && this.props.dataColumn.referenceObjId) { if (optionType == 'reference' && this.props.dataColumn.referenceObjId) {
valueName = this.props.dataColumn.referenceCodeName; valueName = this.props.dataColumn.referenceCodeName;
...@@ -122,13 +141,22 @@ export default class TableSelect extends React.Component { ...@@ -122,13 +141,22 @@ export default class TableSelect extends React.Component {
}; };
close = (i) => { close = (i) => {
var { values, labels } = this.state; var {
values,
labels
} = this.state;
values.splice(i, 1); values.splice(i, 1);
labels.splice(i, 1); labels.splice(i, 1);
if (!('value' in this.props)) { if (!('value' in this.props)) {
this.setState({ values, labels }); this.setState({
values,
labels
});
} }
this.triggerChange({ values, labels }); this.triggerChange({
values,
labels
});
}; };
open = () => { open = () => {
...@@ -150,7 +178,10 @@ export default class TableSelect extends React.Component { ...@@ -150,7 +178,10 @@ export default class TableSelect extends React.Component {
cancelOne = (record) => { cancelOne = (record) => {
var { selects } = this.state; var { selects } = this.state;
const { const {
json: { isMultiple, optionType }, json: {
isMultiple,
optionType
},
} = this.props; } = this.props;
let valueName = this.props.json.valueName; let valueName = this.props.json.valueName;
...@@ -174,16 +205,25 @@ export default class TableSelect extends React.Component { ...@@ -174,16 +205,25 @@ export default class TableSelect extends React.Component {
render() { render() {
const { const {
json: { isMultiple, sql, optionType, showTable, isShowQuanXuan }, json: {
isMultiple,
sql,
optionType,
showTable,
isShowQuanXuan
},
dataColumn: { referenceObjId }, dataColumn: { referenceObjId },
sqlModel, sqlModel,
columns, columns,
dataSource, dataSource,
disabled,
} = this.props; } = this.props;
let disabled = this.props.disabled || this.props.json.disabled;
const { cardSelectModalProps = {} } = this.otherProps; const { cardSelectModalProps = {} } = this.otherProps;
let { valueName, labelName } = this.props.json; let {
valueName,
labelName
} = this.props.json;
if (optionType == 'reference' && referenceObjId) { if (optionType == 'reference' && referenceObjId) {
valueName = this.props.dataColumn.referenceCodeName; valueName = this.props.dataColumn.referenceCodeName;
labelName = this.props.dataColumn.referenceNameName; labelName = this.props.dataColumn.referenceNameName;
...@@ -191,21 +231,29 @@ export default class TableSelect extends React.Component { ...@@ -191,21 +231,29 @@ export default class TableSelect extends React.Component {
if (valueName == null || valueName == '') { if (valueName == null || valueName == '') {
return <>请指定取值的列名</>; return <>请指定取值的列名</>;
} }
const { selects, visiable, labels } = this.state; const {
selects,
visiable,
labels
} = this.state;
const keys = []; const keys = [];
for (let i in selects) { for (let i in selects) {
keys.push(selects[i][valueName]); keys.push(selects[i][valueName]);
} }
const columns2 = [ const columns2 = [
...columns, ...columns,
{ ];
if (!disabled) {
columns2.push({
title: '操作', title: '操作',
render: (val, record) => <a onClick={this.remove.bind(this, record.selectKey)}>移除</a>, render: (val, record) => <a onClick={this.remove.bind(this, record.selectKey)}>移除</a>,
}, },);
]; }
const columns3 = [ const columns3 = [
...columns, ...columns,
{ ];
if (!disabled) {
columns3.push( {
title: '操作', title: '操作',
render: (val, record) => render: (val, record) =>
keys.includes(record[valueName]) ? ( keys.includes(record[valueName]) ? (
...@@ -218,8 +266,10 @@ export default class TableSelect extends React.Component { ...@@ -218,8 +266,10 @@ export default class TableSelect extends React.Component {
) : ( ) : (
<a onClick={this.select.bind(this, record)}>选择</a> <a onClick={this.select.bind(this, record)}>选择</a>
), ),
}, },);
]; }
const custom = { const custom = {
isAll: this.state.isAll, isAll: this.state.isAll,
querys: this.state.querys, querys: this.state.querys,
...@@ -260,7 +310,8 @@ export default class TableSelect extends React.Component { ...@@ -260,7 +310,8 @@ export default class TableSelect extends React.Component {
pagination={false} pagination={false}
/> />
) : ( ) : (
Object.keys(selects).map((k) => ( Object.keys(selects)
.map((k) => (
<Tag key={k} closable={!disabled} onClose={this.remove.bind(this, k)}> <Tag key={k} closable={!disabled} onClose={this.remove.bind(this, k)}>
{selects[k][labelName]} {selects[k][labelName]}
</Tag> </Tag>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论