Merge branch 'positec' into dms
| | |
| | | /** |
| | | * @description 获取系统配置,优先从缓存中取值,增加appkey |
| | | * @param {Object} param 请求参数 |
| | | * @param {Boolean} SSO 是否为单点登录地址 |
| | | * @param {Boolean} cache 是否使用缓存 |
| | | */ |
| | | getSystemCacheConfig (param, cache = true) { |
| | | param.userid = param.userid || sessionStorage.getItem('UserID') || '' |
| | |
| | | appkey: window.GLOB.appkey || '' |
| | | } |
| | | |
| | | let id = Utils.getuuid() |
| | | sql = sql.replace(/@time_id@/ig, `'${id}'`) |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | sql = sql.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | |
| | | } |
| | | .ant-pagination-options { |
| | | > div:not(:first-child) { |
| | | z-index: 1; |
| | | z-index: 3; |
| | | } |
| | | } |
| | | } |
| | |
| | | trdItem.type = PageParam.Template || 'CommonTable' |
| | | trdItem.OpenType = PageParam.OpenType || 'newtab' |
| | | trdItem.hidden = PageParam.hidden || 'false' |
| | | trdItem.menuColor = PageParam.menuColor || '' |
| | | |
| | | if (trdItem.type === 'NewPage') { |
| | | trdItem.OpenType = 'newpage' |
| | |
| | | <div className="title" onClick={e => e.stopPropagation()}>{cell.MenuName}</div> |
| | | <div className="menu-detail"> |
| | | {cell.children && cell.children.map(m => ( |
| | | <div key={m.MenuID} title={m.MenuName} onClick={() => {this.changeVerMenu(m)}}> |
| | | <div key={m.MenuID} title={m.MenuName} style={m.menuColor ? {color: m.menuColor} : null} onClick={() => {this.changeVerMenu(m)}}> |
| | | {m.MenuName} |
| | | </div> |
| | | ))} |
| | |
| | | GLOB.showline = _systemMsg.showline || '' |
| | | GLOB.navBar = _systemMsg.navBar || 'shutter' |
| | | GLOB.appVersion = _systemMsg.app_version || '' |
| | | sessionStorage.setItem('appname', _systemMsg.appname || '') |
| | | |
| | | let levels = [30, 10, 20, 40, 50, 60, 70, 80, 90, 100] |
| | | |
| | |
| | | |
| | | changeBtnStyle = (element) => { |
| | | let _style = element.style ? fromJS(element.style).toJS() : {} |
| | | let options = ['font', 'border', 'background', 'margin', 'padding'] |
| | | let options = ['font', 'border', 'background', 'margin', 'padding', 'minHeight'] |
| | | |
| | | this.setState({ |
| | | card: element |
| | |
| | | * @description 获取显示列表单配置信息 |
| | | * @param {object} card // 搜索条件对象 |
| | | */ |
| | | export function getColumnForm (card, fields = [], columns = []) { |
| | | export function getColumnForm (card, fields = [], columns = [], wrap) { |
| | | let roleList = sessionStorage.getItem('sysRoles') |
| | | if (roleList) { |
| | | try { |
| | |
| | | }] |
| | | |
| | | let editCols = [ |
| | | // { |
| | | // field: '$sub', |
| | | // label: '提交' |
| | | // }, |
| | | { |
| | | field: '$sub', |
| | | label: '提交' |
| | | field: '$noAct', |
| | | label: '无动作' |
| | | }, |
| | | { |
| | | field: '$next', |
| | | label: '下一行' |
| | | }, |
| | | { |
| | | field: '$noAct', |
| | | label: '无动作' |
| | | } |
| | | ] |
| | | |
| | | if (card.enter === '$sub') { |
| | | card.enter = '$noAct' |
| | | } |
| | | if (wrap.commit === 'change') { |
| | | editCols[0].label = '失去焦点' |
| | | } |
| | | |
| | | let cols = [] |
| | | let getcols = (columns, suplabel = '') => { |
| | |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'showField', |
| | | label: '显示字段', |
| | | initVal: card.showField || '', |
| | | tooltip: '用于控制选择框中的显示内容。', |
| | | required: true, |
| | | options: 'columns' |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'controlField', |
| | | label: '禁用字段', |
| | | initVal: card.controlField || '', |
| | |
| | | initVal: card.popWidth || 60, |
| | | tooltip: '小于100时为百分率,大于100时为绝对值。', |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'laypage', |
| | | label: '分页', |
| | | initVal: card.laypage || 'true', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '是' |
| | | }, { |
| | | value: 'false', |
| | | text: '否' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'onload', |
| | | label: '初始化', |
| | | initVal: card.onload || 'true', |
| | | tooltip: '当没有设置搜索字段时,初始化加载数据。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '加载' |
| | | }, { |
| | | value: 'false', |
| | | text: '不加载' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'cache', |
| | | label: '选项查询', |
| | | initVal: card.cache || 'true', |
| | | tooltip: '数据查询是否使用缓存。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '缓存' |
| | | }, { |
| | | value: 'false', |
| | | text: '实时' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | |
| | | key: 'enter', |
| | | label: '回车切换', |
| | | initVal: card.enter || '$noAct', |
| | | tooltip: '包括文本或数值回车事件、下拉菜单选中事件、开关切换事件。', |
| | | tooltip: '包括文本或数值回车事件、下拉菜单、选择器、时间变化事件、开关切换事件。', |
| | | options: editCols |
| | | }, |
| | | { |
| | |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'clearField', |
| | | label: '清空字段', |
| | | initVal: card.clearField || '', |
| | | tooltip: '当前字段编辑时需要清空的字段。', |
| | | allowClear: true, |
| | | required: false, |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'decimal', |
| | | min: 0, |
| | |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import { getColumnForm } from './formconfig' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import { formRule } from '@/utils/option.js' |
| | |
| | | class EdiTableColumn extends Component { |
| | | static propTpyes = { |
| | | column: PropTypes.object, |
| | | wrap: PropTypes.object, |
| | | columns: PropTypes.array, |
| | | fields: PropTypes.array, |
| | | submitCol: PropTypes.func, // 提交事件 |
| | |
| | | } else if (this.record.editType === 'date') { |
| | | _options.push('required', 'precision', 'enter', 'declareType') |
| | | } else if (this.record.editType === 'popSelect') { |
| | | _options.push('required', 'enter', 'linkSubField', 'columns', 'dataSource', 'primaryKey', 'order', 'showField', 'controlField', 'searchKey', 'popWidth') |
| | | _options.push('required', 'enter', 'linkSubField', 'columns', 'dataSource', 'primaryKey', 'order', 'controlField', 'searchKey', 'popWidth', 'laypage', 'cache', 'onload') |
| | | } else if (this.record.editType === 'select') { |
| | | _options.push('required', 'enter', 'resourceType', 'linkSubField', 'dropdown') |
| | | |
| | |
| | | _options.push('required', 'enter') |
| | | } |
| | | } else if (this.record.type === 'number') { |
| | | _options.push('max', 'min', 'enter') |
| | | _options.push('max', 'min', 'enter', 'clearField') |
| | | } |
| | | } |
| | | if (this.record.type === 'formula' && this.record.eval === 'true') { |
| | |
| | | return item |
| | | }) |
| | | |
| | | let formlist = getColumnForm(column, fields, this.props.columns) |
| | | let formlist = getColumnForm(column, fields, this.props.columns, this.props.wrap) |
| | | this.record = {} |
| | | |
| | | formlist.forEach(item => { |
| | |
| | | } |
| | | |
| | | if (values.dataSource) { |
| | | let error = Utils.verifySql(values.dataSource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | let pass = checkSQL(values.dataSource) |
| | | |
| | | if (!pass) return |
| | | } |
| | | |
| | | if (values.editType === 'select' && values.resourceType === '1' && values.dataSource) { |
| | |
| | | |
| | | class NormalTableColumns extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 配置信息 |
| | | updatecolumn: PropTypes.func // 数据变化 |
| | | config: PropTypes.object, |
| | | updatecolumn: PropTypes.func, |
| | | addColumns: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | |
| | | |
| | | submitCol = (col) => { |
| | | const { card } = this.state |
| | | |
| | | if (!card) return |
| | | |
| | | col.uuid = card.uuid |
| | | col.isSub = card.isSub === true |
| | |
| | | } trigger="hover"> |
| | | <Button className="submit-btn" style={config.submit.style} onDoubleClick={() => this.setState({visible: true})} type="primary">提交</Button> |
| | | </Popover> |
| | | <PlusOutlined title="添加列" onClick={this.props.addColumns}/> |
| | | <CopyOutlined title="复制显示列" onClick={this.copycolumn} /> |
| | | <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} /> |
| | | <ColsControl config={config} onSubmit={this.props.updatecolumn}/> |
| | |
| | | }} |
| | | /> |
| | | </DndProvider> |
| | | <EditColumn column={card} columns={this.state.columns} fields={fields} submitCol={this.submitCol} cancelCol={this.cancelCol}/> |
| | | <EditColumn column={card} wrap={config.wrap} columns={this.state.columns} fields={fields} submitCol={this.submitCol} cancelCol={this.cancelCol}/> |
| | | <Modal |
| | | wrapClassName="mk-pop-modal" |
| | | visible={visible} |
| | |
| | | margin-right: 10px; |
| | | cursor: pointer; |
| | | } |
| | | >.anticon-copy { |
| | | >.anticon-copy, >.anticon-plus { |
| | | color: #26C281; |
| | | margin-left: 5px; |
| | | } |
| | |
| | | import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | |
| | | fields.push('jskey') |
| | | |
| | | let sheet = btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '') |
| | | let _sql = `create table #${sheet} (${usefulfields.map(item => item.field + ' ' + item.type).join(',')},jskey nvarchar(50),data_type nvarchar(50),BID nvarchar(50)) |
| | | let _sql = `create table #${sheet} (${usefulfields.map(item => item.field + ' ' + item.datatype).join(',')},jskey nvarchar(50),data_type nvarchar(50),BID nvarchar(50)) |
| | | Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50), @retmsg nvarchar(4000),@tbid Nvarchar(512) |
| | | Select @ErrorCode='', @retmsg='' |
| | | ` |
| | |
| | | values.status = editItem.status || 'true' |
| | | } |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | let pass = checkSQL(values.sql, 'customscript') |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/,,/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { |
| | | let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql, 'customscript') |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | let sheet = btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '') |
| | | let tail = ` |
| | |
| | | |
| | | this.updateComponent(_card) |
| | | } else { |
| | | let _card = fromJS(card).toJS() |
| | | |
| | | if (_card.mergeCol) { |
| | | let col = _card.cols[_card.mergeCol[0]] |
| | | _card.cols.splice(_card.mergeCol[0], 1, ...col.pops) |
| | | } |
| | | |
| | | if (_card.wrap.commit === 'simple') { |
| | | _card.wrap.commit = 'change' |
| | | } |
| | | |
| | | this.setState({ |
| | | card: fromJS(card).toJS() |
| | | card: _card |
| | | }) |
| | | } |
| | | } |
| | |
| | | card: card |
| | | }) |
| | | |
| | | let _card = card.isNew ? fromJS(card).toJS() : card |
| | | let _card = card |
| | | if (_card.isNew) { |
| | | _card = fromJS(card).toJS() |
| | | _card.cols = _card.cols.filter(a => !a.origin) |
| | | |
| | | delete _card.isNew |
| | | delete _card.mergeCol |
| | | } else if (_card.mergeCol) { |
| | | _card = fromJS(card).toJS() |
| | | let col = {..._card.cols[_card.mergeCol[0]]} |
| | | col.initval = '' |
| | | col.pops = [] |
| | | |
| | | _card.mergeCol.forEach(index => { |
| | | col.pops.push(_card.cols[index]) |
| | | }) |
| | | |
| | | _card.cols = _card.cols.filter((col, index) => !_card.mergeCol.includes(index)) |
| | | _card.cols.splice(_card.mergeCol[0], 0, col) |
| | | } |
| | | |
| | | |
| | | this.props.updateConfig(_card) |
| | | } |
| | | |
| | |
| | | |
| | | updatecolumn = (config) => { |
| | | config.absFields = [] |
| | | config.cols.forEach(col => { |
| | | config.mergeCol = false |
| | | |
| | | config.cols.forEach((col, index) => { |
| | | delete col.pops |
| | | |
| | | if (col.type === 'number') { |
| | | if (col.format === 'abs') { |
| | | config.absFields.push(col.field) |
| | |
| | | } |
| | | } |
| | | }) |
| | | } else if (col.type === 'text') { |
| | | if (col.editable === 'true' && col.editType === 'popSelect' && /^tab:/.test(col.initval)) { |
| | | config.mergeCol = config.mergeCol || [] |
| | | config.mergeCol.push(index) |
| | | } |
| | | } |
| | | }) |
| | | |
| | |
| | | </Popover> |
| | | <SearchComponent config={card} updatesearch={this.updateComponent}/> |
| | | <ActionComponent config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/> |
| | | <ColumnComponent config={card} updatecolumn={this.updatecolumn}/> |
| | | <ColumnComponent config={card} updatecolumn={this.updatecolumn} addColumns={this.addColumns}/> |
| | | <div className="component-name"> |
| | | <div className="center"> |
| | | <div className="title" onDoubleClick={() => { |
| | |
| | | precision: 0, |
| | | required: false |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // field: 'editable', |
| | | // label: '初始化', |
| | | // initval: wrap.editable || 'false', |
| | | // required: false, |
| | | // options: [ |
| | | // {value: 'true', label: '可编辑'}, |
| | | // {value: 'false', label: '不可编辑'}, |
| | | // ], |
| | | // controlFields: [ |
| | | // {field: 'switchable', values: ['true']}, |
| | | // ] |
| | | // }, |
| | | // { |
| | | // type: 'radio', |
| | | // field: 'submittal', |
| | | // label: '提交后', |
| | | // initval: wrap.submittal || 'false', |
| | | // required: false, |
| | | // options: [ |
| | | // {value: 'true', label: '可编辑'}, |
| | | // {value: 'false', label: '不可编辑'}, |
| | | // ] |
| | | // }, |
| | | // { |
| | | // type: 'radio', |
| | | // field: 'addable', |
| | | // label: '可新增', |
| | | // initval: wrap.addable || 'false', |
| | | // required: false, |
| | | // options: [ |
| | | // {value: 'true', label: '是'}, |
| | | // {value: 'false', label: '否'}, |
| | | // ] |
| | | // }, |
| | | // { |
| | | // type: 'radio', |
| | | // field: 'delable', |
| | | // label: '可删除', |
| | | // initval: wrap.delable || 'false', |
| | | // required: false, |
| | | // options: [ |
| | | // {value: 'true', label: '是'}, |
| | | // {value: 'false', label: '否'}, |
| | | // ] |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | field: 'commit', |
| | | label: '数据提交', |
| | | initval: wrap.commit || 'all', |
| | | tooltip: '单项提交指在表单中回车或删除行时,设置为单项时如点击提交按钮,会提交修改项。失去焦点提交时会验证数据是否修改,未修改的数据不会提交。', |
| | | tooltip: '设置为修改项时,在失去焦点且不存在必填项为空时触发提交。设置为修改项(全)时,在点击提交按钮时触发提交。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'all', label: '全部'}, |
| | | {value: 'change', label: '修改项'}, |
| | | {value: 'simple', label: '单项'}, |
| | | {value: 'blur', label: '失去焦点'}, |
| | | ], |
| | | controlFields: [ |
| | | {field: 'standard', values: ['change', 'simple']}, |
| | | {value: 'amend', label: '修改项(全)'}, |
| | | ] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // field: 'operType', |
| | | // label: '编辑按钮', |
| | | // initval: wrap.operType || 'btnMode', |
| | | // tooltip: '编辑时的添加、删除按钮显示位置,注:使用浮标时表格横向滚动失效,表格设置高度时浮标无效。', |
| | | // required: false, |
| | | // options: [ |
| | | // {value: 'btnMode', label: '按钮式'}, |
| | | // {value: 'buoyMode', label: '浮标式'}, |
| | | // ] |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | field: 'editType', |
| | |
| | | {value: 'multi', label: '整体'}, |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'standard', |
| | | label: '修改标准', |
| | | initval: wrap.standard || 'init', |
| | | tooltip: '如何判断行信息是否应该提交。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'init', label: '与初始值不同'}, |
| | | {value: 'change', label: '存在编辑痕迹'}, |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'cache', |
| | | label: '缓存', |
| | | initval: wrap.cache || 'true', |
| | | tooltip: '对于使用数据源的下拉菜单,下拉选项是否缓存到本地。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'true', label: '使用'}, |
| | | {value: 'false', label: '不使用'}, |
| | | ] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // field: 'cache', |
| | | // label: '缓存', |
| | | // initval: wrap.cache || 'true', |
| | | // tooltip: '对于使用数据源的下拉菜单,下拉选项是否缓存到本地。', |
| | | // required: false, |
| | | // options: [ |
| | | // {value: 'true', label: '使用'}, |
| | | // {value: 'false', label: '不使用'}, |
| | | // ] |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | field: 'tableType', |
| | |
| | | {value: '', label: '不可选'}, |
| | | {value: 'radio', label: '单选'}, |
| | | {value: 'checkbox', label: '多选'}, |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'size', |
| | | label: '表格大小', |
| | | initval: wrap.size || 'middle', |
| | | tooltip: '表格的内边距,从大到小依次递减。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'default', label: '大'}, |
| | | {value: 'middle', label: '中'}, |
| | | {value: 'small', label: '小'}, |
| | | {value: 'mini', label: '迷你'}, |
| | | ] |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'size', |
| | | label: '表格大小', |
| | | initval: wrap.size || 'middle', |
| | | tooltip: '表格的内边距,从大到小依次递减。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'default', label: '大'}, |
| | | {value: 'middle', label: '中'}, |
| | | {value: 'small', label: '小'}, |
| | | {value: 'mini', label: '迷你'}, |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'mode', |
| | | label: '模式', |
| | | initval: wrap.mode || 'default', |
| | |
| | | {value: 'ghost', label: '透明'}, |
| | | ] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // field: 'show', |
| | | // label: '搜索按钮', |
| | | // initval: wrap.show || 'true', |
| | | // tooltip: '搜索条件存在时,可选择是否显示搜索按钮。', |
| | | // required: false, |
| | | // options: [ |
| | | // {value: 'true', label: '显示'}, |
| | | // {value: 'false', label: '隐藏'}, |
| | | // ] |
| | | // }, |
| | | { |
| | | type: 'color', |
| | | field: 'borderColor', |
| | |
| | | {value: 'bottom', label: '向下'}, |
| | | ] |
| | | }, |
| | | // { |
| | | // type: 'color', |
| | | // field: 'color', |
| | | // label: '字体颜色', |
| | | // initval: wrap.color || 'rgba(0, 0, 0, 0.65)', |
| | | // tooltip: '默认值 rgba(0, 0, 0, 0.65)。', |
| | | // required: false |
| | | // }, |
| | | // { |
| | | // type: 'number', |
| | | // field: 'fontSize', |
| | | // label: '字体大小', |
| | | // initval: wrap.fontSize || 14, |
| | | // min: 12, |
| | | // max: 30, |
| | | // precision: 0, |
| | | // required: false |
| | | // }, |
| | | // { |
| | | // type: 'number', |
| | | // field: 'advanceWidth', |
| | | // label: '高级搜索', |
| | | // initval: wrap.advanceWidth || 1000, |
| | | // tooltip: '高级搜索弹窗的宽度,注:当宽度值小于100时表示占窗口的百分比,大于100时表示宽度的绝对值。', |
| | | // min: 10, |
| | | // max: 3000, |
| | | // precision: 0, |
| | | // required: false |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | field: 'permission', |
| | |
| | | ], |
| | | forbid: sessionStorage.getItem('editMenuType') === 'popview' |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // field: 'switchable', |
| | | // label: '状态切换', |
| | | // initval: wrap.switchable || 'true', |
| | | // tooltip: '是否可以在编辑和默认table状态间切换。', |
| | | // required: false, |
| | | // options: [ |
| | | // {value: 'true', label: '启用'}, |
| | | // {value: 'false', label: '禁用'}, |
| | | // ] |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | field: 'empty', |
| | |
| | | import Toast from 'antd-mobile/es/components/toast' |
| | | import Dialog from 'antd-mobile/es/components/dialog' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | |
| | | |
| | | values.uuid = this.state.editItem ? this.state.editItem.uuid : '' |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | let pass = checkSQL(values.sql, 'customscript') |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/,,/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { |
| | | let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql, 'customscript') |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | if (skip) { |
| | | this.setState({ |
| | |
| | | |
| | | let _debugId = md5(r.sql) |
| | | |
| | | if (r.custompage && _columns.findIndex(col => col.field === 'mk_total') === -1) { |
| | | if (r.custompage && setting.laypage === 'true' && _columns.findIndex(col => col.field === 'mk_total') === -1) { |
| | | Modal.warning({ |
| | | title: `数据源或自定义脚本中使用自定义分页排序时,请在字段集中添加 mk_total。`, |
| | | okText: '知道了', |
| | |
| | | import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons' |
| | | |
| | | import { formRule } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import MenuUtils from '@/utils/utils-custom.js' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import KeyInterface from '@/components/keyInterface' |
| | | import './index.scss' |
| | |
| | | |
| | | // 数据源前端验证 |
| | | if (values.interType === 'system' && values.execute !== 'false' && values.dataresource) { |
| | | let _quot = values.dataresource.match(/'{1}/g) |
| | | let _lparen = values.dataresource.match(/\({1}/g) |
| | | let _rparen = values.dataresource.match(/\){1}/g) |
| | | let pass = checkSQL(values.dataresource) |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (/--/ig.test(values.dataresource)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (/,,/ig.test(values.dataresource)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.dataresource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | if (!pass) { |
| | | reject() |
| | | return |
| | | } |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {config.pageable && setting.laypage !== 'false' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="选择分页时有效。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 每页数量 |
| | | </Tooltip> |
| | | }> |
| | | <Form.Item label="每页数量"> |
| | | {getFieldDecorator('pageSize', { |
| | | initialValue: setting.pageSize || 10, |
| | | rules: [ |
| | |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else if (_tailScript) { |
| | | sql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else { |
| | | sql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else if (_tailScript) { |
| | | sql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else { |
| | | sql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | |
| | | if (res.copyType !== 'style') { |
| | | message.warning('配置信息格式错误!', 5) |
| | | return |
| | | } else if (JSON.stringify(res.options) !== JSON.stringify(options)) { |
| | | message.warning('样式选项不一致,不可粘贴!', 5) |
| | | return |
| | | } |
| | | |
| | | let style = res.data || {} |
| | | |
| | | if (JSON.stringify(res.options) !== JSON.stringify(options)) { |
| | | res.options.forEach(n => { |
| | | if (options.includes(n)) return |
| | | |
| | | if (n === 'width') { |
| | | delete style.width |
| | | } else if (n === 'height') { |
| | | delete style.height |
| | | } else if (n === 'font') { |
| | | if (options.includes('font1')) { |
| | | ['lineHeight', 'letterSpacing', 'fontStyle', 'textAlign', 'textDecoration'].forEach(m => { |
| | | delete style[m] |
| | | }) |
| | | } else if (options.includes('font2')) { |
| | | |
| | | } else { |
| | | ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'color', 'fontStyle', 'textAlign', 'textDecoration'].forEach(m => { |
| | | delete style[m] |
| | | }) |
| | | } |
| | | } else if (n === 'font1') { |
| | | if (options.includes('font') || options.includes('font2')) { |
| | | |
| | | } else { |
| | | ['fontSize', 'fontWeight', 'color'].forEach(m => { |
| | | delete style[m] |
| | | }) |
| | | } |
| | | } else if (n === 'font2') { |
| | | if (options.includes('font')) { |
| | | ['textIndent', 'wordBreak'].forEach(m => { |
| | | delete style[m] |
| | | }) |
| | | } else if (options.includes('font1')) { |
| | | ['lineHeight', 'letterSpacing', 'fontStyle', 'textAlign', 'textDecoration', 'textIndent', 'wordBreak'].forEach(m => { |
| | | delete style[m] |
| | | }) |
| | | } else { |
| | | ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'color', 'fontStyle', 'textAlign', 'textDecoration', 'textIndent', 'wordBreak'].forEach(m => { |
| | | delete style[m] |
| | | }) |
| | | } |
| | | } else if (n === 'background') { |
| | | if (!options.includes('backgroundColor')) { |
| | | delete style.backgroundColor |
| | | } |
| | | delete style.backgroundImage |
| | | delete style.backgroundSize |
| | | delete style.backgroundRepeat |
| | | delete style.backgroundPosition |
| | | } else if (n === 'backgroundColor') { |
| | | if (!options.includes('background')) { |
| | | delete style.backgroundColor |
| | | } |
| | | } else if (n === 'border') { |
| | | Object.keys(style).forEach(key => { |
| | | if (!/border/.test(key)) return |
| | | delete style[key] |
| | | }) |
| | | } else if (n === 'shadow') { |
| | | delete style.boxShadow |
| | | delete style.hShadow |
| | | delete style.vShadow |
| | | delete style.shadowBlur |
| | | delete style.shadowColor |
| | | } else if (n === 'margin') { |
| | | delete style.marginTop |
| | | delete style.marginBottom |
| | | delete style.marginLeft |
| | | delete style.marginRight |
| | | } else if (n === 'padding') { |
| | | delete style.paddingTop |
| | | delete style.paddingBottom |
| | | delete style.paddingLeft |
| | | delete style.paddingRight |
| | | } else if (n === 'float') { |
| | | delete style.float |
| | | } else if (n === 'minHeight') { |
| | | delete style.minHeight |
| | | } else if (n === 'clear') { |
| | | delete style.clear |
| | | } else if (n === 'display') { |
| | | delete style.display |
| | | } else if (n === 'position') { |
| | | delete style.position |
| | | delete style.top |
| | | delete style.bottom |
| | | delete style.left |
| | | delete style.right |
| | | } else if (n === 'transform') { |
| | | delete style.transform |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let backgroundImage = '' |
| | | if (style.backgroundImage && /^url/ig.test(style.backgroundImage)) { |
| | | backgroundImage = style.backgroundImage.replace(/^url\(/ig, '').replace(/\)$/ig, '') |
| | |
| | | getPrinter = (item, parentId) => { |
| | | let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) |
| | | |
| | | item.verify.logLabel = item.logLabel |
| | | |
| | | if (_item) { |
| | | item.printer = _item.printer || '' |
| | | item.verify.defaultPrinter = _item.printer || '' |
| | |
| | | |
| | | if (card.datatype === 'static') { |
| | | val = card.value || '' |
| | | if (/@username@|@fullName@|@mk_city@|@bid@/ig.test(val)) { |
| | | if (/@username@|@fullName@|@mk_city@|@appname@|@bid@/ig.test(val)) { |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | let city = sessionStorage.getItem('city') || '' |
| | | let appname = sessionStorage.getItem('appname') || '' |
| | | let bid = data.$$BID || '' |
| | | val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@mk_city@/ig, city).replace(/@bid@/ig, bid) |
| | | val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@mk_city@/ig, city).replace(/@appname@/ig, appname).replace(/@bid@/ig, bid) |
| | | } else if (/@month@/ig.test(val)) { |
| | | val = val.replace(/@month@/ig, new Date().toLocaleString('en-US', { month: 'long' })) |
| | | } else if (/@week@/ig.test(val)) { |
| | |
| | | |
| | | val += _val |
| | | }) |
| | | } else if (data && data.$$empty) { |
| | | } else if (data && data.$$empty && /@.*@/.test(card.formula)) { |
| | | val = '' |
| | | } else if (data) { |
| | | let _val = card.formula |
| | |
| | | |
| | | setTimeout(() => { |
| | | if (col.field === 'debit' && (line.debit || line.debit === 0)) { |
| | | MKEmitter.emit('nextLine', col, record) |
| | | MKEmitter.emit('nextVoucher', col, record) |
| | | } else if (col.field === 'credit') { |
| | | MKEmitter.emit('nextLine', col, record) |
| | | MKEmitter.emit('nextVoucher', col, record) |
| | | } else { |
| | | let cl = {subject_voucher_text: 'subject_code', subject_code: 'debit', debit: 'credit'} |
| | | MKEmitter.emit('tdFocus', cl[col.uuid] + record.uuid) |
| | |
| | | MKEmitter.emit('plusLine', col.tableId, record) |
| | | } |
| | | |
| | | delRecord = () => { |
| | | delVoucher = () => { |
| | | const { col, record } = this.props |
| | | |
| | | MKEmitter.emit('delRecord', col.tableId, record) |
| | | MKEmitter.emit('delVoucher', col.tableId, record) |
| | | } |
| | | |
| | | onSelectBlur = () => { |
| | |
| | | </div> |
| | | } |
| | | } else if (col.field === 'credit') { |
| | | extra = <CloseOutlined onClick={this.delRecord}/> |
| | | extra = <CloseOutlined onClick={this.delVoucher}/> |
| | | |
| | | if (editing) { |
| | | children = <InputNumber id={col.uuid + record.uuid} precision={2} defaultValue={record.credit} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('nextLine', this.nextLine) |
| | | MKEmitter.addListener('plusLine', this.plusLine) |
| | | MKEmitter.addListener('delRecord', this.delRecord) |
| | | MKEmitter.addListener('delVoucher', this.delVoucher) |
| | | MKEmitter.addListener('cleartable', this.cleartable) |
| | | MKEmitter.addListener('nextVoucher', this.nextVoucher) |
| | | MKEmitter.addListener('changeRecord', this.changeRecord) |
| | | } |
| | | |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('nextLine', this.nextLine) |
| | | MKEmitter.removeListener('plusLine', this.plusLine) |
| | | MKEmitter.removeListener('delRecord', this.delRecord) |
| | | MKEmitter.removeListener('delVoucher', this.delVoucher) |
| | | MKEmitter.removeListener('cleartable', this.cleartable) |
| | | MKEmitter.removeListener('nextVoucher', this.nextVoucher) |
| | | MKEmitter.removeListener('changeRecord', this.changeRecord) |
| | | } |
| | | |
| | |
| | | return ChineseStr |
| | | } |
| | | |
| | | nextLine = (col, record) => { |
| | | nextVoucher = (col, record) => { |
| | | const { edData, tableId } = this.state |
| | | |
| | | if (col.tableId !== tableId) return |
| | |
| | | this.props.onChange(_data) |
| | | } |
| | | |
| | | delRecord = (id, record) => { |
| | | delVoucher = (id, record) => { |
| | | const { tableId, edData } = this.state |
| | | |
| | | if (id !== tableId) return |
| | |
| | | rowspans, |
| | | tableId, |
| | | orderfields |
| | | }, () => { |
| | | const element = document.getElementById(tableId) |
| | | element && element.style.setProperty('--mk-table-border-color', setting.borderColor || '#e8e8e8') |
| | | element && element.style.setProperty('--mk-table-color', setting.color || 'rgba(0, 0, 0, 0.65)') |
| | | element && element.style.setProperty('--mk-table-font-size', setting.fontSize || '14px') |
| | | element && element.style.setProperty('--mk-table-font-weight', setting.fontWeight || 'normal') |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | render() { |
| | | const { setting, statFValue, lineMarks, data } = this.props |
| | | const { selectedRowKeys, activeIndex, pickup, tableId, pageOptions, columns, reseting } = this.state |
| | | const { selectedRowKeys, activeIndex, pickup, pageOptions, columns, reseting } = this.state |
| | | |
| | | if (reseting) return null |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | let style = { |
| | | '--mk-table-border-color': setting.borderColor || '#e8e8e8', |
| | | '--mk-table-color': setting.color || 'rgba(0, 0, 0, 0.65)', |
| | | '--mk-table-font-size': setting.fontSize || '14px', |
| | | '--mk-table-font-weight': setting.fontWeight || 'normal' |
| | | } |
| | | |
| | | return ( |
| | | <div className={`normal-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || 'middle'} table-col-${columns.length} ${fixed}`} id={tableId}> |
| | | <div className={`normal-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || 'middle'} table-col-${columns.length} ${fixed}`} style={style}> |
| | | {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && data && data.length > 0 ? |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | |
| | | } |
| | | .main-table-box { |
| | | position: relative; |
| | | min-height: 150px; |
| | | min-height: 40px; |
| | | .main-pickup { |
| | | position: absolute; |
| | | right: 5px; |
| | |
| | | UNSAFE_componentWillMount () { |
| | | let _config = fromJS(this.props.config).toJS() |
| | | let setting = {..._config.setting, ..._config.wrap} |
| | | setting.tableId = Utils.getuuid() |
| | | |
| | | let BID = '' |
| | | let BData = '' |
| | | |
| | | setting.tableId = Utils.getuuid().substr(-6).toUpperCase() |
| | | |
| | | if (_config.setting.supModule) { |
| | | BData = window.GLOB.CacheData.get(_config.setting.supModule) |
| | |
| | | }) |
| | | |
| | | let _columns = [] |
| | | setting.initId = '' |
| | | let triMap = new Map() |
| | | let initId = '' |
| | | |
| | | setting.hasSubmit = false |
| | | if (setting.commit === 'change' || setting.commit === 'simple') { |
| | | setting.commit = 'change' |
| | | } |
| | | |
| | | let getColumns = (cols) => { |
| | | return cols.filter(item => { |
| | |
| | | } |
| | | |
| | | if (item.editable === 'true') { |
| | | setting.hasSubmit = true |
| | | if (!setting.initId) { |
| | | setting.initId = item.uuid |
| | | setting.hasSubmit = setting.commit !== 'change' |
| | | item.$ctrl = setting.commit === 'change' |
| | | |
| | | if (!initId) { |
| | | initId = item.uuid |
| | | } |
| | | if (item.type === 'text' && (item.editType === 'switch' || item.editType === 'select')) { |
| | | triMap.set(item.uuid, item.editType) |
| | | if (item.enter === '$sub') { |
| | | item.enter = '$noAct' |
| | | } else if (item.enter === '$next') { |
| | | item.enter = '$next_' + initId |
| | | } |
| | | if (item.type === 'text' && item.editType === 'select') { |
| | | |
| | | if (item.linkSubField && item.linkSubField.length === 0) { |
| | | item.linkSubField = null |
| | | } |
| | | |
| | | if (item.type === 'number') { |
| | | |
| | | } else if (item.editType === 'select') { |
| | | item.options = item.options || [] |
| | | item.options = item.options.filter(cell => { |
| | | cell.value = cell.Value |
| | |
| | | |
| | | return !cell.Hide |
| | | }) |
| | | } else if (item.editType === 'popSelect') { |
| | | if (item.pops) { |
| | | item.pops.forEach(cell => { |
| | | cell.linkSubField = item.linkSubField |
| | | this.resetPop(cell) |
| | | cell.tabName = cell.initval.replace(/^tab:/, '') |
| | | }) |
| | | } else { |
| | | this.resetPop(item) |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | _columns = getColumns(_config.cols) |
| | | |
| | | if (triMap.size > 0) { |
| | | let setColumns = (cols) => { |
| | | return cols.map(item => { |
| | | if (item.type === 'colspan') { |
| | | item.subcols = setColumns(item.subcols) |
| | | } else if (item.editable === 'true' && triMap.has(item.enter)) { |
| | | item.triType = 'click' |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | _columns = setColumns(_columns) |
| | | |
| | | if (setting.initId && triMap.has(setting.initId)) { |
| | | setting.triType = 'click' |
| | | } |
| | | } |
| | | setting.initId = initId |
| | | |
| | | if (!_config.lineMarks || _config.lineMarks.length === 0) { |
| | | _config.lineMarks = null |
| | |
| | | } |
| | | } else { |
| | | _config.colsCtrls = null |
| | | } |
| | | |
| | | if (setting.commit === 'blur') { |
| | | setting.hasSubmit = false |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | }, _config.setting.delay || 0) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | resetPop = (config) => { |
| | | let arrfield = config.columns.map(f => f.field) |
| | | |
| | | if (config.linkSubField && config.linkSubField.length > 0) { |
| | | config.linkSubField.forEach(n => { |
| | | if (!arrfield.includes(n)) { |
| | | arrfield.push(n) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | config.dataSource = config.dataSource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') |
| | | } else { |
| | | config.dataSource = config.dataSource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | config.dataSource = config.dataSource.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | config.dataSource = config.dataSource.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | config.dataSource = config.dataSource.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | config.dataSource = config.dataSource.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | |
| | | if (/\s/.test(config.dataSource)) { // 拼接别名 |
| | | config.dataSource = '(' + config.dataSource + ') tb' |
| | | } |
| | | |
| | | let labels = {} |
| | | config.cols = [] |
| | | config.columns.forEach(col => { |
| | | labels[col.field] = col.label |
| | | |
| | | if (col.Hide === 'true') return |
| | | |
| | | config.cols.push({ |
| | | dataIndex: col.field, |
| | | title: col.label, |
| | | sorter: col.IsSort === 'true', |
| | | width: col.Width || 120 |
| | | }) |
| | | }) |
| | | |
| | | let placeholder = '' |
| | | if (!config.searchKey) { |
| | | config.onload = 'true' |
| | | } else { |
| | | placeholder = [] |
| | | config.searchKey.split(',').forEach(key => { |
| | | if (!labels[key]) { |
| | | placeholder = '' |
| | | } else if (placeholder) { |
| | | placeholder.push(labels[key]) |
| | | } |
| | | }) |
| | | |
| | | placeholder = placeholder ? placeholder.join('、') : '' |
| | | } |
| | | |
| | | config.placeholder = placeholder |
| | | config.arr_field = arrfield.join(',') |
| | | } |
| | | |
| | | /** |
| | |
| | | loading: false |
| | | }) |
| | | |
| | | MKEmitter.emit('transferData', config.uuid, data) |
| | | MKEmitter.emit('transferData' + setting.tableId, data) |
| | | |
| | | if (result.message) { |
| | | if (result.ErrCode === 'Y') { |
| | |
| | | return item |
| | | }) |
| | | |
| | | MKEmitter.emit('transferData', config.uuid, _data, 'line') |
| | | MKEmitter.emit('transferData' + setting.tableId, _data, 'line') |
| | | MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid, _data) |
| | | |
| | | this.setState({ |
| | |
| | | |
| | | const { Paragraph } = Typography |
| | | const MkIcon = asyncComponent(() => import('@/components/mk-icon')) |
| | | const MKPopSelect = asyncComponent(() => import('./mkPopSelect')) |
| | | const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList')) |
| | | |
| | | class CusSwitch extends Component { |
| | | class MkSwitch extends Component { |
| | | static propTpyes = { |
| | | autoFocus: PropTypes.bool, |
| | | defaultValue: PropTypes.any, |
| | | autoFocus: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func |
| | | } |
| | |
| | | state = { |
| | | status: false |
| | | } |
| | | |
| | | node = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { defaultValue, config } = this.props |
| | |
| | | } |
| | | |
| | | 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) |
| | | }) |
| | | const { config, lineId } = this.props |
| | | |
| | | this.setState({ status: val }) |
| | | |
| | | let values = {[config.field]: val ? config.openVal : config.closeVal} |
| | | |
| | | this.props.onChange(values, '') |
| | | |
| | | this.node.blur() |
| | | |
| | | if (config.enter === '$noAct') return |
| | | |
| | | if (/\$next/.test(config.enter)) { |
| | | MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', '')) |
| | | } else { |
| | | MKEmitter.emit('setFocus' + config.tableId, lineId, config.enter) |
| | | } |
| | | } |
| | | |
| | | onFocus = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (!config.$ctrl) return |
| | | |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | onBlur = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | this.props.onBlur && this.props.onBlur() |
| | | } |
| | | |
| | | 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} /> |
| | | <Switch |
| | | ref={ref => this.node = ref} |
| | | checkedChildren={config.openText} |
| | | checked={status} |
| | | autoFocus={autoFocus} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | unCheckedChildren={config.closeText} |
| | | onChange={this.changeStatus} |
| | | /> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class CusDatePicker extends Component { |
| | | class MkDatePicker extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func, |
| | | blur: PropTypes.func |
| | | onChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { value, open } = this.props |
| | | const { defaultValue } = this.props |
| | | |
| | | let _value = value || null |
| | | let _value = defaultValue || null |
| | | if (_value) { |
| | | _value = moment(_value, 'YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | this.setState({value: _value, open: open === true}) |
| | | this.setState({value: _value}) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { config, autoFocus, lineId } = this.props |
| | | |
| | | if (autoFocus === true) { |
| | | this.setState({open: true}) |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } |
| | | } |
| | | |
| | | MKEmitter.addListener('setFocus' + config.tableId, this.setFocus) |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | |
| | | MKEmitter.removeListener('setFocus' + this.props.config.tableId, this.setFocus) |
| | | } |
| | | |
| | | setFocus = (lId, colId) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (lId !== lineId || config.uuid !== colId) return |
| | | |
| | | this.setState({open: true}) |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } |
| | | } |
| | | |
| | | onOpenChange = (open) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | this.setState({open}) |
| | | |
| | | if (open === false) { |
| | | this.props.blur() |
| | | if (!open) { |
| | | this.props.onBlur && this.props.onBlur() |
| | | } |
| | | |
| | | if (!config.$ctrl) return |
| | | |
| | | if (open) { |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } else { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | } |
| | | |
| | | onChange = (val) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | let _val = val ? moment(val).format(config.format) : '' |
| | | |
| | | if (config.precision === 'hour') { |
| | | _val = _val + ':00:00' |
| | | } else if (config.precision === 'minute') { |
| | | _val = _val + ':00' |
| | | } |
| | | |
| | | let values = {[config.field]: _val} |
| | | |
| | | this.props.onChange(values) |
| | | |
| | | if (config.enter === '$noAct') return |
| | | |
| | | if (/\$next/.test(config.enter)) { |
| | | MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', '')) |
| | | } else { |
| | | MKEmitter.emit('setFocus' + config.tableId, lineId, config.enter) |
| | | } |
| | | } |
| | | |
| | |
| | | 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}/> |
| | | <DatePicker dropdownClassName={'mk-date-picker ' + config.precision} showTime={config.format !== 'YYYY-MM-DD'} format={config.format} open={open} defaultValue={value} onChange={this.onChange} onOpenChange={this.onOpenChange}/> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class MkSelect extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | lineId: PropTypes.string, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func, |
| | | } |
| | | |
| | | state = { |
| | | value: '' |
| | | } |
| | | |
| | | node = null |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { defaultValue } = this.props |
| | | |
| | | this.setState({value: defaultValue}) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { config, autoFocus, lineId } = this.props |
| | | |
| | | if (autoFocus) { |
| | | let node = document.getElementById(config.uuid + lineId) |
| | | node && node.click() |
| | | } |
| | | MKEmitter.addListener('setFocus' + config.tableId, this.setFocus) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (nextProps.defaultValue !== this.props.defaultValue) { |
| | | this.setState({value: nextProps.defaultValue}) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | |
| | | MKEmitter.removeListener('setFocus' + this.props.config.tableId, this.setFocus) |
| | | } |
| | | |
| | | setFocus = (lId, colId) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (lId !== lineId || config.uuid !== colId) return |
| | | |
| | | let node = document.getElementById(config.uuid + lineId) |
| | | node && node.click() |
| | | } |
| | | |
| | | onSelectChange = (val, option) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | let values = {} |
| | | let _option = config.options.filter(m => m.key === option.key)[0] |
| | | |
| | | if (_option) { |
| | | if (config.linkSubField) { |
| | | config.linkSubField.forEach((m, i) => { |
| | | values[m] = _option[m] !== undefined ? _option[m] : '' |
| | | }) |
| | | } |
| | | |
| | | values[config.field] = val |
| | | } |
| | | |
| | | this.setState({value: val}) |
| | | |
| | | this.props.onChange(values, val) |
| | | |
| | | this.node.blur() |
| | | |
| | | if (config.enter === '$noAct') return |
| | | |
| | | setTimeout(() => { |
| | | if (/\$next/.test(config.enter)) { |
| | | MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', '')) |
| | | } else { |
| | | MKEmitter.emit('setFocus' + config.tableId, lineId, config.enter) |
| | | } |
| | | }, 100) |
| | | } |
| | | |
| | | onFocus = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (!config.$ctrl) return |
| | | |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | onBlur = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | setTimeout(() => { |
| | | this.props.onBlur && this.props.onBlur() |
| | | }, 10) |
| | | } |
| | | |
| | | render() { |
| | | const { config, lineId } = this.props |
| | | const { value } = this.state |
| | | |
| | | return ( |
| | | <Select |
| | | showSearch |
| | | dropdownClassName="edit-table-dropdown" |
| | | dropdownMatchSelectWidth={config.dropdown === 'fixed'} |
| | | value={value} |
| | | id={config.uuid + lineId} |
| | | ref={ref => this.node = ref} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.onSelectChange} |
| | | > |
| | | {config.options.map(item => (<Select.Option key={item.key} disabled={item.$disabled} value={item.value}>{item.label}</Select.Option>))} |
| | | </Select> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class MkInput extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | lineId: PropTypes.string, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | value: null, |
| | | err: null |
| | | } |
| | | |
| | | node = null |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { defaultValue } = this.props |
| | | |
| | | this.setState({value: defaultValue}) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { config, autoFocus } = this.props |
| | | |
| | | if (autoFocus) { |
| | | this.node.select() |
| | | } |
| | | MKEmitter.addListener('setFocus' + config.tableId, this.setFocus) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (nextProps.defaultValue !== this.props.defaultValue) { |
| | | this.setState({value: nextProps.defaultValue}) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | |
| | | MKEmitter.removeListener('setFocus' + this.props.config.tableId, this.setFocus) |
| | | } |
| | | |
| | | setFocus = (lId, colId) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (lId !== lineId || config.uuid !== colId) return |
| | | |
| | | this.node.select() |
| | | } |
| | | |
| | | onChange = (val) => { |
| | | this.setState({value: val}) |
| | | } |
| | | |
| | | onFocus = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (!config.$ctrl) return |
| | | |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | enterPress = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | this.node.blur() |
| | | |
| | | if (config.enter === '$noAct') return |
| | | |
| | | if (/\$next/.test(config.enter)) { |
| | | MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', '')) |
| | | } else { |
| | | MKEmitter.emit('setFocus' + config.tableId, lineId, config.enter) |
| | | } |
| | | } |
| | | |
| | | onBlur = () => { |
| | | const { config, lineId } = this.props |
| | | const { value } = this.state |
| | | |
| | | let err = null |
| | | |
| | | if (config.required === 'true' && !value) { |
| | | err = '请填写' + config.label |
| | | } |
| | | |
| | | this.setState({err}) |
| | | |
| | | this.props.onChange({[config.field]: value}) |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | this.props.onBlur && this.props.onBlur() |
| | | } |
| | | |
| | | render() { |
| | | const { value, err } = this.state |
| | | |
| | | return ( |
| | | <Input |
| | | title={err} |
| | | className={err ? 'has-error' : ''} |
| | | ref={ref => this.node = ref} |
| | | value={value} |
| | | onChange={(e) => this.onChange(e.target.value)} |
| | | onPressEnter={this.enterPress} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | /> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class MkInputNumber extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | lineId: PropTypes.string, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | value: null, |
| | | err: null, |
| | | clear: false |
| | | } |
| | | |
| | | node = null |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { defaultValue } = this.props |
| | | |
| | | this.setState({value: defaultValue}) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { config, autoFocus } = this.props |
| | | |
| | | if (autoFocus) { |
| | | this.node.focus() |
| | | } |
| | | MKEmitter.addListener('setFocus' + config.tableId, this.setFocus) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (nextProps.defaultValue !== this.props.defaultValue) { |
| | | this.setState({value: nextProps.defaultValue}) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | |
| | | MKEmitter.removeListener('setFocus' + this.props.config.tableId, this.setFocus) |
| | | } |
| | | |
| | | setFocus = (lId, colId) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (lId !== lineId || config.uuid !== colId) return |
| | | |
| | | this.node.focus() |
| | | } |
| | | |
| | | onChange = (val) => { |
| | | const { config } = this.props |
| | | |
| | | this.setState({value: val}) |
| | | |
| | | if (config.clearField && val && !this.state.clear) { |
| | | this.setState({clear: true}) |
| | | |
| | | this.props.onChange({[config.clearField]: ''}) |
| | | } |
| | | } |
| | | |
| | | onFocus = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | this.setState({clear: false}) |
| | | |
| | | if (!config.$ctrl) return |
| | | |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | enterPress = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | this.node.blur() |
| | | |
| | | if (config.enter === '$noAct') return |
| | | |
| | | setTimeout(() => { |
| | | if (/\$next/.test(config.enter)) { |
| | | MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', '')) |
| | | } else { |
| | | MKEmitter.emit('setFocus' + config.tableId, lineId, config.enter) |
| | | } |
| | | }, 10) |
| | | } |
| | | |
| | | onBlur = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | setTimeout(() => { |
| | | let err = null |
| | | let value = this.state.value |
| | | |
| | | if (config.noValue === 'hide' && !value) { |
| | | value = 0 |
| | | } else { |
| | | if (typeof(config.max) === 'number' && value > config.max) { |
| | | err = config.label + '最大为' + config.max |
| | | } else if (typeof(config.min) === 'number' && value < config.min) { |
| | | err = config.label + '最小为' + config.min |
| | | } |
| | | } |
| | | |
| | | this.setState({err}) |
| | | |
| | | this.props.onChange({[config.field]: value}) |
| | | |
| | | this.props.onBlur && this.props.onBlur() |
| | | }, 5) |
| | | } |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { value, err } = this.state |
| | | |
| | | return ( |
| | | <InputNumber |
| | | title={err} |
| | | className={err ? 'has-error' : ''} |
| | | ref={ref => this.node = ref} |
| | | precision={config.decimal || 0} |
| | | value={value} |
| | | onChange={(value) => this.onChange(value)} |
| | | onPressEnter={this.enterPress} |
| | | onFocus={this.onFocus} |
| | | onBlur={this.onBlur} |
| | | /> |
| | | ) |
| | | } |
| | | } |
| | |
| | | |
| | | class BodyCell extends React.Component { |
| | | state = { |
| | | editing: false, |
| | | err: null, |
| | | value: '' |
| | | editing: false |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { col } = this.props |
| | | |
| | | if (col && col.editable === 'true') { |
| | | MKEmitter.addListener('setFocus' + col.tableId, this.setFocus) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | if (this.props.col) { |
| | | MKEmitter.removeListener('setFocus' + this.props.col.tableId, this.setFocus) |
| | | } |
| | | } |
| | | |
| | | enterPress = () => { |
| | | setFocus = (lId, colId) => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | 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) |
| | | if (lId !== record.$$uuid || col.uuid !== colId) return |
| | | if (col.ctrlField && col.ctrlValue.includes(record[col.ctrlField] + '')) return |
| | | |
| | | if (value !== record[col.field]) { |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: value}) |
| | | } |
| | | this.setState({editing: true}) |
| | | } |
| | | |
| | | focus = () => { |
| | | const { col, record } = this.props |
| | | |
| | | if (col.ctrlField && col.ctrlValue.includes(record[col.ctrlField])) return |
| | | if (col.ctrlField && col.ctrlValue.includes(record[col.ctrlField] + '')) return |
| | | |
| | | if (col.editType === 'switch' || col.editType === 'select') { |
| | | this.setState({editing: true}, () => { |
| | | let node = document.getElementById(col.uuid + record.$$uuid) |
| | | node && node.click() |
| | | }) |
| | | } else { |
| | | let err = null |
| | | let val = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (col.type === 'number') { |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | err = col.label + '最大为' + col.max |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = col.label + '最小为' + col.min |
| | | } |
| | | } else if (col.required === 'true' && !val) { |
| | | err = '请填写' + col.label |
| | | } |
| | | |
| | | this.setState({editing: true, value: val, err}, () => { |
| | | let node = document.getElementById(col.uuid + record.$$uuid) |
| | | node && node.select() |
| | | }) |
| | | } |
| | | this.setState({editing: true}) |
| | | } |
| | | |
| | | onBlur = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | this.setState({editing: false}) |
| | | |
| | | if (value !== record[col.field]) { |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: value}) |
| | | } |
| | | } |
| | | |
| | | onChange = (val) => { |
| | | const { col } = this.props |
| | | |
| | | let err = null |
| | | |
| | | if (col.type === 'number') { |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | err = col.label + '最大为' + col.max |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = col.label + '最小为' + col.min |
| | | } |
| | | } else if (col.required === 'true' && !val) { |
| | | err = '请填写' + col.label |
| | | } |
| | | |
| | | this.setState({value: val, err}) |
| | | } |
| | | |
| | | onSwitchChange = (val, label) => { |
| | | onColChange = (values) => { |
| | | const { col, record } = this.props |
| | | |
| | | 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}) |
| | | } |
| | | |
| | | onSelectChange = (val, option) => { |
| | | const { col, record } = this.props |
| | | |
| | | let values = {} |
| | | let _option = col.options.filter(m => m.key === option.key)[0] |
| | | |
| | | if (_option) { |
| | | if (col.linkSubField) { |
| | | col.linkSubField.forEach(m => { |
| | | values[m] = _option[m] !== undefined ? _option[m] : '' |
| | | }) |
| | | } |
| | | |
| | | values[col.field] = val |
| | | } |
| | | |
| | | 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, ...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}) |
| | | }, 10) |
| | | MKEmitter.emit('changeRecord' + col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | render() { |
| | | let { col, config, record, style, className, ...resProps } = this.props |
| | | const { editing, value, err } = this.state |
| | | const { editing } = this.state |
| | | |
| | | if (!col) return (<td {...resProps} className={className} style={style}/>) |
| | | |
| | | let disabled = false |
| | | if (col.ctrlField) { |
| | | disabled = col.ctrlValue.includes(record[col.ctrlField]) |
| | | disabled = col.ctrlValue.includes(record[col.ctrlField] + '') |
| | | } |
| | | |
| | | let children = null |
| | |
| | | |
| | | if (col.editType === 'select' && col.options.length > 0) { |
| | | content = col.map.get(content) || content |
| | | } else if (col.editType === 'switch') { |
| | | if (content === config.openVal) { |
| | | content = config.openText |
| | | } else if (content === config.closeVal) { |
| | | content = config.closeText |
| | | } |
| | | } |
| | | |
| | | if (content !== '') { |
| | |
| | | |
| | | if (col.editable === 'true' && !disabled) { |
| | | if (editing) { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (!col.editType || col.editType === 'text') { |
| | | return (<td onClick={(e) => e.stopPropagation()} 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}/> |
| | | <MkInput config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'date') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <CusDatePicker config={col} value={record[col.field] || null} open={true} onChange={this.onDateChange} blur={() => this.setState({editing: false})}/> |
| | | <MkDatePicker config={col} lineId={record.$$uuid} defaultValue={_value || null} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | } else if (col.editType === 'popSelect') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <CusSwitch config={col} defaultValue={_value} autoFocus={true} onChange={this.onSwitchChange} onBlur={this.switchBlur}/> |
| | | <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} BID={record.$$BID} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <Select |
| | | showSearch |
| | | defaultValue={_value} |
| | | dropdownClassName="edit-table-dropdown" |
| | | dropdownMatchSelectWidth={col.dropdown === 'fixed'} |
| | | id={col.uuid + record.$$uuid} |
| | | onBlur={() => this.setState({editing: false})} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.onSelectChange} |
| | | > |
| | | {col.options.map((item, i) => (<Select.Option key={item.key} disabled={item.$disabled} value={item.value}>{item.label}</Select.Option>))} |
| | | </Select> |
| | | <MkSelect config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } |
| | | } else { |
| | |
| | | |
| | | if (col.editable === 'true' && !disabled) { |
| | | if (editing) { |
| | | let val = value |
| | | if (col.noValue === 'hide' && value === 0) { |
| | | let val = record[col.field] !== undefined ? record[col.field] : '' |
| | | if (col.noValue === 'hide' && val === 0) { |
| | | val = '' |
| | | } |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <InputNumber className={err ? 'has-error' : ''} precision={col.decimal || 0} title={err} id={col.uuid + record.$$uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | <MkInputNumber config={col} lineId={record.$$uuid} defaultValue={val} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else { |
| | | return (<td onClick={(e) => e.stopPropagation()} className={className + ' pointer'} style={style}> |
| | |
| | | } |
| | | |
| | | class BodyAllCell extends React.Component { |
| | | state = { |
| | | err: null, |
| | | value: '' |
| | | } |
| | | state = {} |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props.record), fromJS(nextProps.record)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { col } = this.props |
| | | |
| | | if (col && col.editable === 'true') { |
| | | this.setState({value: this.props.record[col.field]}) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { col } = this.props |
| | | const { value } = this.state |
| | | |
| | | if (col && col.editable === 'true' && nextProps.record[col.field] !== value) { |
| | | this.setState({value: nextProps.record[col.field]}) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | enterPress = () => { |
| | | onColChange = (values) => { |
| | | const { col, record } = this.props |
| | | |
| | | this.onBlur() |
| | | |
| | | 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) |
| | | |
| | | if (node) { |
| | | if (col.triType === 'click') { |
| | | node.click() |
| | | } else { |
| | | node.select && node.select() |
| | | } |
| | | } |
| | | } |
| | | }, 50) |
| | | } |
| | | |
| | | onChange = (val) => { |
| | | const { col } = this.props |
| | | |
| | | if (col.noValue === 'hide' && val === null) { |
| | | this.setState({value: 0}) |
| | | } else { |
| | | this.setState({value: val}) |
| | | } |
| | | } |
| | | |
| | | onBlur = () => { |
| | | const { col, record } = this.props |
| | | const { value } = this.state |
| | | |
| | | let err = null |
| | | let val = value |
| | | |
| | | if (col.type === 'number') { |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | err = col.label + '最大为' + col.max |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = col.label + '最小为' + col.min |
| | | } |
| | | } else if (col.required === 'true' && !val) { |
| | | err = '请填写' + col.label |
| | | } |
| | | |
| | | this.setState({err}) |
| | | |
| | | if (value !== record[col.field]) { |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | } |
| | | } |
| | | |
| | | onSwitchChange = (val, label) => { |
| | | const { col, record } = this.props |
| | | |
| | | 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) |
| | | if (node) { |
| | | if (col.triType === 'click') { |
| | | node.click() |
| | | } else { |
| | | node.select && node.select() |
| | | } |
| | | } |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | } |
| | | |
| | | onSelectChange = (val, option) => { |
| | | const { col, record } = this.props |
| | | |
| | | let values = {} |
| | | let _option = col.options.filter(m => m.key === option.key)[0] |
| | | |
| | | if (_option) { |
| | | if (col.linkSubField) { |
| | | col.linkSubField.forEach(m => { |
| | | values[m] = _option[m] !== undefined ? _option[m] : '' |
| | | }) |
| | | } |
| | | |
| | | values[col.field] = val |
| | | } |
| | | |
| | | 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) |
| | | if (node) { |
| | | if (col.triType === 'click') { |
| | | node.click() |
| | | } else { |
| | | node.select && node.select() |
| | | } |
| | | } |
| | | } |
| | | }, 50) |
| | | |
| | | 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}) |
| | | MKEmitter.emit('changeRecord' + col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | render() { |
| | | let { col, config, record, style, className, ...resProps } = this.props |
| | | const { err } = this.state |
| | | |
| | | if (!col) return (<td {...resProps} className={className} style={style}/>) |
| | | |
| | | let disabled = false |
| | | let editable = false |
| | | if (col.ctrlField) { |
| | | disabled = col.ctrlValue.includes(record[col.ctrlField]) |
| | | disabled = col.ctrlValue.includes(record[col.ctrlField] + '') |
| | | } |
| | | |
| | | let children = null |
| | |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (!col.editType || col.editType === 'text') { |
| | | children = (<> |
| | | <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}/> |
| | | </>) |
| | | children = ( |
| | | <MkInput config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={false} onChange={this.onColChange}/> |
| | | ) |
| | | } else if (col.editType === 'switch') { |
| | | children = ( |
| | | <CusSwitch config={col} autoFocus={false} defaultValue={_value} onChange={this.onSwitchChange} onBlur={() => {}}/> |
| | | <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={false} onChange={this.onColChange}/> |
| | | ) |
| | | } else if (col.editType === 'date') { |
| | | children = ( |
| | | <CusDatePicker config={col} value={record[col.field] || null} onChange={this.onDateChange} blur={() => {}}/> |
| | | <MkDatePicker config={col} lineId={record.$$uuid} defaultValue={_value || null} autoFocus={false} onChange={this.onColChange}/> |
| | | ) |
| | | } else if (col.editType === 'popSelect') { |
| | | children = ( |
| | | <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} BID={record.$$BID} autoFocus={false} onChange={this.onColChange}/> |
| | | ) |
| | | } else { |
| | | children = (<> |
| | | <Select |
| | | showSearch |
| | | dropdownClassName="edit-table-dropdown" |
| | | dropdownMatchSelectWidth={col.dropdown === 'fixed'} |
| | | defaultValue={_value} |
| | | id={col.uuid + record.$$uuid} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.onSelectChange} |
| | | > |
| | | {col.options.map((item, i) => (<Select.Option key={item.key} disabled={item.$disabled} value={item.value}>{item.label}</Select.Option>))} |
| | | </Select> |
| | | </>) |
| | | children = ( |
| | | <MkSelect config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={false} onChange={this.onColChange} /> |
| | | ) |
| | | } |
| | | } else { |
| | | let content = '' |
| | |
| | | |
| | | if (col.editType === 'select' && col.options.length > 0) { |
| | | content = col.map.get(content) || content |
| | | } else if (col.editType === 'switch') { |
| | | if (content === config.openVal) { |
| | | content = config.openText |
| | | } else if (content === config.closeVal) { |
| | | content = config.closeText |
| | | } |
| | | } |
| | | |
| | | if (content !== '') { |
| | |
| | | _value = '' |
| | | } |
| | | |
| | | children = (<> |
| | | <InputNumber className={err ? 'has-error' : ''} title={err} precision={col.decimal || 0} id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | </>) |
| | | children = ( |
| | | <MkInputNumber config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={false} onChange={this.onColChange}/> |
| | | ) |
| | | } else { |
| | | let content = '' |
| | | try { |
| | |
| | | pageSize: 10, // 每页数据条数 |
| | | columns: null, // 显示列 |
| | | forms: [], |
| | | signForms: [], |
| | | orderfields: {}, // 排序id与field转换 |
| | | loading: false, |
| | | pageOptions: [], |
| | |
| | | visible: false, |
| | | midData: null, |
| | | allColumns: null, |
| | | checkForms: [], |
| | | allForms: [], |
| | | reseting: false |
| | | } |
| | | |
| | | timer = null |
| | | focusId = '' |
| | | blurId = '' |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { setting, fields, columns, BID, colsCtrls } = this.props |
| | |
| | | let deForms = [] |
| | | let _forms = {} |
| | | let hasBid = false |
| | | let signForms = [] |
| | | let index = 0 |
| | | let checkForms = [] |
| | | let allForms = [] |
| | | |
| | | let getColumns = (cols) => { |
| | | let getColumns = (cols, sk) => { |
| | | return cols.map(item => { |
| | | let cell = null |
| | | |
| | | if (item.type === 'colspan') { |
| | | cell = { title: item.label, align: item.Align, $key: item.uuid } |
| | | cell.children = getColumns(item.subcols) |
| | | cell.children = getColumns(item.subcols, sk || item.uuid) |
| | | } else { |
| | | if (item.editable === 'true') { |
| | | item.$sort = index |
| | | index++ |
| | | _forms[item.field] = item |
| | | |
| | | signForms.push(item.field) |
| | | allForms.push({uuid: sk || item.uuid, field: item.field}) |
| | | checkForms.push(item.field) |
| | | |
| | | if (item.ctrlField) { |
| | | item.ctrlValue = item.ctrlValue.split(',') |
| | | } |
| | | |
| | | if (item.type === 'text' && item.editType === 'select') { |
| | | if (item.type === 'number' && item.clearField) { |
| | | fields.forEach(cell => { |
| | | if (cell.field === item.clearField) { |
| | | item.clearName = cell.label |
| | | } |
| | | }) |
| | | } else if (item.type === 'text' && item.editType === 'select') { |
| | | item.map = new Map() |
| | | if (item.resourceType === '1') { |
| | | let _option = Utils.getSelectQueryOptions(item) |
| | | |
| | | if (/@BID@/ig.test(_option.sql)) { |
| | | if (/@BID@/ig.test(_option.sql) && setting.supModule) { |
| | | hasBid = true |
| | | } |
| | | |
| | |
| | | title: item.editable === 'true' ? <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> : item.label, |
| | | sorter: (item.field || item.sortField) && item.IsSort === 'true', |
| | | width: item.Width || 120, |
| | | // $type: item.type, |
| | | $key: item.uuid, |
| | | onCell: record => ({ |
| | | record, |
| | |
| | | } else { |
| | | _item.datatype = item.datatype |
| | | } |
| | | |
| | | forms.push(_item) |
| | | } else { |
| | | forms.push(item) |
| | | forms.push({...item, $sort: 999}) |
| | | } |
| | | }) |
| | | |
| | | forms.sort((a, b) => a.$sort - b.$sort) |
| | | |
| | | let size = (setting.pageSize || 10) + '' |
| | | let pageOptions = ['10', '25', '50', '100', '500', '1000'] |
| | |
| | | let allColumns = null |
| | | if (colsCtrls) { |
| | | allColumns = [..._columns] |
| | | _columns = this.getCurColumns(_columns, this.props.allSearch) |
| | | checkForms = [] |
| | | _columns = this.getCurColumns(_columns, this.props.allSearch, allForms, checkForms) |
| | | } else { |
| | | allForms = null |
| | | } |
| | | |
| | | checkForms = Array.from(new Set(checkForms)) |
| | | |
| | | this.setState({ |
| | | forms, |
| | | signForms, |
| | | allForms, |
| | | allColumns, |
| | | checkForms, |
| | | pageSize: setting.pageSize || 10, |
| | | pageOptions, |
| | | columns: _columns, |
| | | tableId: setting.tableId, |
| | | orderfields |
| | | orderfields, |
| | | deForms: hasBid ? deForms : null |
| | | }, () => { |
| | | if (deForms.length > 0) { |
| | | if (hasBid && setting.supModule && !BID) { |
| | | this.setState({ deForms }) |
| | | } else { |
| | | this.improveActionForm(deForms, BID) |
| | | } |
| | | if (deForms.length > 0 && (!hasBid || BID)) { |
| | | this.improveActionForm(deForms, BID) |
| | | } |
| | | |
| | | const element = document.getElementById(setting.tableId) |
| | | element && element.style.setProperty('--mk-table-border-color', setting.borderColor || '#e8e8e8') |
| | | element && element.style.setProperty('--mk-table-color', setting.color || 'rgba(0, 0, 0, 0.65)') |
| | | element && element.style.setProperty('--mk-table-font-size', setting.fontSize || '14px') |
| | | element && element.style.setProperty('--mk-table-font-weight', setting.fontWeight || 'normal') |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('subLine', this.subLine) |
| | | MKEmitter.addListener('nextLine', this.nextLine) |
| | | MKEmitter.addListener('addRecord', this.addRecord) |
| | | MKEmitter.addListener('delRecord', this.delRecord) |
| | | const { setting } = this.props |
| | | const { tableId } = this.state |
| | | |
| | | if (setting.commit === 'change') { |
| | | MKEmitter.addListener('colBlur' + tableId, this.colBlur) |
| | | MKEmitter.addListener('colFocus' + tableId, this.colFocus) |
| | | } |
| | | |
| | | MKEmitter.addListener('resetTable', this.resetTable) |
| | | MKEmitter.addListener('transferData', this.transferData) |
| | | MKEmitter.addListener('changeRecord', this.changeRecord) |
| | | MKEmitter.addListener('nextLine' + tableId, this.nextLine) |
| | | MKEmitter.addListener('addRecord' + tableId, this.plusLine) |
| | | MKEmitter.addListener('delRecord' + tableId, this.delRecord) |
| | | MKEmitter.addListener('transferData' + tableId, this.transferData) |
| | | MKEmitter.addListener('changeRecord' + tableId, this.changeRecord) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | | componentWillUnmount () { |
| | | const { tableId } = this.state |
| | | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('subLine', this.subLine) |
| | | MKEmitter.removeListener('nextLine', this.nextLine) |
| | | MKEmitter.removeListener('addRecord', this.addRecord) |
| | | MKEmitter.removeListener('delRecord', this.delRecord) |
| | | |
| | | MKEmitter.removeListener('resetTable', this.resetTable) |
| | | MKEmitter.removeListener('transferData', this.transferData) |
| | | MKEmitter.removeListener('changeRecord', this.changeRecord) |
| | | MKEmitter.removeListener('colBlur' + tableId, this.colBlur) |
| | | MKEmitter.removeListener('colFocus' + tableId, this.colFocus) |
| | | MKEmitter.removeListener('nextLine' + tableId, this.nextLine) |
| | | MKEmitter.removeListener('addRecord' + tableId, this.plusLine) |
| | | MKEmitter.removeListener('delRecord' + tableId, this.delRecord) |
| | | MKEmitter.removeListener('transferData' + tableId, this.transferData) |
| | | MKEmitter.removeListener('changeRecord' + tableId, this.changeRecord) |
| | | } |
| | | |
| | | getCurColumns = (columns, allSearch) => { |
| | | colBlur = (lineId) => { |
| | | this.blurId = lineId |
| | | this.focusId = '' |
| | | |
| | | this.timer && clearTimeout(this.timer) |
| | | |
| | | this.timer = setTimeout(() => { |
| | | if (!this.focusId || this.focusId !== this.blurId) { |
| | | this.checkLine() |
| | | } |
| | | }, 150) |
| | | } |
| | | |
| | | colFocus = (lineId) => { |
| | | this.focusId = lineId |
| | | } |
| | | |
| | | checkLine = () => { |
| | | const { edData, forms, checkForms } = this.state |
| | | |
| | | let data = edData.filter(item => item.$$uuid === this.blurId)[0] |
| | | |
| | | if (!data) return |
| | | |
| | | let record = fromJS(data).toJS() |
| | | |
| | | let value = '' |
| | | Object.keys(record).sort().forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | value += record[key] |
| | | }) |
| | | |
| | | if (record.$sign === md5(value)) return |
| | | |
| | | let err = '' |
| | | forms.forEach(col => { |
| | | let check = true |
| | | if (col.editable !== 'true' || !checkForms.includes(col.field)) { |
| | | check = false |
| | | } |
| | | if (col.ctrlField && col.ctrlValue.includes(record[col.ctrlField] + '')) { |
| | | check = false |
| | | } |
| | | |
| | | if (!check) { |
| | | if (col.type === 'number') { |
| | | record[col.field] = +record[col.field] |
| | | if (isNaN(record[col.field])) { |
| | | record[col.field] = 0 |
| | | } |
| | | } else { |
| | | record[col.field] = record[col.field] !== undefined ? (record[col.field] + '') : '' |
| | | } |
| | | return |
| | | } |
| | | |
| | | if (err) return |
| | | |
| | | if (col.type === 'text') { |
| | | let val = record[col.field] !== undefined ? (record[col.field] + '') : '' |
| | | if (col.required === 'true' && !val) { |
| | | err = `${col.label}不可为空` |
| | | } else if (col.datatype === 'datetime' && !val) { |
| | | val = '1949-10-01' |
| | | } |
| | | record[col.field] = val |
| | | } else if (col.type === 'number') { |
| | | let val = record[col.field] |
| | | |
| | | if (col.noValue === 'hide' && !val) { |
| | | if (col.clearField && checkForms.includes(col.clearField) && !record[col.clearField]) { |
| | | err = `请填写 ${col.label} 或 ${col.clearName}` |
| | | } |
| | | val = 0 |
| | | } else if (!val && val !== 0) { |
| | | err = `${col.label}不可为空` |
| | | } else { |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | err = `${col.label}数据格式错误` |
| | | return |
| | | } |
| | | |
| | | val = +val.toFixed(col.decimal || 0) |
| | | |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | err = `${col.label}不可大于${col.max}` |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = `${col.label}不可小于${col.min}` |
| | | } |
| | | } |
| | | |
| | | record[col.field] = val |
| | | } |
| | | }) |
| | | |
| | | if (err) { |
| | | message.warning(err) |
| | | return |
| | | } |
| | | |
| | | this.submit(record) |
| | | } |
| | | |
| | | getCurColumns = (columns, allSearch, allForms, checkForms) => { |
| | | const { colsCtrls } = this.props |
| | | |
| | | let values = {} |
| | |
| | | }) |
| | | |
| | | if (cols) { |
| | | allForms.forEach(item => { |
| | | if (cols.includes(item.uuid)) { |
| | | checkForms.push(item.field) |
| | | } |
| | | }) |
| | | |
| | | return columns.filter(col => cols.includes(col.$key)) |
| | | } |
| | | |
| | | allForms.forEach(item => { |
| | | checkForms.push(item.field) |
| | | }) |
| | | |
| | | return columns |
| | | } |
| | | |
| | | transferData = (menuid, data, type) => { |
| | | const { MenuID, setting } = this.props |
| | | const { edData, signForms } = this.state |
| | | transferData = (data, type) => { |
| | | const { edData } = this.state |
| | | |
| | | if (menuid !== MenuID) return |
| | | |
| | | if (setting.commit !== 'all' && setting.commit !== 'blur' && setting.standard !== 'change') { |
| | | if (type !== 'line') { |
| | | data.forEach(item => { |
| | | let value = '' |
| | | signForms.forEach(field => { |
| | | value += item[field] |
| | | }) |
| | | item.$sign = md5(value) |
| | | }) |
| | | } else { |
| | | if (type === 'line') { |
| | | let value = '' |
| | | Object.keys(data).sort().forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | value += data[key] |
| | | }) |
| | | data.$sign = md5(value) |
| | | } else { |
| | | data.forEach(item => { |
| | | let value = '' |
| | | signForms.forEach(field => { |
| | | value += data[field] |
| | | Object.keys(item).sort().forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | value += item[key] |
| | | }) |
| | | data.$sign = md5(value) |
| | | } |
| | | item.$sign = md5(value) |
| | | }) |
| | | } |
| | | |
| | | if (type !== 'line') { |
| | |
| | | } |
| | | }) |
| | | |
| | | this.setState({edData: _edData}) |
| | | this.setState({edData: _edData, reseting: true}, () => { |
| | | this.setState({reseting: false}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | updateMutil = (data) => { |
| | | const { setting, colsCtrls, allSearch } = this.props |
| | | const { allColumns } = this.state |
| | | const { allColumns, allForms } = this.state |
| | | |
| | | if (colsCtrls) { |
| | | let checkForms = [] |
| | | let columns = this.getCurColumns(allColumns, allSearch, allForms, checkForms) |
| | | |
| | | checkForms = Array.from(new Set(checkForms)) |
| | | |
| | | this.setState({ |
| | | columns: this.getCurColumns(allColumns, allSearch), |
| | | checkForms, |
| | | columns: columns, |
| | | reseting: true, |
| | | edData: data, |
| | | visible: false, |
| | |
| | | } |
| | | |
| | | if (setting.editType === 'multi' && data.length > 0) { |
| | | this.setState({edData: []}, () => { |
| | | this.setState({edData: data, visible: false, midData: null}) |
| | | this.setState({edData: data, visible: false, midData: null, reseting: true}, () => { |
| | | this.setState({reseting: false}) |
| | | }) |
| | | } else { |
| | | this.setState({edData: data, visible: false, midData: null}) |
| | |
| | | |
| | | if (setting.addable && data.length === 0) { |
| | | setTimeout(() => { |
| | | this.plusLine(true) |
| | | this.plusLine() |
| | | }, 10) |
| | | } |
| | | } |
| | | |
| | | improveActionForm = (deForms, BID) => { |
| | | const { setting } = this.props |
| | | |
| | | let deffers = [] |
| | | let mainItems = [] // 云端或单点数据 |
| | | let localItems = [] // 本地数据 |
| | | let cache = setting.cache !== 'false' |
| | | let debug = window.GLOB.debugger === true |
| | | let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` |
| | | let _sso = _sql |
| | |
| | | |
| | | deffers.push( |
| | | new Promise(resolve => { |
| | | Api.getSystemCacheConfig(param, cache).then(res => { |
| | | Api.getSystemCacheConfig(param, false).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | |
| | | deffers.push( |
| | | new Promise(resolve => { |
| | | Api.getSystemCacheConfig(mainparam, cache).then(res => { |
| | | Api.getSystemCacheConfig(mainparam, false).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | }) |
| | | } |
| | | |
| | | nextLine = (col, uuid) => { |
| | | nextLine = (lineId, colId) => { |
| | | const { setting } = this.props |
| | | const { edData, tableId } = this.state |
| | | |
| | | if (col.tableId !== tableId) return |
| | | |
| | | let index = edData.findIndex(item => item.$$uuid === uuid) |
| | | let index = edData.findIndex(item => item.$$uuid === lineId) |
| | | let next = edData[index + 1] || null |
| | | |
| | | if (next) { |
| | | let nextId = setting.initId + next.$$uuid |
| | | if (/^\$next_/.test(col.enter)) { |
| | | nextId = col.enter.split('_')[1] + next.$$uuid |
| | | } |
| | | |
| | | let node = document.getElementById(nextId) |
| | | if (node) { |
| | | if (setting.editType === 'multi') { |
| | | if (setting.triType === 'click') { |
| | | node.click() |
| | | } else { |
| | | node.select && node.select() |
| | | } |
| | | } else { |
| | | node.click() |
| | | } |
| | | } |
| | | MKEmitter.emit('setFocus' + tableId, next.$$uuid, colId) |
| | | } else if (setting.addable) { |
| | | setTimeout(() => { |
| | | this.plusLine() |
| | | this.plusLine(colId) |
| | | }, 10) |
| | | } else if (edData[index]) { |
| | | } else if (edData[index] && setting.commit !== 'change') { |
| | | setTimeout(() => { |
| | | this.subLine(col, edData[index]) |
| | | this.submit() |
| | | }, 10) |
| | | } |
| | | } |
| | | |
| | | subLine = (col, record) => { |
| | | const { tableId, edData } = this.state |
| | | |
| | | if (col && col.tableId !== tableId) return |
| | | |
| | | let _data = edData.map(item => { |
| | | if (item.$$uuid === record.$$uuid) { |
| | | item.$origin = false |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({edData: _data}, () => { |
| | | this.submit() |
| | | }) |
| | | } |
| | | |
| | | plusLine = (auto) => { |
| | | const { setting } = this.props |
| | | const { edData, forms } = this.state |
| | | |
| | | let item = edData.length > 0 ? {...edData[edData.length - 1]} : {} |
| | | |
| | | item.$$uuid = Utils.getguid() |
| | | item.$type = 'add' |
| | | item.$forbid = true |
| | | item.$Index = '' |
| | | |
| | | forms.forEach(col => { |
| | | if (col.initval !== '$copy') { |
| | | item[col.field] = col.initval |
| | | } |
| | | if (col.type === 'number') { |
| | | item[col.field] = +item[col.field] |
| | | if (isNaN(item[col.field])) { |
| | | item[col.field] = 0 |
| | | } |
| | | } |
| | | if (item[col.field] === undefined) { |
| | | item[col.field] = '' |
| | | } |
| | | }) |
| | | |
| | | this.setState({edData: [...edData, item]}, () => { |
| | | let node = document.getElementById(setting.initId + item.$$uuid) |
| | | if (node && !auto) { |
| | | if (setting.editType === 'multi') { |
| | | if (setting.triType === 'click') { |
| | | node.click() |
| | | } else { |
| | | node.select && node.select() |
| | | } |
| | | } else { |
| | | node.click() |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | delRecord = (id, record) => { |
| | | const { setting } = this.props |
| | | const { tableId, edData } = this.state |
| | | |
| | | if (id !== tableId) return |
| | | |
| | | if (record.$type === 'add') { |
| | | let _data = edData.filter(item => item.$$uuid !== record.$$uuid) |
| | | this.setState({edData: _data}) |
| | | } else { |
| | | let _data = fromJS(edData).toJS().map(item => { |
| | | if (item.$$uuid === record.$$uuid) { |
| | | item.$deleted = true |
| | | item.$origin = false |
| | | item.$type = 'del' |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({edData: _data}, () => { |
| | | if (setting.commit === 'simple') { |
| | | this.submit() |
| | | } else if (setting.commit === 'blur') { |
| | | this.submit(record) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | changeRecord = (id, record) => { |
| | | const { setting } = this.props |
| | | const { tableId, signForms } = this.state |
| | | |
| | | if (id !== tableId) return |
| | | |
| | | if (setting.commit === 'blur') { |
| | | |
| | | } else if (!record.$sign) { |
| | | record.$origin = false |
| | | record.$lock = true |
| | | delete record.$forbid |
| | | } else { |
| | | let value = '' |
| | | signForms.forEach(field => { |
| | | value += record[field] |
| | | }) |
| | | |
| | | if (record.$sign !== md5(value)) { |
| | | record.$origin = false |
| | | record.$lock = true |
| | | } else { |
| | | record.$origin = true |
| | | record.$lock = false |
| | | } |
| | | } |
| | | |
| | | let _data = this.state.edData.map(item => { |
| | | if (item.$$uuid === record.$$uuid) { |
| | | return record |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | this.setState({edData: _data}, () => { |
| | | if (setting.tableType && setting.hasAction && this.state.selectedRowKeys.includes(record.$$uuid)) { |
| | | this.selectdata(this.state.selectedRowKeys) |
| | | } |
| | | if (setting.commit === 'blur') { |
| | | this.submit(record) |
| | | } |
| | | }) |
| | | |
| | | } |
| | | |
| | | addRecord = (id, record) => { |
| | | plusLine = (colId, lineId) => { |
| | | const { BID } = this.props |
| | | const { edData, forms, tableId } = this.state |
| | | const { forms, tableId } = this.state |
| | | |
| | | if (id !== tableId) return |
| | | |
| | | let _edData = fromJS(edData).toJS() |
| | | let item = {} |
| | | let edData = fromJS(this.state.edData).toJS() |
| | | let item = edData.length > 0 ? {...edData[edData.length - 1]} : {} |
| | | let index = null |
| | | let copy = edData.length > 0 ? {...edData[edData.length - 1]} : null |
| | | |
| | | if (record) { |
| | | index = _edData.findIndex(item => record.$$uuid === item.$$uuid) |
| | | |
| | | if (lineId) { |
| | | index = edData.findIndex(item => lineId === item.$$uuid) |
| | | index = index === -1 ? null : index |
| | | |
| | | copy = {...record} |
| | | |
| | | if (index !== null) { |
| | | item = {...edData[index]} |
| | | } |
| | | } |
| | | |
| | | if (copy) { |
| | | item = {...copy} |
| | | } |
| | | |
| | | item.key = edData.length |
| | | item.$$uuid = Utils.getguid() |
| | | item.$type = 'add' |
| | | item.$Index = '' |
| | | item.$forbid = true |
| | | item.$Index = '' |
| | | item.$$BID = BID || '' |
| | | |
| | | forms.forEach(col => { |
| | |
| | | item[col.field] = 0 |
| | | } |
| | | } |
| | | |
| | | if (item[col.field] === undefined) { |
| | | item[col.field] = '' |
| | | } |
| | | }) |
| | | |
| | | let value = '' |
| | | Object.keys(item).sort().forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | value += item[key] |
| | | }) |
| | | item.$sign = md5(value) |
| | | |
| | | if (index === null) { |
| | | _edData.push(item) |
| | | edData.push(item) |
| | | } else { |
| | | _edData.splice(index, 0, item) |
| | | edData.splice(index, 0, item) |
| | | } |
| | | |
| | | this.setState({edData: _edData}) |
| | | this.setState({edData: edData}, () => { |
| | | if (colId) { |
| | | MKEmitter.emit('setFocus' + tableId, item.$$uuid, colId) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | delRecord = (record) => { |
| | | const { setting } = this.props |
| | | const { edData } = this.state |
| | | |
| | | if (record.$type === 'add') { |
| | | let _data = edData.filter(item => item.$$uuid !== record.$$uuid) |
| | | this.setState({edData: _data}) |
| | | } else { |
| | | let _data = fromJS(edData).toJS().map(item => { |
| | | if (item.$$uuid === record.$$uuid) { |
| | | item.$deleted = true |
| | | item.$origin = false |
| | | item.$type = 'del' |
| | | |
| | | record.$deleted = true |
| | | record.$origin = false |
| | | record.$type = 'del' |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({edData: _data}, () => { |
| | | if (setting.commit === 'change') { |
| | | this.submit(record) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | changeRecord = (record) => { |
| | | const { setting } = this.props |
| | | const { edData } = this.state |
| | | |
| | | let data = edData.filter(item => item.$$uuid === record.$$uuid)[0] |
| | | |
| | | if (!data) return |
| | | |
| | | if (is(fromJS(data), fromJS(record))) return |
| | | |
| | | delete record.$forbid |
| | | |
| | | let value = '' |
| | | Object.keys(record).sort().forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | value += record[key] |
| | | }) |
| | | |
| | | let sign = md5(value) |
| | | |
| | | if (record.$sign === sign) { |
| | | record.$origin = true |
| | | record.$lock = false |
| | | } else { |
| | | record.$origin = false |
| | | record.$lock = true |
| | | } |
| | | |
| | | let _data = edData.map(item => { |
| | | if (item.$$uuid === record.$$uuid) { |
| | | return record |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | this.setState({edData: _data}, () => { |
| | | if (setting.tableType && setting.hasAction && this.state.selectedRowKeys.includes(record.$$uuid)) { |
| | | this.selectdata(this.state.selectedRowKeys) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | checkData = () => { |
| | | const { setting } = this.props |
| | | const { edData, forms } = this.state |
| | | |
| | | if (edData.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '提交数据不可为空!', |
| | | duration: 5 |
| | | }) |
| | | return null |
| | | } |
| | | const { edData, forms, checkForms } = this.state |
| | | |
| | | let data = fromJS(edData).toJS() |
| | | |
| | | data = data.filter(item => !item.$forbid) |
| | | if (setting.commit === 'change' || setting.commit === 'simple') { |
| | | |
| | | if (setting.commit === 'amend') { |
| | | data = data.filter(item => !item.$origin) |
| | | } |
| | | |
| | |
| | | data = data.map(item => { |
| | | let line = [] |
| | | forms.forEach(col => { |
| | | if (col.editable !== 'true' || item.$deleted) { |
| | | let check = true |
| | | if (col.editable !== 'true' || item.$deleted || !checkForms.includes(col.field)) { |
| | | check = false |
| | | } |
| | | if (col.ctrlField && col.ctrlValue.includes(item[col.ctrlField] + '')) { |
| | | check = false |
| | | } |
| | | |
| | | if (!check) { |
| | | if (col.type === 'number') { |
| | | item[col.field] = +item[col.field] |
| | | if (isNaN(item[col.field])) { |
| | |
| | | } |
| | | return |
| | | } |
| | | |
| | | if (col.type === 'text') { |
| | | let val = item[col.field] !== undefined ? (item[col.field] + '') : '' |
| | | if (col.required === 'true' && !val) { |
| | |
| | | } else if (col.type === 'number') { |
| | | let val = item[col.field] |
| | | if (col.noValue === 'hide' && !val) { |
| | | if (col.clearField && checkForms.includes(col.clearField) && !item[col.clearField]) { |
| | | let msg = `请填写 ${col.label} 或 ${col.clearName}` |
| | | if (!line.includes(msg)) { |
| | | line.push(msg) |
| | | } |
| | | } |
| | | val = 0 |
| | | } else if (!val && val !== 0) { |
| | | line.push(`${col.label}不可为空`) |
| | | return |
| | | } |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | line.push(`${col.label}数据格式错误`) |
| | | return |
| | | } |
| | | |
| | | val = +val.toFixed(col.decimal || 0) |
| | | |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | line.push(`${col.label}不可大于${col.max}`) |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | line.push(`${col.label}不可小于${col.min}`) |
| | | } else { |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | line.push(`${col.label}数据格式错误`) |
| | | return |
| | | } |
| | | |
| | | val = +val.toFixed(col.decimal || 0) |
| | | |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | line.push(`${col.label}不可大于${col.max}`) |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | line.push(`${col.label}不可小于${col.min}`) |
| | | } |
| | | } |
| | | |
| | | item[col.field] = val |
| | |
| | | return data |
| | | } |
| | | |
| | | checkLineData = (item) => { |
| | | const { forms } = this.state |
| | | |
| | | let record = fromJS(item).toJS() |
| | | let err = '' |
| | | forms.forEach(col => { |
| | | if (col.editable !== 'true' || record.$deleted) { |
| | | if (col.type === 'number') { |
| | | record[col.field] = +record[col.field] |
| | | if (isNaN(record[col.field])) { |
| | | record[col.field] = 0 |
| | | } |
| | | } else { |
| | | record[col.field] = record[col.field] !== undefined ? (record[col.field] + '') : '' |
| | | } |
| | | return |
| | | } |
| | | if (col.type === 'text') { |
| | | let val = record[col.field] !== undefined ? (record[col.field] + '') : '' |
| | | if (col.required === 'true' && !val) { |
| | | err = `${col.label}不可为空` |
| | | } else if (col.datatype === 'datetime' && !val) { |
| | | val = '1949-10-01' |
| | | } |
| | | record[col.field] = val |
| | | } else if (col.type === 'number') { |
| | | let val = record[col.field] |
| | | if (col.noValue === 'hide' && !val) { |
| | | val = 0 |
| | | } else if (!val && val !== 0) { |
| | | err = `${col.label}不可为空` |
| | | return |
| | | } |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | err = `${col.label}数据格式错误` |
| | | return |
| | | } |
| | | |
| | | val = +val.toFixed(col.decimal || 0) |
| | | |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | err = `${col.label}不可大于${col.max}` |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = `${col.label}不可小于${col.min}` |
| | | } |
| | | |
| | | record[col.field] = val |
| | | } |
| | | }) |
| | | |
| | | if (err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: err, |
| | | duration: 5 |
| | | }) |
| | | |
| | | return null |
| | | } |
| | | |
| | | return [record] |
| | | } |
| | | |
| | | submit = (record) => { |
| | | const { submit, BID, setting } = this.props |
| | | const { forms } = this.state |
| | |
| | | return |
| | | } |
| | | |
| | | if (setting.commit === 'blur' && !record) return |
| | | |
| | | let data = null |
| | | if (setting.commit === 'blur') { |
| | | data = this.checkLineData(record) |
| | | if (record) { |
| | | data = [record] |
| | | } else { |
| | | data = this.checkData() |
| | | } |
| | |
| | | |
| | | let _edData = fromJS(edData).toJS() |
| | | |
| | | _edData = _edData.map(item => { |
| | | _edData = _edData.filter(item => { |
| | | if (item.$deleted) return false |
| | | |
| | | if (!item.$forbid) { |
| | | item.$type = 'upt' |
| | | item.$origin = true |
| | | item.$lock = false |
| | | } |
| | | return item |
| | | |
| | | let value = '' |
| | | Object.keys(item).sort().forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | value += item[key] |
| | | }) |
| | | |
| | | item.$sign = md5(value) |
| | | |
| | | return true |
| | | }) |
| | | |
| | | this.setState({ |
| | |
| | | |
| | | render() { |
| | | const { setting, lineMarks, submit } = this.props |
| | | const { tableId, edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting } = this.state |
| | | const { edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting } = this.state |
| | | |
| | | if (reseting) return null |
| | | |
| | |
| | | height = height + 'vh' |
| | | } |
| | | |
| | | let style = { |
| | | '--mk-table-border-color': setting.borderColor || '#e8e8e8', |
| | | '--mk-table-color': setting.color || 'rgba(0, 0, 0, 0.65)', |
| | | '--mk-table-font-size': setting.fontSize || '14px', |
| | | '--mk-table-font-weight': setting.fontWeight || 'normal' |
| | | } |
| | | |
| | | return ( |
| | | <> |
| | | {setting.hasSubmit ? <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> |
| | | {setting.hasSubmit && edData.length > 0 ? <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> |
| | | <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-table" type="link">提交</Button> |
| | | </div> : null} |
| | | <div className={`edit-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} id={tableId}> |
| | | <div className={`edit-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} style={style}> |
| | | <Table |
| | | rowKey="$$uuid" |
| | | components={components} |
| | |
| | | right: 0px; |
| | | bottom: 0px; |
| | | border: 1px solid var(--mk-sys-color); |
| | | background: #ffffff; |
| | | } |
| | | } |
| | | .ant-calendar-picker { |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Modal, Table, Input, Tabs } from 'antd' |
| | | import moment from 'moment' |
| | | import { TableOutlined, CloseCircleFilled } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const { Search } = Input |
| | | const { TabPane } = Tabs |
| | | |
| | | class PopTable extends Component { |
| | | state = { |
| | | options: [], |
| | | searchKey: '', |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | orderBy: '', |
| | | loading: false |
| | | } |
| | | |
| | | timer = null |
| | | |
| | | componentDidMount () { |
| | | const { config } = this.props |
| | | const { options } = this.state |
| | | |
| | | if (config.onload === 'true' && options.length === 0) { |
| | | this.loadData() |
| | | } |
| | | } |
| | | |
| | | loadData () { |
| | | const { BID, ID, config } = this.props |
| | | const { pageIndex, pageSize, searchKey, orderBy } = this.state |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | exec_type: 'y', |
| | | arr_field: config.arr_field, |
| | | default_sql: 'true', |
| | | custom_script: '', |
| | | menuname: config.label |
| | | } |
| | | |
| | | let sql = '' |
| | | let DateCount = '' |
| | | let _search = '' |
| | | let _orderBy = orderBy || config.order || '' |
| | | let _datasource = config.dataSource |
| | | |
| | | if (config.searchKey && searchKey) { |
| | | let fields = config.searchKey.split(',').map(field => field + ` like '%${searchKey}%'`) |
| | | _search = 'where ' + fields.join(' OR ') |
| | | } |
| | | |
| | | _datasource = _datasource.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | _datasource = _datasource.replace(/@ID@/ig, `'${ID || ''}'`) |
| | | |
| | | if (config.laypage === 'true') { |
| | | sql = `/*system_query*/select top ${pageSize} ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows ` |
| | | DateCount = `/*system_query*/select count(1) as total from ${_datasource} ${_search}` |
| | | } else if (_orderBy) { |
| | | sql = `/*system_query*/select ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable order by tmptable.rows ` |
| | | } else { |
| | | sql = `/*system_query*/select ${config.arr_field} from ${_datasource} ${_search} ` |
| | | } |
| | | |
| | | let departmentcode = sessionStorage.getItem('departmentcode') || '' |
| | | let organization = sessionStorage.getItem('organization') || '' |
| | | let mk_user_type = sessionStorage.getItem('mk_user_type') || '' |
| | | |
| | | sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) |
| | | Select @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}' |
| | | ${sql}` |
| | | |
| | | // 测试系统打印查询语句 |
| | | if (window.GLOB.debugger === true) { |
| | | console.info(`/*${config.label} 数据源*/\n` + sql.replace(/\n\s{6}/ig, '\n')) |
| | | DateCount && console.info(`/*${config.label} 总数查询*/\n` + DateCount.replace(/\n\s{6}/ig, '\n')) |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(sql) |
| | | param.DateCount = Utils.formatOptions(DateCount) |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | param.username = sessionStorage.getItem('User_Name') || '' |
| | | param.fullname = sessionStorage.getItem('Full_Name') || '' |
| | | |
| | | Api.getSystemCacheConfig(param, config.cache === 'true').then(result => { |
| | | if (result.status) { |
| | | let options = result.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[config.primaryKey] || '' |
| | | |
| | | if (config.controlField && item[config.controlField] === 'true') { |
| | | item.$disabled = true |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | options: options, |
| | | total: result.total || 0, |
| | | loading: false |
| | | }) |
| | | |
| | | if (result.message) { |
| | | if (result.ErrCode === 'Y') { |
| | | Modal.success({ |
| | | title: result.message |
| | | }) |
| | | } else if (result.ErrCode === 'S') { |
| | | notification.success({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 2 |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | |
| | | if (!result.message) return |
| | | if (result.ErrCode === 'N') { |
| | | Modal.error({ |
| | | title: result.message, |
| | | }) |
| | | } else if (result.ErrCode !== '-2') { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | searchOption = (val) => { |
| | | this.setState({searchKey: val}) |
| | | |
| | | if (this.timer) { |
| | | clearTimeout(this.timer) |
| | | } |
| | | |
| | | this.timer = setTimeout(() => { |
| | | this.loadData() |
| | | }, 500) |
| | | } |
| | | |
| | | changeRow = (record) => { |
| | | if (record.$disabled) return |
| | | |
| | | this.props.onChange(record) |
| | | } |
| | | |
| | | changeTable = (pagination, filters, sorter) => { |
| | | let orderBy = '' |
| | | |
| | | if (sorter.field && sorter.order) { |
| | | if (sorter.order === 'ascend') { |
| | | orderBy = `${sorter.field} asc` |
| | | } else { |
| | | orderBy = `${sorter.field} desc` |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | pageIndex: pagination.current, |
| | | pageSize: pagination.pageSize, |
| | | orderBy: orderBy, |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { config, value } = this.props |
| | | const { options, loading, total, pageIndex, pageSize } = this.state |
| | | |
| | | return <> |
| | | {config.searchKey ? <Search placeholder={config.placeholder} onSearch={this.searchOption} enterButton /> : null} |
| | | <Table |
| | | rowKey="$$uuid" |
| | | bordered={true} |
| | | rowSelection={null} |
| | | columns={config.cols} |
| | | 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: className, |
| | | onClick: () => {this.changeRow(record)}, |
| | | } |
| | | }} |
| | | onChange={this.changeTable} |
| | | pagination={config.laypage === 'true' ? { |
| | | current: pageIndex, |
| | | pageSize: pageSize, |
| | | showSizeChanger: true, |
| | | total: total || 0, |
| | | showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条` |
| | | } : false} |
| | | /> |
| | | </> |
| | | } |
| | | } |
| | | |
| | | class MKPopSelect extends Component { |
| | | constructor(props) { |
| | | super(props) |
| | | |
| | | this.state = { |
| | | value: props.defaultValue, |
| | | visible: false |
| | | } |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { autoFocus, config } = this.props |
| | | |
| | | MKEmitter.addListener('setFocus' + config.tableId, this.setFocus) |
| | | |
| | | if (autoFocus) { |
| | | this.trigger() |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('setFocus' + this.props.config.tableId, this.setFocus) |
| | | } |
| | | |
| | | setFocus = (lId, colId) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | if (lId !== lineId || config.uuid !== colId) return |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | selectChange = (record) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | let values = {[config.field]: record.$$uuid} |
| | | |
| | | if (config.linkSubField) { |
| | | config.linkSubField.forEach((m, i) => { |
| | | values[m] = record[m] !== undefined ? record[m] : '' |
| | | }) |
| | | } |
| | | |
| | | this.props.onChange(values, record.$$uuid) |
| | | |
| | | this.setState({visible: false, value: record.$$uuid}) |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | this.props.onBlur && this.props.onBlur() |
| | | |
| | | if (config.enter === '$noAct') return |
| | | |
| | | setTimeout(() => { |
| | | if (/\$next/.test(config.enter)) { |
| | | MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', '')) |
| | | } else { |
| | | MKEmitter.emit('setFocus' + config.tableId, lineId, config.enter) |
| | | } |
| | | }, 10) |
| | | } |
| | | |
| | | trigger = (e) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | e && e.stopPropagation() |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colFocus' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | clear = (e) => { |
| | | const { config, lineId } = this.props |
| | | |
| | | e.stopPropagation() |
| | | |
| | | let values = {[config.field]: ''} |
| | | |
| | | if (config.linkSubField) { |
| | | config.linkSubField.forEach((m, i) => { |
| | | values[m] = '' |
| | | }) |
| | | } |
| | | |
| | | this.props.onChange(values, '') |
| | | this.setState({value: ''}) |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | } |
| | | |
| | | cancel = () => { |
| | | const { config, lineId } = this.props |
| | | |
| | | this.setState({visible: false}) |
| | | |
| | | if (config.$ctrl) { |
| | | MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid) |
| | | } |
| | | |
| | | this.props.onBlur && this.props.onBlur() |
| | | } |
| | | |
| | | render() { |
| | | const { autoFocus, BID, lineId, config } = this.props |
| | | const { value, visible } = this.state |
| | | |
| | | return <> |
| | | {autoFocus ? <div className="mk-pop-select-mask" onClick={this.trigger}></div> : null} |
| | | <div className="mk-pop-select-wrap" onClick={this.trigger}> |
| | | {value} |
| | | {value && !autoFocus ? <CloseCircleFilled onClick={this.clear} /> : null} |
| | | <TableOutlined onClick={this.trigger}/> |
| | | </div> |
| | | <Modal |
| | | wrapClassName='mk-table-pop-select-modal' |
| | | title={config.label} |
| | | visible={visible} |
| | | closable={true} |
| | | centered={true} |
| | | maskClosable={false} |
| | | cancelText="关闭" |
| | | width={config.popWidth < 100 ? config.popWidth + 'vw' : config.popWidth} |
| | | onCancel={this.cancel} |
| | | destroyOnClose |
| | | > |
| | | {config.pops ? <Tabs> |
| | | {config.pops.map(tab => ( |
| | | <TabPane tab={tab.tabName} key={tab.uuid}> |
| | | <PopTable config={tab} BID={BID} ID={lineId} value={value} onChange={this.selectChange}/> |
| | | </TabPane> |
| | | ))} |
| | | </Tabs> : |
| | | <PopTable config={config} BID={BID} ID={lineId} value={value} onChange={this.selectChange}/>} |
| | | </Modal> |
| | | </> |
| | | } |
| | | } |
| | | |
| | | export default MKPopSelect |
New file |
| | |
| | | .mk-pop-select-wrap { |
| | | position: relative; |
| | | box-sizing: border-box; |
| | | margin: 0; |
| | | padding: 0 30px 0 11px; |
| | | color: rgba(0, 0, 0, 0.65); |
| | | font-size: 14px; |
| | | font-variant: tabular-nums; |
| | | list-style: none; |
| | | font-feature-settings: 'tnum'; |
| | | position: relative; |
| | | display: inline-block; |
| | | width: 100%; |
| | | outline: 0; |
| | | border: 1px solid #d9d9d9; |
| | | border-top-width: 1.02px; |
| | | background: #ffffff; |
| | | user-select: none; |
| | | height: 32px; |
| | | cursor: pointer; |
| | | transition: all 0.3s; |
| | | overflow: hidden; |
| | | white-space: nowrap; |
| | | text-overflow: ellipsis; |
| | | line-height: 30px; |
| | | vertical-align: top; |
| | | |
| | | .anticon-table { |
| | | padding: 7px; |
| | | color: rgba(0, 0, 0, 0.25); |
| | | transition: color 0.3s; |
| | | font-size: 14px; |
| | | position: absolute; |
| | | right: 0px; |
| | | top: 0px; |
| | | } |
| | | .anticon-close-circle { |
| | | color: rgba(0, 0, 0, 0.25); |
| | | transition: all 0.3s; |
| | | padding: 7px; |
| | | opacity: 0; |
| | | position: absolute; |
| | | right: 25px; |
| | | } |
| | | .anticon-close-circle:hover { |
| | | color: rgba(0, 0, 0, 0.45); |
| | | } |
| | | } |
| | | .mk-pop-select-wrap:hover, .mk-pop-select-mask:hover + .mk-pop-select-wrap { |
| | | border-color: var(--mk-sys-color5); |
| | | box-shadow: 0 0 0 2px var(--mk-sys-color2); |
| | | |
| | | .anticon-table { |
| | | color: var(--mk-sys-color); |
| | | } |
| | | .anticon-close-circle { |
| | | opacity: 1; |
| | | } |
| | | } |
| | | .mk-pop-select-mask { |
| | | position: absolute; |
| | | background: #ffffff; |
| | | top: 0px; |
| | | left: 0px; |
| | | right: 0px; |
| | | bottom: 0px; |
| | | height: auto; |
| | | border: 1px solid #d9d9d9; |
| | | cursor: pointer; |
| | | } |
| | | .mk-pop-select-mask + .mk-pop-select-wrap { |
| | | border: none; |
| | | box-shadow: none!important; |
| | | padding-left: 0px; |
| | | } |
| | | .mk-table-pop-select-modal { |
| | | .ant-modal-body { |
| | | min-height: 200px; |
| | | max-height: calc(100vh - 210px); |
| | | overflow-y: auto; |
| | | |
| | | .ant-input-search { |
| | | max-width: 300px; |
| | | margin-bottom: 20px; |
| | | } |
| | | .ant-tabs { |
| | | margin-top: -20px; |
| | | } |
| | | table { |
| | | td { |
| | | padding: 12px 16px; |
| | | } |
| | | tr:not(.ant-table-row-selected):hover > td { |
| | | background-color: var(--mk-sys-color1); |
| | | } |
| | | 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 { |
| | | width: 7px; |
| | | } |
| | | .ant-modal-body::-webkit-scrollbar-thumb { |
| | | border-radius: 5px; |
| | | box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); |
| | | background: rgba(0, 0, 0, 0.13); |
| | | } |
| | | .ant-modal-body::-webkit-scrollbar-track { |
| | | box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); |
| | | border-radius: 3px; |
| | | border: 1px solid rgba(0, 0, 0, 0.07); |
| | | background: rgba(0, 0, 0, 0); |
| | | } |
| | | |
| | | .ant-modal-footer { |
| | | .ant-btn-primary { |
| | | display: none; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | .main-table-box { |
| | | position: relative; |
| | | min-height: 150px; |
| | | min-height: 40px; |
| | | .main-pickup { |
| | | position: absolute; |
| | | right: 5px; |
| | |
| | | getPrinter = (item, parentId) => { |
| | | let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) |
| | | |
| | | item.verify.logLabel = item.logLabel |
| | | |
| | | if (_item) { |
| | | item.printer = _item.printer || '' |
| | | item.verify.defaultPrinter = _item.printer || '' |
| | |
| | | delete item.style.shadowColor |
| | | } |
| | | |
| | | item.$menuname = (Tab.label || '') + '-' + (item.name || '') |
| | | item.$menuname = (Tab.logLabel || Tab.label || '') + '-' + (item.name || '') |
| | | |
| | | if (item.type === 'tabs') { |
| | | if ( |
| | |
| | | } |
| | | |
| | | return cell |
| | | } |
| | | |
| | | getPrinter = (item, parentId) => { |
| | | let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) |
| | | |
| | | if (_item) { |
| | | item.printer = _item.printer || '' |
| | | item.verify.defaultPrinter = _item.printer || '' |
| | | if (item.verify.printerTypeList && _item.printerList) { |
| | | item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { |
| | | cell.printer = _item.printerList[cell.Value] || '' |
| | | |
| | | return cell |
| | | }) |
| | | } |
| | | } |
| | | |
| | | return item |
| | | } |
| | | |
| | | // 格式化默认设置 |
| | |
| | | let data = selectedData || [] |
| | | |
| | | if (btn.funcType === 'addline') { |
| | | MKEmitter.emit('addRecord', btn.$tableId, data[0] || null) |
| | | MKEmitter.emit('addRecord' + btn.$tableId, '', data[0] ? data[0].$$uuid : null) |
| | | } else { |
| | | MKEmitter.emit('delRecord', btn.$tableId, data[0] || null) |
| | | MKEmitter.emit('delRecord' + btn.$tableId, data[0] || null) |
| | | } |
| | | } |
| | | |
| | |
| | | } else { |
| | | let iserror = false |
| | | btnColumns.forEach(op => { |
| | | if (iserror) return |
| | | |
| | | let _name = typeof(header[op.Column]) === 'string' ? header[op.Column].replace(/(^\s*|\s*$)/g, '') : header[op.Column] |
| | | let _text = op.Text ? op.Text.replace(/(^\s*|\s*$)/g, '') : op.Text |
| | | |
| | | if (!_name && !iserror) { |
| | | if (!_name) { |
| | | iserror = true |
| | | errors = 'headerError' |
| | | errDetail = `Excel中不存在(${_text})列!` |
| | | } else if (_name !== _text && !iserror) { |
| | | } else if (_name !== _text) { |
| | | iserror = true |
| | | errors = 'headerError' |
| | | errDetail = `Excel中(${_name})与按钮列信息(${_text})不一致!` |
| | |
| | | |
| | | Object.keys(cell).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | |
| | | if (/^\$/.test(_key)) return |
| | | |
| | | _cell[_key] = cell[key] |
| | | }) |
| | | |
| | |
| | | execCustomPrint = (printlist, formdata) => { |
| | | const { btn } = this.props |
| | | |
| | | this.execSuccess({ |
| | | ErrCode: '-1', |
| | | message: '', |
| | | status: true |
| | | }) |
| | | let callback = null |
| | | |
| | | if (/callback\(\)/.test(btn.verify.printFunc)) { |
| | | callback = () => { |
| | | this.execSuccess({ |
| | | ErrCode: '-1', |
| | | message: '', |
| | | status: true |
| | | }) |
| | | } |
| | | } else { |
| | | this.execSuccess({ |
| | | ErrCode: '-1', |
| | | message: '', |
| | | status: true |
| | | }) |
| | | } |
| | | |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', btn.verify.printFunc) |
| | | func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType) |
| | | let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', 'callback', btn.verify.printFunc) |
| | | func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType, callback) |
| | | |
| | | // 自定义打印示例 |
| | | // let defaultPrinter = printer.defaultPrinter || 'lackprinter' |
| | |
| | | } catch (e) { |
| | | console.warn(e) |
| | | |
| | | try { |
| | | // eslint-disable-next-line |
| | | let evalfunc = eval('(true && function (data, form, printer, notification, Api, systemType) {' + btn.verify.printFunc + '})') |
| | | evalfunc(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType) |
| | | } catch (error) { |
| | | console.warn(error) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义函数执行错误!', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义函数执行错误!', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | return |
| | | } |
| | | |
| | | if (printerList.length === 0) { |
| | | this.execSuccess({ |
| | | ErrCode: '-1', |
| | | message: '未获取到打印信息!', |
| | | status: true |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) { |
| | | socket = new WebSocket('ws://' + btn.verify.linkUrl) |
| | | } else { |
| | | this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '打印请求已发出。', |
| | | status: true |
| | | this.syncMessageSend(printerList, () => { |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | // 打开Socket |
| | | socket.onopen = () =>{ |
| | | this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '打印请求已发出。', |
| | | status: true |
| | | this.syncMessageSend(printerList, () => { |
| | | this.execSuccess({ |
| | | ErrCode: 'S', |
| | | message: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | }) |
| | | } |
| | | // 监听消息 |
| | |
| | | } |
| | | } |
| | | |
| | | syncMessageSend = (list) => { |
| | | syncMessageSend = (list, callback) => { |
| | | let param = list.shift() |
| | | |
| | | if (socket && param) { |
| | | socket.send(JSON.stringify(param)) |
| | | if (socket) { |
| | | try { |
| | | socket.send(JSON.stringify(param)) |
| | | } catch(e) { |
| | | console.warn('打印请求发送失败!') |
| | | } |
| | | } |
| | | |
| | | if (list && list.length > 0) { |
| | | setTimeout(() => {this.syncMessageSend(list)}, 3000) |
| | | if (list.length > 0) { |
| | | setTimeout(() => { |
| | | this.syncMessageSend(list, callback) |
| | | }, 3000) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 操作成功后处理 |
| | | * 1、excel导出,成功后取消导出按钮加载中状态 |
| | |
| | | margin-bottom: 20px; |
| | | } |
| | | table { |
| | | td { |
| | | padding: 12px 16px; |
| | | } |
| | | tr:not(.ant-table-row-selected):hover > td { |
| | | background-color: var(--mk-sys-color1); |
| | | } |
| | |
| | | import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | |
| | | values.status = editItem.status || 'true' |
| | | } |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | let pass = checkSQL(values.sql, 'customscript') |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/,,/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { |
| | | let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql, 'customscript') |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | let sheet = btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '') |
| | | let tail = ` |
| | |
| | | changeColumns = (columns) => { |
| | | const { verify } = this.state |
| | | |
| | | let reset = false |
| | | columns = columns.map(col => { |
| | | col.type = col.type || 'Nvarchar(50)' |
| | | if (col.type === 'text' || col.type === 'image') { |
| | |
| | | col.type = 'Decimal(18,2)' |
| | | } |
| | | |
| | | if (col.import === 'init') { |
| | | col.required = 'false' |
| | | col.min = '' |
| | | col.max = '' |
| | | } |
| | | |
| | | if (/^Nvarchar/ig.test(col.type)) { |
| | | col.limit = col.type.match(/\d+/) ? col.type.match(/\d+/)[0] : '20000' |
| | | } else if (/^Decimal/ig.test(col.type)) { |
| | | col.limit = col.type.match(/\d+/ig)[1] |
| | | if (col.required === 'false') { |
| | | reset = true |
| | | } |
| | | col.required = 'true' |
| | | } else if (/^int/ig.test(col.type)) { |
| | | if (col.required === 'false') { |
| | | reset = true |
| | | } |
| | | col.required = 'true' |
| | | |
| | | } else { |
| | | col.limit = '' |
| | | } |
| | |
| | | |
| | | return col |
| | | }) |
| | | |
| | | if (reset) { |
| | | message.warning('数值类型均为必填。') |
| | | } |
| | | |
| | | this.setState({verify: {...verify, columns}}, () => { |
| | | this.resetUniqueColumns() |
| | |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | |
| | | |
| | | values.uuid = this.state.editItem ? this.state.editItem.uuid : '' |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | let pass = checkSQL(values.sql, 'customscript') |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/,,/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { |
| | | let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql, 'customscript') |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | this.setState({ |
| | | loading: true |
| | |
| | | import { Form, Row, Col, Input, Radio, Tooltip, notification, InputNumber } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | |
| | | reject() |
| | | return |
| | | } else if (values.defaultSql === 'true' && values.dataresource) { |
| | | let _quot = values.dataresource.match(/'{1}/g) |
| | | let _lparen = values.dataresource.match(/\({1}/g) |
| | | let _rparen = values.dataresource.match(/\){1}/g) |
| | | let pass = checkSQL(values.dataresource) |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (/--/ig.test(values.dataresource)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (/,,/ig.test(values.dataresource)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.dataresource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | if (!pass) { |
| | | reject() |
| | | return |
| | | } |
| | |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else if (_tailScript) { |
| | | sql = `${declare} |
| | |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else { |
| | | sql = `${declare} |
| | |
| | | dataType: _verify.dataType || 'line', |
| | | linkType: _verify.linkType, |
| | | printMode: _verify.printMode, |
| | | printFunc: _verify.printFunc || '// Function(data, form, printer, notification) data-打印数据列表,form-表单信息(不存在时为{}),printer-打印设置,notification-信息提示控件' |
| | | printFunc: _verify.printFunc || '// Function(data, form, printer, notification) data-打印数据列表,form-表单信息(不存在时为{}),printer-打印设置,notification-信息提示控件,callback-释放按钮的回调' |
| | | }) |
| | | } |
| | | |
| | |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else if (_tailScript) { |
| | | sql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | |
| | | ${_tailScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else { |
| | | sql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | |
| | | |
| | | import { dateOptions, matchReg, formRule } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | |
| | | } |
| | | }) |
| | | |
| | | let error = Utils.verifySql(values.dataSource) |
| | | let pass = checkSQL(values.dataSource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | resolve(values) |
| | | } else { |
| | |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import { formRule } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | // import './index.scss' |
| | | |
| | |
| | | reject() |
| | | return |
| | | } else if (values.interType === 'system' && values.default !== 'false' && values.dataresource) { |
| | | let _quot = values.dataresource.match(/'{1}/g) |
| | | let _lparen = values.dataresource.match(/\({1}/g) |
| | | let _rparen = values.dataresource.match(/\){1}/g) |
| | | let pass = checkSQL(values.dataresource) |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (/--/ig.test(values.dataresource)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (/,,/ig.test(values.dataresource)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.dataresource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | if (!pass) { |
| | | reject() |
| | | return |
| | | } |
| | |
| | | ${_dataresource} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else { |
| | | sql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import { formRule } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | // import './index.scss' |
| | | |
| | |
| | | reject() |
| | | return |
| | | } else if (values.interType === 'system' && values.default !== 'false' && values.dataresource) { |
| | | let _quot = values.dataresource.match(/'{1}/g) |
| | | let _lparen = values.dataresource.match(/\({1}/g) |
| | | let _rparen = values.dataresource.match(/\){1}/g) |
| | | let pass = checkSQL(values.dataresource) |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (/--/ig.test(values.dataresource)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } else if (/,,/ig.test(values.dataresource)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | reject() |
| | | return |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.dataresource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | if (!pass) { |
| | | reject() |
| | | return |
| | | } |
| | |
| | | ${_dataresource} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'1949-10-01 15:00:00' |
| | | ` |
| | | } else { |
| | | sql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' |
| | |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | |
| | | return |
| | | } |
| | | |
| | | let pass = checkSQL(_sql, 'customscript') |
| | | |
| | | if (!pass) return |
| | | |
| | | let values = { |
| | | uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(), |
| | | sql: _sql |
| | | } |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/,,/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { |
| | | let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql, 'customscript') |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _scripts = fromJS(scripts).toJS() |
| | |
| | | import { dateOptions } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import EditTable from './modaleditable' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | |
| | | } |
| | | }) |
| | | |
| | | let error = Utils.verifySql(values.dataSource) |
| | | let pass = checkSQL(values.dataSource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | window.GLOB.formId = card.uuid |
| | | |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' |
| | | import { Form, Row, Col, Button, Modal, Tooltip, Radio, Select, Switch } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | |
| | | if (!err) { |
| | | values.uuid = editItem ? editItem.uuid : '' |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | let pass = checkSQL(values.sql, 'customscript') |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/,,/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { |
| | | let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql, 'customscript') |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | let tail = ` |
| | | aaa: |
| | |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Select, Button, notification, Modal, Tooltip } from 'antd' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | // import './index.scss' |
| | | |
| | |
| | | values.uuid = this.state.editItem ? this.state.editItem.uuid : '' |
| | | values.resultName = values.result === 'false' ? '不存在' : '存在' |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | let pass = checkSQL(values.sql, 'customscript') |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/,,/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { |
| | | let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | let sql = `${this.props.initsql} |
| | | /* 自定义验证 */ |
| | |
| | | import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | |
| | | values.status = editItem.status || 'true' |
| | | } |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | | let _rparen = values.sql.match(/\){1}/g) |
| | | let pass = checkSQL(values.sql, 'customscript') |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/--/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/,,/ig.test(values.sql)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义sql语句中,不可出现连续的英文逗号(,,)', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { |
| | | let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | let error = Utils.verifySql(values.sql, 'customscript') |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!pass) return |
| | | |
| | | let tail = ` |
| | | aaa: |
| | |
| | | import md5 from 'md5' |
| | | import { notification } from 'antd' |
| | | |
| | | export default class MenuUtils { |
| | | /** |
| | |
| | | } |
| | | |
| | | return errors |
| | | } |
| | | |
| | | /** |
| | | * @description 检测sql |
| | | */ |
| | | export function checkSQL(sql, type) { |
| | | if (!sql) return true |
| | | |
| | | let label = '数据源中' |
| | | if (type === 'customscript') { |
| | | label = '自定义sql语句中' |
| | | } |
| | | |
| | | let _quot = sql.match(/'{1}/g) |
| | | let _lparen = sql.match(/\({1}/g) |
| | | let _rparen = sql.match(/\){1}/g) |
| | | |
| | | _quot = _quot ? _quot.length : 0 |
| | | _lparen = _lparen ? _lparen.length : 0 |
| | | _rparen = _rparen ? _rparen.length : 0 |
| | | |
| | | if (_quot % 2 !== 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中\'必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (_lparen !== _rparen) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中()必须成对出现', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (/--/ig.test(sql)) { |
| | | let lines = [] |
| | | sql.split(/\n/).forEach((s, i) => { |
| | | if (/--/ig.test(s)) { |
| | | lines.push(i + 1) |
| | | } |
| | | }) |
| | | |
| | | lines = lines.join('、') |
| | | lines = lines ? '(第' + lines + '行)' : '' |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: label + `${lines},不可出现字符 -- ,注释请用 /*内容*/`, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (/,,/ig.test(sql)) { |
| | | let lines = [] |
| | | sql.split(/\n/).forEach((s, i) => { |
| | | if (/,,/ig.test(s)) { |
| | | lines.push(i + 1) |
| | | } |
| | | }) |
| | | |
| | | lines = lines.join('、') |
| | | lines = lines ? '(第' + lines + '行)' : '' |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: label + `${lines},不可出现连续的英文逗号,,`, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (/‘|’/ig.test(sql)) { |
| | | let lines = [] |
| | | sql.split(/\n/).forEach((s, i) => { |
| | | if (/‘|’/ig.test(s)) { |
| | | lines.push(i + 1) |
| | | } |
| | | }) |
| | | |
| | | lines = lines.join('、') |
| | | lines = lines ? '(第' + lines + '行)' : '' |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: label + `${lines},不可出现中文单引号`, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } else if (type === 'customscript' && /\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(sql)) { |
| | | let list = sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) |
| | | let errors = [] |
| | | list.forEach(str => { |
| | | str = str.replace(/^\s/, '') |
| | | let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) |
| | | if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { |
| | | errors.push(str) |
| | | } |
| | | }) |
| | | |
| | | if (errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '不可使用同一个表字段进行关联:' + errors.join('、'), |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | } |
| | | |
| | | let error = '' |
| | | let chars = [ |
| | | {key: 'create', reg: /(^|\s|\(|\))create\s/ig}, |
| | | {key: 'insert', reg: /(^|\s|\(|\))insert\s/ig}, |
| | | {key: 'delete', reg: /(^|\s|\(|\))delete\s/ig}, |
| | | {key: 'update', reg: /(^|\s|\(|\))update\s/ig}, |
| | | {key: 'set', reg: /(^|\s|\(|\))set\s/ig}, |
| | | {key: 'drop', reg: /(^|\s|\(|\))drop\s/ig}, |
| | | {key: 'alter', reg: /(^|\s|\(|\))alter\s/ig}, |
| | | {key: 'truncate', reg: /(^|\s|\(|\))truncate\s/ig}, |
| | | {key: 'if', reg: /(^|\s|\(|\))if\s/ig}, |
| | | {key: 'exec', reg: /(^|\s|\(|\))exec(\s|\()/ig}, |
| | | {key: 'OBJECT', reg: /(^|\s|\(|\))object(\s|\()/ig}, |
| | | {key: 'sys.', reg: /(^|\s|\(|\))sys\./ig}, |
| | | {key: 'kill', reg: /(^|\s|\(|\))kill\s/ig} |
| | | ] |
| | | |
| | | if (type === 'customscript') { |
| | | chars = chars.filter(char => !['create', 'insert', 'delete', 'update', 'set', 'drop', 'if', 'exec'].includes(char.key)) |
| | | } |
| | | |
| | | sql = sql.replace(/sys\.fn_/ig, '') // 跳过sys.fn_验证 |
| | | |
| | | chars.forEach(char => { |
| | | if (!error && char.reg.test(sql)) { |
| | | error = char.key |
| | | } |
| | | }) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'sql中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | |
| | | return true |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description sql语法验证 |
| | | * @return {String} sql sql语句 |
| | | * @return {String} type 验证类型 |
| | | */ |
| | | static verifySql (sql, type) { |
| | | if (!sql) return '' |
| | | let chars = [ |
| | | {key: 'create', reg: /(^|\s|\(|\))create\s/ig}, |
| | | {key: 'insert', reg: /(^|\s|\(|\))insert\s/ig}, |
| | | {key: 'delete', reg: /(^|\s|\(|\))delete\s/ig}, |
| | | {key: 'update', reg: /(^|\s|\(|\))update\s/ig}, |
| | | {key: 'set', reg: /(^|\s|\(|\))set\s/ig}, |
| | | {key: 'drop', reg: /(^|\s|\(|\))drop\s/ig}, |
| | | {key: 'alter', reg: /(^|\s|\(|\))alter\s/ig}, |
| | | {key: 'truncate', reg: /(^|\s|\(|\))truncate\s/ig}, |
| | | {key: 'if', reg: /(^|\s|\(|\))if\s/ig}, |
| | | {key: 'exec', reg: /(^|\s|\(|\))exec(\s|\()/ig}, |
| | | {key: 'OBJECT', reg: /(^|\s|\(|\))object(\s|\()/ig}, |
| | | {key: 'sys.', reg: /(^|\s|\(|\))sys\./ig}, |
| | | {key: 'kill', reg: /(^|\s|\(|\))kill\s/ig} |
| | | ] |
| | | |
| | | if (type === 'customscript') { |
| | | chars = chars.filter(char => !['create', 'insert', 'delete', 'update', 'set', 'drop', 'if', 'exec'].includes(char.key)) |
| | | } |
| | | |
| | | let error = '' |
| | | |
| | | sql = sql.replace(/sys\.fn_/ig, '') // 跳过sys.fn_验证 |
| | | |
| | | chars.forEach(char => { |
| | | if (!error && char.reg.test(sql)) { |
| | | error = char.key |
| | | } |
| | | }) |
| | | |
| | | return error |
| | | } |
| | | |
| | | /** |
| | | * @description sql加密 |
| | | * @return {String} value |
| | | */ |
| | |
| | | }) |
| | | } |
| | | } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) { |
| | | if (!val && val !== 0) { |
| | | if (col.required === 'false') { |
| | | if (!val || isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | } else if (!val && val !== 0) { |
| | | errors.push(_position + '内容不可为空') |
| | | } else if (isNaN(val)) { // 检验是否为数值 |
| | | errors.push(_position + '内容应为数值') |
| | |
| | | _sql = _sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | _sql = _sql.replace(/@typename@/ig, `'admin'`) |
| | | |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | _sql = _sql.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | _sql = _sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`) |
| | | } else { |
| | |
| | | * @description 获取标记信息 |
| | | */ |
| | | export function getMark (marks, record, style) { |
| | | let res = {} |
| | | let res = {signType: ''} |
| | | |
| | | marks.some(mark => { |
| | | let originVal = record[mark.field[0]] |
| | |
| | | if (res.status) { |
| | | window.GLOB.style = res.CSS |
| | | document.title = res.titleName |
| | | sessionStorage.setItem('appname', res.appname || '') |
| | | |
| | | if (window.GLOB.style && styles[window.GLOB.style]) { |
| | | document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '') |
| | |
| | | auto: config.printPage === 'auto', |
| | | config |
| | | }, () => { |
| | | if (config.normalcss) { |
| | | let node = document.getElementById(config.uuid) |
| | | node && node.remove() |
| | | |
| | | let ele = document.createElement('style') |
| | | ele.id = config.uuid |
| | | ele.innerHTML = config.normalcss |
| | | document.getElementsByTagName('head')[0].appendChild(ele) |
| | | } |
| | | |
| | | if (params.length === 0 && initInters.length === 0) { |
| | | this.setState({loadingview: false, pages: [config.components]}) |
| | | } else if (initInters.length > 0) { |
| | |
| | | webSite: res.WebSite || '', |
| | | navBar: res.menu_type, // shutter 百叶窗、linkage_navigation 联动菜单、linkage 联动菜单_无导航栏、menu_board 菜单面板、menu_board_navigation 菜单面板_标签页 |
| | | app_version: res.app_version, |
| | | Member_Level: 0 |
| | | Member_Level: 0, |
| | | appname: res.appname || '' |
| | | } |
| | | |
| | | if ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100].includes(res.member_level)) { |
| | |
| | | window.GLOB.style = systemMsg.style |
| | | window.GLOB.navBar = systemMsg.navBar |
| | | window.GLOB.appVersion = systemMsg.app_version |
| | | sessionStorage.setItem('appname', res.appname || '') |
| | | |
| | | if (window.GLOB.style && styles[window.GLOB.style]) { |
| | | document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '') |
| | |
| | | EasyCode: config.easyCode || '', |
| | | Template: 'CustomPage', |
| | | MenuName: config.MenuName || '', |
| | | PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', interfaces}), |
| | | PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces}), |
| | | open_edition: config.open_edition, |
| | | LText: '', |
| | | LTexttb: '', |
| | |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | |
| | | const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) |
| | | const SysColorSketch = asyncComponent(() => import('@/menu/stylecontroller/syscolorsketch')) |
| | | |
| | | class CustomMenuForm extends Component { |
| | | static propTpyes = { |
| | |
| | | })(<TextArea rows={2} placeholder={''} onChange={(e) => {this.selectChange('Remark', e.target.value)}}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item style={{marginBottom: '0px'}} label="菜单颜色"> |
| | | <ColorSketch allowClear={true} value={config.menuColor || ''} onChange={(val) => {this.selectChange('menuColor', val)}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item style={{marginBottom: '0px'}} label="系统色"> |
| | | <SysColorSketch onChange={(val) => {this.selectChange('menuColor', val)}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | ) |
| | |
| | | color: red; |
| | | } |
| | | } |
| | | .color-sketch-block { |
| | | position: relative; |
| | | top: 7px; |
| | | .color-sketch-block-box { |
| | | width: 40px; |
| | | } |
| | | .color-sketch-value { |
| | | width: 130px; |
| | | |
| | | .anticon-close-circle { |
| | | right: 10px; |
| | | } |
| | | } |
| | | } |
| | | .sys-color-sketch-block { |
| | | white-space: nowrap; |
| | | } |
| | | } |
| | |
| | | webSite: res.WebSite || '', |
| | | navBar: res.menu_type, |
| | | app_version: res.app_version, |
| | | Member_Level: 0 |
| | | Member_Level: 0, |
| | | appname: res.appname || '' |
| | | } |
| | | |
| | | if ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100].includes(res.member_level)) { |
| | |
| | | window.GLOB.style = systemMsg.style |
| | | window.GLOB.navBar = systemMsg.navBar |
| | | window.GLOB.appVersion = systemMsg.app_version |
| | | sessionStorage.setItem('appname', res.appname || '') |
| | | |
| | | if (window.GLOB.style && styles[window.GLOB.style]) { |
| | | document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '') |
| | |
| | | EasyCode: config.easyCode || '', |
| | | Template: 'BaseTable', |
| | | MenuName: config.MenuName || '', |
| | | PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', interfaces}), |
| | | PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces}), |
| | | open_edition: config.open_edition, |
| | | LText: '', |
| | | LTexttb: '', |
| | |
| | | import { Form, Row, Col, Input, Select, notification, Switch, Radio } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | |
| | | const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) |
| | | const SysColorSketch = asyncComponent(() => import('@/menu/stylecontroller/syscolorsketch')) |
| | | |
| | | class CustomMenuForm extends Component { |
| | | static propTpyes = { |
| | |
| | | })(<TextArea rows={2} placeholder={''} onChange={this.changeRemark} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item style={{marginBottom: '0px'}} label="菜单颜色"> |
| | | <ColorSketch allowClear={true} value={config.menuColor || ''} onChange={(val) => {this.selectChange('menuColor', val)}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item style={{marginBottom: '0px'}} label="系统色"> |
| | | <SysColorSketch onChange={(val) => {this.selectChange('menuColor', val)}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | ) |
| | |
| | | color: red; |
| | | } |
| | | } |
| | | .color-sketch-block { |
| | | position: relative; |
| | | top: 7px; |
| | | .color-sketch-block-box { |
| | | width: 40px; |
| | | } |
| | | .color-sketch-value { |
| | | width: 130px; |
| | | .anticon-close-circle { |
| | | right: 10px; |
| | | } |
| | | } |
| | | } |
| | | .sys-color-sketch-block { |
| | | white-space: nowrap; |
| | | } |
| | | } |