import React from 'react';
import { Icon, Button, Input, Select, Spin, Table, DatePicker, message, Cascader, Switch, Modal } from 'antd';
import { provinceArr, contractStateList, contractTypeList } from '../../../dataDic.js';
import { getTime, companySearch, getContractState, getContractType, getInUrgentTime, getSearchUrl } from '../../../tools.js';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import ContractAdd from './contractAdd.jsx';
import ContractDetail from './contractDetail.jsx';
import moment from 'moment';
import './contract.less';
const Contract = React.createClass({
loadData(pageNo) {
this.state.data = [];
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/contract/list",
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
province: this.state.province,
uid: this.state.unitId,
type: this.state.contractType,
status: this.state.contractState,
startDateFormattedDate: this.state.startDateFormattedDate,
endDateFormattedDate: this.state.endDateFormattedDate,
},
success: function (data) {
if (data.error.length || !data.data || !data.data.list) {
message.warning(data.error[0].message);
return;
};
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
this.state.data.push({
key: i,
completeDate: thisdata.completeDate,
completeDateFormattedDate: thisdata.completeDateFormattedDate,
contacts: thisdata.contacts,
depict: thisdata.depict,
founder: thisdata.founder,
id: thisdata.id,
province: thisdata.province,
serialNumber: thisdata.serialNumber,
signDate: thisdata.signDate,
signDateFormattedDate: thisdata.signDateFormattedDate,
status: thisdata.status,
type: thisdata.type,
uid: thisdata.uid,
unitName: thisdata.unitName,
});
};
this.state.pagination.defaultCurrent = data.data.pageNo;
this.state.pagination.total = data.data.totalCount;
this.setState({
dataSource: this.state.data,
pagination: this.state.pagination
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getAuthorList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/contract/principal",
success: function (data) {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
return;
};
let _me = this, theArr = [];
for (var item in data.data) {
theArr.push(
{data.data[item]}
)
};
this.setState({
authorOption: theArr
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getCompanyList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/getUnitNames",
success: function (data) {
if (data.error.length || !data.data) {
return;
};
let _me = this, theArr = [];
for (var item in data.data) {
theArr.push(
{data.data[item]}
)
};
this.setState({
companyOption: theArr
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getStateList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/contract/status",
success: function (data) {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
return;
};
};
let _me = this, theArr = [];
for (var item in data.data) {
theArr.push(
{data.data[item]}
)
};
this.setState({
statusOption: theArr
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getInitialState() {
return {
visible: false,
data: [],
loading: false,
showAdd: false,
showDesc: false,
searchMore: true,
startDateFormattedDate: [],
endDateFormattedDate: [],
pagination: {
defaultCurrent: 1,
defaultPageSize: 10,
showQuickJumper: true,
pageSize: 10,
onChange: function (page) {
this.loadData(page);
}.bind(this),
showTotal: function (total) {
return '共' + total + '条数据';
}
},
columns: [
{
title: '编号',
dataIndex: 'serialNumber',
key: 'serialNumber',
}, {
title: '省份',
dataIndex: 'province',
key: 'province',
}, {
title: '公司名称',
dataIndex: 'unitName',
key: 'unitName',
}, {
title: '签订时间',
dataIndex: 'signDateFormattedDate',
key: 'signDateFormattedDate',
}, {
title: '合同状态',
dataIndex: 'status',
key: 'status',
render: (text) => { return getContractState(text) }
}, {
title: '合同类型',
dataIndex: 'type',
key: 'type',
render: (text) => { return getContractType(text) }
}, {
title: '创建人',
dataIndex: 'founder',
key: 'founder'
}, {
title: '技术员',
dataIndex: 'techPrincipal',
key: 'techPrincipal',
}, {
title: '描述',
dataIndex: 'describe',
key: 'describe',
}
],
dataSource: []
};
},
getContractList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/contract/serialNumber",
success: function (data) {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
return;
};
let theArr = [];
for (var item in data.data) {
theArr.push(
{data.data[item]}
);
};
this.setState({
contractListOption: theArr
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
componentWillMount() {
let _me = this, pArr = [], tArr = [], sArr = [];
provinceArr.map(function (item) {
pArr.push(
{item}
)
});
contractTypeList.map(function (item) {
tArr.push(
{item.key}
)
});
contractStateList.map(function (item) {
sArr.push(
{item.key}
)
});
this.setState({
provinceOption: pArr,
typeOption: tArr,
stateOption: sArr
});
this.loadData();
this.getAuthorList();
this.getCompanyList();
this.getStateList();
this.getContractList();
// if (window.location.search) {
// let theArr = getSearchUrl(window.location.search);
// if (theArr.length > 1) {
// let theObj = {};
// theObj.id = theArr[0];
// theObj.uid = theArr[1];
// if (theObj.id != 'null' && theObj.uid != 'null') {
// this.tableRowClick(theObj);
// };
// } else if (theArr.length == 1) {
// this.state.unitName = theArr[0];
// };
// };
},
tableRowClick(record, index) {
this.state.RowData = record;
if (record.status === '0') {
this.setState({
showAdd: true
});
} else {
this.setState({
showDesc: true
});
};
},
closeDesc(e, s) {
this.state.showDesc = e;
if (s) {
this.loadData();
};
},
addClick() {
this.setState({
showAdd: true
});
},
closeAdd(e, s) {
this.setState({
showAdd: e
});
if (s) {
this.loadData();
};
},
searchSwitch() {
this.setState({
searchMore: !this.state.searchMore
});
},
search() {
this.loadData();
},
reset() {
this.state.province = undefined;
this.state.unitId = undefined;
this.state.contractState = undefined;
this.state.contractType = undefined;
this.state.startDateFormattedDate = [];
this.state.endDateFormattedDate = [];
this.loadData();
},
render() {
const { MonthPicker, RangePicker } = DatePicker;
return (
合同申请管理
更多搜索
创建时间:
{ this.setState({ startDateFormattedDate: dateString }) }} />
结束时间:
{ this.setState({ endDateFormattedDate: dateString }) }} />
);
}
});
export default Contract;