2023-03-15 13:50:48 +08:00
|
|
|
// 主表预计付款日期
|
|
|
|
const yjfksj = WfForm.convertFieldNameToId('yjfksj');
|
|
|
|
// 主表比例
|
|
|
|
const bl = WfForm.convertFieldNameToId('bcfkbl');
|
|
|
|
// 明细要求付款日期
|
2023-05-11 15:25:53 +08:00
|
|
|
const detail3Yqfkrq = WfForm.convertFieldNameToId('yqfkrq',"detail_3");
|
2023-03-15 13:50:48 +08:00
|
|
|
// 明细本次付款比例
|
2023-05-11 15:25:53 +08:00
|
|
|
const detailBl = WfForm.convertFieldNameToId('bcfkbl',"detail_3");
|
2023-04-09 21:15:39 +08:00
|
|
|
// 关联订单
|
2023-05-11 15:25:53 +08:00
|
|
|
const relationOrder = WfForm.convertFieldNameToId("gldd");
|
2023-04-09 21:15:39 +08:00
|
|
|
// 明细4施工合同字段
|
2023-05-11 15:25:53 +08:00
|
|
|
const detail4SgField = WfForm.convertFieldNameToId("sght","detail_4");
|
2023-04-09 21:15:39 +08:00
|
|
|
// 明细4采购合同字段
|
2023-05-11 15:25:53 +08:00
|
|
|
const detail4CgField = WfForm.convertFieldNameToId("cght","detail_4");
|
2023-04-09 21:15:39 +08:00
|
|
|
// 明细4发票字段
|
2023-05-11 15:25:53 +08:00
|
|
|
const detail4FpField = WfForm.convertFieldNameToId("fpje","detail_4");
|
2023-04-09 21:15:39 +08:00
|
|
|
// 明细4合同发票金额和
|
|
|
|
let detail4Map = new Map();
|
|
|
|
// 明细3施工合同字段
|
2023-05-11 15:25:53 +08:00
|
|
|
const detail3SgField = WfForm.convertFieldNameToId("sght","detail_3");
|
2023-04-09 21:15:39 +08:00
|
|
|
// 明细3采购合同字段
|
2023-05-11 15:25:53 +08:00
|
|
|
const detail3CgField = WfForm.convertFieldNameToId("cght","detail_3");
|
2023-04-09 21:15:39 +08:00
|
|
|
// 明细3 含税金额
|
2023-05-11 15:25:53 +08:00
|
|
|
const detail3TaxField = WfForm.convertFieldNameToId("ddhsje","detail_3");
|
2023-04-09 21:15:39 +08:00
|
|
|
// 明细3以收票金额
|
2023-05-11 15:25:53 +08:00
|
|
|
const detail3YspField = WfForm.convertFieldNameToId("yspje","detail_3");
|
|
|
|
|
|
|
|
const detail3ApplyMoneyField = WfForm.convertFieldNameToId("bcfkje", "detail_3");
|
|
|
|
const detail3CgId = WfForm.convertFieldNameToId("cgddzbid", "detail_3");
|
|
|
|
const detail3Bl = WfForm.convertFieldNameToId('bcfkbl', "detail_3");
|
|
|
|
let detailBlMap = new Map();
|
|
|
|
const detail1Bl = WfForm.convertFieldNameToId('bcljfkbl', "detail_1");
|
|
|
|
const detail1CgId = WfForm.convertFieldNameToId("cgddzbid", "detail_1");
|
2023-03-15 13:50:48 +08:00
|
|
|
|
|
|
|
WfForm.registerCheckEvent(WfForm.OPER_ADDROW + "3", function (callback) {
|
|
|
|
callback();
|
2023-05-11 15:25:53 +08:00
|
|
|
setTimeout(()=>{
|
2023-04-09 21:15:39 +08:00
|
|
|
initDeatail3Date();
|
2023-05-11 15:25:53 +08:00
|
|
|
},5)
|
2023-04-09 21:15:39 +08:00
|
|
|
});
|
2023-05-11 15:25:53 +08:00
|
|
|
// // 关联订单变化时将明细四的合同-金额map进行初始化
|
|
|
|
// WfForm.bindFieldChangeEvent(relationOrder, function(obj,id,value){
|
|
|
|
// setTimeout(()=>{
|
|
|
|
// initDetail4Map();
|
|
|
|
// changeDetail3SpMoney();
|
|
|
|
// },2000);
|
|
|
|
// });
|
|
|
|
|
2023-04-09 21:15:39 +08:00
|
|
|
WfForm.bindFieldChangeEvent(relationOrder, function (obj, id, value) {
|
|
|
|
setTimeout(() => {
|
|
|
|
initDetail4Map();
|
|
|
|
changeDetail3SpMoney();
|
2023-05-11 15:25:53 +08:00
|
|
|
changeDetail1ApplyAMount();
|
|
|
|
}, 2000);
|
|
|
|
});
|
|
|
|
WfForm.bindDetailFieldChangeEvent(detail3ApplyMoneyField, function () {
|
|
|
|
setTimeout(() => {
|
|
|
|
changeDetail1ApplyAMount();
|
2023-04-09 21:15:39 +08:00
|
|
|
}, 2000);
|
2023-03-15 13:50:48 +08:00
|
|
|
});
|
|
|
|
|
2023-05-11 15:25:53 +08:00
|
|
|
WfForm.bindFieldChangeEvent(`${yjfksj},${bl}`, function(obj,id,value){
|
2023-03-15 13:50:48 +08:00
|
|
|
initDeatail3Date();
|
|
|
|
});
|
|
|
|
|
2023-04-09 21:15:39 +08:00
|
|
|
// 计算明细三开票金额
|
2023-05-11 15:25:53 +08:00
|
|
|
function changeDetail3SpMoney(){
|
2023-04-09 21:15:39 +08:00
|
|
|
let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
|
|
|
|
for (let i = 0; i < detail3RowArr.length; i++) {
|
|
|
|
let rowIndex = detail3RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
|
|
|
let detail3SgFieldVal = WfForm.getFieldValue(`${detail3SgField}_${rowIndex}`);
|
|
|
|
let detail3CgFieldVal = WfForm.getFieldValue(`${detail3CgField}_${rowIndex}`);
|
|
|
|
let fpje = detail4Map.get(detail3SgFieldVal) ?? detail4Map.get(detail3CgFieldVal);
|
|
|
|
let mapVal = detail4Map.get(detail3SgFieldVal);
|
|
|
|
let key = detail3SgFieldVal;
|
2023-05-11 15:25:53 +08:00
|
|
|
if(!mapVal){
|
2023-04-09 21:15:39 +08:00
|
|
|
key = detail3CgFieldVal;
|
|
|
|
}
|
|
|
|
console.log('key ', key);
|
2023-05-11 15:25:53 +08:00
|
|
|
if(fpje){
|
2023-04-09 21:15:39 +08:00
|
|
|
console.log('fpje => ', fpje);
|
2023-05-11 15:25:53 +08:00
|
|
|
// 0.1 0.3
|
2023-04-09 21:15:39 +08:00
|
|
|
let detail3TaxVal = WfForm.getFieldValue(`${detail3TaxField}_${rowIndex}`);
|
|
|
|
console.log('detail3TaxVal => ', detail3TaxVal);
|
|
|
|
let tempJe = fpje - detail3TaxVal;
|
|
|
|
console.log('tempJe => ', tempJe);
|
2023-05-11 15:25:53 +08:00
|
|
|
if(fpje > detail3TaxVal){
|
|
|
|
WfForm.changeFieldValue(`${detail3YspField}_${rowIndex}`,{value: detail3TaxVal});
|
|
|
|
}else if(tempJe <= 0 && fpje == 0){
|
|
|
|
WfForm.changeFieldValue(`${detail3YspField}_${rowIndex}`,{value: 0});
|
|
|
|
}else if(tempJe < 0){
|
|
|
|
WfForm.changeFieldValue(`${detail3YspField}_${rowIndex}`,{value: fpje});
|
2023-04-09 21:15:39 +08:00
|
|
|
tempJe = 0;
|
|
|
|
}
|
|
|
|
detail4Map.set(key, tempJe);
|
|
|
|
console.log('detail4Map ', detail4Map)
|
2023-05-11 15:25:53 +08:00
|
|
|
}else{
|
|
|
|
WfForm.changeFieldValue(`${detail3YspField}_${rowIndex}`,{value: 0});
|
2023-04-09 21:15:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-11 15:25:53 +08:00
|
|
|
function initDeatail3Date(){
|
2023-03-15 13:50:48 +08:00
|
|
|
let dateVal = WfForm.getFieldValue(yjfksj);
|
|
|
|
let blVal = WfForm.getFieldValue(bl);
|
|
|
|
let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
|
|
|
|
for (let i = 0; i < detail3RowArr.length; i++) {
|
|
|
|
let rowIndex = detail3RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
2023-05-11 15:25:53 +08:00
|
|
|
WfForm.changeFieldValue(`${detail3Yqfkrq}_${rowIndex}`,{value: dateVal});
|
|
|
|
WfForm.changeFieldValue(`${detailBl}_${rowIndex}`,{value: blVal});
|
2023-04-09 21:15:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-11 15:25:53 +08:00
|
|
|
function initDetail4Map(){
|
2023-04-09 21:15:39 +08:00
|
|
|
let detail4RowArr = WfForm.getDetailAllRowIndexStr('detail_4').split(",");
|
|
|
|
console.log('detail4RowArr ', detail4RowArr);
|
|
|
|
for (let i = 0; i < detail4RowArr.length; i++) {
|
|
|
|
let rowIndex = detail4RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
|
|
|
let detail4SgFieldVal = WfForm.getFieldValue(`${detail4SgField}_${rowIndex}`);
|
|
|
|
let detail4CgFieldVal = WfForm.getFieldValue(`${detail4CgField}_${rowIndex}`);
|
|
|
|
let detail4FpFieldVal = WfForm.getFieldValue(`${detail4FpField}_${rowIndex}`);
|
|
|
|
let key = -1;
|
|
|
|
console.log('detail4SgFieldVal ', detail4SgFieldVal);
|
|
|
|
console.log('detail4CgFieldVal ', detail4CgFieldVal);
|
|
|
|
console.log('detail4FpFieldVal ', detail4FpFieldVal);
|
2023-05-11 15:25:53 +08:00
|
|
|
if(!detail4FpFieldVal){
|
2023-04-09 21:15:39 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
key = detail4CgFieldVal ?? detail4SgFieldVal;
|
|
|
|
console.log('key ', key);
|
|
|
|
let tempVal = parseFloat(detail4Map.get(key) ?? 0);
|
|
|
|
tempVal += parseFloat(detail4FpFieldVal);
|
|
|
|
detail4Map.set(key, tempVal);
|
2023-03-15 13:50:48 +08:00
|
|
|
}
|
|
|
|
}
|
2023-04-09 21:15:39 +08:00
|
|
|
console.log('detail4Map ', detail4Map)
|
|
|
|
}
|
|
|
|
|
2023-05-11 15:25:53 +08:00
|
|
|
|
2023-04-09 21:15:39 +08:00
|
|
|
WfForm.bindDetailFieldChangeEvent(detail3ApplyMoneyField, (id, rowIndex, value) => {
|
2023-05-11 15:25:53 +08:00
|
|
|
setTimeout(()=>{
|
|
|
|
let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
|
|
|
|
detailBlMap = new Map();
|
|
|
|
for (let i = 0; i < detail3RowArr.length; i++) {
|
|
|
|
let rowIndex = detail3RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
|
|
|
let blStr = WfForm.getFieldValue(`${detail3Bl}_${rowIndex}`);
|
|
|
|
if(blStr == ''){
|
|
|
|
console.log('111')
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
let bl = parseFloat(blStr);
|
|
|
|
console.log('bl => ' , bl);
|
|
|
|
let cg = WfForm.getFieldValue(`${detail3CgId}_${rowIndex}`);
|
|
|
|
let mapVal = detailBlMap.get(cg);
|
|
|
|
if(!mapVal){
|
|
|
|
mapVal = 0;
|
|
|
|
}
|
|
|
|
mapVal+= bl;
|
|
|
|
detailBlMap.set(cg, mapVal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('detailBlMap ', detailBlMap)
|
|
|
|
let detail1RowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
|
|
|
|
for (let i = 0; i < detail1RowArr.length; i++) {
|
|
|
|
let rowIndex = detail1RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
|
|
|
let cg = WfForm.getFieldValue(`${detail1CgId}_${rowIndex}`);
|
|
|
|
let val = detailBlMap.get(cg) === '' ? 0 : detailBlMap.get(cg);
|
|
|
|
WfForm.changeFieldValue(`${detail1Bl}_${rowIndex}`, {value: val})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},300);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 明细3合同总金额
|
|
|
|
const detail3AmountField = WfForm.convertFieldNameToId("htzje", "detail_3");
|
|
|
|
// 明细3订单号字段
|
|
|
|
const detail3OrderField = WfForm.convertFieldNameToId("ddh","detail_3");
|
|
|
|
// 明细1本次付款金额字段
|
|
|
|
const detail1ApplyAmountField = WfForm.convertFieldNameToId("bcsqfkje","detail_1");
|
|
|
|
// 明细1含税金额
|
|
|
|
const detail1AmountTaxField = WfForm.convertFieldNameToId("ddmxxj","detail_1");
|
|
|
|
// 明细1订单号
|
|
|
|
const detail1OrderField = WfForm.convertFieldNameToId("ddh","detail_1");
|
|
|
|
// 明细1预计付款日期
|
|
|
|
const detail1ApplyDate = WfForm.convertFieldNameToId("yjfkrq","detail_1");
|
|
|
|
function changeDetail1ApplyAMount(){
|
2023-04-09 21:15:39 +08:00
|
|
|
let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
|
2023-05-11 15:25:53 +08:00
|
|
|
// 明细3 订单号-合同总金额map
|
|
|
|
let detail3ContractAmountMap = new Map();
|
|
|
|
let detail3ApplyAmountMap = new Map();
|
|
|
|
let detail3ApplyMoneyField = WfForm.convertFieldNameToId("bcfkje", "detail_3");
|
2023-04-09 21:15:39 +08:00
|
|
|
for (let i = 0; i < detail3RowArr.length; i++) {
|
|
|
|
let rowIndex = detail3RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
2023-05-11 15:25:53 +08:00
|
|
|
let detail3Order = WfForm.getFieldValue(`${detail3OrderField}_${rowIndex}`);
|
|
|
|
if(!detail3ContractAmountMap.has(detail3Order)){
|
|
|
|
detail3ContractAmountMap.set(detail3Order, parseFloat(WfForm.getFieldValue(`${detail3AmountField}_${rowIndex}`)));
|
|
|
|
}
|
|
|
|
let detail3Amount = parseFloat(WfForm.getFieldValue(`${detail3ApplyMoneyField}_${rowIndex}`));
|
|
|
|
let sum = detail3ApplyAmountMap.get(detail3Order) ?? 0;
|
|
|
|
detail3ApplyAmountMap.set(detail3Order, sum + detail3Amount);
|
2023-04-09 21:15:39 +08:00
|
|
|
}
|
|
|
|
}
|
2023-05-11 15:25:53 +08:00
|
|
|
console.log('detail3ContractAmountMap : ', detail3ContractAmountMap);
|
|
|
|
console.log('detail3ApplyAmountMap : ', detail3ApplyAmountMap);
|
2023-04-09 21:15:39 +08:00
|
|
|
let detail1RowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
|
|
|
|
for (let i = 0; i < detail1RowArr.length; i++) {
|
|
|
|
let rowIndex = detail1RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
2023-05-11 15:25:53 +08:00
|
|
|
let detail1Order =WfForm.getFieldValue(`${detail1OrderField}_${rowIndex}`);
|
|
|
|
console.log('detail1Order ', detail1Order);
|
|
|
|
// 含税金额
|
|
|
|
let detail1AmountTax = parseFloat(WfForm.getFieldValue(`${detail1AmountTaxField}_${rowIndex}`) ?? 0);
|
|
|
|
console.log('detail1AmountTax ', detail1AmountTax);
|
|
|
|
// 本次付款金额和
|
|
|
|
let applySum = parseFloat(detail3ApplyAmountMap.get(detail1Order) ?? 0);
|
|
|
|
console.log('applySum ', applySum);
|
|
|
|
// 合同总金额
|
|
|
|
let contractAmount = parseFloat(detail3ContractAmountMap.get(detail1Order) ?? 0);
|
|
|
|
console.log('contractAmount ', contractAmount);
|
|
|
|
let val = (applySum / contractAmount) * detail1AmountTax;
|
|
|
|
console.log('计算金额 : ', val)
|
|
|
|
WfForm.changeFieldValue(`${detail1ApplyAmountField}_${rowIndex}`, {value: val})
|
2023-04-09 21:15:39 +08:00
|
|
|
}
|
|
|
|
}
|
2023-05-11 15:25:53 +08:00
|
|
|
}
|
|
|
|
WfForm.bindDetailFieldChangeEvent(detail3Yqfkrq,()=>{
|
|
|
|
initDetail1ApplyDate();
|
2023-04-09 21:15:39 +08:00
|
|
|
});
|
2023-05-11 15:25:53 +08:00
|
|
|
function initDetail1ApplyDate(){
|
|
|
|
let detail3RowArr = WfForm.getDetailAllRowIndexStr('detail_3').split(",");
|
|
|
|
let detail3DateMap = new Map();
|
|
|
|
for (let i = 0; i < detail3RowArr.length; i++) {
|
|
|
|
let rowIndex = detail3RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
|
|
|
let detail3Order = WfForm.getFieldValue(`${detail3OrderField}_${rowIndex}`);
|
|
|
|
if(!detail3DateMap.has(detail3Order)){
|
|
|
|
detail3DateMap.set(detail3Order, WfForm.getFieldValue(`${detail3Yqfkrq}_${rowIndex}`));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('detail3DateMap ', detail3DateMap);
|
|
|
|
let detail1RowArr = WfForm.getDetailAllRowIndexStr('detail_1').split(",");
|
|
|
|
for (let i = 0; i < detail1RowArr.length; i++) {
|
|
|
|
let rowIndex = detail1RowArr[i];
|
|
|
|
if (rowIndex !== "") {
|
|
|
|
let detail1Order =WfForm.getFieldValue(`${detail1OrderField}_${rowIndex}`);
|
|
|
|
WfForm.changeFieldValue(`${detail1ApplyDate}_${rowIndex}`, {value: detail3DateMap.get(detail1Order)})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|