| | |
| | | /** |
| | | * @description 打开websql |
| | | */ |
| | | static openWebSql () { |
| | | static openWebSql (sysType) { |
| | | let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' |
| | | try { |
| | | window.GLOB.WebSql = openDatabase(`mkdb${service}`, '1', 'mk-pc-database', 50 * 1024 * 1024) |
| | |
| | | // eslint-disable-next-line |
| | | throw 'CREATE TABLE ERROR' |
| | | }) |
| | | |
| | | if (sysType === 'local' && window.GLOB.systemType === '') { |
| | | tx.executeSql('CREATE TABLE IF NOT EXISTS FUNCS (func_code varchar(50), key_sql text, CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50))', [], () => { |
| | | |
| | | }, () => { |
| | | // eslint-disable-next-line |
| | | throw 'CREATE TABLE ERROR' |
| | | }) |
| | | } |
| | | }) |
| | | // window.GLOB.WebSql.transaction(tx => { |
| | | // tx.executeSql('DROP TABLE VERSIONS') |
| | |
| | | } |
| | | return new Promise((resolve, reject) => { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql('SELECT * FROM VERSIONS', [], (tx, results) => { |
| | | tx.executeSql("SELECT * FROM VERSIONS where CDefine1='LongParam'", [], (tx, results) => { |
| | | if (results.rows.length === 0) { |
| | | tx.executeSql('DELETE FROM CONFIGS') |
| | | resolve({version: '', createDate: ''}) |
| | | } else if (results.rows.length === 1) { |
| | | resolve(results.rows[0]) |
| | | } else if (results.rows.length > 1) { |
| | | tx.executeSql('DELETE FROM VERSIONS') |
| | | tx.executeSql('DELETE FROM CONFIGS') |
| | | resolve({version: '', createDate: ''}) |
| | | } else { |
| | | resolve(results.rows[0]) |
| | | } |
| | | }, (tx, results) => { |
| | | window.GLOB.WebSql = null |
| | |
| | | static updateWebSqlTime (curTime) { |
| | | if (!window.GLOB.WebSql || !curTime) return |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql(`UPDATE VERSIONS SET createDate='${curTime}'`, [], () => {}, () => { |
| | | tx.executeSql(`UPDATE VERSIONS SET createDate='${curTime}' where CDefine1='LongParam'`, [], () => {}, () => { |
| | | window.GLOB.WebSql = null |
| | | }) |
| | | }) |
| | |
| | | static updateWebSqlversion (version, curTime) { |
| | | if (!window.GLOB.WebSql || !curTime || !version) return |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql(`UPDATE VERSIONS SET version='${version}', createDate='${curTime}'`, [], () => {}, () => { |
| | | tx.executeSql(`UPDATE VERSIONS SET version='${version}', createDate='${curTime}' where CDefine1='LongParam'`, [], () => {}, () => { |
| | | window.GLOB.WebSql = null |
| | | }) |
| | | }) |
| | |
| | | static createWebSqlversion (version, curTime) { |
| | | if (!window.GLOB.WebSql || !curTime || !version) return |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql('INSERT INTO VERSIONS (version, createDate) VALUES (?, ?)', [version, curTime], () => {}, () => { |
| | | tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', [version, curTime, 'LongParam'], () => {}, () => { |
| | | window.GLOB.WebSql = null |
| | | }) |
| | | }) |
| | |
| | | /** |
| | | * @description 打开IndexedDB |
| | | */ |
| | | static openIndexDB () { |
| | | static openIndexDB (sysType) { |
| | | let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' |
| | | try { |
| | | let request = window.indexedDB.open(`mkdb${service}`, 1) |
| | |
| | | objectStore.createIndex('menuid', 'menuid', { unique: false }) |
| | | objectStore.createIndex('userid', 'userid', { unique: false }) |
| | | } |
| | | if (window.GLOB.systemType === '' && sysType === 'local' && !window.GLOB.IndexDB.objectStoreNames.contains('funcs')) { |
| | | window.GLOB.IndexDB.createObjectStore('funcs', { keyPath: 'id' }) |
| | | } |
| | | } |
| | | } catch (e) { |
| | | console.warn('IndexedDB 初始化失败!') |
| | |
| | | 1578479100252lfbp29v1kafk4s4q4ig,1577971621421tg4v0i1ur8873k7e0ob,1577929944419lgc5h3hepum765e2k7u,1588493493409k9guqp067d31lu7blsv` |
| | | |
| | | if (window.openDatabase) { |
| | | CacheUtils.openWebSql() |
| | | CacheUtils.openWebSql(options.sysType) |
| | | } else if (window.indexedDB) { |
| | | CacheUtils.openIndexDB() |
| | | CacheUtils.openIndexDB(options.sysType) |
| | | } |
| | | |
| | | axios.defaults.crossDomain = true |
| | |
| | | /** |
| | | * @description 获取或修改系统配置,增加appkey |
| | | */ |
| | | getSystemFuncs (time) { |
| | | let param = { |
| | | func: 's_get_func_base_sso', |
| | | update_date: time, |
| | | userid: sessionStorage.getItem('UserID') || '', |
| | | lang: sessionStorage.getItem('lang') || '', |
| | | SessionUid: localStorage.getItem('SessionUid') || '', |
| | | LoginUID: sessionStorage.getItem('LoginUID') || '', |
| | | appkey: window.GLOB.appkey |
| | | } |
| | | |
| | | let url = window.GLOB.mainSystemApi |
| | | param = this.encryptParam(param) |
| | | |
| | | return axios({ |
| | | url: `${url}/${param.func}`, |
| | | method: 'post', |
| | | data: param |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取或修改系统配置,增加appkey |
| | | */ |
| | | getSystemConfig (param) { |
| | | param.userid = param.userid || sessionStorage.getItem('UserID') || '' |
| | | param.lang = param.lang || sessionStorage.getItem('lang') || '' |
| | |
| | | // 修改编辑状态 |
| | | let UserID = sessionStorage.getItem('CloudUserID') |
| | | let LoginUID = sessionStorage.getItem('CloudLoginUID') |
| | | |
| | | |
| | | if (!UserID || !LoginUID) { |
| | | this.setState({ |
| | | loginVisible: true |
| | |
| | | sessionStorage.setItem('dataM', res.dataM ? 'true' : '') |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | |
| | | this.setSystemFuncs() |
| | | |
| | | this.props.modifyMenuTree([]) |
| | | this.props.modifyMainMenu(null) |
| | | this.props.modifyTabview([]) |
| | |
| | | }) |
| | | } |
| | | |
| | | setSystemFuncs = () => { |
| | | if (!window.GLOB.WebSql && !window.GLOB.IndexDB) { |
| | | return |
| | | } |
| | | this.getfuncTime().then(res => { |
| | | Api.getSystemFuncs(res.createDate).then(result => { |
| | | if (!result.status) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (result.func_detail && result.func_detail.length > 0) { |
| | | this.writeFuncs(result.func_detail) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | writeFuncs = (funcs) => { |
| | | let timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | |
| | | let sys_datetime = sessionStorage.getItem('sys_datetime') |
| | | let app_datetime = sessionStorage.getItem('app_datetime') |
| | | if (sys_datetime && app_datetime) { |
| | | let seconds = Math.floor((new Date().getTime() - app_datetime) / 1000) |
| | | timestamp = moment(sys_datetime, 'YYYY-MM-DD HH:mm:ss').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql('DELETE FROM FUNCS') |
| | | |
| | | funcs.forEach(item => { |
| | | if (!item.key_sql) return |
| | | tx.executeSql('INSERT INTO FUNCS (func_code, key_sql) VALUES (?, ?)', [item.func_code, item.key_sql]) |
| | | }) |
| | | tx.executeSql(`UPDATE VERSIONS SET createDate='${timestamp}' where CDefine1='funcs'`) |
| | | }) |
| | | } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['funcs'], 'readwrite').objectStore('funcs') |
| | | |
| | | objectStore.clear() |
| | | |
| | | funcs.forEach(item => { |
| | | if (!item.key_sql) return |
| | | item.id = item.func_code |
| | | objectStore.add(item) |
| | | }) |
| | | |
| | | let funcStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | funcStore.put({id: 'funcs', version: '1.0', createDate: timestamp}) |
| | | } |
| | | } |
| | | |
| | | getfuncTime = () => { |
| | | return new Promise((resolve, reject) => { |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql("SELECT * FROM VERSIONS where CDefine1='funcs'", [], (tx, results) => { |
| | | let rows = results.rows |
| | | if (rows.length === 0) { |
| | | tx.executeSql('DELETE FROM FUNCS') |
| | | tx.executeSql('INSERT INTO VERSIONS (version, createDate, CDefine1) VALUES (?, ?, ?)', ['1.0', '1970-01-01 14:59:09.000', 'funcs']) |
| | | resolve({createDate: '1970-01-01 14:59:09.000'}) |
| | | } else { |
| | | resolve(rows[0]) |
| | | } |
| | | }, (tx, results) => { |
| | | reject() |
| | | console.warn(results) |
| | | }) |
| | | }) |
| | | } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction(['version'], 'readwrite').objectStore('version') |
| | | let request = objectStore.get('funcs') |
| | | |
| | | request.onerror = (event) => { |
| | | console.warn(event) |
| | | reject() |
| | | } |
| | | |
| | | request.onsuccess = () => { |
| | | if (request.result) { |
| | | resolve(request.result) |
| | | } else { |
| | | let add = objectStore.add({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | |
| | | add.onerror = () => { |
| | | reject() |
| | | } |
| | | add.onsuccess = () => { |
| | | resolve({id: 'funcs', version: '1.0', createDate: '1970-01-01 14:59:09.000'}) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | changeSystem = (system) => { |
| | | let url = system.LinkUrl1 |
| | | |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.viewrender() |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | MKEmitter.addListener('tabsChange', this.handleTabsChange) |
| | | setTimeout(() => { |
| | | this.viewrender() |
| | | }, 1000) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | */ |
| | | linerender = () => { |
| | | const { card } = this.state |
| | | let plot = {...card.plot, height: card.plot.height - 70} // 去除title所占空间 |
| | | let plot = {...card.plot} // 去除title所占空间 |
| | | let color = plot.color || 'rgba(0, 0, 0, 0.65)' |
| | | let X_axis = plot.Xaxis || 'x' |
| | | let Y_axis = plot.Yaxis || ['y'] |
| | | |
| | | if (card.plot.title || card.search.length > 0) { |
| | | plot.height = card.plot.height - 70 |
| | | } |
| | | |
| | | let data = this.getdata(X_axis, Y_axis) |
| | | |
| | |
| | | */ |
| | | customrender = (data) => { |
| | | let card = fromJS(this.state.card).toJS() |
| | | let plot = {...card.plot, height: card.plot.height - 70} // 去除title所占空间 |
| | | let plot = {...card.plot} // 去除title所占空间 |
| | | let color = plot.color || 'rgba(0, 0, 0, 0.65)' |
| | | let fields = [] |
| | | let legends = [] |
| | | let transfield = {} |
| | | let Bar_axis = [] |
| | | |
| | | if (card.plot.title || card.search.length > 0) { |
| | | plot.height = card.plot.height - 70 |
| | | } |
| | | |
| | | card.columns.forEach(col => { |
| | | if (col.field) { |
| | |
| | | */ |
| | | barrender = () => { |
| | | const { card } = this.state |
| | | let plot = {...card.plot, height: card.plot.height - 70} |
| | | let plot = {...card.plot} |
| | | let color = plot.color || 'rgba(0, 0, 0, 0.65)' |
| | | let X_axis = plot.Xaxis || 'x' |
| | | let Y_axis = plot.Yaxis || ['y'] |
| | | |
| | | if (card.plot.title || card.search.length > 0) { |
| | | plot.height = card.plot.height - 70 |
| | | } |
| | | |
| | | let data = this.getdata(X_axis, Y_axis) |
| | | |
| | |
| | | |
| | | return ( |
| | | <div className="menu-line-chart-edit-box" style={{..._style, height: card.plot.height || 400}} onClick={this.clickComponent} id={card.uuid}> |
| | | <NormalHeader config={card} updateComponent={this.updateComponent}/> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | {!ismob ? <Icon className="plus" title="添加搜索" onClick={this.addSearch} type="plus-circle" /> : null} |
| | |
| | | } trigger="hover"> |
| | | <Icon type="tool" /> |
| | | </Popover> |
| | | {card.plot.title || card.search.length > 0 ? <NormalHeader config={card} updateComponent={this.updateComponent}/> : null} |
| | | <div className="canvas" id={card.uuid + 'canvas'}></div> |
| | | <ActionComponent |
| | | type="chart" |
| | | config={card} |
| | | updateaction={this.updateComponent} |
| | | /> |
| | | <div className="canvas" id={card.uuid + 'canvas'}></div> |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | margin: 0px; |
| | | padding: 15px 10px 10px; |
| | | letter-spacing: 0px; |
| | | min-height: calc(100% - 45px); |
| | | height: 100%; |
| | | } |
| | | .normal-header + .canvas { |
| | | height: calc(100% - 45px); |
| | | } |
| | | |
| | | .chart-header { |
| | |
| | | .model-menu-action-list { |
| | | position: absolute; |
| | | right: 0px; |
| | | top: 30px; |
| | | z-index: 4; |
| | | font-size: 16px; |
| | | |
| | |
| | | float: right; |
| | | } |
| | | } |
| | | .normal-header + .canvas + .model-menu-action-list { |
| | | top: 45px; |
| | | } |
| | | } |
| | | .menu-line-chart-edit-box:hover { |
| | | z-index: 1; |
| | |
| | | } |
| | | ] |
| | | } |
| | | |
| | | /** |
| | | * @description 获取图表视图配置表单 |
| | | * @param {object} card // 图表对象 |
| | | * @param {Array} columns // 显示列 |
| | | */ |
| | | export function getRadioOptionForm (card, columns) { |
| | | let xfields = columns.filter(item => /^Nvarchar/ig.test(item.datatype)) |
| | | let yfields = columns.filter(item => /^(Int|Decimal)/ig.test(item.datatype)) |
| | | |
| | | return [ |
| | | { |
| | | type: 'select', |
| | | key: 'labelField', |
| | | label: '指标', |
| | | initVal: card.labelField || '', |
| | | required: true, |
| | | options: xfields |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'valueField', |
| | | label: '值', |
| | | initVal: card.valueField || '', |
| | | required: true, |
| | | options: yfields |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'maxValue', |
| | | label: '最大值', |
| | | initVal: card.maxValue || 100, |
| | | min: 0, |
| | | max: 999999, |
| | | decimal: 1, |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'radius', |
| | | label: '外环', |
| | | initVal: card.radius || 75, |
| | | tooltip: '图形所占区域的百分率。', |
| | | min: 30, |
| | | max: 100, |
| | | decimal: 0, |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'fontSize', |
| | | label: '字体大小', |
| | | initVal: card.fontSize || 28, |
| | | min: 12, |
| | | max: 200, |
| | | decimal: 0, |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'percent', |
| | | label: '百分率', |
| | | initVal: card.percent || 'true', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '使用' |
| | | }, { |
| | | value: 'false', |
| | | text: '不使用' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'color', |
| | | key: 'backColor', |
| | | label: '背景色', |
| | | initVal: card.backColor || '#ebedf0', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'color', |
| | | key: 'labelColor', |
| | | label: '字体颜色', |
| | | initVal: card.labelColor || '#8c8c8c', |
| | | required: false |
| | | } |
| | | ] |
| | | } |
| | |
| | | import { Modal, Form, Row, Col, Select, Icon, Radio, Tooltip, Input, InputNumber, Tabs, Button } from 'antd' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import { getBaseForm, getOptionForm } from './formconfig' |
| | | import { getBaseForm, getOptionForm, getRadioOptionForm } from './formconfig' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import ColorSketch from '@/mob/colorsketch' |
| | | import './index.scss' |
| | |
| | | { |
| | | title: '指标', |
| | | dataIndex: 'tick', |
| | | inputType: 'number', |
| | | inputType: this.props.config.subtype === 'ratioboard' ? 'text' : 'number', |
| | | editable: true, |
| | | width: '40%' |
| | | }, |
| | |
| | | view: 'normal', |
| | | plot: fromJS(config.plot).toJS(), |
| | | baseFormlist: getBaseForm(config.plot), |
| | | formlist: getOptionForm(config.plot, config.columns) |
| | | formlist: config.subtype === 'ratioboard' ? getRadioOptionForm(config.plot, config.columns) : getOptionForm(config.plot, config.columns) |
| | | }) |
| | | } |
| | | |
| | | radioChange = (e, key) => { |
| | | const { formlist } = this.state |
| | | let val = e.target.value |
| | | |
| | | if (key === 'shape') { |
| | | this.setState({ |
| | | formlist: formlist.map(item => { |
| | | if (item.key === 'innerRadius') { |
| | | item.hidden = val === 'pie' |
| | | } |
| | | return item |
| | | }) |
| | | }, () => { |
| | | if (val === 'ring') { |
| | | this.props.form.setFieldsValue({innerRadius: 50}) |
| | | } else if (val === 'nightingale') { |
| | | this.props.form.setFieldsValue({innerRadius: 0}) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | getFields() { |
| | |
| | | } |
| | | ] |
| | | })( |
| | | <Radio.Group disabled={item.readonly} onChange={(e) => this.radioChange(e, item.key)}> |
| | | <Radio.Group disabled={item.readonly}> |
| | | {item.options.map(option => { |
| | | return ( |
| | | <Radio key={option.value} value={option.value}>{option.text}</Radio> |
| | |
| | | ) |
| | | } else if (item.type === 'color') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Col span={12} key={index} className="color-col"> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <Icon type="question-circle" /> |
| | |
| | | position: relative; |
| | | z-index: 1; |
| | | } |
| | | .color-col { |
| | | .ant-form-item-control { |
| | | height: 40px; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | }, |
| | | }) |
| | | |
| | | registerShape('point', 'hidden', { |
| | | draw(cfg, container) { |
| | | return container.addGroup({}) |
| | | } |
| | | }) |
| | | |
| | | class antvDashboardChart extends Component { |
| | | static propTpyes = { |
| | | card: PropTypes.object, |
| | |
| | | const { card, ismob } = this.props |
| | | |
| | | if (card.isNew) { |
| | | let _plot = { |
| | | width: card.width || 12, |
| | | height: 400, |
| | | label: '', |
| | | valueField: '', |
| | | name: card.name, |
| | | maxValue: 100, |
| | | tickInterval: 10, |
| | | labelColor: '#545454', |
| | | tickColor: '#CBCBCB', |
| | | percent: 'true' |
| | | let _plot = null |
| | | if (card.subtype === 'ratioboard') { |
| | | _plot = { |
| | | width: card.width || 12, |
| | | height: 400, |
| | | labelField: '', |
| | | valueField: '', |
| | | name: card.name, |
| | | maxValue: 100, |
| | | radius: 75, |
| | | fontSize: 28, |
| | | percent: 'true', |
| | | backColor: '#ebedf0', |
| | | labelColor: '#8c8c8c' |
| | | } |
| | | } else { |
| | | _plot = { |
| | | width: card.width || 12, |
| | | height: 400, |
| | | label: '', |
| | | valueField: '', |
| | | name: card.name, |
| | | maxValue: 100, |
| | | tickInterval: 10, |
| | | labelColor: '#545454', |
| | | tickColor: '#CBCBCB', |
| | | percent: 'true' |
| | | } |
| | | } |
| | | |
| | | if (ismob) { |
| | |
| | | floor: card.floor, |
| | | tabId: card.tabId || '', |
| | | parentId: card.parentId || '', |
| | | format: 'object', // 组件属性 - 数据格式 |
| | | format: card.subtype === 'ratioboard' ? 'array' : 'object', // 组件属性 - 数据格式 |
| | | pageable: false, // 组件属性 - 是否可分页 |
| | | switchable: false, // 组件属性 - 数据是否可切换 |
| | | dataName: card.dataName || '', |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.dashboardrender() |
| | | this.viewrender() |
| | | MKEmitter.addListener('tabsChange', this.handleTabsChange) |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | } |
| | |
| | | } |
| | | |
| | | this.$timer && clearTimeout(this.$timer) |
| | | this.$timer = setTimeout(this.dashboardrender, 100) |
| | | this.$timer = setTimeout(this.viewrender, 100) |
| | | } |
| | | } |
| | | |
| | | viewrender = () => { |
| | | const { card } = this.state |
| | | if (card.subtype === 'ratioboard') { |
| | | this.ratioboardrender() |
| | | } else { |
| | | this.dashboardrender() |
| | | } |
| | | } |
| | | |
| | | getratiodata = () => { |
| | | const { card } = this.state |
| | | |
| | | let val = (Math.random() * card.plot.maxValue).toFixed(1) |
| | | let data = [ |
| | | { type: '新用户', value: val, $percent: val / card.plot.maxValue, $color: '#1890ff' }, |
| | | ] |
| | | if (card.plot.colors && card.plot.colors.length > 0) { |
| | | data = [] |
| | | card.plot.colors.forEach(item => { |
| | | let _val = (Math.random() * card.plot.maxValue).toFixed(1) |
| | | data.push({ |
| | | type: item.tick, |
| | | value: _val, |
| | | $percent: _val / card.plot.maxValue, |
| | | $color: item.color |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | return data |
| | | } |
| | | |
| | | ratioboardrender = () => { |
| | | const { card } = this.state |
| | | const plot = card.plot |
| | | |
| | | const data = this.getratiodata() |
| | | |
| | | const chart = new Chart({ |
| | | container: card.uuid + 'dashboard', |
| | | autoFit: true, |
| | | height: plot.title ? plot.height - 45 : plot.height, |
| | | }) |
| | | |
| | | chart.data(data) |
| | | chart.coordinate('polar', { |
| | | startAngle: -Math.PI / 2, |
| | | endAngle: 3 * Math.PI / 2, |
| | | radius: (plot.radius || 75) / 100 |
| | | }) |
| | | chart.scale('$percent', { |
| | | min: 0, |
| | | max: 1, |
| | | tickInterval: 1, |
| | | }) |
| | | chart.axis(false) |
| | | chart.facet('rect', { |
| | | fields: ['type'], |
| | | showTitle: false, |
| | | eachView: function eachView(view, facet) { |
| | | const data = facet.data[0] |
| | | |
| | | view.point().position('').shape('hidden') |
| | | |
| | | view.annotation().arc({ |
| | | top: false, |
| | | start: [0, 1], |
| | | end: [0.9999, 1], |
| | | style: { |
| | | stroke: plot.backColor, |
| | | lineWidth: 10 |
| | | } |
| | | }) |
| | | |
| | | let _tick = data.$percent |
| | | if (_tick >= 1) { |
| | | _tick = 0.9999 |
| | | } |
| | | |
| | | view.annotation().arc({ |
| | | start: [0, 1], |
| | | end: [_tick, 1], |
| | | style: { |
| | | stroke: data.$color, |
| | | lineWidth: 10, |
| | | } |
| | | }) |
| | | // 仪表盘信息 |
| | | let text = '' |
| | | if (plot.percent === 'true') { |
| | | text = +(data.$percent * 100).toFixed(2) + '%' |
| | | } else { |
| | | text = data.value |
| | | } |
| | | |
| | | view.annotation().text({ |
| | | position: ['50%', '45%'], |
| | | content: data.type, |
| | | style: { |
| | | fontSize: plot.fontSize * 0.8, |
| | | fill: plot.labelColor, |
| | | fontWeight: 300, |
| | | textAlign: 'center' |
| | | }, |
| | | offsetX: 0 |
| | | }) |
| | | view.annotation().text({ |
| | | position: ['50%', '55%'], |
| | | content: text, |
| | | style: { |
| | | fontSize: plot.fontSize, |
| | | fill: plot.labelColor, |
| | | fontWeight: 500, |
| | | textAlign: 'center' |
| | | }, |
| | | offsetX: 0, |
| | | offsetY: 10 |
| | | }) |
| | | } |
| | | }) |
| | | chart.render() |
| | | } |
| | | |
| | | getdata = () => { |
| | |
| | | const chart = new Chart({ |
| | | container: card.uuid + 'dashboard', |
| | | autoFit: true, |
| | | height: plot.height ? (plot.height - 75) : 325, |
| | | height: plot.title ? plot.height - 45 : plot.height, |
| | | padding: [0, 0, 0, 0], |
| | | }) |
| | | chart.data(data); |
| | | chart.data(data) |
| | | chart.scale('value', { |
| | | min: 0, |
| | | max: plot.maxValue, |
| | | tickInterval: plot.tickInterval, |
| | | }); |
| | | }) |
| | | chart.coordinate('polar', { |
| | | startAngle: (-9 / 8) * Math.PI, |
| | | endAngle: (1 / 8) * Math.PI, |
| | | radius: 0.75, |
| | | }); |
| | | }) |
| | | |
| | | chart.axis('1', false); |
| | | chart.axis('1', false) |
| | | chart.axis('value', { |
| | | line: null, |
| | | label: { |
| | |
| | | } |
| | | }, |
| | | grid: null, |
| | | }); |
| | | chart.legend(false); |
| | | chart.tooltip(false); |
| | | }) |
| | | chart.legend(false) |
| | | chart.tooltip(false) |
| | | chart |
| | | .point() |
| | | .position('value*1') |
| | |
| | | appear: { |
| | | animation: 'fade-in' |
| | | } |
| | | }); |
| | | }) |
| | | |
| | | // 绘制仪表盘背景 |
| | | chart.annotation().arc({ |
| | |
| | | start: [0, 1], |
| | | end: [plot.maxValue, 1], |
| | | style: { |
| | | stroke: '#CBCBCB', |
| | | stroke: '#ebedf0', |
| | | lineWidth: 18, |
| | | lineDash: null, |
| | | }, |
| | |
| | | } |
| | | this.$timer && clearTimeout(this.$timer) |
| | | this.$timer = setTimeout(() => { |
| | | this.dashboardrender() |
| | | this.viewrender() |
| | | }, 150) |
| | | } |
| | | |
| | |
| | | |
| | | return ( |
| | | <div className="menu-dashboard-edit-box" style={{..._style, height: card.plot.height || 400}} onClick={this.clickComponent} id={card.uuid}> |
| | | <NormalHeader config={card} updateComponent={this.updateComponent}/> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <ChartCompileForm config={card} dict={this.state.dict} plotchange={this.updateComponent}/> |
| | |
| | | } trigger="hover"> |
| | | <Icon type="tool" /> |
| | | </Popover> |
| | | {card.plot.title ? <NormalHeader config={card} updateComponent={this.updateComponent}/> : null} |
| | | <div className="canvas" id={card.uuid + 'dashboard'}></div> |
| | | </div> |
| | | ) |
| | |
| | | margin: 0px; |
| | | padding: 15px; |
| | | letter-spacing: 0px; |
| | | min-height: calc(100% - 45px); |
| | | height: 100%; |
| | | } |
| | | .normal-header + .canvas { |
| | | height: calc(100% - 45px); |
| | | } |
| | | |
| | | >.anticon-tool { |
| | |
| | | let X_axis = plot.Xaxis || 'x' |
| | | let Y_axis = plot.Yaxis || 'y' |
| | | let type = plot.type || 'type' |
| | | let height = plot.height || 400 |
| | | if (card.plot.title || card.search.length > 0) { |
| | | height = height - 45 |
| | | } |
| | | |
| | | const _data = this.getnestdata(X_axis, Y_axis, type) |
| | | const dvx = new DataView().source(_data) |
| | |
| | | const chart = new Chart({ |
| | | container: card.uuid + 'canvas', |
| | | autoFit: true, |
| | | height: card.plot.height ? (card.plot.height - 75) : 325, |
| | | height: height, |
| | | padding: 0, |
| | | }) |
| | | |
| | |
| | | let color = plot.color || 'rgba(0, 0, 0, 0.85)' |
| | | let X_axis = plot.Xaxis || 'x' |
| | | let Y_axis = plot.Yaxis || 'y' |
| | | let height = plot.height || 400 |
| | | if (card.plot.title || card.search.length > 0) { |
| | | height = height - 45 |
| | | } |
| | | |
| | | let data = this.getdata(X_axis, Y_axis) |
| | | |
| | |
| | | const chart = new Chart({ |
| | | container: card.uuid + 'canvas', |
| | | autoFit: true, |
| | | height: card.plot.height ? (card.plot.height - 75) : 325 |
| | | height: height |
| | | }) |
| | | |
| | | if (plot.shape !== 'nightingale' && plot.show !== 'value') { |
| | |
| | | |
| | | return ( |
| | | <div className="menu-pie-chart-edit-box" style={{..._style, height: card.plot.height || 400}} onClick={this.clickComponent} id={card.uuid}> |
| | | <NormalHeader config={card} updateComponent={this.updateComponent}/> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | {!ismob ? <Icon className="plus" title="添加搜索" onClick={this.addSearch} type="plus-circle" /> : null} |
| | |
| | | } trigger="hover"> |
| | | <Icon type="tool" /> |
| | | </Popover> |
| | | {card.plot.title || card.search.length > 0 ? <NormalHeader config={card} updateComponent={this.updateComponent}/> : null} |
| | | <div className="canvas" id={card.uuid + 'canvas'}></div> |
| | | </div> |
| | | ) |
| | |
| | | margin: 0px; |
| | | padding: 15px; |
| | | letter-spacing: 0px; |
| | | min-height: calc(100% - 45px); |
| | | height: 100%; |
| | | } |
| | | .normal-header + .canvas { |
| | | height: calc(100% - 45px); |
| | | } |
| | | |
| | | >.anticon-tool { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.ponitrender() |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | MKEmitter.addListener('tabsChange', this.handleTabsChange) |
| | | setTimeout(() => { |
| | | this.ponitrender() |
| | | }, 1000) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | const { card } = this.state |
| | | const plot = card.plot |
| | | const data = this.getdata() |
| | | let height = plot.height - 25 |
| | | |
| | | if (card.plot.title || card.search.length > 0) { |
| | | height = plot.height - 70 |
| | | } |
| | | |
| | | const chart = new Chart({ |
| | | container: card.uuid + 'canvas', |
| | | autoFit: true, |
| | | height: plot.height - 70 |
| | | height: height |
| | | }) |
| | | |
| | | chart.data(data); |
| | |
| | | let _style = resetStyle(card.style) |
| | | |
| | | return ( |
| | | <div className="menu-line-chart-edit-box" style={{..._style, height: card.plot.height || 400}} onClick={this.clickComponent} id={card.uuid}> |
| | | <NormalHeader config={card} updateComponent={this.updateComponent}/> |
| | | <div className="menu-scatter-chart-edit-box" style={{..._style, height: card.plot.height || 400}} onClick={this.clickComponent} id={card.uuid}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | {!ismob ? <Icon className="plus" title="添加搜索" onClick={this.addSearch} type="plus-circle" /> : null} |
| | | {!ismob ? <Icon className="plus" title="添加搜索" onClick={this.addSearch} type="plus-circle"/> : null} |
| | | <Icon className="plus" title="添加按钮" onClick={this.addButton} type="plus-square" /> |
| | | <ChartCompileForm config={card} dict={this.state.dict} plotchange={this.updateComponent}/> |
| | | <CopyComponent type="line" card={card}/> |
| | | <PasteComponent config={card} options={['action', 'search', 'form']} updateConfig={this.updateComponent} /> |
| | | <Icon className="style" title="调整样式" onClick={this.changeStyle} type="font-colors" /> |
| | | <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} /> |
| | | <PasteComponent config={card} options={['action', 'search', 'form']} updateConfig={this.updateComponent}/> |
| | | <Icon className="style" title="调整样式" onClick={this.changeStyle} type="font-colors"/> |
| | | <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog}/> |
| | | <ClockComponent config={card} updateConfig={this.updateComponent}/> |
| | | <UserComponent config={card}/> |
| | | <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> |
| | | <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(card.uuid)}/> |
| | | <SettingComponent config={card} updateConfig={this.updateComponent}/> |
| | | </div> |
| | | } trigger="hover"> |
| | | <Icon type="tool" /> |
| | | </Popover> |
| | | <ActionComponent type="chart" config={card} updateaction={this.updateComponent} /> |
| | | {card.plot.title || card.search.length > 0 ? <NormalHeader config={card} updateComponent={this.updateComponent}/> : null} |
| | | <div className="canvas" id={card.uuid + 'canvas'}></div> |
| | | <ActionComponent type="chart" config={card} updateaction={this.updateComponent}/> |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | .menu-line-chart-edit-box { |
| | | .menu-scatter-chart-edit-box { |
| | | position: relative; |
| | | box-sizing: border-box; |
| | | background: #ffffff; |
| | |
| | | margin: 0px; |
| | | padding: 15px 10px 10px; |
| | | letter-spacing: 0px; |
| | | min-height: calc(100% - 45px); |
| | | height: 100%; |
| | | } |
| | | .normal-header + .canvas { |
| | | height: calc(100% - 45px); |
| | | } |
| | | |
| | | .chart-header { |
| | |
| | | .model-menu-action-list { |
| | | position: absolute; |
| | | right: 0px; |
| | | top: 30px; |
| | | z-index: 4; |
| | | font-size: 16px; |
| | | |
| | |
| | | float: right; |
| | | } |
| | | } |
| | | .normal-header + .canvas + .model-menu-action-list { |
| | | top: 45px; |
| | | } |
| | | } |
| | | .menu-line-chart-edit-box:hover { |
| | | .menu-scatter-chart-edit-box:hover { |
| | | z-index: 1; |
| | | box-shadow: 0px 0px 4px #1890ff; |
| | | } |
| | |
| | | this.props.updateConfig(component) |
| | | } |
| | | |
| | | checkComponent = (component) => { |
| | | this.updateComponent(component) |
| | | |
| | | let _item = null |
| | | component.search.forEach(item => { |
| | | if (!_item && item.focus) { |
| | | _item = item |
| | | } |
| | | }) |
| | | if (_item) { |
| | | this.handleSearch(_item) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 搜索条件顺序调整,或拖拽添加 |
| | | */ |
| | |
| | | <Icon className="plus" title="添加" onClick={this.addSearch} type="plus" /> |
| | | <WrapComponent config={card} updateConfig={this.updateComponent}/> |
| | | <CopyComponent type="mainsearch" card={card}/> |
| | | <PasteComponent config={card} options={['search', 'form']} updateConfig={this.updateComponent} /> |
| | | <PasteComponent config={card} options={['search', 'form']} updateConfig={this.checkComponent} /> |
| | | <Icon className="style" title="调整样式" onClick={this.changeStyle} type="font-colors" /> |
| | | <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> |
| | | </div> |
| | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') |
| | | if (res.setting.dataresource) { |
| | | res.setting.dataresource = res.setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | } |
| | | res.scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | this.setState({loading: false, visible: false}) |
| | | this.props.updateConfig({...config, ...res}) |
| | | }, () => { |
| | |
| | | getcomponentmarks(menu, config) |
| | | |
| | | let _setting = fromJS(config.setting).toJS() |
| | | let scripts = fromJS(config.scripts).toJS() |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig') |
| | | if (_setting.dataresource) { |
| | | _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | } |
| | | scripts && scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | scripts, |
| | | columns: fromJS(config.columns).toJS(), |
| | | setting: _setting, |
| | | scripts: fromJS(config.scripts).toJS(), |
| | | searches: search, |
| | | varMarks: Marks |
| | | }) |
| | |
| | | _dataresource = setting.dataresource || '' |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | _dataresource = _dataresource.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | _customScript = _customScript.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '') |
| | |
| | | _customScript = _customScript.replace(reg, '0') |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | // 正则替换 |
| | | let _regoptions = [] |
| | | let _fields = [] |
| | |
| | | import Carousel1 from '@/assets/mobimg/carousel1.png' |
| | | import form from '@/assets/mobimg/form.png' |
| | | import dashboard from '@/assets/mobimg/dashboard.png' |
| | | import ratioboard from '@/assets/mobimg/ratioboard.png' |
| | | import scatter from '@/assets/mobimg/scatter.png' |
| | | import tree from '@/assets/mobimg/tree.png' |
| | | |
| | |
| | | { type: 'menu', url: Pie3, component: 'pie', subtype: 'nest', title: '嵌套饼图', width: 12 }, |
| | | { type: 'menu', url: Pie2, component: 'pie', subtype: 'nightingale', title: '南丁格尔图', width: 12 }, |
| | | { type: 'menu', url: dashboard, component: 'dashboard', subtype: 'dashboard', title: '仪表盘', width: 12 }, |
| | | { type: 'menu', url: ratioboard, component: 'dashboard', subtype: 'ratioboard', title: '占比图', width: 12 }, |
| | | { type: 'menu', url: scatter, component: 'scatter', subtype: 'scatter', title: '散点图', width: 24 }, |
| | | { type: 'menu', url: Editor, component: 'editor', subtype: 'brafteditor', title: '富文本', width: 24 }, |
| | | { type: 'menu', url: SandBox, component: 'code', subtype: 'sandbox', title: '自定义', width: 24 }, |
| | |
| | | import form from '@/assets/mobimg/form.png' |
| | | import Login from '@/assets/mobimg/login.png' |
| | | import dashboard from '@/assets/mobimg/dashboard.png' |
| | | import ratioboard from '@/assets/mobimg/ratioboard.png' |
| | | import scatter from '@/assets/mobimg/scatter.png' |
| | | import tree from '@/assets/mobimg/tree.png' |
| | | |
| | |
| | | { type: 'menu', url: Pie3, component: 'pie', subtype: 'nest', title: '嵌套饼图', width: 12 }, |
| | | { type: 'menu', url: Pie2, component: 'pie', subtype: 'nightingale', title: '南丁格尔图', width: 12 }, |
| | | { type: 'menu', url: dashboard, component: 'dashboard', subtype: 'dashboard', title: '仪表盘', width: 12 }, |
| | | { type: 'menu', url: ratioboard, component: 'dashboard', subtype: 'ratioboard', title: '占比图', width: 12 }, |
| | | { type: 'menu', url: scatter, component: 'scatter', subtype: 'scatter', title: '散点图', width: 24 }, |
| | | { type: 'menu', url: Editor, component: 'editor', subtype: 'brafteditor', title: '富文本', width: 24 }, |
| | | { type: 'menu', url: SandBox, component: 'code', subtype: 'sandbox', title: '自定义', width: 24 }, |
| | |
| | | }, |
| | | }) |
| | | |
| | | registerShape('point', 'hidden', { |
| | | draw(cfg, container) { |
| | | return container.addGroup({}) |
| | | } |
| | | }) |
| | | |
| | | class DashboardChart extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.any, // 父级Id |
| | |
| | | const { config, data, initdata, BID } = this.props |
| | | let _config = fromJS(config).toJS() |
| | | |
| | | let _data = {} |
| | | let _data = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | |
| | | |
| | | if (_sync && data) { |
| | | _data = data[_config.dataName] || {} |
| | | if (_data && Array.isArray(_data)) { |
| | | _data = _data[0] || {} |
| | | } |
| | | _data = data[config.dataName] || [] |
| | | _sync = false |
| | | } else if (_sync && initdata) { |
| | | _data = initdata || {} |
| | | _data = initdata || [] |
| | | _sync = false |
| | | } |
| | | |
| | | if (_config.subtype === 'ratioboard') { |
| | | _data = _data || [] |
| | | } else { |
| | | if (_data && Array.isArray(_data)) { |
| | | _data = _data[0] || {} |
| | | } else { |
| | | _data = {} |
| | | } |
| | | _sync = false |
| | | } |
| | | |
| | | let height = config.plot.height || 400 |
| | |
| | | }, () => { |
| | | if (config.setting.sync !== 'true' && config.setting.onload === 'true') { |
| | | this.loadData() |
| | | } else if (config.setting.sync === 'true' && _data) { |
| | | } else if (config.setting.sync === 'true') { |
| | | this.handleData() |
| | | } |
| | | }) |
| | |
| | | const { sync, config } = this.state |
| | | |
| | | if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | let _data = {} |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || {} |
| | | } |
| | | if (_data.hasOwnProperty(config.plot.valueField)) { |
| | | _data.value = _data[config.plot.valueField] |
| | | let _data = null |
| | | |
| | | if (config.subtype === 'ratioboard') { |
| | | _data = [] |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || [] |
| | | } |
| | | } else { |
| | | _data = {} |
| | | if (nextProps.data && nextProps.data[config.dataName]) { |
| | | _data = nextProps.data[config.dataName] || {} |
| | | } |
| | | if (_data.hasOwnProperty(config.plot.valueField)) { |
| | | _data.value = _data[config.plot.valueField] |
| | | } |
| | | } |
| | | |
| | | this.setState({sync: false, data: _data}, () => { |
| | |
| | | if (_element) { |
| | | _element.innerHTML = '' |
| | | } |
| | | this.dashboardrender() |
| | | this.viewrender() |
| | | } |
| | | |
| | | async loadData (hastimer) { |
| | |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | let data = {} |
| | | if (result.data && result.data[0] && result.data[0].hasOwnProperty(config.plot.valueField)) { |
| | | data.value = result.data[0][config.plot.valueField] |
| | | let data = null |
| | | if (config.subtype === 'ratioboard') { |
| | | data = result.data || [] |
| | | } else { |
| | | let data = {} |
| | | if (result.data && result.data[0] && result.data[0].hasOwnProperty(config.plot.valueField)) { |
| | | data.value = result.data[0][config.plot.valueField] |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | } |
| | | } |
| | | |
| | | viewrender = () => { |
| | | const { config } = this.state |
| | | if (config.subtype === 'ratioboard') { |
| | | this.ratioboardrender() |
| | | } else { |
| | | this.dashboardrender() |
| | | } |
| | | } |
| | | |
| | | getratiodata = () => { |
| | | const { data, plot } = this.state |
| | | |
| | | let colors = {} |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | plot.colors.forEach(item => { |
| | | colors[item.tick] = item.color |
| | | }) |
| | | } |
| | | |
| | | return data.map(item => { |
| | | let val = +item[plot.valueField] |
| | | let type = item[plot.labelField] || '' |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | return { |
| | | type: type, |
| | | value: val, |
| | | $percent: val / plot.maxValue, |
| | | $color: colors[type] || '#1890ff' |
| | | } |
| | | }) |
| | | } |
| | | |
| | | ratioboardrender = () => { |
| | | const { plot, chartId } = this.state |
| | | |
| | | const data = this.getratiodata() |
| | | |
| | | const chart = new Chart({ |
| | | container: chartId, |
| | | autoFit: true, |
| | | height: plot.height, |
| | | }) |
| | | |
| | | chart.data(data) |
| | | chart.coordinate('polar', { |
| | | startAngle: -Math.PI / 2, |
| | | endAngle: 3 * Math.PI / 2, |
| | | radius: (plot.radius || 75) / 100 |
| | | }) |
| | | chart.scale('$percent', { |
| | | min: 0, |
| | | max: 1, |
| | | tickInterval: 1, |
| | | }) |
| | | chart.axis(false) |
| | | chart.facet('rect', { |
| | | fields: ['type'], |
| | | showTitle: false, |
| | | eachView: function eachView(view, facet) { |
| | | const data = facet.data[0] |
| | | |
| | | view.point().position('').shape('hidden') |
| | | |
| | | view.annotation().arc({ |
| | | top: false, |
| | | start: [0, 1], |
| | | end: [0.9999, 1], |
| | | style: { |
| | | stroke: plot.backColor, |
| | | lineWidth: 10 |
| | | } |
| | | }) |
| | | |
| | | let _tick = data.$percent |
| | | if (_tick >= 1) { |
| | | _tick = 0.9999 |
| | | } |
| | | |
| | | view.annotation().arc({ |
| | | start: [0, 1], |
| | | end: [_tick, 1], |
| | | style: { |
| | | stroke: data.$color, |
| | | lineWidth: 10, |
| | | } |
| | | }) |
| | | // 仪表盘信息 |
| | | let text = '' |
| | | if (plot.percent === 'true') { |
| | | text = +(data.$percent * 100).toFixed(2) + '%' |
| | | } else { |
| | | text = data.value |
| | | } |
| | | |
| | | view.annotation().text({ |
| | | position: ['50%', '45%'], |
| | | content: data.type, |
| | | style: { |
| | | fontSize: plot.fontSize * 0.8, |
| | | fill: plot.labelColor, |
| | | fontWeight: 300, |
| | | textAlign: 'center' |
| | | }, |
| | | offsetX: 0 |
| | | }) |
| | | view.annotation().text({ |
| | | position: ['50%', '55%'], |
| | | content: text, |
| | | style: { |
| | | fontSize: plot.fontSize, |
| | | fill: plot.labelColor, |
| | | fontWeight: 500, |
| | | textAlign: 'center' |
| | | }, |
| | | offsetX: 0, |
| | | offsetY: 10 |
| | | }) |
| | | } |
| | | }) |
| | | chart.render() |
| | | } |
| | | |
| | | /** |
| | | * @description 仪表盘渲染 |
| | | */ |
| | |
| | | |
| | | this.setState({loading: true}) |
| | | this.verifyRef.submitDataSource().then(res => { |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') |
| | | res.scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | if (res.setting.dataresource) { |
| | | res.setting.dataresource = res.setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({loading: false, visible: false}) |
| | | this.props.updateConfig({...config, ...res}) |
| | |
| | | UNSAFE_componentWillMount() { |
| | | const { config } = this.props |
| | | |
| | | let _setting = fromJS(config.setting).toJS() |
| | | let _scripts = fromJS(config.scripts).toJS() |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig') |
| | | _scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | if (_setting.dataresource) { |
| | | _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | setting: fromJS(config.setting).toJS(), |
| | | setting: _setting, |
| | | columns: fromJS(config.columns).toJS(), |
| | | scripts: fromJS(config.scripts).toJS() |
| | | scripts: _scripts |
| | | }) |
| | | } |
| | | |
| | |
| | | if (setting.execute !== 'false') { |
| | | _dataresource = setting.dataresource || '' |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | _dataresource = _dataresource.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | _customScript = _customScript.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | this.settingRef.handleConfirm().then(res => { |
| | | this.settingRef.handleConfirm().then(setting => { |
| | | let res = this.resetSetting(setting) |
| | | this.setState({ |
| | | visible: false, |
| | | loading: false |
| | |
| | | const { menu } = this.state |
| | | |
| | | this.settingRef.handleConfirm('func').then(setting => { |
| | | let _config = {...config, setting: setting} |
| | | let res = this.resetSetting(setting) |
| | | let _config = {...config, setting: res} |
| | | let newLText = Utils.formatOptions(FuncUtils.getTableFunc(setting, menu, _config)) // 创建存储过程sql |
| | | let DelText = Utils.formatOptions(FuncUtils.dropfunc(setting.innerFunc)) // 删除存储过程sql |
| | | |
| | |
| | | const { menu } = this.state |
| | | |
| | | this.settingRef.handleConfirm('interface').then(setting => { |
| | | let _config = {...config, setting: setting} |
| | | let res = this.resetSetting(setting) |
| | | let _config = {...config, setting: res} |
| | | let _menu = { |
| | | type: config.Template === 'CommonTable' ? 'main' : 'subtable', |
| | | MenuID: menu.MenuID, |
| | |
| | | }) |
| | | } |
| | | |
| | | resetSetting = (s) => { |
| | | let setting = fromJS(s).toJS() |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') |
| | | setting.scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | setting.preScripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | setting.cbScripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | if (setting.dataresource) { |
| | | setting.dataresource = setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | return setting |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig') |
| | | _scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | _preScripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | _cbScripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | if (_setting.dataresource) { |
| | | _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | setting: _setting, |
| | | search: _search, |
| | |
| | | if (setting.default === 'false') { |
| | | _dataresource = '' |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | _dataresource = _dataresource.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | _customScript = _customScript.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | ` |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | _customScript = _customScript.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@userName@|@fullName@|@login_city@/ig, `''`) |
| | | // 外联数据库替换 |
| | |
| | | loading: true |
| | | }) |
| | | this.settingRef.handleConfirm().then(res => { |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') |
| | | res.scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | if (res.dataresource) { |
| | | res.dataresource = res.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | } |
| | | }) |
| | | } |
| | | this.setState({ |
| | | visible: false, |
| | | loading: false |
| | |
| | | let _setting = fromJS(config.setting).toJS() |
| | | let _scripts = _setting.scripts || [] |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig') |
| | | _scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | if (_setting.dataresource) { |
| | | _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | setting: _setting, |
| | | scripts: _scripts |
| | |
| | | if (setting.default === 'false') { |
| | | _dataresource = '' |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | _dataresource = _dataresource.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | _customScript = _customScript.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | LText: this.props.initsql + _prevCustomScript + _backCustomScript + tail |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | param.LText = param.LText.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | // 数据权限 |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | |
| | |
| | | LText: this.props.initsql + values.sql |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | param.LText = param.LText.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | // 数据权限 |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | |
| | |
| | | LText: this.props.initsql + _initCustomScript + _prevCustomScript + _backCustomScript + tail |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(item => { |
| | | let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') |
| | | param.LText = param.LText.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | } |
| | | |
| | | // 数据权限 |
| | | param.LText = param.LText.replace(/@\$|\$@/ig, '') |
| | | // check |
| | |
| | | _verify.scripts = _verify.scripts || [] |
| | | _verify.cbScripts = _verify.cbScripts || [] |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig') |
| | | _verify.customverifys.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | _verify.scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | _verify.cbScripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | verify: _verify |
| | | }) |
| | |
| | | verify.noteCode = '' |
| | | } |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') |
| | | verify.customverifys.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | verify.scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | verify.cbScripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | if (msg) { |
| | | confirm({ |
| | | content: msg + '未保存,确定提交吗?', |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 生成替换函数列表 |
| | | */ |
| | | export function setGLOBFuncs () { |
| | | window.GLOB.funcs = [] |
| | | if (!window.GLOB.WebSql && !window.GLOB.IndexDB) { |
| | | return |
| | | } |
| | | |
| | | if (window.GLOB.WebSql) { |
| | | window.GLOB.WebSql.transaction(tx => { |
| | | tx.executeSql("SELECT * FROM FUNCS", [], (tx, results) => { |
| | | let rows = results.rows |
| | | if (!rows || rows.length === 0) return |
| | | for (let i = 0; i < rows.length; i++) { |
| | | window.GLOB.funcs.push({ |
| | | func_code: rows[i].func_code, |
| | | key_sql: window.decodeURIComponent(window.atob(rows[i].key_sql)) |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | let objectStore = window.GLOB.IndexDB.transaction('funcs').objectStore('funcs') |
| | | |
| | | objectStore.openCursor().onsuccess = (event) => { |
| | | let cursor = event.target.result |
| | | |
| | | if (cursor) { |
| | | window.GLOB.funcs.push({ |
| | | func_code: cursor.value.func_code, |
| | | key_sql: window.decodeURIComponent(window.atob(cursor.value.key_sql)) |
| | | }) |
| | | cursor.continue() |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @description 创建存储过程类 |
| | | */ |
| | | export class FuncUtils { |
| | |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Header from './header' |
| | | import { setGLOBFuncs } from '@/utils/utils.js' |
| | | import Sidemenu from './sidemenu' |
| | | |
| | | import './index.scss' |
| | |
| | | const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS |
| | | |
| | | class Design extends Component { |
| | | componentDidMount() { |
| | | setGLOBFuncs() |
| | | } |
| | | |
| | | render () { |
| | | return ( |
| | | <div className="mk-main-view"> |
| | |
| | | |
| | | import Api from '@/api' |
| | | import options from '@/store/options.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import Utils, { setGLOBFuncs } from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/mob.js' |
| | | import enUS from '@/locales/en-US/mob.js' |
| | | import antdEnUS from 'antd/es/locale/en_US' |
| | |
| | | setTimeout(() => { |
| | | this.updateCustomComponent() |
| | | this.getAppPictures() |
| | | setGLOBFuncs() |
| | | }, 1000) |
| | | } |
| | | |
| | |
| | | import { ConfigProvider, notification, Modal, Collapse, Switch, Button, message, Spin } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import Utils, { setGLOBFuncs } from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/mob.js' |
| | | import enUS from '@/locales/en-US/mob.js' |
| | | import antdEnUS from 'antd/es/locale/en_US' |
| | |
| | | this.updateCustomComponent() |
| | | this.getAppPictures() |
| | | this.getSmStemp() |
| | | setGLOBFuncs() |
| | | }, 1000) |
| | | } |
| | | |
| | |
| | | import { ConfigProvider, notification, Modal, Collapse, Switch, Button, Icon, message, Spin } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import Utils, { setGLOBFuncs } from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/mob.js' |
| | | import enUS from '@/locales/en-US/mob.js' |
| | | import antdEnUS from 'antd/es/locale/en_US' |
| | |
| | | this.updateCustomComponent() |
| | | this.getAppPictures() |
| | | this.getSmStemp() |
| | | setGLOBFuncs() |
| | | }, 1000) |
| | | } |
| | | |