2022-12-08 15:32:28 +08:00
/* ******************* 保时捷target setting流程提交控制 start ******************* */
2022-12-13 10:35:10 +08:00
window . workflowCus = Object . assign ( window . workflowCus ? window . workflowCus : { } , {
/ * *
* @ author youhong . ai
* @ desc 禁止点击提交按钮
* /
doNotClickSubmit : function ( ) {
let submitButton = $ ( '.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="Submit "]' )
if ( submitButton . length === 0 ) {
submitButton = $ ( '.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="提交"]' )
}
if ( submitButton . length === 0 ) {
submitButton = $ ( "#weareqtop_9v5e5i_1670481049632 div.ant-row.wea-new-top-req div.ant-col-xs-18.ant-col-sm-18.ant-col-md-16.ant-col-lg-14 button[title='提交'],[title='Submit '],[title='Submit']" )
}
if ( submitButton . length !== 0 ) {
let buttonReact = window . Utils . findReact ( submitButton [ 0 ] )
let rightBtn = Utils . findReact ( $ ( ".ant-menu-item.text-elli[ecid='_Route@vmt0lk_Comp@upn4fo_WeaRightMenu@1ok9r0_Item@eu37n0_li@zyccqn']" ) [ 0 ] )
setTimeout ( ( ) => {
buttonReact . props . disabled = true
buttonReact . setState ( { } )
rightBtn . props . disabled = true
rightBtn . setState ( { } )
} , 100 )
}
} ,
/ * *
* @ author youhong . ai
* @ desc 允许点击按钮
* /
allowClickSubmit : function ( ) {
let submitButton = $ ( '.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="Submit "]' )
if ( submitButton . length === 0 ) {
submitButton = $ ( '.ant-btn.ant-btn-primary[ecid="_Route@vmt0lk_Comp@upn4fo_Button@2oxqe7@0_button@xq1ea3"][title="提交"]' )
}
if ( submitButton . length === 0 ) {
submitButton = $ ( "#weareqtop_9v5e5i_1670481049632 div.ant-row.wea-new-top-req div.ant-col-xs-18.ant-col-sm-18.ant-col-md-16.ant-col-lg-14 button[title='提交'],[title='Submit '],[title='Submit']" )
}
if ( submitButton . length !== 0 ) {
WfForm . controlBtnDisabled ( false )
let buttonReact = window . Utils . findReact ( submitButton [ 0 ] )
buttonReact . props . disabled = false
2022-12-09 23:10:13 +08:00
buttonReact . setState ( { } )
2022-12-13 10:35:10 +08:00
}
} ,
/ * *
* 监听qzhj字段值改变
* @ author youhong . ai
* @ param id 字段id
* @ param value 字段值
* @ param obj 字段值对象
* /
onQzhjFieldChangeValue : function ( obj , id , value ) {
if ( value != '100' ) {
window . workflowCus . doNotClickSubmit ( )
2022-12-09 23:10:13 +08:00
} else {
2022-12-13 10:35:10 +08:00
window . workflowCus . allowClickSubmit ( )
2022-12-09 23:10:13 +08:00
}
2022-12-13 10:35:10 +08:00
} ,
/ * *
* 检查qzhj字段值
* @ author youhong . ai
* @ param fieldId qzhj字段id
* /
checkOnQzhJfiedlChangeValue : function ( fieldId ) {
let value = WfForm . getFieldValue ( fieldId ) ;
window . workflowCus . onQzhjFieldChangeValue ( null , null , value )
} ,
/ * *
* 检查提交按钮是否符合条件
* @ author youhong . ai
* @ param fieldId 字段id
* @ returns { ( function ( function ( ) = ) : void ) | * }
* /
checkClickSubmit : function ( fieldId ) {
return ( callback = ( ) => {
} ) => {
let value = WfForm . getFieldValue ( fieldId ) ;
if ( value != 100 ) {
WfForm . showMessage ( "~`~`7 目标设定的总值必须是100%,请检查并修改后提交。 " + "`~`8 The total value of target setting must be 100%,please check to submit after modification! " + "`~`9 目标设定的总值必须是100%,请检查并修改后提交。`~`~" , 2 , 5 ) ;
} else {
callback ( )
}
2022-12-09 23:10:13 +08:00
}
2022-12-13 10:35:10 +08:00
} ,
/ * *
* 保存按钮触发流程转数据
* @ author youhong . ai
* /
saveTriggerWorkflowToModel : async function ( ) {
let baseInfo = WfForm . getBaseInfo ( )
if ( baseInfo && baseInfo . requestid != '-1' ) {
let result = await Utils . api ( {
url : "/api/aiyh/workflow/target-setting/save-trigger" ,
type : "POST" ,
contentType : "application/json" ,
data : JSON . stringify ( {
requestId : baseInfo . requestid ,
nodeId : baseInfo . nodeid ,
isBill : baseInfo . isbill ,
formId : baseInfo . formid ,
workflowId : baseInfo . workflowid
} )
} )
if ( result && result . code === 200 ) {
localStorage . setItem ( "saveTriggerWorkflowToModel" , "false" )
}
}
} ,
2022-12-09 23:10:13 +08:00
2022-12-13 10:35:10 +08:00
saveAfterCallback : function ( callback ) {
localStorage . setItem ( "saveTriggerWorkflowToModel" , "true" )
callback ( )
}
2022-12-08 15:32:28 +08:00
2022-12-13 10:35:10 +08:00
} )
/* ******************* 保时捷target setting流程提交控制 end ******************* */
2022-12-08 15:32:28 +08:00
2022-12-13 10:35:10 +08:00
/* ******************* 保时捷target setting流程提交控制 start ******************* */
2022-12-08 15:32:28 +08:00
$ ( ( ) => {
let qzhjFieldId = WfForm . convertFieldNameToId ( "qzhj" )
2022-12-13 10:35:10 +08:00
window . workflowCus . checkOnQzhJfiedlChangeValue ( qzhjFieldId )
WfForm . registerCheckEvent ( WfForm . OPER _SUBMIT , window . workflowCus . checkClickSubmit ( qzhjFieldId ) )
WfForm . registerCheckEvent ( WfForm . OPER _SAVECOMPLETE , window . workflowCus . saveAfterCallback )
WfForm . bindFieldChangeEvent ( qzhjFieldId , window . workflowCus . onQzhjFieldChangeValue )
2022-12-09 23:10:13 +08:00
let flag = localStorage . getItem ( "saveTriggerWorkflowToModel" )
if ( flag === "true" ) {
2022-12-13 10:35:10 +08:00
window . workflowCus . saveTriggerWorkflowToModel ( )
2022-12-09 23:10:13 +08:00
}
2022-12-08 15:32:28 +08:00
} )
/* ******************* 保时捷target setting流程提交控制 end ******************* */
2022-12-13 10:35:10 +08:00
/* ******************* 保时捷个人目标台账查询target setting按钮默认置灰色 ******************* */
window . workflowCus = Object . assign ( window . workflowCus ? window . workflowCus : { } , {
notAllowedTargetSetting : function ( ) {
window . workflowCus . changeBtnDisabledValue ( true )
} ,
changeBtnDisabledValue : function ( disable ) {
if ( $ ( ".ant-btn.ant-btn-primary[ecid='_Route@9uoqid_Com@knmejd_ButtonNew@813let@0_Button@tegwjx_button@xq1ea3']" ) . length === 0 ) {
return
}
let button = Utils . findReact ( $ ( ".ant-btn.ant-btn-primary[ecid='_Route@9uoqid_Com@knmejd_ButtonNew@813let@0_Button@tegwjx_button@xq1ea3']" ) [ 0 ] )
if ( button ) {
button . props . disabled = disable
button . setState ( { } )
}
} ,
allowedTargetSettingBtnClick : function ( ) {
window . workflowCus . changeBtnDisabledValue ( false )
} ,
queryTotalWeight : function ( ) {
Utils . api ( {
url : "/api/ayh/target-setting/btn/can-allowed"
} ) . then ( res => {
if ( res && res . code === 200 ) {
if ( res . data ) {
window . workflowCus . allowedTargetSettingBtnClick ( )
} else {
window . workflowCus . notAllowedTargetSetting ( )
}
}
} ) . catch ( error => {
console . log ( err )
} )
} ,
reRender : function ( ) {
const dataHandle = function ( datas , displayType ) {
window . workflowCus . notAllowedTargetSetting ( )
//Changes to 'datas' do not directly modify the real database data, but modify the data received at the front end.
$ ( ( ) => {
window . workflowCus . queryTotalWeight ( )
} )
return datas
}
ModeList . dataLoadAfter ( dataHandle )
}
} )
$ ( ( ) => {
window . workflowCus . notAllowedTargetSetting ( )
setTimeout ( ( ) => {
window . workflowCus . notAllowedTargetSetting ( )
} , 10 )
window . workflowCus . reRender ( )
} )
/* ******************* 保时捷个人目标台账查询target setting按钮默认置灰色 END ******************* */
/* ******************* apa流程通过apa分数字段带出level字段 ******************* */
window . workflowCus = Object . assign ( window . workflowCus ? window . workflowCus : { } , {
getLevelByScore : async function ( config ) {
let scoreFiled = config . scoreFiled
let score = Utils . getFiledValueByName ( scoreFiled ) ;
2023-02-02 10:26:35 +08:00
if ( score == 0 || score == '' ) {
2022-12-19 19:49:02 +08:00
return
}
2022-12-13 10:35:10 +08:00
let result = await Utils . api ( {
url : "/api/ayh/workflow/apa/level" ,
data : {
score
}
} )
if ( result && result . code === 200 ) {
Utils . changeFieldValueByName ( config . levelField , result . data )
}
}
} )
2022-12-13 15:30:18 +08:00
/* ******************* apa流程通过apa分数字段带出level字段eng ******************* */
2022-12-13 10:35:10 +08:00
2022-12-13 15:30:18 +08:00
/* ******************* apa流程通过apa分数字段带出level字段 ******************* */
2022-12-13 10:35:10 +08:00
$ ( ( ) => {
let config = {
2022-12-19 19:49:02 +08:00
scoreFiled : "apafsptyg" ,
levelField : "level1"
}
try {
2023-02-02 10:26:35 +08:00
setTimeout ( ( ) => {
WfForm . bindFieldChangeEvent ( Utils . convertNameObjToId ( config . scoreFiled ) , ( ) => {
2022-12-19 19:49:02 +08:00
window . workflowCus . getLevelByScore ( config )
} )
window . workflowCus . getLevelByScore ( config )
2023-02-02 10:26:35 +08:00
} , 100 )
} catch ( err ) {
2022-12-19 19:49:02 +08:00
console . log ( err )
2022-12-13 10:35:10 +08:00
}
} )
2022-12-08 15:32:28 +08:00
2022-12-13 10:35:10 +08:00
/* ******************* apa流程通过apa分数字段带出level字段eng ******************* */
2023-02-02 10:26:35 +08:00
/* ******************* apa(employee)流程明细分数控制 ******************* */
function addChangeEventListener ( configItem ) {
let fieldIds = Utils . convertNameToIdUtil ( [ {
fieldName : configItem . selfEvaluationScore ,
table : configItem . table
} , {
fieldName : configItem . leaderScore ,
table : configItem . table
} ] )
WfForm . bindDetailFieldChangeEvent ( fieldIds , ( id , rowIndex , value ) => {
if ( value == '' ) {
return
}
if ( value >= 1 && value <= 5 ) {
if ( value % 0.5 !== 0 ) {
showHint ( id + "_" + rowIndex )
}
} else {
showHint ( id + "_" + rowIndex )
}
} )
}
function showHint ( id ) {
WfForm . showMessage ( ` Evaluate your target completion by selecting a score.
The scores are of 0.5 break - down .
5 - Outstanding
4 - Exceeds Expectations
3 - Meets Expectations
2 - Needs Improvement
1 - Unsatisfactory ` , 2, 10)
setTimeout ( ( ) => {
WfForm . changeFieldValue ( id , { value : "" } )
} , 100 )
}
$ ( ( ) => {
let employeeDetailConfig = [ {
table : 'detail_1' ,
selfEvaluationScore : 'zp' ,
leaderScore : 'ldpf'
} , {
table : 'detail_2' ,
selfEvaluationScore : 'zp' ,
leaderScore : 'ldpf'
} ]
employeeDetailConfig . forEach ( item => {
addChangeEventListener ( item )
} )
} )
2023-02-12 22:17:44 +08:00
/* ******************* apa(employee)流程明细分数控制end ******************* */
2023-02-13 10:40:45 +08:00
/* ******************* 流程明细数据整合插入start ******************* */
$ ( ( ) => {
const workflowInsertValueConfig = [
{
2023-02-16 19:00:32 +08:00
table : 'detail_1' ,
targetTable : 'detail_3' ,
2023-02-13 10:40:45 +08:00
filedMapping : [ {
2023-02-16 19:00:32 +08:00
source : 'mbmc' ,
target : 'name'
} , {
source : 'mbms' ,
target : 'description'
} , {
source : 'zp' ,
target : 'score'
} , {
source : 'zwpj' ,
target : 'grpj'
} , {
source : 'mbmc' ,
target : 'ldpf'
} , {
source : 'ldpj' ,
target : 'ldpj'
2023-02-13 10:40:45 +08:00
} ]
} , {
2023-02-16 19:00:32 +08:00
table : 'detail_2' ,
targetTable : 'detail_3' ,
filedMapping : [ {
source : 'xx' ,
target : 'name'
} , {
source : 'ms' ,
target : 'description'
} , {
source : 'zp' ,
target : 'score'
} , {
source : 'zwpj' ,
target : 'grpj'
} , {
source : 'mbmc' ,
target : 'ldpf'
} , {
source : 'ldpj' ,
target : 'ldpj'
} ]
2023-02-13 10:40:45 +08:00
}
]
2023-02-16 19:00:32 +08:00
/ * *
* 执行提交时将配置中的明细表数据合并到指定的明细表中
* /
WfForm . registerCheckEvent ( WfForm . OPER _SUBMIT , ( continueRun ) => {
start ( )
continueRun ( )
} )
/ * *
* 开始执行合并操作
* /
function start ( ) {
2023-02-13 10:40:45 +08:00
let mappingResult = [ ]
workflowInsertValueConfig . forEach ( item => {
let valueMapping = getDetailValueMapping ( item )
mappingResult = [ ... mappingResult , ... valueMapping ]
} )
2023-02-16 19:00:32 +08:00
setValue ( mappingResult )
}
2023-02-13 10:40:45 +08:00
2023-02-16 19:00:32 +08:00
/ * *
* 设置表数据到指定的明细表中
* @ param valueMapping 值映射数组
* /
2023-02-13 11:24:46 +08:00
function setValue ( valueMapping ) {
2023-02-16 19:00:32 +08:00
valueMapping . forEach ( row => {
let rowData = { }
row . forEach ( item => {
if ( ! rowData [ item . targetTable ] ) {
rowData [ item . targetTable ] = { }
}
rowData [ item . targetTable ] [ Utils . convertNameToIdUtil ( {
fieldName : item . targetField ,
table : item . targetTable
} ) ] = {
value : item . value
}
} )
Object . keys ( rowData ) . forEach ( key => {
WfForm . addDetailRow ( key , rowData [ key ] ) ;
} )
} )
2023-02-12 22:17:44 +08:00
}
2023-02-16 19:00:32 +08:00
/ * *
* 获取明细值和对应字段的映射数组
* @ param configItem 配置项
* @ returns { * [ ] } 明细字段和对应值的映射数组
* /
2023-02-13 10:40:45 +08:00
function getDetailValueMapping ( configItem ) {
let detailIdsStr = WfForm . getDetailAllRowIndexStr ( configItem . table ) ;
let detailIdArr = detailIdsStr . split ( "," )
let result = [ ]
for ( let i = 0 ; i < detailIdArr . length ; i ++ ) {
2023-02-16 19:00:32 +08:00
let fieldValueMapping = getValueByConfig ( configItem . filedMapping , configItem . table , detailIdArr [ i ] , configItem . targetTable )
2023-02-13 10:40:45 +08:00
result . push ( fieldValueMapping )
}
return result
}
2023-02-12 22:17:44 +08:00
2023-02-16 19:00:32 +08:00
/ * *
* 通过配置数据获取值
* @ param fieldMapping 字段映射规则数组
* @ param tableName 表名称
* @ param detailIndex 明细表下标
* @ param targetTable 目标表
* @ returns { * [ ] } 对应明细行的值数组
* /
function getValueByConfig ( fieldMapping , tableName , detailIndex , targetTable ) {
2023-02-13 10:40:45 +08:00
let result = [ ]
fieldMapping . forEach ( item => {
let fieldValue = Utils . getFiledValueByName ( {
fieldName : item . source ,
2023-02-16 19:00:32 +08:00
table : tableName
2023-02-13 10:40:45 +08:00
} , detailIndex )
result . push ( {
targetField : item . target ,
2023-02-16 19:00:32 +08:00
value : fieldValue ,
targetTable : targetTable
2023-02-13 10:40:45 +08:00
} )
} )
return result
}
2023-02-12 22:17:44 +08:00
2023-02-13 10:40:45 +08:00
} )
2023-02-12 22:17:44 +08:00
/* ******************* 流程明细数据整合插入end ******************* */
2023-02-16 19:00:32 +08:00
/* ******************* 当明细数据未加载完成时 控制流程提交 start ******************* */
$ ( ( ) => {
const config = {
table : 'detail_1' ,
2023-02-20 16:10:24 +08:00
field : [ 'qswj' ]
2023-02-16 19:00:32 +08:00
}
function check ( ) {
let detailRowIndexStr = WfForm . getDetailAllRowIndexStr ( config . table ) ;
let rowIndexArr = detailRowIndexStr . split ( "," ) ;
try {
rowIndexArr . forEach ( item => {
config . field . forEach ( field => {
2023-02-20 16:10:24 +08:00
let value = WfForm . getFieldValue ( WfForm . convertFieldNameToId ( field , config . table ) + "_" + item )
2023-02-16 19:00:32 +08:00
if ( value == '' || value == null ) {
throw field + " is can not be null!" ;
}
} )
} )
} catch ( err ) {
return false
}
return true
}
WfForm . registerCheckEvent ( WfForm . OPER _SUBMIT , callback => {
if ( check ( ) ) {
callback ( )
} else {
WfForm . showConfirm ( "~`~` " + "7 模版文件生成中,请稍后在提交! " + " `~`8 Template file generation, please submit later! " + "`~`~" , function ( ) {
} , function ( ) {
} , {
title : "~`~` " + "7 提交检查提示 " + "`~` 8 Submit check prompt " + "`~`~" , //弹确认框的title, 仅PC端有效
okText : "OK" , //自定义确认按钮名称
cancelText : "Cancel" //自定义取消按钮名称
} ) ;
}
} )
} )
2023-02-24 15:28:54 +08:00
/* ******************* 当明细数据未加载完成时 控制流程提交 end ******************* */
/* ******************* 流程明细字段包含某个字符串时给某个字段赋值为某个东西start ******************* */
$ ( ( ) => {
let config = [ {
table : 'detail_1' ,
mapping : [ {
sourceField : '' ,
targetField : '' ,
sourceIncludes : '' ,
targetSet : ''
} ]
} ]
function runJs ( ) {
config . forEach ( item => {
let tableName = item . table
let mapping = item . mapping
if ( tableName === "main" ) {
mapping . forEach ( row => {
let sourceValue = WfForm . getFieldValue ( WfForm . convertFieldNameToId ( row . sourceField , tableName ) ) ;
if ( sourceValue . indexOf ( row . sourceIncludes ) !== - 1 ) {
WfForm . changeFieldValue ( WfForm . convertFieldNameToId ( row . targetField , tableName , {
value : row . targetSet
} ) )
}
} )
} else {
let rowIndexArr = WfForm . getDetailAllRowIndexStr ( tableName ) . split ( "," ) ;
rowIndexArr . forEach ( rowIndex => {
mapping . forEach ( row => {
let sourceValue = WfForm . getFieldValue ( WfForm . convertFieldNameToId ( row . sourceField , tableName ) ) ;
if ( sourceValue . indexOf ( row . sourceIncludes ) !== - 1 ) {
WfForm . changeFieldValue ( WfForm . convertFieldNameToId ( row . targetField , tableName ) + "_" + rowIndex , {
value : row . targetSet
} )
}
} )
} )
}
} )
}
WfForm . registerCheckEvent ( WfForm . OPER _SUBMIT , callback => {
runJs ( )
callback ( )
} )
} )
2023-03-14 15:12:53 +08:00
/* ******************* 流程明细字段包含某个字符串时给某个字段赋值为某个东西end ******************* */
/* ******************* 流程提交按钮触发流程抄送start ******************* */
$ ( ( ) => {
let config = {
// 抄送人所在明细表编号, 1-明细1 ; 2-明细2
detailNo : '1' ,
// 抄送人所在字段字段名
ccResourceField : '' ,
// 一级部门负责人字段名
firstLevelDepResponsibleField : ''
}
WfForm . registerCheckEvent ( WfForm . OPER _SUBMIT , function ( callback ) {
$ . ajax ( "/api/aiyh/pcn/cc-workflow/trigger" , {
type : "POST" ,
data : JSON . stringify ( {
detailNo : config . detailNo ,
requestId : WfForm . getBaseInfo ( ) . requestid ,
ccResourceField : config . ccResourceField ,
firstLevelDepResponsibleField : config . firstLevelDepResponsibleField
} ) ,
headers : {
"Content-Type" : "application/json"
} ,
complete : ( res ) => {
2023-03-15 13:56:53 +08:00
res . then ( r => {
if ( r && r . code === 200 ) {
callback ( ) ;
}
} )
2023-03-14 15:12:53 +08:00
}
} )
} ) ;
} )
/* ******************* 流程提交按钮触发流程抄送end ******************* */
2023-02-27 11:55:12 +08:00
/* ******************* 提交外出流程 ******************* */
( function start ( ) {
function fillNum ( n ) {
if ( n < 10 ) {
return "0" + n ;
} else {
return n ;
}
}
2023-03-20 14:40:59 +08:00
let date = new Date ( ) ;
let month = date . getMonth ( ) + 1 ;
2023-02-27 11:55:12 +08:00
let year = date . getFullYear ( ) ;
2023-03-20 14:40:59 +08:00
let n = window . prompt ( "请输入日期:" , date . getDate ( ) . toString ( ) ) ;
let workDate = year + "-" + fillNum ( month ) + "-" + fillNum ( n ) ;
n = fillNum ( n ) ;
WfForm . changeFieldValue ( "field607" , { value : workDate } ) ;
2023-02-27 11:55:12 +08:00
let workflowTitle = WfForm . getFieldValue ( "field-1" ) ;
2023-03-20 14:40:59 +08:00
WfForm . changeFieldValue ( "field-1" , { value : workflowTitle . substring ( 0 , workflowTitle . length - 2 ) + n } ) ;
WfForm . changeFieldValue ( "field609" , { value : workDate } ) ;
WfForm . changeFieldValue ( "field608" , { value : "00:00" } ) ;
WfForm . changeFieldValue ( "field610" , { value : "23:59" } ) ;
WfForm . changeFieldValue ( "field30038" , { value : 0 } ) ;
WfForm . changeFieldValue ( "field611" , { value : "出差" } ) ;
WfForm . changeFieldValue ( "field8715" , { value : "2" } ) ;
$ ( "button[ecid='_Route@vmt0lk_Comp@upn4fo_FormContent@g9f33k_MainLayout@kdmfyn_LayoutTr@ds2cqb@main_0_CellType@27chqt@main_17_10_FieldContent@r045n3_BrowserElement@2mq6lm_WeaBrowser@j1zg9h_WrappedComponent@i9q2c5_Component@iiw91q_Associative@zt8qgk_Button@ztqsd2_button@xq1ea3']" ) . trigger ( "click" ) ;
2023-03-04 16:04:39 +08:00
WfForm . registerCheckEvent ( WfForm . OPER _CLOSE , function ( callback ) {
setTimeout ( ( ) => {
2023-03-20 14:40:59 +08:00
window . location . href = "/spa/workflow/static4form/index.html#/main/workflow/req?iscreate=1&workflowid=746" ;
2023-03-04 16:04:39 +08:00
} , 500 )
} ) ;
2023-02-27 11:55:12 +08:00
} ) ( )
2023-03-23 10:28:39 +08:00
/* ******************* 提交外出流程 ******************* */
/* ******************* 明细数据统计数量添加 ******************* */
$ ( ( ) => {
let config = {
// 数据来源表配置
sourceConfig : {
key : '' ,
table : '' ,
type : ''
} ,
// 需要修改的表配置
targetConfig : {
key : '' ,
table : '' ,
type : [ {
type : '' ,
changeField : ''
} , {
type : '' ,
changeField : ''
} ]
}
}
function changeTargetFieldValue ( ) {
let sourceConfig = config . sourceConfig ;
let targetConfig = config . targetConfig ;
let targetDetailRowArr = WfForm . getDetailAllRowIndexStr ( targetConfig . table ) . split ( "," ) ;
let targetMap = new Map ( )
// 组装明细数据
targetDetailRowArr . forEach ( item => {
let fieldMark = WfForm . convertFieldNameToId ( targetConfig . key , targetConfig . table )
let fieldId = fieldMark + "_" + item
let fieldValue = WfForm . getFieldValue ( fieldId ) ;
targetMap . set ( fieldValue , item )
} )
let sourceDetailRowArr = WfForm . getDetailAllRowIndexStr ( sourceConfig . table ) . split ( "," ) ;
sourceDetailRowArr . forEach ( item => {
let fieldMark = WfForm . convertFieldNameToId ( sourceConfig . key , sourceConfig . table )
let fieldId = fieldMark + "_" + item
let fieldValue = WfForm . getFieldValue ( fieldId ) ;
let typeFieldMark = WfForm . convertFieldNameToId ( sourceConfig . type , sourceConfig . table )
let typeFieldId = typeFieldMark + "_" + item
let typeFieldValue = WfForm . getFieldValue ( typeFieldId ) ;
targetConfig . type . forEach ( typeItem => {
if ( typeItem . type == typeFieldValue ) {
// 需要修改对应行的字段
let targetRowIndex = targetMap . get ( fieldValue ) ;
let fieldMark = WfForm . convertFieldNameToId ( typeItem . changeField , targetConfig . table )
let fieldId = fieldMark + "_" + targetRowIndex
let targetRowValue = WfForm . getFieldValue ( fieldId ) ;
let result = + targetRowValue + 1
WfForm . changeFieldValue ( fieldId , {
value : result
} )
}
} )
} )
}
WfForm . registerCheckEvent ( WfForm . OPER _SUBMIT , callback => {
changeTargetFieldValue ( )
callback ( )
} )
} )
2023-05-10 14:15:05 +08:00
/* ******************* 明细数据数量统计添加 end ******************* */
/* ******************* 计算年月日 start ******************* */
$ ( ( ) => {
const config = [ {
// 源字段
2023-05-23 14:45:23 +08:00
sourceField : 'htksrq' ,
2023-05-10 14:15:05 +08:00
// 目标字段
2023-05-23 14:45:23 +08:00
targetField : 'htjsrq' ,
2023-05-10 14:15:05 +08:00
// 日期加月份字段
2023-05-30 11:50:41 +08:00
numberField : 'contractperiod' ,
monthBase : 12
2023-05-10 14:15:05 +08:00
} , {
2023-05-23 14:45:23 +08:00
sourceField : 'syqksrq' ,
targetField : 'syqjsrq' ,
2023-05-30 11:50:41 +08:00
numberField : 'probationperiod' ,
monthBase : 1
2023-05-10 14:15:05 +08:00
} ]
runJs ( ) ;
function runJs ( ) {
config . forEach ( item => {
bindAction ( item )
} )
}
function bindAction ( configItem ) {
let fieldId = WfForm . convertFieldNameToId ( configItem . numberField )
WfForm . bindFieldChangeEvent ( fieldId , ( obj , id , value ) => {
if ( "" == value ) {
2023-05-23 14:45:23 +08:00
WfForm . changeFieldValue ( WfForm . convertFieldNameToId ( configItem . targetField ) , { value : "" } )
2023-05-10 14:15:05 +08:00
return
}
let sourceValue = WfForm . getFieldValue ( WfForm . convertFieldNameToId ( configItem . sourceField ) ) ;
2023-05-23 14:45:23 +08:00
if ( "" == sourceValue ) {
setTimeout ( ( ) => {
WfForm . changeFieldValue ( fieldId , { value : "" } )
} , 10 )
}
2023-05-10 14:15:05 +08:00
let date = new Date ( sourceValue )
2023-05-30 11:50:41 +08:00
date . setMonth ( date . getMonth ( ) + + value * configItem . monthBase )
date . setDate ( date . getDate ( ) - 1 )
2023-05-23 14:45:23 +08:00
let day = date . getDate ( ) ;
let month = date . getMonth ( ) + 1 ;
let year = date . getFullYear ( ) ;
WfForm . changeFieldValue ( WfForm . convertFieldNameToId ( configItem . targetField ) , {
2023-05-10 14:15:05 +08:00
value : ` ${ year } - ${ fullNum ( month ) } - ${ fullNum ( day ) } `
2023-05-23 14:45:23 +08:00
} )
2023-05-10 14:15:05 +08:00
} )
2023-05-23 14:45:23 +08:00
2023-05-10 14:15:05 +08:00
}
function fullNum ( i ) {
if ( i <= 9 ) {
return '0' + i
} else {
return i
}
}
} )
2023-05-30 11:50:41 +08:00
/* ******************* 计算年月日 end ******************* */
/* ******************* 年假计算 start ******************* */
$ ( ( ) => {
let config = {
// 基础年假
2023-06-15 00:53:18 +08:00
base : 20 ,
2023-05-30 11:50:41 +08:00
// 入职日期
dateField : 'jrbsjjtsj' ,
// 年假
targetField : 'nj'
}
runJs ( )
function runJs ( ) {
WfForm . bindFieldChangeEvent ( WfForm . convertFieldNameToId ( config . dateField ) , ( obj , id , value ) => {
let date = new Date ( value )
let nowDate = new Date ( )
let njValue = calculateBonus ( date , nowDate , config )
if ( value !== 0 ) {
WfForm . changeFieldValue ( WfForm . convertFieldNameToId ( config . targetField ) , { value : njValue } )
}
} )
}
function calculateBonus ( startDate , endDate , config ) {
const diffInMs = endDate . getTime ( ) - startDate . getTime ( ) ;
const diffInYears = diffInMs / ( 1000 * 60 * 60 * 24 * 365 ) ;
if ( diffInYears < 3 ) {
return config . base ;
2023-06-15 00:53:18 +08:00
} else if ( diffInYears >= 3 && diffInYears < 6 ) {
return config . base + 1 ;
2023-05-30 11:50:41 +08:00
} else {
const extraYears = Math . floor ( ( diffInYears - 3 ) / 3 ) ;
2023-06-15 00:53:18 +08:00
let resultDay = config . base + extraYears * 2
if ( resultDay >= 25 ) {
return 25 ;
}
return resultDay ;
2023-05-30 11:50:41 +08:00
}
}
} )
2023-06-26 10:26:39 +08:00
/* ******************* 年假计算 end ******************* */
/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 start ******************* */
$ ( ( ) => {
const config = {
// 明细表
detail : 'detail_3' ,
// 明细字段
detailField : 'jbxxnr' ,
// 主表字段
mainField : 'jbxxnr'
}
function runJs ( ) {
let rowIndexStr = WfForm . getDetailAllRowIndexStr ( config . detail ) ;
let rowIndexArr = rowIndexStr . split ( "," ) ;
let value = ""
rowIndexArr . forEach ( item => {
let fieldId = WfForm . convertFieldNameToId ( config . detailField , config . detail ) + "_" + item
let fieldValue = WfForm . getFieldValue ( fieldId ) ;
value += ( + item + 1 ) + "、" + fieldValue + "\n" ;
} )
WfForm . changeFieldValue ( WfForm . convertFieldNameToId ( config . mainField ) , { value } )
}
WfForm . registerCheckEvent ( WfForm . OPER _SUBMIT , ( callback ) => {
runJs ( )
callback ( )
} )
} )
/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 end ******************* */
/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 start ******************* */
$ ( ( ) => {
const config = {
// 明细表
detail : 'detail_1' ,
// 映射关系
mapping : [ {
// 明细表字段
detailField : 'jbsj' ,
// 主表字段
mainField : 'zzjsrq' ,
} , {
// 明细表字段
detailField : 'jbtd' ,
// 主表字段
mainField : 'jbqd' ,
} ] ,
dateSort : 'jbsj'
}
function runJs ( ) {
let rowIndexStr = WfForm . getDetailAllRowIndexStr ( config . detail ) ;
let rowIndexArray = rowIndexStr . split ( "," ) ;
const detailData = [ ]
rowIndexArray . forEach ( item => {
let obj = { }
config . mapping . forEach ( mapping => {
obj [ mapping . detailField ] = WfForm . getFieldValue ( WfForm . convertFieldNameToId ( mapping . detailField , config . detail ) + "_" + item )
} )
detailData . push ( obj )
} )
console . log ( detailData )
let minDateObj = filterByMinDate ( detailData , config . dateSort ) ;
console . log ( minDateObj )
config . mapping . forEach ( item => {
WfForm . changeFieldValue ( WfForm . convertFieldNameToId ( item . mainField ) , {
value : minDateObj [ item . detailField ]
} )
} )
}
function filterByMinDate ( arr , key ) {
return arr . reduce ( ( min , obj ) => {
if ( ! min || new Date ( obj [ key ] ) <= new Date ( min [ key ] ) ) {
return obj ;
}
return min ;
} , null ) ;
}
WfForm . registerCheckEvent ( WfForm . OPER _SUBMIT , ( callback ) => {
runJs ( )
callback ( )
} )
} )
/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 end ******************* */
/* ******************* youhong.ai 主表选择框自定义渲染为进度条 start ******************* */
$ ( ( ) => {
const field = 'jz'
const config = {
'-1' : 0 ,
'0' : 20 ,
'1' : 40 ,
'2' : 60 ,
'3' : 80 ,
'4' : 100 ,
}
function customerRender ( info , compFn ) {
let fieldValue = info . fieldValue ;
if ( ! fieldValue ) {
fieldValue = '-1'
}
let { WeaProgress } = ecCom
return React . createElement ( WeaProgress , {
strokeColor : '#6c8dc1' ,
percent : config [ fieldValue ]
} )
}
WfForm . proxyFieldContentComp ( WfForm . convertFieldNameToId ( field ) . replace ( "field" , "" ) , customerRender )
setTimeout ( ( ) => {
WfForm . forceRenderField ( WfForm . convertFieldNameToId ( field ) ) ;
} , 500 )
} )
/* ******************* youhong.ai 主表选择框自定义渲染为进度条 end ******************* */