469 lines
15 KiB
JavaScript
469 lines
15 KiB
JavaScript
//<editor-fold desc="法务预算审核流程 明细表数据计算(╰_╯)#o(≧口≦)o">
|
||
//#region 法务预算审核流程 明细表数据计算
|
||
|
||
/**
|
||
* 转换字段名为字段id
|
||
* @param fieldName 字段名
|
||
* @param detail 表
|
||
* @returns {*} 字段id
|
||
*/
|
||
function convertField2Id(fieldName, detail = "main") {
|
||
return WfForm.convertFieldNameToId(fieldName, detail)
|
||
}
|
||
|
||
/**
|
||
* 统计第一个明细表数据
|
||
* @returns {Map} 整理后的明细数据
|
||
*/
|
||
function statisticalDetailTableData() {
|
||
let config = {
|
||
groupField: "sqrbm",
|
||
sumField: 'fyygrmb',
|
||
detailTable: 'formtable_main_173_dt1',
|
||
detailTableSimple: 'detail_1'
|
||
}
|
||
let sumMap = new Map()
|
||
let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(",");
|
||
for (let i = 0; i < rowArr.length; i++) {
|
||
let rowIndex = rowArr[i];
|
||
let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple)
|
||
let groupFieldId = groupFieldMark + "_" + rowIndex
|
||
// 获取值
|
||
let groupFieldValue = WfForm.getFieldValue(groupFieldId)
|
||
let groupFieldValueObj = WfForm.getFieldValueObj(groupFieldId)
|
||
let sumFieldMark = convertField2Id(config.sumField, config.detailTableSimple)
|
||
let sumFieldId = sumFieldMark + "_" + rowIndex
|
||
// 获取值
|
||
let sumFieldValue = parseInt(WfForm.getFieldValue(sumFieldId) === "" ? 0 : WfForm.getFieldValue(sumFieldId))
|
||
if (sumMap.has(groupFieldValue)) {
|
||
sumMap.get(groupFieldValue).sum += sumFieldValue
|
||
} else {
|
||
let obj = {
|
||
value: groupFieldValueObj,
|
||
sum: sumFieldValue
|
||
}
|
||
sumMap.set(groupFieldValue, obj)
|
||
}
|
||
}
|
||
return sumMap
|
||
}
|
||
|
||
/**
|
||
* 第二个明细表赋值
|
||
* @param sumMap 整理后的明细数据
|
||
*/
|
||
function assignmentDetailTable2(sumMap) {
|
||
let config = {
|
||
groupField: "sqrbm",
|
||
sumField: 'fyygrmbxj',
|
||
detailTable: 'formtable_main_173_dt2',
|
||
detailTableSimple: 'detail_2'
|
||
}
|
||
// 删除所有信息
|
||
|
||
if ((WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? "") !== "") {
|
||
return
|
||
// WfForm.delDetailRow(config.detailTableSimple, "all");
|
||
}
|
||
// 赋值
|
||
sumMap.forEach((value, key) => {
|
||
let valueObj = {
|
||
[convertField2Id(config.groupField, config.detailTableSimple)]: value.value,
|
||
[convertField2Id(config.sumField, config.detailTableSimple)]: {
|
||
value: value.sum
|
||
},
|
||
}
|
||
WfForm.addDetailRow(config.detailTableSimple, valueObj);
|
||
})
|
||
}
|
||
|
||
$(() => {
|
||
//页面加载时执行一次
|
||
let sumMap = statisticalDetailTableData()
|
||
assignmentDetailTable2(sumMap)
|
||
})
|
||
/**
|
||
* 注册监听提交和保存事件
|
||
*/
|
||
WfForm.registerCheckEvent(WfForm.OPER_SAVE + "," + WfForm.OPER_SUBMIT, function (callback) {
|
||
let sumMap = statisticalDetailTableData()
|
||
assignmentDetailTable2(sumMap)
|
||
callback();
|
||
});
|
||
|
||
|
||
//#endregion
|
||
// </editor-fold>(╰_╯)#(╰_╯)#
|
||
|
||
// ================================================================================
|
||
|
||
//<editor-fold desc="法务预算审核流程 法务VP节点VP审核节点计算 明细表数据计算(╰_╯)#o(≧口≦)o">
|
||
//#region
|
||
|
||
/**
|
||
* 转换字段名为字段id
|
||
* @param fieldName 字段名
|
||
* @param detail 表
|
||
* @returns {*} 字段id
|
||
*/
|
||
function convertField2Id(fieldName, detail = "main") {
|
||
return WfForm.convertFieldNameToId(fieldName, detail)
|
||
}
|
||
|
||
/**
|
||
* 绑定明细表发生变化时触发并执行计算逻辑
|
||
*/
|
||
function bindDetailFieldChange() {
|
||
let config = {
|
||
changeField: 'fyygrmb',
|
||
detailTable: 'formtable_main_173_dt1',
|
||
detailTableSimple: 'detail_1'
|
||
}
|
||
WfForm.bindDetailFieldChangeEvent(convertField2Id(config.changeField, config.detailTableSimple), () => {
|
||
let sumMap = statisticalDetailTableData()
|
||
assignmentDetailTable2(sumMap)
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 统计第一个明细表数据
|
||
* @returns {Map} 整理后的明细数据
|
||
*/
|
||
function statisticalDetailTableData() {
|
||
let config = {
|
||
groupField: "sqrbm",
|
||
sumField: 'fyygrmb',
|
||
detailTable: 'formtable_main_173_dt1',
|
||
detailTableSimple: 'detail_1'
|
||
}
|
||
let sumMap = new Map()
|
||
let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(",");
|
||
for (let i = 0; i < rowArr.length; i++) {
|
||
let rowIndex = rowArr[i];
|
||
let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple)
|
||
let groupFieldId = groupFieldMark + "_" + rowIndex
|
||
// 获取值
|
||
let groupFieldValue = WfForm.getFieldValue(groupFieldId)
|
||
let sumFieldMark = convertField2Id(config.sumField, config.detailTableSimple)
|
||
let sumFieldId = sumFieldMark + "_" + rowIndex
|
||
// 获取值
|
||
let sumFieldValue = parseInt(WfForm.getFieldValue(sumFieldId) === "" ? 0 : WfForm.getFieldValue(sumFieldId))
|
||
if (sumMap.has(groupFieldValue)) {
|
||
let sumValue = sumMap.get(groupFieldValue) + sumFieldValue
|
||
sumMap.set(groupFieldValue, sumValue)
|
||
} else {
|
||
sumMap.set(groupFieldValue, sumFieldValue)
|
||
}
|
||
}
|
||
return sumMap
|
||
}
|
||
|
||
/**
|
||
* 第二个明细表赋值
|
||
* @param sumMap 整理后的明细数据
|
||
*/
|
||
function assignmentDetailTable2(sumMap) {
|
||
let config = {
|
||
groupField: "sqrbm",
|
||
sumField: 'fyygrmbxj',
|
||
detailTable: 'formtable_main_173_dt2',
|
||
detailTableSimple: 'detail_2'
|
||
}
|
||
|
||
// 赋值
|
||
let valueObj = {}
|
||
let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(",");
|
||
for (let i = 0; i < rowArr.length; i++) {
|
||
let rowIndex = rowArr[i];
|
||
let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple)
|
||
let groupFieldId = groupFieldMark + "_" + rowIndex
|
||
// 获取值
|
||
let groupFieldValue = WfForm.getFieldValue(groupFieldId)
|
||
sumMap.forEach((value, key) => {
|
||
if (groupFieldValue == key) {
|
||
valueObj[convertField2Id(config.sumField, config.detailTableSimple) + "_" + rowIndex] = {value: value}
|
||
}
|
||
})
|
||
}
|
||
WfForm.changeMoreField(valueObj);
|
||
}
|
||
|
||
$(() => {
|
||
//页面加载时执行一次
|
||
bindDetailFieldChange()
|
||
})
|
||
|
||
|
||
//#endregion
|
||
// </editor-fold>(╰_╯)#(╰_╯)#
|
||
|
||
// ================================================================================
|
||
|
||
//<editor-fold desc="法务预算审核流程 明细表数据计算, <( ̄ ﹌  ̄)@m 折算">
|
||
|
||
/**
|
||
* 转换字段名为字段id
|
||
* @param fieldName 字段名
|
||
* @param detail 表
|
||
* @returns {*} 字段id
|
||
*/
|
||
function convertField2Id(fieldName, detail = "main") {
|
||
return WfForm.convertFieldNameToId(fieldName, detail)
|
||
}
|
||
|
||
|
||
/**
|
||
* 根据明细2中的折扣还是啥,不清楚,计算明细1中的实际钱?
|
||
* @param discountMap
|
||
*/
|
||
function calculateDiscountDetail1(discountMap) {
|
||
let config = {
|
||
groupField: "sqrbm",
|
||
discountField: 'spys',
|
||
costCountField: 'fyygrmb',
|
||
detailTable: 'formtable_main_173_dt1',
|
||
detailTableSimple: 'detail_1'
|
||
}
|
||
let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(",");
|
||
let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple)
|
||
let discountFieldMark = convertField2Id(config.discountField, config.detailTableSimple)
|
||
let costCountFieldMark = convertField2Id(config.costCountField, config.detailTableSimple)
|
||
for (let i = 0; i < rowArr.length; i++) {
|
||
let groupFieldId = groupFieldMark + "_" + rowArr[i]
|
||
let discountFieldId = discountFieldMark + "_" + rowArr[i]
|
||
let costCountFieldId = costCountFieldMark + "_" + rowArr[i]
|
||
let groupFieldValue = WfForm.getFieldValue(groupFieldId)
|
||
let costCountFieldValue = parseInt(WfForm.getFieldValue(costCountFieldId) === "" ? 0 : WfForm.getFieldValue(costCountFieldId))
|
||
// console.log(discountMap.get(groupFieldValue) * costCountFieldValue)
|
||
//修改值
|
||
WfForm.changeFieldValue(discountFieldId, {
|
||
value: discountMap[groupFieldValue] * costCountFieldValue
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取明细表2的折扣啥的不知道,反正就是这几个字段
|
||
* @returns {{}}
|
||
*/
|
||
function getDiscountByDetail2() {
|
||
let config = {
|
||
groupField: "sqrbm",
|
||
discountField: 'spys',
|
||
detailTable: 'formtable_main_173_dt2',
|
||
detailTableSimple: 'detail_2'
|
||
}
|
||
let discountMap = {}
|
||
let rowArr = (WfForm.getDetailAllRowIndexStr(config.detailTableSimple) ?? '').split(",");
|
||
let groupFieldMark = convertField2Id(config.groupField, config.detailTableSimple)
|
||
let discountFieldMark = convertField2Id(config.discountField, config.detailTableSimple)
|
||
for (let i = 0; i < rowArr.length; i++) {
|
||
let groupFieldId = groupFieldMark + "_" + rowArr[i]
|
||
let discountFieldId = discountFieldMark + "_" + rowArr[i]
|
||
let groupFieldValue = WfForm.getFieldValue(groupFieldId)
|
||
discountMap[groupFieldValue] = parseFloat(WfForm.getFieldValue(discountFieldId) === "" ? 0 : WfForm.getFieldValue(discountFieldId)) / 100
|
||
}
|
||
return discountMap
|
||
}
|
||
|
||
/**
|
||
* 绑定明细表事件,监听字段改变时触发计算
|
||
*/
|
||
function bindEvent() {
|
||
let config = {
|
||
changeField: 'spys',
|
||
detailTable: 'formtable_main_173_dt2',
|
||
detailTableSimple: 'detail_2'
|
||
}
|
||
WfForm.bindDetailFieldChangeEvent(convertField2Id(config.changeField, config.detailTableSimple), () => {
|
||
let discountMap = getDiscountByDetail2();
|
||
calculateDiscountDetail1(discountMap)
|
||
})
|
||
}
|
||
|
||
$(() => {
|
||
//页面加载时执行一次
|
||
let discountMap = getDiscountByDetail2();
|
||
calculateDiscountDetail1(discountMap)
|
||
bindEvent()
|
||
})
|
||
// </editor-fold>
|
||
|
||
// ================================================================================
|
||
|
||
// <editor-fold desc="捐赠/赞助合作伙伴合规评估 红绿灯变颜色">
|
||
//#region 捐赠/赞助合作伙伴合规评估 红绿灯变颜色
|
||
|
||
|
||
/**
|
||
* 转换字段名为字段id
|
||
* @param fieldName 字段名
|
||
* @param detail 表
|
||
* @returns {*} 字段id
|
||
*/
|
||
function convertField2Id(fieldName, detail = "main", showPrefix = true) {
|
||
return WfForm.convertFieldNameToId(fieldName, detail, showPrefix)
|
||
}
|
||
|
||
/**
|
||
* 改变颜色逻辑处理
|
||
* @param colorMapper 颜色和值的映射关系
|
||
* @returns {(function(*=, *=): void)|*} 值改变回调函数
|
||
*/
|
||
function changeColor(colorMapper) {
|
||
return (info, compFn) => {
|
||
let value = info.fieldValue
|
||
if (value === "") {
|
||
return compFn()
|
||
}
|
||
let options = {style: {}}
|
||
colorMapper.forEach(item => {
|
||
if (item.value == value) {
|
||
options.style.background = item.color
|
||
}
|
||
})
|
||
return React.createElement("div", options, [compFn()]);
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 绑定自定义渲染事件
|
||
* @param configObj 配置对象
|
||
*/
|
||
function bindEvent(configObj) {
|
||
configObj.forEach(item => {
|
||
let colorMapper = item.colorMapper
|
||
for (let v in colorMapper) {
|
||
WfForm.proxyFieldContentComp(convertField2Id(v, item.simpleTableName, false), changeColor(colorMapper[v]));
|
||
setTimeout(()=>{
|
||
let rowArr = (WfForm.getDetailAllRowIndexStr(item.simpleTableName) ?? '').split(",");
|
||
rowArr.forEach(value=>{
|
||
console.log(convertField2Id(v, item.simpleTableName)+"_"+value)
|
||
WfForm.forceRenderField(convertField2Id(v, item.simpleTableName)+"_"+value);
|
||
})
|
||
},100)
|
||
}
|
||
})
|
||
}
|
||
|
||
$(() => {
|
||
let configObj = [{
|
||
tableName: "formtable_main_106_dt1",
|
||
simpleTableName: "detail_1",
|
||
colorMapper: {
|
||
jg: [{
|
||
value: 0,
|
||
color: 'rgb(213,0,28)'
|
||
}, {
|
||
value: 1,
|
||
color: 'rgb(255,255,0)'
|
||
}, {
|
||
value: 2,
|
||
color: 'rgb(146,208,80)'
|
||
}]
|
||
}
|
||
}, {
|
||
tableName: "formtable_main_106_dt2",
|
||
simpleTableName: "detail_2",
|
||
colorMapper: {
|
||
zzjg2: [{
|
||
value: 0,
|
||
color: 'rgb(213,0,28)'
|
||
}, {
|
||
value: 1,
|
||
color: 'rgb(255,255,0)'
|
||
}, {
|
||
value: 2,
|
||
color: 'rgb(146,208,80)'
|
||
}]
|
||
}
|
||
}]
|
||
bindEvent(configObj)
|
||
})
|
||
|
||
|
||
//#endregion
|
||
// </editor-fold>
|
||
|
||
// ================================================================================
|
||
|
||
// <editor-fold desc="发达大合同用印计算">
|
||
//#region 发达大合同用印计算
|
||
|
||
/**
|
||
* 转换字段名为字段id
|
||
* @param fieldName 字段名
|
||
* @param detail 表
|
||
* @returns {*} 字段id
|
||
*/
|
||
function convertField2Id(fieldName, detail = "main") {
|
||
return WfForm.convertFieldNameToId(fieldName, detail)
|
||
}
|
||
|
||
/**
|
||
* 修改用印类型的值
|
||
* @param config 配置信息
|
||
* @param value 需要修改的值
|
||
*/
|
||
function changeContractSelectBox(config, value) {
|
||
WfForm.changeFieldValue(convertField2Id(config.changeField), {value: value});
|
||
}
|
||
|
||
/**
|
||
* 检查是否存在法大大认证编号
|
||
* @param config 配置信息
|
||
* @returns {boolean} 是否存在
|
||
*/
|
||
function checkContractFadadaechapter(config) {
|
||
let rowArr = (WfForm.getDetailAllRowIndexStr(config.simpleTableName) ?? '').split(",");
|
||
for (let i = 0; i < rowArr.length; i++) {
|
||
let rowIndex = rowArr[i]
|
||
let fieldValue = WfForm.getFieldValue(convertField2Id(config.changeField,config.simpleTableName) + "_" + rowIndex);
|
||
if((fieldValue ?? "" ) === ""){
|
||
return false
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
/**
|
||
* 绑定提交和保存事件拦截,触发修改电子用印字段
|
||
* @param config
|
||
*/
|
||
function bindSubmitEvent(config){
|
||
WfForm.registerCheckEvent(WfForm.OPER_SAVE+","+WfForm.OPER_SUBMIT, function(callback){
|
||
let electronicSeals = checkContractFadadaechapter(config.detailConfig)
|
||
if(electronicSeals){
|
||
// 电子用印
|
||
changeContractSelectBox(config.mainConfig,0)
|
||
}else{
|
||
// 物理用印
|
||
changeContractSelectBox(config.mainConfig,1)
|
||
}
|
||
callback();
|
||
});
|
||
}
|
||
|
||
$(() => {
|
||
let config = {
|
||
mainConfig: {
|
||
tableName: "formtable_main_56",
|
||
changeField: "yylx",
|
||
simpleTableName: "main"
|
||
},
|
||
detailConfig: {
|
||
tableName: "formtable_main_56_dt1",
|
||
changeField: "fadadaechapter",
|
||
simpleTableName: "detail_1"
|
||
}
|
||
}
|
||
bindSubmitEvent(config)
|
||
})
|
||
|
||
//#endregion
|
||
// </editor-fold>
|
||
|
||
|