| | |
| | | key: 'formula', |
| | | label: '公式', |
| | | initVal: card.formula || '', |
| | | tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等', |
| | | tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果,在不使用解析时换行符或空格会替换为页面元素。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等', |
| | | placeholder: '例如:@price@ * @number@', |
| | | required: true |
| | | }, |
| | |
| | | if (type === 'card') { |
| | | opentypes.push({ |
| | | value: 'form', |
| | | text: '表单' |
| | | text: '表单(开关或勾选框)' |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | let editCols = [ |
| | | { |
| | | field: '$sub', |
| | | label: '提交' |
| | | }, |
| | | { |
| | | field: '$next', |
| | | label: '下一行' |
| | | }, |
| | | { |
| | | field: '$noAct', |
| | | label: '无动作' |
| | | } |
| | | ] |
| | | columns.forEach(col => { |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'dropdown', |
| | | label: '下拉宽度', |
| | | initVal: card.dropdown || 'flex', |
| | | required: false, |
| | | options: [{ |
| | | value: 'flex', |
| | | text: '自适应' |
| | | }, { |
| | | value: 'fixed', |
| | | text: '定宽' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'required', |
| | | label: '必填', |
| | | initVal: card.required || 'false', |
| | |
| | | tooltip: '包括文本或数值回车事件、下拉菜单选中事件、开关切换事件。', |
| | | options: editCols |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'footEnter', |
| | | label: '末行回车', |
| | | initVal: card.footEnter || 'false', |
| | | tooltip: '新增功能仅在表格可新增时有效。', |
| | | options: [{ |
| | | value: 'sub', |
| | | text: '提交' |
| | | }, { |
| | | value: 'add', |
| | | text: '新增' |
| | | }, { |
| | | value: 'false', |
| | | text: '无动作' |
| | | }] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // key: 'footEnter', |
| | | // label: '末行回车', |
| | | // initVal: card.footEnter || 'false', |
| | | // tooltip: '新增功能仅在表格可新增时有效。', |
| | | // options: [{ |
| | | // value: 'sub', |
| | | // text: '提交' |
| | | // }, { |
| | | // value: 'add', |
| | | // text: '新增' |
| | | // }, { |
| | | // value: 'false', |
| | | // text: '无动作' |
| | | // }] |
| | | // }, |
| | | { |
| | | type: 'number', |
| | | key: 'decimal', |
| | |
| | | key: 'formula', |
| | | label: '公式', |
| | | initVal: card.formula || '', |
| | | tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等', |
| | | tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果,在不使用解析时换行符或空格会替换为页面元素。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等', |
| | | placeholder: '例如:@price@ * @number@', |
| | | required: true |
| | | }, |
| | |
| | | _options.push('editType') |
| | | |
| | | if (this.column.editType === 'switch') { |
| | | _options.push('enter', 'footEnter', 'openVal', 'closeVal', 'openText', 'closeText') |
| | | _options.push('enter', 'openVal', 'closeVal', 'openText', 'closeText', 'editField') |
| | | } else if (this.column.editType === 'select') { |
| | | _options.push('required', 'enter', 'footEnter', 'resourceType', 'linkSubField', 'editField') |
| | | _options.push('required', 'enter', 'resourceType', 'linkSubField', 'editField', 'dropdown') |
| | | |
| | | if (this.column.resourceType === '0') { |
| | | _options.push('options') |
| | |
| | | _options.push('dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'disableField', 'database') |
| | | } |
| | | } else { |
| | | _options.push('required', 'enter', 'footEnter') |
| | | _options.push('required', 'enter') |
| | | } |
| | | } else if (this.column.type === 'number') { |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | _options.push('max', 'min', 'enter') |
| | | } |
| | | } |
| | | |
| | |
| | | const columns = this.state.columns.map((col, index) => { |
| | | let title = col.label |
| | | if (col.editable === 'true') { |
| | | title = <span>{col.label}<EditOutlined style={{position: 'absolute', bottom: 0, right: 0, color: '#1890ff'}}/></span> |
| | | title = <span>{col.label}<EditOutlined style={{position: 'absolute', bottom: 0, right: 0, color: '#1890ff', opacity: '0.7'}}/></span> |
| | | } |
| | | return { |
| | | title: title, |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'commit', |
| | | label: '数据提交', |
| | | initval: wrap.commit || 'all', |
| | | field: 'submittal', |
| | | label: '提交后', |
| | | initval: wrap.submittal || 'false', |
| | | required: false, |
| | | options: [ |
| | | {value: 'all', label: '全部'}, |
| | | {value: 'change', label: '修改项'}, |
| | | {value: 'true', label: '可编辑'}, |
| | | {value: 'false', label: '不可编辑'}, |
| | | ] |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'commit', |
| | | label: '数据提交', |
| | | initval: wrap.commit || 'all', |
| | | tooltip: '单项提交指在表单中回车或删除行时,设置为单项时如点击提交按钮,会提交修改项。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'all', label: '全部'}, |
| | | {value: 'change', label: '修改项'}, |
| | | {value: 'simple', label: '单项'}, |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'operType', |
| | | label: '编辑按钮', |
| | | initval: wrap.operType || 'btnMode', |
| | |
| | | key: 'formula', |
| | | label: '公式', |
| | | initVal: card.formula || '', |
| | | tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等', |
| | | tooltip: '执行时会使用查询到的数据替换相应的字段,展示获得的结果,在不使用解析时换行符或空格会替换为页面元素。可使用JS的一些语法,如:三元表达式 @field1@ > @field2@ ? 0 : 1;Math对象,取绝对值 Math.abs(@field@)、四舍五入 Math.round(@field@)等', |
| | | placeholder: '例如:@price@ * @number@', |
| | | required: true |
| | | }, |
| | |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MainTable from './normalTable' |
| | | import './index.scss' |
| | | |
| | | // 通用组件 |
| | | const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) |
| | | const MainAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) |
| | | const MainTable = asyncComponent(() => import('./normalTable')) |
| | | // const MainTable = asyncComponent(() => import('./normalTable')) |
| | | const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) |
| | | |
| | | class EditableTable extends Component { |
| | |
| | | pageSize: 10, // 每页数据条数 |
| | | orderBy: '', // 排序 |
| | | search: '', // 搜索条件数组,使用时需分场景处理 |
| | | statFValue: [] // 合计值 |
| | | statFValue: [], // 合计值 |
| | | lock: false |
| | | } |
| | | |
| | | /** |
| | |
| | | if (setting.laypage) { |
| | | start = pageSize * (pageIndex - 1) + 1 |
| | | } |
| | | let data = result.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = start + index + '' |
| | | item.$type = 'upt' |
| | | item.$origin = true |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | data: result.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = start + index + '' |
| | | item.$type = 'upt' |
| | | item.$origin = true |
| | | return item |
| | | }), |
| | | data: data, |
| | | selectedData: [], |
| | | total: result.total, |
| | | loading: false |
| | | }) |
| | | |
| | | MKEmitter.emit('transferData', config.uuid, data) |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | |
| | | /** |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadmainLinedata (id) { |
| | | async loadmainLinedata (id, line) { |
| | | const { mainSearch } = this.props |
| | | const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state |
| | | |
| | |
| | | if (result.status) { |
| | | let data = fromJS(this.state.data).toJS() |
| | | let selectedData = fromJS(this.state.selectedData).toJS() |
| | | if (result.data && result.data[0]) { |
| | | let _data = result.data[0] || {} |
| | | _data.$$uuid = _data[setting.primaryKey] || '' |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | _data.$type = 'upt' |
| | | _data.$origin = true |
| | | |
| | | try { |
| | | data = data.map(item => { |
| | | if (item.$$uuid === _data.$$uuid) { |
| | | _data.key = item.key |
| | | _data.$Index = item.$Index |
| | | return _data |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | selectedData = selectedData.map(item => { |
| | | if (_data.$$uuid === item.$$uuid) { |
| | | return _data |
| | | } |
| | | let _data = result.data[0] || {} |
| | | _data.$$uuid = _data[setting.primaryKey] || '' |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | _data.$type = 'upt' |
| | | _data.$origin = true |
| | | |
| | | try { |
| | | data = data.map(item => { |
| | | if (item.$$uuid === _data.$$uuid) { |
| | | _data.key = item.key |
| | | _data.$Index = item.$Index |
| | | return _data |
| | | } else { |
| | | return item |
| | | }) |
| | | } catch (e) { |
| | | console.warn('数据查询错误') |
| | | } |
| | | } |
| | | }) |
| | | selectedData = selectedData.map(item => { |
| | | if (_data.$$uuid === item.$$uuid) { |
| | | return _data |
| | | } |
| | | return item |
| | | }) |
| | | } catch (e) { |
| | | console.warn('数据查询错误') |
| | | } |
| | | |
| | | if (line) { |
| | | if (line.$type === 'del' && !result.data[0]) { |
| | | data = data.filter(m => m.$$uuid === line.$$uuid) |
| | | } |
| | | MKEmitter.emit('transferData', config.uuid, _data, 'line') |
| | | } else { |
| | | MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid || '', _data) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId, id) => { |
| | | reloadData = (menuId, id, item) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | |
| | | if (!id) { |
| | | this.reloadtable() |
| | | } else { |
| | | this.loadmainLinedata(id) |
| | | this.loadmainLinedata(id, item) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { BID, setting, searchlist, actions, config, columns, BData, data, selectedData } = this.state |
| | | const { BID, setting, searchlist, actions, config, columns, BData, data, selectedData, lock } = this.state |
| | | |
| | | return ( |
| | | <div className="custom-edit-table" style={config.style}> |
| | |
| | | setting={setting} |
| | | actions={actions} |
| | | BData={BData} |
| | | lock={lock} |
| | | columns={config.columns} |
| | | selectedData={selectedData} |
| | | /> |
| | |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | chgSelectData={(selects) => this.setState({selectedData: selects})} |
| | | changeLock={(lock) => this.setState({lock: lock})} |
| | | statFValue={this.state.statFValue} |
| | | /> |
| | | </div> |
| | |
| | | const { config } = this.props |
| | | this.setState({ status: val }, () => { |
| | | let _val = val ? config.openVal : config.closeVal |
| | | this.props.onChange(_val) |
| | | let _text = val ? config.openText : config.closeText |
| | | this.props.onChange(_val, _text) |
| | | }) |
| | | } |
| | | |
| | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else { |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | MKEmitter.emit('tdFocus', col.enter + record.$$uuid) |
| | | } |
| | | }, 50) |
| | |
| | | this.setState({value: val, err}) |
| | | } |
| | | |
| | | onSwitchChange = (val) => { |
| | | onSwitchChange = (val, label) => { |
| | | const { col, record } = this.props |
| | | |
| | | this.setState({editing: false}) |
| | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else { |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | MKEmitter.emit('tdFocus', col.enter + record.$$uuid) |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | let values = {} |
| | | if (col.editField) { |
| | | values[col.field] = label |
| | | values[col.editField] = val |
| | | } else { |
| | | values[col.field] = val |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | onSelectChange = (val, option) => { |
| | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else { |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | MKEmitter.emit('tdFocus', col.enter + record.$$uuid) |
| | | } |
| | | }, 50) |
| | |
| | | {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null} |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | return (<td className="editing_table_cell"> |
| | | <CusSwitch config={col} defaultValue={_value} autoFocus={true} onChange={this.onSwitchChange} onBlur={this.switchBlur}/> |
| | | </td>) |
| | | } else { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | return (<td className="editing_table_cell"> |
| | | <Select |
| | | showSearch |
| | | defaultValue={_value} |
| | | dropdownClassName="edit-table-dropdown" |
| | | dropdownMatchSelectWidth={col.dropdown === 'fixed'} |
| | | id={col.uuid + record.$$uuid} |
| | | onBlur={() => this.setState({editing: false})} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else { |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | MKEmitter.emit('tdFocus', col.enter + record.$$uuid) |
| | | } |
| | | }, 50) |
| | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | } |
| | | |
| | | onSwitchChange = (val) => { |
| | | onSwitchChange = (val, label) => { |
| | | const { col, record } = this.props |
| | | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else { |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | MKEmitter.emit('tdFocus', col.enter + record.$$uuid) |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | let values = {} |
| | | if (col.editField) { |
| | | values[col.field] = label |
| | | values[col.editField] = val |
| | | } else { |
| | | values[col.field] = val |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | onSelectChange = (val, option) => { |
| | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else { |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | MKEmitter.emit('tdFocus', col.enter + record.$$uuid) |
| | | } |
| | | }, 50) |
| | |
| | | let children = null |
| | | if (col.type === 'text') { |
| | | if (col.editable === 'true') { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | |
| | | if (!col.editType || col.editType === 'text') { |
| | | children = (<> |
| | | <Input id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | |
| | | children = (<> |
| | | <Select |
| | | showSearch |
| | | dropdownClassName="edit-table-dropdown" |
| | | dropdownMatchSelectWidth={col.dropdown === 'fixed'} |
| | | defaultValue={_value} |
| | | id={col.uuid + record.$$uuid} |
| | | onBlur={() => this.setState({editing: false})} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.onSelectChange} |
| | | > |
| | |
| | | total: PropTypes.any, // 总数 |
| | | loading: PropTypes.bool, // 表格加载中 |
| | | refreshdata: PropTypes.func, // 表格中排序列、页码的变化时刷新 |
| | | changeLock: PropTypes.func, |
| | | chgSelectData: PropTypes.func, |
| | | } |
| | | |
| | | state = { |
| | |
| | | pickup: false, // 收起未选择项 |
| | | orderfields: {}, // 排序id与field转换 |
| | | loading: false, |
| | | editable: 'false', |
| | | editable: false, |
| | | pageOptions: [] |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { setting, fields, columns, data } = this.props |
| | | const { setting, fields, columns } = this.props |
| | | let orderfields = {} |
| | | let initEditLine = null |
| | | let edColumns = [] |
| | |
| | | this.setState({ |
| | | pageSize: setting.pageSize || 10, |
| | | pageOptions, |
| | | data, |
| | | columns: _columns, |
| | | edColumns, |
| | | tableId: setting.tableId, |
| | | orderfields, |
| | | initEditLine, |
| | | editable: setting.editable |
| | | editable: setting.editable === 'true' |
| | | }, () => { |
| | | if (deForms.length > 0) { |
| | | this.improveActionForm(deForms) |
| | |
| | | |
| | | componentDidMount () { |
| | | const { fields, setting } = this.props |
| | | const { data, editable } = this.state |
| | | |
| | | this.setState({ |
| | | fields: fields.filter(item => item.field !== setting.primaryKey), |
| | | }) |
| | | |
| | | if (editable === 'true' && data && data.length > 0) { |
| | | this.setState({editable: 'false'}) |
| | | setTimeout(() => { |
| | | this.pickupChange() |
| | | }, 200) |
| | | } |
| | | |
| | | MKEmitter.addListener('subLine', this.subLine) |
| | | MKEmitter.addListener('nextLine', this.nextLine) |
| | | MKEmitter.addListener('addRecord', this.addLine) |
| | | MKEmitter.addListener('delRecord', this.delRecord) |
| | | MKEmitter.addListener('resetTable', this.resetTable) |
| | | MKEmitter.addListener('transferData', this.transferData) |
| | | MKEmitter.addListener('changeRecord', this.changeRecord) |
| | | } |
| | | |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('subLine', this.subLine) |
| | | MKEmitter.removeListener('nextLine', this.nextLine) |
| | | MKEmitter.removeListener('addRecord', this.addLine) |
| | | MKEmitter.removeListener('delRecord', this.delRecord) |
| | | MKEmitter.removeListener('resetTable', this.resetTable) |
| | | MKEmitter.removeListener('transferData', this.transferData) |
| | | MKEmitter.removeListener('changeRecord', this.changeRecord) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | this.setState({data: nextProps.data || []}) |
| | | if (this.state.editable === 'true' && !this.state.pickup) { |
| | | this.setState({editable: 'false'}) |
| | | transferData = (menuid, data, type) => { |
| | | if (menuid !== this.props.MenuID) return |
| | | |
| | | if (type !== 'line') { |
| | | this.setState({data: data || []}) |
| | | |
| | | if (this.state.editable && !this.state.pickup) { |
| | | this.setState({editable: false}) |
| | | setTimeout(() => { |
| | | this.pickupChange() |
| | | }, 200) |
| | | } |
| | | } else if (type === 'line' && data.$$uuid) { |
| | | let _data = this.state.data.map(item => { |
| | | if (item.$$uuid === data.$$uuid) { |
| | | return data |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | let _edData = this.state.edData.map(item => { |
| | | if (item.$$uuid === data.$$uuid) { |
| | | return data |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | this.setState({edData: _edData, data: _data}) |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | if (next && initEditLine) { |
| | | MKEmitter.emit('tdFocus', initEditLine.uuid + next.$$uuid) |
| | | } else if (col.footEnter === 'add' && setting.addable === 'true') { |
| | | } else if (setting.addable === 'true') { |
| | | setTimeout(() => { |
| | | this.plusLine() |
| | | }, 10) |
| | | } else if (col.footEnter === 'sub') { |
| | | setTimeout(() => { |
| | | this.checkData() |
| | | }, 10) |
| | | } |
| | | } |
| | | |
| | | subLine = (col, record) => { |
| | | const { tableId, fields, edData } = this.state |
| | | |
| | | if (col && col.tableId !== tableId) return |
| | | |
| | | if (edData.filter(item => !item.$origin).length > 1) { |
| | | setTimeout(() => { |
| | | this.submit(edData) |
| | | }, 10) |
| | | return |
| | | } |
| | | |
| | | setTimeout(() => { |
| | | let item = fromJS(record).toJS() |
| | | let line = [] |
| | | fields.forEach(col => { |
| | | if (col.editable !== 'true' || item.$deleted) { |
| | | if (col.type === 'number') { |
| | | item[col.field] = +item[col.field] |
| | | if (isNaN(item[col.field])) { |
| | | item[col.field] = 0 |
| | | } |
| | | } else { |
| | | item[col.field] = item[col.field] !== undefined ? (item[col.field] + '') : '' |
| | | } |
| | | return |
| | | } |
| | | if (col.type === 'text') { |
| | | let val = item[col.field] !== undefined ? (item[col.field] + '') : '' |
| | | if (col.required === 'true' && !val) { |
| | | line.push(`${col.label}不可为空`) |
| | | } |
| | | item[col.field] = val |
| | | } else if (col.type === 'number') { |
| | | let val = item[col.field] |
| | | if (!val && val !== 0) { |
| | | line.push(`${col.label}不可为空`) |
| | | return |
| | | } |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | line.push(`${col.label}数据格式错误`) |
| | | return |
| | | } |
| | | |
| | | val = +val.toFixed(col.decimal || 0) |
| | | |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | line.push(`${col.label}不可大于${col.max}`) |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | line.push(`${col.label}不可小于${col.min}`) |
| | | } |
| | | |
| | | item[col.field] = val |
| | | } |
| | | }) |
| | | |
| | | let err = line.join(',') |
| | | |
| | | if (err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: err, |
| | | duration: 5 |
| | | }) |
| | | } else { |
| | | this.submit([item], 'simple') |
| | | } |
| | | }, 10) |
| | | } |
| | | |
| | | plusLine = () => { |
| | |
| | | } |
| | | |
| | | delRecord = (id, record) => { |
| | | const { setting } = this.props |
| | | const { tableId, edData } = this.state |
| | | |
| | | if (id !== tableId) return |
| | |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | if (setting.commit === 'simple' && record.$deleted) { |
| | | this.subLine(null, record) |
| | | } |
| | | } |
| | | |
| | | this.setState({edData: _data}) |
| | |
| | | } |
| | | } |
| | | |
| | | submit = (data) => { |
| | | submit = (data, type) => { |
| | | const { submit, BID, setting } = this.props |
| | | const { fields } = this.state |
| | | |
| | | if (setting.commit === 'change') { |
| | | if (type !== 'simple' && (setting.commit === 'change' || setting.commit === 'simple')) { |
| | | data = data.filter(item => !item.$origin) |
| | | } |
| | | |
| | |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | | this.execSuccess(res) |
| | | if (type === 'simple') { |
| | | this.updataLine(data[0]) |
| | | this.execSuccess(res, type) |
| | | } else { |
| | | this.execSuccess(res) |
| | | } |
| | | } else { |
| | | this.execError(res) |
| | | } |
| | |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | | this.execSuccess(res) |
| | | if (type === 'simple') { |
| | | this.updataLine(data[0]) |
| | | this.execSuccess(res, type) |
| | | } else { |
| | | this.execSuccess(res) |
| | | } |
| | | } else { |
| | | this.execError(res) |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | execSuccess = (res) => { |
| | | updataLine = (item) => { |
| | | if (item.$type === 'del') { |
| | | let _data = this.state.edData.filter(m => m.$$uuid !== item.$$uuid) |
| | | |
| | | this.setState({edData: _data}) |
| | | } else { |
| | | let _data = this.state.edData.map(m => { |
| | | if (m.$$uuid === item.$$uuid) { |
| | | item.$origin = true |
| | | return item |
| | | } |
| | | return m |
| | | }) |
| | | |
| | | this.setState({edData: _data}) |
| | | } |
| | | MKEmitter.emit('reloadData', this.props.MenuID, item.$$uuid, item) |
| | | } |
| | | |
| | | execSuccess = (res, type) => { |
| | | const { submit } = this.props |
| | | |
| | | if (res && res.ErrCode === 'S') { // 执行成功 |
| | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | |
| | | if (type === 'simple') return |
| | | |
| | | if (submit.closetab === 'true') { |
| | | MKEmitter.emit('popclose') |
| | |
| | | } |
| | | |
| | | repick = () => { |
| | | const { setting } = this.props |
| | | const { data } = this.state |
| | | |
| | | if (setting.submittal === 'true') { |
| | | this.setState({editable: true}) |
| | | } |
| | | |
| | | this.props.changeLock(false) |
| | | this.setState({ |
| | | data: [], |
| | | edData: [], |
| | |
| | | }) |
| | | } else { |
| | | pickup && MKEmitter.emit('resetSelectLine', MenuID, '', '') |
| | | pickup && this.props.chgSelectData([]) |
| | | this.setState({ |
| | | data: [], |
| | | edData: [], |
| | |
| | | }) |
| | | }) |
| | | } |
| | | this.props.changeLock(pickup) |
| | | } |
| | | |
| | | render() { |
| | |
| | | } |
| | | } |
| | | .editing_all_table_cell { |
| | | .ant-input { |
| | | border-radius: 0; |
| | | } |
| | | .ant-select { |
| | | width: 100%; |
| | | .ant-select-selection { |
| | | border-radius: 0; |
| | | } |
| | | } |
| | | .ant-input-number-handler-wrap { |
| | | display: none; |
| | | .ant-input-number { |
| | | border-radius: 0; |
| | | |
| | | .ant-input-number-handler-wrap { |
| | | display: none; |
| | | } |
| | | .ant-input-number-input { |
| | | border-radius: 0; |
| | | } |
| | | } |
| | | .anticon-exclamation-circle { |
| | | color: #ff4d4f; |
| | |
| | | } |
| | | .mk-add-line { |
| | | display: block; |
| | | width: 100%; |
| | | width: 100px; |
| | | color: #26C281; |
| | | border: 1px solid #dddddd; |
| | | border-radius: 0; |
| | | font-size: 25px; |
| | | height: 40px; |
| | | } |
| | | .mk-add-line:disabled { |
| | | border-color: #fafafa!important; |
| | | height: 45px; |
| | | } |
| | | } |
| | | .edit-custom-table.buoyMode { |
| | |
| | | cursor: pointer; |
| | | } |
| | | } |
| | | } |
| | | .edit-table-dropdown { |
| | | .ant-select-dropdown-menu-item { |
| | | white-space: unset; |
| | | text-overflow: unset; |
| | | } |
| | | } |
| | |
| | | class ActionList extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.any, // 主表ID |
| | | lock: PropTypes.any, // 可编辑表中按钮锁定 |
| | | BData: PropTypes.any, // 主表数据 |
| | | selectedData: PropTypes.any, // 子表中选择数据 |
| | | Tab: PropTypes.any, // 如果当前元素为标签时,tab为标签信息 |
| | |
| | | } |
| | | |
| | | getButtonList = (actions) => { |
| | | const { BID, BData, MenuID, Tab, columns, setting, ContainerId, selectedData } = this.props |
| | | const { BID, BData, MenuID, Tab, columns, setting, ContainerId, selectedData, lock } = this.props |
| | | |
| | | return actions.map(item => { |
| | | if (['exec', 'prompt', 'pop'].includes(item.OpenType)) { |
| | |
| | | <NormalButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | BID={BID} |
| | | Tab={Tab} |
| | | btn={item} |
| | |
| | | <ExcelInButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | BID={BID} |
| | | Tab={Tab} |
| | | btn={item} |
| | |
| | | <ExcelOutButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | BID={BID} |
| | | Tab={Tab} |
| | | btn={item} |
| | |
| | | <PopupButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | BID={BID} |
| | | Tab={Tab} |
| | | btn={item} |
| | |
| | | <TabButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | btn={item} |
| | | BData={BData} |
| | | MenuID={MenuID} |
| | |
| | | <NewPageButton |
| | | key={item.uuid} |
| | | show="actionList" |
| | | disabled={lock || false} |
| | | btn={item} |
| | | BData={BData} |
| | | setting={setting} |
| | |
| | | <ChangeUserButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | BID={BID} |
| | | btn={item} |
| | | BData={BData} |
| | |
| | | <PrintButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | BID={BID} |
| | | Tab={Tab} |
| | | btn={item} |
| | |
| | | // 需要选择单行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['main.action.confirm.selectSingleLine'], |
| | | message: data.length === 0 ? '请选择行!' : '请选择单行数据!', |
| | | duration: 5 |
| | | }) |
| | | return |