提交 f1d9dc29 authored 作者: chlolch's avatar chlolch

修改bug

上级 c98d63ff
......@@ -11,7 +11,7 @@ export default class ChildForm extends React.Component {
constructor(props) {
super(props)
const value = props.value || {};
this.state = value
}
......@@ -26,7 +26,7 @@ export default class ChildForm extends React.Component {
// Should be a controlled component.
if ('value' in nextProps) {
const value = nextProps.value;
this.state=value
this.state = value
}
}
componentDidMount = () => {
......@@ -54,7 +54,7 @@ export default class ChildForm extends React.Component {
}
delete = (uuid) => {
const objs = this.state
const {json:{numCode},form,base52}=this.props
const { json: { numCode }, form, base52 } = this.props
if (this.props.min != null && Object.keys(objs).length - 1 < this.props.min) {
message.error("不能小于最小限制")
......@@ -67,14 +67,14 @@ export default class ChildForm extends React.Component {
}
this.triggerChange({ ...objs });
if(numCode!=null){
this.props.form.setFieldsValue({[numCode]:Object.keys(objs).length})
if (numCode != null) {
this.props.form.setFieldsValue({ [numCode]: Object.keys(objs).length })
}
}
add = () => {
const objs = this.state
const {json:{numCode},form,base52}=this.props
const { json: { numCode }, form, base52 } = this.props
if (this.props.max != null && Object.keys(objs).length + 1 > this.props.max) {
message.error("不能大于最大限制")
......@@ -86,10 +86,10 @@ export default class ChildForm extends React.Component {
this.setState({ ...objs });
}
this.triggerChange({ ...objs });
if(numCode!=null){
this.props.form.setFieldsValue({[numCode]:Object.keys(objs).length})
if (numCode != null) {
this.props.form.setFieldsValue({ [numCode]: Object.keys(objs).length })
}
}
......@@ -98,12 +98,13 @@ export default class ChildForm extends React.Component {
render() {
const objs = this.state;
const { form, mapData, sqlData, defaultValues, datas, base52, isEdit, addName, deleteName, obj, isMobile, json,modalInit } = this.props
const { form, mapData, sqlData, defaultValues, datas, base52, isEdit, addName, deleteName, obj, isMobile, json, modalInit } = this.props
const span = json.span || 24
const gutter = json.gutter != null ? json.gutter : 0
const rights = this.props.rights
if (datas == null) {
return (<div>还没有配置子表单key</div>)
}
......@@ -113,35 +114,37 @@ export default class ChildForm extends React.Component {
return (
<WingBlank size="lg">
{Object.keys(objs).length > 1 || rights.includes("add") ? <Card style={{ marginLeft: '-27px' }}>
<Card.Body style={{ minHeight: 10 }}>
{Object.keys(objs).map((r) => {
if (r == "") {
return ""
}
return <Row key={r} gutter={gutter} ><Col style={{ textAlign: 'right' }} span={isEdit ? 23 : span} >
<ZdyTable key={r} modalInit={modalInit} formCode={this.props.formCode}
formId={this.props.formId}
formConfig={datas} get='mobile' fatherCode={base52} isEdit={isEdit} index={r} obj={objs[r]} fatherObj={this.props.fatherObj} init={objs} isChild={true} form={form} mapData={mapData} sqlData={sqlData} {...datas} defaultValues={defaultValues} />
<ZdyTable key={r} modalInit={modalInit} formCode={this.props.formCode}
formId={this.props.formId}
formConfig={datas} get='mobile' fatherCode={base52} isEdit={isEdit} index={r} obj={objs[r]} fatherObj={this.props.fatherObj} init={objs} isChild={true} form={form} mapData={mapData} sqlData={sqlData} {...datas} defaultValues={defaultValues} />
{rights.includes("delete") && isEdit ? <Button type='danger' size="small" onClick={this.delete.bind(this, r)}>{deleteName || "删除"} </Button> : ''}
</Col>
</Row>
})}
{rights.includes("add") ? <Row>
<Col style={{textAlign:"center"}}><Button type="primary" size="small" style={{ margin: "auto"}} onClick={this.add}>{addName || "新增"}</Button> </Col>
</Row>:""}
{rights.includes("add") ? <Row>
<Col style={{ textAlign: "center" }}><Button type="primary" size="small" style={{ margin: "auto" }} onClick={this.add}>{addName || "新增"}</Button> </Col>
</Row> : ""}
</Card.Body>
</Card> : ""}
</WingBlank>
)
}
return (
<div style={{ width: "100%" }}>
<Row gutter={gutter}>
{Object.keys(objs).map((r) => {
if (r == "") {
return ""
}
......
......@@ -415,9 +415,9 @@ export default class tableCom extends Component {
onFilter: (value, record) =>
record[dataIndex]
? record[dataIndex]
.toString()
.toLowerCase()
.includes(value.toLowerCase())
.toString()
.toLowerCase()
.includes(value.toLowerCase())
: '',
onFilterDropdownVisibleChange: visible => {
if (visible) {
......@@ -490,7 +490,7 @@ export default class tableCom extends Component {
if (this.count.length > 10) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:存在循环风险,1秒内执行超过10次,现已停止执行,请检查,`,
1}列:存在循环风险,1秒内执行超过10次,现已停止执行,请检查,`,
);
return;
......@@ -512,9 +512,9 @@ export default class tableCom extends Component {
this.props.fatherCode != null
? bindObj
? {
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
: { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
: bindObj;
if (this.props.fatherCode == null && dataColumn == null)
......@@ -754,7 +754,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -810,7 +810,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
//message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
......@@ -824,7 +824,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -836,7 +836,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -885,7 +885,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -898,7 +898,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -910,7 +910,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -961,7 +961,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -974,7 +974,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -986,7 +986,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -1041,7 +1041,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -1054,7 +1054,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -1066,7 +1066,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,回调函数内部错误,`,
1}列:公式配置有误,回调函数内部错误,`,
e,
);
}
......@@ -1184,7 +1184,7 @@ export default class tableCom extends Component {
} catch {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,函数内部错误,`,
1}列:公式配置有误,函数内部错误,`,
e,
);
}
......@@ -1194,7 +1194,7 @@ export default class tableCom extends Component {
} catch (e) {
console.log(
`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j +
1}列:公式配置有误,暂存失败,`,
1}列:公式配置有误,暂存失败,`,
e,
);
}
......@@ -1221,9 +1221,9 @@ export default class tableCom extends Component {
this.props.fatherCode != null
? bindObj
? {
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
: { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
: bindObj;
if (this.props.fatherCode == null && dataColumn == null)
......@@ -1601,8 +1601,8 @@ export default class tableCom extends Component {
{get === 'mobile' ? <br /> : ''}
</span>
) : (
''
);
''
);
break;
case 'UploadCom':
......@@ -1749,8 +1749,8 @@ export default class tableCom extends Component {
</span>
</>
) : (
''
)}
''
)}
</Col>
<Col
span={json.wrapperSpan}
......@@ -1817,9 +1817,9 @@ export default class tableCom extends Component {
this.props.fatherCode != null
? bindObj
? {
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
...bindObj,
base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
}
: { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
: bindObj;
......@@ -1832,16 +1832,18 @@ export default class tableCom extends Component {
var title = json.label || (dataColumn && dataColumn.title);
var initValue;
if (init != null) {
const objinit = { ...init, ...obj }
if (objinit != null) {
if (this.props.fatherCode != null) {
initValue =
init[this.props.index] != null
? init[this.props.index][bindObj ? bindObj.base52 : this.props.uuid]
: null;
initValue = objinit[this.props.index] != null
? objinit[this.props.index][bindObj ? bindObj.base52 : this.props.uuid]
: null;
} else {
initValue = init[dataColumn.base52];
initValue = objinit[dataColumn.base52];
}
} else {
if (json.initialValue != null) {
try {
initValue = JSON.parse(json.initialValue);
......@@ -1850,6 +1852,8 @@ export default class tableCom extends Component {
}
}
}
if (!isEdit) {
if (this.props.fatherCode) {
if (bindObj != null) {
......@@ -1925,18 +1929,18 @@ export default class tableCom extends Component {
<span>
{labels != null
? labels.map((r, i) =>
i == 0 ? (
typeof r == 'string' ? (
<span>{r}</span>
) : (
i == 0 ? (
typeof r == 'string' ? (
<span>{r}</span>
) : (
Object.values(r)
)
) : typeof r == 'string' ? (
<span style={{ marginLeft: 12 }}>{r}</span>
) : (
',' + Object.values(r)
),
)
) : typeof r == 'string' ? (
<span style={{ marginLeft: 12 }}>{r}</span>
) : (
',' + Object.values(r)
),
)
: ''}
</span>
);
......@@ -2014,8 +2018,8 @@ export default class tableCom extends Component {
<span>
{obj[dataColumn.base52]
? 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',
)
: ''}
</span>
);
......@@ -2129,11 +2133,11 @@ export default class tableCom extends Component {
height={json.height}
/>
) : (
<img
src={config.httpServer + obj[dataColumn.base52]}
style={{ width: json.width, height: json.height }}
/>
);
<img
src={config.httpServer + obj[dataColumn.base52]}
style={{ width: json.width, height: json.height }}
/>
);
}
break;
......@@ -2347,7 +2351,7 @@ export default class tableCom extends Component {
}
>
{(json.isMobileLabel != null && json.isMobileLabel) ||
(json.isMobileLabel == null && json.isLabel)
(json.isMobileLabel == null && json.isLabel)
? title
: ''}
</MobileList.Item>
......@@ -2541,25 +2545,25 @@ export default class tableCom extends Component {
getPopupContainer={
this.props.isDynamic && document.querySelector('#dynamic_div')
? () => {
return document.querySelector('#dynamic_div');
}
return document.querySelector('#dynamic_div');
}
: ''
}
onFocus={() => {
get === 'mobile' // 移动端取消输入键盘弹出
? setTimeout(() => {
if (document.querySelectorAll(`.ant-select-search__field`).length > 0) {
let ary = [...document.querySelectorAll(`.ant-select-search__field`)];
ary.map(item => {
item.setAttribute('readonly', 'readonly');
// setTimeout(() => {
// ary.map(arr => {
// arr.removeAttribute('readonly');
// })
// });
});
}
})
if (document.querySelectorAll(`.ant-select-search__field`).length > 0) {
let ary = [...document.querySelectorAll(`.ant-select-search__field`)];
ary.map(item => {
item.setAttribute('readonly', 'readonly');
// setTimeout(() => {
// ary.map(arr => {
// arr.removeAttribute('readonly');
// })
// });
});
}
})
: null;
}}
filterOption={(input, option) =>
......@@ -2570,10 +2574,10 @@ export default class tableCom extends Component {
>
{options
? options.map(r => (
<Option key={r.value} value={r.value}>
{r.label}
</Option>
))
<Option key={r.value} value={r.value}>
{r.label}
</Option>
))
: ''}
</Select>,
);
......@@ -2605,22 +2609,22 @@ export default class tableCom extends Component {
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
validator: (rule, value, callback) => {
if (
(Object.keys(value).length == 0 ||
Object.keys(value.selects).length == 0) &&
required != null &&
required
) {
var errors = [];
errors.push(new Error('请选择至少一个', rule.field));
}
callback(errors);
},
required: required,
{
validator: (rule, value, callback) => {
if (
(Object.keys(value).length == 0 ||
Object.keys(value.selects).length == 0) &&
required != null &&
required
) {
var errors = [];
errors.push(new Error('请选择至少一个', rule.field));
}
callback(errors);
},
],
required: required,
},
],
})(
<TableSelect
get={get}
......@@ -2734,21 +2738,21 @@ export default class tableCom extends Component {
onOpenChange={
get === 'mobile'
? () => {
// 取消唤起移动端小键盘
setTimeout(() => {
if (document.querySelector('.ant-calendar-input ')) {
// 取消唤起移动端小键盘
setTimeout(() => {
if (document.querySelector('.ant-calendar-input ')) {
document
.querySelector('.ant-calendar-input ')
.setAttribute('readonly', 'readonly');
setTimeout(() => {
document
.querySelector('.ant-calendar-input ')
.setAttribute('readonly', 'readonly');
setTimeout(() => {
document
.querySelector('.ant-calendar-input ')
.removeAttribute('readonly');
});
}
});
}
: () => {}
.removeAttribute('readonly');
});
}
});
}
: () => { }
}
format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'}
/>,
......@@ -3027,8 +3031,8 @@ export default class tableCom extends Component {
/>
</FormModal>
) : (
''
)}
''
)}
<Card.Header title={<span style={{ fontSize: 14 }}>{title}:</span>} />
<Card.Body>{cm}</Card.Body>
</Card>
......@@ -3106,8 +3110,8 @@ export default class tableCom extends Component {
/>
</FormModal>
) : (
''
)}
''
)}
</Row>
);
} else {
......@@ -3140,8 +3144,8 @@ export default class tableCom extends Component {
/>
</FormModal>
) : (
''
)}
''
)}
<Form.Item
labelCol={{ span: json.labelSpan }}
wrapperCol={{ span: json.wrapperSpan }}
......@@ -3182,8 +3186,8 @@ export default class tableCom extends Component {
/>
</FormModal>
) : (
''
)}
''
)}
{cm}
</>
);
......@@ -3218,8 +3222,8 @@ export default class tableCom extends Component {
/>
</FormModal>
) : (
''
)}
''
)}
{json.isMobileLabel && !isEdit && get == 'mobile' ? (
<MobileItem
labelCol={{ span: json.labelSpan }}
......@@ -3229,8 +3233,8 @@ export default class tableCom extends Component {
{cm}
</MobileItem>
) : (
cm
)}
cm
)}
</>
);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论