/** * Copyright (c) OpenSpug Organization. https://github.com/openspug/spug * Copyright (c) * Released under the AGPL-3.0 License. */ import React from 'react'; import { observer } from 'mobx-react'; import { BranchesOutlined, BuildOutlined, TagOutlined, PlusOutlined } from '@ant-design/icons'; import { Radio, Modal, Popover, Tag, Popconfirm, Tooltip, message } from 'antd'; import { http, hasPermission } from 'libs'; import { Action, AuthButton, TableCard } from 'components'; import styles from './index.module.less'; import store from './store'; function ComTable() { const columns = [{ title: '申请标题', render: info => (
{info.type === '2' && R} {info.plan && P} {info.name}
) }, { title: '应用', dataIndex: 'app_name', }, { title: '发布环境', dataIndex: 'env_name', }, { title: '版本', render: info => { if (info['app_extend'] === '1') { const [ext1] = info.rep_extra; return ( {ext1 === 'branch' ? : } {info.version} ) } else { return ( {info.version} ) } } }, { title: '状态', render: info => { if (info.status === '-1' && info.reason) { return {info['status_alias']} } else if (info.status === '1' && info.reason) { return {info['status_alias']} } else if (info.status === '2') { return {info['status_alias']} } else if (info.status === '3') { return {info['status_alias']} } else if (info.status === '-3') { return {info['status_alias']} } else { return {info['status_alias']} } } }, { title: '申请人', dataIndex: 'created_by_user', hide: true }, { title: '申请时间', dataIndex: 'created_at', sorter: (a, b) => a['created_at'].localeCompare(b['created_at']), hide: true }, { title: '备注', dataIndex: 'desc', }, { title: '操作', className: hasPermission('deploy.request.do|deploy.request.edit|deploy.request.approve|deploy.request.del') ? null : 'none', render: info => { switch (info.status) { case '-3': return store.readConsole(info)}>查看 handleDeploy(e, info)}> 发布 store.rollback(info)}>回滚 ; case '3': return store.readConsole(info)}>查看 store.rollback(info)}>回滚 ; case '-1': return store.showForm(info)}>编辑 handleDelete(info)}>删除 ; case '0': return store.showApprove(info)}>审核 store.showForm(info)}>编辑 handleDelete(info)}>删除 ; case '1': return handleDeploy(e, info)}> 发布 handleDelete(info)}>删除 ; case '2': return store.readConsole(info)}>查看 ; default: return null } } }]; function handleDelete(info) { Modal.confirm({ title: '删除确认', content: `确定要删除【${info['name']}】?`, onOk: () => { return http.delete('/api/deploy/request/', {params: {id: info.id}}) .then(() => { message.success('删除成功'); store.fetchRecords() }) } }) } 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;`); setTimeout(() => { store.box.setAttribute('class', `${styles.floatBox} ${styles.floatBoxAnimate}`) }, 10); setTimeout(() => { store.showConsole(info); store.box.setAttribute('style', 'display: none'); store.box.setAttribute('class', styles.floatBox) }, 300) } 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 observer(ComTable)