| | |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import {connect} from 'react-redux' |
| | | import { BackTop, notification } from 'antd' |
| | | import { BackTop, notification, Button } from 'antd' |
| | | import MutilForm from '@/components/mutilform' |
| | | import {refreshTabView} from '@/store/action' |
| | | import Api from '@/api' |
| | | import DataSearch from './modules/search' |
| | |
| | | mainKey: null, // 主键 |
| | | selectable: false, // 表格是否可选 |
| | | datafunc: null, // 获取数据及显示列的存储过程名称 |
| | | data: null, |
| | | total: 0, |
| | | loading: true |
| | | data: null, // 列表数据 |
| | | total: 0, // 总数 |
| | | loading: true, // 表格加载中 |
| | | confirmloading: false, // 表单提交确认中 |
| | | formparam: null, // 表单参数 |
| | | showdetail: false // 是否显示详情或表单页面 |
| | | } |
| | | |
| | | async loadconfig () { |
| | | // 加载搜索条件及按钮信息 |
| | | let param = { |
| | | func: 's_Get_Page_wheproc', |
| | | MenuNo: this.props.MenuNo |
| | |
| | | } |
| | | |
| | | async loadDbdata (searches, pageIndex = 1, pageSize = 10, orderColumn = '', orderType = '') { |
| | | // 加载显示列及表格数据 |
| | | let param = { |
| | | func: this.state.datafunc, |
| | | MenuNo: this.props.MenuNo, |
| | |
| | | } |
| | | |
| | | gettableselected = () => { |
| | | // 获取表格选择项 |
| | | // 获取表格已选择项 |
| | | let data = [] |
| | | this.refs.dataTable.state.selectedRowKeys.forEach(item => { |
| | | data.push(this.refs.dataTable.props.data[item]) |
| | |
| | | } |
| | | |
| | | switchview = (param) => { |
| | | console.log(param) |
| | | // 切换至详情或表单页面 |
| | | let cols = param.execAction.FormLineQty |
| | | if (![1, 2, 3].includes(cols)) { |
| | | cols = 2 |
| | | } |
| | | param.cols = cols |
| | | this.setState({ |
| | | formparam: param, |
| | | showdetail: true |
| | | }) |
| | | } |
| | | |
| | | handleOk = () => { |
| | | // 表单提交 |
| | | let _param = this.state.formparam |
| | | // 从表单中获取填写数据 |
| | | this.formRef.handleConfirm().then(res => { |
| | | this.setState({ |
| | | confirmloading: true |
| | | }) |
| | | let values = [] |
| | | _param.formdata.forEach(column => { // 依次选取表单值、初始值,获取提交信息 |
| | | let value = '' |
| | | if (res.hasOwnProperty(column.FieldName)) { |
| | | value = res[column.FieldName] |
| | | } else if (column.InitVal) { |
| | | value = column.InitVal |
| | | } |
| | | values.push(column.FieldName + 'equal\'' + value + '\'') |
| | | }) |
| | | |
| | | let queryparam = { // 请求参数 |
| | | func: _param.execAction.AuditProc || _param.defaultproc[_param.execAction.Action], |
| | | ID: (_param.tabledata && _param.primarykey) ? _param.tabledata[_param.primarykey] : '', // 主键字段 |
| | | BID: (_param.tabledata && _param.bidkey) ? _param.tabledata[_param.bidkey] : '' // BID字段 |
| | | } |
| | | // 添加和修改请求参数字段不同 |
| | | if (_param.execAction.Action === 'Add') { |
| | | queryparam.AddLongText = values.join(',') |
| | | } else if (_param.execAction.Action === 'Update') { |
| | | queryparam.UptLongText = values.join(',') |
| | | } |
| | | |
| | | // 提交请求 |
| | | Api.submitInterface(queryparam).then(result => { |
| | | if (result.status) { |
| | | notification.success({ |
| | | top: 92, |
| | | message: this.state.dict['main.action.confirm.success'] |
| | | }) |
| | | |
| | | this.refreshbyaction(_param.execAction.ReloadForm) // 刷新主列表页面 |
| | | |
| | | if (_param.execAction.BackPre !== 'false') { // 页面返回 |
| | | this.handleCancel() |
| | | } |
| | | } else { |
| | | // 错误提示,取消提交中状态 |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 15 |
| | | }) |
| | | this.setState({ |
| | | confirmloading: false |
| | | }) |
| | | } |
| | | }) |
| | | }, () => {}) |
| | | } |
| | | |
| | | handleCancel = () => { |
| | | // 关闭当前窗口,返回原列表页 |
| | | this.setState({ |
| | | confirmloading: false, |
| | | formparam: null, |
| | | showdetail: false |
| | | }) |
| | | // 提交成功或返回时,滚动至顶部 |
| | | document.body.scrollTop = 0 |
| | | document.documentElement.scrollTop = 0 |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | return ( |
| | | <div className="datamanage"> |
| | | {!this.state.searchlist && <Loading />} |
| | | {this.state.searchlist && |
| | | <DataSearch |
| | | refreshdata={this.refreshbysearch} |
| | | searchlist={this.state.searchlist} |
| | | dict={this.state.dict} |
| | | /> |
| | | <div className={this.state.showdetail ? 'hidden-table' : ''}> |
| | | {/* 搜索条件 */} |
| | | {this.state.searchlist && |
| | | <DataSearch |
| | | refreshdata={this.refreshbysearch} |
| | | searchlist={this.state.searchlist} |
| | | dict={this.state.dict} |
| | | /> |
| | | } |
| | | {/* 按钮组 */} |
| | | {this.state.actions && this.state.columns && |
| | | <DataAction |
| | | MenuNo={this.props.MenuNo} |
| | | columns={this.state.columns} |
| | | mainKey={this.state.mainKey} |
| | | refreshdata={this.refreshbyaction} |
| | | switchformview={this.switchview} |
| | | gettableselected={this.gettableselected} |
| | | actions={this.state.actions} |
| | | dict={this.state.dict} |
| | | /> |
| | | } |
| | | {/* 表格 */} |
| | | {this.state.columns && |
| | | <DataTable |
| | | ref="dataTable" |
| | | MenuNo={this.props.MenuNo} |
| | | refreshdata={this.refreshbytable} |
| | | columns={this.state.columns} |
| | | data={this.state.data} |
| | | selectable={this.state.selectable} |
| | | total={this.state.total} |
| | | loading={this.state.loading} |
| | | dict={this.state.dict} |
| | | /> |
| | | } |
| | | </div> |
| | | {/* 详情或修改表单 */} |
| | | {this.state.showdetail && ( |
| | | <div className="tabform"> |
| | | <MutilForm |
| | | dict={this.state.dict} |
| | | formlist={this.state.formparam.formdata} |
| | | data={this.state.formparam.tabledata} |
| | | cols={this.state.formparam.cols} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> |
| | | <div className="operation"> |
| | | <Button type="primary" htmlType="submit" onClick={() => {this.handleOk()}} loading={this.state.confirmloading}> |
| | | {this.state.dict['main.confirm']} |
| | | </Button> |
| | | <Button onClick={() => {this.handleCancel()}}> |
| | | {this.state.dict['main.return']} |
| | | </Button> |
| | | </div> |
| | | </div>) |
| | | } |
| | | {this.state.actions && this.state.columns && |
| | | <DataAction |
| | | MenuNo={this.props.MenuNo} |
| | | columns={this.state.columns} |
| | | mainKey={this.state.mainKey} |
| | | refreshdata={this.refreshbyaction} |
| | | switchview={this.switchview} |
| | | gettableselected={this.gettableselected} |
| | | actions={this.state.actions} |
| | | dict={this.state.dict} |
| | | /> |
| | | } |
| | | {this.state.columns && |
| | | <DataTable |
| | | ref="dataTable" |
| | | MenuNo={this.props.MenuNo} |
| | | refreshdata={this.refreshbytable} |
| | | columns={this.state.columns} |
| | | data={this.state.data} |
| | | selectable={this.state.selectable} |
| | | total={this.state.total} |
| | | loading={this.state.loading} |
| | | dict={this.state.dict} |
| | | /> |
| | | } |
| | | {/* 返回顶部 */} |
| | | <BackTop> |
| | | <div className="ant-back-top"> |
| | | <div className="ant-back-top-content"> |