| | |
| | | |
| | | 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} |
| | |
| | | const { config } = this.props |
| | | const { value, err } = this.state |
| | | |
| | | return ( |
| | | <InputNumber |
| | | title={err} |
| | | className={err ? 'has-error' : ''} |
| | | ref={ref => this.node = ref} |
| | | precision={config.decimal || 0} |
| | | value={value} |
| | | onChange={(value) => this.onChange(value)} |
| | | onPressEnter={this.enterPress} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | /> |
| | | ) |
| | | if (!config.decimal && config.decimal !== 0) { |
| | | return ( |
| | | <InputNumber |
| | | title={err} |
| | | className={err ? 'has-error' : ''} |
| | | ref={ref => this.node = ref} |
| | | value={value} |
| | | onChange={(value) => this.onChange(value)} |
| | | onPressEnter={this.enterPress} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | /> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <InputNumber |
| | | title={err} |
| | | className={err ? 'has-error' : ''} |
| | | ref={ref => this.node = ref} |
| | | precision={config.decimal} |
| | | value={value} |
| | | onChange={(value) => this.onChange(value)} |
| | | onPressEnter={this.enterPress} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | /> |
| | | ) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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"> |
| | |
| | | } |
| | | 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]) |
| | |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | } catch (e) { |
| | | console.info(content) |
| | | window.mkInfo(content) |
| | | console.warn(e) |
| | | content = '' |
| | | } |
| | |
| | | ) |
| | | } 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]) |
| | |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | } catch (e) { |
| | | console.info(content) |
| | | window.mkInfo(content) |
| | | console.warn(e) |
| | | content = '' |
| | | } |
| | |
| | | } else { |
| | | _item.datatype = item.datatype |
| | | } |
| | | if (_item.type === 'number' && item.type === 'number') { |
| | | _item.decimal = item.decimal || 0 |
| | | } |
| | | |
| | | forms.push(_item) |
| | | } else { |
| | |
| | | deForms: hasBid ? deForms : null |
| | | }, () => { |
| | | if (deForms.length > 0 && (!hasBid || BID)) { |
| | | this.improveActionForm(deForms, BID) |
| | | if (window.backend && window.GLOB.CacheData.has('sql_' + deForms[0].uuid)) { |
| | | this.improveBackActionForm(deForms, BID) |
| | | } else { |
| | | this.improveActionForm(deForms, BID) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | |
| | | const { deForms } = this.state |
| | | |
| | | if (deForms && nextProps.BID !== BID) { |
| | | this.improveActionForm(deForms, nextProps.BID) |
| | | if (window.backend && window.GLOB.CacheData.has('sql_' + deForms[0].uuid)) { |
| | | this.improveBackActionForm(deForms, nextProps.BID) |
| | | } else { |
| | | this.improveActionForm(deForms, nextProps.BID) |
| | | } |
| | | } |
| | | if (parCtrl && !is(fromJS(this.props.columns), fromJS(nextProps.columns))) { |
| | | let getColumns = (cols, sk) => { |
| | |
| | | sql = sql.replace(/@BID@/ig, `'${BID}'`) |
| | | |
| | | if (debug) { |
| | | console.info(sql) |
| | | window.mkInfo(sql) |
| | | } |
| | | |
| | | sql = sql.replace(/%/ig, ' mpercent ') |
| | |
| | | sql = sql.replace(/@BID@/ig, `'${BID}'`) |
| | | |
| | | if (debug) { |
| | | console.info(sql) |
| | | window.mkInfo(sql) |
| | | } |
| | | |
| | | sql = sql.replace(/%/ig, ' mpercent ') |
| | |
| | | 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, |
| | |
| | | delete result.ErrMesg |
| | | delete result.message |
| | | delete result.status |
| | | |
| | | this.resetFormList(result) |
| | | }) |
| | | } |
| | | |
| | | improveBackActionForm = (deForms, BID) => { |
| | | let sysvals = { |
| | | mk_departmentcode: sessionStorage.getItem('departmentcode') || '', |
| | | mk_organization: sessionStorage.getItem('organization') || '', |
| | | mk_user_type: sessionStorage.getItem('mk_user_type') || '', |
| | | bid: BID || '', |
| | | datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '' |
| | | } |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | sysvals.db = window.GLOB.externalDatabase |
| | | } |
| | | |
| | | let deffers = [] |
| | | let mainItems = [] // 云端或单点数据 |
| | | let localItems = [] // 本地数据 |
| | | |
| | | deForms.forEach(item => { |
| | | let ex = window.GLOB.CacheData.get('sql_' + item.uuid) |
| | | |
| | | if (!ex) return |
| | | |
| | | let exps = [] |
| | | ex.reps.forEach(n => { |
| | | let key = n.toLowerCase() |
| | | if (sysvals.hasOwnProperty(key)) { |
| | | exps.push({ |
| | | key: n, |
| | | value: sysvals[key] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | let cell = { |
| | | id: ex.id, |
| | | menuname: item.label + '(表单)', |
| | | exps: exps, |
| | | md5_id: '' |
| | | } |
| | | |
| | | if (item.database === 'sso' && window.GLOB.mainSystemApi) { |
| | | mainItems.push(cell) |
| | | } else { |
| | | localItems.push(cell) |
| | | } |
| | | }) |
| | | |
| | | if (localItems.length) { |
| | | deffers.push({ |
| | | $backend: true, |
| | | $type: 's_Get_SelectedList', |
| | | data: localItems |
| | | }) |
| | | } |
| | | |
| | | if (mainItems.length) { |
| | | deffers.push({ |
| | | $backend: true, |
| | | $type: 's_Get_SelectedList', |
| | | data: mainItems, |
| | | rduri: window.GLOB.mainSystemApi |
| | | }) |
| | | } |
| | | |
| | | if (!deffers.length) return |
| | | |
| | | deffers = deffers.map(item => { |
| | | return new Promise(resolve => { |
| | | Api.getSystemCacheConfig(item, false).then(res => { |
| | | if (!res.status && res.ErrCode !== '-2') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | }) |
| | | |
| | | Promise.all(deffers).then(response => { |
| | | let result = {...response[0], ...(response[1] || {})} |
| | | |
| | | delete result.ErrCode |
| | | 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 |
| | | }) |
| | | |
| | |
| | | |
| | | if (!data) return |
| | | |
| | | let result = getEditTableSql(submit, data, forms) |
| | | |
| | | let param = { |
| | | excel_in: result.lines, |
| | | BID: BID || '' |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | if (submit.intertype === 'system') { // 系统存储过程 |
| | | param.func = 'sPC_TableData_InUpDe' |
| | | |
| | | delete param.excel_in |
| | | if (submit.intertype === 'system' && window.backend && window.GLOB.CacheData.has('sql_submit_' + submit.$menuId)) { |
| | | let ex = window.GLOB.CacheData.get('sql_submit_' + submit.$menuId) |
| | | let param = this.getExps(ex, submit, data, forms) |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | | this.execSuccess(res, record) |
| | | } else { |
| | | this.execError(res, record) |
| | | } |
| | | }, (error) => { |
| | | if (error && error.ErrCode === 'LoginError') return |
| | | |
| | | this.execError({}) |
| | | }) |
| | | } else if (submit.intertype === 'system') { // 系统存储过程 |
| | | let result = getEditTableSql(submit, data, forms, setting) |
| | | let param = {} |
| | | |
| | | param.func = 'sPC_TableData_InUpDe' |
| | | param.BID = BID || '' |
| | | |
| | | param.exec_type = window.GLOB.execType || 'y' |
| | | param.LText = Utils.formatOptions(result.sql, param.exec_type) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | |
| | | this.execError({}) |
| | | }) |
| | | } else if (submit.intertype === 'inner' && submit.innerFunc) { // 自定义存储过程 |
| | | let result = getEditTableSql(submit, data, forms, setting) |
| | | let param = {} |
| | | |
| | | param.func = submit.innerFunc |
| | | param.BID = BID || '' |
| | | param.excel_in = result.lines |
| | | |
| | | if (submit.recordUser === 'true') { |
| | | param.username = sessionStorage.getItem('User_Name') || '' |
| | |
| | | |
| | | this.execError({}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | getExps = (ex, btn, data, forms) => { |
| | | const { BID } = this.props |
| | | |
| | | let exps = [] |
| | | let values = { |
| | | time_id: Utils.getguid(), |
| | | roleid: sessionStorage.getItem('role_id') || '', |
| | | mk_departmentcode: sessionStorage.getItem('departmentcode') || '', |
| | | mk_organization: sessionStorage.getItem('organization') || '', |
| | | mk_user_type: sessionStorage.getItem('mk_user_type') || '', |
| | | mk_nation: sessionStorage.getItem('nation') || '', |
| | | mk_province: sessionStorage.getItem('province') || '', |
| | | mk_city: sessionStorage.getItem('city') || '', |
| | | mk_district: sessionStorage.getItem('district') || '', |
| | | mk_address: sessionStorage.getItem('address') || '', |
| | | bid: BID || '', |
| | | typename: 'admin', |
| | | datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '', |
| | | } |
| | | |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | values.db = window.GLOB.externalDatabase |
| | | } |
| | | |
| | | let lines = data.map(item => { |
| | | let vals = [] |
| | | forms.forEach(col => { |
| | | if (typeof(item[col.field]) === 'number') { |
| | | vals.push(item[col.field] + '') |
| | | } else { |
| | | vals.push(item[col.field]) |
| | | } |
| | | }) |
| | | |
| | | vals.push(item.$$uuid) |
| | | vals.push(item.$type || 'upt') |
| | | vals.push(BID) |
| | | |
| | | return vals |
| | | }) |
| | | |
| | | ex.reps.forEach(n => { |
| | | let key = n.toLowerCase() |
| | | if (values.hasOwnProperty(key)) { |
| | | exps.push({ |
| | | key: n, |
| | | value: values[key] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | exps.push({ |
| | | key: 'mk_excel_data', |
| | | value: lines |
| | | }) |
| | | |
| | | let md5_id = '' |
| | | if (window.GLOB.probation) { |
| | | md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000)) |
| | | md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18) |
| | | } |
| | | |
| | | return { |
| | | $backend: true, |
| | | $type: 's_TableData_InUpDe', |
| | | data: [{ |
| | | id: ex.id, |
| | | menuname: btn.logLabel || '', |
| | | exps: exps, |
| | | md5_id: md5_id |
| | | }] |
| | | } |
| | | } |
| | | |
| | |
| | | {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} |