| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 | import React from 'react';import { Icon, Form, Button, Input, Spin, Table, message, Modal, Upload, DatePicker } from 'antd';import './techProduct.less';import { beforeUploadFile, downloadFile } from '../../tools.js';import moment from 'moment';import ajax from 'jquery/src/ajax/xhr.js';import $ from 'jquery/src/ajax';const CenterListDescFrom = Form.create()(React.createClass({    getInitialState() {        return {            loading: false        };    },    handleSubmit(e) {        e.preventDefault();        this.props.form.validateFields((err, values) => {            if (!err) {                this.props.spinState(true);                $.ajax({                    method: "POST",                    dataType: "json",                    crossDomain: false,                    url: globalConfig.context + "/techservice/cognizance/disposeCenterDetail",                    data: {                        id: this.props.data.id,                        projectName: values.projectName,                        projectTime: values.projectTime.format("YYYY-MM-DD"),                        institution: values.institution,                        termTime: values.termTime.format("YYYY-MM-DD"),                        protocolUrl: this.state.protocolUrl                    }                }).done(function (data) {                    if (!data.error.length) {                        message.success('保存成功!');                        this.props.closeModal();                        this.props.spinState(false);                        this.props.form.resetFields();                    } else {                        message.warning(data.error[0].message);                        this.props.spinState(false);                    }                }.bind(this));            }        });    },    render() {        const FormItem = Form.Item;        const { getFieldDecorator } = this.props.form;        const theData = this.props.data;        const formItemLayout = {            labelCol: { span: 4 },            wrapperCol: { span: 12 },        };        const _me = this;        return (            <Form onSubmit={this.handleSubmit} className="activityCost-form">                <div className="clearfix">                    <FormItem className="half-item"                        {...formItemLayout}                        label="时间"                    >                        {getFieldDecorator('projectTimeFormattedDate', {                            rules: [{ type: 'object', required: true, message: '此项为必填项!' }],                            initialValue: theData.projectTimeFormattedDate ? moment(theData.projectTimeFormattedDate) : null                        })(                            <DatePicker />                            )}                    </FormItem>                    <FormItem className="half-item"                        {...formItemLayout}                        label="名称"                    >                        {getFieldDecorator('projectName', {                            rules: [{ required: true, message: '此项为必填项!' }],                            initialValue: theData.projectName                        })(                            <Input />                            )}                    </FormItem>                    <FormItem className="half-item"                        {...formItemLayout}                        label="期限"                    >                        {getFieldDecorator('termTimeFormattedDate', {                            rules: [{ type: 'object', required: true, message: '此项为必填项!' }],                            initialValue: theData.termTimeFormattedDate ? moment(theData.termTimeFormattedDate) : null                        })(                            <DatePicker />                            )}                    </FormItem>                    <FormItem className="half-item"                        {...formItemLayout}                        label="大学机构"                    >                        {getFieldDecorator('institution', {                            rules: [{ required: true, message: '此项为必填项!' }],                            initialValue: theData.institution                        })(                            <Input />                            )}                    </FormItem>                </div>                <div className="hrSituation-roster">                    <Upload                        name="ratepay"                        action={globalConfig.context + "/techservice/cognizance/upload"}                        data={{ 'sign': this.props.year + 'protocol' }}                        beforeUpload={beforeUploadFile}                        onChange={(info) => {                            if (info.file.status !== 'uploading') {                                console.log(info.file, info.fileList);                            }                            if (info.file.status === 'done') {                                if (!info.file.response.error.length) {                                    message.success(`${info.file.name} 文件上传成功!`);                                } else {                                    message.warning(info.file.response.error[0].message);                                    return;                                };                                this.state.protocolUrl = info.file.response.data;                            } else if (info.file.status === 'error') {                                message.error(`${info.file.name} 文件上传失败。`);                            }                        }}                    >                        <Button><Icon type="upload" /> 上传文件 </Button>                    </Upload>                </div>                <FormItem style={{ marginTop: '20px' }}>                    <Button className="set-submit" type="primary" htmlType="submit">保存</Button>                    <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>                </FormItem>            </Form >        );    },}));const CenterListDesc = React.createClass({    getInitialState() {        return {            visible: false,            loading: false        };    },    componentWillReceiveProps(nextProps) {        this.state.visible = nextProps.showDesc    },    showModal() {        this.setState({            visible: true,        });    },    handleOk() {        this.setState({            visible: false,        });        this.props.closeDesc(false);    },    handleCancel(e) {        this.setState({            visible: false,        });        this.props.closeDesc(false);    },    spinChange(e) {        this.setState({            loading: e        });    },    render() {        return (            <div className="patent-addNew">                <Spin spinning={this.state.loading} className='spin-box'>                    <Modal title="产学研情况详情" visible={this.state.visible}                        onOk={this.handleOk} onCancel={this.handleCancel}                        width='800px'                        footer=''                    >                        <CenterListDescFrom data={this.props.data}                            spinState={this.spinChange} closeModal={this.handleCancel} />                    </Modal>                </Spin>            </div>        );    },});const CenterList = React.createClass({    loadOrgTechCenterDetail() {        this.setState({            loading: true        });        $.ajax({            method: "get",            dataType: "json",            crossDomain: false,            url: globalConfig.context + "/techservice/cognizance/center",            data: {            }        }).done((data) => {            if (data.error.length || !data.data) {                message.warning(data.error[0].message);                return;            };            this.state.cid = data.data.id;            this.state.foundingTime = data.data.foundingTimeFormattedDate;            this.state.principal = data.data.principal;            this.state.systemCatalog = data.data.systemCatalog;            this.state.systemUrl = data.data.systemUrl;            this.state.systemDownloadFileName = data.data.systemDownloadFileName;            this.state.centerName = data.data.centerName;            this.state.comment = data.data.comment;            this.loadData();        }).always(function () {            this.setState({                loading: false            });        }.bind(this));    },    loadData(pageNo) {        this.state.data = [];        this.setState({            loading: true        });        $.ajax({            method: "post",            dataType: "json",            crossDomain: false,            url: globalConfig.context + "/techservice/cognizance/centerDetail",            data: {                pageNo: pageNo || 1,                pageSize: this.state.pagination.pageSize,                cid: this.state.cid            }        }).done((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,                    cid: thisdata.cid,                    projectTimeFormattedDate: thisdata.projectTimeFormattedDate,                    projectName: thisdata.projectName,                    protocolDownloadFileName:thisdata.protocolDownloadFileName,                    protocolUrl: thisdata.protocolUrl,                    institution: thisdata.institution,                    termTimeFormattedDate: thisdata.termTimeFormattedDate                });            };            this.state.pagination.current = data.data.pageNo;            this.state.pagination.total = data.data.totalCount;            this.setState({                dataSource: this.state.data,                pagination: this.state.pagination            });        }).always(function () {            this.setState({                loading: false            });        }.bind(this));    },    getInitialState() {        return {            selectedRowKeys: [],            selectedRows: [],            loading: false,            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: 'projectTimeFormattedDate',                    key: 'projectTimeFormattedDate'                }, {                    title: '名称',                    dataIndex: 'projectName',                    key: 'projectName'                }, {                    title: '期限',                    dataIndex: 'termTimeFormattedDate',                    key: 'termTimeFormattedDate'                }, {                    title: '大学机构',                    dataIndex: 'institution',                    key: 'institution'                }, {                    title: '协议附件',                    dataIndex: 'protocolUrl',                    key: 'protocolUrl',                    render: (text) => {                        <a href="" onClick={() => {                            window.open(globalConfig.context + "/techservice/patent/downloadFile?path=" + text + "&sign=" + "type")                        }}></a>                    }                }            ],            dataSource: []        };    },    componentWillMount() {        this.loadOrgTechCenterDetail();    },    tableRowClick(record, index) {        this.state.RowData = record;        this.setState({            showDesc: true        });    },    delectRow() {        let deletedIds = [];        for (let idx = 0; idx < this.state.selectedRows.length; idx++) {            let rowItem = this.state.selectedRows[idx];            if (rowItem.id) {                deletedIds.push(rowItem.id)            }        }        this.setState({            selectedRowKeys: [],            loading: deletedIds.length > 0        });        $.ajax({            method: "POST",            dataType: "json",            crossDomain: false,            url: globalConfig.context + "/techservice/cognizance/deleteOrgTechCenterDetail",            data: {                ids: deletedIds            }        }).done(function (data) {            if (!data.error.length) {                message.success('保存成功!');                this.setState({                    loading: false,                });            } else {                message.warning(data.error[0].message);            };            this.loadData();        }.bind(this));    },    closeDesc(e) {        this.state.showDesc = e;        this.loadData();    },    saveCenterDetail() {        this.setState({            loading: true        });        $.ajax({            method: "post",            dataType: "json",            crossDomain: false,            url: globalConfig.context + "/techservice/cognizance/disposeCenter",            data: {                id: this.state.cid,                principal: this.state.principal,                systemUrl: this.state.systemUrl,                systemCatalog: this.state.systemCatalog,                foundingTimeFormattedDate: this.state.foundingTime,                comment: this.state.comment,                centerName: this.state.centerName            }        }).done((data) => {            if (!data.error.length) {                message.success('保存成功!');                this.loadOrgTechCenterDetail();                this.setState({                    loading: false,                });            } else {                message.warning(data.error[0].message);            };        });    },    render() {        const rowSelection = {            selectedRowKeys: this.state.selectedRowKeys,            onChange: (selectedRowKeys, selectedRows) => {                this.setState({                    selectedRows: selectedRows,                    selectedRowKeys: selectedRowKeys                });            }        };        const hasSelected = this.state.selectedRowKeys.length > 0;        return (            <div className="user-content" >                <div className="content-title">                    <span>研发部门</span>                </div>                <div className="clearfix">                    <div className="orgTech-item">                        <span>研发部门名称: </span>                        <Input                            value={this.state.centerName}                            onChange={(e) => { this.setState({ centerName: e.target.value }); }}                        />                        <span>成立时间: </span>                        <DatePicker                            value={moment(this.state.foundingTime)}                            allowClear={false}                            onChange={(date, dateString) => { this.setState({ foundingTime: dateString }); }}                        />                        <span>负责人: </span>                        <Input                            value={this.state.principal}                            onChange={(e) => { this.setState({ principal: e.target.value }); }}                        />                    </div>                    <div className="orgTech-item">                        <span>制度目录: </span>                        <Input type='textarea' rows={6}                            value={this.state.systemCatalog}                            onChange={(e) => { this.setState({ systemCatalog: e.target.value }); }}                        />                    </div>                    <div className="orgTech-item">                        <span>备注: </span>                        <Input type='textarea' rows={3}                            value={this.state.comment}                            onChange={(e) => { this.setState({ comment: e.target.value }); }}                        />                    </div>                </div>                <div className="half-item">                    <p>制度上传: (上传 zip 或者 rar 文件)</p>                    <div style={{ margin: '10px 0' }}>                        <Upload                            name="ratepay"                            action={globalConfig.context + "/techservice/cognizance/upload"}                            data={{ 'sign': 'institution' }}                            beforeUpload={beforeUploadFile}                            showUploadList={false}                            onChange={(info) => {                                if (info.file.status !== 'uploading') {                                    console.log(info.file, info.fileList);                                }                                if (info.file.status === 'done') {                                    if (!info.file.response.error.length) {                                        message.success(`${info.file.name} 文件上传成功!`);                                    } else {                                        message.warning(info.file.response.error[0].message);                                        return;                                    };                                    this.state.systemUrl = info.file.response.data;                                } else if (info.file.status === 'error') {                                    message.error(`${info.file.name} 文件上传失败。`);                                }                            }}                        >                            <Button><Icon type="upload" /> 上传研发费用台账 </Button>                        </Upload>                        <p style={{ marginTop: '10px' }}>{this.state.systemUrl ? <a onClick={downloadFile.bind(null, this.state.systemUrl, this.state.systemDownloadFileName)}>{this.state.systemDownloadFileName}</a> : <span>未上传!</span>}</p>                    </div>                </div>                <Button type='primary' onClick={this.saveCenterDetail}>保存</Button>                <div className="content-title">                    <span>产学研情况</span>                </div>                <div className="user-search">                    <p>                        <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}                            onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>                        <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}                            disabled={!hasSelected}                            onClick={this.delectRow}>删除<Icon type="minus" /></Button>                    </p>                </div>                <div className="patent-table">                    <Spin spinning={this.state.loading}>                        <Table columns={this.state.columns}                            dataSource={this.state.dataSource}                            pagination={this.state.pagination}                            rowSelection={rowSelection}                            onRowClick={this.tableRowClick} />                    </Spin>                </div>                <CenterListDesc data={this.state.RowData}                    showDesc={this.state.showDesc} closeDesc={this.closeDesc} />            </div >        );    }});export default CenterList;
 |