123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
- 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,
- id: thisdata.id,
- uid: thisdata.uid,
- province: thisdata.province,
- unitName: thisdata.unitName,
- serialNumber: thisdata.serialNumber,
- type: thisdata.type,
- signDate: thisdata.signDate,
- founder: thisdata.founder,
- describe: thisdata.describe,
- status: thisdata.status,
- signDateFormattedDate: thisdata.signDateFormattedDate
- });
- };
- 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(
- <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
- )
- };
- 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(
- <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
- )
- };
- 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(
- <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
- )
- };
- 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: []
- };
- },
- componentWillMount() {
- let _me = this, pArr = [], tArr = [], sArr = [];
- provinceArr.map(function (item) {
- pArr.push(
- <Select.Option value={item} key={item}>{item}</Select.Option>
- )
- });
- contractTypeList.map(function (item) {
- tArr.push(
- <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
- )
- });
- contractStateList.map(function (item) {
- sArr.push(
- <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
- )
- });
- this.setState({
- provinceOption: pArr,
- typeOption: tArr,
- stateOption: sArr
- });
- this.loadData();
- this.getAuthorList();
- this.getCompanyList();
- this.getStateList();
- // 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;
- this.setState({
- showDesc: true
- });
- },
- closeDesc(e, s) {
- this.state.showDesc = e;
- if (s) {
- this.loadData();
- };
- },
- addClick() {
- this.setState({
- showAdd: true
- });
- },
- closeAdd(e, s) {
- this.state.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 (
- <div className="foster-box">
- <div className="foster-content">
- <div className="content-title">
- <span>合同申请管理</span>
- <ContractAdd
- companyOption={this.state.companyOption}
- authorOption={this.state.authorOption}
- typeOption={this.state.typeOption}
- onClick={this.addClick}
- closeAdd={this.closeAdd} />
- </div>
- <div className="foster-query">
- <Select placeholder="选择省份"
- style={{ width: 100 }}
- value={this.state.province}
- showSearch
- filterOption={companySearch}
- onChange={(e) => { this.setState({ province: e }) }}>
- {this.state.provinceOption}
- </Select>
- <Select placeholder="选择公司"
- style={{ width: 200 }}
- value={this.state.unitId}
- showSearch
- filterOption={companySearch}
- onChange={(e) => { this.setState({ unitId: e }) }}>
- {this.state.companyOption}
- </Select>
- <Select placeholder="选择一个合同类型"
- style={{ width: 200 }}
- value={this.state.contractType}
- showSearch
- filterOption={companySearch}
- onChange={(e) => { this.setState({ contractType: e }) }}>
- {this.state.typeOption}
- </Select>
- <Select style={{ width: 120 }}
- value={this.state.searchStatus}
- onChange={(e) => { this.setState({ contractState: e }) }}
- placeholder="选择一个状态">
- {this.state.stateOption}
- </Select>
- <span>更多搜索 <Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
- <Button type="primary" onClick={this.search}>搜索</Button>
- <Button onClick={this.reset}>重置</Button>
- <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
- <span>创建时间:</span>
- <RangePicker style={{ width: '240px' }}
- allowClear={false}
- value={[this.state.startDateFormattedDate[0] ? moment(this.state.startDateFormattedDate[0]) : null,
- this.state.startDateFormattedDate[1] ? moment(this.state.startDateFormattedDate[1]) : null]}
- onChange={(date, dateString) => { this.setState({ startDateFormattedDate: dateString }) }} />
- <span>结束时间:</span>
- <RangePicker style={{ width: '240px' }}
- allowClear={false}
- value={[this.state.endDateFormattedDate[0] ? moment(this.state.endDateFormattedDate[0]) : null,
- this.state.endDateFormattedDate[1] ? moment(this.state.endDateFormattedDate[1]) : null]}
- onChange={(date, dateString) => { this.setState({ endDateFormattedDate: dateString }) }} />
- </div>
- </div>
- <div className="foster-table">
- <Spin spinning={this.state.loading}>
- <Table columns={this.state.columns}
- dataSource={this.state.dataSource}
- pagination={this.state.pagination}
- onRowClick={this.tableRowClick} />
- </Spin>
- </div>
- <ContractDetail
- data={this.state.RowData}
- authorOption={this.state.authorOption}
- statusOption={this.state.statusOption}
- showDesc={this.state.showDesc}
- closeDesc={this.closeDesc} />
- </div >
- </div>
- );
- }
- });
- export default Contract;
|