| | |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.hidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | |
| | | let validate = item.Validate ? JSON.parse(item.Validate) : {} // 检验是否必填 |
| | | let _required = validate.required || false |
| | | if (item.InputType === 'text') { // 文本搜索 |
| | | if (item.InputType === 'text') { // 文本 |
| | | fields.push( |
| | | <Col span={24 / this.props.cols} key={index}> |
| | | <Form.Item label={item.Label}> |
| | |
| | | */ |
| | | handleMenu = (menu) => { |
| | | const _this = this |
| | | |
| | | if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | |
| | | let result = await Api.getSystemConfig(_param) |
| | | if (result.status) { |
| | | if (this.props.editState && this.props.editLevel) return |
| | | if (this.props.editState && this.props.editLevel === 'level4') return |
| | | |
| | | if (result.data.length === 0) { // 查询菜单为空 |
| | | this.setState({ |
| | |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Tree, Typography } from 'antd' |
| | | import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Tree, Typography, Col } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | import asyncLoadComponent from '@/utils/asyncLoadComponent' |
| | | import {refreshTabView, modifyTabview} from '@/store/action' |
| | | |
| | | import ChartComponent from '@/tabviews/zshare/chartcomponent' |
| | | import MainTable from '@/tabviews/zshare/normalTable' |
| | | import MainSearch from '@/tabviews/zshare/topSearch' |
| | | import NotFount from '@/components/404' |
| | |
| | | return |
| | | } |
| | | |
| | | // 兼容标签 |
| | | if (!config.tabgroups) { |
| | | config.tabgroups = [{ uuid: 'tabs', sublist: [] }] |
| | | } else if (typeof(config.tabgroups[0]) === 'string') { |
| | | let _tabgroups = [] |
| | | config.tabgroups.forEach(groupId => { |
| | | let _group = { |
| | | uuid: groupId, |
| | | sublist: fromJS(config[groupId]).toJS() |
| | | } |
| | | |
| | | delete config[groupId] |
| | | |
| | | _tabgroups.push(_group) |
| | | }) |
| | | |
| | | config.tabgroups = _tabgroups |
| | | } |
| | | |
| | | // 兼容图表 |
| | | if (!config.charts) { |
| | | config.expand = false |
| | | config.charts = [{ |
| | | uuid: Utils.getuuid(), |
| | | label: '', |
| | | title: '', |
| | | chartType: 'table', |
| | | icon: 'table', |
| | | Hide: 'false', |
| | | blacklist: [] |
| | | }] |
| | | } |
| | | |
| | | // 权限过滤 |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | config.tabgroups.forEach(group => { |
| | | if (!config[group]) return |
| | | |
| | | config[group] = config[group].filter(tab => permAction[tab.linkTab]) |
| | | group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) |
| | | }) |
| | | |
| | | // 视图权限 |
| | | config.charts = config.charts.filter(item => { |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0 || item.Hide === 'true') { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | |
| | | if (config.charts.length <= 1) { |
| | | config.expand = true |
| | | } |
| | | |
| | | // 字段权限黑名单 |
| | | config.search = config.search.filter(item => { |
| | |
| | | |
| | | let _tabActive = {} // 筛选展开的tab页 |
| | | |
| | | config.tabgroups.forEach(groupId => { |
| | | if (!config[groupId] || config[groupId].length === 0) return |
| | | _tabActive[groupId] = config[groupId][0].uuid |
| | | config.tabgroups.forEach(group => { |
| | | if (group.sublist.length === 0) return |
| | | _tabActive[group.uuid] = group.sublist[0].uuid |
| | | }) |
| | | |
| | | let _arrField = [] // 字段集 |
| | |
| | | |
| | | let _groupId = '' |
| | | let _ActiveTabId = '' |
| | | config.tabgroups.forEach(groupId => { |
| | | if (!config[groupId] || config[groupId].length === 0) return |
| | | config.tabgroups.forEach(group => { |
| | | if (group.sublist.length === 0) return |
| | | |
| | | let _tab = config[groupId].filter(tab => tab.uuid === key)[0] |
| | | let _tab = group.sublist.filter(tab => tab.uuid === key)[0] |
| | | if (_tab) { |
| | | _groupId = groupId |
| | | _groupId = group.uuid |
| | | _ActiveTabId = _tab.uuid |
| | | } |
| | | }) |
| | |
| | | let _search = Utils.formatCustomMainSearch(search) |
| | | |
| | | let param = { |
| | | PageIndex: pageIndex, |
| | | PageSize: pageSize, |
| | | OrderCol: orderBy || setting.order, |
| | | ..._search |
| | | } |
| | | |
| | | if (setting.laypage !== 'false') { |
| | | param.PageIndex = pageIndex |
| | | param.PageSize = pageSize |
| | | } |
| | | |
| | | if (setting.interType === 'inner') { |
| | |
| | | let param = { |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | arr_field: arr_field |
| | | arr_field: arr_field, |
| | | custom_script: setting.customScript || '', |
| | | default_sql: setting.default || 'true' |
| | | } |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | |
| | | let LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` |
| | | let DateCount = `select count(1) as total from ${_dataresource} ${_search}` |
| | | |
| | | if (setting.laypage === 'false') { |
| | | LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` |
| | | DateCount = '' |
| | | } |
| | | |
| | | param.custom_script = Utils.formatOptions(param.custom_script) |
| | | param.LText = Utils.formatOptions(LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | |
| | | refreshdata={this.refreshbysearch} |
| | | /> : null |
| | | } |
| | | {actions && setting.onload !== 'false' ? |
| | | <div style={{minHeight: '25px'}}> |
| | | <MainAction |
| | | BID="" |
| | | type="main" |
| | | menuType="main" |
| | | setting={setting} |
| | | actions={actions} |
| | | triggerBtn={triggerBtn} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | ContainerId={this.state.ContainerId} |
| | | refreshdata={this.refreshbyaction} |
| | | triggerPopview={this.triggerPopview} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> : null |
| | | } |
| | | {columns && setting.onload !== 'false' ? |
| | | <div className="main-table-box"> |
| | | <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} /> |
| | | {this.state.data && this.state.data.length > 0 ? |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | {setting && setting.onload !== 'false' ? <div className="chart-view"> |
| | | {/* 视图组 */} |
| | | {!config.expand ? <Tabs> |
| | | {config.charts.map(item => ( |
| | | <TabPane tab={ |
| | | <Icon type={item.icon} /> |
| | | } key={item.uuid}> |
| | | {item.chartType === 'table' ? |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div style={{minHeight: '25px'}}> |
| | | <MainAction |
| | | BID="" |
| | | type="main" |
| | | menuType="main" |
| | | setting={setting} |
| | | actions={actions} |
| | | triggerBtn={triggerBtn} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | ContainerId={this.state.ContainerId} |
| | | refreshdata={this.refreshbyaction} |
| | | triggerPopview={this.triggerPopview} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> |
| | | <div className="main-table-box"> |
| | | <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} /> |
| | | {this.state.data && this.state.data.length > 0 ? |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <MainTable |
| | | ref="mainTable" |
| | | tableId="mainTable" |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | pagination={setting.laypage !== 'false'} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | linkTrigger={this.linkTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </div> |
| | | </Col> : null |
| | | } |
| | | {item.chartType !== 'table' ? |
| | | <Col span={item.width} key={item.uuid}> |
| | | <ChartComponent |
| | | plot={item} |
| | | data={this.state.data} |
| | | config={config} |
| | | /> |
| | | </Col> : null |
| | | } |
| | | </TabPane> |
| | | ))} |
| | | </Tabs> : null} |
| | | {config.expand && config.charts.map(item => { |
| | | if (item.chartType === 'table') { |
| | | return ( |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div style={{minHeight: '25px'}}> |
| | | <MainAction |
| | | BID="" |
| | | type="main" |
| | | menuType="main" |
| | | setting={setting} |
| | | actions={actions} |
| | | triggerBtn={triggerBtn} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | ContainerId={this.state.ContainerId} |
| | | refreshdata={this.refreshbyaction} |
| | | triggerPopview={this.triggerPopview} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> |
| | | <div className="main-table-box"> |
| | | <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} /> |
| | | {this.state.data && this.state.data.length > 0 ? |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <MainTable |
| | | ref="mainTable" |
| | | tableId="mainTable" |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | pagination={setting.laypage !== 'false'} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | linkTrigger={this.linkTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </div> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <ChartComponent |
| | | plot={item} |
| | | data={this.state.data} |
| | | config={config} |
| | | /> |
| | | </Col> |
| | | ) |
| | | } |
| | | <MainTable |
| | | ref="mainTable" |
| | | tableId="mainTable" |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | linkTrigger={this.linkTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </div> : null |
| | | } |
| | | })} |
| | | </div> : null } |
| | | {setting && setting.onload !== 'false' && |
| | | config.tabgroups.map(group => { |
| | | if (config[group].length === 0) return null |
| | | if (group.sublist.length === 0) return null |
| | | |
| | | return ( |
| | | <Tabs activeKey={tabActive[group]} key={group} onChange={(key) => this.setState({tabActive: {...tabActive, [group]: key}})}> |
| | | {config[group].map(_tab => { |
| | | <Tabs activeKey={tabActive[group.uuid]} key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}> |
| | | {group.sublist.map(_tab => { |
| | | return ( |
| | | <TabPane tab={ |
| | | <span> |
| | |
| | | .ant-table-fixed-left, .ant-table-fixed-right { |
| | | z-index: 1; |
| | | } |
| | | .chart-view { |
| | | position: relative; |
| | | .ant-tabs-bar { |
| | | margin: 0; |
| | | border: 0; |
| | | .ant-tabs-nav-scroll { |
| | | text-align: right; |
| | | .ant-tabs-ink-bar { |
| | | display: none!important; |
| | | } |
| | | .ant-tabs-tab { |
| | | margin-right: 0; |
| | | padding: 10px 16px; |
| | | } |
| | | } |
| | | } |
| | | .chart-title { |
| | | position: relative; |
| | | top: -20px; |
| | | margin-bottom: 0px; |
| | | color: rgba(0, 0, 0, 0.85); |
| | | font-weight: 400; |
| | | font-size: 16px; |
| | | line-height: 25px; |
| | | height: 35px; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | overflow: hidden; |
| | | max-width: 50%; |
| | | padding-top: 10px; |
| | | padding-left: 30px; |
| | | } |
| | | .chart-table.chart-title { |
| | | position: absolute; |
| | | top: 0px; |
| | | } |
| | | } |
| | | } |
| | | .commontable.pick-control { |
| | | .button-list { |
| | |
| | | return |
| | | } |
| | | |
| | | // 兼容标签 |
| | | if (!config.tabgroups) { |
| | | config.tabgroups = [{ uuid: 'tabs', sublist: [] }] |
| | | } else if (typeof(config.tabgroups[0]) === 'string') { |
| | | let _tabgroups = [] |
| | | config.tabgroups.forEach(groupId => { |
| | | let _group = { |
| | | uuid: groupId, |
| | | sublist: fromJS(config[groupId]).toJS() |
| | | } |
| | | |
| | | delete config[groupId] |
| | | |
| | | _tabgroups.push(_group) |
| | | }) |
| | | |
| | | config.tabgroups = _tabgroups |
| | | } |
| | | |
| | | // 权限过滤 |
| | | if (this.props.param.menuType !== 'HS') { |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | config.tabgroups.forEach(group => { |
| | | if (!config[group]) return |
| | | |
| | | config[group] = config[group].filter(tab => permAction[tab.linkTab]) |
| | | group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) |
| | | }) |
| | | } |
| | | |
| | |
| | | /> : null |
| | | } |
| | | {!loadingview && !viewlost && config.tabgroups.map(group => { |
| | | if (config[group].length === 0) return null |
| | | if (group.sublist.length === 0) return null |
| | | |
| | | return ( |
| | | <Tabs defaultActiveKey="0" key={group}> |
| | | {config[group].map((_tab, index) => { |
| | | <Tabs defaultActiveKey="0" key={group.uuid}> |
| | | {group.sublist.map((_tab, index) => { |
| | | return ( |
| | | <TabPane tab={ |
| | | <span> |
| | |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Modal, Button, Switch} from 'antd' |
| | | import { notification, Spin, Modal, Button, Switch, Col, Icon, Tabs} from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | import options from '@/store/options.js' |
| | | import { modifyTabview } from '@/store/action' |
| | | |
| | | import ChartComponent from '@/tabviews/zshare/chartcomponent' |
| | | import SubTable from '@/tabviews/zshare/normalTable' |
| | | import SubSearch from '@/tabviews/zshare/topSearch' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | | const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) |
| | | const SubTabTable = asyncLoadComponent(() => import('@/tabviews/subtabtable')) |
| | | |
| | |
| | | let _hideCol = [] // 隐藏及合并列中字段的uuid集 |
| | | let colMap = new Map() |
| | | |
| | | // 兼容图表 |
| | | if (!config.charts) { |
| | | config.expand = false |
| | | config.charts = [{ |
| | | uuid: Utils.getuuid(), |
| | | label: '', |
| | | title: '', |
| | | chartType: 'table', |
| | | icon: 'table', |
| | | Hide: 'false', |
| | | blacklist: [] |
| | | }] |
| | | } |
| | | |
| | | // 权限过滤 |
| | | if (this.props.menuType !== 'HS') { |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | |
| | | return true |
| | | } |
| | | }) |
| | | |
| | | // 视图权限 |
| | | config.charts = config.charts.filter(item => { |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0 || item.Hide === 'true') { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (config.charts.length <= 1) { |
| | | config.expand = true |
| | | } |
| | | |
| | | if (userConfig) { |
| | |
| | | let _search = Utils.formatCustomMainSearch(searches) |
| | | |
| | | let param = { |
| | | PageIndex: pageIndex, |
| | | PageSize: pageSize, |
| | | OrderCol: orderBy || setting.order, |
| | | BID: BID, |
| | | ..._search |
| | | } |
| | | |
| | | if (setting.laypage !== 'false') { |
| | | param.PageIndex = pageIndex |
| | | param.PageSize = pageSize |
| | | } |
| | | |
| | | if (setting.interType === 'inner') { |
| | |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | arr_field: arr_field, |
| | | BID: BID |
| | | BID: BID, |
| | | custom_script: setting.customScript || '', |
| | | default_sql: setting.default || 'true' |
| | | } |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | |
| | | let LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` |
| | | let DateCount = `select count(1) as total from ${_dataresource} ${_search}` |
| | | |
| | | if (setting.laypage === 'false') { |
| | | LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` |
| | | DateCount = '' |
| | | } |
| | | |
| | | param.custom_script = Utils.formatOptions(param.custom_script) |
| | | param.LText = Utils.formatOptions(LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { setting, searchlist, actions, columns, loadingview, viewlost, pickup, triggerBtn } = this.state |
| | | const { config, setting, searchlist, actions, columns, loadingview, viewlost, pickup, triggerBtn } = this.state |
| | | |
| | | return ( |
| | | <div className="subtable" id={'subtable' + this.props.MenuID}> |
| | |
| | | dict={this.state.dict} |
| | | /> : null |
| | | } |
| | | {actions ? |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | type="sub" |
| | | menuType={this.props.menuType} |
| | | triggerBtn={triggerBtn} |
| | | setting={setting} |
| | | actions={actions} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | refreshdata={this.refreshbyaction} |
| | | ContainerId={this.props.ContainerId} |
| | | triggerPopview={this.triggerPopview} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> : null |
| | | } |
| | | {columns ? |
| | | <div className="subtable-box"> |
| | | {this.state.data && this.state.data.length > 0 ? |
| | | <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | {config ? <div className="chart-view"> |
| | | {/* 视图组 */} |
| | | {!config.expand ? <Tabs> |
| | | {config.charts.map(item => ( |
| | | <TabPane tab={ |
| | | <Icon type={item.icon} /> |
| | | } key={item.uuid}> |
| | | {item.chartType === 'table' ? |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | type="sub" |
| | | menuType={this.props.menuType} |
| | | triggerBtn={triggerBtn} |
| | | setting={setting} |
| | | actions={actions} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | refreshdata={this.refreshbyaction} |
| | | ContainerId={this.props.ContainerId} |
| | | triggerPopview={this.triggerPopview} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> |
| | | <div className="subtable-box"> |
| | | {this.state.data && this.state.data.length > 0 ? |
| | | <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <SubTable |
| | | ref="subTable" |
| | | menuType={this.props.menuType} |
| | | tableId={this.props.Tab.uuid} |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | pagination={setting.laypage !== 'false'} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | linkTrigger={this.linkTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </div> |
| | | </Col> : null |
| | | } |
| | | {item.chartType !== 'table' ? |
| | | <Col span={item.width} key={item.uuid}> |
| | | <ChartComponent |
| | | plot={item} |
| | | data={this.state.data} |
| | | config={config} |
| | | /> |
| | | </Col> : null |
| | | } |
| | | </TabPane> |
| | | ))} |
| | | </Tabs> : null} |
| | | {config.expand && config.charts.map(item => { |
| | | if (item.chartType === 'table') { |
| | | return ( |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | type="sub" |
| | | menuType={this.props.menuType} |
| | | triggerBtn={triggerBtn} |
| | | setting={setting} |
| | | actions={actions} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | refreshdata={this.refreshbyaction} |
| | | ContainerId={this.props.ContainerId} |
| | | triggerPopview={this.triggerPopview} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> |
| | | <div className="subtable-box"> |
| | | {this.state.data && this.state.data.length > 0 ? |
| | | <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <SubTable |
| | | ref="subTable" |
| | | menuType={this.props.menuType} |
| | | tableId={this.props.Tab.uuid} |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | pagination={setting.laypage !== 'false'} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | linkTrigger={this.linkTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </div> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <ChartComponent |
| | | plot={item} |
| | | data={this.state.data} |
| | | config={config} |
| | | /> |
| | | </Col> |
| | | ) |
| | | } |
| | | <SubTable |
| | | ref="subTable" |
| | | menuType={this.props.menuType} |
| | | tableId={this.props.Tab.uuid} |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | linkTrigger={this.linkTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </div> : null |
| | | } |
| | | })} |
| | | </div> : null } |
| | | <Modal |
| | | className="popview-modal" |
| | | title={this.state.popAction.label} |
| | |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin} from 'antd' |
| | | import { notification, Spin, Col, Icon, Tabs} from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import options from '@/store/options.js' |
| | | |
| | | import ChartComponent from '@/tabviews/zshare/chartcomponent' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import SubTable from '@/tabviews/zshare/normalTable' |
| | | import SubSearch from '@/tabviews/zshare/topSearch' |
| | |
| | | |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | | const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) |
| | | |
| | | class SubTabModalTable extends Component { |
| | |
| | | loadingview: true, // 页面加载中 |
| | | viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用 |
| | | lostmsg: '', // 页面丢失时的提示信息 |
| | | config: {}, // 页面配置信息,包括按钮、搜索、显示列、标签等 |
| | | config: null, // 页面配置信息,包括按钮、搜索、显示列、标签等 |
| | | searchlist: null, // 搜索条件 |
| | | actions: null, // 按钮集 |
| | | columns: null, // 显示列 |
| | |
| | | let _hideCol = [] // 隐藏及合并列中字段的uuid集 |
| | | let colMap = new Map() |
| | | |
| | | // 兼容图表 |
| | | if (!config.charts) { |
| | | config.expand = false |
| | | config.charts = [{ |
| | | uuid: Utils.getuuid(), |
| | | label: '', |
| | | title: '', |
| | | chartType: 'table', |
| | | icon: 'table', |
| | | Hide: 'false', |
| | | blacklist: [] |
| | | }] |
| | | } |
| | | |
| | | // 仅支持exec、prompt、pop 三种类型按钮 |
| | | config.action = config.action.filter(item => ['exec', 'prompt', 'pop'].includes(item.OpenType)) |
| | | |
| | |
| | | return true |
| | | } |
| | | }) |
| | | |
| | | // 视图权限 |
| | | config.charts = config.charts.filter(item => { |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0 || item.Hide === 'true') { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (config.charts.length <= 1) { |
| | | config.expand = true |
| | | } |
| | | |
| | | // 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid |
| | |
| | | let _search = Utils.formatCustomMainSearch(search) |
| | | |
| | | let param = { |
| | | PageIndex: pageIndex, |
| | | PageSize: pageSize, |
| | | OrderCol: orderBy || setting.order, |
| | | ..._search |
| | | } |
| | | |
| | | if (setting.laypage !== 'false') { |
| | | param.PageIndex = pageIndex |
| | | param.PageSize = pageSize |
| | | } |
| | | |
| | | if (setting.interType === 'inner') { |
| | |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | arr_field: arr_field, |
| | | BID: this.props.BID |
| | | BID: this.props.BID, |
| | | custom_script: setting.customScript || '', |
| | | default_sql: setting.default || 'true' |
| | | } |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | |
| | | let LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` |
| | | let DateCount = `select count(1) as total from ${_dataresource} ${_search}` |
| | | |
| | | if (setting.laypage === 'false') { |
| | | LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` |
| | | DateCount = '' |
| | | } |
| | | |
| | | param.custom_script = Utils.formatOptions(param.custom_script) |
| | | param.LText = Utils.formatOptions(LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | |
| | | loadingview: true, |
| | | viewlost: false, |
| | | lostmsg: '', |
| | | config: {}, |
| | | config: null, |
| | | searchlist: null, |
| | | actions: null, |
| | | columns: null, |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { setting, searchlist, actions, columns, loadingview, viewlost, triggerBtn } = this.state |
| | | const { config, setting, searchlist, actions, columns, loadingview, viewlost, triggerBtn } = this.state |
| | | |
| | | return ( |
| | | <div className="subtabtable" id={'subtabtable' + this.props.MenuID}> |
| | |
| | | dict={this.state.dict} |
| | | /> : null |
| | | } |
| | | {actions ? |
| | | <div style={{minHeight: '25px'}}> |
| | | <SubAction |
| | | type="subtab" |
| | | triggerBtn={triggerBtn} |
| | | menuType={this.props.menuType} |
| | | setting={setting} |
| | | actions={actions} |
| | | BID={this.props.BID} |
| | | dict={this.state.dict} |
| | | BData={this.props.BData} |
| | | MenuID={this.props.SupMenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | refreshdata={this.refreshbyaction} |
| | | ContainerId={this.props.ContainerId} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> : null |
| | | } |
| | | {columns && |
| | | <SubTable |
| | | ref="subTable" |
| | | menuType={this.props.menuType} |
| | | tableId="" |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | setting={setting} |
| | | columns={columns} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | handleTableId={() => {}} |
| | | /> |
| | | } |
| | | {config ? <div className="chart-view"> |
| | | {/* 视图组 */} |
| | | {!config.expand ? <Tabs> |
| | | {config.charts.map(item => ( |
| | | <TabPane tab={ |
| | | <Icon type={item.icon} /> |
| | | } key={item.uuid}> |
| | | {item.chartType === 'table' ? |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div style={{minHeight: '25px'}}> |
| | | <SubAction |
| | | type="subtab" |
| | | triggerBtn={triggerBtn} |
| | | menuType={this.props.menuType} |
| | | setting={setting} |
| | | actions={actions} |
| | | BID={this.props.BID} |
| | | dict={this.state.dict} |
| | | BData={this.props.BData} |
| | | MenuID={this.props.SupMenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | refreshdata={this.refreshbyaction} |
| | | ContainerId={this.props.ContainerId} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> |
| | | <SubTable |
| | | ref="subTable" |
| | | menuType={this.props.menuType} |
| | | tableId="" |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | setting={setting} |
| | | columns={columns} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | loading={this.state.loading} |
| | | pagination={setting.laypage !== 'false'} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | handleTableId={() => {}} |
| | | /> |
| | | </Col> : null |
| | | } |
| | | {item.chartType !== 'table' ? |
| | | <Col span={item.width} key={item.uuid}> |
| | | <ChartComponent |
| | | plot={item} |
| | | data={this.state.data} |
| | | config={config} |
| | | /> |
| | | </Col> : null |
| | | } |
| | | </TabPane> |
| | | ))} |
| | | </Tabs> : null} |
| | | {config.expand && config.charts.map(item => { |
| | | if (item.chartType === 'table') { |
| | | return ( |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div style={{minHeight: '25px'}}> |
| | | <SubAction |
| | | type="subtab" |
| | | triggerBtn={triggerBtn} |
| | | menuType={this.props.menuType} |
| | | setting={setting} |
| | | actions={actions} |
| | | BID={this.props.BID} |
| | | dict={this.state.dict} |
| | | BData={this.props.BData} |
| | | MenuID={this.props.SupMenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | refreshdata={this.refreshbyaction} |
| | | ContainerId={this.props.ContainerId} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> |
| | | <SubTable |
| | | ref="subTable" |
| | | menuType={this.props.menuType} |
| | | tableId="" |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | setting={setting} |
| | | columns={columns} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | loading={this.state.loading} |
| | | pagination={setting.laypage !== 'false'} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | handleTableId={() => {}} |
| | | /> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <ChartComponent |
| | | plot={item} |
| | | data={this.state.data} |
| | | config={config} |
| | | /> |
| | | </Col> |
| | | ) |
| | | } |
| | | })} |
| | | </div> : null } |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |
| | | </div> |
| | | ) |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Chart } from '@antv/g2' |
| | | import DataSet from '@antv/data-set' |
| | | |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import './index.scss' |
| | | |
| | | class LineChart extends Component { |
| | | static propTpyes = { |
| | | plot: PropTypes.object, |
| | | data: PropTypes.array, |
| | | config: PropTypes.object |
| | | } |
| | | |
| | | state = { |
| | | dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.viewrender() |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | this.setState({}, () => { |
| | | let _element = document.getElementById(this.props.plot.uuid) |
| | | if (_element) { |
| | | _element.innerHTML = '' |
| | | } |
| | | this.viewrender() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | getdata = () => { |
| | | const { data } = this.props |
| | | // let _data = [] |
| | | |
| | | return data || [] |
| | | } |
| | | |
| | | viewrender = () => { |
| | | const { plot } = this.props |
| | | |
| | | if (plot.chartType === 'line') { |
| | | this.linerender() |
| | | } else if (plot.chartType === 'bar') { |
| | | this.barrender() |
| | | } else if (plot.chartType === 'pie') { |
| | | this.pierender() |
| | | } |
| | | } |
| | | |
| | | linerender = () => { |
| | | const { plot, config } = this.props |
| | | |
| | | let transfield = {} |
| | | config.columns.forEach(col => { |
| | | if (col.field) { |
| | | transfield[col.field] = col.label |
| | | } |
| | | }) |
| | | // const colors = ['#f49d37', '#f03838', '#35d1d1', '#5be56b', '#4e7af0', '#ebcc21'] |
| | | let X_axis = plot.Xaxis |
| | | let Y_axis = plot.Yaxis |
| | | |
| | | let data = this.getdata() |
| | | |
| | | const ds = new DataSet() |
| | | const dv = ds.createView().source(data) |
| | | |
| | | dv.transform({ |
| | | type: 'fold', |
| | | fields: [...Y_axis], |
| | | key: 'key', // key字段 |
| | | value: 'value', // value字段 |
| | | // retains: [], // 保留字段集,默认为除 fields 以外的所有字段 |
| | | }) |
| | | |
| | | if (plot.Xaxis) { |
| | | dv.transform({ |
| | | type: 'map', |
| | | callback(row) { |
| | | row.key = transfield[row.key] |
| | | return row |
| | | }, |
| | | }) |
| | | } |
| | | |
| | | const chart = new Chart({ |
| | | container: plot.uuid, |
| | | autoFit: true, |
| | | height: plot.height || 400 |
| | | }) |
| | | |
| | | chart.data(dv.rows) |
| | | |
| | | if (plot.coordinate !== 'polar') { |
| | | chart.scale(X_axis, { |
| | | range: [0, 1] |
| | | }) |
| | | } |
| | | chart.scale('value', { |
| | | nice: true |
| | | }) |
| | | |
| | | if (!plot.legend || plot.legend === 'hidden') { |
| | | chart.legend(false) |
| | | } else { |
| | | chart.legend({ |
| | | position: plot.legend |
| | | }) |
| | | } |
| | | |
| | | if (plot.tooltip !== 'true') { |
| | | chart.tooltip(false) |
| | | } else { |
| | | chart.tooltip({ |
| | | shared: true |
| | | }) |
| | | } |
| | | |
| | | if (plot.transpose === 'true') { |
| | | chart.coordinate().transpose() |
| | | } |
| | | |
| | | if (plot.coordinate === 'polar') { |
| | | chart.coordinate('polar', { |
| | | innerRadius: 0.1, |
| | | radius: 0.8 |
| | | }) |
| | | } |
| | | |
| | | let _chart = chart |
| | | .line() |
| | | .position(`${X_axis}*value`) |
| | | .color('key') |
| | | .shape(plot.shape || 'smooth') |
| | | |
| | | if (plot.label === 'true') { |
| | | _chart.label('value') |
| | | } |
| | | |
| | | if (plot.point === 'true') { |
| | | chart |
| | | .point() |
| | | .position(`${X_axis}*value`) |
| | | .color('key') |
| | | .size(3) |
| | | .shape('circle') |
| | | } |
| | | |
| | | chart.render() |
| | | } |
| | | |
| | | barrender = () => { |
| | | const { plot, config } = this.props |
| | | |
| | | let transfield = {} |
| | | config.columns.forEach(col => { |
| | | if (col.field) { |
| | | transfield[col.field] = col.label |
| | | } |
| | | }) |
| | | let X_axis = plot.Xaxis |
| | | let Y_axis = plot.Yaxis |
| | | |
| | | let data = this.getdata() |
| | | |
| | | const ds = new DataSet() |
| | | const dv = ds.createView().source(data) |
| | | |
| | | dv.transform({ |
| | | type: 'fold', |
| | | fields: [...Y_axis], |
| | | key: 'key', |
| | | value: 'value' |
| | | }) |
| | | |
| | | if (plot.Xaxis) { |
| | | dv.transform({ |
| | | type: 'map', |
| | | callback(row) { |
| | | row.key = transfield[row.key] |
| | | return row |
| | | }, |
| | | }) |
| | | } |
| | | |
| | | const chart = new Chart({ |
| | | container: plot.uuid, |
| | | autoFit: true, |
| | | height: plot.height || 400 |
| | | }) |
| | | |
| | | chart.data(dv.rows) |
| | | |
| | | chart.scale('value', { |
| | | nice: true |
| | | }) |
| | | |
| | | if (!plot.legend || plot.legend === 'hidden') { |
| | | chart.legend(false) |
| | | } else { |
| | | chart.legend({ |
| | | position: plot.legend |
| | | }) |
| | | } |
| | | |
| | | if (plot.tooltip !== 'true') { |
| | | chart.tooltip(false) |
| | | } else { |
| | | chart.tooltip({ |
| | | shared: true |
| | | }) |
| | | } |
| | | |
| | | if (plot.transpose === 'true') { |
| | | chart.coordinate().transpose() |
| | | } |
| | | |
| | | if (plot.coordinate === 'polar') { |
| | | chart.coordinate('polar', { |
| | | innerRadius: 0.1, |
| | | radius: 0.8 |
| | | }) |
| | | } |
| | | |
| | | if (plot.adjust !== 'stack') { |
| | | chart |
| | | .interval() |
| | | .position(`${X_axis}*value`) |
| | | .color('key') |
| | | .adjust([ |
| | | { |
| | | type: 'dodge', |
| | | marginRatio: 0 |
| | | } |
| | | ]) |
| | | .shape(plot.shape || 'rect') |
| | | } else if (plot.adjust === 'stack') { |
| | | chart |
| | | .interval() |
| | | .position(`${X_axis}*value`) |
| | | .color('key') |
| | | .adjust('stack') |
| | | .shape(plot.shape || 'rect') |
| | | } |
| | | |
| | | chart.render() |
| | | } |
| | | |
| | | pierender = () => { |
| | | const { plot, config } = this.props |
| | | |
| | | let transfield = {} |
| | | config.columns.forEach(col => { |
| | | if (col.field) { |
| | | transfield[col.field] = col.label |
| | | } |
| | | }) |
| | | let X_axis = plot.Xaxis |
| | | let Y_axis = plot.Yaxis |
| | | |
| | | let data = this.getdata() |
| | | |
| | | const ds = new DataSet() |
| | | const dv = ds.createView().source(data) |
| | | |
| | | if (plot.pieshow !== 'value') { |
| | | dv.transform({ |
| | | type: 'percent', |
| | | field: Y_axis, |
| | | dimension: X_axis, |
| | | as: 'percent' |
| | | }) |
| | | } |
| | | |
| | | const chart = new Chart({ |
| | | container: plot.uuid, |
| | | autoFit: true, |
| | | height: plot.height || 400 |
| | | }) |
| | | |
| | | chart.data(dv.rows) |
| | | |
| | | if (plot.pieshow !== 'value') { |
| | | chart.scale('percent', { |
| | | formatter: (val) => { |
| | | val = val * 100 + '%' |
| | | return val |
| | | } |
| | | }) |
| | | } |
| | | |
| | | chart.coordinate('theta', { |
| | | innerRadius: plot.shape === 'ring' ? 0.6 : 0, |
| | | radius: 0.75, |
| | | }) |
| | | |
| | | if (!plot.legend || plot.legend === 'hidden') { |
| | | chart.legend(false) |
| | | } else { |
| | | chart.legend({ |
| | | position: plot.legend |
| | | }) |
| | | } |
| | | |
| | | if (plot.tooltip !== 'true') { |
| | | chart.tooltip(false) |
| | | } else { |
| | | chart.tooltip({ |
| | | showTitle: false, |
| | | showMarkers: false |
| | | }) |
| | | } |
| | | |
| | | if (plot.pieshow !== 'value') { |
| | | let _chart = chart |
| | | .interval() |
| | | .adjust('stack') |
| | | .position('percent') |
| | | .color(X_axis) |
| | | .tooltip(X_axis + '*percent', (item, percent) => { |
| | | percent = (percent * 100).toFixed(2) + '%' |
| | | return { |
| | | name: item, |
| | | value: percent |
| | | } |
| | | }) |
| | | |
| | | if (plot.label === 'true') { |
| | | let setting = { |
| | | content: (data) => { |
| | | return `${data[X_axis]}: ${(data.percent * 100).toFixed(2)}%` |
| | | } |
| | | } |
| | | |
| | | if (plot.labelLayout === 'overlap') { |
| | | setting.type = 'pie' |
| | | setting.layout = { |
| | | type: 'overlap' |
| | | } |
| | | setting.offset = 0 |
| | | // setting.style = { |
| | | // textAlign: 'center', |
| | | // fontSize: 12, |
| | | // fill: '#535353' |
| | | // } |
| | | } |
| | | |
| | | _chart.label('percent', setting) |
| | | } |
| | | |
| | | } else { |
| | | let _chart = chart |
| | | .interval() |
| | | .adjust('stack') |
| | | .position(Y_axis) |
| | | .color(X_axis) |
| | | .tooltip(X_axis + '*' + Y_axis, (item, value) => { |
| | | return { |
| | | name: item, |
| | | value: value |
| | | } |
| | | }) |
| | | |
| | | if (plot.label === 'true') { |
| | | let setting = { |
| | | content: (data) => { |
| | | return `${data[X_axis]}: ${data[Y_axis]}` |
| | | } |
| | | } |
| | | |
| | | if (plot.labelLayout === 'overlap') { |
| | | setting.type = 'pie' |
| | | setting.layout = { |
| | | type: 'overlap' |
| | | } |
| | | setting.offset = 0 |
| | | } |
| | | |
| | | _chart.label(Y_axis, setting) |
| | | } |
| | | } |
| | | |
| | | chart.render() |
| | | } |
| | | |
| | | render() { |
| | | const { plot } = this.props |
| | | |
| | | return ( |
| | | <div className="line-chart-edit-box" style={{minHeight: plot.height ? plot.height + 50 : 450}}> |
| | | <p className="chart-title">{plot.title}</p> |
| | | <div className="canvas" id={plot.uuid}></div> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default LineChart |
New file |
| | |
| | | .line-chart-edit-box { |
| | | margin-bottom: 30px; |
| | | |
| | | .canvas { |
| | | margin: 0 40px; |
| | | } |
| | | } |
| | |
| | | _readin = false |
| | | } |
| | | |
| | | item.initVal = item.initval ? JSON.parse(JSON.stringify(item.initval)) : '' // 用于受控值的表单,隐藏时传默认值 |
| | | item.initVal = typeof(item.initval) === 'object' ? JSON.parse(JSON.stringify(item.initval)) : item.initval // 用于受控值的表单,隐藏时传默认值 |
| | | |
| | | let _fieldlen = item.fieldlength || 50 |
| | | if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { |
| | |
| | | let _data = option.props.data |
| | | _field.linkSubField.forEach(subfield => { |
| | | if (this.props.form.getFieldValue(subfield) !== undefined) { |
| | | fieldsvalue[subfield] = _data[subfield] || '' |
| | | fieldsvalue[subfield] = (_data[subfield] || _data[subfield] === 0) ? _data[subfield] : '' |
| | | } else { |
| | | _record[subfield] = _data[subfield] || '' |
| | | _record[subfield] = (_data[subfield] || _data[subfield] === 0) ? _data[subfield] : '' |
| | | } |
| | | }) |
| | | } |
| | |
| | | <Col span={24 / cols} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, { |
| | | initialValue: item.initval || '', |
| | | initialValue: item.initval, |
| | | rules: [ |
| | | { |
| | | required: item.required === 'true', |
| | |
| | | // <Col span={24 / cols} key={index}> |
| | | // <Form.Item label={item.label}> |
| | | // {getFieldDecorator(item.field, { |
| | | // initialValue: item.linkfield || '', |
| | | // initialValue: item.linkfield, |
| | | // })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} />)} |
| | | // </Form.Item> |
| | | // </Col> |
| | |
| | | <Col span={24} key={index} className="textarea-row" style={{..._style}}> |
| | | <Form.Item label={item.label} labelCol={{xs: { span: 24 }, sm: { span: _labelcol }}} wrapperCol={ {xs: { span: 24 }, sm: { span: _wrapcol }} }> |
| | | {getFieldDecorator(item.field, { |
| | | initialValue: item.initval || '', |
| | | initialValue: item.initval, |
| | | rules: [ |
| | | { |
| | | required: item.required === 'true', |
| | |
| | | buttonTrigger: PropTypes.func, // 表格中按钮触发操作 |
| | | linkTrigger: PropTypes.func, // 字段透视 |
| | | handleTableId: PropTypes.func, // 数据切换 |
| | | pagination: PropTypes.any // 数据切换 |
| | | pagination: PropTypes.any // 数据分页 |
| | | } |
| | | |
| | | state = { |
| | |
| | | }) |
| | | |
| | | let deffers = [] |
| | | config.tabgroups.forEach(groupId => { |
| | | config[groupId].forEach(tab => { |
| | | config.tabgroups.forEach(group => { |
| | | group.sublist.forEach(tab => { |
| | | deffers.push(new Promise(resolve => { |
| | | let param = { |
| | | func: 'sPC_Get_LongParam', |
| | |
| | | margin-bottom: 15px; |
| | | color: rgba(0, 0, 0, 0.85); |
| | | font-weight: 400; |
| | | font-size: 18px; |
| | | font-size: 16px; |
| | | line-height: 25px; |
| | | height: 35px; |
| | | text-overflow: ellipsis; |
| | |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class ActionComponent extends Component { |
| | | static propTpyes = { |
| | | type: PropTypes.string, // 菜单类型,主表或子表 |
| | |
| | | |
| | | class LineChartDrawerForm extends Component { |
| | | static propTpyes = { |
| | | type: PropTypes.string, |
| | | dict: PropTypes.object, |
| | | plot: PropTypes.object, |
| | | columns: PropTypes.array, |
| | | config: PropTypes.object, |
| | | plotchange: PropTypes.func |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | showDrawer = () => { |
| | | const { columns, plot, type } = this.props |
| | | const { config, plot } = this.props |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | formlist: getChartOptionForm(plot, columns, type) |
| | | formlist: getChartOptionForm(plot, config.columns, config.setting) |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | radioChange = (e, key) => { |
| | | const { formlist } = this.state |
| | | let val = e.target.value |
| | | |
| | | if (key === 'datatype') { |
| | | this.setState({ |
| | | formlist: formlist.map(item => { |
| | | if (['Yaxis'].includes(item.key)) { |
| | | item.hidden = val === 'statistics' |
| | | } else if (['InfoType', 'InfoValue', 'InfoDefNumber'].includes(item.key)) { |
| | | item.hidden = val !== 'statistics' |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | getFields() { |
| | | const { formlist } = this.state |
| | | const { getFieldDecorator } = this.props.form |
| | |
| | | } |
| | | |
| | | formlist.forEach((item, index) => { |
| | | if (item.hidden) return |
| | | if (item.hidden || item.forbid) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'select') { // 下拉搜索 |
| | | } else if (item.type === 'select') { // 下拉 |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | } else if (item.type === 'radio') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | |
| | | } |
| | | ] |
| | | })( |
| | | <Radio.Group> |
| | | <Radio.Group disabled={item.readonly} onChange={(e) => this.radioChange(e, item.key)}> |
| | | {item.options.map(option => { |
| | | return ( |
| | | <Radio key={option.value} value={option.value}>{option.text}</Radio> |
| | |
| | | .line-chart-drawer-form { |
| | | position: absolute; |
| | | right: 10px; |
| | | top: 50px; |
| | | |
| | | > .anticon-edit { |
| | | color: #1890ff; |
| | |
| | | .ant-drawer-body { |
| | | max-height: calc(100vh - 60px); |
| | | overflow-y: auto; |
| | | |
| | | .anticon-question-circle { |
| | | color: #c49f47; |
| | | margin-right: 3px; |
| | | } |
| | | .ant-input-number { |
| | | width: 100%; |
| | | } |
| | | } |
| | | .ant-drawer-body::-webkit-scrollbar { |
| | | width: 7px; |
| | |
| | | return ( |
| | | <div className="line-chart-edit-box" style={{minHeight: plot.height ? plot.height + 50 : 450}}> |
| | | <p className="chart-title">{plot.title}</p> |
| | | <ChartDrawerForm type={plot.chartType} columns={this.props.config.columns} dict={this.state.dict} plot={plot} plotchange={this.plotChange} /> |
| | | <div className="canvas" id={plot.uuid}></div> |
| | | <ChartDrawerForm |
| | | plot={plot} |
| | | type={plot.chartType} |
| | | config={this.props.config} |
| | | dict={this.state.dict} |
| | | plotchange={this.plotChange} |
| | | /> |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class ChartGroupComponent extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 菜单配置信息 |
| | |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class ColumnComponent extends Component { |
| | | static propTpyes = { |
| | | menu: PropTypes.object, // 三级菜单信息 |
| | |
| | | |
| | | import './index.scss' |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class FieldsComponent extends Component { |
| | | static propTpyes = { |
| | | type: PropTypes.string, // 搜索条件添加、显示列添加 |
| | |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class SearchComponent extends Component { |
| | | static propTpyes = { |
| | | menu: PropTypes.object, // 当前菜单信息 |
| | |
| | | |
| | | // const { Option } = Select |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class TablesComponent extends Component { |
| | | static propTpyes = { |
| | | type: PropTypes.string, // 菜单类型 |
| | |
| | | _setting.scripts = _setting.scripts || [] |
| | | _setting.default = _setting.default || 'true' |
| | | |
| | | delete _setting.subtabs |
| | | |
| | | this.setState({ |
| | | setting: _setting, |
| | | formlist: _formlist.map(item => { |
| | |
| | | |
| | | const { Option } = Select |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class TablesComponent extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 容器Id |
| | |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class TablesComponent extends Component { |
| | | static propTpyes = { |
| | | type: PropTypes.string, // 菜单类型 |
| | |
| | | margin-bottom: 15px; |
| | | color: rgba(0, 0, 0, 0.85); |
| | | font-weight: 400; |
| | | font-size: 18px; |
| | | font-size: 16px; |
| | | line-height: 25px; |
| | | height: 35px; |
| | | text-overflow: ellipsis; |
| | |
| | | AppendWhere: config.setting.queryType === 'query' ? searchText.join(' AND ') : '', |
| | | WhereType: config.setting.queryType === 'statistics' ? 'Statistics' : 'query', |
| | | custom_script: config.setting.customScript || '', |
| | | // default_sql: config.setting.default || 'true', |
| | | default_sql: config.setting.default || 'true', |
| | | OrderCol: config.setting.order |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * @description 获取图表视图配置表单 |
| | | * @param {object} card // 搜索条件对象 |
| | | * @param {object} card // 图表对象 |
| | | * @param {Array} columns // 显示列 |
| | | * @param {String} type // 图表类型 |
| | | * @param {String} setting // 页面设置 |
| | | */ |
| | | export function getChartOptionForm (card, columns, type) { |
| | | export function getChartOptionForm (card, columns, setting) { |
| | | let shapes = [] |
| | | |
| | | if (type === 'line') { |
| | | if (card.chartType === 'line') { |
| | | shapes = [ |
| | | { field: 'smooth', label: 'smooth' }, |
| | | { field: 'line', label: 'line' }, |
| | |
| | | { field: 'hvh', label: 'hvh' }, |
| | | { field: 'vhv', label: 'vhv' } |
| | | ] |
| | | } else if (type === 'bar') { |
| | | } else if (card.chartType === 'bar') { |
| | | shapes = [ |
| | | { field: 'rect', label: 'rect' }, |
| | | { field: 'hollow-rect', label: 'hollow-rect' }, |
| | |
| | | { field: 'funnel', label: 'funnel' }, |
| | | { field: 'pyramid', label: 'pyramid' } |
| | | ] |
| | | } else if (type === 'pie') { |
| | | } else if (card.chartType === 'pie') { |
| | | shapes = [ |
| | | { field: 'pie', label: '饼图' }, |
| | | { field: 'ring', label: '环图' } |
| | |
| | | |
| | | return [ |
| | | { |
| | | type: 'radio', |
| | | key: 'datatype', |
| | | label: '数据类型', |
| | | initVal: card.datatype || 'query', |
| | | tooltip: '统计图表适用于表格不分页,且数据需要转换', |
| | | required: false, |
| | | readonly: !(setting.laypage === 'false'), |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | options: [ |
| | | { value: 'query', text: Formdict['header.form.query'] }, |
| | | { value: 'statistics', text: Formdict['header.form.statistics'] } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'Xaxis', |
| | | label: type === 'pie' ? 'Text' : 'X-轴', |
| | | label: card.chartType === 'pie' ? 'Text' : 'X-轴', |
| | | initVal: card.Xaxis || '', |
| | | required: true, |
| | | options: columns.filter(col => col.type === 'text') |
| | |
| | | { |
| | | type: 'select', |
| | | key: 'Yaxis', |
| | | label: type === 'pie' ? 'Value' : 'Y-轴', |
| | | initVal: type === 'pie' ? card.Yaxis || '' : card.Yaxis || [], |
| | | multi: type !== 'pie', |
| | | label: card.chartType === 'pie' ? 'Value' : 'Y-轴', |
| | | initVal: card.chartType === 'pie' ? card.Yaxis || '' : card.Yaxis || [], |
| | | multi: card.chartType !== 'pie', |
| | | hidden: card.datatype === 'statistics', |
| | | required: true, |
| | | options: columns.filter(col => col.type === 'number') |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'InfoType', |
| | | label: '类型', |
| | | initVal: card.InfoType || '', |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | hidden: card.datatype !== 'statistics', |
| | | required: true, |
| | | options: columns.filter(col => col.type === 'text') |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'InfoValue', |
| | | label: '值', |
| | | initVal: card.InfoValue || '', |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | hidden: card.datatype !== 'statistics', |
| | | required: true, |
| | | options: columns.filter(col => col.type === 'number') |
| | | }, |
| | |
| | | label: '形状', |
| | | initVal: card.shape || (shapes[0] && shapes[0].field), |
| | | required: false, |
| | | hidden: !['line', 'bar', 'pie'].includes(type), |
| | | forbid: !['line', 'bar', 'pie'].includes(card.chartType), |
| | | options: shapes |
| | | }, |
| | | { |
| | |
| | | label: '坐标', |
| | | initVal: card.coordinate || 'angle', |
| | | required: false, |
| | | hidden: !['line', 'bar'].includes(type), |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'angle', |
| | | text: '二维坐标' |
| | |
| | | label: '点图', |
| | | initVal: card.point || 'false', |
| | | required: false, |
| | | hidden: !['line'].includes(type), |
| | | forbid: !['line'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'true', |
| | | text: '显示' |
| | |
| | | label: '变换', |
| | | initVal: card.transpose || 'false', |
| | | required: false, |
| | | hidden: !['line', 'bar'].includes(type), |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['header.form.true'] |
| | |
| | | label: '显示值', |
| | | initVal: card.pieshow || 'percent', |
| | | required: false, |
| | | hidden: !['pie'].includes(type), |
| | | forbid: !['pie'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'percent', |
| | | text: '百分比' |
| | |
| | | type: 'radio', |
| | | key: 'label', |
| | | label: '文本标签', |
| | | initVal: card.label || (type === 'pie' ? 'true' : 'false'), |
| | | initVal: card.label || (card.chartType === 'pie' ? 'true' : 'false'), |
| | | required: false, |
| | | hidden: !['pie', 'line'].includes(type), |
| | | forbid: !['pie', 'line'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'true', |
| | | text: '显示' |
| | |
| | | label: '标签布局', |
| | | initVal: card.labelLayout || 'normal', |
| | | required: false, |
| | | hidden: !['pie'].includes(type), |
| | | forbid: !['pie'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'normal', |
| | | text: '常规' |
| | |
| | | label: '多柱排列', |
| | | initVal: card.adjust || 'dodge', |
| | | required: false, |
| | | hidden: !['bar'].includes(type), |
| | | forbid: !['bar'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'dodge', |
| | | text: '分组' |
| | |
| | | value: 'stack', |
| | | text: '堆叠' |
| | | }] |
| | | } |
| | | }, { |
| | | type: 'radio', |
| | | key: 'repeat', |
| | | label: '重复数据', |
| | | initVal: card.repeat || 'unrepeat', |
| | | required: false, |
| | | // forbid: !['bar', 'pie', 'line'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'unrepeat', |
| | | text: '去重' |
| | | }, { |
| | | value: 'average', |
| | | text: '平均' |
| | | }, { |
| | | value: 'cumsum', |
| | | text: '累加' |
| | | }] |
| | | }, { |
| | | type: 'number', |
| | | key: 'InfoDefNumber', |
| | | label: '展示数', |
| | | tooltip: '默认显示类型数量', |
| | | min: 1, |
| | | max: 50, |
| | | decimal: 0, |
| | | initVal: card.InfoDefNumber || 5, |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | hidden: card.datatype !== 'statistics', |
| | | required: true |
| | | }, |
| | | ] |
| | | } |
| | | |
| | |
| | | let _prevCustomScript = '' // 默认sql前执行脚本 |
| | | let _backCustomScript = '' // 默认sql后执行脚本 |
| | | |
| | | if (verify.scripts) { |
| | | verify.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | verify.scripts && verify.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | |
| | | if (item.position === 'init') { |
| | | _initCustomScript += ` |
| | | ${item.sql} |
| | | ` |
| | | } else if (item.position === 'front') { |
| | | _prevCustomScript += ` |
| | | ${item.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | ${item.sql} |
| | | ` |
| | | } |
| | | }) |
| | | } |
| | | if (item.position === 'init') { |
| | | _initCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${item.sql} |
| | | ` |
| | | } else if (item.position === 'front') { |
| | | _prevCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${item.sql} |
| | | ` |
| | | } else { |
| | | _backCustomScript += ` |
| | | /* 自定义脚本 */ |
| | | ${item.sql} |
| | | ` |
| | | } |
| | | }) |
| | | |
| | | // 需要声明的变量集 |
| | | // let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] |
| | |
| | | let primaryKey = setting.primaryKey || 'id' |
| | | |
| | | // 系统变量声明与设置初始值 |
| | | let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50) |
| | | let _sql = `/* 系统生成 */ |
| | | Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50) |
| | | ` |
| | | |
| | | // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 已赋值字段集 |
| | |
| | | if (!_initvars.includes(_key)) { |
| | | _initvars.push(_key) |
| | | |
| | | if (form.type === 'number' && typeof(form.value) === 'number') { |
| | | _initfields.push(`@${_key}=${form.value}`) |
| | | if (form.type === 'number') { |
| | | let val = form.value |
| | | if (typeof(val) !== 'number') { |
| | | val = parseFloat(val) |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | } |
| | | _initfields.push(`@${_key}=${val}`) |
| | | } else { |
| | | _initfields.push(`@${_key}='${form.value}'`) |
| | | } |
| | |
| | | |
| | | let _val = data.hasOwnProperty(col.field) ? data[col.field] : '' |
| | | |
| | | if (col.type === 'number' && typeof(_val) === 'number') { |
| | | if (col.type === 'number') { |
| | | if (typeof(_val) !== 'number') { |
| | | _val = parseFloat(_val) |
| | | if (isNaN(_val)) { |
| | | _val = 0 |
| | | } |
| | | } |
| | | _initfields.push(`@${_key}=${_val}`) |
| | | } else { |
| | | _initfields.push(`@${_key}='${_val}'`) |
| | |
| | | // 变量声明 |
| | | _declarefields = _declarefields.join(',') |
| | | if (_declarefields) { |
| | | _sql += `,${_declarefields} |
| | | ` |
| | | _sql = `/* 系统生成 */ |
| | | Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50),${_declarefields} |
| | | ` |
| | | } |
| | | |
| | | // 变量赋值 |
| | |
| | | } |
| | | |
| | | // 初始化凭证及用户信息字段 |
| | | _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}' |
| | | ` |
| | | _sql += ` |
| | | /* 凭证及用户信息初始化赋值 */ |
| | | select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}' |
| | | ` |
| | | |
| | | if (_initCustomScript) { |
| | | _sql += _initCustomScript |
| | |
| | | |
| | | // 启用账期验证 |
| | | if (verify.accountdate === 'true') { |
| | | _sql += `exec s_FIBVoucherDateCheck @ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT |
| | | _sql += ` |
| | | /* 账期验证 */ |
| | | exec s_FIBVoucherDateCheck @ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT |
| | | if @ErrorCode!='' |
| | | GOTO aaa |
| | | ` |
| | |
| | | datasource = '(' + datasource + ') tb' |
| | | } |
| | | |
| | | _sql += `select @tbid='', @ErrorCode='',@retmsg='' |
| | | _sql += ` |
| | | /* 失效验证 */ |
| | | select @tbid='', @ErrorCode='',@retmsg='' |
| | | select @tbid=${primaryKey} from ${datasource} where ${primaryKey} ='${primaryId}' |
| | | If @tbid='' |
| | | Begin |
| | |
| | | // 比较验证 |
| | | if (verify.contrasts && verify.contrasts.length > 0) { |
| | | verify.contrasts.forEach(item => { |
| | | _sql += `If ${item.frontfield} ${item.operator} ${item.backfield} |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' |
| | | goto aaa |
| | | end |
| | | ` |
| | | _sql += ` |
| | | /* 比较验证 */ |
| | | If ${item.frontfield} ${item.operator} ${item.backfield} |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | } |
| | | |
| | |
| | | _fieldValue.push(`${primaryKey} !='${primaryId}'`) |
| | | } |
| | | |
| | | _sql += `select @tbid='', @ErrorCode='',@retmsg='' |
| | | select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType} |
| | | If @tbid!='' |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 已存在' |
| | | goto aaa |
| | | end |
| | | ` |
| | | _sql += ` |
| | | /* 唯一性验证 */ |
| | | select @tbid='', @ErrorCode='',@retmsg='' |
| | | select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType} |
| | | If @tbid!='' |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 已存在' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | } |
| | | |
| | | // 自定义验证 |
| | | if (verify.customverifys && verify.customverifys.length > 0) { |
| | | verify.customverifys.forEach(item => { |
| | | _sql += `select @tbid='', @ErrorCode='',@retmsg='' |
| | | select top 1 @tbid='X' from (${item.sql}) a |
| | | If @tbid ${item.result === 'true' ? '!=' : '='}'' |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | } |
| | | verify.customverifys && verify.customverifys.forEach(item => { |
| | | _sql += ` |
| | | /* 自定义验证 */ |
| | | select @tbid='', @ErrorCode='',@retmsg='' |
| | | select top 1 @tbid='X' from (${item.sql}) a |
| | | If @tbid ${item.result === 'true' ? '!=' : '='}'' |
| | | Begin |
| | | select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' |
| | | goto aaa |
| | | end |
| | | ` |
| | | }) |
| | | |
| | | // 单号生成,使用上级id(BID)或列表数据,声明变量(检验) |
| | | let _billcodesSql = '' |
| | |
| | | _vars.push(_key) |
| | | } |
| | | |
| | | _billcodesSql += `${_declare} |
| | | select @BillCode='', @${_key}='', @ModularDetailCode='' |
| | | ${_lpline} |
| | | exec s_get_BillCode |
| | | @ModularDetailCode=${_ModularDetailCode}, |
| | | @Type=${item.Type}, |
| | | @TypeCharOne='${item.TypeCharOne}', |
| | | @TypeCharTwo ='${item.TypeCharTwo}', |
| | | @BillCode =@BillCode output, |
| | | @ErrorCode =@ErrorCode output, |
| | | @retmsg=@retmsg output |
| | | if @ErrorCode!='' |
| | | goto aaa |
| | | set @${_key}=@BillCode |
| | | ` |
| | | _billcodesSql += ` |
| | | /* 单号生成 */ |
| | | ${_declare} |
| | | select @BillCode='', @${_key}='', @ModularDetailCode='' |
| | | ${_lpline} |
| | | exec s_get_BillCode |
| | | @ModularDetailCode=${_ModularDetailCode}, |
| | | @Type=${item.Type}, |
| | | @TypeCharOne='${item.TypeCharOne}', |
| | | @TypeCharTwo ='${item.TypeCharTwo}', |
| | | @BillCode =@BillCode output, |
| | | @ErrorCode =@ErrorCode output, |
| | | @retmsg=@retmsg output |
| | | if @ErrorCode!='' |
| | | goto aaa |
| | | set @${_key}=@BillCode |
| | | ` |
| | | }) |
| | | |
| | | if (_actionType !== 'insertOrUpdate') { |
| | |
| | | |
| | | hasvoucher = true |
| | | |
| | | _sql += `exec s_BVoucher_Create |
| | | _sql += ` |
| | | /* 创建凭证 */ |
| | | exec s_BVoucher_Create |
| | | @Bill ='${data[_voucher.linkField]}', |
| | | @BVoucherType ='${_voucher.BVoucherType}', |
| | | @VoucherTypeOne ='${_voucher.VoucherTypeOne}', |
| | |
| | | |
| | | // 添加、修改、逻辑删除、物理删除 |
| | | if (_actionType === 'insert') { |
| | | _sql += _insertsql |
| | | _sql += ` |
| | | /* 默认sql */ |
| | | ${_insertsql}` |
| | | } else if (_actionType === 'update') { |
| | | _sql += _updatesql |
| | | _sql += ` |
| | | /* 默认sql */ |
| | | ${_updatesql}` |
| | | } else if (_actionType === 'LogicDelete') { // 逻辑删除 |
| | | _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKeyName};` |
| | | _sql += ` |
| | | /* 默认sql */ |
| | | update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKeyName};` |
| | | |
| | | } else if (_actionType === 'delete') { // 物理删除 |
| | | let _msg = '' |
| | |
| | | } |
| | | }) |
| | | } |
| | | _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select left('删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@${primaryKeyName},200),@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKeyName};` |
| | | _sql += ` |
| | | /* 默认sql */ |
| | | insert into snote (remark,createuserid,CreateUser,CreateStaff) select left('删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@${primaryKeyName},200),@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKeyName};` |
| | | } else if (_actionType === 'insertOrUpdate') { |
| | | _sql += `select @tbid='' |
| | | _sql += ` |
| | | /* 默认sql */ |
| | | select @tbid='' |
| | | select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@ |
| | | if @tbid='' |
| | | begin |
| | |
| | | } |
| | | |
| | | _sql += ` |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | |
| | | _sql = _sql.replace(/\n\s{8}/ig, '\n') |
| | | console.log(_sql) |
| | | return _sql |
| | | } |