| | |
| | | |
| | | class MkSwitch extends Component { |
| | | static propTpyes = { |
| | | autoFocus: PropTypes.bool, |
| | | defaultValue: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func |
| | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | this.props.onBlur && this.props.onBlur() |
| | | } |
| | | |
| | | render() { |
| | | const { config, autoFocus } = this.props |
| | | const { config } = this.props |
| | | const { status } = this.state |
| | | |
| | | return ( |
| | |
| | | ref={ref => this.node = ref} |
| | | checkedChildren={config.openText} |
| | | checked={status} |
| | | autoFocus={autoFocus} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | unCheckedChildren={config.closeText} |
| | |
| | | content = `${record[col.field]}` |
| | | } |
| | | |
| | | if (col.editType === 'select' && col.options.length > 0) { |
| | | if (col.editType === 'select' && col.showValue !== 'value' && col.options.length > 0) { |
| | | content = col.map.get(content) || content |
| | | } else if (col.editType === 'switch') { |
| | | if (content === col.openVal) { |
| | |
| | | } |
| | | |
| | | if (col.editable === 'true' && !disabled) { |
| | | if (editing) { |
| | | if (col.editType === 'switch') { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} onChange={this.onColChange}/> |
| | | </td>) |
| | | } else if (editing) { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (!col.editType || col.editType === 'text') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <MkInput config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'date') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | |
| | | content = '' |
| | | } |
| | | } else { |
| | | if (col.eval === 'false' && col.noValue === 'hide') { // 空值隐藏 |
| | | Object.keys(record).forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | if (record[key]) return |
| | | |
| | | content = content.replace(new RegExp('[^@]*@' + key + '@', 'ig'), '') |
| | | }) |
| | | } |
| | | |
| | | Object.keys(record).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | content = content.replace(reg, record[key]) |
| | |
| | | ) |
| | | } else if (col.editType === 'switch') { |
| | | children = ( |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={false} onChange={this.onColChange}/> |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} onChange={this.onColChange}/> |
| | | ) |
| | | } else if (col.editType === 'date') { |
| | | children = ( |
| | |
| | | content = `${record[col.field]}` |
| | | } |
| | | |
| | | if (col.editType === 'select' && col.options.length > 0) { |
| | | if (col.editType === 'select' && col.showValue !== 'value' && col.options.length > 0) { |
| | | content = col.map.get(content) || content |
| | | } else if (col.editType === 'switch') { |
| | | if (content === col.openVal) { |
| | |
| | | } |
| | | if (col.format === 'percent') { |
| | | content = content * 100 |
| | | if (!col.round) { |
| | | content = +content.toFixed(2) |
| | | } |
| | | } else if (col.format === 'abs') { |
| | | content = Math.abs(content) |
| | | } |
| | |
| | | content = '' |
| | | } |
| | | } else { |
| | | if (col.eval === 'false' && col.noValue === 'hide') { // 空值隐藏 |
| | | Object.keys(record).forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | if (record[key]) return |
| | | |
| | | content = content.replace(new RegExp('[^@]*@' + key + '@', 'ig'), '') |
| | | }) |
| | | } |
| | | |
| | | Object.keys(record).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | content = content.replace(reg, record[key]) |
| | |
| | | deffers.push( |
| | | new Promise(resolve => { |
| | | Api.getSystemCacheConfig(param, false).then(res => { |
| | | if (!res.status) { |
| | | if (!res.status && res.ErrCode !== '-2') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | |
| | | deffers.push( |
| | | new Promise(resolve => { |
| | | Api.getSystemCacheConfig(mainparam, false).then(res => { |
| | | if (!res.status) { |
| | | if (!res.status && res.ErrCode !== '-2') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | |
| | | deffers = deffers.map(item => { |
| | | return new Promise(resolve => { |
| | | Api.getSystemCacheConfig(item, false).then(res => { |
| | | if (!res.status) { |
| | | if (!res.status && res.ErrCode !== '-2') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | |
| | | delete result.ErrMesg |
| | | delete result.message |
| | | delete result.status |
| | | |
| | | this.props.columns.forEach(item => { |
| | | if (item.arr_field && result[item.field]) { |
| | | result[item.uuid] = result[item.field] |
| | | } |
| | | }) |
| | | |
| | | this.resetFormList(result) |
| | | }) |
| | |
| | | if (setting.supModule && !BID) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: dict['sup_key_req'] || '需要上级主键值!', |
| | | message: setting.supModTip || dict['sup_key_req'] || '需要上级主键值!', |
| | | duration: 5 |
| | | }) |
| | | |
| | |
| | | this.execError({}) |
| | | }) |
| | | } else if (submit.intertype === 'system') { // 系统存储过程 |
| | | let result = getEditTableSql(submit, data, forms) |
| | | let result = getEditTableSql(submit, data, forms, setting) |
| | | let param = {} |
| | | |
| | | param.func = 'sPC_TableData_InUpDe' |
| | |
| | | this.execError({}) |
| | | }) |
| | | } else if (submit.intertype === 'inner' && submit.innerFunc) { // 自定义存储过程 |
| | | let result = getEditTableSql(submit, data, forms) |
| | | let result = getEditTableSql(submit, data, forms, setting) |
| | | let param = {} |
| | | |
| | | param.func = submit.innerFunc |
| | |
| | | let lines = data.map(item => { |
| | | let vals = [] |
| | | forms.forEach(col => { |
| | | vals.push(item[col.field]) |
| | | if (typeof(item[col.field]) === 'number') { |
| | | vals.push(item[col.field] + '') |
| | | } else { |
| | | vals.push(item[col.field]) |
| | | } |
| | | }) |
| | | |
| | | vals.push(item.$$uuid) |
| | |
| | | {setting.hasSubmit && edData.length > 0 ? <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> |
| | | <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-table" type="link">{dict['submit'] || '提交'}</Button> |
| | | </div> : null} |
| | | <div className={`edit-custom-table ${setting.tableHeader || ''} ${setting.parity === 'true' ? 'mk-parity' : ''} ${height ? 'fixed-table-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} style={style}> |
| | | <div className={`edit-custom-table ${setting.tableHeader || ''} ${setting.parity === 'true' ? 'mk-parity' : ''} ${height ? 'fixed-table-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'} ${setting.empSign === 'hidden' ? 'mk-empty-hide' : ''}`} style={style}> |
| | | <Table |
| | | rowKey="$$uuid" |
| | | components={components} |