Skip to content

Commit

Permalink
optimize and format code by eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslcj committed Nov 14, 2018
1 parent 48ceb40 commit 6836dca
Show file tree
Hide file tree
Showing 69 changed files with 9,655 additions and 8,021 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,106 +12,141 @@
*/

import React from 'react';
import PropTypes from 'prop-types';
import { Dialog, Pagination, Transfer } from '@alifd/next';
import { request, aliwareIntl } from '../../globalLib';
import './index.less';

/*****************************此行为标记行, 请勿删和修改此行, 文件和组件依赖请写在此行上面, 主体代码请写在此行下面的class中*****************************/
class BatchHandle extends React.Component {
constructor(props) {
super(props);
this.state = {
visible: false,
valueList: props.valueList || [],
dataSourceList: props.dataSource || [],
currentPage: 1,
total: 0,
pageSize: 10,
dataSource: {}
};
}
componentDidMount() { }
openDialog(dataSource) {
this.setState({
visible: true,
dataSource: dataSource,
pageSize: dataSource.pageSize
}, () => {
this.getData();
console.log(this.transfer._instance.filterCheckedValue);
this.transfer._instance.filterCheckedValue = function (left, right, dataSource) {
var result = {
left: left,
right: right
};
static propTypes = {
valueList: PropTypes.array,
dataSource: PropTypes.array,
onSubmit: PropTypes.func,
};

console.log(left, right, dataSource);
// if (left.length || right.length) {
// var value = dataSource.map(function (item) {
// return item.value;
// });
// value.forEach(function (itemValue) {
// if (left.indexOf(itemValue) > -1) {
// result.left.push(itemValue);
// } else if (right.indexOf(itemValue) > -1) {
// result.right.push(itemValue);
// }
// });
// }
constructor(props) {
super(props);
this.state = {
visible: false,
valueList: props.valueList || [],
dataSourceList: props.dataSource || [],
currentPage: 1,
total: 0,
pageSize: 10,
dataSource: {},
};
}

return result;
};
});
}
closeDialog() {
this.setState({
visible: false
});
}
getData() {
const dataSource = this.state.dataSource;
request({
url: `/diamond-ops/configList/serverId/${dataSource.serverId}?dataId=${dataSource.dataId}&group=${dataSource.group}&appName=${dataSource.appName}&config_tags=${dataSource.config_tags || ''}&pageNo=${this.state.currentPage}&pageSize=${dataSource.pageSize}`,
success: res => {
if (res.code === 200) {
this.setState({
dataSourceList: res.data.map(obj => {
return {
label: obj.dataId,
value: obj.dataId
};
}) || [],
total: res.total
});
}
}
});
}
changePage(currentPage) {
this.setState({
currentPage
}, () => {
this.getData();
});
}
onChange(valueList, data, extra) {
this.setState({
valueList
});
}
onSubmit() {
this.props.onSubmit && this.props.onSubmit(this.state.valueList);
}
render() {
// console.log("valueList: ", this.state.valueList, this.transfer);
componentDidMount() {}

return <Dialog visible={this.state.visible} language={aliwareIntl.currentLanguageCode || 'zh-cn'} style={{ width: "500px" }} onCancel={this.closeDialog.bind(this)} onClose={this.closeDialog.bind(this)} onOk={this.onSubmit.bind(this)} title={"批量操作"}>
<div>
<Transfer ref={ref => this.transfer = ref} listStyle={{ height: 350 }} dataSource={this.state.dataSourceList || []} value={this.state.valueList} onChange={this.onChange.bind(this)} language={aliwareIntl.currentLanguageCode || 'zh-cn'} />
<Pagination style={{ marginTop: 10 }} current={this.state.currentPage} language={aliwareIntl.currentLanguageCode || 'zh-cn'} total={this.state.total} pageSize={this.state.pageSize} onChange={this.changePage.bind(this)} type="simple" />
</div>
</Dialog>;
}
openDialog(dataSource) {
this.setState(
{
visible: true,
dataSource,
pageSize: dataSource.pageSize,
},
() => {
this.getData();
this.transfer._instance.filterCheckedValue = function(left, right, dataSource) {
const result = {
left,
right,
};

return result;
};
}
);
}

closeDialog() {
this.setState({
visible: false,
});
}

getData() {
const { dataSource } = this.state;
request({
url: `/diamond-ops/configList/serverId/${dataSource.serverId}?dataId=${
dataSource.dataId
}&group=${dataSource.group}&appName=${
dataSource.appName
}&config_tags=${dataSource.config_tags || ''}&pageNo=${this.state.currentPage}&pageSize=${
dataSource.pageSize
}`,
success: res => {
if (res.code === 200) {
this.setState({
dataSourceList:
res.data.map(obj => ({
label: obj.dataId,
value: obj.dataId,
})) || [],
total: res.total,
});
}
},
});
}

changePage(currentPage) {
this.setState(
{
currentPage,
},
() => {
this.getData();
}
);
}

onChange(valueList, data, extra) {
this.setState({
valueList,
});
}

onSubmit() {
this.props.onSubmit && this.props.onSubmit(this.state.valueList);
}

render() {
// console.log("valueList: ", this.state.valueList, this.transfer);

return (
<Dialog
visible={this.state.visible}
language={aliwareIntl.currentLanguageCode || 'zh-cn'}
style={{ width: '500px' }}
onCancel={this.closeDialog.bind(this)}
onClose={this.closeDialog.bind(this)}
onOk={this.onSubmit.bind(this)}
title={'批量操作'}
>
<div>
<Transfer
ref={ref => (this.transfer = ref)}
listStyle={{ height: 350 }}
dataSource={this.state.dataSourceList || []}
value={this.state.valueList}
onChange={this.onChange.bind(this)}
language={aliwareIntl.currentLanguageCode || 'zh-cn'}
/>
<Pagination
style={{ marginTop: 10 }}
current={this.state.currentPage}
language={aliwareIntl.currentLanguageCode || 'zh-cn'}
total={this.state.total}
pageSize={this.state.pageSize}
onChange={this.changePage.bind(this)}
type="simple"
/>
</div>
</Dialog>
);
}
}
/*****************************此行为标记行, 请勿删和修改此行, 主体代码请写在此行上面的class中, 组件导出语句及其他信息请写在此行下面*****************************/
export default BatchHandle;

export default BatchHandle;
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

import BatchHandle from './BatchHandle';

export default BatchHandle;
export default BatchHandle;
Loading

0 comments on commit 6836dca

Please sign in to comment.