import React,{Component} from "react";
import $ from "jquery/src/ajax";
import {Button, Form, Icon, Input, message, Modal, Spin, Table, Tabs, TimePicker, InputNumber, Popconfirm} from "antd";
import moment from 'moment';
import {getCondition} from "../../../tools";
const {TabPane} = Tabs
const FormItem = Form.Item
class WorkeTimes extends Component{
constructor(props) {
super(props);
this.state={
list:[],
loading:false,
timeTypeId:'',
start: '08:30',
restStart: '12:00',
restEnd: '13:30',
end: '17:30',
typeNum:'',
columns:[
{
title: '类型名称',
dataIndex: 'name',
key: 'name',
},
{
title: '类型代号',
dataIndex: 'type',
key: 'type',
},
{
title: '上班时间',
dataIndex: 'start',
key: 'start',
},
{
title: '下班时间',
dataIndex: 'end',
key: 'end',
},
{
title: '午休开始时间',
dataIndex: 'restStart',
key: 'restStart',
},
{
title: '午休结束时间',
dataIndex: 'restEnd',
key: 'restEnd',
},
{
title: '操作',
dataIndex: 'id',
key: 'id',
render: text => { return (
{
this.remove(text);
}}
okText="删除"
cancelText="不删除"
>
)}
}
]
}
this.loadData = this.loadData.bind(this);
this.add = this.add.bind(this);
this.remove = this.remove.bind(this);
this.onCancel = this.onCancel.bind(this);
}
loadData() {
this.setState({
loading: true,
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/department/workingHours/list',
data: {},
success: function (data) {
if (data.error.length === 0) {
this.setState({
list:data.data
})
} else {
message.warning(data.error[0].message)
}
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
}
add(){
if(!this.state.typeName){
message.warning('请输入类型名称')
return ;
}
if(!this.state.start){
message.warning('请选择上班时间')
return ;
}
if(!this.state.restStart){
message.warning('请选择午休开始时间')
return ;
}
if(!this.state.restEnd){
message.warning('请选择午休结束时间')
return ;
}
if(!this.state.end){
message.warning('请选择下班时间')
return ;
}
if(!this.state.typeNum){
message.warning('请输入类型代号')
return ;
}
this.setState({
addLoading:true
})
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url:globalConfig.context + '/api/admin/department/workingHours/add',
data:{
name:this.state.typeName,
start: this.state.start,
restStart: this.state.restStart,
restEnd: this.state.restEnd,
end: this.state.end,
type:this.state.typeNum
}
}).done(function (data) {
this.setState({
addLoading: false
});
if (data.error.length === 0) {
message.success('添加成功!');
this.loadData();
this.onCancel();
} else {
message.warning(data.error[0].message);
}
}.bind(this));
}
remove(id){
this.setState({
removeLoading:true
})
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url:globalConfig.context + '/api/admin/department/workingHours/delete',
data:{
id
}
}).done(function (data) {
this.setState({
removeLoading: false
});
if (data.error.length === 0) {
message.success('删除成功!');
this.loadData();
} else {
message.warning(data.error[0].message);
}
}.bind(this));
}
onCancel(){
this.setState({
typeName:'',
visible:false,
timeTypeInfor:{},
timeTypeId:'',
start: '08:30',
restStart: '12:00',
restEnd: '13:30',
end: '17:30',
typeNum:'',
})
}
componentDidMount() {
this.loadData();
}
render() {
return (
{
}} />
{this.setState({typeName:e.target.value})}}/>
{
this.setState({typeNum:e})
}} />
{
this.setState({
start:timeString
})
}}/>
{
this.setState({
end:timeString
})
}}/>
{
this.setState({
restStart:timeString
})
}}/>
{
this.setState({
restEnd:timeString
})
}}/>
)
}
}
export default WorkeTimes;