| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MKEInput from './mkInput' |
| | | import MKNumberInput from './mkNumberInput' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MKSelect from './mkSelect' |
| | | import './index.scss' |
| | | |
| | |
| | | |
| | | class ModalForm extends Component { |
| | | static propTpyes = { |
| | | formlist: PropTypes.array, // 表单列表 |
| | | inputSubmit: PropTypes.func // input回车提交 |
| | | formlist: PropTypes.array, |
| | | inputSubmit: PropTypes.func, |
| | | transVals: PropTypes.func, |
| | | } |
| | | |
| | | state = { |
| | |
| | | let supItem = fieldMap.get(key) |
| | | let supval = supItem.initval |
| | | |
| | | if (supItem.initval && supItem.type !== 'checkbox' && JSON.stringify(supItem.initval) === '[]') { |
| | | if (supItem.initval && supItem.type !== 'checkbox' && supItem.type !== 'multiselect' && JSON.stringify(supItem.initval) === '[]') { |
| | | supval = '' |
| | | } |
| | | |
| | |
| | | |
| | | } else if (supItem.hidden) { |
| | | cell.hidden = true |
| | | } else if (supItem.type === 'checkbox') { |
| | | } else if (supItem.type === 'checkbox' || supItem.type === 'multiselect') { |
| | | let vals = [...supval, ...item.values] |
| | | if (vals.length === new Set(vals).size) { |
| | | cell.hidden = true |
| | |
| | | this.record = {...this.record, ...values} |
| | | |
| | | if (!item) return |
| | | |
| | | if (item.$trans) { |
| | | this.props.transVals && this.props.transVals(values, item.field) |
| | | } |
| | | |
| | | if (item.controlFields) { |
| | | let map = new Map() |
| | |
| | | let reset = (current) => { |
| | | let val = this.record[current.field] |
| | | |
| | | if (val && current.type !== 'checkbox' && JSON.stringify(val) === '[]') { |
| | | if (val && current.type !== 'checkbox' && current.type !== 'multiselect' && JSON.stringify(val) === '[]') { |
| | | val = '' |
| | | } |
| | | |
| | |
| | | |
| | | if (current.hidden) { |
| | | m.hidden = true |
| | | } else if (current.type === 'checkbox') { |
| | | } else if (current.type === 'checkbox' || current.type === 'multiselect') { |
| | | let vals = [...val, ...cell.values] |
| | | if (vals.length !== new Set(vals).size) { |
| | | m.hidden = false |
| | |
| | | map.set(cell.field, cell) |
| | | }) |
| | | |
| | | item.callback(map, this.record) |
| | | item.callback(map, this.record, MKEmitter) |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(cell => { |
| | |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('mkFP', this.mkFormHandle) |
| | | MKEmitter.addListener('mkFC', this.mkFormControl) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { config } = this.state |
| | | |
| | | if (!is(fromJS(config.oriOptions), fromJS(nextProps.config.oriOptions))) { |
| | | this.setState({ |
| | | config: fromJS(nextProps.config).toJS(), |
| | | options: fromJS(nextProps.config.options).toJS() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('mkFP', this.mkFormHandle) |
| | | MKEmitter.removeListener('mkFC', this.mkFormControl) |
| | | } |
| | | |
| | | mkFormControl = (type, field, value) => { |
| | | if (field !== this.props.config.field) return |
| | | |
| | | if (type === 'input') { |
| | | this.setState({value}) |
| | | this.props.onChange(value, {}) |
| | | } |
| | | } |
| | | |
| | | mkFormHandle = (field, parentId) => { |
| | |
| | | value: val |
| | | }) |
| | | |
| | | this.props.onChange(val) |
| | | this.props.onChange(val, {}) |
| | | |
| | | config.linkFields && config.linkFields.forEach((m, i) => { |
| | | setTimeout(() => { |
| | |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.mutilselectChange} |
| | | > |
| | | {options.map(option => |
| | | <Select.Option key={option.value} disabled={option.disabled} value={option.value}>{option.label || option.text}</Select.Option> |
| | | {options.map((option, i) => |
| | | <Select.Option key={i} disabled={option.disabled} value={option.value || option.field}>{option.label || option.text}</Select.Option> |
| | | )} |
| | | </Select>) |
| | | } |
| | |
| | | return [ |
| | | { |
| | | type: 'text', |
| | | key: 'title', |
| | | field: 'title', |
| | | label: '标题', |
| | | initVal: card.title, |
| | | initval: card.title, |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'name', |
| | | field: 'name', |
| | | label: '组件名称', |
| | | initVal: card.name, |
| | | initval: card.name, |
| | | tooltip: '用于组件间的区分。', |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'width', |
| | | field: 'width', |
| | | label: '宽度', |
| | | initVal: card.width, |
| | | initval: card.width, |
| | | tooltip: '栅格布局,每行等分为24列。', |
| | | min: 1, |
| | | max: 24, |
| | |
| | | }, |
| | | { |
| | | type: 'styleInput', |
| | | key: 'height', |
| | | field: 'height', |
| | | label: '图表高度', |
| | | initVal: card.height, |
| | | initval: card.height, |
| | | tooltip: '图表绘图区域的高度,不包括标题及内外边距。', |
| | | required: true, |
| | | options: ['px', 'vh', 'vw'] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'permission', |
| | | field: 'permission', |
| | | label: '权限验证', |
| | | initVal: card.permission || 'false', |
| | | initval: card.permission || 'false', |
| | | required: false, |
| | | options: [ |
| | | {value: 'true', text: '启用'}, |
| | | {value: 'false', text: '禁用'}, |
| | | {value: 'true', label: '启用'}, |
| | | {value: 'false', label: '禁用'}, |
| | | ], |
| | | forbid: !appType || ispop || isprint |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'cacheLocal', |
| | | field: 'cacheLocal', |
| | | label: '本地缓存', |
| | | initVal: card.cacheLocal || 'true', |
| | | initval: card.cacheLocal || 'true', |
| | | required: false, |
| | | options: [ |
| | | {value: 'true', text: '继承菜单'}, |
| | | {value: 'false', text: '禁用'}, |
| | | {value: 'true', label: '继承菜单'}, |
| | | {value: 'false', label: '禁用'}, |
| | | ], |
| | | forbid: ispop || isprint |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'blacklist', |
| | | type: 'multiselect', |
| | | field: 'blacklist', |
| | | label: '黑名单', |
| | | initVal: card.blacklist || [], |
| | | multi: true, |
| | | initval: card.blacklist || [], |
| | | required: false, |
| | | options: roleList, |
| | | forbid: !!appType || isprint |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'click', |
| | | field: 'click', |
| | | label: '点击事件', |
| | | initVal: card.click || '', |
| | | initval: card.click || '', |
| | | tooltip: '点击柱子时触发的事件,启用自定义设置时无效。', |
| | | required: false, |
| | | forbid: appType === 'mob' || card.chartType !== 'bar', |
| | |
| | | {value: '', label: '数据切换'}, |
| | | {value: 'menu', label: '菜单'}, |
| | | {value: 'menus', label: '菜单组'} |
| | | ], |
| | | controlFields: [ |
| | | {field: 'menu', values: ['menu']}, |
| | | {field: 'open', values: ['menu', 'menus']}, |
| | | {field: 'joint', values: ['menu', 'menus']}, |
| | | {field: 'menuType', values: ['menus']}, |
| | | {field: 'menus', values: ['menus']}, |
| | | ] |
| | | }, |
| | | { |
| | | type: appType === '' ? 'cascader' : 'select', |
| | | key: 'menu', |
| | | field: 'menu', |
| | | label: '关联菜单', |
| | | initVal: card.menu || (appType === '' ? [] : ''), |
| | | initval: card.menu || (appType === '' ? [] : ''), |
| | | tooltip: '在使用柱形图且未启用自定义设置时有效。', |
| | | required: true, |
| | | forbid: appType === 'mob' || card.chartType !== 'bar', |
| | |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'menuType', |
| | | field: 'menuType', |
| | | label: '菜单类型', |
| | | initVal: card.menuType || '', |
| | | initval: card.menuType || '', |
| | | required: true, |
| | | forbid: appType === 'mob' || card.chartType !== 'bar', |
| | | hidden: card.click !== 'menus', |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'open', |
| | | field: 'open', |
| | | label: '打开方式', |
| | | initVal: card.open || 'blank', |
| | | initval: card.open || 'blank', |
| | | required: false, |
| | | options: [ |
| | | {value: 'blank', label: '新窗口'}, |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'joint', |
| | | field: 'joint', |
| | | label: '参数拼接', |
| | | initVal: card.joint || 'true', |
| | | initval: card.joint || 'true', |
| | | required: false, |
| | | options: [ |
| | | {value: 'true', label: '是'}, |
| | |
| | | }, |
| | | { |
| | | type: 'table', |
| | | key: 'menus', |
| | | field: 'menus', |
| | | label: '菜单组', |
| | | initVal: card.menus || [], |
| | | initval: card.menus || [], |
| | | required: true, |
| | | span: 24, |
| | | actions: ['view'], |
| | |
| | | |
| | | let labelOptions = [{ |
| | | value: 'false', |
| | | text: '隐藏' |
| | | label: '隐藏' |
| | | }, { |
| | | value: 'true', |
| | | text: '显示' |
| | | label: '显示' |
| | | }] |
| | | |
| | | if (card.chartType === 'bar') { |
| | | labelOptions[1].text = '外部' |
| | | labelOptions[1].label = '外部' |
| | | labelOptions.push(...[{ |
| | | value: 'top', |
| | | text: '顶部' |
| | | label: '顶部' |
| | | }, { |
| | | value: 'middle', |
| | | text: '中间' |
| | | label: '中间' |
| | | }, { |
| | | value: 'bottom', |
| | | text: '底部' |
| | | label: '底部' |
| | | }]) |
| | | } |
| | | |
| | | let _label = card.label || 'false' |
| | | |
| | | return [ |
| | | { |
| | | type: 'radio', |
| | | key: 'datatype', |
| | | field: 'datatype', |
| | | label: '数据类型', |
| | | initVal: card.datatype || 'query', |
| | | initval: card.datatype || 'query', |
| | | tooltip: '统计图表适用于展示数据类型为动态值。', |
| | | required: false, |
| | | $trans: true, |
| | | options: [ |
| | | { value: 'query', text: '查询' }, |
| | | { value: 'statistics', text: '统计' } |
| | | { value: 'query', label: '查询' }, |
| | | { value: 'statistics', label: '统计' } |
| | | ], |
| | | controlFields: [ |
| | | {field: 'InfoType', values: ['statistics']}, |
| | | {field: 'InfoValue', values: ['statistics']}, |
| | | {field: 'Yaxis', values: ['query']}, |
| | | ] |
| | | }, { |
| | | type: 'select', |
| | | key: 'Xaxis', |
| | | field: 'Xaxis', |
| | | label: 'X-轴', |
| | | initVal: card.Xaxis || '', |
| | | initval: card.Xaxis || '', |
| | | required: true, |
| | | options: xfields |
| | | }, { |
| | | type: 'select', |
| | | key: 'InfoType', |
| | | field: 'InfoType', |
| | | label: '类型', |
| | | initVal: card.InfoType || '', |
| | | hidden: card.datatype !== 'statistics', |
| | | initval: card.InfoType || '', |
| | | required: true, |
| | | options: xfields |
| | | }, { |
| | | type: 'select', |
| | | key: 'InfoValue', |
| | | field: 'InfoValue', |
| | | label: '值', |
| | | initVal: card.InfoValue || '', |
| | | hidden: card.datatype !== 'statistics', |
| | | initval: card.InfoValue || '', |
| | | required: true, |
| | | options: yfields |
| | | }, { |
| | | type: 'select', |
| | | key: 'legend', |
| | | field: 'legend', |
| | | label: '图例位置', |
| | | initVal: card.legend || 'bottom', |
| | | initval: card.legend || 'bottom', |
| | | required: false, |
| | | options: [ |
| | | { field: 'bottom', label: '下' }, |
| | |
| | | { field: 'hidden', label: '隐藏' } |
| | | ] |
| | | }, { |
| | | type: 'select', |
| | | key: 'Yaxis', |
| | | type: 'multiselect', |
| | | field: 'Yaxis', |
| | | label: 'Y-轴', |
| | | initVal: card.Yaxis || [], |
| | | multi: true, // 多选 |
| | | hidden: card.datatype === 'statistics', |
| | | initval: card.Yaxis || [], |
| | | required: true, |
| | | options: yfields |
| | | }, { |
| | | type: 'select', |
| | | key: 'shape', |
| | | field: 'shape', |
| | | label: '形状', |
| | | initVal: card.shape || (shapes[0] && shapes[0].field), |
| | | initval: card.shape || (shapes[0] && shapes[0].field), |
| | | required: false, |
| | | options: shapes |
| | | }, { |
| | | type: 'radio', |
| | | key: 'tooltip', |
| | | field: 'tooltip', |
| | | label: '悬浮提示', |
| | | initVal: card.tooltip || 'true', |
| | | initval: card.tooltip || 'true', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '显示' |
| | | label: '显示' |
| | | }, { |
| | | value: 'false', |
| | | text: '隐藏' |
| | | label: '隐藏' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'point', |
| | | field: 'point', |
| | | label: '点图', |
| | | initVal: card.point || 'false', |
| | | initval: card.point || 'false', |
| | | required: false, |
| | | forbid: !['line'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'true', |
| | | text: '显示' |
| | | label: '显示' |
| | | }, { |
| | | value: 'false', |
| | | text: '隐藏' |
| | | label: '隐藏' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'transpose', |
| | | field: 'transpose', |
| | | label: '变换', |
| | | initVal: card.transpose || 'false', |
| | | initval: card.transpose || 'false', |
| | | tooltip: '横纵坐标轴交换', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '是' |
| | | label: '是' |
| | | }, { |
| | | value: 'false', |
| | | text: '否' |
| | | label: '否' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'show', |
| | | field: 'show', |
| | | label: '显示', |
| | | initVal: card.show || 'value', |
| | | initval: card.show || 'value', |
| | | tooltip: '当使用自定义设置时,可在显示(值/%)处单独设置显示类型。注:自定义为空时使用此处设置。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'value', |
| | | text: '数值' |
| | | label: '数值' |
| | | }, { |
| | | value: 'percent', |
| | | text: '百分比' |
| | | label: '百分比' |
| | | }, { |
| | | value: 'thdSeparator', |
| | | text: '千分位' |
| | | label: '千分位' |
| | | }] |
| | | }, { |
| | | type: labelOptions.length > 20 ? 'select' : 'radio', |
| | | key: 'label', |
| | | type: 'radio', |
| | | field: 'label', |
| | | label: '标注', |
| | | initVal: _label, |
| | | initval: card.label || 'false', |
| | | tooltip: '图形节点处的数值。', |
| | | required: false, |
| | | options: labelOptions |
| | | options: labelOptions, |
| | | controlFields: [ |
| | | {field: 'labelColor', values: ['true']} |
| | | ] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'labelColor', |
| | | field: 'labelColor', |
| | | label: '标注颜色', |
| | | initVal: card.labelColor || 'system', |
| | | initval: card.labelColor || 'system', |
| | | tooltip: '使用系统色时,使用色系选项设置的系统颜色,使用自定义为颜色设置中定义的图形颜色。', |
| | | required: false, |
| | | hidden: _label !== 'true', |
| | | options: [{ |
| | | value: 'system', |
| | | text: '系统' |
| | | label: '系统' |
| | | }, { |
| | | value: 'custom', |
| | | text: '自定义' |
| | | label: '自定义' |
| | | }] |
| | | // }, { |
| | | // type: 'radio', |
| | | // field: 'labelValue', |
| | | // label: '标注值', |
| | | // initval: card.labelValue || 'default', |
| | | // tooltip: '标注值的显示规则。', |
| | | // required: false, |
| | | // options: [{ |
| | | // value: 'default', |
| | | // label: '默认' |
| | | // }, { |
| | | // value: 'zero', |
| | | // label: '隐藏 0 值' |
| | | // }], |
| | | }, { |
| | | type: 'radio', |
| | | key: 'labelValue', |
| | | label: '标注值', |
| | | initVal: card.labelValue || 'default', |
| | | tooltip: '标注值的显示规则。', |
| | | required: false, |
| | | hidden: _label === 'false', |
| | | options: [{ |
| | | value: 'default', |
| | | text: '默认' |
| | | }, { |
| | | value: 'zero', |
| | | text: '隐藏 0 值' |
| | | }], |
| | | }, { |
| | | type: 'radio', |
| | | key: 'adjust', |
| | | field: 'adjust', |
| | | label: '多柱排列', |
| | | initVal: card.adjust || 'dodge', |
| | | initval: card.adjust || 'dodge', |
| | | required: false, |
| | | forbid: !['bar'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'dodge', |
| | | text: '分组' |
| | | label: '分组' |
| | | }, { |
| | | value: 'stack', |
| | | text: '堆叠' |
| | | label: '堆叠' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'area', |
| | | field: 'area', |
| | | label: '面积图', |
| | | initVal: card.area || 'false', |
| | | // tooltip: '仅在形状为smooth时有效。', |
| | | initval: card.area || 'false', |
| | | required: false, |
| | | forbid: ['bar'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'true', |
| | | text: '显示' |
| | | label: '显示' |
| | | }, { |
| | | value: 'false', |
| | | text: '不显示' |
| | | label: '不显示' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'repeat', |
| | | field: 'repeat', |
| | | label: '重复数据', |
| | | initVal: card.repeat || 'unrepeat', |
| | | initval: card.repeat || 'unrepeat', |
| | | required: false, |
| | | options: [{ |
| | | value: 'unrepeat', |
| | | text: '去重' |
| | | label: '去重' |
| | | }, { |
| | | value: 'average', |
| | | text: '平均' |
| | | label: '平均' |
| | | }, { |
| | | value: 'cumsum', |
| | | text: '累加' |
| | | label: '累加' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'coordinate', |
| | | field: 'coordinate', |
| | | label: '坐标', |
| | | initVal: card.coordinate || 'angle', |
| | | initval: card.coordinate || 'angle', |
| | | required: false, |
| | | options: [{ |
| | | value: 'angle', |
| | | text: '二维坐标' |
| | | label: '二维坐标' |
| | | }, { |
| | | value: 'polar', |
| | | text: '极坐标' |
| | | label: '极坐标' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'grid', |
| | | field: 'grid', |
| | | label: '网格线', |
| | | initVal: card.grid || 'show', |
| | | initval: card.grid || 'show', |
| | | required: false, |
| | | options: [{ |
| | | value: 'show', |
| | | text: '显示' |
| | | label: '显示' |
| | | }, { |
| | | value: 'hidden', |
| | | text: '隐藏' |
| | | label: '隐藏' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'y_line', |
| | | field: 'y_line', |
| | | label: 'y轴边线', |
| | | initVal: card.y_line || 'hidden', |
| | | initval: card.y_line || 'hidden', |
| | | tooltip: '图形左侧或右侧的边线。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'show', |
| | | text: '显示' |
| | | label: '显示' |
| | | }, { |
| | | value: 'hidden', |
| | | text: '隐藏' |
| | | label: '隐藏' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'download', |
| | | field: 'download', |
| | | label: '导出图片', |
| | | initVal: card.download || 'forbid', |
| | | initval: card.download || 'forbid', |
| | | required: false, |
| | | forbid: appType === 'mob', |
| | | options: [{ |
| | | value: 'forbid', |
| | | text: '禁用' |
| | | label: '禁用' |
| | | }, { |
| | | value: 'enable', |
| | | text: '启用' |
| | | label: '启用' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | key: 'empty', |
| | | field: 'empty', |
| | | label: '空值隐藏', |
| | | initVal: card.empty || 'show', |
| | | initval: card.empty || 'show', |
| | | tooltip: '当查询数据为空时,隐藏该组件。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'show', text: '否'}, |
| | | {value: 'hidden', text: '是'}, |
| | | {value: 'show', label: '否'}, |
| | | {value: 'hidden', label: '是'}, |
| | | ], |
| | | }, { |
| | | type: 'number', |
| | | key: 'barSize', |
| | | field: 'barSize', |
| | | label: '柱形宽度', |
| | | tooltip: '空值时,宽度自适应。', |
| | | min: 5, |
| | | max: 100, |
| | | decimal: 0, |
| | | initVal: card.barSize, |
| | | initval: card.barSize, |
| | | forbid: !['bar'].includes(card.chartType), |
| | | required: false |
| | | }, { |
| | | type: 'number', |
| | | key: 'barRadius', |
| | | field: 'barRadius', |
| | | label: '柱形圆角', |
| | | tooltip: '柱形图上端圆角。', |
| | | min: 0, |
| | | max: 200, |
| | | decimal: 0, |
| | | initVal: card.barRadius || 0, |
| | | initval: card.barRadius || 0, |
| | | forbid: !['bar'].includes(card.chartType), |
| | | required: false |
| | | }, { |
| | | type: 'number', |
| | | key: 'min', |
| | | field: 'min', |
| | | label: '最小值', |
| | | tooltip: 'y轴最小值,为空时自适应。', |
| | | initVal: card.min, |
| | | initval: card.min, |
| | | required: false |
| | | }, { |
| | | type: 'number', |
| | | key: 'max', |
| | | field: 'max', |
| | | label: '最大值', |
| | | tooltip: 'y轴最大值,为空时自适应。', |
| | | initVal: card.max, |
| | | initval: card.max, |
| | | required: false |
| | | }, { |
| | | type: 'number', |
| | | key: 'XLimit', |
| | | field: 'XLimit', |
| | | min: 2, |
| | | label: '字符限制', |
| | | tooltip: 'X轴最大字符限制。', |
| | | initVal: card.XLimit || 11, |
| | | initval: card.XLimit || 11, |
| | | forbid: appType === 'mob', |
| | | required: false |
| | | }, { |
| | | type: 'color', |
| | | key: 'color', |
| | | field: 'color', |
| | | label: '色系', |
| | | initVal: card.color || 'rgba(0, 0, 0, 0.65)', |
| | | initval: card.color || 'rgba(0, 0, 0, 0.65)', |
| | | tooltip: '坐标轴提示文字及示例的颜色。', |
| | | required: false |
| | | }, { |
| | | type: 'color', |
| | | key: 'lineColor', |
| | | field: 'lineColor', |
| | | label: '轴线颜色', |
| | | initVal: card.lineColor, |
| | | initval: card.lineColor, |
| | | tooltip: '坐标轴线的颜色,包括x轴、y轴及网格线。', |
| | | allowClear: true, |
| | | required: false |
| | | }, { |
| | | type: 'color', |
| | | key: 'selectColor', |
| | | label: '选中颜色', |
| | | initVal: card.selectColor || '', |
| | | tooltip: '选中柱形图的颜色,在交互效果《元素选中(多选)》和《元素选中(单选)》中有效,启用自定义设置时无效。', |
| | | forbid: !['bar'].includes(card.chartType), |
| | | allowClear: true, |
| | | required: false |
| | | }, { |
| | | type: 'number', |
| | | key: 'rotate', |
| | | field: 'rotate', |
| | | label: '旋转', |
| | | tooltip: '坐标轴标注文本的旋转角度。', |
| | | min: 0, |
| | | max: 360, |
| | | decimal: 0, |
| | | initVal: card.rotate, |
| | | initval: card.rotate, |
| | | forbid: appType !== 'mob', |
| | | required: false |
| | | }, { |
| | | type: 'select', |
| | | key: 'interaction', |
| | | type: 'multiselect', |
| | | field: 'interaction', |
| | | label: '交互效果', |
| | | initVal: card.interaction || [], |
| | | multi: true, |
| | | initval: card.interaction || [], |
| | | required: false, |
| | | forbid: appType === 'mob', |
| | | options: [ |
| | |
| | | { value: 'legend-active', label: '图例聚焦' }, |
| | | { value: 'legend-highlight', label: '图例高亮' }, |
| | | { value: 'brush', label: '选框过滤' }, |
| | | ], |
| | | controlFields: [ |
| | | {field: 'selectColor', values: ['element-selected', 'element-single-selected']}, |
| | | ] |
| | | }, { |
| | | type: 'color', |
| | | field: 'selectColor', |
| | | label: '选中颜色', |
| | | initval: card.selectColor || '', |
| | | tooltip: '选中柱形图的颜色,启用自定义设置时无效。', |
| | | forbid: !['bar'].includes(card.chartType), |
| | | allowClear: true, |
| | | required: false |
| | | } |
| | | ] |
| | | } |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Modal, Form, Row, Col, Select, Radio, notification, Tooltip, Input, InputNumber, Tabs, Button } from 'antd' |
| | | import { QuestionCircleOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons' |
| | | import { Modal, Form, Col, Radio, notification, Tabs, Button } from 'antd' |
| | | import { EditOutlined, PlusOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import { chartColors } from '@/utils/option.js' |
| | | import { getBaseForm, getOptionForm } from './formconfig' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import ColorSketch from '@/mob/colorsketch' |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | | const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) |
| | | const NormalForm = asyncComponent(() => import('@/menu/components/share/normalform')) |
| | | const ModalForm = asyncComponent(() => import('@/components/normalform/modalform')) |
| | | |
| | | class LineChartDrawerForm extends Component { |
| | | static propTpyes = { |
| | |
| | | |
| | | state = { |
| | | view: 'base', |
| | | ramp: 'false', |
| | | visible: false, |
| | | datatype: '', |
| | | plot: null, |
| | |
| | | this.setState({ |
| | | visible: true, |
| | | view: 'base', |
| | | ramp: plot.ramp || 'false', |
| | | datatype: plot.datatype || 'query', |
| | | fieldName: fieldName, |
| | | plot: plot, |
| | |
| | | formlist: getOptionForm(plot, config.columns), |
| | | cusColumns: this.getCusColumns(plot.zoomYaxis) |
| | | }) |
| | | } |
| | | |
| | | radioChange = (e, key) => { |
| | | const { formlist } = this.state |
| | | let val = e.target.value |
| | | |
| | | if (key === 'datatype') { |
| | | this.setState({ |
| | | datatype: val, |
| | | formlist: fromJS(formlist).toJS().map(item => { |
| | | if (['Yaxis'].includes(item.key)) { |
| | | item.hidden = val === 'statistics' |
| | | } else if (['InfoType', 'InfoValue'].includes(item.key)) { |
| | | item.hidden = val !== 'statistics' |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | } else if (key === 'label') { |
| | | this.setState({formlist: fromJS(formlist).toJS().map(cell => { |
| | | if (!['labelColor', 'labelValue'].includes(cell.key)) return cell |
| | | |
| | | if (cell.key === 'labelColor') { |
| | | if (val !== 'true') { |
| | | cell.hidden = true |
| | | } else { |
| | | cell.hidden = false |
| | | } |
| | | } else { |
| | | if (val === 'false') { |
| | | cell.hidden = true |
| | | } else { |
| | | cell.hidden = false |
| | | } |
| | | } |
| | | |
| | | return cell |
| | | })}) |
| | | } |
| | | } |
| | | |
| | | getFields() { |
| | | const { formlist } = this.state |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | |
| | | if (!formlist) { |
| | | return fields |
| | | } |
| | | |
| | | formlist.forEach((item, index) => { |
| | | if (item.hidden || item.forbid) return |
| | | |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: '请输入' + item.label + '!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.onSubmit}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'number') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: '请输入' + item.label + '!' |
| | | } |
| | | ] |
| | | })(<InputNumber min={item.min} max={item.max} precision={item.decimal} onPressEnter={this.onSubmit}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'select') { // 下拉 |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: '请选择' + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select mode={item.multi ? 'multiple' : ''}> |
| | | {item.options.map((option, index) => |
| | | <Select.Option key={index} value={option.field || option.value}> |
| | | {option.label || option.text} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'radio') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: '请选择' + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Radio.Group style={{whiteSpace: 'nowrap'}} 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> |
| | | ) |
| | | })} |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'color') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal |
| | | })( |
| | | <ColorSketch allowClear={item.allowClear} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } |
| | | }) |
| | | return fields |
| | | } |
| | | |
| | | enabledChange = (e) => { |
| | |
| | | }) |
| | | } |
| | | |
| | | this.setState({plot: {...plot, colors, ramp: val}, ramp: val}) |
| | | this.setState({plot: {...plot, colors, ramp: val}}) |
| | | } |
| | | |
| | | rampDirectionChange = (e) => { |
| | |
| | | const { plot, view } = this.state |
| | | |
| | | if (view === 'normal') { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | let _plot = {...plot, ...values} |
| | | this.normalRef.handleConfirm().then(values => { |
| | | let _plot = {...plot, ...values} |
| | | |
| | | if (_plot.datatype !== plot.datatype) { |
| | | _plot.colors = null |
| | | } |
| | | if (_plot.datatype === 'statistics') { |
| | | _plot.enabled = 'false' |
| | | _plot.customs = [] |
| | | delete _plot.Yaxis |
| | | } else if (_plot.Yaxis) { |
| | | let yaxis = JSON.parse(JSON.stringify(_plot.Yaxis)) |
| | | let caxis = _plot.customs ? _plot.customs.map(m => m.type) : [] |
| | | yaxis.sort() |
| | | caxis.sort() |
| | | |
| | | if (JSON.stringify(yaxis) !== JSON.stringify(caxis)) { |
| | | let labels = {} |
| | | config.columns.forEach(col => { |
| | | labels[col.field] = col.label |
| | | }) |
| | | |
| | | let cus = {} |
| | | _plot.customs && _plot.customs.forEach(m => { |
| | | cus[m.type] = m |
| | | }) |
| | | _plot.customs = _plot.Yaxis.map((item, i) => { |
| | | if (cus[item]) return cus[item] |
| | | |
| | | return { |
| | | uuid: Utils.getuuid(), |
| | | type: item, |
| | | name: labels[item] || item, |
| | | axis: i === 0 ? 'true' : 'false', |
| | | label: 'false', |
| | | title: 'true', |
| | | shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth'] |
| | | } |
| | | }) |
| | | |
| | | let cusColor = {} |
| | | let limit = chartColors.length |
| | | |
| | | _plot.colors && _plot.colors.forEach(m => { |
| | | cusColor[m.type] = m |
| | | }) |
| | | _plot.colors = _plot.Yaxis.map((item, i) => { |
| | | if (cusColor[item]) return cusColor[item] |
| | | |
| | | return { |
| | | uuid: Utils.getuuid(), |
| | | type: item, |
| | | label: labels[item] || item, |
| | | color: chartColors[i % limit], |
| | | color1: chartColors[i % limit] |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | plot: _plot, |
| | | visible: false |
| | | }) |
| | | |
| | | this.props.plotchange({...config, plot: _plot}) |
| | | if (_plot.datatype !== plot.datatype) { |
| | | _plot.colors = null |
| | | } |
| | | this.resetPlot(_plot) |
| | | |
| | | this.setState({ |
| | | plot: _plot, |
| | | visible: false |
| | | }) |
| | | |
| | | this.props.plotchange({...config, plot: _plot}) |
| | | }) |
| | | } else if (view === 'base') { |
| | | this.baseRef.handleConfirm().then(res => { |
| | | let _plot = {...plot, ...res} |
| | | |
| | | if (res.click === 'menu') { |
| | | delete _plot.menus |
| | | } else if (res.click === 'menus') { |
| | | delete _plot.menu |
| | | } else { |
| | | delete _plot.menus |
| | | delete _plot.menu |
| | | } |
| | | |
| | | delete _plot.MenuID |
| | | delete _plot.MenuName |
| | | delete _plot.MenuNo |
| | | delete _plot.tabType |
| | | |
| | | if (_plot.click === 'menu' && sessionStorage.getItem('appType') === '' && _plot.menu) { |
| | | let list = null |
| | | try { |
| | | list = JSON.parse(sessionStorage.getItem('thdMenuList')) || [] |
| | | } catch (e) { |
| | | list = [] |
| | | } |
| | | |
| | | let id = _plot.menu[_plot.menu.length - 1] |
| | | |
| | | list.forEach(item => { |
| | | if (item.MenuID === id) { |
| | | _plot.MenuID = id |
| | | _plot.MenuName = item.MenuName |
| | | _plot.MenuNo = item.MenuNo |
| | | _plot.tabType = item.type |
| | | } |
| | | }) |
| | | } |
| | | this.resetBase(_plot) |
| | | |
| | | this.setState({ |
| | | plot: _plot, |
| | |
| | | } |
| | | |
| | | changeTab = (tab) => { |
| | | const { config } = this.props |
| | | const { plot, view } = this.state |
| | | |
| | | if (view === 'normal') { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | let _plot = {...plot, ...values} |
| | | this.normalRef.handleConfirm().then(values => { |
| | | let _plot = {...plot, ...values} |
| | | |
| | | if (_plot.datatype !== plot.datatype) { |
| | | _plot.colors = null |
| | | } |
| | | if (_plot.datatype === 'statistics') { |
| | | _plot.enabled = 'false' |
| | | _plot.customs = [] |
| | | _plot.colors = _plot.colors || [] |
| | | delete _plot.Yaxis |
| | | } else if (_plot.Yaxis) { |
| | | let yaxis = JSON.parse(JSON.stringify(_plot.Yaxis)) |
| | | let caxis = _plot.customs ? _plot.customs.map(m => m.type) : [] |
| | | yaxis.sort() |
| | | caxis.sort() |
| | | |
| | | if (JSON.stringify(yaxis) !== JSON.stringify(caxis)) { |
| | | let labels = {} |
| | | config.columns.forEach(col => { |
| | | labels[col.field] = col.label |
| | | }) |
| | | |
| | | let cus = {} |
| | | _plot.customs && _plot.customs.forEach(m => { |
| | | cus[m.type] = m |
| | | }) |
| | | _plot.customs = _plot.Yaxis.map((item, i) => { |
| | | if (cus[item]) return cus[item] |
| | | |
| | | return { |
| | | uuid: Utils.getuuid(), |
| | | type: item, |
| | | name: labels[item] || item, |
| | | axis: i === 0 ? 'true' : 'false', |
| | | label: _plot.label === 'false' ? 'false' : true, |
| | | title: 'true', |
| | | shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth'] |
| | | } |
| | | }) |
| | | |
| | | let cusColor = {} |
| | | let limit = chartColors.length |
| | | |
| | | _plot.colors && _plot.colors.forEach(m => { |
| | | cusColor[m.type] = m |
| | | }) |
| | | _plot.colors = _plot.Yaxis.map((item, i) => { |
| | | if (cusColor[item]) return cusColor[item] |
| | | |
| | | return { |
| | | uuid: Utils.getuuid(), |
| | | type: item, |
| | | label: labels[item] || item, |
| | | color: chartColors[i % limit], |
| | | color1: chartColors[i % limit] |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | datatype: _plot.datatype, |
| | | plot: _plot, |
| | | view: tab |
| | | }) |
| | | if (_plot.datatype !== plot.datatype) { |
| | | _plot.colors = null |
| | | } |
| | | |
| | | this.resetPlot(_plot) |
| | | |
| | | this.setState({ |
| | | plot: _plot, |
| | | view: tab |
| | | }) |
| | | }) |
| | | } else if (view === 'base') { |
| | | this.baseRef.handleConfirm().then(res => { |
| | | let _plot = {...plot, ...res} |
| | | |
| | | if (res.click === 'menu') { |
| | | delete _plot.menus |
| | | } else if (res.click === 'menus') { |
| | | delete _plot.menu |
| | | } else { |
| | | delete _plot.menus |
| | | delete _plot.menu |
| | | } |
| | | |
| | | delete _plot.MenuID |
| | | delete _plot.MenuName |
| | | delete _plot.MenuNo |
| | | delete _plot.tabType |
| | | |
| | | if (_plot.click === 'menu' && sessionStorage.getItem('appType') === '' && _plot.menu) { |
| | | let list = null |
| | | try { |
| | | list = JSON.parse(sessionStorage.getItem('thdMenuList')) || [] |
| | | } catch (e) { |
| | | list = [] |
| | | } |
| | | |
| | | let id = _plot.menu[_plot.menu.length - 1] |
| | | |
| | | list.forEach(item => { |
| | | if (item.MenuID === id) { |
| | | _plot.MenuID = id |
| | | _plot.MenuName = item.MenuName |
| | | _plot.MenuNo = item.MenuNo |
| | | _plot.tabType = item.type |
| | | } |
| | | }) |
| | | } |
| | | this.resetBase(_plot) |
| | | |
| | | if (!plot.Xaxis && (tab === 'color' || tab === 'custom')) { |
| | | this.setState({ |
| | |
| | | view: tab |
| | | }) |
| | | } |
| | | } |
| | | |
| | | resetBase = (_plot) => { |
| | | if (_plot.click === 'menu') { |
| | | delete _plot.menus |
| | | delete _plot.menuType |
| | | } else if (_plot.click === 'menus') { |
| | | delete _plot.menu |
| | | } else { |
| | | delete _plot.menus |
| | | delete _plot.menu |
| | | delete _plot.menuType |
| | | } |
| | | |
| | | delete _plot.MenuID |
| | | delete _plot.MenuName |
| | | delete _plot.MenuNo |
| | | delete _plot.tabType |
| | | |
| | | if (_plot.click === 'menu' && sessionStorage.getItem('appType') === '' && _plot.menu) { |
| | | let list = null |
| | | try { |
| | | list = JSON.parse(sessionStorage.getItem('thdMenuList')) || [] |
| | | } catch (e) { |
| | | list = [] |
| | | } |
| | | |
| | | let id = _plot.menu[_plot.menu.length - 1] |
| | | |
| | | list.forEach(item => { |
| | | if (item.MenuID === id) { |
| | | _plot.MenuID = id |
| | | _plot.MenuName = item.MenuName |
| | | _plot.MenuNo = item.MenuNo |
| | | _plot.tabType = item.type |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | resetPlot = (_plot) => { |
| | | const { config } = this.props |
| | | |
| | | if (_plot.datatype === 'statistics') { |
| | | _plot.enabled = 'false' |
| | | _plot.customs = [] |
| | | _plot.colors = _plot.colors || [] |
| | | delete _plot.Yaxis |
| | | } else if (_plot.Yaxis) { |
| | | delete _plot.InfoType |
| | | delete _plot.InfoValue |
| | | |
| | | let yaxis = JSON.parse(JSON.stringify(_plot.Yaxis)) |
| | | let caxis = _plot.customs ? _plot.customs.map(m => m.type) : [] |
| | | yaxis.sort() |
| | | caxis.sort() |
| | | |
| | | if (JSON.stringify(yaxis) !== JSON.stringify(caxis)) { |
| | | let labels = {} |
| | | config.columns.forEach(col => { |
| | | labels[col.field] = col.label |
| | | }) |
| | | |
| | | let cus = {} |
| | | _plot.customs && _plot.customs.forEach(m => { |
| | | cus[m.type] = m |
| | | }) |
| | | _plot.customs = _plot.Yaxis.map((item, i) => { |
| | | if (cus[item]) return cus[item] |
| | | |
| | | return { |
| | | uuid: Utils.getuuid(), |
| | | type: item, |
| | | name: labels[item] || item, |
| | | axis: i === 0 ? 'true' : 'false', |
| | | label: _plot.label === 'false' ? 'false' : true, |
| | | title: 'true', |
| | | shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth'] |
| | | } |
| | | }) |
| | | |
| | | let cusColor = {} |
| | | let limit = chartColors.length |
| | | |
| | | _plot.colors && _plot.colors.forEach(m => { |
| | | cusColor[m.type] = m |
| | | }) |
| | | _plot.colors = _plot.Yaxis.map((item, i) => { |
| | | if (cusColor[item]) return cusColor[item] |
| | | |
| | | return { |
| | | uuid: Utils.getuuid(), |
| | | type: item, |
| | | label: labels[item] || item, |
| | | color: chartColors[i % limit], |
| | | color1: chartColors[i % limit] |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | transVals = (values, key) => { |
| | | if (key !== 'datatype') return |
| | | |
| | | this.setState({ |
| | | datatype: values.datatype |
| | | }) |
| | | } |
| | | |
| | | addColor = () => { |
| | |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { view, visible, datatype, plot, ramp, colorColumns, barColorColumns, rampColorColumns, statColorColumns, rampStatColorColumns, cusColumns, baseFormlist } = this.state |
| | | const { view, visible, datatype, plot, colorColumns, barColorColumns, rampColorColumns, statColorColumns, rampStatColorColumns, cusColumns, baseFormlist, formlist } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | {config.name ? <div className="mk-com-name">{config.name} - 编辑</div> : null} |
| | | <Tabs activeKey={view} className="menu-chart-edit-box" onChange={this.changeTab}> |
| | | <TabPane tab="组件设置" key="base"> |
| | | <NormalForm formlist={baseFormlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.baseRef = inst}/> |
| | | <ModalForm formlist={baseFormlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.baseRef = inst}/> |
| | | </TabPane> |
| | | <TabPane tab="图表设置" key="normal"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={16}>{this.getFields()}</Row> |
| | | </Form> |
| | | <ModalForm formlist={formlist} inputSubmit={this.onSubmit} transVals={this.transVals} wrappedComponentRef={(inst) => this.normalRef = inst}/> |
| | | </TabPane> |
| | | {plot ? <TabPane tab="颜色设置" key="color"> |
| | | <div> |
| | |
| | | </Form> |
| | | </Col> : null} |
| | | {datatype === 'statistics' ? <Button className="color-add mk-green" onClick={this.addColor}>添加</Button> : null} |
| | | {datatype === 'statistics' ? <EditTable actions={['edit', 'move', 'del']} data={plot.colors || []} columns={ramp ==='true' ? rampStatColorColumns : statColorColumns} onChange={this.changeColor}/> : null} |
| | | {datatype !== 'statistics' ? <EditTable actions={['edit']} data={plot.colors || []} columns={ramp ==='true' ? rampColorColumns : colorColumns} onChange={this.changeColor}/> : null} |
| | | {datatype === 'statistics' ? <EditTable actions={['edit', 'move', 'del']} data={plot.colors || []} columns={plot.ramp ==='true' ? rampStatColorColumns : statColorColumns} onChange={this.changeColor}/> : null} |
| | | {datatype !== 'statistics' ? <EditTable actions={['edit']} data={plot.colors || []} columns={plot.ramp ==='true' ? rampColorColumns : colorColumns} onChange={this.changeColor}/> : null} |
| | | {plot.chartType === 'bar' && plot.datatype === 'query' ? <div className="mk-bar-colors"> |
| | | <p>柱形颜色:可根据柱图序号设置颜色(请设置柱形宽度)。注:使用自定义图形设置或多根柱图时无效。</p> |
| | | <div className="bar-color-add"><PlusOutlined onClick={this.addbarColor}/></div> |
| | |
| | | .ant-radio-wrapper { |
| | | margin-right: 5px; |
| | | } |
| | | .color-sketch-block { |
| | | position: relative; |
| | | top: 5px; |
| | | width: 240px; |
| | | } |
| | | .color-add { |
| | | float: right; |
| | | margin-bottom: 10px; |
| | |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | type: 'select', |
| | | field: 'commit', |
| | | label: '数据提交', |
| | | initval: wrap.commit || 'all', |
| | |
| | | {value: 'all', label: '全部'}, |
| | | {value: 'change', label: '修改项'}, |
| | | {value: 'amend', label: '修改项(全)'}, |
| | | ] |
| | | {value: 'check', label: '勾选项'}, |
| | | ], |
| | | reset_source: true, |
| | | callback: (map, record, MKEmitter) => { |
| | | let _tableType = map.get('tableType') |
| | | |
| | | _tableType.options[0].disabled = record.commit === 'check' |
| | | _tableType.oriOptions[0].disabled = record.commit === 'check' |
| | | |
| | | map.set('tableType', _tableType) |
| | | |
| | | if (record.commit === 'check' && !record.tableType) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFC', 'input', 'tableType', 'radio') |
| | | }, 50) |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | initval: wrap.tableType || '', |
| | | required: false, |
| | | options: [ |
| | | {value: '', label: '不可选'}, |
| | | {value: '', label: '不可选', disabled: wrap.commit === 'check'}, |
| | | {value: 'radio', label: '单选'}, |
| | | {value: 'checkbox', label: '多选'}, |
| | | ] |
| | |
| | | } |
| | | if (plot.label !== 'false') { |
| | | _chart.label(_valfield, (value) => { |
| | | if (plot.labelValue === 'zero' && value === 0) { |
| | | return null |
| | | } |
| | | let val = value |
| | | if (plot.show === 'percent') { |
| | | val = value + '%' |
| | |
| | | } |
| | | if (plot.$label !== 'false') { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.labelValue === 'zero' && value === 0) { |
| | | if (plot.$label !== 'true' && value === 0) { |
| | | return null |
| | | } |
| | | |
| | |
| | | } |
| | | if (plot.$label !== 'false') { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.labelValue === 'zero' && value === 0) { |
| | | if (plot.$label !== 'true' && value === 0) { |
| | | return null |
| | | } |
| | | |
| | |
| | | } |
| | | if (item.label !== 'false') { |
| | | _chart.label(item.name, (value) => { |
| | | if (plot.labelValue === 'zero' && value === 0) { |
| | | if (plot.label !== 'true' && value === 0) { |
| | | return null |
| | | } |
| | | |
| | |
| | | |
| | | if (item.label === 'true') { |
| | | _chart.label(item.name, (value) => { |
| | | if (plot.labelValue === 'zero' && value === 0) { |
| | | return null |
| | | } |
| | | |
| | | let val = value |
| | | if (item.show === 'percent') { |
| | | val = value + '%' |
| | |
| | | } |
| | | if (plot.label !== 'false') { |
| | | _chart.label(`${_valfield}*${_typefield}`, (value, key) => { |
| | | if (plot.labelValue === 'zero' && value === 0) { |
| | | if (plot.label !== 'true' && value === 0) { |
| | | return null |
| | | } |
| | | |
| | |
| | | } |
| | | if (plot.label !== 'false') { |
| | | _chart.label(`${_valfield}*${_typefield}`, (value, key) => { |
| | | if (plot.labelValue === 'zero' && value === 0) { |
| | | if (plot.label !== 'true' && value === 0) { |
| | | return null |
| | | } |
| | | |
| | |
| | | setTimeout(() => { |
| | | this.plusLine(colId) |
| | | }, 10) |
| | | } else if (edData[index] && setting.commit !== 'change') { |
| | | } else if (edData[index] && (setting.commit === 'all' || setting.commit === 'amend')) { |
| | | setTimeout(() => { |
| | | this.submit() |
| | | }, 10) |
| | |
| | | |
| | | checkData = () => { |
| | | const { setting } = this.props |
| | | const { edData, forms, checkForms } = this.state |
| | | const { edData, forms, checkForms, selectedRowKeys } = this.state |
| | | |
| | | let data = fromJS(edData).toJS() |
| | | |
| | |
| | | |
| | | if (setting.commit === 'amend') { |
| | | data = data.filter(item => !item.$origin) |
| | | } else if (setting.commit === 'check') { |
| | | data = data.filter(item => selectedRowKeys.includes(item.$$uuid)) |
| | | |
| | | if (data.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择需要提交的数据!', |
| | | duration: 5 |
| | | }) |
| | | return null |
| | | } |
| | | } |
| | | |
| | | if (data.length === 0) { |