From e8edfdadb561cd83bf6e1c3e00d55b8cc2aee6d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 17 十月 2022 17:57:34 +0800 Subject: [PATCH] 2022-10-17 --- src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx | 106 +++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 74 insertions(+), 32 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx index e94f798..936a558 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx @@ -22,7 +22,6 @@ class VerifyCard extends Component { static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� config: PropTypes.object, card: PropTypes.object, } @@ -34,46 +33,50 @@ defaultscript: '', // 鑷畾涔夎剼鏈� excelColumns: [ { - title: this.props.dict['model.form.field'], + title: '瀛楁', dataIndex: 'Column', inputType: 'input', editable: true, unique: true, - width: '20%' + width: '17%' }, { - title: this.props.dict['model.name'], + title: '鍚嶇О', dataIndex: 'Text', inputType: 'input', editable: true, - width: '20%' + unique: true, + width: '17%' }, { - title: this.props.dict['model.form.columnWidth'], + title: '鍒楀', dataIndex: 'Width', inputType: 'number', min: 5, max: 200, editable: true, - width: '14%', + width: '12%', render: (text) => text || 20 }, { title: '绫诲瀷', dataIndex: 'type', - inputType: 'radio', + inputType: 'select', editable: true, required: false, - width: '18%', + width: '14%', render: (text) => { if (text === 'image') { return '鍥剧墖' + } else if (text === 'number') { + return '鏁板��' } else { return '鏂囨湰' } }, options: [ {value: 'text', text: '鏂囨湰'}, + {value: 'number', text: '鏁板��'}, {value: 'image', text: '鍥剧墖'} ] }, @@ -95,6 +98,16 @@ {value: 'true', text: '鏄�'}, {value: 'false', text: '鍚�'} ] + }, + { + title: '灏忔暟浣�', + dataIndex: 'decimal', + inputType: 'number', + min: 0, + max: 18, + editable: true, + required: false, + width: '12%' }, { title: '瀵煎嚭', @@ -155,13 +168,13 @@ render: (text, record) => record.status === 'false' ? ( <div style={{color: '#ff4d4f'}}> - {this.props.dict['model.status.forbidden']} + 绂佺敤 <StopOutlined style={{marginLeft: '5px'}} /> </div> ) : ( <div style={{color: '#26C281'}}> - {this.props.dict['model.status.open']} + 鍚敤 <CheckCircleOutlined style={{marginLeft: '5px'}}/> </div> ) @@ -173,11 +186,11 @@ dataIndex: 'operation', render: (text, record) => (<div style={{textAlign: 'center'}}> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span> + <span className="operation-btn" title="缂栬緫" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span> + <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span> <Popconfirm overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} + title="纭畾鍒犻櫎鍚�?" onConfirm={() => this.handleDelete(record, 'scripts') }> <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> @@ -280,6 +293,17 @@ } componentDidMount () { + this.getsysScript() + } + + getsysScript = () => { + if (sessionStorage.getItem('mk_sys_scripts')) { + this.setState({ + systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts')) + }) + return + } + let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` _scriptSql = Utils.formatOptions(_scriptSql) @@ -293,18 +317,21 @@ _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) - _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 Api.getSystemConfig(_sParam).then(res => { if (res.status) { + let _scripts = res.data.map(item => { + return { + name: item.funcname, + value: window.decodeURIComponent(window.atob(item.longparam)) + } + }) + + sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts)) + this.setState({ - systemScripts: res.data.map(item => { - return { - name: item.funcname, - value: window.decodeURIComponent(window.atob(item.longparam)) - } - }) + systemScripts: _scripts }) } else { notification.warning({ @@ -317,11 +344,13 @@ } handleEdit = (record, type) => { + let node = null + if (type === 'scripts') { this.scriptsForm.edit(record) + node = document.getElementById('mk-exout-script') } - let node = document.getElementById('verify-excelout-box-tab').parentNode if (node && node.scrollTop) { let inter = Math.ceil(node.scrollTop / 10) @@ -657,7 +686,7 @@ this.setState({ loading: true }) - Api.getLocalConfig(param).then(res => { + Api.genericInterface(param).then(res => { this.setState({ loading: false }) @@ -703,7 +732,7 @@ if (fields.includes(item.field) || !item.field) return fields.push(item.field) - columns.push({ + let cell = { Column: item.field, Text: item.label, Width: 20, @@ -711,7 +740,14 @@ output: 'true', type: 'text', uuid: Utils.getuuid() - }) + } + + if (item.type === 'number') { + cell.type = 'number' + cell.decimal = item.decimal + } + + columns.push(cell) }) this.setState({ @@ -740,7 +776,7 @@ changeColumns = (columns) => { const { verify } = this.state - if (columns[0] && (columns[0].type !== 'image' && columns[0].type !== 'text')) { + if (columns[0] && (columns[0].type !== 'image' && columns[0].type !== 'text' && columns[0].type !== 'number')) { columns = columns.map(col => { let _cell = { uuid: Utils.getuuid(), @@ -877,6 +913,11 @@ sqlverify = (_resolve, _reject, scripts) => { const { searches, verify } = this.state + if (verify.dataType !== 'custom') { + _resolve() + return + } + let timestamp = moment().format('YYYY-MM-DD HH:mm:ss') let sql = SettingUtils.getDebugSql(verify, scripts, searches, Utils, timestamp) let param = { @@ -888,7 +929,7 @@ param.timestamp = timestamp param.secretkey = Utils.encrypt('', timestamp) - Api.getLocalConfig(param).then(result => { + Api.genericInterface(param).then(result => { if (result.status) { _resolve() } else { @@ -920,7 +961,8 @@ } return ( - <div id="verify-excelout-box-tab"> + <div className="verify-excelout-box-tab"> + {card.label ? <div className="mk-com-name">{card.label} - 楠岃瘉淇℃伅</div> : null} {loading && <Spin size="large" />} <Tabs activeKey={activeKey} className="excelout-verify-card-box" onChange={this.tabchange}> {card.intertype === 'system' ? <TabPane tab="鍩虹楠岃瘉" key="setting"> @@ -932,14 +974,14 @@ {verify.columns.length ? <span className="count-tip">{verify.columns.length}</span> : null} </span> } key="columns"> - <ColumnForm dict={this.props.dict} columnChange={this.columnChange}/> + <ColumnForm columnChange={this.columnChange}/> <Button className="excel-col-add mk-green" title="娣诲姞鏄剧ず鍒楀瓧娈�" onClick={this.columnFieldInput}> 鍚屾鏄剧ず鍒� </Button> <Button className="excel-col-add mk-red" title="娓呯┖Excel鍒�" onClick={this.clearField}> 娓呯┖Excel鍒� </Button> - <div style={{color: '#959595', fontSize: '13px', paddingLeft: '10px'}}>濡傞渶瀵煎嚭搴忓彿锛岃浣跨敤瀛楁 $Index銆�</div> + <div style={{color: '#959595', fontSize: '13px', paddingLeft: '10px'}}>濡傞渶瀵煎嚭搴忓彿锛岃浣跨敤瀛楁 $Index锛涙暟鍊肩被鍨嬪鍑烘椂鍙繘琛屾暟鎹鐞嗭紙鍙栫粷瀵瑰�笺�佷繚鐣欏皬鏁颁綅锛夈��</div> <EditTable actions={['edit', 'move', 'copy', 'del']} type="excelcolumn" wrappedComponentRef={(inst) => this.columnRef = inst} data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> </TabPane> {card.intertype === 'system' ? <TabPane tab={ @@ -947,7 +989,7 @@ 鑷畾涔夎剼鏈� {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} </span> - } key="scripts" disabled={verify.dataType !== 'custom'}> + } key="scripts" disabled={verify.dataType !== 'custom'} id="mk-exout-script"> <CustomScript btn={card} sheet={verify.tableName} @@ -983,7 +1025,7 @@ rules: [ { required: true, - message: this.props.dict['form.required.input'] + 'sql!' + message: '璇疯緭鍏ql!' } ] })(<CodeMirror />)} -- Gitblit v1.8.0