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

18715 学生提给老师的咨询信息,老师还能编辑,按钮已做限制,但未生效

上级 d90700ef
...@@ -248,6 +248,7 @@ export default class TableSelect extends Component { ...@@ -248,6 +248,7 @@ export default class TableSelect extends Component {
value: one[valueName], value: one[valueName],
}); });
} }
return ( return (
<Fragment> <Fragment>
{!showModal ? ( {!showModal ? (
......
...@@ -85,7 +85,6 @@ export default class TableSelect extends React.Component { ...@@ -85,7 +85,6 @@ export default class TableSelect extends React.Component {
const { dataSource, json } = this.props; const { dataSource, json } = this.props;
let { valueName, optionType } = json; let { valueName, optionType } = json;
const { list } = dataSource; const { list } = dataSource;
console.log(list);
if (optionType == 'reference' && this.props.dataColumn.referenceObjId) { if (optionType == 'reference' && this.props.dataColumn.referenceObjId) {
valueName = this.props.dataColumn.referenceCodeName; valueName = this.props.dataColumn.referenceCodeName;
} }
...@@ -102,15 +101,15 @@ export default class TableSelect extends React.Component { ...@@ -102,15 +101,15 @@ export default class TableSelect extends React.Component {
this.triggerChange({ selects }); this.triggerChange({ selects });
}; };
cancelAll = () => { cancelAll = () => {
let selects = {}; let selects = {};
if (!('value' in this.props)) { if (!('value' in this.props)) {
this.setState({ selects }); this.setState({ selects });
} }
this.triggerChange({ selects }); this.triggerChange({ selects });
}; };
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);
...@@ -136,6 +135,30 @@ export default class TableSelect extends React.Component { ...@@ -136,6 +135,30 @@ export default class TableSelect extends React.Component {
this.triggerChange({ visiable: false }); this.triggerChange({ visiable: false });
}; };
cancelOne = (record) => {
var { selects } = this.state;
const {
json: { isMultiple, optionType },
} = this.props;
let valueName = this.props.json.valueName;
if (optionType == 'reference' && this.props.dataColumn.referenceObjId) {
valueName = this.props.dataColumn.referenceCodeName;
}
const kk = record[valueName];
if (kk == null) {
message.error('指定的取值字段不存在或者值为空');
return;
}
if (selects[kk]) {
delete selects[kk];
}
if (!('value' in this.props)) {
this.setState({ selects });
}
this.triggerChange({ selects });
};
render() { render() {
const { const {
...@@ -144,6 +167,7 @@ export default class TableSelect extends React.Component { ...@@ -144,6 +167,7 @@ export default class TableSelect extends React.Component {
sqlModel, sqlModel,
columns, columns,
dataSource, dataSource,
disabled,
} = this.props; } = this.props;
let { valueName, labelName } = this.props.json; let { valueName, labelName } = this.props.json;
if (optionType == 'reference' && referenceObjId) { if (optionType == 'reference' && referenceObjId) {
...@@ -171,7 +195,12 @@ export default class TableSelect extends React.Component { ...@@ -171,7 +195,12 @@ export default class TableSelect extends React.Component {
title: '操作', title: '操作',
render: (val, record) => render: (val, record) =>
keys.includes(record[valueName]) ? ( keys.includes(record[valueName]) ? (
<span>已选择</span> <a
onClick={() => {
this.cancelOne(record);
}}>
已选择
</a>
) : ( ) : (
<a onClick={this.select.bind(this, record)}>选择</a> <a onClick={this.select.bind(this, record)}>选择</a>
), ),
...@@ -205,8 +234,9 @@ export default class TableSelect extends React.Component { ...@@ -205,8 +234,9 @@ export default class TableSelect extends React.Component {
}); });
} }
// console.log(this.props); console.log(this.props);
// console.log(this.state); console.log(this.state);
console.log('-0000 TableSelect000');
return ( return (
<div> <div>
{Object.keys(selects).length > 0 ? ( {Object.keys(selects).length > 0 ? (
...@@ -220,7 +250,7 @@ export default class TableSelect extends React.Component { ...@@ -220,7 +250,7 @@ export default class TableSelect extends React.Component {
/> />
) : ( ) : (
Object.keys(selects).map((k) => ( Object.keys(selects).map((k) => (
<Tag key={k} closable 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>
)) ))
...@@ -228,9 +258,12 @@ export default class TableSelect extends React.Component { ...@@ -228,9 +258,12 @@ export default class TableSelect extends React.Component {
) : ( ) : (
'' ''
)} )}
<Button type="primary" onClick={this.open}> {!disabled && (
选择 <Button type="primary" onClick={this.open}>
</Button> 选择
</Button>
)}
{visiable && ( {visiable && (
<Modal <Modal
width={this.props.get === 'mobile' ? '100%' : '60%'} width={this.props.get === 'mobile' ? '100%' : '60%'}
......
import React from 'react'; import React from "react";
import { Tree, Upload, Icon, Button, message } from 'antd'; import { Button, Icon, message, Upload } from "antd";
import { queryApiActionPath } from '../utils/queryConfig'; import { queryApiActionPath } from "../utils/queryConfig";
import config from '@/webPublic/one_stop_public/config'; import config from "@/webPublic/one_stop_public/config";
export default class UploadCom extends React.Component { export default class UploadCom extends React.Component {
constructor(props) { constructor(props) {
...@@ -19,6 +19,7 @@ export default class UploadCom extends React.Component { ...@@ -19,6 +19,7 @@ export default class UploadCom extends React.Component {
onChange(Object.assign({}, this.state, changedValue)); onChange(Object.assign({}, this.state, changedValue));
} }
}; };
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// Should be a controlled component. // Should be a controlled component.
if ('value' in nextProps) { if ('value' in nextProps) {
...@@ -26,6 +27,7 @@ export default class UploadCom extends React.Component { ...@@ -26,6 +27,7 @@ export default class UploadCom extends React.Component {
this.setState(value); this.setState(value);
} }
} }
changeUrl = (info) => { changeUrl = (info) => {
if (info.file.status === 'done') { if (info.file.status === 'done') {
message.success(`${info.file.name} 上传成功`); message.success(`${info.file.name} 上传成功`);
...@@ -52,9 +54,10 @@ export default class UploadCom extends React.Component { ...@@ -52,9 +54,10 @@ export default class UploadCom extends React.Component {
} }
this.triggerChange({ files }); this.triggerChange({ files });
}; };
render() { render() {
const { files } = this.state; const { files } = this.state;
const { isMultiple, accept, btnName } = this.props; const { isMultiple, accept, btnName, disabled } = this.props;
const props = { const props = {
name: 'file', name: 'file',
multiple: isMultiple, multiple: isMultiple,
...@@ -63,27 +66,34 @@ export default class UploadCom extends React.Component { ...@@ -63,27 +66,34 @@ export default class UploadCom extends React.Component {
showUploadList: false, showUploadList: false,
onChange: this.changeUrl, onChange: this.changeUrl,
}; };
console.log('---------asdasd-------', this.props, this.state);
return ( return (
<div> <div>
{' '} {' '}
<Upload {...props}> <Upload {...props} disabled={disabled}>
<Button> {!disabled && (
<Icon type="upload" /> <Button>
{btnName ? btnName : '上传附件'} <Icon type="upload" />
</Button> {btnName ? btnName : '上传附件'}
</Button>
)}
</Upload> </Upload>
<ul style={{ paddingLeft: 8 }}> <ul style={{ paddingLeft: 8 }}>
{files.map((f) => { {(files || []).map((f) => {
if ((f.path && f.path.indexOf('.png') != -1) || f.path.indexOf('.jpg') != -1) { if ((f.path && f.path.indexOf('.png') !== -1) || f.path.indexOf('.jpg') !== -1) {
return ( return (
<li key={f.path}> <li key={f.path}>
<img style={{ width: 100, height: 100 }} src={queryApiActionPath() + f.path} /> <img style={{ width: 100, height: 100 }} src={queryApiActionPath() + f.path} onClick={() => {
<Icon window.open(queryApiActionPath() + f.path);
style={{ marginLeft: 10 }} }}/>
type="delete" {!disabled && (
onClick={this.remove.bind(this, f.path)} <Icon
/> style={{ marginLeft: 10 }}
type="delete"
onClick={this.remove.bind(this, f.path)}
/>
)}
</li> </li>
); );
} }
...@@ -92,11 +102,13 @@ export default class UploadCom extends React.Component { ...@@ -92,11 +102,13 @@ export default class UploadCom extends React.Component {
<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>{' '}
<Icon {!disabled && (
style={{ marginLeft: 10 }} <Icon
type="delete" style={{ marginLeft: 10 }}
onClick={this.remove.bind(this, f.path)} type="delete"
/> onClick={this.remove.bind(this, f.path)}
/>
)}
</li> </li>
); );
})} })}
......
...@@ -828,7 +828,7 @@ class TreeList extends React.Component { ...@@ -828,7 +828,7 @@ class TreeList extends React.Component {
); );
}; };
getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => { getItem = (isQuery, form, item, isAdd, formData, labelCol, wrapperCol) => {
const { groups } = this.state; const { groups, isView } = this.state;
if (item.isPrimaryKey) { if (item.isPrimaryKey) {
if (isAdd) { if (isAdd) {
return <></>; return <></>;
...@@ -893,7 +893,7 @@ class TreeList extends React.Component { ...@@ -893,7 +893,7 @@ class TreeList extends React.Component {
? JSON.parse(formData[item.name]) ? JSON.parse(formData[item.name])
: null, : null,
rules: [{ required: !item.isNull }], rules: [{ required: !item.isNull }],
})(<UploadCom />)} })(<UploadCom disabled={isView} />)}
</FormItem> </FormItem>
); );
} else if (isQuery && item.isGroupQuery != null && item.isGroupQuery) { } else if (isQuery && item.isGroupQuery != null && item.isGroupQuery) {
......
...@@ -2868,7 +2868,8 @@ export default class tableCom extends Component { ...@@ -2868,7 +2868,8 @@ export default class tableCom extends Component {
<TableSelect <TableSelect
get={get} get={get}
json={json} json={json}
dataColumn={dataColumn} disabled={!isEdit}
dataColumn={dataColumn}
columns={this.state.columns} columns={this.state.columns}
dataSource={this.state.dataSource} dataSource={this.state.dataSource}
sqlModel={this.state.sqlModel} sqlModel={this.state.sqlModel}
...@@ -3020,6 +3021,8 @@ export default class tableCom extends Component { ...@@ -3020,6 +3021,8 @@ export default class tableCom extends Component {
if (initValue != null && !isEmpty(initValue.files)) { if (initValue != null && !isEmpty(initValue.files)) {
files = initValue.files; files = initValue.files;
} }
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
initialValue: { files: files }, initialValue: { files: files },
rules: [ rules: [
...@@ -3036,7 +3039,11 @@ export default class tableCom extends Component { ...@@ -3036,7 +3039,11 @@ export default class tableCom extends Component {
}, },
], ],
})( })(
<UploadCom isMultiple={json.isMultiple} accept={json.accept} btnName={json.btnName} />, <UploadCom isMultiple={json.isMultiple}
accept={json.accept}
btnName={json.btnName}
disabled={disabled || isPreview}
/>,
); );
if ( if (
get === 'mobile' && get === 'mobile' &&
...@@ -3124,9 +3131,6 @@ export default class tableCom extends Component { ...@@ -3124,9 +3131,6 @@ export default class tableCom extends Component {
} }
break; break;
case 'ChildForm': case 'ChildForm':
// console.log(dataColumn.base52, '----key-ChildForm--'); // KUSyCzEhdCJ
// console.log(JSON.stringify(this.props.form.getFieldsValue()), '----formValue----');
// console.log(JSON.stringify(initValue)); // undefined
cm = getFieldDecorator(dataColumn.base52, { initialValue: initValue || {} })( cm = getFieldDecorator(dataColumn.base52, { initialValue: initValue || {} })(
<ChildForm <ChildForm
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论