From 213c70792e6af7f9ccef17d778c5f8806fbd513c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 28 十一月 2019 15:01:24 +0800 Subject: [PATCH] 2019-11-28-01 --- src/templates/comtableconfig/index.scss | 2 src/components/header/index.jsx | 12 + src/tabviews/commontable/mainTable/index.scss | 6 src/components/sidemenu/index.jsx | 16 + src/tabviews/commontable/index.jsx | 109 +++++++++++- src/tabviews/commontable/mainAction/index.jsx | 139 ++++++++-------- src/tabviews/commontable/mainTable/index.jsx | 43 +++- src/templates/comtableconfig/index.jsx | 14 + src/templates/comtableconfig/dragelement/card.jsx | 1 src/utils/utils.js | 130 +++++++++++++--- src/tabviews/datamanage/modules/table/index.jsx | 1 11 files changed, 343 insertions(+), 130 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 40897f4..7b9749c 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -180,6 +180,14 @@ } } + async getRolesMenu () { + // 鑾峰彇涓昏彍鍗� + let result = await Api.getSystemConfig({func: 'sPC_Get_RolesMenu'}) + if (result.status) { + // console.log(result.Roles) + } + } + reload = () => { this.setState({ menulist: null @@ -215,6 +223,10 @@ return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } + componentDidMount () { + this.getRolesMenu() + } + render () { const menu = ( <Menu overlayclassname="header-dropdown"> diff --git a/src/components/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index dbd3a56..43397f7 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -74,17 +74,23 @@ } else if (child.LinkUrl.split('?')[0] === 'Main/Index' || child.LinkUrl.split('?')[0] === 'bda/rdt') { _tmenu.type = 'iframe' } - try { - _tmenu.PageParam = JSON.parse(child.PageParam) - } catch (e) { - _tmenu.PageParam = {} + + if (_tmenu.type !== 'iframe') { + try { + _tmenu.PageParam = JSON.parse(child.PageParam) + } catch (e) { + _tmenu.PageParam = {} + } + _tmenu.type = _tmenu.PageParam.Template || _tmenu.type + } else { + _tmenu.LinkUrl = child.LinkUrl } + _tmenu.id = n _tmenu.MenuID = child.MenuID _tmenu.MenuNo = child.MenuNo _tmenu.MenuName = child.MenuName _tmenu.text = child.MenuName - _tmenu.type = _tmenu.PageParam.Template || _tmenu.type return _tmenu }) } diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index c685004..194afb2 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -10,7 +10,7 @@ import Loading from '@/components/loading' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' -// import Utils from '@/utils/utils.js' +import Utils from '@/utils/utils.js' import './index.scss' export default class NormalTable extends Component { @@ -27,7 +27,7 @@ searchlist: null, actions: null, columns: null, - select: null, + setting: null, data: null, total: 0, loading: false, @@ -67,8 +67,15 @@ duration: 10 }) } - this.setState({config}) - console.log(config.columns) + this.setState({ + config: config, + setting: config.setting, + searchlist: config.search, + actions: config.action, + columns: config.columns + }, () => { + this.improveSearch() + }) } else { this.setState({ loadingview: false, @@ -80,6 +87,77 @@ duration: 10 }) } + } + + improveSearch = () => { + let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) + let deffers = [] + searchlist.forEach(item => { + if (item.type !== 'select' && item.type !== 'link') return + + let unloaded = item.options.length === 0 + + if (item.setAll === 'true') { + item.options.unshift({ + key: Utils.getuuid(), + Value: '', + Text: '鍏ㄩ儴' + }) + } + + if (item.resourceType === '1' && item.dataSource && unloaded) { + let param = { + func: 'sPC_Get_SelectedList', + // LText: item.dataSourceSql, + LText: 'msltk * mfrmk sOrganization', + obj_name: 'data', + arr_field: item.valueField + ',' + item.valueText + } + let defer = new Promise(resolve => { + Api.getSystemConfig(param).then(res => { + res.search = item + resolve(res) + }) + }) + deffers.push(defer) + } else if (item.resourceType === '1' && !item.dataSource) { + notification.warning({ + top: 92, + message: item.label + '鏁版嵁婧愰厤缃敊璇�', + duration: 10 + }) + } + }) + + this.setState({searchlist: JSON.parse(JSON.stringify(searchlist))}) + + if (deffers.length === 0) return + + Promise.all(deffers).then(result => { + result.forEach(res => { + if (res.status) { + searchlist = searchlist.map(item => { + if (item.uuid === res.search.uuid) { + res.data.forEach(cell => { + item.options.push({ + key: Utils.getuuid(), + Value: cell[res.search.valueField], + Text: cell[res.search.valueText] + }) + }) + } + return item + }) + } else { + notification.warning({ + top: 92, + message: res.search.label + ':' + res.message, + duration: 10 + }) + } + }) + this.setState({searchlist}) + }) } async loadmaindata (pageIndex = 1, pageSize = 10, orderColumn = '', orderType = '', search = '') { @@ -150,6 +228,7 @@ // 鑾峰彇琛ㄦ牸閫夋嫨椤� let data = [] this.refs.mainTable.state.selectedRowKeys.forEach(item => { + console.log(item) data.push(this.refs.mainTable.props.data[item]) }) return data @@ -166,8 +245,8 @@ key: item, ID: item + 'mainkey', ExRateName: '$', - SupplierName: '闃块噷宸村反' + item + '搴�', - SupShortName: '闃块噷宸村反', + SupplierName: '澶╃尗' + item + '搴�', + SupShortName: '澶╃尗', SupplierCode: '201922' + item, OrgName: '闃块噷宸村反', OrgCode: '302999', @@ -183,35 +262,35 @@ } render() { - const { config, loadingview, viewlost } = this.state + const { setting, searchlist, actions, columns, loadingview, viewlost } = this.state return ( <div className="commontable"> {loadingview && <Loading />} - {config.search && config.search.length > 0 ? + {searchlist && searchlist.length > 0 ? <MainSearch refreshdata={this.refreshbysearch} - searchlist={config.search} + searchlist={searchlist} dict={this.state.dict} /> : null } - {config.action && + {actions && <MainAction MenuID={this.props.MenuID} - fixed={config.setting && config.setting.actionfixed} + fixed={setting && setting.actionfixed} refreshdata={this.refreshbyaction} gettableselected={this.gettableselected} - actions={config.action} + actions={actions} dict={this.state.dict} /> } - {config.columns && + {columns && <MainTable ref="mainTable" MenuID={this.props.MenuID} - setting={config.setting} + setting={setting} refreshdata={this.refreshbytable} - columns={config.columns} + columns={columns} data={this.state.data} total={this.state.total} loading={this.state.loading} diff --git a/src/tabviews/commontable/mainAction/index.jsx b/src/tabviews/commontable/mainAction/index.jsx index 5ba5f08..97f3764 100644 --- a/src/tabviews/commontable/mainAction/index.jsx +++ b/src/tabviews/commontable/mainAction/index.jsx @@ -6,7 +6,7 @@ import Api from '@/api' import './index.scss' -const { confirm } = Modal +// const { confirm } = Modal class MainAction extends Component { static propTpyes = { @@ -28,76 +28,77 @@ this.props.refreshdata() } actionTrigger = (item) => { - let _this = this + // let _this = this let data = this.props.gettableselected() || [] - if (item.Ot === 'required' && data.length === 0) { - // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� - notification.warning({ - top: 92, - message: this.props.dict['main.action.confirm.selectline'] - }) - return - } else if (item.Ot === 'pop' && data.length !== 1) { - if (data.length === 0) { - // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� - notification.warning({ - top: 92, - message: this.props.dict['main.action.confirm.selectline'] - }) - return - } else { - // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 - notification.warning({ - top: 92, - message: this.props.dict['main.action.confirm.selectSingleLine'] - }) - return - } - } + console.log(data) + // if (item.Ot === 'required' && data.length === 0) { + // // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� + // notification.warning({ + // top: 92, + // message: this.props.dict['main.action.confirm.selectline'] + // }) + // return + // } else if (item.Ot === 'pop' && data.length !== 1) { + // if (data.length === 0) { + // // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� + // notification.warning({ + // top: 92, + // message: this.props.dict['main.action.confirm.selectline'] + // }) + // return + // } else { + // // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 + // notification.warning({ + // top: 92, + // message: this.props.dict['main.action.confirm.selectSingleLine'] + // }) + // return + // } + // } - if (item.Action === 'Prompt' || item.Action === 'Delete') { - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - return Api.setActionSubmit({ - func: 'SetActionSubmitSuccess' - // func: 'SetActionSubmitError' - }).then((res) => { - if (res.status) { - notification.success({ - top: 92, - message: _this.props.dict['main.action.confirm.success'] - // duration: 0 - // description: - }) - _this.refreshdata() - } else { - notification.error({ - top: 92, - message: res.message - }) - } - }) - }, - onCancel() {} - }) - } else if (item.Action === 'Update') { - Api.getModelFormData(item.MenuID).then(res => { - if (res.status) { - this.setState({ - formdata: res.data.map(input => { - let validate = input.Validate && JSON.parse(input.Validate) - input.DynOptions = JSON.parse(input.DynOptions) - input.required = (validate && validate.required) || false - return input - }), - visible: true, - execAction: item, - tabledata: data[0] - }) - } - }) - } + // if (item.Action === 'Prompt' || item.Action === 'Delete') { + // confirm({ + // title: this.props.dict['main.action.confirm.tip'], + // onOk() { + // return Api.setActionSubmit({ + // func: 'SetActionSubmitSuccess' + // // func: 'SetActionSubmitError' + // }).then((res) => { + // if (res.status) { + // notification.success({ + // top: 92, + // message: _this.props.dict['main.action.confirm.success'] + // // duration: 0 + // // description: + // }) + // _this.refreshdata() + // } else { + // notification.error({ + // top: 92, + // message: res.message + // }) + // } + // }) + // }, + // onCancel() {} + // }) + // } else if (item.Action === 'Update') { + // Api.getModelFormData(item.MenuID).then(res => { + // if (res.status) { + // this.setState({ + // formdata: res.data.map(input => { + // let validate = input.Validate && JSON.parse(input.Validate) + // input.DynOptions = JSON.parse(input.DynOptions) + // input.required = (validate && validate.required) || false + // return input + // }), + // visible: true, + // execAction: item, + // tabledata: data[0] + // }) + // } + // }) + // } } getModels = () => { diff --git a/src/tabviews/commontable/mainTable/index.jsx b/src/tabviews/commontable/mainTable/index.jsx index 30f6f7f..6dfe35e 100644 --- a/src/tabviews/commontable/mainTable/index.jsx +++ b/src/tabviews/commontable/mainTable/index.jsx @@ -23,22 +23,39 @@ selectedRowKeys: [], pageIndex: 1, pageSize: 10, - columns: this.props.columns.map((item, index) => { - return { + columns: null + } + + UNSAFE_componentWillMount () { + const { columns } = this.props + let _columns = [] + columns.forEach((item, index) => { + // console.log(item) + if (item.Hide === 'true') return + + let cell = { align: item.Align, - dataIndex: item.field, + dataIndex: item.uuid, title: item.label, - // fixed: index < 3, sorter: item.IsSort === 'true', width: item.Width || 120, - render: (text, record) => ( - <div style={{ wordWrap: 'break-word', wordBreak: 'break-word', minWidth: (item.Width || 120) + 'px' }}> - {text} - {/* {item.FieldName === 'MenuNo' ? <Icon onClick={(e) => {this.copycontent(e, record[item.FieldName])}} type="copy"/> : ''} */} - </div> - ) + render: (text, record) => { + let content = '' + if (item.field) { + content = record[item.field] || '' + } + return ( + <div className="content" style={{ minWidth: (item.Width || 120) + 'px' }}> + {content} + </div> + ) + } } + _columns.push(cell) }) + // {item.FieldName === 'MenuNo' ? <Icon onClick={(e) => {this.copycontent(e, record[item.FieldName])}} type="copy"/> : ''} + + this.setState({columns: _columns}) } copycontent = (e, content) => { @@ -60,12 +77,14 @@ changeRow = (record, index) => { // 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹紝鍒ゆ柇鏄惁鍙�夛紝鍗曢�夋垨澶氶�夛紝杩涜瀵瑰簲鎿嶄綔 - if (!this.props.select || !this.props.select.selectable) return + console.log(index) + if (!this.props.setting.tableType) return let newkeys = JSON.parse(JSON.stringify(this.state.selectedRowKeys)) + console.log(newkeys) let _re = newkeys.includes(index) - if (this.props.select.selectType === 'radio') { + if (this.props.setting.tableType === 'radio') { this.setState({ selectedRowKeys: [index] }) } else { if (_re) { diff --git a/src/tabviews/commontable/mainTable/index.scss b/src/tabviews/commontable/mainTable/index.scss index 12469f9..d71f1fc 100644 --- a/src/tabviews/commontable/mainTable/index.scss +++ b/src/tabviews/commontable/mainTable/index.scss @@ -30,6 +30,12 @@ .ant-table-tbody > tr > td:last-child { border-right: 0; } + .ant-table-tbody > tr > td.ant-table-column-has-actions { + .content { + word-wrap: break-word; + word-break: break-word; + } + } } } .ant-table-body::-webkit-scrollbar { diff --git a/src/tabviews/datamanage/modules/table/index.jsx b/src/tabviews/datamanage/modules/table/index.jsx index 9339e95..ff79406 100644 --- a/src/tabviews/datamanage/modules/table/index.jsx +++ b/src/tabviews/datamanage/modules/table/index.jsx @@ -33,6 +33,7 @@ align: item.Align, dataIndex: item.FieldName, title: item.Label, + // fixed: index < 3, sorter: item.IsSort === 'true', width: _width, render: (text) => ( diff --git a/src/templates/comtableconfig/dragelement/card.jsx b/src/templates/comtableconfig/dragelement/card.jsx index 4f36985..608e86b 100644 --- a/src/templates/comtableconfig/dragelement/card.jsx +++ b/src/templates/comtableconfig/dragelement/card.jsx @@ -80,6 +80,7 @@ } {card.type === 'daterange' ? <RangePicker + className="data-range" placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']} renderExtraFooter={() => 'extra footer'} defaultValue={card.initval ? [moment().subtract(card.initval, 'days'), moment().subtract(card.initval === 1 ? 1 : 0, 'days')] : [null, null]} diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index aa3fd6a..5774698 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -137,7 +137,8 @@ * 2銆佹牴鎹厤缃俊鎭腑宸蹭娇鐢ㄨ〃鑾峰彇鐩稿叧瀛楁淇℃伅 */ componentDidMount () { - let _text = "select TbName ,Remark from sDataDictionary where IsKey!='' and Deleted =0" + let _text = "select TbName ,Remark from sDataDictionary where IsKey!='' and Deleted =0 and Remark != '鍏徃'" + // let _text = "select TbName ,Remark from sDataDictionary where IsKey!='' and Deleted =0" _text = Utils.formatOptions(_text) Api.getSystemConfig({func: 'sPC_Get_SelectedList', LText: _text, obj_name: 'data', arr_field: 'TbName,Remark'}).then(res => { @@ -716,6 +717,16 @@ this.formRef.handleConfirm().then(res => { let _config = this.state.config + if (res.type === 'search') { + if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { + let sql = 'select ' + res.values.valueField + ',' + res.values.valueText + ' from (' + res.values.dataSource + ')' + if (res.values.orderBy) { + sql = sql + ' ld order by ' + res.values.orderBy + ' ' + res.values.orderType + } + res.values.dataSourceSql = Utils.formatOptions(sql) + } + } + if (this.state.operaType === 'add') { _config[res.type] = _config[res.type].map(item => { if (item.uuid === res.values.uuid) { @@ -733,7 +744,6 @@ return item } }) - // _config[res.type] = _config[res.type].filter(item => !item.origin) } this.setState({ diff --git a/src/templates/comtableconfig/index.scss b/src/templates/comtableconfig/index.scss index a9e872c..944465b 100644 --- a/src/templates/comtableconfig/index.scss +++ b/src/templates/comtableconfig/index.scss @@ -183,7 +183,7 @@ opacity: 0; z-index: 2; } - .ant-calendar-picker-input { + .data-range .ant-calendar-picker-input { padding: 4px 20px 4px 5px; font-size: 13px; } diff --git a/src/utils/utils.js b/src/utils/utils.js index d570d6c..1717dc4 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -30,54 +30,132 @@ } /** - * @description 鏍煎紡鍖栨悳绱㈡潯浠� + * @description sql鍔犲瘑 * @return {String} value */ static formatOptions (value) { // 浜х敓涓�涓柊鐨凣UID鍊� let format = [{ key: 'select', - value: 'msltk' + value: ' msltk ' }, { key: 'from', - value: 'mfrmk' + value: ' mfrmk ' }, { key: 'where', - value: 'mwhrk' + value: ' mwhrk ' }, { key: 'order by', - value: 'modbk' + value: ' modbk ' }, { key: 'asc', - value: 'modack' + value: ' modack ' }, { key: 'desc', - value: 'moddesk' - }, { - key: '%', - value: 'mpercent' - }, { - key: '>', - value: 'greateror' - }, { - key: '<', - value: 'lessor' - }, { - key: '=', - value: 'equal' + value: ' moddesk ' }, { key: 'top', - value: 'mtpk' + value: ' mtpk ' + }, { + key: 'like', + value: ' mlkk ' + }, { + key: 'not like', + value: ' mnlkk ' + }, { + key: 'between', + value: ' mbtnk ' + }, { + key: 'and', + value: ' madk ' + }, { + key: 'insert', + value: ' mistk ' + }, { + key: 'into', + value: ' mitk ' + }, { + key: 'update', + value: ' muptk ' + }, { + key: 'delete', + value: ' mdelk ' + }, { + key: 'begin', + value: ' mbgink ' + }, { + key: 'end', + value: ' medk ' + }, { + key: 'if', + value: ' mefk ' + }, { + key: 'while', + value: ' mwilk ' + }, { + key: 'create', + value: ' mcrtk ' + }, { + key: 'alter', + value: ' matek ' + }, { + key: 'len', + value: ' mlnk ' + }, { + key: 'left', + value: ' mlftk ' + }, { + key: 'right', + value: ' mritk ' + }, { + key: 'union', + value: ' munok ' + }, { + key: 'varchar', + value: ' mvcrk ' + }, { + key: 'getdate', + value: ' mgtdtk ' + }, { + key: 'TRY', + value: ' mtryonek ' + }, { + key: 'TRAN', + value: ' mtrnk ' + }, { + key: 'goto', + value: ' mgtk ' + }, { + key: 'set', + value: ' mstk ' + }, { + key: 'ROLLBACK', + value: ' mrlbkk ' }] - format.forEach(item => { - let reg = new RegExp(item.key, 'ig') + let reg = new RegExp('(^|\\s)' + item.key + '(\\s|$)', 'ig') value = value.replace(reg, item.value) }) - - value = value.replace(/\*/ig, 'mastrsk') - value = value.replace(/'/ig, 'mqotek') - value = value.replace(/\s/ig, 'mspace') + value = value.replace(/(^\s|\s$)/ig, '') + value = window.btoa(window.encodeURIComponent(value)) + // let index = Math.floor(Math.random() * value.length) + // value = value.slice(0, index) + 'minKe' + value.slice(index) + value = 'minKe' + value + value = window.btoa(value) + // value = value.replace(/%/ig, 'mpercent') + // .replace(/>/ig, 'greateror') + // .replace(/</ig, 'lessor') + // .replace(/!=/ig, 'noequal') + // .replace(/=/ig, 'equal') + // .replace(/,/ig, 'comma') + // .replace(/>=/ig, 'greaterorequal') + // .replace(/<=/ig, 'lessorequal') + // .replace(/@/ig, 'matk') + // .replace(/\(/ig, 'mlbrktsk') + // .replace(/\)/ig, 'mrbrktsk') + // .replace(/\*/ig, 'mastrsk') + // .replace(/'/ig, 'mqotek') + // .replace(/\s/ig, 'mspace') return value } -- Gitblit v1.8.0