From 49f09cc6f8ff8c30a75ed1a9d6f510b69b73962a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 12 十二月 2023 21:05:37 +0800 Subject: [PATCH] 2023-12-12 --- src/menu/versions/index.jsx | 190 ++++++++++++++++++++++++++++++----------------- 1 files changed, 121 insertions(+), 69 deletions(-) diff --git a/src/menu/versions/index.jsx b/src/menu/versions/index.jsx index 7f584ae..373365e 100644 --- a/src/menu/versions/index.jsx +++ b/src/menu/versions/index.jsx @@ -1,8 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Modal, Button, notification } from 'antd' -import { QuestionCircleOutlined, CalendarOutlined } from '@ant-design/icons' +import { Modal, Button, notification, Table, Spin } from 'antd' +import { CalendarOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' @@ -12,16 +12,30 @@ class Versions extends Component { static propTpyes = { MenuId: PropTypes.string, - open_edition: PropTypes.string, + Template: PropTypes.string, + checklog: PropTypes.func, updateConfig: PropTypes.func } state = { visible: false, - loadingTable: false, - preconfirming: false, - nextconfirming: false, - tables: [], + loading: false, + logs: [], + columns: [ + { title: '淇敼鏃堕棿', dataIndex: 'createdate', key: 'createdate', align: 'center' }, + { title: '淇敼浜�', dataIndex: 'fullname', key: 'fullname', align: 'center' }, + { + title: '鎿嶄綔', + key: 'action', + align: 'center', + width: '230px', + render: (text, record) => ( + <div> + <Button type="link" onClick={() => this.change(record)} style={{color: '#1890ff'}}>鍒囨崲</Button> + </div> + ), + }, + ] } shouldComponentUpdate (nextProps, nextState) { @@ -29,124 +43,162 @@ } trigger = () => { - this.setState({visible: true}) - } - - preVersion = () => { - const { MenuId, open_edition, updateConfig } = this.props - let param = { - func: 's_spages_Param_ctrlzy', - ctrlzy: 'z', - MenuID: MenuId, + func: 's_get_spages_param_log', + MenuID: this.props.MenuId, TypeCharOne: sessionStorage.getItem('kei_no') || '', TypeName: sessionStorage.getItem('typename') || '', lang: sessionStorage.getItem('lang'), timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), - open_edition: open_edition, - LText: MenuId + window.GLOB.appkey + LText: this.props.MenuId + window.GLOB.appkey } param.secretkey = Utils.encrypt(param.LText, param.timestamp) - this.setState({preconfirming: true}) + this.setState({loading: true, visible: true, logs: []}) Api.getCloudConfig(param).then(res => { - this.setState({preconfirming: false}) + this.setState({loading: false}) + if (!res.status) { notification.warning({ top: 92, message: res.message, duration: 5 }) - } else { - this.setState({visible: false}) - notification.success({ - top: 92, - message: '鎵ц鎴愬姛銆�', - duration: 1 + return + } else if (!res.data || res.data.length === 0) { + Modal.warning({ + title: '褰撳墠鑿滃崟鏃犲巻鍙茬増鏈��', + okText: '鐭ラ亾浜�' }) - - if (updateConfig) { - updateConfig() - } else { - setTimeout(() => { - window.location.reload() - }, 1000) - } + return } + + this.setState({logs: res.data}) }) } - nextVersion = () => { - const { MenuId, open_edition, updateConfig } = this.props + change = (record) => { + const { checklog } = this.props + + if (checklog()) { + this.getpage(record) + } else { + const that = this + + Modal.confirm({ + title: '褰撳墠閰嶇疆鏈繚瀛橈紝纭畾鍒囨崲鍚楋紵', + onOk: () => { + that.getpage(record) + }, + onCancel() {} + }) + } + } + + getpage = (record) => { + const { Template } = this.props let param = { - func: 's_spages_Param_ctrlzy', - ctrlzy: 'y', - MenuID: MenuId, + func: 'sPC_Get_LongParam_page_id', + id: record.id, TypeCharOne: sessionStorage.getItem('kei_no') || '', TypeName: sessionStorage.getItem('typename') || '', lang: sessionStorage.getItem('lang'), - timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), - open_edition: open_edition, - LText: MenuId + window.GLOB.appkey } - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - this.setState({nextconfirming: true}) + this.setState({loading: true}) Api.getCloudConfig(param).then(res => { - this.setState({nextconfirming: false}) + this.setState({loading: false}) + if (!res.status) { notification.warning({ top: 92, message: res.message, duration: 5 }) - } else { - this.setState({visible: false}) - notification.success({ + } else if (!res.LongParam) { + notification.warning({ top: 92, - message: '鎵ц鎴愬姛銆�', - duration: 1 + message: '鏈幏鍙栧埌閰嶇疆淇℃伅锛�', + duration: 5 }) - - if (updateConfig) { - updateConfig() + } else { + let config = null + + try { + config = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) + } catch (e) { + console.warn('Parse Failure') + config = null + } + + if (!config) { + notification.warning({ + top: 92, + message: '閰嶇疆淇℃伅瑙f瀽澶辫触锛�', + duration: 5 + }) } else { - setTimeout(() => { - window.location.reload() - }, 1000) + if (Template !== config.Template) { + notification.warning({ + top: 92, + message: '鑿滃崟妯℃澘涓嶄竴鑷达紝涓嶅彲鍒囨崲锛�', + duration: 5 + }) + } else if (config.Template === 'CustomPage' && config.version !== 2.0) { + notification.warning({ + top: 92, + message: '鍘嗗彶閰嶇疆鐗堟湰杩囦綆锛屼笉鍙垏鎹紒', + duration: 5 + }) + } else { + this.setState({visible: false}, () => { + this.props.updateConfig(config) + }) + + notification.success({ + top: 92, + message: '鐗堟湰鍒囨崲鎴愬姛锛屼繚瀛樺悗鐢熸晥锛�', + duration: 5 + }) + } } } }) } render() { - const { visible, preconfirming, nextconfirming } = this.state + const { visible, loading, logs, columns } = this.state return ( <> <Button style={{borderColor: '#40a9ff', color: '#40a9ff'}} onClick={this.trigger}><CalendarOutlined /> 鐗堟湰绠$悊</Button> <Modal - title="" + title="鐗堟湰绠$悊" wrapClassName="version-modal" visible={visible} - width={500} - closable={false} + width={800} maskClosable={false} - footer={[]} + onCancel={() => { this.setState({ visible: false, logs: [] }) }} + footer={[ + <Button key="cancel" onClick={() => this.setState({ visible: false, logs: [] })}>鍏抽棴</Button> + ]} destroyOnClose > - <div className="header"><QuestionCircleOutlined/>鐗堟湰鍒囨崲</div> - <div className="detail">璇烽�夋嫨闇�瑕佸垏鎹㈢殑鐗堟湰锛屾垨鐐瑰嚮鍙栨秷鍏抽棴寮圭獥銆�</div> - <div className="footer"> - <Button key="pre" type="primary" loading={preconfirming} onClick={this.preVersion}>涓婁竴鐗堟湰</Button> - <Button key="next" type="primary" loading={nextconfirming} onClick={this.nextVersion}>涓嬩竴鐗堟湰</Button> - <Button key="cancel" onClick={() => { this.setState({ visible: false })}}>鍙栨秷</Button> - </div> + {loading ? <Spin size="large" /> : null} + <Table + rowKey="id" + columns={columns} + dataSource={logs} + pagination={{ + pageSize: 10, + total: logs.length, + showTotal: (total, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉 + }} + /> </Modal> </> ) -- Gitblit v1.8.0