import React, { Component } from "react"; import { AutoComplete, Button, Form, Input, message, Modal, Radio, Select, Spin, Tag, DatePicker } from "antd"; import { boutique } from "../../dataDic"; import $ from "jquery"; import { getboutique, splitUrl } from "../../tools"; import moment from "moment"; import { vipYear } from "../../dataDic"; import ImgList from "../imgList"; const FormItem = Form.Item; const Option = Select.Option; const RadioGroup = Radio.Group; const confirm = Modal.confirm; const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; const PicturesWall = React.createClass({ getInitialState() { return { previewVisible: false, previewImage: "", fileList: this.props.pictureUrl, }; }, getDefaultProps() { return { changeClick: this.modifyChange, }; }, handleCancel() { this.setState({ previewVisible: false }); }, handlePreview(file) { this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }, handleChange(info) { let fileList = info.fileList; this.setState({ fileList }); this.props.fileList(fileList); }, componentWillReceiveProps(nextProps) { this.state.fileList = nextProps.pictureUrl; }, render() { const { fileList } = this.state; return (
{ this.handleChange(infor); }} fileList={fileList} />
); }, }); /** * 新增项目 */ class NewAddProject extends Component { constructor(props) { super(props); this.state = { commodityName: '',//项目名称 commodityQuantity: '',//项目数量 patentType: 0, officialCost: '', costReduction: '', commodityPrice: '',//项目价格 main: '',//主要项目 0否 1是 lastYearCapital: '',//上年度总资本 lastYearIncome: '',//上年度总资本 taskComment: '',//项目说明 declarationBatch: '', ifCertificationFee: '', displayFees: "none", customerArr: [], patentTypeList: [], loading: false, orgCodeUrl: [], patentTransfer: 0, //是否为专利转让 0 否 1 是 serviceLife: [],//服务年份 isVip: undefined, histYear: [], editName: false, isEdit: false,//是否可编辑 contractTerm: [],//合同期 addyear: undefined,// isGive: undefined,//是否赠送 splitList: [],//子集 addFrom: false, serviceYear: '', } 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.getOrgCodeUrl = this.getOrgCodeUrl.bind(this); } componentDidMount() { this.getpatentTypeList(); this.props.type == "vipAdd" && this.setValue(); } setValue() { const { newData } = this.props; if (!!newData && newData.length > 0) { let list = [] for (var i = 0; i < newData.length; i++) { if (newData[i].cSort == 6) { list.push({ bname: newData[i].commodityName, type: newData[i].type, id: newData[i].commodityId, cSort: newData[i].cSort, patentTransfer: newData[i].patentTransfer, }) } } this.setState({ commodityName: undefined, customerArr: list }) } } 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)) { message.warning("请选择费减!"); return false; } } if (isNaN(parseFloat(this.state.commodityPrice))) { message.warning("请输入正确的金额!"); return false; } // 3审计 if (this.state.addProjectType == "3") { if (this.state.serviceLife.length === 0) { message.warning("请选择服务年限!"); return } if (this.state.serviceLife.length != this.state.commodityQuantity) { message.warning("服务数量与服务年限不符!"); return } if (isNaN(parseFloat(this.state.lastYearCapital))) { message.warning("请输入正确的企业上年度总资本!"); return } if (isNaN(parseFloat(this.state.lastYearIncome))) { message.warning("请输入正确的企业上年度总收入!"); return } } if (!this.state.main) { message.warning("请选择是否为主要项目!"); return false; } // 5高新 if (this.state.addProjectType === 5) { if (!this.state.declarationBatch) { message.warning("请选择企业要求申报批次!"); return } if (!this.state.serviceYear) { message.warning("请选择申报年份!"); return } } if (this.state.isIso && !this.state.ifCertificationFee) { message.warning("请选择是否包含认证费用!"); return false; } if (this.state.isVip == 6) { // if (this.state.yearSum === undefined) { // message.warning("请选择会员总服务年限!"); // return // } if (this.state.serviceLife.length === 0) { message.warning("请添加会员服务年限!"); return } // if (this.state.serviceLife.length != this.state.yearSum) { // message.warning("会员服务年限与总年限不符合!"); // return // } // if (this.state.serviceYear === undefined) { // message.warning("请选择本次派单年份!"); // return // } if (this.state.contractTerm.length === 0 || this.state.contractTerm[1] == "") { message.warning("请填写合同期!"); return } } this.setState({ loading: true, }); let infor = { commodityId: this.state.gid, //商品ID orderNo: this.props.orderNo, //订单编号 commodityName: this.state.commodityName, //商品名称 commodityQuantity: this.state.isVip == 6 ? this.state.yearSum : this.state.commodityQuantity, //商品数量 commodityPrice: this.state.commodityPrice, //签单总价 taskComment: this.state.taskComment, //服务说明 main: this.state.main, //是否为主要项目 } // 变更添加 this.props.type == "change" let type = 0; if (this.props.typeChange == 4 || this.props.typeChange == 5) { type = 1; } if (this.props.type == "change") { infor.cid = this.props.cid infor.type = type } if (this.state.displayFees === 'block') { infor.officialCost = this.state.officialCost //是否有官费 infor.costReduction = (this.state.patentType === 0 || this.state.patentType === 2) ? this.state.costReduction : 0//是否有费减 infor.patentType = this.state.patentType //专利类型 } if (this.state.isIso) { infor.ifCertificationFee = this.state.ifCertificationFee || undefined;//是否包含认证费用 } if (this.state.addProjectType == "3") {//审计 infor.serviceLife = JSON.stringify(this.state.serviceLife) //服务年限 infor.lastYear = new Date().getFullYear() - 1 //上年度年份 infor.lastYearCapital = this.state.lastYearCapital //上年度总资本 infor.lastYearIncome = this.state.lastYearIncome //上年度总收入 } if (this.state.addProjectType == "5") {//高新 infor.declarationBatch = this.state.declarationBatch || 1//申报批次 infor.serviceYear = this.state.serviceYear //申报年份 } if (this.state.isVip == 6) {//会员 infor.yearSum = this.state.yearSum //会员总服务年限 infor.serviceLife = JSON.stringify(this.state.serviceLife) //会员服务年限 // infor.serviceYear = this.state.serviceYear //本次派单年份 infor.contractTerm = JSON.stringify(this.state.contractTerm)//合同期 } $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + this.props.type == "change" ? "/api/admin/orderChange/addChangeTask" : "/api/admin/newOrder/addOrderTask", data: infor, }).done( function (data) { this.setState({ loading: false, }); if (!data.error.length) { message.success("保存成功!"); if (this.state.isVip == 6) { this.setState({ isEdit: true, editName: true, tid: data.data.id, }) } else { this.props.onCancel(); } if (this.props.type == "change") { this.setState({ tid: data.data.id }) } } 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) { const { newData, children = "splitList" } = this.props 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", }); } //0通用 1专利 2软著 3审计 4双软 5高新 6商标 this.setState({ commodityName: value, gid: kid.id, addProjectType: kid.type, isIso: value.indexOf("贯标") !== -1,// 是否为贯标项目 isVip: kid.cSort,//暂时判断等于6的时候会员 commodityQuantity: kid.cSort == 6 ? 1 : undefined,//服务数量 histYear: [], }); if (newData && newData.length > 0 && kid.cSort == 6) { for (var i = newData.length - 1; i >= 0; i--) { if (newData[i].commodityId == kid.id) { if (!!newData[i][children]) { let list = [] for (var j = 0; j < newData[i][children].length; j++) { list.push(newData[i][children][j].serviceYear) } this.setState({ histYear: list, // 已派单 }) } this.setState({ commodityPrice: newData[i].commodityPrice, // 实签价格 main: newData[i].main.toString(), // 是否为主要项目 yearSum: !newData[i].yearSum ? "" : newData[i].yearSum, // 会员总服务年限 serviceLife: !newData[i].serviceLife ? [] : JSON.parse(newData[i].serviceLife), // 会员服务年限 contractTerm: (!newData[i].contractTerm || (newData[i].contractTerm.indexOf("-") == -1)) ? [] : JSON.parse(newData[i].contractTerm), // 合同期 // taskComment: kid.cSort == 6 ? undefined : newData[i].taskComment, // 项目说明 isEdit: true, // 不可编辑 splitList: newData[i][children] || [], tid: newData[i].id, // 父级项目id }) return } else { this.setState({ commodityPrice: undefined, main: undefined, yearSum: undefined, serviceLife: [], contractTerm: [], taskComment: undefined, isEdit: false, // 可编辑 splitList: [], }) } } } } 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) }); } deleteMemberSonProject(id) { const { splitList, serviceLife } = this.state $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/orderProject/deleteMemberSonProject', data: { id, }, success: function (data) { if (data.error.length === 0) { let splList = splitList for (var i = 0; i < splitList.length; i++) { if (id == splitList[i].id) { splList.splice(i, 1) } } this.setState({ splitList: splList }) } else { message.warning(data.error[0].message); }; }.bind(this) }); } handleClose(removedTag) { let serviceLife = this.state.serviceLife.filter(tag => { return tag !== removedTag }); this.setState({ serviceLife, commodityQuantity: serviceLife.length == 0 ? undefined : serviceLife.length, yearSum: serviceLife.length == 0 ? undefined : serviceLife.length.toString(), serviceYear: undefined }); } // 添加会员子项目 addMemberFirstSonProject() { // type=="change" 变更项目 const { type = "" } = this.props // type=="vipAdd" 需审批的会员项目 let pictureUrl = []; if (type == "vipAdd") { if (this.state.orgCodeUrl.length) { let picArr = []; this.state.orgCodeUrl.map(function (item) { if ( item.response && item.response.data && item.response.data.length ) { picArr.push(item.response.data); } }); pictureUrl = picArr.join(","); } if (this.state.memberType === undefined) { message.warning("请选择付款情况!"); return } if (this.state.memberType == "1" || this.state.memberType == "2") { if (typeof pictureUrl !== "string") { message.warning("请上传附件!"); return } } } if (this.state.serviceYear === undefined) { message.warning("请选择本次派单年份!"); return } this.setState({ loading: true, }); let info = { tid: this.state.tid, serviceYear: this.state.serviceYear, taskComment: this.state.taskComment, } let changeInfo = { id: this.state.tid, serviceYear: this.state.serviceYear, taskComment: this.state.taskComment, } let vipAddInfo = { tid: this.state.tid, serviceYear: this.state.serviceYear,//本次派单 taskComment: this.state.taskComment,//服务说明 memberType: this.state.memberType,//会员付款状态 pictureUrl: pictureUrl.length ? pictureUrl : undefined,//附件 } $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + type == "change" ? "/api/admin/orderChange/addMemberSonProject" : type == "vipAdd" ? "/api/admin/orderProject/addMemberSonProject" : "/api/admin/orderProject/addMemberFirstSonProject", data: type == "change" ? changeInfo : type == "vipAdd" ? vipAddInfo : info, }).done( function (data) { this.setState({ loading: false, }); if (!data.error.length) { message.success("添加成功!"); let list = this.state.splitList let histList = this.state.histYear list.push(data.data) histList.push(data.data.serviceYear) this.setState({ addFrom: false, splitList: list, histYear: histList, serviceYear: undefined, taskComment: undefined, memberType: undefined, orgCodeUrl: [], }) } else { message.warning(data.error[0].message); } }.bind(this) ); } // 图片添加 getOrgCodeUrl(e) { this.setState({ orgCodeUrl: e }); } render() { let newOptions = this.state.customerArr.map((group, index) => ( {group.bname} )); let options = this.state.states ? this.state.customerArr.map((group) => ( {group.name} )) : this.state.customerArr.map((group, index) => ( {group.bname} )); let children = vipYear.map(its => ( )); const { RangePicker } = DatePicker; const { type = "" } = this.props; const { isVip, histYear, isEdit } = this.state return (
{ type == "vipAdd" ? : {this.state.jid ? this.state.commodityName : } {*} } { isVip != 6 && { { this.setState({ commodityQuantity: e.target.value }); }} ref="commodityQuantity" /> } {*} }
{ { this.setState({ commodityPrice: e.target.value }); }} ref="commodityPrice" /> } {*} { } {*} {!this.state.patentTransfer && { } * }
{ { this.setState({ officialCost: e.target.value }); if (e.target.value === 0) { this.setState({ costReduction: '' }) } }} > 含官费 不含官费 } *
{ (this.state.patentType === 0 || this.state.patentType === 2) &&
{/*专利类型不为复审或者申请时置灰*/} { this.setState({ costReduction: e.target.value }); }} > 有费减 无费减 *
} { //审计 this.state.addProjectType == "3" && { } {*} } { isVip == 6 && {
{ this.state.serviceLife.map((tag) => this.handleClose(tag)} >{tag} ) } { !isEdit && (this.state.serviceLife.length < 10) && }
}
} { isVip == 6 && { !this.state.yearSum ? "" : [ { value: "0", key: "" }, { value: "1", key: "一年" }, { value: "2", key: "二年" }, { value: "3", key: "三年" }, { value: "4", key: "四年" }, { value: "5", key: "五年" }, { value: "6", key: "六年" }, { value: "7", key: "七年" }, { value: "8", key: "八年" }, { value: "9", key: "九年" }, { value: "10", key: "十年" }, ][this.state.yearSum]["key"] } } { // 会员合同期 isVip == 6 &&
{ { this.setState({ contractTerm: dataString }); }} /> } {*}
} { // 审计 this.state.addProjectType == "3" &&
注:派单年度的上年度总资产和收入。如,当前为2022年,那么需要填写2021年的总资产和收入! { this.setState({ lastYearCapital: e.target.value }); }} /> {*} { this.setState({ lastYearIncome: e.target.value }); }} /> {*}
} { // 普通项目说明 isVip != 6 &&
{ { this.setState({ taskComment: e.target.value }); }} /> }
} {/*0通用 1专利 2软著 3审计 4双软 5高新 6商标*/} {this.state.addProjectType === 5 &&
{ } {*} { } {*}
} { this.props.isIso || this.state.isIso ?
{ } {*}
: null } {((isVip != 6) || (isVip == 6 && !isEdit)) &&
} { // 会员项目子集列表 isEdit && !!this.state.splitList && this.state.splitList.length > 0 && this.state.splitList.map((item) =>
{item.serviceYear} {item.commodityQuantity} { type == "vipAdd" && {item.memberType == "0" ? "已付会员节点全款" : item.memberType == "1" ? "已付部分期款,需特批" : item.memberType == "2" ? "未付款,需特批" : ""} } { type == "vipAdd" && (item.memberType == "1" || item.memberType == "2") &&
{item.pictureUrl ?
:
}
}
{item.taskComment}
) } { this.state.splitList.length < this.state.yearSum &&
{ isEdit && !this.state.addFrom && this.state.splitList.length < this.state.yearSum &&
请填写本次派单的年份,派单表示立即安排人员开始相关的工作!!!
} { this.state.addFrom &&
{*} { // this.setState({ commodityQuantity: e.target.value }); // }} ref="commodityQuantity" /> {*} { this.props.type == "vipAdd" && { } * } { (this.state.memberType == "1" || this.state.memberType == "2") && this.props.type == "vipAdd" &&
{*}
特批需上传附件图,请上传客户同意我方继续服务并安排给我司付款的聊天记录截图,

若没有客户同意继续服务及会安排付款的截图,特派流程将无法走下去,以免造成派单耽搁

}
{ this.setState({ taskComment: e.target.value }); }} />
}
}
{ this.state.addYears && { if (!this.state.addyear) { message.warn("请选择年份!") return } if (this.state.isGive == undefined) { message.warn("请选择是否赠送!") return } let slist = this.state.serviceLife if (this.state.isGive == 0) { slist.push(this.state.addyear) } else if (this.state.isGive == 1) { let newYear = this.state.addyear + "(赠)" slist.push(newYear) } this.setState({ serviceLife: slist, yearSum: slist.length.toString(), addYears: false }) }} onCancel={() => { this.setState({ addYears: false }) }} > { this.setState({ isGive: e.target.value }) }} value={this.state.isGive} > 非赠送 赠送 } ) } } export default NewAddProject;