From a70940450c021a47e69abdf8fa8f7f98594601cc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 13 十二月 2019 17:36:54 +0800 Subject: [PATCH] 2019-12-13 --- src/tabviews/commontable/index.jsx | 114 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 64 insertions(+), 50 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 082ad93..893367c 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -16,14 +16,15 @@ export default class NormalTable extends Component { static propTpyes = { - MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 - MenuID: PropTypes.string // 鑿滃崟Id + MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 + MenuID: PropTypes.string // 鑿滃崟Id } state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - loadingview: true, - viewlost: false, + loadingview: true, // 椤甸潰鍔犺浇涓� + viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 + lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: {}, searchlist: null, actions: null, @@ -41,39 +42,51 @@ configMap: {} } + /** + * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 + */ async loadconfig () { - // 鑾峰彇涓昏彍鍗� let param = { func: 'sPC_Get_LongParam', MenuID: this.props.MenuID } let result = await Api.getSystemCacheConfig(param) if (result.status && result.LongParam) { - let config = window.decodeURIComponent(window.atob(result.LongParam)) + let config = '' - try { + try { // 閰嶇疆淇℃伅瑙f瀽 + config = window.decodeURIComponent(window.atob(result.LongParam)) config = JSON.parse(config) - this.setState({ - loadingview: false - }) } catch (e) { - this.setState({ - loadingview: false, - viewlost: true - }) + config = '' + } + + // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� + if (!config) { notification.warning({ top: 92, message: this.state.dict['main.page.settingerror'], duration: 10 }) + return } - let _search = Utils.mainjointsearchkey(config.search) - let _arrField = [] - let _columns = [] - let _hideCol = [] + // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰 + if (!config.enabled) { + this.setState({ + loadingview: false, + viewlost: true, + lostmsg: this.state.dict['main.view.unenabled'] + }) + return + } + + let _arrField = [] // 瀛楁闆� + let _columns = [] // 鏄剧ず鍒� + let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� let colMap = new Map() + // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid config.columns.forEach(col => { if (col.field) { _arrField.push(col.field) @@ -86,8 +99,10 @@ colMap.set(col.uuid, col) }) + // 鐢熸垚鏄剧ず鍒楋紝澶勭悊鍚堝苟鍒椾腑鐨勫瓧娈� config.columns.forEach(col => { if (_hideCol.includes(col.uuid)) return + if (col.type === 'colspan' && col.sublist) { let _col = JSON.parse(JSON.stringify(col)) let subColumn = [] @@ -103,31 +118,26 @@ } }) - let _actions = config.action.filter(item => item.position === 'toolbar') - // let _operation = config.action.filter(item => item.position === 'grid') + // 娣诲姞鎿嶄綔鍒楋紙瀛樺湪鏃讹級锛堟湭缁忚繃鏉冮檺杩囨护锛� + if (config.gridBtn && config.gridBtn.display) { + _columns.push({ + ...config.gridBtn, + operations: config.action.filter(item => item.position === 'grid') + }) + } - // if (_operation.length > 0) { - // _columns.push({ - // Align: 'center', - // uuid: Utils.getuuid(), - // IsSort: 'false', - // Width: 120, - // type: 'action', - // style: 'button', - // label: this.state.dict['main.column.operation'], - // operations: _operation - // }) - // } + // 杩囨护宸ュ叿鏍忔寜閽紙鏈粡杩囨潈闄愯繃婊わ級 + let _actions = config.action.filter(item => item.position === 'toolbar') this.setState({ + loadingview: false, config: config, setting: config.setting, searchlist: config.search, actions: _actions, columns: _columns, arr_field: _arrField.join(','), - search: _search ? 'where (' + _search + ')' : '', - // orderColumn: config.setting.orderColumn, + search: Utils.initMainSearch(config.search), // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 loading: true }, () => { this.improveSearch() @@ -255,7 +265,9 @@ async loadmaindata () { const { arr_field, pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state - console.log(setting) + + let _search = Utils.joinMainSearchkey(search) + _search = _search ? 'where (' + _search + ')' : '' // 鑾峰彇鍒楄〃鏁版嵁 let param = { func: setting.innerFunc || 'sPC_Get_TableData', @@ -265,8 +277,8 @@ let orderBy = orderColumn ? (orderColumn + ' ' + orderType) : setting.order - let LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${setting.dataresource} ${search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` - let DateCount = `select count(1) as total from ${setting.dataresource} ${search}` + let LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${setting.dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` + let DateCount = `select count(1) as total from ${setting.dataresource} ${_search}` console.log(LText) param.LText = Utils.formatOptions(LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' @@ -284,17 +296,20 @@ loading: false }) } else { + // this.setState({ + // data: [1,2,3,4,5,6,7,8,9,10].map((item, index) => { + // let cell = {} + // this.state.config.columns.forEach(column => { + // if (!column.field) return + // cell[column.field] = 'test' + item + // }) + // cell.key = index + // return cell + // }), + // total: 329, + // loading: false + // }) this.setState({ - data: [1,2,3,4,5,6,7,8,9,10].map((item, index) => { - let cell = {} - this.state.config.columns.forEach(column => { - if (!column.field) return - cell[column.field] = 'test' + item - }) - cell.key = index - return cell - }), - total: 329, loading: false }) notification.error({ @@ -307,12 +322,11 @@ refreshbysearch = (searches) => { // 鎼滅储鏉′欢鍙樺寲 - let search = Utils.mainjointsearchkey(searches) this.refs.mainTable.resetTable() this.setState({ loading: true, - search: search ? 'where (' + search + ')' : '' + search: searches }, () => { this.loadmaindata() }) @@ -412,7 +426,7 @@ </div> </div> </BackTop> - {viewlost ? <NotFount /> : null} + {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) } -- Gitblit v1.8.0