Merge branch 'master' into positec
| | |
| | | }, { |
| | | value: 'switch', |
| | | text: '开关' |
| | | }, { |
| | | value: 'date', |
| | | text: '日期(天)' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'precision', |
| | | label: '精确度', |
| | | initVal: card.precision || 'day', |
| | | options: [{ |
| | | value: 'day', |
| | | text: '天' |
| | | }, { |
| | | value: 'hour', |
| | | text: '小时' |
| | | }, { |
| | | value: 'minute', |
| | | text: '分钟' |
| | | }, { |
| | | value: 'second', |
| | | text: '秒' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'declareType', |
| | | label: '数据类型', |
| | | tooltip: '声明变量时的类型,时间格式datetime或文本格式nvarchar(50)。', |
| | | initVal: card.declareType || 'datetime', |
| | | options: [{ |
| | | value: 'datetime', |
| | | text: 'datetime' |
| | | }, { |
| | | value: 'nvarchar(50)', |
| | | text: 'nvarchar(50)' |
| | | }] |
| | | }, |
| | | { |
| | |
| | | |
| | | if (this.record.editType === 'switch') { |
| | | _options.push('enter', 'openVal', 'closeVal', 'openText', 'closeText', 'editField') |
| | | } else if (this.record.editType === 'date') { |
| | | _options.push('required', 'precision', 'enter', 'declareType') |
| | | } else if (this.record.editType === 'select') { |
| | | _options.push('required', 'enter', 'resourceType', 'linkSubField', 'editField', 'dropdown') |
| | | |
| | |
| | | if (/列名\s*'[a-zA-Z0-9_-]+'\s*无效/.test(result.message)) { |
| | | let tail = '' |
| | | let type = '' |
| | | if (setting.execute !== 'false' && setting.queryType !== 'statistics') { |
| | | searches.forEach(item => { |
| | | if (item.forbid) return |
| | | item.key.split(',').forEach(field => { |
| | |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | if (!tail) { |
| | | let keys = setting.order.replace(/\s+(asc|desc)/ig, '').replace(/\s+/g, '') |
| | |
| | | { subType: 'textarea', text: '多行文本', type: 'form' }, |
| | | { subType: 'multiselect', text: '下拉多选', type: 'form' }, |
| | | { subType: 'link', text: '联动菜单', type: 'form' }, |
| | | { subType: 'popSelect', text: '选择器', type: 'form' }, |
| | | { subType: 'switch', text: '开关', type: 'form' }, |
| | | { subType: 'checkbox', text: '多选框', type: 'form' }, |
| | | { subType: 'radio', text: '单选框', type: 'form' }, |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Table, Typography, Modal, Input, InputNumber, Button, notification, message, Select } from 'antd' |
| | | import { Table, Typography, Modal, Input, InputNumber, Switch, Button, notification, message, Select, DatePicker } from 'antd' |
| | | import { EditOutlined, QuestionCircleOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | import md5 from 'md5' |
| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Utils, { getEditTableSql, getMark } from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import CusSwitch from './cusSwitch' |
| | | import Encrypts from '@/components/encrypts' |
| | | import './index.scss' |
| | | |
| | | const { Paragraph } = Typography |
| | | const MkIcon = asyncComponent(() => import('@/components/mk-icon')) |
| | | const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList')) |
| | | |
| | | class CusSwitch extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | autoFocus: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | status: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { defaultValue, config } = this.props |
| | | |
| | | let status = false |
| | | |
| | | if (defaultValue === config.openVal) { |
| | | status = true |
| | | } |
| | | |
| | | this.setState({status}) |
| | | } |
| | | |
| | | changeStatus = (val) => { |
| | | const { config } = this.props |
| | | this.setState({ status: val }, () => { |
| | | let _val = val ? config.openVal : config.closeVal |
| | | let _text = val ? config.openText : config.closeText |
| | | this.props.onChange(_val, _text) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { config, autoFocus } = this.props |
| | | const { status } = this.state |
| | | return ( |
| | | <Switch checkedChildren={config.openText} autoFocus={autoFocus} onBlur={this.props.onBlur} unCheckedChildren={config.closeText} checked={status} onChange={this.changeStatus} /> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class CusDatePicker extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func, |
| | | blur: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | value: null, |
| | | open: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { value, open } = this.props |
| | | |
| | | let _value = value || null |
| | | if (_value) { |
| | | _value = moment(_value, 'YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | this.setState({value: _value, open: open === true}) |
| | | } |
| | | |
| | | onOpenChange = (open) => { |
| | | this.setState({open}) |
| | | |
| | | if (open === false) { |
| | | this.props.blur() |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { value, open } = this.state |
| | | |
| | | return ( |
| | | <DatePicker dropdownClassName={'mk-date-picker ' + config.precision} showTime={config.format !== 'YYYY-MM-DD'} format={config.format} open={open} defaultValue={value} onChange={this.props.onChange} onOpenChange={this.onOpenChange}/> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class BodyRow extends React.Component { |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | onDateChange = (val) => { |
| | | const { col, record } = this.props |
| | | |
| | | let _val = val ? moment(val).format(col.format) : '' |
| | | |
| | | if (col.precision === 'hour') { |
| | | _val = _val + ':00:00' |
| | | } else if (col.precision === 'minute') { |
| | | _val = _val + ':00' |
| | | } |
| | | |
| | | this.setState({editing: false}) |
| | | |
| | | setTimeout(() => { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | let node = document.getElementById(col.enter + record.$$uuid) |
| | | node && node.click() |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: _val}) |
| | | } |
| | | |
| | | switchBlur = () => { |
| | | setTimeout(() => { |
| | | this.setState({editing: false}) |
| | |
| | | if (!col.editType || col.editType === 'text') { |
| | | return (<td className="editing_table_cell"> |
| | | <Input className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | </td>) |
| | | } else if (col.editType === 'date') { |
| | | return (<td className="editing_table_cell"> |
| | | <CusDatePicker config={col} value={record[col.field] || null} open={true} onChange={this.onDateChange} blur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | onDateChange = (val) => { |
| | | const { col, record } = this.props |
| | | |
| | | let _val = val ? moment(val).format(col.format) : '' |
| | | |
| | | if (col.precision === 'hour') { |
| | | _val = _val + ':00:00' |
| | | } else if (col.precision === 'minute') { |
| | | _val = _val + ':00' |
| | | } |
| | | |
| | | setTimeout(() => { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | let node = document.getElementById(col.enter + record.$$uuid) |
| | | node && node.click() |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: _val}) |
| | | } |
| | | |
| | | render() { |
| | | let { col, config, record, style, className, ...resProps } = this.props |
| | | const { err } = this.state |
| | |
| | | } else if (col.editType === 'switch') { |
| | | children = ( |
| | | <CusSwitch config={col} autoFocus={false} defaultValue={_value} onChange={this.onSwitchChange} onBlur={() => {}}/> |
| | | ) |
| | | } else if (col.editType === 'date') { |
| | | children = ( |
| | | <CusDatePicker config={col} value={record[col.field] || null} onChange={this.onDateChange} blur={() => {}}/> |
| | | ) |
| | | } else { |
| | | children = (<> |
| | |
| | | item.map.set(cell.value, cell.label) |
| | | }) |
| | | } |
| | | } else if (item.type === 'text' && item.editType === 'date') { |
| | | item.format = 'YYYY-MM-DD' |
| | | |
| | | if (item.precision === 'hour') { |
| | | item.format = 'YYYY-MM-DD HH' |
| | | } else if (item.precision === 'minute') { |
| | | item.format = 'YYYY-MM-DD HH:mm' |
| | | } else if (item.precision === 'second') { |
| | | item.format = 'YYYY-MM-DD HH:mm:ss' |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (item.field === setting.primaryKey) return |
| | | |
| | | if (_forms[item.field]) { |
| | | forms.push({..._forms[item.field], datatype: item.datatype}) |
| | | let _item = {..._forms[item.field]} |
| | | if (_item.editType === 'date') { |
| | | _item.datatype = _item.declareType || 'datetime' |
| | | } else { |
| | | _item.datatype = item.datatype |
| | | } |
| | | forms.push(_item) |
| | | } else { |
| | | forms.push(item) |
| | | } |
| | |
| | | let val = item[col.field] !== undefined ? (item[col.field] + '') : '' |
| | | if (col.required === 'true' && !val) { |
| | | line.push(`${col.label}不可为空`) |
| | | } else if (col.datatype === 'datetime' && !val) { |
| | | val = '1949-10-01' |
| | | } |
| | | item[col.field] = val |
| | | } else if (col.type === 'number') { |
| | |
| | | |
| | | >.ant-table-wrapper { |
| | | position: relative; |
| | | z-index: 1; |
| | | // z-index: 1; |
| | | } |
| | | .ant-table { |
| | | color: inherit; |
| | |
| | | border: 1px solid var(--mk-sys-color); |
| | | } |
| | | } |
| | | .ant-calendar-picker { |
| | | display: block; |
| | | position: absolute; |
| | | top: 0px; |
| | | left: 0px; |
| | | right: 0px; |
| | | bottom: 0px; |
| | | } |
| | | .has-error, .has-error .ant-input-number-input { |
| | | border-color: #ff4d4f!important; |
| | | } |
| | |
| | | text-align: inherit; |
| | | } |
| | | } |
| | | .ant-calendar-picker { |
| | | display: block; |
| | | height: 30px; |
| | | } |
| | | .has-error, .has-error .ant-input-number-input { |
| | | border-color: #ff4d4f!important; |
| | | } |
| | |
| | | height: 34px; |
| | | border-radius: 0px; |
| | | padding-left: 15px!important; |
| | | border-bottom-width: 1px!important; |
| | | border: none; |
| | | color: rgba(0, 0, 0, 0.65)!important; |
| | | border-bottom: 1px solid #e8e8e8!important; |
| | | background: #ffffff!important; |
| | | .anticon { |
| | | display: none; |
| | | } |
| | |
| | | dataIndex: col.field, |
| | | title: col.label, |
| | | sorter: col.IsSort === 'true', |
| | | width: 120 |
| | | width: col.Width || 120 |
| | | }) |
| | | }) |
| | | |
| | |
| | | dataSource={options} |
| | | loading={loading} |
| | | onRow={(record) => { |
| | | let className = '' |
| | | |
| | | if (record.$disabled) { |
| | | className = ' mk-disable-line ' |
| | | } else if (value === record.$$uuid) { |
| | | className = ' ant-table-row-selected ' |
| | | } |
| | | |
| | | return { |
| | | className: value === record.$$uuid ? ' ant-table-row-selected ' : '', |
| | | className: className, |
| | | onClick: () => {this.changeRow(record)}, |
| | | } |
| | | }} |
| | |
| | | tr.ant-table-row-selected td { |
| | | background-color: var(--mk-sys-color3); |
| | | } |
| | | tr:not(.mk-disable-line) { |
| | | cursor: pointer; |
| | | } |
| | | .mk-disable-line { |
| | | color: rgba(0, 0, 0, 0.35); |
| | | } |
| | | } |
| | | } |
| | | .ant-modal-body::-webkit-scrollbar { |
| | |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: '选择器', |
| | | subType: 'popSelect', |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: '开关', |
| | | subType: 'switch', |
| | | }, |
| | |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider, DragSource, DropTarget } from 'react-dnd' |
| | | import { Table, Input, InputNumber, Popconfirm, Form, Select, Radio, Cascader, notification, message, Modal, Typography } from 'antd' |
| | | import { Table, Input, InputNumber, Popconfirm, Switch, Form, Select, Radio, Cascader, notification, message, Modal, Typography } from 'antd' |
| | | import { CopyOutlined, EditOutlined, DeleteOutlined, SwapOutlined, PlusOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import ColorSketch from '@/mob/colorsketch' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import CusSwitch from './cusSwitch' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | |
| | | let dragingIndex = -1 |
| | | const { Paragraph } = Typography |
| | | |
| | | class CusSwitch extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | value: PropTypes.any, |
| | | onChange: PropTypes.func |
| | | } |
| | | state = { |
| | | status: true |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { defaultValue, value } = this.props |
| | | let initVal = 'true' |
| | | |
| | | if (this.props['data-__meta']) { |
| | | initVal = this.props['data-__meta'].initialValue |
| | | } else if (defaultValue) { |
| | | initVal = defaultValue |
| | | } else if (value) { |
| | | initVal = value |
| | | } |
| | | |
| | | if (initVal === 'false') { |
| | | initVal = false |
| | | } else { |
| | | initVal = true |
| | | } |
| | | |
| | | this.setState({status: initVal}) |
| | | } |
| | | |
| | | changeStatus = (val) => { |
| | | this.setState({ status: val }, () => { |
| | | let _val = val ? 'true' : 'false' |
| | | this.props.onChange && this.props.onChange(_val) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { status } = this.state |
| | | return ( |
| | | <Switch checkedChildren="是" unCheckedChildren="否" checked={status} onChange={this.changeStatus} /> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class BodyRow extends React.Component { |
| | | render() { |
| | | const { isOver, moveAble, connectDragSource, connectDropTarget, moveRow, ...restProps } = this.props |
| | |
| | | return '否' |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | title: '列宽', |
| | | dataIndex: 'Width', |
| | | inputType: 'number', |
| | | editable: true, |
| | | width: '20%', |
| | | initval: 120 |
| | | } |
| | | ] |
| | | }, |