| | |
| | | } |
| | | } |
| | | |
| | | async getRolesMenu () { |
| | | // 获取主菜单 |
| | | let result = await Api.getSystemConfig({func: 'sPC_Get_RolesMenu'}) |
| | | if (result.status) { |
| | | // console.log(result.Roles) |
| | | } |
| | | } |
| | | |
| | | reload = () => { |
| | | this.setState({ |
| | | menulist: null |
| | |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.getRolesMenu() |
| | | } |
| | | |
| | | render () { |
| | | const menu = ( |
| | | <Menu overlayclassname="header-dropdown"> |
| | |
| | | } else if (child.LinkUrl.split('?')[0] === 'Main/Index' || child.LinkUrl.split('?')[0] === 'bda/rdt') { |
| | | _tmenu.type = 'iframe' |
| | | } |
| | | |
| | | 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 |
| | | }) |
| | | } |
| | |
| | | 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 { |
| | |
| | | searchlist: null, |
| | | actions: null, |
| | | columns: null, |
| | | select: null, |
| | | setting: null, |
| | | data: null, |
| | | total: 0, |
| | | loading: false, |
| | |
| | | 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, |
| | |
| | | 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 = '') { |
| | |
| | | // 获取表格选择项 |
| | | let data = [] |
| | | this.refs.mainTable.state.selectedRowKeys.forEach(item => { |
| | | console.log(item) |
| | | data.push(this.refs.mainTable.props.data[item]) |
| | | }) |
| | | return data |
| | |
| | | key: item, |
| | | ID: item + 'mainkey', |
| | | ExRateName: '$', |
| | | SupplierName: '阿里巴巴' + item + '店', |
| | | SupShortName: '阿里巴巴', |
| | | SupplierName: '天猫' + item + '店', |
| | | SupShortName: '天猫', |
| | | SupplierCode: '201922' + item, |
| | | OrgName: '阿里巴巴', |
| | | OrgCode: '302999', |
| | |
| | | } |
| | | |
| | | 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} |
| | |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | | // const { confirm } = Modal |
| | | |
| | | class MainAction extends Component { |
| | | static propTpyes = { |
| | |
| | | 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 = () => { |
| | |
| | | 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"/> : ''} */} |
| | | 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) => { |
| | |
| | | |
| | | 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) { |
| | |
| | | .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 { |
| | |
| | | align: item.Align, |
| | | dataIndex: item.FieldName, |
| | | title: item.Label, |
| | | // fixed: index < 3, |
| | | sorter: item.IsSort === 'true', |
| | | width: _width, |
| | | render: (text) => ( |
| | |
| | | } |
| | | {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]} |
| | |
| | | * 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 => { |
| | |
| | | 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) { |
| | |
| | | return item |
| | | } |
| | | }) |
| | | // _config[res.type] = _config[res.type].filter(item => !item.origin) |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | opacity: 0; |
| | | z-index: 2; |
| | | } |
| | | .ant-calendar-picker-input { |
| | | .data-range .ant-calendar-picker-input { |
| | | padding: 4px 20px 4px 5px; |
| | | font-size: 13px; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 格式化搜索条件 |
| | | * @description sql加密 |
| | | * @return {String} value |
| | | */ |
| | | static formatOptions (value) { |
| | |
| | | key: 'desc', |
| | | value: 'moddesk' |
| | | }, { |
| | | key: '%', |
| | | value: 'mpercent' |
| | | }, { |
| | | key: '>', |
| | | value: 'greateror' |
| | | }, { |
| | | key: '<', |
| | | value: 'lessor' |
| | | }, { |
| | | key: '=', |
| | | value: 'equal' |
| | | }, { |
| | | key: 'top', |
| | | 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 |
| | | } |
| | | |