import React, { Component } from "react"; import { AutoComplete, Button, Icon, 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, YearList } 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 }, }; /** * 编辑项目 和 查看项目详情 */ class newEditProject 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: props.dataInfor ? props.dataInfor.patentTransfer : 0, //收否为专利转让 0 否 1 是 serviceLife: [], isVip: undefined, histYear: [], contractTerm: [],//合同期 addyear: undefined,// isGive: undefined,//是否赠送 splitList: [],//子集 addFrom: false, isMedit: 0, isYear: false,//审计是否需要修改上年度年份 } this.getpatentTypeList = this.getpatentTypeList.bind(this); this.setValue = this.setValue.bind(this); } componentDidMount() { this.getpatentTypeList(); this.setValue(); } setValue() { const { dataInfor, children = "splitList", type = "", readOnly } = this.props; if (!(dataInfor && Object.keys(dataInfor).length > 0)) { return; } if (type == "change") { // 变更编辑 taskType 0通用 1专利 2软著 3审计 4双软 5高新 6商标 if (dataInfor.taskType === 1) { this.setState({ displayFees: "block", costReduction: dataInfor.costReduction, officialCost: dataInfor.officialCost, patentType: dataInfor.patentType ? dataInfor.patentType : 0, }); } else { this.setState({ displayFees: "none", }); } } else { // 正常编辑 type 0通用 1专利 2软著 3审计 4双软 5高新 6商标 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", }); } } let llist = [] if (dataInfor[children] && dataInfor[children].length > 0) { for (var i = 0; i < dataInfor[children].length; i++) { // if (dataInfor.splitList[i].commodityId == dataInfor.commodityId) { // llist.push(dataInfor.splitList[i].serviceYear != dataInfor.serviceYear && dataInfor.splitList[i].serviceYear) // } if (dataInfor[children][i].type != 3) { llist.push(dataInfor[children][i].serviceYear) } } } this.setState({ jid: dataInfor.id, //项目ID kid: dataInfor.commodityId, //商品ID commodityName: dataInfor.commodityName, //项目名称 commodityPrice: dataInfor.commodityPrice, //金额 commodityQuantity: dataInfor.commodityQuantity, //数量 patentTypeName: dataInfor.patentTypeName,//专利类型名称 taskComment: dataInfor.cSort == 6 ? undefined : dataInfor.taskComment, //备注 main: dataInfor.main.toString(), //是否为主要 addState: 0, addnextVisible: true, addProjectType: type == "change" ? dataInfor.taskType : 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") : [],// isYear: !dataInfor.lastYear ? true : false,// lastYear: dataInfor.lastYear,//上年度年份 lastYearCapital: dataInfor.lastYearCapital,//上年度总资本 lastYearIncome: dataInfor.lastYearIncome,//上年度总收入 isVip: dataInfor.cSort, yearSum: dataInfor.yearSum,//会员总服务年限 serviceLife: !dataInfor.serviceLife ? [] : JSON.parse(dataInfor.serviceLife), // 会员服务年限 contractTerm: (!dataInfor.contractTerm || (dataInfor.contractTerm.indexOf("-") == -1)) ? [] : JSON.parse(dataInfor.contractTerm), // 合同期 serviceYear: dataInfor.cSort == 6 ? undefined : dataInfor.serviceYear,//本次派单 histYear: llist, // 本次已派单 splitList: dataInfor[children] || [], tid: dataInfor.id, // 父级项目id isMedit: readOnly ? 3 : dataInfor.cSort == 6 ? 0 : 1,// 会员项目默认0不可编辑 普通项目默认1可编辑 }); } onChange(text) { const { type = "", dataInfor } = this.props 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; } // 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 (this.state.isYear && !this.state.lastYear) { 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.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 = { 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, //备注 } 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 = this.state.lastYear //上年度年份 infor.lastYearCapital = this.state.lastYearCapital //上年度总资本 infor.lastYearIncome = this.state.lastYearIncome //上年度总收入 } if (this.state.addProjectType == "5") {//高新 infor.declarationBatch = this.state.declarationBatch || undefined//申报批次 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)//合同期 } // 新开单与签单项目变更 -- 编辑项目 if (type == "change") { infor.id = dataInfor.id infor.type = dataInfor.tid ? 2 : 1 infor.tid = dataInfor.tid } $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + type == "change" ? "/api/admin/orderChange/updateChangeTask" : "/api/admin/newOrder/updateOrderTask", data: infor, }).done( function (data) { this.setState({ loading: false, }); if (!data.error.length) { message.success("保存成功!"); if (this.state.isVip == 6) { text == "submit" && this.setState({ isMedit: 0 }) } else { this.props.onCancel(); } } else { message.warning(data.error[0].message); } }.bind(this) ); } 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, histYear } = this.state $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + this.props.type == "change" ? '/api/admin/orderChange/deleteMemberSonProject' : '/api/admin/orderProject/deleteMemberSonProject', data: { id, }, success: function (data) { if (data.error.length === 0) { this.onChange() let splList = splitList let hlist = [] for (var i = 0; i < splitList.length; i++) { if (id == splitList[i].id) { //如果是 type==1 新增 就彻底删除 否则 改为type==3 if (splList[i].type == 0 || splList[i].type == 2) { splList[i].type = 3 } else { splList.splice(i, 1) } // hlist.splice(i, 1) } } for (var j = 0; j < splList.length; j++) { splList[j].type != 3 && hlist.push(splList[j].serviceYear) } this.setState({ splitList: splList, histYear: hlist, }) } else { message.warning(data.error[0].message); }; }.bind(this) }); } // 恢复子项目 updateMemberSonProject(id, taskComment) { const { splitList, histYear, serviceYear } = this.state $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/orderChange/updateMemberSonProject', data: { id, taskComment, }, success: function (data) { if (data.error.length === 0) { // this.onChange() let splList = splitList let histList = histYear for (var i = 0; i < splList.length; i++) { if (splList[i].id == data.data.id) { splList[i].type = data.data.type splList[i].taskComment = data.data.taskComment } } histList.push(serviceYear) this.setState({ addFrom: false, splitList: splList, histYear: histList, serviceYear: undefined, taskComment: undefined, isMedit: 0, }) message.success("保存成功!") } 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 }); } aGain() { const { serviceLife } = this.state this.setState({ serviceLife: serviceLife, commodityQuantity: serviceLife.length == 0 ? undefined : serviceLife.length, yearSum: serviceLife.length == 0 ? undefined : serviceLife.length.toString(), }) } tagClose(tag) { const _this = this let serviceLife = this.state.serviceLife.filter(t => { return t !== tag }); let delid = "" const { splitList = [], } = this.state if (serviceLife.length < 1) { Modal.error({ title: '提示', content: (
会员服务年限必须保留一个