| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674 | // 开单import React, { Component } from "react";import { AutoComplete, Button, Upload, Form, Input, message, Modal, Radio, Select, Spin } from "antd";import { boutique } from "../../dataDic";import $ from "jquery";import { getboutique, splitUrl } from "../../tools";import ImgList from "../imgList";const FormItem = Form.Item;const formItemLayout = {    labelCol: { span: 8 },    wrapperCol: { span: 14 },};class ProjectOperation extends Component {    constructor(props) {        super(props);        this.state = {            commodityName: '',            commodityQuantity: '',            patentType: 0,            officialCost: '',            costReduction: '',            commodityPrice: '',            main: '',            taskComment: '',            declarationBatch: '',            ifCertificationFee: '',            displayFees: "none",            customerArr: [],            patentTypeList: [],            loading: false,            orgCodeUrl: [],            patentTransfer: props.dataInfor ? props.dataInfor.patentTransfer : 0  //收否为专利转让 0 否 1 是        }        this.onSubmit = this.onSubmit.bind(this);        this.httpChange = this.httpChange.bind(this);        this.selectAuto = this.selectAuto.bind(this);        this.getpatentTypeList = this.getpatentTypeList.bind(this);        this.setValue = this.setValue.bind(this);    }    componentDidMount() {        this.getpatentTypeList();        this.setValue();    }    setValue() {        const { dataInfor } = this.props;        if (!(dataInfor && Object.keys(dataInfor).length > 0)) { return; }        if (dataInfor.type === 1) {            this.setState({                displayFees: "block",                costReduction: dataInfor.costReduction,                officialCost: dataInfor.officialCost,                patentType: dataInfor.patentType ? dataInfor.patentType : 0,            });        } else {            this.setState({                displayFees: "none",            });        }        this.setState({            jid: dataInfor.id, //项目ID            kid: dataInfor.commodityId, //商品ID            commodityName: dataInfor.commodityName, //项目名称            commodityPrice: dataInfor.commodityPrice, //金额            commodityQuantity: dataInfor.commodityQuantity, //数量            patentTypeName: dataInfor.patentTypeName,//专利类型名称            taskComment: dataInfor.taskComment, //备注            main: dataInfor.main.toString(), //是否为主要            addState: 0,            addnextVisible: true,            addProjectType: dataInfor.type,            declarationBatch: dataInfor.declarationBatch || 1,//申报批次(只有高新有)            ifCertificationFee: isNaN(parseInt(dataInfor.ifCertificationFee)) ? '' : dataInfor.ifCertificationFee,//是否包含认证费            isIso: dataInfor.commodityName.indexOf("贯标") !== -1,            orgCodeUrl: dataInfor.pictureUrl                ? splitUrl(                    dataInfor.pictureUrl,                    ",",                    globalConfig.avatarHost + "/upload"                )                : [],        });    }    onSubmit() {        if (this.state.gid === undefined || !this.state.gid) {            message.warning("服务名称不匹配!");            return false;        }        let reg = /^([0]|[1-9][0-9]*)$/;        if (            !this.state.commodityQuantity ||            !reg.test(this.state.commodityQuantity)        ) {            message.warning("请输入正确商品数量!");            return false;        }        if (this.state.displayFees === 'block') {            if (this.state.patentType === "" && !this.state.patentTransfer) {                message.warning("请选择专利类型!");                return false;            }            if (this.state.officialCost === '') {                message.warning("请选择官费!");                return false;            }            if (this.state.costReduction === "" && (this.state.patentType === 0 || this.state.patentType === 2) && this.state.officialCost === 1) {                message.warning("请选择费减!");                return false;            }        }        if (isNaN(parseFloat(this.state.commodityPrice))) {            message.warning("请输入正确的金额!");            return false;        }        if (!this.state.main) {            message.warning("请选择是否为主要项目!");            return false;        }        if (this.state.addProjectType === 5 && !this.state.declarationBatch) {            message.warning("请选择企业要求申报批次!");            return false;        }        if (this.state.isIso && !this.state.ifCertificationFee) {            message.warning("请选择是否包含认证费用!");            return false;        }        this.setState({            loading: true,        });        let infor = {            commodityId: this.state.gid, //商品ID            orderNo: this.props.orderNo, //订单编号            commodityName: this.state.commodityName, //商品名称            commodityQuantity: this.state.commodityQuantity, //商品数量            commodityPrice: this.state.commodityPrice, //签单总价            taskComment: this.state.taskComment, //服务说明            main: this.state.main, //是否为主要项目            officialCost: this.state.displayFees === 'block' ? this.state.officialCost : '', //是否有官费            costReduction: this.state.displayFees === 'block' ? ((this.state.patentType === 0 || this.state.patentType === 2) ? (this.state.officialCost === 1 ? this.state.costReduction : 0) : 0) : '', //是否有费减            patentType: this.state.displayFees === 'block' && !this.state.patentTransfer ? this.state.patentType : undefined, // 专利类型        }        if (this.state.addProjectType === 5) {            infor.declarationBatch = this.state.declarationBatch || 1//申报批次        }        if (this.state.isIso) {            infor.ifCertificationFee = this.state.ifCertificationFee || undefined;//是否包含认证费用        }        $.ajax({            method: "POST",            dataType: "json",            crossDomain: false,            url: globalConfig.context + "/api/admin/newOrder/addOrderTask",            data: infor,        }).done(            function (data) {                this.setState({                    loading: false,                });                if (!data.error.length) {                    message.success("保存成功!");                    this.props.onCancel();                } else {                    message.warning(data.error[0].message);                }            }.bind(this)        );    }    onChange() {        if (isNaN(parseFloat(this.state.commodityPrice))) {            message.warning("请输入正确的金额!");            return false;        }        let reg = /^([0]|[1-9][0-9]*)$/;        if (            !this.state.commodityQuantity ||            !reg.test(this.state.commodityQuantity)        ) {            message.warning("请输入正确商品数量!");            return false;        }        if (!this.state.main) {            message.warning("请选择是否为主要项目!");            return false;        }        this.setState({            loading: true,        });        $.ajax({            method: "POST",            dataType: "json",            crossDomain: false,            url: globalConfig.context + "/api/admin/newOrder/updateOrderTask",            data: {                id: this.state.jid, //项目ID                commodityId: this.state.kid, //商品ID                orderNo: this.props.orderNo, //订单编号                main: this.state.main, //是否为主要                commodityPrice: this.state.commodityPrice, //金额                commodityQuantity: this.state.commodityQuantity, //数量                taskComment: this.state.taskComment, //备注                officialCost: this.state.displayFees === 'block' ? this.state.officialCost : '', //是否有官费                costReduction: this.state.displayFees === 'block' ? ((this.state.patentType === 0 || this.state.patentType === 2) ? (this.state.officialCost === 1 ? this.state.costReduction : 0) : 0) : '', //是否有费减                patentType: this.state.displayFees === 'block' ? this.state.patentType : '', //专利类型                declarationBatch: this.state.declarationBatch || undefined,//申报批次                ifCertificationFee: isNaN(parseInt(this.state.ifCertificationFee)) ? undefined : this.state.ifCertificationFee,            },        }).done(            function (data) {                this.setState({                    loading: false,                });                if (!data.error.length) {                    message.success("保存成功!");                    this.props.onCancel();                } else {                    message.warning(data.error[0].message);                }            }.bind(this)        );    }    httpChange(e) {        this.setState({            commodityName: e,        });        if (e.length >= 1) {            this.supervisor(e, false);        }    }    //加载(自动补全)    supervisor(e, state) {        //客户名称与服务名称自动补全        let api = state            ? "/api/admin/customer/getCustomerByName"            : "/api/admin/order/getBusinessProjectByName";        $.ajax({            method: "get",            dataType: "json",            crossDomain: false,            url: globalConfig.context + api,            data: state                ? {                    name: e,                    type: this.state.customType,                }                : {                    businessName: e,                },            success: function (data) {                let thedata = data.data;                if (!thedata) {                    if (data.error && data.error.length) {                        message.warning(data.error[0].message);                    }                    thedata = {};                }                this.setState({                    states: state,                    customerArr: thedata,                });            }.bind(this),        }).always(            function () {            }.bind(this)        );    }    //上级主管输入框失去焦点是判断客户是否存在    selectAuto(value) {        let kid = {};        let fwList = this.state.customerArr;        fwList.map(function (item) {            if (value == item.bname) {                kid = item;            }        });        if (kid.type == "1") {            this.setState({                displayFees: "block",                patentTransfer: kid.patentTransfer,            });        } else {            this.setState({                displayFees: "none",            });        }        console.log(value.indexOf("贯标"), 'value.indexOf("贯标")')        //0通用 1专利 2软著 3审计 4双软 5高新 6商标        this.setState({            commodityName: value,            gid: kid.id,            addProjectType: kid.type,            isIso: value.indexOf("贯标") !== -1,// 是否为贯标项目        });    }    getpatentTypeList() {        $.ajax({            method: "get",            dataType: "json",            crossDomain: false,            url: globalConfig.context + '/api/admin/orderProject/getPatentType',            success: function (data) {                if (data.error.length === 0) {                    this.setState({                        patentTypeList: data.data                    })                } else {                    message.warning(data.error[0].message);                };            }.bind(this)        });    }    render() {        let options = this.state.states            ? this.state.customerArr.map((group) => (                <Select.Option key={group.id} value={group.name}>                    {group.name}                </Select.Option>            ))            : this.state.customerArr.map((group, index) => (                <Select.Option key={index} value={group.bname}>                    {group.bname}                </Select.Option>            ));        const { readOnly } = this.props;        return (            <Modal                maskClosable={false}                visible={this.props.visible}                onOk={this.props.onCancel}                onCancel={this.props.onCancel}                width="900px"                title={readOnly ? "项目任务详情" : this.state.jid ? "编辑项目任务" : "添加项目任务"}                footer=""                className="admin-desc-content"            >                <Form                    layout="horizontal"                >                    <Spin spinning={this.state.loading}>                        <div className="clearfix">                            <FormItem                                className="half-item"                                {...formItemLayout}                                label="服务名称"                            >                                {this.state.jid ? this.state.commodityName : <AutoComplete                                    className="certain-category-search"                                    dropdownClassName="certain-category-search-dropdown"                                    dropdownMatchSelectWidth={false}                                    style={{ width: "200px" }}                                    dataSource={options}                                    placeholder="输入服务名称"                                    value={this.state.commodityName}                                    onChange={this.httpChange}                                    filterOption={true}                                    onSelect={this.selectAuto}                                >                                    <Input />                                </AutoComplete>}                                <span className="mandatory">*</span>                            </FormItem>                            <FormItem                                className="half-item"                                {...formItemLayout}                                label="服务数量"                            >                                {readOnly ? this.state.commodityQuantity : <Input                                    placeholder="请输入服务数量"                                    value={this.state.commodityQuantity}                                    style={{ width: "200px" }}                                    onChange={(e) => {                                        this.setState({ commodityQuantity: e.target.value });                                    }}                                    ref="commodityQuantity"                                />}                                <span className="mandatory">*</span>                            </FormItem>                            <div style={{ marginTop: "33px", color: "red", textAlign: "right", position: "relative", top: "-8", left: "0" }}>如会员项目,服务一年,请填写1,服务二年,请填写2,依次类推</div>                            {!this.state.patentTransfer && <FormItem                                className="half-item"                                labelCol={{ span: 4 }}                                wrapperCol={{ span: 14 }}                                label="专利类型:"                                style={{                                    display: this.state.displayFees,                                    marginLeft: "63px",                                }}                            >                                {readOnly ? this.state.patentTypeName : <Select                                    placeholder="请选择专利类型"                                    style={{ width: "200px" }}                                    value={this.state.patentType}                                    onChange={(e) => {                                        this.setState({ patentType: e });                                        if (e !== 0 && e !== 2) {                                            this.setState({                                                costReduction: ''                                            })                                        }                                    }}                                >                                    {this.state.patentTypeList.map(function (v, k) {                                        return (                                            <Select.Option key={k} value={v.id}>{v.name}</Select.Option>                                        );                                    })}                                </Select>}                                <span style={{ color: "red", marginLeft: "8px" }}>                                    *                                </span>                            </FormItem>}                            <FormItem                                className="half-item"                                labelCol={{ span: 3 }}                                wrapperCol={{ span: 14 }}                                label="官费:"                                style={{                                    display: this.state.displayFees,                                    marginLeft: "63px",                                }}                            >                                {readOnly                                    ? (this.state.officialCost === 1 ? '含官费' : this.state.officialCost === 0 ? '不含官费' : '')                                    : <Radio.Group                                        value={this.state.officialCost}                                        onChange={(e) => {                                            this.setState({ officialCost: e.target.value });                                            if (e.target.value === 0) {                                                this.setState({                                                    costReduction: ''                                                })                                            }                                        }}                                    >                                        <Radio value={1}>含官费</Radio>                                        <Radio value={0}>不含官费</Radio>                                    </Radio.Group>}                                <span style={{ color: "red", marginLeft: "8px" }}>                                    *                                </span>                            </FormItem>                            {                                readOnly ?                                    <FormItem                                        className="half-item"                                        labelCol={{ span: 3 }}                                        wrapperCol={{ span: 14 }}                                        label="费减:"                                        style={{                                            display: this.state.displayFees,                                            marginLeft: "63px",                                        }}                                    >                                        {this.state.costReduction === 1 ? '有费减' : this.state.costReduction === 0 ? '无费减' : ''}                                        <span style={{ color: "red", marginLeft: "8px" }}>                                            *                                        </span>                                    </FormItem>                                    :                                    (this.state.patentType === 0 || this.state.patentType === 2) && this.state.officialCost === 1 &&                                    <FormItem                                        className="half-item"                                        labelCol={{ span: 3 }}                                        wrapperCol={{ span: 14 }}                                        label="费减:"                                        style={{                                            display: this.state.displayFees,                                            marginLeft: "63px",                                        }}                                    >                                        {/*不含官费或者专利类型不为复审或者申请时置灰*/}                                        <Radio.Group                                            disabled={this.state.officialCost === 0 || (this.state.patentType !== 0 && this.state.patentType !== 2)}                                            value={this.state.costReduction}                                            onChange={(e) => {                                                this.setState({ costReduction: e.target.value });                                            }}                                        >                                            <Radio value={1}>有费减</Radio>                                            <Radio value={0}>无费减</Radio>                                        </Radio.Group>                                        <span style={{ color: "red", marginLeft: "8px" }}>                                            *                                        </span>                                    </FormItem>                            }                            <FormItem                                className="half-item"                                {...formItemLayout}                                label="实签价格(万元)"                            >                                {readOnly ? this.state.commodityPrice : <Input                                    type='number'                                    placeholder="请输入实签价格"                                    value={this.state.commodityPrice}                                    style={{ width: "200px" }}                                    onChange={(e) => {                                        this.setState({ commodityPrice: e.target.value });                                    }}                                    ref="commodityPrice"                                />}                                <span className="mandatory">*</span>                            </FormItem>                            <FormItem                                className="half-item"                                {...formItemLayout}                                label="主要业务"                            >                                {readOnly ? getboutique(this.state.main) : <Select                                    placeholder="选择是否为主要业务"                                    style={{ width: "200px" }}                                    value={this.state.main}                                    onChange={(e) => {                                        this.setState({ main: e });                                    }}                                >                                    {boutique.map(function (item) {                                        return (                                            <Select.Option key={item.value}>                                                {item.key}                                            </Select.Option>                                        );                                    })}                                </Select>}                                <span className="mandatory">*</span>                            </FormItem>                            {/* {                                this.state.orgCodeUrl.length > 0 &&                                <div className="clearfix">                                    <FormItem                                        labelCol={{ span: 4 }}                                        wrapperCol={{ span: 16 }}                                        label="附件"                                    >                                        <ImgList                                            fileList={this.state.orgCodeUrl}                                            domId="publicStatistics"                                        />                                    </FormItem>                                </div>                            } */}                            <div className="clearfix">                                <FormItem                                    labelCol={{ span: 4 }}                                    wrapperCol={{ span: 16 }}                                    label="项目说明"                                >                                    {readOnly ? this.state.taskComment :                                        <Input                                            type="textarea"                                            placeholder="如:派2022年会员服务,总会员服务三年,客户付款情况说明"                                            autosize={{ minRows: 4 }}                                            value={this.state.taskComment}                                            onChange={(e) => {                                                this.setState({ taskComment: e.target.value });                                            }}                                        />}                                </FormItem>                                <div style={{ color: "red", marginLeft: 144 }}>                                    请详细说明项目服务时间,总服务时间及付款情况,如:<span style={{ color: "#333" }}>派2022年会员服务,总会员服务三年,客户付款情况说明</span>                                    <p>未付款时,需进行特批审核,请详细说明预计付款时间等详细情况</p>                                </div>                            </div>                            {/*0通用 1专利 2软著 3审计 4双软 5高新 6商标*/}                            {this.state.addProjectType === 5 ?                                <div className="clearfix">                                    <FormItem                                        className="half-item"                                        {...formItemLayout}                                        label="企业要求申报批次"                                    >                                        {readOnly ? (                                            this.state.declarationBatch === 1 ? '第一批' :                                                this.state.declarationBatch === 2 ? '第二批' :                                                    this.state.declarationBatch === 3 ? '第三批' :                                                        this.state.declarationBatch === 4 ? '第四批' : '未知'                                        ) :                                            <Select                                                placeholder="请选择企业要求申报批次"                                                style={{ width: "200px" }}                                                value={this.state.declarationBatch}                                                onChange={(e) => {                                                    this.setState({ declarationBatch: e });                                                }}                                            >                                                <Select.Option value={1}>                                                    第一批                                                </Select.Option>                                                <Select.Option value={2}>                                                    第二批                                                </Select.Option>                                                <Select.Option value={3}>                                                    第三批                                                </Select.Option>                                                <Select.Option value={4}>                                                    第四批                                                </Select.Option>                                            </Select>}                                        <span className="mandatory">*</span>                                    </FormItem>                                </div> : null                            }                            {                                this.props.isIso || this.state.isIso ? <div className="clearfix">                                    <FormItem                                        className="half-item"                                        {...formItemLayout}                                        label="是否包含认证费用"                                    >                                        {readOnly ? (                                            this.state.ifCertificationFee == "1" ? '包含' :                                                this.state.ifCertificationFee == "0" ? '不包含' : '未知'                                        ) : <Select                                            placeholder="请选择是否包含认证费用"                                            style={{ width: "200px" }}                                            value={this.state.ifCertificationFee}                                            onChange={(e) => {                                                this.setState({ ifCertificationFee: e });                                            }}                                        >                                            <Select.Option value={"0"}>否</Select.Option>                                            <Select.Option value={"1"}>是</Select.Option>                                        </Select>}                                        <span className="mandatory">*</span>                                    </FormItem>                                </div> : null                            }                            {readOnly ? null : <FormItem                                wrapperCol={{ span: 12, offset: 4 }}                                className="half-middle"                            >                                <Button                                    className="submitSave"                                    type="primary"                                    onClick={() => {                                        if (this.state.jid) {                                            this.onChange();                                        } else {                                            this.onSubmit();                                        }                                    }}                                >                                    保存                                </Button>                                <Button                                    className="submitSave"                                    type="ghost"                                    onClick={this.props.onCancel}                                >                                    取消                                </Button>                            </FormItem>}                        </div>                    </Spin>                </Form>            </Modal>        )    }}export default ProjectOperation;
 |