From a06655e10f4242c350a3450c6c21e77f33302e2e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 27 十一月 2020 22:09:04 +0800 Subject: [PATCH] 2020-11-27 --- src/menu/datasource/verifycard/utils.jsx | 11 src/templates/zshare/editTable/index.jsx | 129 +++++++++--- src/menu/components/table/normal-table/columncomponent/index.jsx | 4 src/menu/stylecontroller/index.jsx | 4 src/templates/sharecomponent/columncomponent/markcolumn/markform/index.jsx | 22 - src/tabviews/zshare/normalTable/index.jsx | 154 ++++++-------- src/templates/zshare/verifycard/index.jsx | 6 src/menu/stylecontroller/styleInput/index.jsx | 4 src/templates/sharecomponent/fieldscomponent/editcard/index.jsx | 2 src/templates/zshare/verifycard/customscript/index.jsx | 2 src/menu/components/tabs/antv-tabs/index.scss | 9 src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx | 8 src/menu/components/tabs/antv-tabs/dragabletabs.jsx | 125 ++++++++++++ src/menu/components/table/normal-table/index.scss | 3 src/menu/stylecontroller/index.scss | 22 - src/templates/sharecomponent/columncomponent/index.jsx | 4 src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx | 8 src/menu/components/table/normal-table/index.jsx | 12 + src/menu/components/tabs/antv-tabs/index.jsx | 24 + src/templates/zshare/editTable/index.scss | 20 + src/templates/sharecomponent/settingcomponent/settingform/utils.jsx | 8 src/menu/stylecontroller/styleInput/index.scss | 8 22 files changed, 403 insertions(+), 186 deletions(-) diff --git a/src/menu/components/table/normal-table/columncomponent/index.jsx b/src/menu/components/table/normal-table/columncomponent/index.jsx index ea1c143..cd4d1d1 100644 --- a/src/menu/components/table/normal-table/columncomponent/index.jsx +++ b/src/menu/components/table/normal-table/columncomponent/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Modal, notification, Switch, message, Spin } from 'antd' +import { Icon, Modal, notification, Switch, message } from 'antd' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' @@ -25,7 +25,6 @@ state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, columnlist: null, // 鏄剧ず鍒� - loading: false, // 鏌ヨ鏄剧ず鍒楄仈鍔ㄨ彍鍗� showField: false, // 鏄剧ず鍒楀瓧娈� modaltype: '', // 妯℃�佹鎺у埗 card: null // 缂栬緫涓厓绱� @@ -500,7 +499,6 @@ columns={columnlist} /> </Modal> - {this.state.loading && <Spin size="large" />} </div> ) } diff --git a/src/menu/components/table/normal-table/index.jsx b/src/menu/components/table/normal-table/index.jsx index a344fde..0c0bc3e 100644 --- a/src/menu/components/table/normal-table/index.jsx +++ b/src/menu/components/table/normal-table/index.jsx @@ -71,6 +71,18 @@ cols: [ { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, + { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 } ], scripts: [] diff --git a/src/menu/components/table/normal-table/index.scss b/src/menu/components/table/normal-table/index.scss index 0077e7e..cdbcbe6 100644 --- a/src/menu/components/table/normal-table/index.scss +++ b/src/menu/components/table/normal-table/index.scss @@ -10,6 +10,7 @@ .model-table-search-list { padding: 10px 0px 0px; min-height: 65px; + border-bottom: 1px solid #f0f0f0; >.anticon-question-circle { display: none; } @@ -32,7 +33,7 @@ } .model-menu-action-list { line-height: 40px; - padding: 15px 0px 10px; + padding: 10px 0px; } .model-menu-action-list.length0 { display: none; diff --git a/src/menu/components/tabs/antv-tabs/dragabletabs.jsx b/src/menu/components/tabs/antv-tabs/dragabletabs.jsx new file mode 100644 index 0000000..74ef3ef --- /dev/null +++ b/src/menu/components/tabs/antv-tabs/dragabletabs.jsx @@ -0,0 +1,125 @@ +import React, { Component } from 'react' +import { Tabs } from 'antd' +import { DndProvider, DragSource, DropTarget } from 'react-dnd' + +// Drag & Drop node +class TabNode extends Component { + render() { + const { connectDragSource, connectDropTarget, children } = this.props + + return connectDragSource(connectDropTarget(children)) + } +} + +const cardTarget = { + drop(props, monitor) { + const dragKey = monitor.getItem().index + const hoverKey = props.index + + if (dragKey === hoverKey) { + return; + } + + props.moveTabNode(dragKey, hoverKey) + monitor.getItem().index = hoverKey + } +} + +const cardSource = { + beginDrag(props) { + return { + id: props.id, + index: props.index, + } + } +} + +const WrapTabNode = DropTarget('DND_NODE', cardTarget, connect => ({ + connectDropTarget: connect.dropTarget(), +}))( + DragSource('DND_NODE', cardSource, (connect, monitor) => ({ + connectDragSource: connect.dragSource(), + isDragging: monitor.isDragging(), + }))(TabNode) +) + +class DraggableTabs extends Component { + state = { + order: [] + } + + moveTabNode = (dragKey, hoverKey) => { + const newOrder = this.state.order.slice() + const { children } = this.props + + if (dragKey === 'tool' || hoverKey === 'tool') return + + React.Children.forEach(children, c => { + if (newOrder.indexOf(c.key) === -1) { + newOrder.push(c.key) + } + }) + + const dragIndex = newOrder.indexOf(dragKey) + const hoverIndex = newOrder.indexOf(hoverKey) + + newOrder.splice(dragIndex, 1) + newOrder.splice(hoverIndex, 0, dragKey) + let _order = newOrder.filter(item => item !== 'tool') + + this.setState({ + order: [..._order, 'tool'] + }) + this.props.tabsMove(_order) + } + + renderTabBar = (props, DefaultTabBar) => ( + <DefaultTabBar {...props}> + {node => ( + <WrapTabNode key={node.key} index={node.key} moveTabNode={this.moveTabNode}> + {node} + </WrapTabNode> + )} + </DefaultTabBar> + ) + + render() { + const { order } = this.state + const { children } = this.props + + const tabs = [] + React.Children.forEach(children, c => { + tabs.push(c) + }) + + const orderTabs = tabs.slice().sort((a, b) => { + const orderA = order.indexOf(a.key) + const orderB = order.indexOf(b.key) + + if (orderA !== -1 && orderB !== -1) { + return orderA - orderB + } + if (orderA !== -1) { + return -1 + } + if (orderB !== -1) { + return 1 + } + + const ia = tabs.indexOf(a) + const ib = tabs.indexOf(b) + + return ia - ib + }) + + return ( + <DndProvider> + <Tabs renderTabBar={this.renderTabBar} {...this.props}> + {orderTabs} + </Tabs> + </DndProvider> + ) + } +} + +export default DraggableTabs \ No newline at end of file diff --git a/src/menu/components/tabs/antv-tabs/index.jsx b/src/menu/components/tabs/antv-tabs/index.jsx index e5b9733..720b8b4 100644 --- a/src/menu/components/tabs/antv-tabs/index.jsx +++ b/src/menu/components/tabs/antv-tabs/index.jsx @@ -7,6 +7,7 @@ import MKEmitter from '@/utils/events.js' import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' +import DraggableTabs from './dragabletabs' import Utils from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/model.js' @@ -218,9 +219,20 @@ }) } - moveSwitch = (index, index1) => { + moveSwitch = (order) => { let tabs = fromJS(this.state.tabs).toJS() - tabs.subtabs[index] = tabs.subtabs.splice(index1, 1, tabs.subtabs[index])[0] + let subtab = {} + tabs.subtabs.forEach(item => { + subtab[item.uuid] = item + }) + + tabs.subtabs = [] + + order.forEach(item => { + if (subtab[item]) { + tabs.subtabs.push(subtab[item]) + } + }) this.setState({tabs}) this.props.updateConfig(tabs) @@ -231,14 +243,12 @@ return ( <div className="menu-tabs-edit-box" style={tabs.style}> - <Tabs defaultActiveKey="1" tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}> - {tabs.subtabs.map((tab, index) => ( + <DraggableTabs tabPosition={tabs.setting.position} type={tabs.setting.tabStyle} tabsMove={this.moveSwitch}> + {tabs.subtabs.map(tab => ( <TabPane tab={ <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> <Icon className="edit" title="edit" type="edit" onClick={() => this.editTab(tab)} /> - {index !== 0 ? <Icon className="edit" type="arrow-left" onClick={() => this.moveSwitch(index, index - 1)} /> : null} - {(index + 1) !== tabs.subtabs.length ? <Icon className="edit" type="arrow-right" onClick={() => this.moveSwitch(index, index + 1)} /> : null} <Icon className="close" title="delete" type="close" onClick={() => this.delTab(tab)} /> </div> } trigger="hover"> @@ -261,7 +271,7 @@ </Popover> } key="tool"> </TabPane> - </Tabs> + </DraggableTabs> <Modal wrapClassName="popview-modal" title={'鏍囩缂栬緫'} diff --git a/src/menu/components/tabs/antv-tabs/index.scss b/src/menu/components/tabs/antv-tabs/index.scss index b459cec..15a8e81 100644 --- a/src/menu/components/tabs/antv-tabs/index.scss +++ b/src/menu/components/tabs/antv-tabs/index.scss @@ -10,6 +10,15 @@ min-height: 200px; } + .ant-tabs .ant-tabs-top-bar > .ant-tabs-nav-container { + >.ant-tabs-tab-next:not(.ant-tabs-tab-arrow-show) + .ant-tabs-nav-wrap > .ant-tabs-nav-scroll > .ant-tabs-nav { + width: 100%; + > div > .ant-tabs-tab-disabled { + float: right; + } + } + } + .ant-tabs .ant-tabs-left-bar .ant-tabs-tab { padding: 0px; text-align: right; diff --git a/src/menu/datasource/verifycard/utils.jsx b/src/menu/datasource/verifycard/utils.jsx index bb94a8f..109192d 100644 --- a/src/menu/datasource/verifycard/utils.jsx +++ b/src/menu/datasource/verifycard/utils.jsx @@ -141,19 +141,24 @@ _dataresource = '(' + _dataresource + ') tb' } - _dataresource = `select ${setting.laypage !== 'false' ? 'top 10' : ''} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource} ${_search}) tmptable ${setting.laypage !== 'false' ? 'where rows > 0' : ''} order by tmptable.rows` + _dataresource = `select${setting.laypage !== 'false' ? ' top 10' : ''} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource} ${_search}) tmptable ${setting.laypage !== 'false' ? 'where rows > 0' : ''} order by tmptable.rows` } if (_customScript) { - sql = `${_customScript} + sql = `/* sql 楠岃瘉 */ + ${_customScript} ${_dataresource} aaa: if @ErrorCode!='' insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ ` } else { - sql = _dataresource + sql = `/* sql 楠岃瘉 */ + ${_dataresource}` } + sql = sql.replace(/\n\s{8}/ig, '\n') + + console.info(sql) return { error, sql } } diff --git a/src/menu/stylecontroller/index.jsx b/src/menu/stylecontroller/index.jsx index c84c183..2a89594 100644 --- a/src/menu/stylecontroller/index.jsx +++ b/src/menu/stylecontroller/index.jsx @@ -295,7 +295,7 @@ > <div className="menu-style-controller"> <Form {...formItemLayout}> - {card ? <Collapse expandIconPosition="right" destroyInactivePanel={true} defaultActiveKey={options[0]} accordion={true}> + {card ? <Collapse expandIconPosition="right" destroyInactivePanel={true} defaultActiveKey={options[0]}> {options.includes('height') ? <Panel header="楂樺害" key="height"> <Col span={24}> <Form.Item @@ -597,7 +597,7 @@ </Collapse> : null} </Form> <div style={{textAlign: 'right'}}> - <Button style={{margin: '30px 10px 0px 0px'}} onClick={this.onCloseDrawer}>鍏抽棴</Button> + <Button style={{margin: '30px 10px 30px 0px'}} onClick={this.onCloseDrawer}>鍏抽棴</Button> </div> </div> </Drawer> diff --git a/src/menu/stylecontroller/index.scss b/src/menu/stylecontroller/index.scss index f1c1560..e17070f 100644 --- a/src/menu/stylecontroller/index.scss +++ b/src/menu/stylecontroller/index.scss @@ -9,7 +9,7 @@ > .ant-collapse-item { border-color: #202735; > .ant-collapse-header { - padding: 10px 40px 10px 16px; + padding: 7px 40px 7px 16px; background: #262E3F; color: rgba(255, 255, 255, 0.85); } @@ -29,7 +29,7 @@ width: 100%; } .ant-form-item { - margin-bottom: 5px; + margin-bottom: 2px; .ant-form-item-label > label { color: rgba(255, 255, 255, 0.85); @@ -62,6 +62,9 @@ .ant-input-number-input { height: 28px; } + } + .ant-input-group-addon { + background: transparent; } .ant-select-selection { background: transparent; @@ -172,18 +175,7 @@ overflow-y: auto; } .ant-drawer-body::-webkit-scrollbar { - width: 7px; - } - .ant-drawer-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-drawer-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); + display: none; } .ant-drawer-wrapper-body { background: #262E3F; @@ -206,7 +198,7 @@ height: 48px; width: 48px; line-height: 48px; - color: rgba(255, 255, 255, 0.65); + color: #ffffff; } } } diff --git a/src/menu/stylecontroller/styleInput/index.jsx b/src/menu/stylecontroller/styleInput/index.jsx index a7d3df9..7426b2d 100644 --- a/src/menu/stylecontroller/styleInput/index.jsx +++ b/src/menu/stylecontroller/styleInput/index.jsx @@ -139,9 +139,11 @@ return ( <div className="style-input-box"> <Input value={value} addonAfter={ + options.length > 1 ? <Select value={unit} onChange={this.changeUnit}> {options.map(item => <Option key={item} value={item}>{item}</Option>)} - </Select> + </Select> : + <div className="single-unit">{unit}</div> } onChange={this.changeValue}/> </div> ) diff --git a/src/menu/stylecontroller/styleInput/index.scss b/src/menu/stylecontroller/styleInput/index.scss index e76a3e4..6e9d563 100644 --- a/src/menu/stylecontroller/styleInput/index.scss +++ b/src/menu/stylecontroller/styleInput/index.scss @@ -2,8 +2,10 @@ line-height: 32px; .ant-select { width: 60px!important; - .ant-select-selection { - color: rgba(0, 0, 0, 0.75)!important; - } + } + .single-unit { + width: 38px; + text-align: left; + color: rgba(255, 255, 255, 0.65); } } diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index bfe9cc6..73ab9d6 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -56,7 +56,6 @@ imgShow: false, // 鍥剧墖鏀惧ぇ妯℃�佹 imgSrc: '', // 鍥剧墖璺緞 lineMarks: null, // 琛屾爣璁� - colMap: null, // 鍒椾俊鎭紙鍏ㄩ儴锛� activeIndex: null, // 鏍囪褰撳墠閫変腑琛� rowspan: null // 琛屽悎骞跺瓧娈典俊鎭� } @@ -66,7 +65,6 @@ let columns = JSON.parse(JSON.stringify(this.props.columns)) let lineMarks = [] let _columns = [] - let colMap = new Map() // 鐢ㄤ簬鑾峰彇瀛楁淇℃伅 let radio = 5 // 铏氬寲姣斾緥 let _format = false // 鏄惁铏氬寲澶勭悊 let rowspan = null @@ -81,10 +79,15 @@ } } + // 鑾峰彇琛屾爣璁� config.columns.forEach(col => { if (!col.field) return - colMap.set(col.field, col) + col.marks && col.marks.forEach(mark => { + if (mark.signType === 'line') { + lineMarks.push(mark) + } + }) }) columns.forEach((item, index) => { @@ -94,31 +97,8 @@ item.blur = true } - if (item.marks) { - item.marks = item.marks.filter(mark => { - let originField = colMap.get(mark.field) - let contrastField = mark.contrastType === 'dynamic' ? colMap.get(mark.contrastField) : '' - - if (!originField || (mark.contrastType === 'dynamic' && !contrastField)) return false - if (contrastField && originField.type !== contrastField.type) return false - if (mark.contrastType === 'static') { - if (originField.type === 'text' && typeof(mark.contrastValue) === 'number') { - return false - } else if (originField.type === 'number' && typeof(mark.contrastValue) === 'string') { - return false - } else if (!['number', 'text'].includes(originField.type)) { - return false - } - } - - if (mark.signType === 'line') { - lineMarks.push(mark) - return false - } else if (mark.signType === 'card') { - return false - } - return true - }) + if (item.marks) { // 杩囨护琛屽拰鍗$墖鏍囪 + item.marks = item.marks.filter(mark => mark.signType !== 'line' && mark.signType !== 'card') if (item.marks.length === 0) { item.marks = '' @@ -134,6 +114,14 @@ if (col.rowspan === 'true') { rowspan = col + } + + if (col.marks) { // 杩囨护琛屽拰鍗$墖鏍囪 + col.marks = col.marks.filter(mark => mark.signType !== 'line' && mark.signType !== 'card') + + if (col.marks.length === 0) { + col.marks = '' + } } cell.children.push({ @@ -179,7 +167,6 @@ columns: _columns, pageSize: pageSize ? pageSize : 10, lineMarks: lineMarks, - colMap: colMap, rowspan: rowspan }) } @@ -271,54 +258,48 @@ } getMark = (record, marks) => { - const { colMap } = this.state let className = '' let isIcon = false let position = 'back' let icon = '' marks.some(mark => { - let originField = colMap.get(mark.field) - - if (!originField) return false - - let originType = originField.type || 'text' - - let originVal = record.hasOwnProperty(mark.field) ? record[mark.field] : '' + let originVal = record[mark.field] + '' let contrastVal = '' if (mark.contrastType === 'static') { - contrastVal = mark.contrastValue + contrastVal = mark.contrastValue + '' } else { - contrastVal = record.hasOwnProperty(mark.contrastField) ? record[mark.contrastField] : '' + contrastVal = record[mark.contrastField] + '' } - if (originType === 'text') { - originVal = '' + originVal - contrastVal = '' + contrastVal - } else if (originType === 'number' && originVal !== '' && contrastVal !== '') { + if (mark.match === '=') { + className = originVal === contrastVal ? mark.color[1] : '' + } else if (mark.match === '!=') { + className = originVal !== contrastVal ? mark.color[1] : '' + } else if (mark.match === 'like') { + className = originVal.indexOf(contrastVal) > -1 ? mark.color[1] : '' + } else if (mark.match === '>') { try { originVal = parseFloat(originVal) contrastVal = parseFloat(contrastVal) - if (isNaN(originVal) || isNaN(contrastVal)) { - originVal = '' - } } catch { - originVal = '' + originVal = NaN } - } - if (originVal === '' || contrastVal === '') return false + if (!isNaN(originVal) && !isNaN(contrastVal) && originVal > contrastVal) { + className = mark.color[1] + } + } else if (mark.match === '<') { + try { + originVal = parseFloat(originVal) + contrastVal = parseFloat(contrastVal) + } catch { + originVal = NaN + } - if (mark.match === '=' && originVal === contrastVal) { - className = mark.color[1] - } else if (mark.match === '!=' && originVal !== contrastVal) { - className = mark.color[1] - } else if (mark.match === 'like' && originVal.indexOf(contrastVal) > -1) { - className = mark.color[1] - } else if (mark.match === '>' && originVal > contrastVal) { - className = mark.color[1] - } else if (mark.match === '<' && originVal < contrastVal) { - className = mark.color[1] + if (!isNaN(originVal) && !isNaN(contrastVal) && originVal < contrastVal) { + className = mark.color[1] + } } if (!className) return false @@ -999,7 +980,7 @@ render() { const { setting, pickup, statFValue } = this.props - const { selectedRowKeys, lineMarks, colMap, activeIndex, rowspan } = this.state + const { selectedRowKeys, lineMarks, activeIndex, rowspan } = this.state // 璁剧疆琛ㄦ牸閫夋嫨灞炴�э細鍗曢�夈�佸閫夈�佷笉鍙�� let rowSelection = null @@ -1112,43 +1093,42 @@ if (lineMarks.length === 0) return className lineMarks.some(mark => { - let originType = colMap.get(mark.field).type - - let originVal = record.hasOwnProperty(mark.field) ? record[mark.field] : '' + let originVal = record[mark.field] + '' let contrastVal = '' if (mark.contrastType === 'static') { - contrastVal = mark.contrastValue + contrastVal = mark.contrastValue + '' } else { - contrastVal = record.hasOwnProperty(mark.contrastField) ? record[mark.contrastField] : '' + contrastVal = record[mark.contrastField] + '' } - if (originType === 'text') { - originVal = '' + originVal - contrastVal = '' + contrastVal - } else if (originType === 'number' && originVal !== '' && contrastVal !== '') { + if (mark.match === '=') { + className = originVal === contrastVal ? 'background ' + mark.color[1] : '' + } else if (mark.match === '!=') { + className = originVal !== contrastVal ? 'background ' + mark.color[1] : '' + } else if (mark.match === 'like') { + className = originVal.indexOf(contrastVal) > -1 ? 'background ' + mark.color[1] : '' + } else if (mark.match === '>') { try { originVal = parseFloat(originVal) contrastVal = parseFloat(contrastVal) - if (isNaN(originVal) || isNaN(contrastVal)) { - originVal = '' - } } catch { - originVal = '' + originVal = NaN } - } - - if (originVal === '' || contrastVal === '') return false - - if (mark.match === '=' && originVal === contrastVal) { - className = 'background ' + mark.color[1] - } else if (mark.match === '!=' && originVal !== contrastVal) { - className = 'background ' + mark.color[1] - } else if (mark.match === 'like' && originVal.indexOf(contrastVal) > -1) { - className = 'background ' + mark.color[1] - } else if (mark.match === '>' && originVal > contrastVal) { - className = 'background ' + mark.color[1] - } else if (mark.match === '<' && originVal < contrastVal) { - className = 'background ' + mark.color[1] + + if (!isNaN(originVal) && !isNaN(contrastVal) && originVal > contrastVal) { + className = 'background ' + mark.color[1] + } + } else if (mark.match === '<') { + try { + originVal = parseFloat(originVal) + contrastVal = parseFloat(contrastVal) + } catch { + originVal = NaN + } + + if (!isNaN(originVal) && !isNaN(contrastVal) && originVal < contrastVal) { + className = 'background ' + mark.color[1] + } } if (!className) return false diff --git a/src/templates/sharecomponent/columncomponent/index.jsx b/src/templates/sharecomponent/columncomponent/index.jsx index b24f1db..edcba01 100644 --- a/src/templates/sharecomponent/columncomponent/index.jsx +++ b/src/templates/sharecomponent/columncomponent/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Tooltip, Modal, notification, Switch, message, Spin } from 'antd' +import { Icon, Tooltip, Modal, notification, Switch, message } from 'antd' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' @@ -26,7 +26,6 @@ state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, columnlist: null, // 鏄剧ず鍒� - loading: false, // 鏌ヨ鏄剧ず鍒楄仈鍔ㄨ彍鍗� showField: false, // 鏄剧ず鍒楀瓧娈� modaltype: '', // 妯℃�佹鎺у埗 card: null // 缂栬緫涓厓绱� @@ -583,7 +582,6 @@ columns={columnlist} /> </Modal> - {this.state.loading && <Spin size="large" />} </div> ) } diff --git a/src/templates/sharecomponent/columncomponent/markcolumn/markform/index.jsx b/src/templates/sharecomponent/columncomponent/markcolumn/markform/index.jsx index 07d195f..de77471 100644 --- a/src/templates/sharecomponent/columncomponent/markcolumn/markform/index.jsx +++ b/src/templates/sharecomponent/columncomponent/markcolumn/markform/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Select, Button, Input, InputNumber, Radio, Icon, Cascader, Tooltip } from 'antd' +import { Form, Row, Col, Select, Button, Input, Radio, Icon, Cascader, Tooltip } from 'antd' import { minkeColorSystem, minkeIconSystem } from '@/utils/option.js' import './index.scss' @@ -183,8 +183,6 @@ } } - let contFields = columns.filter(col => originField.field !== col.field && originField.type === col.type) - return ( <Form {...formItemLayout} id="model-mark-form-box" className="mingke-table"> <Row gutter={24}> @@ -237,9 +235,9 @@ <Select> <Select.Option value="="> = </Select.Option> <Select.Option value="!="> != </Select.Option> - {originField.type === 'number' ? <Select.Option value=">"> > </Select.Option> : null} - {originField.type === 'number' ? <Select.Option value="<"> < </Select.Option> : null} - {originField.type === 'text' ? <Select.Option value="like"> like </Select.Option> : null} + <Select.Option value=">"> > </Select.Option> + <Select.Option value="<"> < </Select.Option> + <Select.Option value="like"> like </Select.Option> </Select> )} </Form.Item> @@ -247,14 +245,8 @@ {contrastType === 'static' ? <Col span={6}> <Form.Item label={'瀵规瘮鍊�'}> {getFieldDecorator('contrastValue', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '瀵规瘮鍊�!' - } - ] - })(originField.type === 'number' ? <InputNumber /> : <Input placeholder="" autoComplete="off" />)} + initialValue: '' + })(<Input placeholder="" autoComplete="off" />)} </Form.Item> </Col> : null} {contrastType === 'dynamic' ? <Col span={6}> @@ -272,7 +264,7 @@ showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} > - {contFields.map(item => ( + {columns.map(item => ( <Select.Option key={item.uuid} title={item.label + '(' + item.field + ')'} value={item.field}>{item.label + '(' + item.field + ')'}</Select.Option> ))} </Select> diff --git a/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx b/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx index befaacb..2d89188 100644 --- a/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx +++ b/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx @@ -139,7 +139,7 @@ </Row> <Row> {dataSource.map((item, index) => { - if (item.field.toLowerCase().indexOf(this.state.searchKey.toLowerCase()) >= 0) { + if (item.field.toLowerCase().indexOf(this.state.searchKey.toLowerCase()) >= 0 || item.label.indexOf(this.state.searchKey) >= 0) { return ( <Col key={index} span={8}> <EditCardCell ref={'cellCard' + index} type={type} card={item} dict={this.props.dict} changeCard={this.changeCard} /> diff --git a/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx b/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx index dd9ef88..af0e089 100644 --- a/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx +++ b/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx @@ -96,15 +96,19 @@ } if (_customScript) { - sql = `${_customScript} + sql = `/* sql 楠岃瘉 */ + ${_customScript} ${_dataresource} aaa: if @ErrorCode!='' insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ ` } else { - sql = _dataresource + sql = `/* sql 楠岃瘉 */ + ${_dataresource}` } + sql = sql.replace(/\n\s{8}/ig, '\n') + console.info(sql) return sql } diff --git a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx index b5c6d98..273f935 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx @@ -78,15 +78,19 @@ } if (_customScript) { - sql = `${_customScript} + sql = `/* sql 楠岃瘉 */ + ${_customScript} ${_dataresource} aaa: if @ErrorCode!='' insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ ` } else { - sql = _dataresource + sql = `/* sql 楠岃瘉 */ + ${_dataresource}` } + sql = sql.replace(/\n\s{8}/ig, '\n') + console.info(sql) return sql } diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx index 0358ea7..3844adb 100644 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx @@ -52,15 +52,19 @@ } if (_customScript) { - sql = `${_customScript} + sql = `/* sql 楠岃瘉 */ + ${_customScript} ${_dataresource} aaa: if @ErrorCode!='' insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ ` } else { - sql = _dataresource + sql = `/* sql 楠岃瘉 */ + ${_dataresource}` } + sql = sql.replace(/\n\s{8}/ig, '\n') + console.info(sql) return sql } diff --git a/src/templates/zshare/editTable/index.jsx b/src/templates/zshare/editTable/index.jsx index bfeffd6..24d7725 100644 --- a/src/templates/zshare/editTable/index.jsx +++ b/src/templates/zshare/editTable/index.jsx @@ -1,6 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' +import { DndProvider, DragSource, DropTarget } from 'react-dnd' import { Table, Input, InputNumber, Popconfirm, Form, Icon, Select, Radio, Cascader, notification } from 'antd' import ColorSketch from '@/mob/colorsketch' @@ -11,6 +12,61 @@ let eTDict = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS const EditableContext = React.createContext() +let dragingIndex = -1 + +class BodyRow extends React.Component { + render() { + const { isOver, connectDragSource, connectDropTarget, moveRow, ...restProps } = this.props + const style = { ...restProps.style, cursor: 'move' } + + let { className } = restProps + if (isOver) { + if (restProps.index > dragingIndex) { + className += ' drop-over-downward' + } + if (restProps.index < dragingIndex) { + className += ' drop-over-upward' + } + } + + return connectDragSource( + connectDropTarget(<tr {...restProps} className={className} style={style} />), + ) + } +} + +const rowSource = { + beginDrag(props) { + dragingIndex = props.index + return { + index: props.index, + } + } +} + +const rowTarget = { + drop(props, monitor) { + const dragIndex = monitor.getItem().index + const hoverIndex = props.index + + if (dragIndex === hoverIndex) { + return + } + + props.moveRow(dragIndex, hoverIndex) + + monitor.getItem().index = hoverIndex + }, +} + +const DragableBodyRow = DropTarget('row', rowTarget, (connect, monitor) => ({ + connectDropTarget: connect.dropTarget(), + isOver: monitor.isOver(), +}))( + DragSource('row', rowSource, connect => ({ + connectDragSource: connect.dragSource(), + }))(BodyRow), +) class EditableCell extends Component { getInput = (form) => { @@ -130,8 +186,6 @@ ) : ( <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')}> {!actions || actions.includes('edit') ? <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><Icon type="edit" /></span> : null} - {!actions || actions.includes('up') ? <span className="primary" onClick={() => {editingKey === '' && this.handleUpDown(record.uuid, 'up')}}><Icon type="arrow-up" /></span> : null} - {!actions || actions.includes('down') ? <span className="danger" onClick={() => {editingKey === '' && this.handleUpDown(record.uuid, 'down')}}><Icon type="arrow-down" /></span> : null} {(!actions || actions.includes('del')) && editingKey === '' ? <Popconfirm overlayClassName="popover-confirm" title={eTDict['model.query.delete']} @@ -226,27 +280,6 @@ }) } - handleUpDown = (uuid, direction) => { - let _data = fromJS(this.state.data).toJS() - const index = _data.findIndex(item => uuid === item.uuid) - - if ((index === 0 && direction === 'up') || (index === _data.length - 1 && direction === 'down')) { - return - } - - if (direction === 'up') { - _data.splice(index - 1, 0, ..._data.splice(index, 1)) - } else { - _data.splice(index + 1, 0, ..._data.splice(index, 1)) - } - - this.setState({ - data: _data - }, () => { - this.props.onChange(_data) - }) - } - save(form, uuid) { const { columns } = this.state form.validateFields((error, row) => { @@ -296,11 +329,31 @@ this.setState({ editingKey: uuid }) } + moveRow = (dragIndex, hoverIndex) => { + const { editingKey } = this.state + let _data = fromJS(this.state.data).toJS() + + if (editingKey) return + + _data.splice(hoverIndex, 0, ..._data.splice(dragIndex, 1)) + + this.setState({ + data: _data + }, () => { + this.props.onChange(_data) + }) + } + render() { - const components = { + const { actions } = this.props + + let components = { body: { - cell: EditableCell, + cell: EditableCell } + } + if (!actions || actions.includes('down') || actions.includes('up')) { + components.body.row = DragableBodyRow } const columns = this.state.columns.map(col => { @@ -325,16 +378,22 @@ return ( <EditableContext.Provider value={this.props.form}> - <div className="modal-edit-table"> - <Table - bordered - rowKey="uuid" - components={components} - dataSource={this.state.data} - columns={columns} - rowClassName="editable-row" - pagination={false} - /> + <div className={'modal-edit-table ' + (this.state.editingKey ? 'editing' : '')}> + <DndProvider> + <Table + bordered + rowKey="uuid" + components={components} + dataSource={this.state.data} + columns={columns} + rowClassName="editable-row" + pagination={false} + onRow={(record, index) => ({ + index, + moveRow: this.moveRow, + })} + /> + </DndProvider> </div> </EditableContext.Provider> ) diff --git a/src/templates/zshare/editTable/index.scss b/src/templates/zshare/editTable/index.scss index f51b1ff..4d73446 100644 --- a/src/templates/zshare/editTable/index.scss +++ b/src/templates/zshare/editTable/index.scss @@ -14,7 +14,10 @@ width: 100%; } > td { - padding: 16px 10px; + padding: 14px 10px; + } + > td:last-child { + padding: 0px; } } @@ -27,6 +30,8 @@ span { margin-right: 10px; cursor: pointer; + font-size: 16px; + padding: 5px; } .primary { color: #1890ff; @@ -54,3 +59,16 @@ margin: 0; } } +.modal-edit-table.editing { + .editable-row { + cursor: default!important; + } +} +.modal-edit-table:not(.editing) { + tr.drop-over-downward td { + border-bottom: 2px dashed #1890ff; + } + tr.drop-over-upward td { + border-top: 2px dashed #1890ff; + } +} diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index 7495890..de7308c 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -106,6 +106,8 @@ // 鏁版嵁鏉冮檺 param.LText = param.LText.replace(/@\$|\$@/ig, '') + console.info(`/* sql 楠岃瘉 */\n${param.LText.replace(/\n\s{6,20}/ig, '\n')}`) + param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index b067018..758fcd7 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -60,7 +60,7 @@ { title: '鎶ラ敊缂栫爜', dataIndex: 'errorCode', - width: '12%', + width: '13%', editable: true, inputType: 'select', options: [ @@ -73,7 +73,7 @@ { title: '楠岃瘉绫诲瀷', dataIndex: 'verifyType', - width: '13%', + width: '14%', render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉', inputType: 'select', editable: true, @@ -85,7 +85,7 @@ { title: '鏄惁鍚敤', dataIndex: 'status', - width: '13%', + width: '14%', editable: true, required: false, inputType: 'switch', -- Gitblit v1.8.0