/** * Created by mar105 on 2019-02-13. */ /* eslint-disable no-undef,import/first,prefer-destructuring,jsx-a11y/alt-text */ import React, { Component } from 'react'; import { Form } from '@ant-design/compatible'; import '@ant-design/compatible/assets/index.css'; import { Row, Col, Radio } from 'antd'; import * as commonUtils from '../../utils/utils'; import ShowType from './CommonComponent';/* 通用方法 */ import AntdDraggableModal from '../Common/AntdDraggableModal'; import * as commonFunc from './commonFunc'; const FormItem = Form.Item; export default class ContextMenuModal extends Component { /** 构造函数 */ constructor(props) { super(props); this.state = { contextMenuValue: null, contextType: 1, }; this.form = {}; /* 表单对象 */ } handleViewClick = (name, sName, sId) => { this.props.onViewClick(name, sName, sId); }; /* 右击弹出窗确定 取表单值 */ handleContextMenuOk= () => { const { contextMenuTbName } = this.props; const { masterData, contextMenuConfig, [`${contextMenuTbName}Data`]: tableData, [`${contextMenuTbName}SelectedRowKeys`]: selectedRowKeys, } = this.props; if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyArr(contextMenuConfig)) { const showConfig = contextMenuConfig[0]; if (commonUtils.isNotEmptyObject(showConfig.sName)) { // const contextMenuValue = masterData[showConfig.sName]; /* 取弹窗框的值 */ let { contextMenuData } = this.state; const { contextMenuValue, contextType } = this.state; console.log('dddd', contextType); const contextMenuType = commonUtils.isNotEmptyNumber(contextType) ? contextType : 1; if (!commonUtils.isEmpty(contextMenuValue)) { if (!contextMenuData) { let tableDataRow = {}; if (commonUtils.isNotEmptyArr(tableData)) { const tableFilterData = tableData.filter(item => selectedRowKeys.includes(item.sId)); if (commonUtils.isNotEmptyArr(tableFilterData)) { tableDataRow = tableFilterData[0]; tableDataRow.contextType = commonUtils.isNotEmptyNumber(contextType) ? contextType : 1; } } contextMenuData = commonFunc.getAssignFieldValue(showConfig.sAssignField, tableDataRow); } console.log('ddda1a', contextMenuData, contextMenuType); this.props.onContextMenuOk(contextMenuValue, contextMenuData, contextMenuType); } } } } handleModalCancel = (modelVisible) => { this.props.onSaveState({ [modelVisible]: false, }); }; handleRdoChange = (e) => { this.setState({ contextType: e.target.value }); }; /** 渲染 */ render() { const { contextMenuModalVisible, contextMenuTbName, contextMenuConfig, contextMenuName, app, form, sTabId, [`${contextMenuTbName}Data`]: tableData, [`${contextMenuTbName}SelectedRowKeys`]: selectedRowKeys, } = this.props; const { contextMenuValue, contextType } = this.state; let tableDataRow = {}; if (commonUtils.isNotEmptyArr(tableData)) { const tableFilterData = tableData.filter(item => selectedRowKeys.includes(item.sId)); if (commonUtils.isNotEmptyArr(tableFilterData)) { tableDataRow = tableFilterData[0]; } } if (contextMenuValue === null && commonUtils.isNotEmptyObject(tableDataRow) && commonUtils.isNotEmptyArr(contextMenuConfig)) { this.setState({ contextMenuValue: tableDataRow[contextMenuConfig[0].sName], }); } const radioValue = commonUtils.isNotEmptyNumber(contextType) ? contextType : 1; const pane = app.panes.filter(paneTmp => paneTmp.key === sTabId)[0]; return (
{ (pane.notCurrentPane ? false : contextMenuModalVisible) ?
全部更新 当前数据往下更新
{ commonUtils.isNotEmptyArr(contextMenuConfig) ? contextMenuConfig.map((child) => { const sMemo = child.sName.toLowerCase().endsWith('memo'); let enabledNew = !child.bReadonly; if (child.iTag === 1) { enabledNew = false; } else if (child.iTag === 3) { enabledNew = true; } const showTypeProps = { name: 'slave', app, form, record: tableDataRow, sId: commonUtils.createSid(), getSqlDropDownData: this.props.getSqlDropDownData, getSqlCondition: this.props.getSqlCondition, handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord, getFloatNum: this.props.getFloatNum, onChange: (name, sFieldName, changeValue) => { this.setState({ contextMenuValue: changeValue[sFieldName], contextMenuData: changeValue, }); }, onViewClick: this.handleViewClick, getDateFormat: this.props.getDateFormat, showConfig: child, textArea: sMemo, enabled: enabledNew, dataValue: !commonUtils.isEmpty(contextMenuValue) ? contextMenuValue : commonUtils.isNotEmptyObject(tableDataRow) ? tableDataRow[child.sName] : '', bTable: true, formRoute: this.props.formRoute, formItemLayout: {}, onExecInstructSet: this.props.onExecInstructSet, }; return ( ); }) : '' }
: '' }
); } }