From 910e22f4bccbe5e5d8951398bd53a7d6d636b852 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 16 十月 2019 11:42:37 +0800 Subject: [PATCH] complete-datamanage --- src/tabviews/datamanage/index.jsx | 186 +++++++++++++++++++++++++++++++++++++--------- 1 files changed, 149 insertions(+), 37 deletions(-) diff --git a/src/tabviews/datamanage/index.jsx b/src/tabviews/datamanage/index.jsx index 444dbf5..dea5447 100644 --- a/src/tabviews/datamanage/index.jsx +++ b/src/tabviews/datamanage/index.jsx @@ -2,7 +2,8 @@ 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' @@ -28,12 +29,16 @@ 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 @@ -67,6 +72,7 @@ } async loadDbdata (searches, pageIndex = 1, pageSize = 10, orderColumn = '', orderType = '') { + // 鍔犺浇鏄剧ず鍒楀強琛ㄦ牸鏁版嵁 let param = { func: this.state.datafunc, MenuNo: this.props.MenuNo, @@ -159,7 +165,7 @@ } gettableselected = () => { - // 鑾峰彇琛ㄦ牸閫夋嫨椤� + // 鑾峰彇琛ㄦ牸宸查�夋嫨椤� let data = [] this.refs.dataTable.state.selectedRowKeys.forEach(item => { data.push(this.refs.dataTable.props.data[item]) @@ -168,7 +174,87 @@ } 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 () { @@ -194,38 +280,64 @@ 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"> -- Gitblit v1.8.0