提交 7a1d69de authored 作者: chscls@163.com's avatar chscls@163.com

弹出框函数

上级 0d669149
...@@ -11,7 +11,6 @@ import { Toast } from 'antd-mobile' ...@@ -11,7 +11,6 @@ import { Toast } from 'antd-mobile'
import router from 'umi/router' import router from 'umi/router'
import IsNewTable from './isNewTable'; import IsNewTable from './isNewTable';
import maintain from '../assets/maintain.png' import maintain from '../assets/maintain.png'
import FormModal from '../tableCompon/FormModal'
import moment from 'moment' import moment from 'moment'
export default class ZdyTable extends Component { export default class ZdyTable extends Component {
constructor(props) { constructor(props) {
...@@ -37,13 +36,10 @@ export default class ZdyTable extends Component { ...@@ -37,13 +36,10 @@ export default class ZdyTable extends Component {
isEdit: true, isEdit: true,
isReady: false, isReady: false,
formConfig: {}, formConfig: {},
modalCode:null,
modalTitle:"",
}
} }
showModal=(modalCode,modalTitle)=>{
this.setState({modalCode,modalTitle,isShowModal:true})
} }
componentDidMount() { componentDidMount() {
let { let {
postData, // 数据源 postData, // 数据源
...@@ -363,9 +359,7 @@ export default class ZdyTable extends Component { ...@@ -363,9 +359,7 @@ export default class ZdyTable extends Component {
}) })
return max return max
} }
handleCancel=()=>{
this.setState({isShowModal:false})
}
render() { render() {
let { width, let { width,
isBorder, isBorder,
...@@ -383,8 +377,7 @@ export default class ZdyTable extends Component { ...@@ -383,8 +377,7 @@ export default class ZdyTable extends Component {
formConfig, formConfig,
formCode, formCode,
formId, formId,
isShowModal,
modalCode,
} = this.state } = this.state
let { border, let { border,
get, get,
...@@ -393,6 +386,7 @@ export default class ZdyTable extends Component { ...@@ -393,6 +386,7 @@ export default class ZdyTable extends Component {
fatherCode, fatherCode,
routerState, routerState,
postData, postData,
modalInit
} = this.props } = this.props
let style = {} let style = {}
if (formConfig.style != null) { if (formConfig.style != null) {
...@@ -473,7 +467,7 @@ export default class ZdyTable extends Component { ...@@ -473,7 +467,7 @@ export default class ZdyTable extends Component {
})(<Input type="hidden" />); })(<Input type="hidden" />);
}) : ""} }) : ""}
<FormModal visible={isShowModal} handleCancel={this.handleCancel} title={modalTitle}>{modalCode}</FormModal>
<Row> <Row>
<Col span={24}> <Col span={24}>
<div <div
...@@ -521,8 +515,7 @@ export default class ZdyTable extends Component { ...@@ -521,8 +515,7 @@ export default class ZdyTable extends Component {
}} > }} >
<TableCom <TableCom
showModal={this.showModal} modalInit={modalInit||{}}
modalInit={this.props.modalInit||{}}
formCode={formCode} // 当前表单code formCode={formCode} // 当前表单code
formId={formId} // 当前表单Id formId={formId} // 当前表单Id
i={i} // 当前组件下标 i={i} // 当前组件下标
...@@ -606,7 +599,7 @@ export default class ZdyTable extends Component { ...@@ -606,7 +599,7 @@ export default class ZdyTable extends Component {
})(<Input type="hidden" />); })(<Input type="hidden" />);
}) : ""} }) : ""}
<FormModal visible={isShowModal} handleCancel={this.handleCancel} title={modalTitle}>{modalCode}</FormModal>
{ {
items.map((item, i) => { items.map((item, i) => {
const allhidden = this.checkAllHidden(items) const allhidden = this.checkAllHidden(items)
...@@ -624,8 +617,7 @@ export default class ZdyTable extends Component { ...@@ -624,8 +617,7 @@ export default class ZdyTable extends Component {
item.map((ary, j) => { item.map((ary, j) => {
return !allhidden && ary.hidden ? "" return !allhidden && ary.hidden ? ""
: <><TableCom : <><TableCom
showModal={this.showModal} modalInit={modalInit||{}}
modalInit={this.props.modalInit||{}}
formCode={formCode} formCode={formCode}
formId={formId} formId={formId}
i={i} i={i}
......
...@@ -14,6 +14,7 @@ export default class FormModal extends React.Component { ...@@ -14,6 +14,7 @@ export default class FormModal extends React.Component {
<Modal <Modal
destroyOnClose destroyOnClose
title={this.props.title} title={this.props.title}
maskClosable={false}
visible={this.props.visible} visible={this.props.visible}
footer={null} footer={null}
onCancel={this.props.handleCancel} onCancel={this.props.handleCancel}
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
import React, { Component } from 'react'; import React, { Component } from 'react';
import md5 from 'js-md5'; import md5 from 'js-md5';
import FormModal from './FormModal'
import { import {
message, message,
Icon, Icon,
...@@ -140,18 +141,22 @@ export default class tableCom extends Component { ...@@ -140,18 +141,22 @@ export default class tableCom extends Component {
sqlModel: {}, sqlModel: {},
columns: [], columns: [],
sqlContent: null, sqlContent: null,
isShowModal:false,
modalTitle:"",
modalInit:{},
modalCode:null,
dataSource: { dataSource: {
list: [], list: [],
pagination: false pagination: false
}, },
}; };
excludeKeys = ["defaultValues", ""] excludeKeys = ["defaultValues", ""]
handleCancel=()=>{
this.setState({isShowModal:false})
}
showModal=(fk,title,data)=>{ showModal=(fk,title,data)=>{
const {datas,get,isEdit,obj,init,mapData,sqlData,defaultValues}=this.props this.setState({isShowModal:true,modalInit:data,modalTitle:title,modalCode:fk})
const child =<ZdyTable modalInit={data} key={fk} datas={datas} get={get} isChild={true} currentFormKey={fk} isEdit={isEdit} obj={obj} init={init} form={this.props.form} mapData={mapData} sqlData={sqlData} {...datas[fk]} defaultValues={defaultValues} />
this.props.showModal(child,title)
} }
equal = (obj1, obj2, json, sqlContent, depth) => { equal = (obj1, obj2, json, sqlContent, depth) => {
...@@ -1117,10 +1122,12 @@ export default class tableCom extends Component { ...@@ -1117,10 +1122,12 @@ export default class tableCom extends Component {
getFunctionValue = (fun, column, json, callback) => { getFunctionValue = (fun, column, json, callback) => {
/* if (!this.props.isEdit) { /* if (!this.props.isEdit) {
return return
} */ } */
const base52 = column.base52 const base52 = column.base52
/** /**
* 中台函数库注入 * 中台函数库注入
* 动态生成表单配置函数所使用 * 动态生成表单配置函数所使用
...@@ -1184,7 +1191,9 @@ export default class tableCom extends Component { ...@@ -1184,7 +1191,9 @@ export default class tableCom extends Component {
this.setState({ option: value }) this.setState({ option: value })
} else { } else {
try { try {
this.props.form.setFieldsValue({ [base52]: value }) this.props.form.setFieldsValue({ [base52]: value })
} catch{ } catch{
console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,函数内部错误,`, e) console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,函数内部错误,`, e)
//message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,函数内部错误${e}`, 10) //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,函数内部错误${e}`, 10)
...@@ -1475,7 +1484,7 @@ export default class tableCom extends Component { ...@@ -1475,7 +1484,7 @@ export default class tableCom extends Component {
* obj为查看详情用户输入值 * obj为查看详情用户输入值
*/ */
let { json, obj, mapData, init, sqlData, defaultValues, get, formKey, isEdit, datas } = this.props; let { json, obj, mapData, init, sqlData, defaultValues, get, formKey, isEdit, datas } = this.props;
const { options, labels, selectDis } = this.state; const { options, labels, selectDis,modalCode,modalTitle,isShowModal,modalInit } = this.state;
const { getFieldDecorator, getFieldError, getFieldProps } = this.props.form; const { getFieldDecorator, getFieldError, getFieldProps } = this.props.form;
const disabled = json != null ? json.disabled : false const disabled = json != null ? json.disabled : false
if (json == null) { if (json == null) {
...@@ -2275,6 +2284,7 @@ export default class tableCom extends Component { ...@@ -2275,6 +2284,7 @@ export default class tableCom extends Component {
})(<Input type="hidden" />); })(<Input type="hidden" />);
break; break;
case 'InputNumber': case 'InputNumber':
/* if (get === 'mobile') { /* if (get === 'mobile') {
cm = (<div className={styles.form}><MobileInputItem cm = (<div className={styles.form}><MobileInputItem
...@@ -2730,6 +2740,10 @@ export default class tableCom extends Component { ...@@ -2730,6 +2740,10 @@ export default class tableCom extends Component {
* 卡片类型 * 卡片类型
*/ */
return (<Card style={{ margin: 5, border: '1px solid #ccc' }}> return (<Card style={{ margin: 5, border: '1px solid #ccc' }}>
{modalCode?<FormModal visible={isShowModal} handleCancel={this.handleCancel} title={modalTitle}>
<ZdyTable modalInit={modalInit} key={modalCode} datas={datas} get={get} isChild={true} currentFormKey={modalCode} isEdit={isEdit} obj={obj} init={init} form={this.props.form} mapData={mapData} sqlData={sqlData} {...datas[modalCode]} defaultValues={defaultValues} />
</FormModal>:""}
<Card.Header title={<span style={{ fontSize: 14 }}>{title}:</span>} /> <Card.Header title={<span style={{ fontSize: 14 }}>{title}:</span>} />
<Card.Body> <Card.Body>
{cm} {cm}
...@@ -2787,30 +2801,45 @@ export default class tableCom extends Component { ...@@ -2787,30 +2801,45 @@ export default class tableCom extends Component {
> >
{cm} {cm}
</Col> </Col>
{modalCode?<FormModal visible={isShowModal} handleCancel={this.handleCancel} title={modalTitle}>
<ZdyTable modalInit={modalInit} key={modalCode} datas={datas} get={get} isChild={true} currentFormKey={modalCode} isEdit={isEdit} obj={obj} init={init} form={this.props.form} mapData={mapData} sqlData={sqlData} {...datas[modalCode]} defaultValues={defaultValues} />
</FormModal>:""}
</Row> </Row>
) )
} else { } else {
return ( return (
<>{modalCode?<FormModal visible={isShowModal} handleCancel={this.handleCancel} title={modalTitle}>
<ZdyTable modalInit={modalInit} key={modalCode} datas={datas} get={get} isChild={true} currentFormKey={modalCode} isEdit={isEdit} obj={obj} init={init} form={this.props.form} mapData={mapData} sqlData={sqlData} {...datas[modalCode]} defaultValues={defaultValues} />
</FormModal>:""}
<Form.Item <Form.Item
labelCol={{ span: json.labelSpan }} labelCol={{ span: json.labelSpan }}
wrapperCol={{ span: json.wrapperSpan }} wrapperCol={{ span: json.wrapperSpan }}
label={title} label={title}
> >
{cm} {cm}
</Form.Item> </Form.Item></>
) )
} }
} else { } else {
return <>{modalCode?<FormModal visible={isShowModal} handleCancel={this.handleCancel} title={modalTitle}>
<ZdyTable modalInit={modalInit} key={modalCode} datas={datas} get={get} isChild={true} currentFormKey={modalCode} isEdit={isEdit} obj={obj} init={init} form={this.props.form} mapData={mapData} sqlData={sqlData} {...datas[modalCode]} defaultValues={defaultValues} />
</FormModal>:""}{cm}</>
return cm
} }
} else { } else {
return ( return (
<>{modalCode?<FormModal visible={isShowModal} handleCancel={this.handleCancel} title={modalTitle}>
<ZdyTable modalInit={modalInit} key={modalCode} datas={datas} get={get} isChild={true} currentFormKey={modalCode} isEdit={isEdit} obj={obj} init={init} form={this.props.form} mapData={mapData} sqlData={sqlData} {...datas[modalCode]} defaultValues={defaultValues} />
</FormModal>:""}
<Form.Item <Form.Item
> >
{cm} {cm}
</Form.Item> </Form.Item></>
); );
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论