|
|
@@ -5,7 +5,7 @@ import {
|
|
|
Checkbox
|
|
|
} from "antd";
|
|
|
import { boutique } from "../../dataDic";
|
|
|
-import $ from "jquery";
|
|
|
+import $, { error } from "jquery";
|
|
|
import { getboutique, splitUrl } from "../../tools";
|
|
|
import moment from "moment";
|
|
|
import { vipYear, YearList } from "../../dataDic";
|
|
|
@@ -78,32 +78,35 @@ class newEditProject extends Component {
|
|
|
*/
|
|
|
getCheckTypeList(checkTypeList) {
|
|
|
let newCheckType = [];
|
|
|
- // 高新会员
|
|
|
- let htMember = 0;
|
|
|
- // 加计扣除
|
|
|
- let additionalDeduction = 0;
|
|
|
- // 研发补助
|
|
|
- let rdAwardsubsidy = 0;
|
|
|
- checkTypeList.map(item => {
|
|
|
- if (item.htMember == 1) {
|
|
|
- htMember = 1;
|
|
|
+ if (checkTypeList instanceof Array) {
|
|
|
+ // 高新会员
|
|
|
+ let htMember = 0;
|
|
|
+ // 加计扣除
|
|
|
+ let additionalDeduction = 0;
|
|
|
+ // 研发补助
|
|
|
+ let rdAwardsubsidy = 0;
|
|
|
+ checkTypeList.map(item => {
|
|
|
+ if (item.htMember == 1) {
|
|
|
+ htMember = 1;
|
|
|
+ }
|
|
|
+ if (item.additionalDeduction == 1) {
|
|
|
+ additionalDeduction = 1;
|
|
|
+ }
|
|
|
+ if (item.rdAwardsubsidy == 1) {
|
|
|
+ rdAwardsubsidy = 1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (htMember) {
|
|
|
+ newCheckType.push(1);
|
|
|
}
|
|
|
- if (item.additionalDeduction == 1) {
|
|
|
- additionalDeduction = 1;
|
|
|
+ if (additionalDeduction) {
|
|
|
+ newCheckType.push(2);
|
|
|
}
|
|
|
- if (item.rdAwardsubsidy == 1) {
|
|
|
- rdAwardsubsidy = 1;
|
|
|
+ if (rdAwardsubsidy) {
|
|
|
+ newCheckType.push(3);
|
|
|
}
|
|
|
- });
|
|
|
- if (htMember) {
|
|
|
- newCheckType.push(1);
|
|
|
- }
|
|
|
- if (additionalDeduction) {
|
|
|
- newCheckType.push(2);
|
|
|
- }
|
|
|
- if (rdAwardsubsidy) {
|
|
|
- newCheckType.push(3);
|
|
|
}
|
|
|
+
|
|
|
return newCheckType;
|
|
|
}
|
|
|
|
|
|
@@ -140,15 +143,21 @@ class newEditProject extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ let splitList = [];
|
|
|
+ if (!!dataInfor.splitList) {
|
|
|
+ splitList = dataInfor.splitList.filter(item => item.type != 3);
|
|
|
+ }
|
|
|
+ if (!!dataInfor.list) {
|
|
|
+ splitList = dataInfor.list.filter(item => item.type != 3);;
|
|
|
+ }
|
|
|
+
|
|
|
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)
|
|
|
- }
|
|
|
+ for (var i = 0; i < splitList.length; i++) {
|
|
|
+ // if (dataInfor.splitList[i].commodityId == dataInfor.commodityId) {
|
|
|
+ // llist.push(dataInfor.splitList[i].serviceYear != dataInfor.serviceYear && dataInfor.splitList[i].serviceYear)
|
|
|
+ // }
|
|
|
+ if (splitList[i].type != 3) {
|
|
|
+ llist.push(splitList[i].serviceYear)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -157,7 +166,7 @@ class newEditProject extends Component {
|
|
|
// 单边会员和简单会员
|
|
|
newCheckType = [1];
|
|
|
} else {
|
|
|
- newCheckType = this.getCheckTypeList(dataInfor.splitList);
|
|
|
+ newCheckType = this.getCheckTypeList(splitList);
|
|
|
}
|
|
|
// if (dataInfor.projectType == 1) {
|
|
|
// if (dataInfor.htMember == 1) {
|
|
|
@@ -196,8 +205,8 @@ class newEditProject extends Component {
|
|
|
contractTerm: (!dataInfor.contractTerm || (dataInfor.contractTerm.indexOf("-") == -1)) ? [] : JSON.parse(dataInfor.contractTerm), // 合同期
|
|
|
serviceYear: dataInfor.cSort == 6 ? undefined : dataInfor.serviceYear,//本次派单
|
|
|
histYear: llist, // 本次已派单
|
|
|
- oldSplitList: JSON.parse(JSON.stringify(dataInfor[children])),
|
|
|
- splitList: dataInfor[children] || [],
|
|
|
+ oldSplitList: JSON.parse(JSON.stringify(splitList)),
|
|
|
+ splitList,
|
|
|
tid: dataInfor.id, // 父级项目id
|
|
|
isMedit: readOnly ? 3 : dataInfor.cSort == 6 ? 0 : 1,// 会员项目默认0不可编辑 普通项目默认1可编辑
|
|
|
projectType: dataInfor.projectType, // 会员项目类型
|
|
|
@@ -211,6 +220,30 @@ class newEditProject extends Component {
|
|
|
}
|
|
|
|
|
|
onChange(text) {
|
|
|
+ const { flag, message } = this.validSunProTypeIsNull();
|
|
|
+ if (!flag) {
|
|
|
+ message.warning(message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const updatedList = this.getUpdatedSubProject();
|
|
|
+ let subLen = updatedList.length;
|
|
|
+ if (subLen === 0) {
|
|
|
+ this.saveParentProject();
|
|
|
+ }
|
|
|
+
|
|
|
+ updatedList.map((item) => this.handleUpdateSubProject(item, () => {
|
|
|
+ subLen -= 1;
|
|
|
+ if (subLen === 0) {
|
|
|
+ this.saveParentProject();
|
|
|
+ }
|
|
|
+ }, () => {
|
|
|
+ subLen -= 1;
|
|
|
+ this.saveParentProject();
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ saveParentProject() {
|
|
|
const { type = "", dataInfor } = this.props
|
|
|
if (isNaN(parseFloat(this.state.commodityPrice))) {
|
|
|
message.warning("请输入正确的金额!");
|
|
|
@@ -310,6 +343,8 @@ class newEditProject extends Component {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
this.setState({
|
|
|
loading: true,
|
|
|
});
|
|
|
@@ -346,9 +381,10 @@ class newEditProject extends Component {
|
|
|
// infor.serviceYear = this.state.serviceYear //本次派单年份
|
|
|
infor.contractTerm = JSON.stringify(this.state.contractTerm)//合同期
|
|
|
if (this.state.projectType == 1) {
|
|
|
- infor.htMember = this.state.checkType.includes(1) ? 1 : 0
|
|
|
- infor.additionalDeduction = this.state.checkType.includes(2) ? 1 : 0
|
|
|
- infor.rdAwardsubsidy = this.state.checkType.includes(3) ? 1 : 0
|
|
|
+ const checkType = this.getCheckTypeList(this.state.oldSplitList);
|
|
|
+ infor.htMember = checkType.includes(1) ? 1 : 0
|
|
|
+ infor.additionalDeduction = checkType.includes(2) ? 1 : 0
|
|
|
+ infor.rdAwardsubsidy = checkType.includes(3) ? 1 : 0
|
|
|
}
|
|
|
}
|
|
|
if (this.state.isVip == 3) { //科技项目
|
|
|
@@ -382,7 +418,7 @@ class newEditProject extends Component {
|
|
|
});
|
|
|
if (!data.error.length) {
|
|
|
message.success("保存成功!");
|
|
|
- this.loopPostUpdateSubProject();
|
|
|
+
|
|
|
if (this.state.isVip == 6) {
|
|
|
text == "submit" &&
|
|
|
this.setState({
|
|
|
@@ -396,9 +432,6 @@ class newEditProject extends Component {
|
|
|
}
|
|
|
}.bind(this)
|
|
|
);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
getpatentTypeList() {
|
|
|
@@ -605,6 +638,7 @@ class newEditProject extends Component {
|
|
|
this.updateMemberSonProject(this.state.recoveryId, this.state.taskComment)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
this.setState({
|
|
|
loading: true,
|
|
|
});
|
|
|
@@ -675,15 +709,30 @@ class newEditProject extends Component {
|
|
|
return updatedList;
|
|
|
}
|
|
|
|
|
|
- loopPostUpdateSubProject() {
|
|
|
+ // 验证子项目是否有会员类型为空的情况
|
|
|
+ validSunProTypeIsNull() {
|
|
|
const updatedList = this.getUpdatedSubProject();
|
|
|
- updatedList.map((item) => {
|
|
|
- this.handleUpdateSubProject(item)
|
|
|
- });
|
|
|
+ let flag = true; // 判断是否有子项,会员类型都为空,如果存在,则不进行批量更新
|
|
|
+ let messageText = "";
|
|
|
+
|
|
|
+ for (let i=0; i<updatedList.length; i++) {
|
|
|
+ let item = updatedList[i];
|
|
|
+ if (item.htMember != 1 && item.additionalDeduction != 1 && item.rdAwardsubsidy != 1) {
|
|
|
+ flag = false;
|
|
|
+ messageText = `${item.serviceYear}会员类型不能为空!`
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return { flag, message: messageText }
|
|
|
}
|
|
|
|
|
|
+ // loopPostUpdateSubProject() {
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
// 修改子项目
|
|
|
- handleUpdateSubProject(item) {
|
|
|
+ handleUpdateSubProject(item, succCallback, errCallback) {
|
|
|
const { type } = this.props;
|
|
|
let prams = {
|
|
|
[type === "change" ? "id" : "tid"]: item.id,
|
|
|
@@ -703,21 +752,28 @@ class newEditProject extends Component {
|
|
|
success: res => {
|
|
|
if (!res.error.length) {
|
|
|
const { splitList, oldSplitList } = this.state;
|
|
|
- // 更新项目的会员类型
|
|
|
- let checkType = this.getCheckTypeList(splitList);
|
|
|
- // 更新初始的子项目列表
|
|
|
+ // 更新原始的子项目列表,便于计算后续改动的会员类型
|
|
|
let oldSplitIdx = oldSplitList.findIndex(oldItem => oldItem.id === item.id)
|
|
|
+ oldSplitIdx
|
|
|
if (oldSplitIdx > -1) {
|
|
|
- oldSplitList[oldSplitIdx] = item;
|
|
|
+ oldSplitList[oldSplitIdx] = JSON.parse(JSON.stringify(item));
|
|
|
}
|
|
|
+
|
|
|
+ // 更新项目的会员类型
|
|
|
+ let checkType = this.getCheckTypeList(oldSplitList);
|
|
|
this.setState({
|
|
|
checkType,
|
|
|
oldSplitList
|
|
|
+ }, () => {
|
|
|
+ succCallback && succCallback();
|
|
|
});
|
|
|
} else {
|
|
|
+ errCallback && errCallback();
|
|
|
message.error(res.error[0].message);
|
|
|
}
|
|
|
}
|
|
|
+ }).catch(err => {
|
|
|
+ errCallback && errCallback();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -1789,7 +1845,7 @@ class newEditProject extends Component {
|
|
|
}}
|
|
|
>
|
|
|
<Select
|
|
|
- mode="tags"
|
|
|
+ mode="multiple"
|
|
|
style={{ width: '200px', marginRight: 50 }}
|
|
|
placeholder="请选择年份"
|
|
|
onChange={e => {
|