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 --- public/index.html | 1 src/api/index.js | 2 src/tabviews/tabform/index.jsx | 48 ++++--- src/views/login/index.scss | 2 src/tabviews/datamanage/index.jsx | 186 ++++++++++++++++++++++++------ src/tabviews/datamanage/index.scss | 20 +++ src/components/sidemenu/index.jsx | 6 public/options.js | 3 src/tabviews/datamanage/modules/action/index.jsx | 84 +++++++------ src/assets/css/main.scss | 4 src/assets/img/loginbg.jpg | 0 11 files changed, 252 insertions(+), 104 deletions(-) diff --git a/public/index.html b/public/index.html index d1cbecf..3396e4d 100644 --- a/public/index.html +++ b/public/index.html @@ -8,6 +8,7 @@ <meta name="description" content="minkesoft" /> <link rel="apple-touch-icon" href="logo.png" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> + <script src="./options.js"></script> <title>MinkeSoft</title> </head> <body> diff --git a/public/options.js b/public/options.js new file mode 100644 index 0000000..8a70246 --- /dev/null +++ b/public/options.js @@ -0,0 +1,3 @@ +window.GLOB = { + service: 'mkwms' +} \ No newline at end of file diff --git a/src/api/index.js b/src/api/index.js index 78d5efd..d5b81a1 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -30,7 +30,7 @@ class Api { constructor() { if (process.env.NODE_ENV === 'production') { - axios.defaults.baseURL = document.location.origin + axios.defaults.baseURL = document.location.origin + (window.GLOB.service ? '/' + window.GLOB.service : '') } else { // axios.defaults.baseURL = 'http://127.0.0.1:8888' } diff --git a/src/assets/css/main.scss b/src/assets/css/main.scss index bce8f01..12517d4 100644 --- a/src/assets/css/main.scss +++ b/src/assets/css/main.scss @@ -121,6 +121,6 @@ } // 纭鎻愮ず妗嗛珮搴� -.ant-modal { - top: 38vh!important; +.ant-modal.ant-modal-confirm { + top: 38vh; } \ No newline at end of file diff --git a/src/assets/img/loginbg.jpg b/src/assets/img/loginbg.jpg new file mode 100644 index 0000000..72130b7 --- /dev/null +++ b/src/assets/img/loginbg.jpg Binary files differ diff --git a/src/components/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index c56c0fb..00e1b63 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -48,10 +48,10 @@ child.src = '#/main/' + _msg if (child.LinkUrl === 'CommonTable') { child.type = 'CommonTable' - } else if (child.LinkUrl === 'DataManage' || child.LinkUrl === 'Main/Index?MenuNo=sProcExcepM') { + } else if (child.LinkUrl === 'DataManage') { child.type = 'DataManage' - } else if (child.LinkUrl === 'bda/rdt?pageno=rolemenus&MenuNo=RoleMenuM') { - child.type = 'RoleManage' + // } else if (child.LinkUrl === 'bda/rdt?pageno=rolemenus&MenuNo=RoleMenuM') { + // child.type = 'RoleManage' } else if (child.LinkUrl.split('?')[0] === 'Main/Index' || child.LinkUrl.split('?')[0] === 'bda/rdt') { child.type = 'iframe' } 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"> diff --git a/src/tabviews/datamanage/index.scss b/src/tabviews/datamanage/index.scss index f23de89..a07394f 100644 --- a/src/tabviews/datamanage/index.scss +++ b/src/tabviews/datamanage/index.scss @@ -1,6 +1,26 @@ .datamanage { min-height: calc(100vh - 94px); padding-top: 16px; + .hidden-table { + position: absolute; + z-index: -1; + opacity: 0; + } + .tabform { + padding: 25px 25px 120px; + .operation { + text-align: center; + margin: 20px 0; + .ant-btn { + height: 40px; + padding: 0 30px; + font-size: 16px; + } + .ant-btn-primary { + margin-right: 40px; + } + } + } } .ant-back-top { bottom: 30px; diff --git a/src/tabviews/datamanage/modules/action/index.jsx b/src/tabviews/datamanage/modules/action/index.jsx index 84b092d..83dfd8f 100644 --- a/src/tabviews/datamanage/modules/action/index.jsx +++ b/src/tabviews/datamanage/modules/action/index.jsx @@ -157,9 +157,8 @@ top: 92, message: _this.props.dict['main.action.confirm.success'] }) - if (item.ReloadForm && item.ReloadForm !== 'false' && item.ReloadForm !== 'singlegrid') { - _this.props.refreshdata(item.ReloadForm) - } + + _this.props.refreshdata(item.ReloadForm) // 鍒锋柊椤甸潰 } } else { if (res.status) { @@ -167,9 +166,8 @@ top: 92, message: _this.props.dict['main.action.confirm.success'] }) - if (item.ReloadForm && item.ReloadForm !== 'false' && item.ReloadForm !== 'singlegrid') { - _this.props.refreshdata(item.ReloadForm) - } + + _this.props.refreshdata(item.ReloadForm) // 鍒锋柊椤甸潰 } else { notification.error({ top: 92, @@ -202,9 +200,8 @@ top: 92, message: this.props.dict['main.action.confirm.success'] }) - if (item.ReloadForm && item.ReloadForm !== 'false' && item.ReloadForm !== 'singlegrid') { - this.props.refreshdata(item.ReloadForm) - } + + this.props.refreshdata(item.ReloadForm) // 鍒锋柊椤甸潰 } } else { if (res.status) { @@ -212,9 +209,8 @@ top: 92, message: this.props.dict['main.action.confirm.success'] }) - if (item.ReloadForm && item.ReloadForm !== 'false' && item.ReloadForm !== 'singlegrid') { - this.props.refreshdata(item.ReloadForm) - } + + this.props.refreshdata(item.ReloadForm) // 鍒锋柊椤甸潰 } else { notification.error({ top: 92, @@ -227,7 +223,7 @@ } else if (item.OpenType === 'newpage') { // 鎵撳紑鏂伴〉闈� let src = '#/' + item.LinkUrl + '?param=' + window.btoa(JSON.stringify({UserId: sessionStorage.getItem('UserID'), ID: datalist[0][ID[0]], BID: BID.length === 1 ? datalist[0][BID[0]] : ''})) window.open(src) - } else if (item.OpenType === 'pop') { + } else if (item.OpenType === 'pop') { // 妯℃�佹 this.setState({ formdata: this.props.columns.map(column => { column.readonly = false @@ -242,7 +238,7 @@ bidkey: BID.length === 1 ? BID[0] : '', tabledata: datalist[0] || '' }) - } else if (item.OpenType === 'tab') { + } else if (item.OpenType === 'tab') { // 鎵撳紑鏂版爣绛鹃〉 let menu = { MenuNo: this.props.MenuNo, MenuID: item.MenuID, @@ -284,8 +280,21 @@ tabs.splice(_index + 1, 0, menu) } this.props.modifyTabview(tabs) - } else if (item.OpenType === 'blank') { - this.props.switchview(item) + } else if (item.OpenType === 'blank') { // 褰撳墠椤甸潰璺宠浆 + this.props.switchformview({ + formdata: this.props.columns.map(column => { + column.readonly = false + if (column.ReadOnly.includes(item.MenuID)) { + column.readonly = true + } + return column + }), + execAction: item, + primarykey: ID[0], + bidkey: BID.length === 1 ? BID[0] : '', + tabledata: datalist[0] || '', + defaultproc: this.state.defaultproc + }) } else { notification.warning({ top: 92, @@ -295,19 +304,8 @@ } } - changemenu(e) { - let menu = {} - let tabs = JSON.parse(JSON.stringify(this.props.tabviews)) - tabs = tabs.filter(tab => { - tab.selected = false - return tab.MenuID !== menu.MenuID - }) - menu.selected = true - tabs.push(menu) - this.props.modifyTabview(tabs) - } - getModels = () => { + // 鑾峰彇寮圭獥琛ㄥ崟淇℃伅 if (!this.state.execAction) return let cols = +this.state.execAction.FormLineQty if (![1, 2, 3].includes(cols)) { @@ -341,23 +339,31 @@ confirmLoading: true }) let values = [] + // 浠庤〃鍗曚腑鑾峰彇濉啓鏁版嵁 this.props.columns.forEach(column => { let value = '' - if (res[column.FieldName] || res[column.FieldName] === 0) { // 渚濇閫夊彇琛ㄥ崟鍊笺�佽〃鏍兼暟鎹�笺�佸垵濮嬪�� + if (res.hasOwnProperty(column.FieldName)) { // 渚濇閫夊彇琛ㄥ崟鍊笺�佸垵濮嬪�� value = res[column.FieldName] - } else if (this.state.tabledata && this.state.tabledata[column.FieldName]) { - value = this.state.tabledata[column.FieldName] } else if (column.InitVal) { value = column.InitVal } values.push(value) }) - Api.submitInterface({ + + let queryparam = { // 璇锋眰鍙傛暟 func: this.state.execAction.AuditProc || this.state.defaultproc[this.state.execAction.Action], - AddLongText: values.join(','), // 琛ㄥ崟鏁版嵁 ID: (this.state.tabledata && this.state.primarykey) ? this.state.tabledata[this.state.primarykey] : '', // 涓婚敭瀛楁 BID: (this.state.tabledata && this.state.bidkey) ? this.state.tabledata[this.state.bidkey] : '' // BID瀛楁 - }).then(result => { + } + // 娣诲姞鍜屼慨鏀硅姹傚弬鏁板瓧娈典笉鍚� + if (this.state.execAction.Action === 'Add') { + queryparam.AddLongText = values.join(',') + } else if (this.state.execAction.Action === 'Update') { + queryparam.UptLongText = values.join(',') + } + + // 鎻愪氦璇锋眰 + Api.submitInterface(queryparam).then(result => { if (result.status) { notification.success({ top: 92, @@ -367,9 +373,8 @@ confirmLoading: false, visible: false }) - if (this.state.execAction.ReloadForm && this.state.execAction.ReloadForm !== 'false' && this.state.execAction.ReloadForm !== 'singlegrid') { - this.props.refreshdata(this.state.execAction.ReloadForm) - } + + this.props.refreshdata(this.state.execAction.ReloadForm) // 鍒锋柊椤甸潰 } else { this.setState({ confirmLoading: false @@ -385,15 +390,12 @@ } handleCancel = () => { + // 鍙栨秷 this.setState({ confirmLoading: false, visible: false }) this.formRef.handleReset() - } - - UNSAFE_componentWillMount () { - } render() { diff --git a/src/tabviews/tabform/index.jsx b/src/tabviews/tabform/index.jsx index 48fefca..17767f1 100644 --- a/src/tabviews/tabform/index.jsx +++ b/src/tabviews/tabform/index.jsx @@ -20,28 +20,35 @@ } handleOk = () => { - this.setState({ - loading: true - }) + this.formRef.handleConfirm().then(res => { + this.setState({ + loading: true + }) let values = [] this.props.param.formdata.forEach(column => { let value = '' - if (res[column.FieldName] || res[column.FieldName] === 0) { // 渚濇閫夊彇琛ㄥ崟鍊笺�佽〃鏍兼暟鎹�笺�佸垵濮嬪�� + if (res.hasOwnProperty(column.FieldName)) { // 渚濇閫夊彇琛ㄥ崟鍊笺�佸垵濮嬪�� value = res[column.FieldName] - } else if (this.state.tabledata && this.state.tabledata[column.FieldName]) { - value = this.state.tabledata[column.FieldName] } else if (column.InitVal) { value = column.InitVal } values.push(column.FieldName + 'equal\'' + value + '\'') }) - Api.submitInterface({ + + let queryparam = { // 璇锋眰鍙傛暟 func: this.props.param.execAction.AuditProc || this.props.param.defaultproc[this.props.param.execAction.Action], - UptLongText: values.join(','), // 琛ㄥ崟鏁版嵁 ID: (this.props.param.tabledata && this.props.param.primarykey) ? this.props.param.tabledata[this.props.param.primarykey] : '', // 涓婚敭瀛楁 BID: (this.props.param.tabledata && this.props.param.bidkey) ? this.props.param.tabledata[this.props.param.bidkey] : '' // BID瀛楁 - }).then(result => { + } + // 娣诲姞鍜屼慨鏀硅姹傚弬鏁板瓧娈典笉鍚� + if (this.props.param.execAction.Action === 'Add') { + queryparam.AddLongText = values.join(',') + } else if (this.props.param.execAction.Action === 'Update') { + queryparam.UptLongText = values.join(',') + } + + Api.submitInterface(queryparam).then(result => { if (result.status) { notification.success({ top: 92, @@ -49,24 +56,24 @@ }) // 鍒锋柊涓诲垪琛ㄩ〉闈� - if (this.props.param.execAction.ReloadForm && this.props.param.execAction.ReloadForm !== 'false' && this.props.param.execAction.ReloadForm !== 'singlegrid') { - this.props.refreshTabView({ - MenuNo: this.props.MenuNo, - ReloadForm: this.props.param.execAction.ReloadForm - }) - } + this.props.refreshTabView({ + MenuNo: this.props.MenuNo, + ReloadForm: this.props.param.execAction.ReloadForm + }) - this.handleCancel() + if (this.props.param.execAction.BackPre !== 'false') { // 椤甸潰杩斿洖 + this.handleCancel() + } } else { notification.error({ top: 92, message: result.message, duration: 15 }) + this.setState({ + loading: false + }) } - this.setState({ - loading: false - }) }) }, () => {}) } @@ -83,6 +90,9 @@ return tab.MenuID !== this.props.MenuID }) this.props.modifyTabview(tabs) + // 鎻愪氦鎴愬姛鎴栬繑鍥炴椂锛屾粴鍔ㄨ嚦椤堕儴 + document.body.scrollTop = 0 + document.documentElement.scrollTop = 0 } shouldComponentUpdate (nextProps, nextState) { diff --git a/src/views/login/index.scss b/src/views/login/index.scss index c9fcb08..62a58f7 100644 --- a/src/views/login/index.scss +++ b/src/views/login/index.scss @@ -13,7 +13,7 @@ .login-middle { height: calc(100vh - 194px); min-height: 420px; - background: url('../../assets/img/loginbg.png'); + background: url('../../assets/img/loginbg.jpg'); background-size: cover; background-position: center center; border-bottom: 2px solid #06b4f7; -- Gitblit v1.8.0