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

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

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