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

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

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