| | |
| | | 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 |
| | | } |
| | | |
| | | this.setState({ |
| | | data: result.data.map((item, index) => { |
| | | let data = result.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | |
| | | item.$type = 'upt' |
| | | item.$origin = true |
| | | return item |
| | | }), |
| | | }) |
| | | |
| | | this.setState({ |
| | | 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 || '' |
| | |
| | | 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> |