From fe21d23b147ed5cec22b4f76a88840b05495d4ad Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 18 六月 2022 22:33:59 +0800 Subject: [PATCH] 2022-06-18 --- src/menu/components/form/formaction/formconfig.jsx | 2 src/tabviews/custom/components/card/cardcellList/index.jsx | 3 src/menu/datasource/verifycard/index.scss | 103 ++++++++ src/templates/modalconfig/settingform/index.jsx | 14 src/templates/zshare/formconfig.jsx | 2 src/menu/components/share/actioncomponent/formconfig.jsx | 2 src/tabviews/zshare/normalTable/index.jsx | 28 - src/templates/sharecomponent/actioncomponent/actionform/index.jsx | 18 + src/menu/components/form/formaction/actionform/index.jsx | 19 + src/templates/zshare/verifycard/index.jsx | 1 src/menu/components/share/sourcecomponent/index.jsx | 14 + src/menu/datasource/verifycard/customscript/index.jsx | 4 src/templates/zshare/verifycard/customscript/index.jsx | 12 src/tabviews/zshare/actionList/printbutton/index.jsx | 16 public/options.json | 10 src/templates/sharecomponent/settingcomponent/settingform/index.scss | 104 ++++++++ src/menu/components/card/cardcellcomponent/dragaction/card.jsx | 5 src/menu/components/card/cardcellcomponent/formconfig.jsx | 2 src/menu/components/share/actioncomponent/actionform/index.jsx | 20 + src/templates/sharecomponent/settingcomponent/settingform/index.jsx | 135 +++++++++++ src/menu/components/share/sourcecomponent/index.scss | 21 + src/tabviews/zshare/actionList/normalbutton/index.jsx | 3 src/menu/datasource/verifycard/index.jsx | 123 +++++++++ src/utils/utils.js | 10 24 files changed, 613 insertions(+), 58 deletions(-) diff --git a/public/options.json b/public/options.json index 98972d1..2b6d9b6 100644 --- a/public/options.json +++ b/public/options.json @@ -1,12 +1,12 @@ { - "appId": "202108312122504607B107A83F55B40C98CCF", - "appkey": "20210831212235413F287EC3BF489424496C8", + "appId": "201912040924165801464FF1788654BC5AC73", + "appkey": "20191106103859640976D6E924E464D029CF0", "mainSystemApi": "http://sso.mk9h.cn/cloud/webapi/dostars", "systemType": "", "externalDatabase": "false", "lineColor": "", "filter": "false", - "defaultApp": "mkindustry", + "defaultApp": "mk", "defaultLang": "zh-CN", "WXAppID": "", "debugger": false, @@ -14,6 +14,6 @@ "probation": "", "keepPassword": "true", "platforms": ["H5", "wechat", "android", "ios"], - "host": "http://demo.mk9h.cn", - "service": "erp_new/" + "host": "http://qingqiumarket.cn", + "service": "MKWMS/" } \ No newline at end of file diff --git a/src/menu/components/card/cardcellcomponent/dragaction/card.jsx b/src/menu/components/card/cardcellcomponent/dragaction/card.jsx index 61b0c90..bc181b0 100644 --- a/src/menu/components/card/cardcellcomponent/dragaction/card.jsx +++ b/src/menu/components/card/cardcellcomponent/dragaction/card.jsx @@ -107,9 +107,10 @@ // ) } else if (card.eleType === 'picture') { let _imagestyle = {} + let url = card.url !== '@icon@' ? card.url : sessionStorage.getItem('CloudAvatar') - if (card.url) { - _imagestyle = {backgroundImage: `url('${card.url}')`} + if (url) { + _imagestyle = {backgroundImage: `url('${url}')`} } else { let index = card.uuid.match(/\d{1}/g) index = index.slice(-1)[0] % 5 diff --git a/src/menu/components/card/cardcellcomponent/formconfig.jsx b/src/menu/components/card/cardcellcomponent/formconfig.jsx index 2ba2123..ea3a280 100644 --- a/src/menu/components/card/cardcellcomponent/formconfig.jsx +++ b/src/menu/components/card/cardcellcomponent/formconfig.jsx @@ -90,7 +90,7 @@ min: 0, label: '鍐呭', initVal: card.value || '', - tooltip: '鏂囨湰绫诲瀷锛屼細鏇挎崲鍐呭涓殑@username@銆丂fullName@銆丂login_city@銆�', + tooltip: '鏂囨湰绫诲瀷锛屼細鏇挎崲鍐呭涓殑@username@銆丂fullName@銆丂login_city@銆丂appname@銆�', required: true }, { diff --git a/src/menu/components/form/formaction/actionform/index.jsx b/src/menu/components/form/formaction/actionform/index.jsx index 3dc6914..e0a8cdd 100644 --- a/src/menu/components/form/formaction/actionform/index.jsx +++ b/src/menu/components/form/formaction/actionform/index.jsx @@ -160,6 +160,7 @@ getFields() { const { getFieldDecorator } = this.props.form + const { interType } = this.state const fields = [] this.state.formlist.forEach((item, index) => { @@ -185,6 +186,24 @@ max: formRule.func.max, message: formRule.func.maxMessage }] + } else if (item.key === 'output') { + if (interType === 'system') { + _rules = [{ + pattern: /^@[0-9a-zA-Z_]*$/, + message: '鍙橀噺浠绗﹀紑澶达紝鍙娇鐢ㄥ瓧姣嶃�佹暟瀛椾互鍙奯' + }, { + max: 100, + message: '鏈�澶�100涓瓧绗︺��' + }] + } else { + _rules = [{ + pattern: /^[0-9a-zA-Z_]*$/, + message: '瀛楁鍙娇鐢ㄥ瓧姣嶃�佹暟瀛椾互鍙奯' + }, { + max: 100, + message: '鏈�澶�100涓瓧绗︺��' + }] + } } else { _rules = [{ max: formRule.input.max, diff --git a/src/menu/components/form/formaction/formconfig.jsx b/src/menu/components/form/formaction/formconfig.jsx index 4fbab1a..e406576 100644 --- a/src/menu/components/form/formaction/formconfig.jsx +++ b/src/menu/components/form/formaction/formconfig.jsx @@ -287,7 +287,7 @@ type: 'text', key: 'output', label: '杩斿洖鍊�', - tooltip: '鎵ц鎴愬姛鍚庣殑杩斿洖鍊笺�備緥濡傦細@id', + tooltip: '鎵ц鎴愬姛鍚庣殑杩斿洖鍊笺�傜郴缁熷嚱鏁板彲鎸囧畾杩斿洖鐨勫彉閲忥紙浠绗﹀紑澶达紝濡侤id锛夛紱鑷畾涔夊嚱鏁板彲鎸囧畾杩斿洖瀛楁锛堝id锛夈��', initVal: card.output || '', required: false }, diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index f654b14..4dfb893 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -681,6 +681,24 @@ { pattern: formRule.func.pattern, message: formRule.func.message }, { max: formRule.func.max, message: formRule.func.maxMessage } ) + } else if (item.key === 'output') { + if (this.record.intertype === 'system') { + rules = [{ + pattern: /^@[0-9a-zA-Z_]*$/, + message: '鍙橀噺浠绗﹀紑澶达紝鍙娇鐢ㄥ瓧姣嶃�佹暟瀛椾互鍙奯' + }, { + max: 100, + message: '鏈�澶�100涓瓧绗︺��' + }] + } else { + rules = [{ + pattern: /^[0-9a-zA-Z_]*$/, + message: '瀛楁鍙娇鐢ㄥ瓧姣嶃�佹暟瀛椾互鍙奯' + }, { + max: 100, + message: '鏈�澶�100涓瓧绗︺��' + }] + } } else { rules.push({ max: formRule.input.max, message: formRule.input.message }) } @@ -768,7 +786,7 @@ fields.push( <Col span={span} key={index}> - <Form.Item className={className} help={item.help || null} label={item.tooltip ? + <Form.Item className={className} help={item.help} label={item.tooltip ? <Tooltip placement="topLeft" title={item.tooltip}> <QuestionCircleOutlined className="mk-form-tip" /> {item.label} diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index 6c9251e..324781d 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -706,7 +706,7 @@ type: 'text', key: 'output', label: '杩斿洖鍊�', - tooltip: '鎵ц鎴愬姛鍚庣殑杩斿洖鍊笺�備緥濡傦細@id', + tooltip: '鎵ц鎴愬姛鍚庣殑杩斿洖鍊笺�傜郴缁熷嚱鏁板彲鎸囧畾杩斿洖鐨勫彉閲忥紙浠绗﹀紑澶达紝濡侤id锛夛紱鑷畾涔夊嚱鏁板彲鎸囧畾杩斿洖瀛楁锛堝id锛夈��', initVal: card.output || '', required: false, forbid: viewType === 'popview' diff --git a/src/menu/components/share/sourcecomponent/index.jsx b/src/menu/components/share/sourcecomponent/index.jsx index 012c84e..e6657c0 100644 --- a/src/menu/components/share/sourcecomponent/index.jsx +++ b/src/menu/components/share/sourcecomponent/index.jsx @@ -61,6 +61,7 @@ const { url, visible } = this.state const { type } = this.props let name = url ? url.slice(url.lastIndexOf('/') + 1) : '' + // url !== '@icon@' return ( <div className="mk-source-wrap"> @@ -69,11 +70,20 @@ <Radio.Button value="upload" size="small" onClick={() => this.handleChange('upload')}>涓婁紶</Radio.Button> <Radio.Button value="system" size="small" onClick={() => this.handleChange('system')}>绯荤粺</Radio.Button> </Radio.Group> : null} - {url ? <div className={'mk-source-item-info' + (type !== 'video' ? ' picture' : '')}> - {type === 'video' ? <PaperClipOutlined /> : <img src={url} alt="" />} + {url && type === 'video' ? <div className="mk-source-item-info"> + <PaperClipOutlined /> <a target="_blank" rel="noopener noreferrer" href={url}>{name}</a> <DeleteOutlined title="鍒犻櫎鏂囦欢" onClick={this.deleteUrl}/> </div> : null} + {url && type !== 'video' && url !== '@icon@' ? <div className="mk-source-item-info picture"> + <img src={url} alt="" /> + <a target="_blank" rel="noopener noreferrer" href={url}>{name}</a> + <DeleteOutlined title="鍒犻櫎鏂囦欢" onClick={this.deleteUrl}/> + </div> : null} + {url && type !== 'video' && url === '@icon@' ? <div className="mk-source-item-info avatar"> + <span className="mk-avatar">{name}</span> + <DeleteOutlined title="鍒犻櫎鏂囦欢" onClick={this.deleteUrl}/> + </div> : null} <Modal visible={!!visible} width={visible !== 'system' ? 600 : 1000} diff --git a/src/menu/components/share/sourcecomponent/index.scss b/src/menu/components/share/sourcecomponent/index.scss index ecf2c09..2c5ffe1 100644 --- a/src/menu/components/share/sourcecomponent/index.scss +++ b/src/menu/components/share/sourcecomponent/index.scss @@ -14,7 +14,7 @@ top: 3px; right: 0px; padding-right: 6px; - color: rgba(0,0,0,.45); + color: #f5222d; cursor: pointer; display: none; } @@ -27,6 +27,18 @@ white-space: nowrap; text-overflow: ellipsis; } + .mk-avatar { + color: #1890ff; + display: inline-block; + width: 100%; + padding-left: 5px; + padding-right: 14px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + height: 32px; + line-height: 32px; + } } .mk-source-item-info.picture { display: flex; @@ -42,6 +54,13 @@ top: 8px; } } + .mk-source-item-info.avatar { + display: flex; + top: 0px; + .anticon-delete { + top: 8px; + } + } .mk-source-item-info:hover { background-color: #e6f7ff; .anticon-delete { diff --git a/src/menu/datasource/verifycard/customscript/index.jsx b/src/menu/datasource/verifycard/customscript/index.jsx index 2b009a3..071c5c7 100644 --- a/src/menu/datasource/verifycard/customscript/index.jsx +++ b/src/menu/datasource/verifycard/customscript/index.jsx @@ -169,7 +169,9 @@ selectScript = (value, option) => { let _sql = this.props.form.getFieldValue('sql') - if (_sql) { + if (_sql === ' ') { + _sql = '' + } else if (_sql) { _sql = _sql + ` ` diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index 51338af..656728e 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -1,8 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Tabs, Popconfirm, notification, Modal, Typography, Spin, message } from 'antd' -import { StopOutlined, CheckCircleOutlined, EditOutlined, SwapOutlined, DeleteOutlined, CopyOutlined } from '@ant-design/icons' +import { Form, Tabs, Popconfirm, notification, Modal, Typography, Spin, message, Button } from 'antd' +import { StopOutlined, CheckCircleOutlined, EditOutlined, SwapOutlined, DeleteOutlined, CopyOutlined, BorderOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' @@ -13,11 +13,13 @@ import CustomScriptsForm from './customscript' import SettingForm from './settingform' import SettingUtils from './utils' +import MinView from '@/assets/img/minview.png' import './index.scss' const { TabPane } = Tabs const { Paragraph } = Typography +const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror')) const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) @@ -36,6 +38,9 @@ defaultsql: '', // 榛樿Sql defaultSearch: '', systemScripts: [], + visible: false, + script: null, + scriptValue: '', colColumns: [ { title: '鍚嶇О', @@ -257,7 +262,13 @@ } deleteScript = (record) => { - this.setState({ scripts: this.state.scripts.filter(item => item.uuid !== record.uuid) }) + const { script, scripts } = this.state + + if (script && script.uuid === record.uuid) { + this.setState({script: null}) + } + + this.setState({ scripts: scripts.filter(item => item.uuid !== record.uuid) }) } handleEdit = (record) => { @@ -633,6 +644,42 @@ } } + triggerConfirm = () => { + const { script, scriptValue, scripts } = this.state + let _scripts = fromJS(scripts).toJS() + + if (!scriptValue) { + notification.warning({ + top: 92, + message: '璇疯緭鍏ql!', + duration: 5 + }) + return + } + + if (script) { + _scripts = _scripts.map(item => { + if (script.uuid === item.uuid) { + item.sql = scriptValue + } + return item + }) + } else { + let _script = { + uuid: Utils.getuuid(), + sql: scriptValue, + $index: _scripts.length + 1, + status: 'true' + } + + _scripts.push(_script) + } + + this.setState({loading: true}) + + this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, false, _scripts) + } + updatefields = (columns) => { this.setState({ columns: columns @@ -671,7 +718,7 @@ render() { const { config } = this.props - const { columns, setting, scripts, colColumns, scriptsColumns, activeKey, loading, searches, defaultsql } = this.state + const { columns, setting, scripts, colColumns, scriptsColumns, activeKey, loading, searches, defaultsql, visible, script, scriptValue } = this.state return ( <div id="model-data-source-wrap"> @@ -703,6 +750,17 @@ {scripts.length ? <span className="count-tip">{scripts.length}</span> : null} </span> } key="scripts"> + <BorderOutlined className="full-scripts" onClick={() => { + if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) { + notification.warning({ + top: 92, + message: '璇蜂繚瀛樿嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + return + } + this.setState({visible: true, script: null, scriptValue: ''}) + }}/> <CustomScriptsForm setting={setting} searches={searches} @@ -718,6 +776,63 @@ <EditTable actions={['move']} data={scripts} columns={scriptsColumns} onChange={this.changeScripts}/> </TabPane> </Tabs> + <Modal + wrapClassName="model-custom-view-scripts-modal" + title="鑷畾涔夎剼鏈�" + visible={visible} + width={'95vw'} + maskClosable={false} + destroyOnClose + > + <img className="unfull-scripts" src={MinView} onClick={() => this.setState({visible: false, script: null})} alt=""/> + <div className="script-table-wrap"> + {scripts.map(item => { + let title = item.sql.match(/^\s*\/\*.+\*\//) + title = title && title[0] ? title[0] : '' + let _text = title ? item.sql.replace(title, '') : item.sql + + return ( + <div className={'script-item ' + (script && script.uuid === item.uuid ? 'active' : '') } key={item.uuid}> + <div style={{cursor: 'pointer'}} onClick={() => { + this.setState({script: item, scriptValue: item.sql}) + }}> + {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null} + <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph> + <div>{item.status === 'false' ? + <span style={{color: '#ff4d4f', marginLeft: '20px'}}> + 绂佺敤 + <StopOutlined style={{marginLeft: '5px'}} /> + </span> : + <span style={{color: '#26C281', marginLeft: '20px'}}> + 鍚敤 + <CheckCircleOutlined style={{marginLeft: '5px'}}/> + </span>} + </div> + </div> + <div style={{textAlign: 'right'}}> + <span className="operation-btn" onClick={() => this.handleStatus(item)} style={{color: '#8E44AD'}}><SwapOutlined /></span> + <Popconfirm + overlayClassName="popover-confirm" + title={this.props.dict['model.query.delete']} + onConfirm={() => this.deleteScript(item) + }> + <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> + </Popconfirm> + </div> + </div> + ) + })} + </div> + <div className="script-button"> + <Button onClick={this.triggerConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> + {script ? '淇濆瓨' : '娣诲姞'} + </Button> + <Button onClick={() => {this.setState({script: null, scriptValue: ''})}} style={{marginBottom: 15, marginLeft: 10}}> + 鍙栨秷 + </Button> + </div> + <CodeMirror value={scriptValue} onChange={(val) => {this.setState({scriptValue: val})}}></CodeMirror> + </Modal> </div> ) } diff --git a/src/menu/datasource/verifycard/index.scss b/src/menu/datasource/verifycard/index.scss index bef6747..adf5445 100644 --- a/src/menu/datasource/verifycard/index.scss +++ b/src/menu/datasource/verifycard/index.scss @@ -81,4 +81,107 @@ cursor: pointer; } } + .full-scripts { + position: absolute; + right: 0px; + top: -40px; + font-size: 18px; + color: #1890ff; + } +} +.model-custom-view-scripts-modal { + .ant-modal { + top: 30px; + .ant-modal-header { + padding: 10px 24px; + } + .ant-modal-footer { + display: none; + } + .ant-modal-close { + display: none; + } + .ant-modal-body { + padding: 0; + height: calc(100vh - 100px); + overflow: hidden; + display: flex; + + .script-table-wrap { + width: 240px; + overflow-y: auto; + overflow-x: hidden; + height: calc(100vh - 100px); + + .operation-btn { + display: inline-block; + font-size: 16px; + padding: 0 5px; + cursor: pointer; + margin-left: 5px; + } + + .script-item { + border-bottom: 1px solid #eeeeee; + padding: 15px 10px 5px; + } + .script-item.active { + background-color: #bae7ff; + } + .ant-typography { + margin-bottom: 5px; + } + } + + .script-table-wrap::-webkit-scrollbar { + width: 7px; + } + .script-table-wrap::-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); + } + .script-table-wrap::-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); + } + + .unfull-scripts { + position: absolute; + right: 20px; + z-index: 2; + top: 10px; + color: #1890ff; + width: 26px; + cursor: pointer; + padding: 5px; + } + + .script-button { + position: absolute; + top: 10px; + z-index: 1; + left: 240px; + .ant-btn { + height: 28px; + } + .mk-green { + margin-left: 0!important; + margin-right: 10px; + } + } + .code-mirror-wrap { + .CodeMirror { + height: calc(100vh - 100px); + border-radius: 0; + } + .code-mirror-area { + border-radius: 0; + width: calc(95vw - 240px); + } + } + } + } } \ No newline at end of file diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index fd968c0..ab7f92a 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -512,6 +512,9 @@ if (card.datatype === 'static') { url = card.url || '' + if (url === '@icon@') { + url = sessionStorage.getItem('avatar') || '' + } } else { url = data[card.field] || '' } diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index ed0bc66..296ae6e 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -1538,6 +1538,9 @@ if (btn.output) { id = res.mk_b_id || res[btn.output] || '' } + if (res.mk_icon) { + sessionStorage.setItem('avatar', res.mk_icon) + } let tabId = '' if (btn.refreshTab && btn.refreshTab.length > 0) { tabId = btn.refreshTab[btn.refreshTab.length - 1] diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index cf92e72..5d35f3c 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -320,9 +320,9 @@ // 绯荤粺鎵撳嵃鏁版嵁锛屾牎楠宒ata瀛楁 if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return - cell.templateID = baseTemp - cell.printType = baseType - cell.printCount = 0 + let templateID = baseTemp + let printType = baseType + let printCount = 0 Object.keys(cell).forEach(key => { if (!cell[key]) return @@ -330,14 +330,18 @@ let _key = key.toLowerCase() if (_key === 'templateid') { - cell.templateID = cell[key] + templateID = cell[key] } else if (_key === 'printtype') { - cell.printType = cell[key] + printType = cell[key] } else if (_key === 'printcount') { - cell.printCount = +cell[key] + printCount = +cell[key] } }) + cell.templateID = templateID + cell.printType = printType + cell.printCount = printCount + if (isNaN(cell.printCount) || cell.printCount < 1) { cell.printCount = baseCount } diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index 4bf5a88..6b497bd 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -401,40 +401,30 @@ let icon = '' marks.some(mark => { - let originVal = record[mark.field] + '' + let originVal = record[mark.field] let contrastVal = '' if (mark.contrastType === 'static') { - contrastVal = mark.contrastValue + '' + contrastVal = mark.contrastValue } else { - contrastVal = record[mark.contrastField] + '' + contrastVal = record[mark.contrastField] } + + if (originVal === undefined || contrastVal === undefined) return false if (mark.match === '=') { className = originVal === contrastVal ? mark.color[1] : '' } else if (mark.match === '!=') { className = originVal !== contrastVal ? mark.color[1] : '' } else if (mark.match === 'like') { + originVal = originVal + '' + contrastVal = contrastVal + '' className = originVal.indexOf(contrastVal) > -1 ? mark.color[1] : '' } else if (mark.match === '>') { - try { - originVal = parseFloat(originVal) - contrastVal = parseFloat(contrastVal) - } catch (e) { - originVal = NaN - } - - if (!isNaN(originVal) && !isNaN(contrastVal) && originVal > contrastVal) { + if (parseFloat(originVal) > parseFloat(contrastVal)) { className = mark.color[1] } } else if (mark.match === '<') { - try { - originVal = parseFloat(originVal) - contrastVal = parseFloat(contrastVal) - } catch (e) { - originVal = NaN - } - - if (!isNaN(originVal) && !isNaN(contrastVal) && originVal < contrastVal) { + if (parseFloat(originVal) < parseFloat(contrastVal)) { className = mark.color[1] } } diff --git a/src/templates/modalconfig/settingform/index.jsx b/src/templates/modalconfig/settingform/index.jsx index 2d6cc85..b29bbd6 100644 --- a/src/templates/modalconfig/settingform/index.jsx +++ b/src/templates/modalconfig/settingform/index.jsx @@ -44,6 +44,8 @@ let _display = display if (appType === 'mob' && display === 'modal') { _display = 'drawer' + } else if (appType !== 'mob' && display === 'dialog') { + _display = 'modal' } this.setState({ @@ -122,7 +124,7 @@ <Radio value="drawer">鎶藉眽</Radio> <Radio value="prompt">鏄惁妗�</Radio> <Radio value="exec">鐩存帴鎵ц</Radio> - {/* <Radio value="dialog" disabled={dialogInput !== true}>瀵硅瘽妗�</Radio> */} + {appType !== 'mob' ? null : <Radio value="dialog">寮圭獥</Radio>} </Radio.Group> )} </Form.Item> @@ -139,7 +141,7 @@ })(<InputNumber min={10} max={2000} precision={0} onPressEnter={this.handleSubmit}/>)} </Form.Item> </Col> : null} - {display === 'drawer' || display === 'modal' ? <Col span={12}> + {['dialog', 'drawer', 'modal'].includes(display) ? <Col span={12}> <Form.Item label="鍒濆鐒︾偣"> {getFieldDecorator('focus', { initialValue: config.setting.focus || '' @@ -158,7 +160,7 @@ )} </Form.Item> </Col> : null} - {display === 'drawer' || display === 'modal' ? <Col span={12}> + {['drawer', 'modal'].includes(display) ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title="鎵ц澶辫触鏃堕渶瑕佽仛鐒︾殑琛ㄥ崟銆�"> <QuestionCircleOutlined className="mk-form-tip" /> @@ -228,7 +230,7 @@ </Radio.Group>)} </Form.Item> </Col> : null} - {display === 'drawer' || display === 'modal' ? <Col span={12}> + {['drawer', 'modal'].includes(display) ? <Col span={12}> <Form.Item label="瀹屾垚鍚�"> {getFieldDecorator('finish', { initialValue: config.setting.finish || 'close' @@ -240,7 +242,7 @@ )} </Form.Item> </Col> : null} - {display === 'drawer' || display === 'modal' ? <Col span={12}> + {['dialog', 'drawer', 'modal'].includes(display) ? <Col span={12}> <Form.Item label={ <Tooltip placement="topLeft" title="闇�瑕侀�氳繃鏁版嵁婧愭煡璇㈢殑閫夐」锛屾槸鍚︿娇鐢ㄧ紦瀛樸��"> <QuestionCircleOutlined className="mk-form-tip" /> @@ -307,7 +309,7 @@ )} </Form.Item> </Col> : null} - {display === 'drawer' || display === 'modal' ? <Col span={12}> + {['dialog', 'drawer', 'modal'].includes(display) ? <Col span={12}> <Form.Item label="鐐瑰嚮钂欏眰"> {getFieldDecorator('clickouter', { initialValue: config.setting.clickouter || 'unclose' diff --git a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx index 201684b..d410970 100644 --- a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx @@ -523,6 +523,24 @@ { pattern: formRule.func.pattern, message: formRule.func.message }, { max: formRule.func.max, message: formRule.func.maxMessage } ) + } else if (item.key === 'output') { + if (this.record.intertype === 'system') { + rules = [{ + pattern: /^@[0-9a-zA-Z_]*$/, + message: '鍙橀噺浠绗﹀紑澶达紝鍙娇鐢ㄥ瓧姣嶃�佹暟瀛椾互鍙奯' + }, { + max: 100, + message: '鏈�澶�100涓瓧绗︺��' + }] + } else { + rules = [{ + pattern: /^[0-9a-zA-Z_]*$/, + message: '瀛楁鍙娇鐢ㄥ瓧姣嶃�佹暟瀛椾互鍙奯' + }, { + max: 100, + message: '鏈�澶�100涓瓧绗︺��' + }] + } } else { rules.push({ max: formRule.input.max, message: formRule.input.message }) } diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx index b60fc7f..c78bd0a 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx @@ -1,7 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, notification, Modal, Spin, Tabs } from 'antd' +import { Form, notification, Modal, Spin, Tabs, Typography, Popconfirm, Button } from 'antd' +import { CheckCircleOutlined, StopOutlined, SwapOutlined, DeleteOutlined, BorderOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' @@ -9,9 +10,12 @@ import SettingUtils from './utils.jsx' import asyncComponent from '@/utils/asyncComponent' import DataSource from './datasource' +import MinView from '@/assets/img/minview.png' import './index.scss' const { TabPane } = Tabs +const { Paragraph } = Typography +const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror')) const CustomScript = asyncComponent(() => import('@/templates/zshare/customscript')) const SimpleScript = asyncComponent(() => import('./simplescript')) @@ -33,6 +37,9 @@ regoptions: [], setting: null, defaultSql: '', + visible: false, + script: null, + scriptValue: '', status: {} } @@ -478,6 +485,42 @@ }) } + triggerConfirm = () => { + const { script, scriptValue, scripts } = this.state + let _scripts = fromJS(scripts).toJS() + + if (!scriptValue) { + notification.warning({ + top: 92, + message: '璇疯緭鍏ql!', + duration: 5 + }) + return + } + + if (script) { + _scripts = _scripts.map(item => { + if (script.uuid === item.uuid) { + item.sql = scriptValue + } + return item + }) + } else { + let _script = { + uuid: Utils.getuuid(), + sql: scriptValue, + $index: _scripts.length + 1, + status: 'true' + } + + _scripts.push(_script) + } + + this.setState({loading: true}) + + this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, 'verify', _scripts) + } + // 鑷畾涔夎剼鏈洿鏂� scriptsUpdate = (scripts) => { this.setState({scripts}) @@ -493,6 +536,26 @@ this.setState({cbScripts}) } + handleDelete = (item) => { + const { script, scripts } = this.state + + if (script && script.uuid === item.uuid) { + this.setState({script: null}) + } + this.setState({scripts: scripts.filter(cell => cell.uuid !== item.uuid)}) + } + + handleStatus = (item) => { + item.status = item.status === 'false' ? 'true' : 'false' + + this.setState({scripts: this.state.scripts.map(cell => { + if (cell.uuid === item.uuid) { + return item + } + return cell + })}) + } + updateStatus = (status) => { let _status = {...this.state.status, ...status} this.setState({status: _status}) @@ -501,7 +564,7 @@ render() { const { config, menu, dict } = this.props - const { loading, activeKey, setting, defaultSql, columns, scripts, preScripts, cbScripts, status, regoptions } = this.state + const { loading, activeKey, setting, defaultSql, columns, scripts, preScripts, cbScripts, status, regoptions, visible, script, scriptValue } = this.state return ( <div className="model-table-setting-form-box" id="model-setting-form-body"> @@ -525,6 +588,17 @@ {scripts.length ? <span className="count-tip">{scripts.length}</span> : null} </span> } disabled={!(status.interType === 'system' || (status.interType === 'custom' && status.requestMode === 'system'))} key="scripts"> + <BorderOutlined className="full-scripts" onClick={() => { + if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) { + notification.warning({ + top: 92, + message: '璇蜂繚瀛樿嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + return + } + this.setState({visible: true, script: null, scriptValue: ''}) + }}/> <CustomScript dict={dict} setting={setting} @@ -569,6 +643,63 @@ /> </TabPane> </Tabs> + <Modal + wrapClassName="model-custom-table-scripts-modal" + title="鑷畾涔夎剼鏈�" + visible={visible} + width={'95vw'} + maskClosable={false} + destroyOnClose + > + <img className="unfull-scripts" src={MinView} onClick={() => this.setState({visible: false, script: null})} alt=""/> + <div className="script-table-wrap"> + {scripts.map(item => { + let title = item.sql.match(/^\s*\/\*.+\*\//) + title = title && title[0] ? title[0] : '' + let _text = title ? item.sql.replace(title, '') : item.sql + + return ( + <div className={'script-item ' + (script && script.uuid === item.uuid ? 'active' : '') } key={item.uuid}> + <div style={{cursor: 'pointer'}} onClick={() => { + this.setState({script: item, scriptValue: item.sql}) + }}> + {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null} + <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph> + <div>{item.status === 'false' ? + <span style={{color: '#ff4d4f', marginLeft: '20px'}}> + 绂佺敤 + <StopOutlined style={{marginLeft: '5px'}} /> + </span> : + <span style={{color: '#26C281', marginLeft: '20px'}}> + 鍚敤 + <CheckCircleOutlined style={{marginLeft: '5px'}}/> + </span>} + </div> + </div> + <div style={{textAlign: 'right'}}> + <span className="operation-btn" onClick={() => this.handleStatus(item)} style={{color: '#8E44AD'}}><SwapOutlined /></span> + <Popconfirm + overlayClassName="popover-confirm" + title={this.props.dict['model.query.delete']} + onConfirm={() => this.handleDelete(item) + }> + <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> + </Popconfirm> + </div> + </div> + ) + })} + </div> + <div className="script-button"> + <Button onClick={this.triggerConfirm} loading={loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> + {script ? '淇濆瓨' : '娣诲姞'} + </Button> + <Button onClick={() => {this.setState({script: null, scriptValue: ''})}} style={{marginBottom: 15, marginLeft: 10}}> + 鍙栨秷 + </Button> + </div> + <CodeMirror value={scriptValue} onChange={(val) => {this.setState({scriptValue: val})}}></CodeMirror> + </Modal> </div> ) } diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.scss b/src/templates/sharecomponent/settingcomponent/settingform/index.scss index 2166d9b..516889d 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.scss +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.scss @@ -58,4 +58,108 @@ .ant-tabs-nav-wrap { text-align: center; } + .full-scripts { + position: absolute; + right: 0px; + top: 18px; + font-size: 18px; + color: #1890ff; + } +} + +.model-custom-table-scripts-modal { + .ant-modal { + top: 30px; + .ant-modal-header { + padding: 10px 24px; + } + .ant-modal-footer { + display: none; + } + .ant-modal-close { + display: none; + } + .ant-modal-body { + padding: 0; + height: calc(100vh - 100px); + overflow: hidden; + display: flex; + + .script-table-wrap { + width: 240px; + overflow-y: auto; + overflow-x: hidden; + height: calc(100vh - 100px); + + .operation-btn { + display: inline-block; + font-size: 16px; + padding: 0 5px; + cursor: pointer; + margin-left: 5px; + } + + .script-item { + border-bottom: 1px solid #eeeeee; + padding: 15px 10px 5px; + } + .script-item.active { + background-color: #bae7ff; + } + .ant-typography { + margin-bottom: 5px; + } + } + + .script-table-wrap::-webkit-scrollbar { + width: 7px; + } + .script-table-wrap::-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); + } + .script-table-wrap::-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); + } + + .unfull-scripts { + position: absolute; + right: 20px; + z-index: 2; + top: 10px; + color: #1890ff; + width: 26px; + cursor: pointer; + padding: 5px; + } + + .script-button { + position: absolute; + top: 10px; + z-index: 1; + left: 240px; + .ant-btn { + height: 28px; + } + .mk-green { + margin-left: 0!important; + margin-right: 10px; + } + } + .code-mirror-wrap { + .CodeMirror { + height: calc(100vh - 100px); + border-radius: 0; + } + .code-mirror-area { + border-radius: 0; + width: calc(95vw - 240px); + } + } + } + } } \ No newline at end of file diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 62974bd..8574f2e 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -1324,7 +1324,7 @@ type: 'text', key: 'output', label: '杩斿洖鍊�', - tooltip: '鎵ц鎴愬姛鍚庣殑杩斿洖鍊笺�備緥濡傦細@id', + tooltip: '鎵ц鎴愬姛鍚庣殑杩斿洖鍊笺�傜郴缁熷嚱鏁板彲鎸囧畾杩斿洖鐨勫彉閲忥紙浠绗﹀紑澶达紝濡侤id锛夛紱鑷畾涔夊嚱鏁板彲鎸囧畾杩斿洖瀛楁锛堝id锛夈��', initVal: card.output || '', required: false }, diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index ccd9907..257064a 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -45,9 +45,18 @@ } handleConfirm = () => { + const { type } = this.props const { editItem } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { + if (type === 'fullscreen' && err) { + notification.warning({ + top: 92, + message: '璇疯緭鍏ql!', + duration: 5 + }) + return + } if (!err) { values.uuid = editItem ? editItem.uuid : '' values.position = values.position || (editItem ? editItem.position : 'front') @@ -231,6 +240,7 @@ render() { const { usefulfields, systemScripts, btn, type } = this.props const { getFieldDecorator } = this.props.form + const { editItem } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -300,7 +310,7 @@ </Col> : null} <Col span={6} className="add"> <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> - 淇濆瓨 + {_type === 'fullscreen' && !editItem ? '娣诲姞' : '淇濆瓨'} </Button> <Button onClick={this.handleCancel} style={{marginBottom: 15, marginLeft: 10}}> 鍙栨秷 diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index 92034c5..ba04881 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -1695,7 +1695,6 @@ {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} </span> } key="6"> - <BorderOutlined className="full-scripts" onClick={() => { if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) { notification.warning({ diff --git a/src/utils/utils.js b/src/utils/utils.js index e021fe6..1f78e17 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -2072,21 +2072,25 @@ style = JSON.parse(JSON.stringify(style)) marks.some(mark => { - let originVal = record[mark.field[0]] + '' + let originVal = record[mark.field[0]] let contrastVal = '' let result = false if (mark.field[1] === 'static') { - contrastVal = mark.contrastValue + '' + contrastVal = mark.contrastValue } else { - contrastVal = record[mark.field[2]] + '' + contrastVal = record[mark.field[2]] } + + if (originVal === undefined || contrastVal === undefined) return false if (mark.match === '=') { result = originVal === contrastVal } else if (mark.match === '!=') { result = originVal !== contrastVal } else if (mark.match === 'like') { + originVal = originVal + '' + contrastVal = contrastVal + '' result = originVal.indexOf(contrastVal) > -1 } else if (mark.match === '>') { result = parseFloat(originVal) > parseFloat(contrastVal) -- Gitblit v1.8.0