/** * 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 { Modal } from 'antd'; import styles from '@/index.less'; import * as commonUtils from '@/utils/utils'; import StaticEditTable from '@/components/Common/CommonTable';/* 可编辑表格 */ import * as commonBusiness from '@/components/Common/commonBusiness'; /* 单据业务功能 */ export default class AssignmentField extends Component { /** 构造函数 */ constructor(props) { super(props); this.state = {}; } /* 获取数字格式化规范 */ getFloatNum = (sName, decimals) => { if (sName.toLowerCase().endsWith('price')) { /* 价格 */ return decimals.dNetPrice; } else if (sName.toLowerCase().endsWith('money')) { /* 金额 */ return decimals.dNetMoney; } else { /* 其它 */ return 0; } }; handleOk = () => { /* 选中之后 */ const { sAssignFieldData } = this.props; this.props.onGetsAssignField(sAssignFieldData, 'sAssignField'); this.props.onSaveState({ visibleAssignmentField: false, // enabled: false, }); }; handleCancel = () => { this.props.onSaveState({ visibleAssignmentField: false, // enabled: false, }); }; handleSelectRowChange = (name, selectedRowKeys) => { this.props.onSaveState({ selectedRowKeys, sAssignFieldSelectedRowKeys: selectedRowKeys, }); }; handleChange = (name, sFieldName, changeValue, sId) => { const { sAssignFieldData } = this.props; if (name === 'sAssignField') { const iIndex = sAssignFieldData.findIndex(item => item.sId === sId); const newData = sAssignFieldData[iIndex]; newData[sFieldName] = changeValue[sFieldName]; } }; /** 渲染 */ render() { const { sAssignFieldData, visibleAssignmentField, sAssignFieldColumn, selectedRowKeys, } = this.props; /* 获取table中的props */ const app = {}; app.currentPage = null; const commonConst = [ { sId: '1000', sParentId: '100', sName: 'BtnAdd', showName: '新增', }, { sId: '1001', sParentId: '100', sName: 'BtnUpd', showName: '修改', }, { sId: '1002', sParentId: '100', sName: 'BtnDel', showName: '删除', }, ]; app.commonConst = commonConst; app.token = ''; const config = {}; config.iFreezeColumn = 1; const gdsconfigtbsAssignField = []; const showoldsNameConfig = { sId: commonUtils.createSid(), sName: 'sOldName', showName: '源字段', bVisible: true, iFitWidth: 200, }; const shownewsNameConfig = { sId: commonUtils.createSid(), sName: 'sNewName', showName: '现字段', bVisible: true, iFitWidth: 180, }; gdsconfigtbsAssignField.push(showoldsNameConfig); gdsconfigtbsAssignField.push(shownewsNameConfig); config.gdsconfigformslave = gdsconfigtbsAssignField; const assignmentFieldProps = { ...commonBusiness.getTableTypes('sAssignField', this.props), tableProps: { AutoTableHeight: '320px', onChange: this.handleChange }, rowKey: this.rowKey, size: 'small', bordered: true, /* 显示边框 */ dataSource: sAssignFieldData, /* 数据s */ columns: sAssignFieldColumn, /* 表头 */ pagination: false, /* 不分页 */ tableBelone: 'table', selectedRowKeys, getFloatNum: this.getFloatNum, config, app: { ...this.props.app, currentPane: { ...this.props.app.currentPane, sModelsType: 'search/assignmentField', }, }, onRow: (record) => { return { onClick: () => { this.onRowClick(record); }, onDoubleClick: () => { this.onDoubleClick(record); } }; }, onAddRow: this.props.onDataRowAdd, onDelRow: this.props.onDataRowDel, onCopyRow: this.props.onDataRowCopy, onSelectRowChange: this.handleSelectRowChange, onChange: this.handleChange, onDataChange: this.handleChange, ...this.props.tableProps, }; return (
); } }