1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/rainbond-rainbond-ui

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
index.js 48 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
songyg Отправлено 29 дней назад 3b7be45
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469
/* eslint-disable consistent-return */
/* eslint-disable array-callback-return */
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-unused-expressions */
/* eslint-disable react/sort-comp */
/* eslint-disable camelcase */
import NewbieGuiding from '@/components/NewbieGuiding';
import {
Button,
Card,
Col,
Dropdown,
Empty,
Icon,
Input,
Menu,
notification,
Pagination,
Tooltip,
Row,
Spin,
Modal,
Alert,
Form,
InputNumber
} from 'antd';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import ScrollerX from '@/components/ScrollerX'
import React, { PureComponent } from 'react';
import WarningImg from '../../../public/images/warning.png';
import ConfirmModal from '../../components/ConfirmModal';
import CreateTeam from '../../components/CreateTeam';
import JoinTeam from '../../components/JoinTeam';
import OpenRegion from '../../components/OpenRegion';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import roleUtil from '../../utils/role';
import userUtil from '../../utils/user';
import pageheaderSvg from '@/utils/pageHeaderSvg';
import cookie from '../../utils/cookie';
import globalUtil from '../../utils/global';
import styles from './index.less';
import { formatMessage, FormattedMessage } from 'umi-plugin-locale';
import publicColor from '../../../config/theme'
import pluginUtile from '../../utils/pulginUtils'
const { Search } = Input;
const FormItem = Form.Item;
@Form.create()
@connect(({ user, global, rbdPlugin, region }) => ({
user: user.currentUser,
pluginsList: global.pluginsList,
cluster_info: region.cluster_info
}))
export default class EnterpriseTeams extends PureComponent {
constructor(props) {
super(props);
const { user } = this.props;
const adminer = userUtil.isCompanyAdmin(user);
this.state = {
teamList: [],
userTeamList: [],
overviewTeamInfo: false,
showAddTeam: false,
showExitTeam: false,
showDelApply: false,
ApplyInfo: false,
exitTeamName: '',
enterpriseTeamsLoading: false,
userTeamsLoading: true,
overviewTeamsLoading: true,
adminer,
showDelTeam: false,
page: 1,
page_size: 10,
name: '',
total: 1,
joinTeam: false,
delTeamLoading: false,
showOpenRegion: false,
initShow: false,
guideStep: 1,
searchConfig: false,
language: cookie.get('language') === 'zh-CN' ? true : false,
showEnterprisePlugin: false
};
}
componentDidMount() {
const { user } = this.props;
if (user) {
this.load();
}
this.isShowEnterprisePlugin()
}
isShowEnterprisePlugin = () => {
const { dispatch, cluster_info } = this.props;
(cluster_info || []).forEach(item => {
dispatch({
type: 'global/getPluginList',
payload: { enterprise_id: globalUtil.getCurrEnterpriseId(), region_name: item.region_name },
callback: (res) => {
if (res && res.list) {
const showEnterprisePlugin = pluginUtile.isInstallEnterprisePlugin(res.list)
if (showEnterprisePlugin) {
this.setState({
showEnterprisePlugin: true,
})
}
}
},
handleError: () => {
this.setState({ plugins: {}, loading: false });
},
});
})
}
onPageChangeTeam = (page, pageSize) => {
this.setState({ page, page_size: pageSize }, () => {
this.getEnterpriseTeams();
});
};
getEnterpriseTeams = () => {
const {
dispatch,
match: {
params: { eid }
}
} = this.props;
const { page, page_size, name } = this.state;
dispatch({
type: 'global/fetchEnterpriseTeams',
payload: {
page,
page_size,
enterprise_id: eid,
name
},
callback: res => {
if (res && res.status_code === 200) {
this.setState({
total: (res.bean && res.bean.total_count) || 1,
initShow: this.state.searchConfig
? false
: res.bean.total_count === 0,
teamList: (res.bean && res.bean.list) || [],
enterpriseTeamsLoading: false,
searchConfig: false
});
}
}
});
};
getUserTeams = () => {
const {
dispatch,
match: {
params: { eid }
}
} = this.props;
const { page, page_size, name } = this.state;
dispatch({
type: 'global/fetchMyTeams',
payload: {
enterprise_id: eid,
page,
page_size,
name
},
callback: res => {
if (res && res.status_code === 200) {
this.setState({
userTeamList: res.list,
userTeamsLoading: false
});
}
}
});
};
load = () => {
this.state.adminer && this.getEnterpriseTeams();
this.getOverviewTeam();
this.getUserTeams();
};
handleSearchTeam = name => {
this.setState(
{
page: 1,
name,
searchConfig: true
},
() => {
this.getEnterpriseTeams();
}
);
};
handlePaginations = () => (
<Pagination
current={this.state.page}
pageSize={this.state.page_size}
total={Number(this.state.total)}
onChange={this.onPageChangeTeam}
showQuickJumper
showTotal={total => `共 ${total} 条`}
showSizeChanger
onShowSizeChange={this.onPageChangeTeam}
hideOnSinglePage={this.state.total <= 10}
/>
);
handleSearchUserTeam = name => {
this.setState(
{
page: 1,
name
},
() => {
this.getUserTeams();
}
);
};
handleCreateTeam = values => {
this.props.dispatch({
type: 'teamControl/createTeam',
payload: values,
callback: (res) => {
const { response_data } = res
if (response_data && response_data.code) {
if (response_data.code === 400) {
notification.warning({ message: response_data.msg_show });
} else {
notification.success({ message: response_data.msg_show })
}
}
// 添加完查询企业团队列表
this.load();
this.cancelCreateTeam();
}
});
};
getOverviewTeam = () => {
const {
dispatch,
match: {
params: { eid }
}
} = this.props;
dispatch({
type: 'global/fetchOverviewTeam',
payload: {
enterprise_id: eid
},
callback: res => {
if (res && res.status_code === 200) {
this.setState({
overviewTeamsLoading: false,
overviewTeamInfo: res.bean
});
}
}
});
};
onAddTeam = () => {
this.setState({ showAddTeam: true });
};
cancelCreateTeam = () => {
this.setState({ showAddTeam: false, initShow: false });
};
showExitTeam = exitTeamName => {
this.setState({ showExitTeam: true, exitTeamName });
};
handleExitTeam = () => {
const { exitTeamName } = this.state;
this.props.dispatch({
type: 'teamControl/exitTeam',
payload: {
team_name: exitTeamName
},
callback: res => {
if (res && res.status_code === 200) {
this.getOverviewTeam();
this.getUserTeams();
this.hideExitTeam();
}
}
});
};
hideExitTeam = () => {
this.setState({ showExitTeam: false, exitTeamName: '' });
};
showApply = ApplyInfo => {
this.setState({ showDelApply: true, ApplyInfo });
};
hideDelApply = () => {
this.setState({ showDelApply: false, ApplyInfo: false });
};
handleActiveTabs = key => {
this.setState(
{
name: '',
page: 1
},
() => {
if (key === 'team') {
this.getOverviewTeam();
this.getUserTeams();
} else {
this.getEnterpriseTeams();
}
}
);
};
showCloseAllComponent = exitTeamName => {
this.setState({ showCloseAllComponent: true, exitTeamName });
};
hideCloseAllComponent = () => {
this.setState({ showCloseAllComponent: false, exitTeamName: '' });
};
showDelTeam = exitTeamName => {
this.setState({ showDelTeam: true, exitTeamName });
};
hideDelTeam = () => {
this.setState({ showExitTeam: false, showDelTeam: false });
};
handleCloseAllComponentInTeam = () => {
const { exitTeamName, closeTeamComponentLoading } = this.state;
if (closeTeamComponentLoading) {
return;
}
this.setState({ closeTeamComponentLoading: true });
this.props.dispatch({
type: 'teamControl/stopComponentInTeam',
payload: {
team_name: exitTeamName
},
callback: res => {
this.setState({ closeTeamComponentLoading: false });
if (res && res.status_code === 200) {
notification.success({ message: formatMessage({ id: 'notification.success.operate_successfully_close' }) });
}
this.hideCloseAllComponent();
},
handleError: err => {
if (err.data) {
notification.warning({
message: err.data.msg_show
});
}
notification.warning({
message: formatMessage({ id: 'notification.warn.malfunction' })
});
this.setState({ closeTeamComponentLoading: false });
}
});
};
handleDelTeam = () => {
const { exitTeamName, delTeamLoading } = this.state;
if (delTeamLoading) {
return;
}
this.setState({ delTeamLoading: true });
this.props.dispatch({
type: 'teamControl/delTeam',
payload: {
team_name: exitTeamName
},
callback: res => {
this.setState({ delTeamLoading: false });
if (res && res.status_code === 200) {
this.setState(
{
page: 1
},
() => {
this.getEnterpriseTeams();
}
);
this.hideDelTeam();
notification.success({ message: formatMessage({ id: 'notification.success.project_team_delete' }) });
}
},
handleError: err => {
if (err.data) {
notification.warning({
message: err.data.msg_show
});
}
this.setState({ delTeamLoading: false });
}
});
};
handleDelApply = () => {
const { ApplyInfo } = this.state;
this.props.dispatch({
type: 'teamControl/undoTeamUsers',
payload: {
team_name: ApplyInfo.team_name
},
callback: () => {
notification.success({ message: formatMessage({ id: 'notification.success.withdraw_claim' }) });
this.getOverviewTeam();
this.hideDelApply();
}
});
};
handleJoinTeam = values => {
this.props.dispatch({
type: 'global/joinTeam',
payload: values,
callback: () => {
notification.success({ message: formatMessage({ id: 'notification.success.wait_review' }) });
this.getOverviewTeam();
this.cancelJoinTeam();
}
});
};
onJoinTeam = () => {
this.setState({ joinTeam: true });
};
cancelJoinTeam = () => {
this.setState({ joinTeam: false });
};
showRegions = (team_name, regions, ismanagement = false) => {
return (
regions &&
regions.length > 0 &&
regions.map(item => {
return (
<Tooltip placement="top" title={item.region_alias}>
<Button
key={`${item.region_name}region`}
className={styles.regionShow}
onClick={() => {
this.onJumpTeam(team_name, item.region_name);
}}
>
{item.region_alias}
<Icon type="right" />
</Button>
</Tooltip>
);
})
);
};
handleJoinTeams = (teamName, region) => {
const { dispatch } = this.props;
dispatch({
type: 'teamControl/joinTeam',
payload: {
team_name: teamName
},
callback: res => {
if (res && res.status_code === 200) {
this.onJumpTeam(teamName, region);
}
}
});
};
handleOpenRegion = regions => {
const { openRegionTeamName } = this.state;
this.props.dispatch({
type: 'teamControl/openRegion',
payload: {
team_name: openRegionTeamName,
region_names: regions.join(',')
},
callback: () => {
this.load();
this.cancelOpenRegion();
}
});
};
cancelOpenRegion = () => {
this.setState({ showOpenRegion: false, openRegionTeamName: '' });
};
onJumpTeam = (team_name, region) => {
const { dispatch } = this.props;
dispatch(routerRedux.push(`/team/${team_name}/region/${region}/index`));
};
handleNewbieGuiding = info => {
const { prevStep, nextStep, jumpUrl = '' } = info;
const { dispatch } = this.props;
const { adminer } = this.state;
return (
<NewbieGuiding
{...info}
totals={2}
handleClose={() => {
this.handleGuideStep('close');
}}
handlePrev={() => {
if (prevStep) {
this.handleGuideStep(prevStep);
}
}}
handleNext={() => {
if (jumpUrl) {
dispatch(routerRedux.push(jumpUrl));
}
if (nextStep) {
if (nextStep === 2) {
if (adminer) {
this.onAddTeam();
} else {
this.onJoinTeam();
}
}
this.handleGuideStep(nextStep);
}
}}
/>
);
};
handleGuideStep = guideStep => {
this.setState({
guideStep
});
};
/**
* 设置团队限制。
* @param {string} name - 团队名称。
* @param {Array} teamList - 团队列表。
* 该函数用于设置团队的资源限制,并显示相应的对话框。
*/
setTenantLimit = (name, teamList) => {
let info = {}
teamList && teamList.length > 0 &&
teamList.map(item => {
if (item.team_name == name) {
info = item
}
})
const { region_list } = info
this.setState({
setTenantLimitShow: true,
limitTenantName: info.team_name,
limitTeamName: info.team_alias,
initLimitValue: info.set_limit_memory,
initCupLimitValue: info.set_limit_cpu || 0,
showTenantListRegion: region_list[0].region_id,
regionAlias: region_list[0].region_alias,
initLimitStorageValue: info.set_limit_storage || 0
});
};
/**
* 提交资源限制设置。
* @param {Object} e - 事件对象。
* 该函数验证表单字段,如果验证通过,则发送设置企业租户限制的请求,并在请求成功后显示操作成功的通知。
*/
submitLimit = e => {
e.preventDefault();
const {
form,
dispatch
} = this.props;
const eid = globalUtil.getCurrEnterpriseId()
const { limitTenantName, showTenantListRegion } = this.state;
form.validateFields(
{
force: true
},
(err, values) => {
if (!err) {
this.setState({ limitSummitLoading: true });
dispatch({
type: 'region/setEnterpriseTenantLimit',
payload: {
enterprise_id: eid,
region_id: showTenantListRegion,
tenant_name: limitTenantName,
limit_memory: values.limit_memory,
limit_cpu: values.limit_cpu,
limit_storage: values.limit_storage
},
callback: () => {
this.getEnterpriseTeams()
notification.success({
message: formatMessage({ id: 'notification.success.setting_successfully' })
});
this.setState({
limitSummitLoading: false,
setTenantLimitShow: false
});
},
handleError: () => {
notification.warning({
message: formatMessage({ id: 'notification.error.setting_failed' })
});
this.setState({ limitSummitLoading: false });
}
});
}
}
);
};
/**
* 隐藏设置团队限制的对话框。
* 该函数将组件状态中的setTenantLimitShow设置为false,从而隐藏设置团队限制的对话框。
*/
hideTenantListShow = () => {
this.setState({
setTenantLimitShow: false,
});
};
render() {
const {
match: {
params: { eid }
},
form,
pluginsList
} = this.props;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 20 },
sm: { span: 12 }
}
};
const { getFieldDecorator } = form;
const {
teamList,
overviewTeamInfo,
enterpriseTeamsLoading,
overviewTeamsLoading,
adminer,
userTeamList,
userTeamsLoading,
delTeamLoading,
showCloseAllComponent,
closeTeamComponentLoading,
initShow,
guideStep,
language,
setTenantLimitShow,
limitTenantName,
limitTeamName,
initLimitValue,
initCupLimitValue,
regionAlias,
limitSummitLoading,
initLimitStorageValue,
teamNameTitle,
showEnterprisePlugin
} = this.state;
const request_join_team =
overviewTeamInfo &&
overviewTeamInfo.request_join_team.filter(item => {
if (item.is_pass === 0) {
return item;
}
});
const haveNewJoinTeam = request_join_team.length > 0;
const userTeam = userTeamList && userTeamList.length > 0 && userTeamList;
const moreSvg = () => (
<svg
t="1581212425061"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="1314"
width="32"
height="32"
>
<path
d="M512 192m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z"
p-id="1315"
fill="#999999"
/>
<path
d="M512 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z"
p-id="1316"
fill="#999999"
/>
<path
d="M512 832m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z"
p-id="1317"
fill="#999999"
/>
</svg>
);
const menu = exitTeamName => {
return (
<Menu>
<Menu.Item>
<a
onClick={() => {
this.showExitTeam(exitTeamName);
}}
>
{/* 退出项目/团队 */}
<FormattedMessage id='enterpriseTeamManagement.handle.quit' />
</a>
</Menu.Item>
</Menu>
);
};
const menucancel = item => {
return (
<Menu>
<Menu.Item>
<a
onClick={() => {
this.showApply(item);
}}
>
{/* 撤销申请 */}
<FormattedMessage id='enterpriseTeamManagement.handle.backout' />
</a>
</Menu.Item>
</Menu>
);
};
const managementMenu = exitTeamName => {
return (
<Menu>
<Menu.Item>
<a
onClick={() => {
this.showCloseAllComponent(exitTeamName);
}}
>
{/* 关闭所有组件 */}
<FormattedMessage id='enterpriseTeamManagement.admin.handle.turnoff' />
</a>
</Menu.Item>
<Menu.Item>
<a
onClick={() => {
this.setState({
showOpenRegion: true,
openRegionTeamName: exitTeamName
});
}}
>
{/* 开通集群 */}
<FormattedMessage id='enterpriseTeamManagement.admin.handle.open' />
</a>
</Menu.Item>
{showEnterprisePlugin &&
<Menu.Item>
<a
onClick={() => {
this.setTenantLimit(exitTeamName, teamList)
}}
>
<FormattedMessage id='enterpriseColony.table.handle.quota' />
</a>
</Menu.Item>
}
<Menu.Item>
<a
onClick={() => {
this.showDelTeam(exitTeamName);
}}
>
{/* 删除项目/团队 */}
<FormattedMessage id='enterpriseTeamManagement.admin.handle.delete' />
</a>
</Menu.Item>
</Menu>
);
};
const operation = (
<Col span={language ? 7 : 6} style={{ textAlign: 'right' }}>
{adminer ? (
<Button
type="primary"
onClick={this.onAddTeam}
style={{ marginRight: '5px' }}
icon="plus"
>
{/* 创建 项目/团队 */}
<FormattedMessage id='enterpriseTeamManagement.allProject.button.setup' />
</Button>
) : (
<Button type="primary" onClick={this.onJoinTeam} icon="plus">
{/* 加入 项目/团队 */}
<FormattedMessage id='enterpriseTeamManagement.allProject.button.join' />
</Button>
)}
</Col>
);
const en_operation = (
<Col span={language ? 7 : 6} style={{ textAlign: 'right' }}>
{adminer ? (
<Button
type="primary"
onClick={this.onAddTeam}
style={{ marginRight: '5px' }}
icon="plus"
>
{/* 创建 项目/团队 */}
<FormattedMessage id='enterpriseTeamManagement.allProject.button.setup' />
</Button>
) : (
<Button type="primary" onClick={this.onJoinTeam} icon="plus">
{/* 加入 项目/团队 */}
<FormattedMessage id='enterpriseTeamManagement.allProject.button.join' />
</Button>
)}
</Col>
);
const managementTemas = (
<div>
<div style={{
background: '#fff',
borderRadius: 5,
fontSize: 14,
fontWeight: 600
}}>
<Row
className={styles.managementTemas}
>
<Col
span={language ? 2 : 3}
className={styles.teamsTit}
style={{ marginBottom: '0' }}
>
{/* 全部项目/团队 */}
<FormattedMessage id='enterpriseTeamManagement.allProject.lable' />
</Col>
<Col span={15} style={{ textAlign: 'left' }}>
<Search
style={{ width: '500px' }}
placeholder={formatMessage({ id: 'enterpriseTeamManagement.allProject.search' })}
onSearch={this.handleSearchTeam}
/>
</Col>
{operation}
</Row>
{showEnterprisePlugin ? (
<div style={{ padding: '24px 0 0 0', border: '1px solid #e3e3e3', borderTop: 0 }}>
<Row style={{ width: '100%' }} className={styles.rowTitle}>
<Row className={styles.teamMinTit} type="flex" align="middle">
<Col span={4} style={{ width: '13%', textAlign: 'center' }}>
{/* 项目/团队名称 */}
<FormattedMessage id='enterpriseTeamManagement.table.teamName' />
</Col>
<Col span={2} style={{ width: '9%', textAlign: 'center' }}>
{/* 管理员 */}
<FormattedMessage id='enterpriseTeamManagement.table.Administrator' />
</Col>
<Col span={2} style={{ width: '9%', textAlign: 'center' }}>
{/* 人数 */}
<FormattedMessage id='enterpriseTeamManagement.table.number' />
</Col>
<Col span={7} style={{ width: '21%', textAlign: 'center' }}>
{/* 集群 */}
<FormattedMessage id='enterpriseTeamManagement.table.colony' />
</Col>
<Col span={2} style={{ width: '12%', textAlign: 'center' }}>
{/* 内存使用量/总量(MB) */}
<FormattedMessage id='enterpriseTeamManagement.table.memory_total' />
</Col>
<Col span={2} style={{ width: '12%', textAlign: 'center' }}>
{/* CPU使用量/总量(m) */}
<FormattedMessage id='enterpriseTeamManagement.table.CUP_total' />
</Col>
<Col span={2} style={{ width: '12%', textAlign: 'center' }}>
{/* 存储使用量/总量(GB) */}
<FormattedMessage id='enterpriseTeamManagement.table.quota_total' />
</Col>
<Col span={2} style={{ width: '12%', textAlign: 'center' }}>
{/* 运行应用数 */}
<FormattedMessage id='enterpriseTeamManagement.table.operation' />
</Col>
</Row>
<Col className={styles.borTitle}>
{/* 操作 */}
<FormattedMessage id='enterpriseTeamManagement.table.handle' />
</Col>
</Row>
{teamList.map(item => {
const {
team_id,
team_alias,
region_list,
owner_name,
team_name,
running_apps,
user_number,
cpu_request,
memory_request,
storage_request,
set_limit_memory,
set_limit_cpu,
set_limit_storage
} = item;
const memory = (memory_request == 0) ? 0 : memory_request % 1024 == 0 ? (memory_request / 1024) : (memory_request / 1024).toFixed(1)
const limit_memory = (set_limit_memory == 0) ? formatMessage({ id: 'appOverview.no_limit' }) : set_limit_memory % 1024 == 0 ? (set_limit_memory / 1024) : (set_limit_memory / 1024).toFixed(1)
return (
<Card
key={team_id}
style={{ border: 0, borderBottom: '1px solid #f4f4f4' }}
hoverable
bodyStyle={{ padding: 0 }}
>
<Row
type="flex"
align="middle"
className={styles.pl24}
>
<Row
type="flex"
align="middle"
className={styles.pl23}
onClick={() => { this.onJumpTeam(team_name, region_list[0].region_name); }}
>
<Col style={{ color: globalUtil.getPublicColor(), fontWeight: '600', width: '13%', textAlign: 'center', fontSize: '16px' }}>{team_alias}</Col>
<Col style={{ width: '9%', textAlign: 'center' }}>{owner_name}</Col>
<Col style={{ width: '9%', textAlign: 'center' }}>{user_number}</Col>
<Col style={{ width: '21%', display: 'flex', justifyContent: 'center' }} >
{this.showRegions(team_name, region_list, true)}
</Col>
<Col style={{ width: '12%', textAlign: 'center' }}>{memory}/{limit_memory}</Col>
<Col style={{ width: '12%', textAlign: 'center' }}>{cpu_request}/{set_limit_cpu == 0 ? formatMessage({ id: 'appOverview.no_limit' }) : set_limit_cpu}</Col>
<Col style={{ width: '12%', textAlign: 'center' }}>{storage_request}/{set_limit_storage == 0 ? formatMessage({ id: 'appOverview.no_limit' }) : `${set_limit_storage}(GB)`}</Col>
<Col style={{ width: '9%', textAlign: 'center' }}>{running_apps}</Col>
</Row>
<Col className={styles.bor}>
<Dropdown
overlay={managementMenu(team_name)}
placement="bottomLeft"
>
<Icon component={moreSvg} style={{ width: '100%' }} />
</Dropdown>
</Col>
</Row>
</Card>
);
})}
</div>
) : (
<div style={{ padding: '24px 0 0 0', border: '1px solid #e3e3e3', borderTop: 0 }}>
<Row style={{ width: '100%' }} className={styles.rowTitle}>
<Row className={styles.teamMinTit} type="flex" align="middle">
<Col span={4} style={{ width: '13%', textAlign: 'center' }}>
{/* 项目/团队名称 */}
<FormattedMessage id='enterpriseTeamManagement.table.teamName' />
</Col>
<Col span={2} style={{ width: '9%', textAlign: 'center' }}>
{/* 管理员 */}
<FormattedMessage id='enterpriseTeamManagement.table.Administrator' />
</Col>
<Col span={2} style={{ width: '9%', textAlign: 'center' }}>
{/* 人数 */}
<FormattedMessage id='enterpriseTeamManagement.table.number' />
</Col>
<Col span={7} style={{ width: '39%', textAlign: 'center' }}>
{/* 集群 */}
<FormattedMessage id='enterpriseTeamManagement.table.colony' />
</Col>
<Col span={2} style={{ width: '9%', textAlign: 'center' }}>
{/* 内存使用量(MB) */}
<FormattedMessage id='enterpriseTeamManagement.table.memory' />
</Col>
<Col span={2} style={{ width: '9%', textAlign: 'center' }}>
{/* CPU使用量 */}
<FormattedMessage id='enterpriseTeamManagement.table.CUP' />
</Col>
<Col span={2} style={{ width: '9%', textAlign: 'center' }}>
{/* 运行应用数 */}
<FormattedMessage id='enterpriseTeamManagement.table.operation' />
</Col>
</Row>
<Col className={styles.borTitle}>
{/* 操作 */}
<FormattedMessage id='enterpriseTeamManagement.table.handle' />
</Col>
</Row>
{teamList.map(item => {
const {
team_id,
team_alias,
region_list,
owner_name,
team_name,
running_apps,
user_number,
cpu_request,
memory_request,
set_limit_memory
} = item;
const memory = (memory_request == 0) ? formatMessage({ id: 'componentOverview.body.tab.overview.unlimited' }) : memory_request % 1024 == 0 ? (memory_request / 1024) : (memory_request / 1024).toFixed(1)
const set_limit = (set_limit_memory == 0) ? formatMessage({ id: 'componentOverview.body.tab.overview.unlimited' }) : set_limit_memory % 1024 == 0 ? (set_limit_memory / 1024) : (set_limit_memory / 1024).toFixed(1)
return (
<Card
key={team_id}
style={{ border: 0, borderBottom: '1px solid #f4f4f4' }}
hoverable
bodyStyle={{ padding: 0 }}
>
<Row
type="flex"
align="middle"
className={styles.pl24}
>
<Row
type="flex"
align="middle"
className={styles.pl23}
onClick={() => { this.onJumpTeam(team_name, region_list[0].region_name); }}
>
<Col style={{ color: globalUtil.getPublicColor(), fontWeight: '600', width: '13%', textAlign: 'center', fontSize: '16px' }}>{team_alias}</Col>
<Col style={{ width: '9%', textAlign: 'center' }}>{owner_name}</Col>
<Col style={{ width: '9%', textAlign: 'center' }}>{user_number}</Col>
<Col style={{ width: '39%', display: 'flex', justifyContent: 'center' }} >
{this.showRegions(team_name, region_list, true)}
</Col>
<Col style={{ width: '9%', textAlign: 'center' }}>{memory} </Col>
<Col style={{ width: '9%', textAlign: 'center' }}>{cpu_request}</Col>
<Col style={{ width: '9%', textAlign: 'center' }}>{running_apps}</Col>
</Row>
<Col className={styles.bor}>
<Dropdown
overlay={managementMenu(team_name)}
placement="bottomLeft"
>
<Icon component={moreSvg} style={{ width: '100%' }} />
</Dropdown>
</Col>
</Row>
</Card>
);
})}
</div>
)}
<div style={{ textAlign: 'right', margin: '15px' }}>
{Number(this.state.total) > 10 && this.handlePaginations()}
</div>
</div>
</div>
);
const teamInfo = (
<div>
<Row>
<Col span={17} className={styles.teamsTit}>
{/* {haveNewJoinTeam && '最新加入项目/团队'} */}
{haveNewJoinTeam && <FormattedMessage id='enterpriseTeamManagement.other.haveNewJoinTeam' />}
</Col>
</Row>
{haveNewJoinTeam && (
<Row className={styles.teamMinTits} type="flex" align="middle">
<Col span={6}>
{/* 项目/团队名称 */}
<FormattedMessage id='enterpriseTeamManagement.table.teamName' />
</Col>
<Col span={3}>
{/* 管理员 */}
<FormattedMessage id='enterpriseTeamManagement.table.Administrator' />
</Col>
<Col span={3}>
{/* 角色 */}
<FormattedMessage id='enterpriseTeamManagement.table.td.role' />
</Col>
<Col span={12}>
{/* 状态 */}
<FormattedMessage id='enterpriseTeamManagement.table.td.status' />
</Col>
</Row>
)}
{request_join_team &&
request_join_team.map(item => {
const {
is_pass,
team_id,
team_name,
team_alias,
owner_name,
role
} = item;
return (
<Card
key={team_id}
style={{
// marginTop: '10px',
borderLeft: is_pass === 0 && '6px solid #4D73B1',
border: 0
}}
bodyStyle={{ padding: 0 }}
hoverable
>
<Row
type="flex"
className={styles.pls24}
align="middle"
key={team_id}
// onClick={()=>{this.onJumpTeam(team_name, region_list[0].region_name)}}
>
<Col span={6} style={{ color: globalUtil.getPublicColor(), fontWeight: '600', fontSize: '16px' }}>{team_alias}</Col>
<Col span={3}>{owner_name}</Col>
<Col span={3}>{roleUtil.actionMap(role)}</Col>
<Col
span={11}
style={{
color: is_pass === 0 && '#999999'
}}
>
{is_pass === 0 && (
<span>
<img src={WarningImg} alt="" />
&nbsp;
{/* 申请加入项目/团队审批中 */}
<FormattedMessage id='enterpriseTeamManagement.other.examine' />
</span>
)}
</Col>
<Col span={1} className={styles.bors}>
<Dropdown
overlay={
is_pass === 0 ? menucancel(item) : menu(team_name)
}
placement="bottomLeft"
>
<Icon component={moreSvg} style={{ width: '100%' }} />
</Dropdown>
</Col>
</Row>
</Card>
);
})}
<Row
style={{
margin: '10px 0',
display: 'flex',
alignItems: 'center'
}}
>
<Col
span={language ? 2 : 3}
className={styles.teamsTit}
style={{ marginBottom: '0' }}
>
{/* 我的项目/团队 */}
<FormattedMessage id='enterpriseTeamManagement.PageHeaderLayout.title' />
</Col>
<Col span={15} style={{ textAlign: 'left' }}>
<Search
style={{ width: '500px' }}
placeholder={formatMessage({ id: 'enterpriseTeamManagement.allProject.search' })}
onSearch={this.handleSearchUserTeam}
/>
</Col>
{en_operation}
</Row>
{userTeam && (
<Row style={{ width: '100%' }} className={styles.rowTitle}>
<Row className={styles.teamMinTit} type="flex" align="middle">
<Col span={6} style={{ width: '16%', textAlign: 'center' }}>
{/* 项目/团队名称 */}
<FormattedMessage id='enterpriseTeamManagement.table.teamName' />
</Col>
<Col span={3} style={{ width: '10%', textAlign: 'center' }}>
{/* 管理员 */}
<FormattedMessage id='enterpriseTeamManagement.table.Administrator' />
</Col>
<Col span={3} style={{ width: '26%', textAlign: 'center' }}>
{/* 角色 */}
<FormattedMessage id='enterpriseTeamManagement.table.td.role' />
</Col>
<Col span={12} style={{ width: '48%', textAlign: 'left' }}>
{/* 集群 */}
<FormattedMessage id='enterpriseTeamManagement.table.colony' />
</Col>
</Row>
<Col className={styles.borTitle}>
{/* 操作 */}
<FormattedMessage id='enterpriseTeamManagement.table.handle' />
</Col>
</Row>
)}
{!userTeam && (
<Empty
description={<FormattedMessage id='enterpriseTeamManagement.other.description' />}
image={Empty.PRESENTED_IMAGE_SIMPLE}
/>
)}
{userTeam &&
userTeam.map(item => {
const {
team_id,
team_alias,
team_name,
region_list,
owner_name,
roles
} = item;
return (
<Card
key={team_id}
style={{ marginBottom: '10px' }}
hoverable
bodyStyle={{ padding: 0 }}
>
<Row
type="flex"
align="middle"
className={styles.pl24}
>
<Row
type="flex"
align="middle"
className={styles.pl23}
onClick={() => { this.onJumpTeam(team_name, region_list[0].region_name) }}
>
<Col span={6} style={{ color: '#4D73B1', fontWeight: '600', width: '16%', textAlign: 'center', fontSize: '16px' }}>{team_alias}</Col>
<Col span={3} style={{ width: '10%', textAlign: 'center' }}>{owner_name}</Col>
<Col span={3} style={{ width: '26%', textAlign: 'center' }}>
{roles &&
roles.length > 0 &&
roles.map(role => {
return (
<span
style={{ marginRight: '8px' }}
key={`role${role}`}
>
{roleUtil.actionMap(role)}
</span>
);
})}
</Col>
<Col span={11} style={{ width: '48%', textAlign: 'left' }}>
{this.showRegions(team_name, region_list)}
</Col>
</Row>
<Col span={1} className={styles.bor}>
<Dropdown overlay={menu(team_name)} placement="bottomLeft">
<Icon component={moreSvg} style={{ width: '100%' }} />
</Dropdown>
</Col>
</Row>
</Card>
);
})}
</div>
);
let title = <FormattedMessage id='enterpriseTeamManagement.PageHeaderLayout.title' />;
const content = <FormattedMessage id='enterpriseTeamManagement.PageHeaderLayout.context' />;
if (adminer) {
title = <FormattedMessage id='enterpriseTeamManagement.PageHeaderLayout.title.admin' />;
}
return (
<PageHeaderLayout title={title} content={content} titleSvg={pageheaderSvg.getPageHeaderSvg('teams', 20)}>
{showCloseAllComponent && (
<ConfirmModal
onOk={this.handleCloseAllComponentInTeam}
loading={closeTeamComponentLoading}
title={formatMessage({ id: 'confirmModal.project_team_close.delete.title' })}
subDesc={formatMessage({ id: 'confirmModal.delete.strategy.subDesc' })}
desc={formatMessage({ id: 'confirmModal.delete.project_team_close.desc' })}
onCancel={this.hideCloseAllComponent}
/>
)}
{this.state.joinTeam && (
<JoinTeam
enterpriseID={eid}
onOk={this.handleJoinTeam}
onCancel={this.cancelJoinTeam}
/>
)}
{this.state.showAddTeam && (
<CreateTeam
enterprise_id={eid}
onOk={this.handleCreateTeam}
onCancel={this.cancelCreateTeam}
/>
)}
{initShow && (
<CreateTeam
title={<FormattedMessage id='enterpriseTeamManagement.allProject.title' />}
enterprise_id={eid}
onOk={this.handleCreateTeam}
onCancel={this.cancelCreateTeam}
/>
)}
{this.state.showExitTeam && (
<ConfirmModal
onOk={this.handleExitTeam}
title={formatMessage({ id: 'confirmModal.project_team_quit.delete.title' })}
subDesc={formatMessage({ id: 'confirmModal.delete.strategy.subDesc' })}
desc={formatMessage({ id: 'confirmModal.delete.project_team_quit.desc' })}
onCancel={this.hideExitTeam}
/>
)}
{this.state.showDelApply && (
<ConfirmModal
onOk={this.handleDelApply}
title={formatMessage({ id: 'confirmModal.revocation.delete.title' })}
subDesc={formatMessage({ id: 'confirmModal.delete.strategy.subDesc' })}
desc={formatMessage({ id: 'confirmModal.delete.revocation.desc' })}
onCancel={this.hideDelApply}
/>
)}
{this.state.showDelTeam && (
<ConfirmModal
loading={delTeamLoading}
onOk={this.handleDelTeam}
title={formatMessage({ id: 'confirmModal.project_team_delete.delete.title' })}
subDesc={formatMessage({ id: 'confirmModal.delete.strategy.subDesc' })}
desc={formatMessage({ id: 'confirmModal.delete.project_team_delete.desc' })}
onCancel={this.hideDelTeam}
/>
)}
{this.state.showOpenRegion && (
<OpenRegion
onSubmit={this.handleOpenRegion}
onCancel={this.cancelOpenRegion}
teamName={this.state.openRegionTeamName}
/>
)}
{enterpriseTeamsLoading || overviewTeamsLoading || userTeamsLoading ? (
<div className={styles.example}>
<Spin />
</div>
) : (
<ScrollerX sm={1250}>{adminer ? managementTemas : teamInfo}</ScrollerX>
)}
<Modal
centered
maskClosable={false}
title="编辑资源限额"
width={800}
visible={setTenantLimitShow}
footer={null}
onOk={this.hideTenantListShow}
onCancel={this.hideTenantListShow}
>
{setTenantLimitShow && (
<div>
<Alert
style={{ margin: '0px 0 16px 0' }}
message={formatMessage({ id: 'enterpriseColony.table.handle.quota.alert' }, { name: limitTeamName }) + formatMessage({ id: 'enterpriseColony.table.handle.quota.alert1' }, { region: regionAlias })}
/>
<Form onSubmit={this.submitLimit}>
<Form.Item
{...formItemLayout}
name="limit_memory"
label={formatMessage({ id: 'enterpriseColony.table.handle.quota.form.label.limit_memory' })}
>
{getFieldDecorator('limit_memory', {
initialValue: initLimitValue,
rules: [
{
required: true,
message: '内存限额必填'
}
]
})(
<InputNumber
style={{ width: '200px' }}
min={0}
precision={0}
max={2147483647}
/>
)}
</Form.Item>
<Form.Item
{...formItemLayout}
name="limit_cpu"
label={formatMessage({ id: 'enterpriseColony.table.handle.quota.form.label.limit_cpu' })}
>
{getFieldDecorator('limit_cpu', {
initialValue: initCupLimitValue,
rules: [
{
required: true,
message: 'CPU限额必填'
}
]
})(
<InputNumber
style={{ width: '200px' }}
min={0}
precision={0}
max={2147483647}
/>
)}
</Form.Item>
<Form.Item
{...formItemLayout}
name="limit_storage"
label="存储限额(GB)"
>
{getFieldDecorator('limit_storage', {
initialValue: initLimitStorageValue,
rules: [
{
required: true,
message: '请填写存储限额'
}
]
})(
<InputNumber
style={{ width: '200px' }}
min={0}
precision={0}
max={2147483647}
/>
)}
</Form.Item>
<div style={{ textAlign: "right" }}>
<Button
onClick={() => {
this.setState({
setTenantLimitShow: false,
});
}}
>
{formatMessage({ id: 'button.cancel' })}
</Button>
<Button
style={{ marginLeft: '16px' }}
loading={limitSummitLoading}
type="primary"
htmlType="submit"
>
{formatMessage({ id: 'button.confirm' })}
</Button>
</div>
</Form>
</div>
)}
</Modal>
</PageHeaderLayout>
);
}
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/rainbond-rainbond-ui.git
git@gitlife.ru:oschina-mirror/rainbond-rainbond-ui.git
oschina-mirror
rainbond-rainbond-ui
rainbond-rainbond-ui
main