diff --git a/spug_web/src/pages/deploy/request/Table.js b/spug_web/src/pages/deploy/request/Table.js
index 549b7df..2951259 100644
--- a/spug_web/src/pages/deploy/request/Table.js
+++ b/spug_web/src/pages/deploy/request/Table.js
@@ -12,20 +12,8 @@ import { Action, AuthButton, TableCard } from 'components';
import styles from './index.module.less';
import store from './store';
-@observer
-class ComTable extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- loading: false
- }
- }
-
- componentDidMount() {
- store.fetchRecords()
- }
-
- columns = [{
+function ComTable() {
+ const columns = [{
title: '申请标题',
render: info => (
@@ -98,14 +86,13 @@ class ComTable extends React.Component {
case '-3':
return
store.readConsole(info)}>查看
- this.handleCCC(e, info)}>
+ handleDeploy(e, info)}>
发布
this.handleRollback(info)}>回滚
+ onClick={() => handleRollback(info)}>回滚
;
case '3':
return
@@ -115,30 +102,27 @@ class ComTable extends React.Component {
this.handleRollback(info)}>回滚
+ onClick={() => handleRollback(info)}>回滚
;
case '-1':
return
store.showForm(info)}>编辑
- this.handleDelete(info)}>删除
+ handleDelete(info)}>删除
;
case '0':
return
store.showApprove(info)}>审核
store.showForm(info)}>编辑
- this.handleDelete(info)}>删除
+ handleDelete(info)}>删除
;
case '1':
return
store.showConsole(info)}>发布
- this.handleDelete(info)}>删除
+ handleDelete(info)}>删除
;
case '2':
return
- 查看
+ store.readConsole(info)}>查看
;
default:
return null
@@ -146,8 +130,7 @@ class ComTable extends React.Component {
}
}];
- handleRollback = (info) => {
- this.setState({loading: true});
+ function handleRollback(info) {
http.put('/api/deploy/request/', {id: info.id, action: 'check'})
.then(res => {
Modal.confirm({
@@ -162,10 +145,9 @@ class ComTable extends React.Component {
}
})
})
- .finally(() => this.setState({loading: false}))
- };
+ }
- handleDelete = (info) => {
+ function handleDelete(info) {
Modal.confirm({
title: '删除确认',
content: `确定要删除【${info['name']}】?`,
@@ -177,9 +159,9 @@ class ComTable extends React.Component {
})
}
})
- };
+ }
- handleCCC = (e, info) => {
+ function handleDeploy(e, info) {
const right = document.body.clientWidth - 25 - e.target.getBoundingClientRect().x;
const bottom = document.body.clientHeight - 40 - e.target.getBoundingClientRect().y;
store.box.setAttribute('style', `display: block; bottom: ${bottom}px; right: ${right}px;`);
@@ -194,59 +176,37 @@ class ComTable extends React.Component {
}
- render() {
- let data = store.records;
- if (store.f_app_id) {
- data = data.filter(item => item['app_id'] === store.f_app_id)
- }
- if (store.f_env_id) {
- data = data.filter(item => item['env_id'] === store.f_env_id)
- }
- if (store.f_s_date) {
- data = data.filter(item => {
- const date = item['created_at'].substr(0, 10);
- return date >= store.f_s_date && date <= store.f_e_date
- })
- }
- if (store.f_status !== 'all') {
- if (store.f_status === '99') {
- data = data.filter(item => ['-1', '2'].includes(item['status']))
- } else {
- data = data.filter(item => item['status'] === store.f_status)
- }
- }
- return (
-
}
- onClick={() => store.addVisible = true}>新建申请,
- store.f_status = e.target.value}>
- 全部({store.counter['all'] || 0})
- 待审核({store.counter['0'] || 0})
- 待发布({store.counter['1'] || 0})
- 发布成功({store.counter['3'] || 0})
- 发布异常({store.counter['-3'] || 0})
- 其他({store.counter['99'] || 0})
-
- ]}
- pagination={{
- showSizeChanger: true,
- showLessItems: true,
- hideOnSinglePage: true,
- showTotal: total => `共 ${total} 条`,
- pageSizeOptions: ['10', '20', '50', '100']
- }}
- columns={this.columns}/>
- )
- }
+ return (
+ }
+ onClick={() => store.addVisible = true}>新建申请,
+ store.f_status = e.target.value}>
+ 全部({store.counter['all'] || 0})
+ 待审核({store.counter['0'] || 0})
+ 待发布({store.counter['1'] || 0})
+ 发布成功({store.counter['3'] || 0})
+ 发布异常({store.counter['-3'] || 0})
+ 其他({store.counter['99'] || 0})
+
+ ]}
+ pagination={{
+ showSizeChanger: true,
+ showLessItems: true,
+ hideOnSinglePage: true,
+ showTotal: total => `共 ${total} 条`,
+ pageSizeOptions: ['10', '20', '50', '100']
+ }}/>
+ )
}
-export default ComTable
+export default observer(ComTable)
diff --git a/spug_web/src/pages/deploy/request/index.js b/spug_web/src/pages/deploy/request/index.js
index d9dc578..1251b07 100644
--- a/spug_web/src/pages/deploy/request/index.js
+++ b/spug_web/src/pages/deploy/request/index.js
@@ -3,7 +3,7 @@
* Copyright (c)
* Released under the AGPL-3.0 License.
*/
-import React from 'react';
+import React, { useState, useEffect } from 'react';
import { observer } from 'mobx-react';
import { ExclamationCircleOutlined, DeleteOutlined } from '@ant-design/icons';
import { Form, Select, DatePicker, Modal, Input, Row, Col, message } from 'antd';
@@ -20,26 +20,17 @@ import store from './store';
import moment from 'moment';
import styles from './index.module.less';
-@observer
-class Index extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- expire: undefined,
- count: ''
- }
- }
+function Index() {
+ const [expire, setExpire] = useState();
+ const [count, setCount] = useState();
- componentDidMount() {
- if (envStore.records.length === 0) {
- envStore.fetchRecords()
- }
- if (appStore.records.length === 0) {
- appStore.fetchRecords()
- }
- }
+ useEffect(() => {
+ store.fetchRecords()
+ if (envStore.records.length === 0) envStore.fetchRecords()
+ if (appStore.records.length === 0) appStore.fetchRecords()
+ }, [])
- handleBatchDel = () => {
+ function handleBatchDel() {
Modal.confirm({
icon: ,
title: '批量删除发布申请',
@@ -47,16 +38,15 @@ class Index extends React.Component {
将删除截止日期之前的所有发布申请记录。 }>