ebu_ecology_dev1/javascript/youhong.ai/pcn/workflow_code_block.js

248 lines
9.0 KiB
JavaScript

/* ******************* 保时捷target setting流程提交控制 start ******************* */
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
buttonReact.setState({})
}
},
/**
* 监听qzhj字段值改变
* @author youhong.ai
* @param id 字段id
* @param value 字段值
* @param obj 字段值对象
*/
onQzhjFieldChangeValue: function (obj, id, value) {
if (value != '100') {
window.workflowCus.doNotClickSubmit()
} else {
window.workflowCus.allowClickSubmit()
}
},
/**
* 检查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()
}
}
},
/**
* 保存按钮触发流程转数据
* @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")
}
}
},
saveAfterCallback: function (callback) {
localStorage.setItem("saveTriggerWorkflowToModel", "true")
callback()
}
})
/* ******************* 保时捷target setting流程提交控制 end ******************* */
/* ******************* 保时捷target setting流程提交控制 start ******************* */
$(() => {
let qzhjFieldId = WfForm.convertFieldNameToId("qzhj")
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)
let flag = localStorage.getItem("saveTriggerWorkflowToModel")
if (flag === "true") {
window.workflowCus.saveTriggerWorkflowToModel()
}
})
/* ******************* 保时捷target setting流程提交控制 end ******************* */
/* ******************* 保时捷个人目标台账查询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);
if(score == 0 || score == ''){
return
}
let result = await Utils.api({
url: "/api/ayh/workflow/apa/level",
data: {
score
}
})
if (result && result.code === 200) {
Utils.changeFieldValueByName(config.levelField, result.data)
}
}
})
/* ******************* apa流程通过apa分数字段带出level字段eng ******************* */
/* ******************* apa流程通过apa分数字段带出level字段 ******************* */
$(() => {
let config = {
scoreFiled: "apafsptyg",
levelField: "level1"
}
try {
setTimeout(()=>{
WfForm.bindFieldChangeEvent(Utils.convertNameObjToId(config.scoreFiled),()=>{
console.log("asdfasdfasdfsadfasdf")
window.workflowCus.getLevelByScore(config)
})
window.workflowCus.getLevelByScore(config)
},100)
}catch (err){
console.log(err)
}
})
/* ******************* apa流程通过apa分数字段带出level字段eng ******************* */