486 lines
16 KiB
JavaScript
486 lines
16 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), () => {
|
||
window.workflowCus.getLevelByScore(config)
|
||
})
|
||
window.workflowCus.getLevelByScore(config)
|
||
}, 100)
|
||
} catch (err) {
|
||
console.log(err)
|
||
}
|
||
})
|
||
|
||
/* ******************* apa流程通过apa分数字段带出level字段eng ******************* */
|
||
|
||
|
||
/* ******************* 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)
|
||
})
|
||
})
|
||
|
||
/* ******************* apa(employee)流程明细分数控制end ******************* */
|
||
|
||
|
||
/* ******************* 流程明细数据整合插入start ******************* */
|
||
|
||
$(() => {
|
||
const workflowInsertValueConfig = [
|
||
{
|
||
table: 'detail_1',
|
||
targetTable: 'detail_3',
|
||
filedMapping: [{
|
||
source: 'mbmc',
|
||
target: 'name'
|
||
}, {
|
||
source: 'mbms',
|
||
target: 'description'
|
||
}, {
|
||
source: 'zp',
|
||
target: 'score'
|
||
}, {
|
||
source: 'zwpj',
|
||
target: 'grpj'
|
||
}, {
|
||
source: 'mbmc',
|
||
target: 'ldpf'
|
||
}, {
|
||
source: 'ldpj',
|
||
target: 'ldpj'
|
||
}]
|
||
}, {
|
||
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'
|
||
}]
|
||
}
|
||
]
|
||
|
||
/**
|
||
* 执行提交时将配置中的明细表数据合并到指定的明细表中
|
||
*/
|
||
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (continueRun) => {
|
||
start()
|
||
continueRun()
|
||
})
|
||
|
||
|
||
/**
|
||
* 开始执行合并操作
|
||
*/
|
||
function start() {
|
||
let mappingResult = []
|
||
workflowInsertValueConfig.forEach(item => {
|
||
let valueMapping = getDetailValueMapping(item)
|
||
mappingResult = [...mappingResult, ...valueMapping]
|
||
})
|
||
setValue(mappingResult)
|
||
}
|
||
|
||
|
||
/**
|
||
* 设置表数据到指定的明细表中
|
||
* @param valueMapping 值映射数组
|
||
*/
|
||
function setValue(valueMapping) {
|
||
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]);
|
||
})
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 获取明细值和对应字段的映射数组
|
||
* @param configItem 配置项
|
||
* @returns {*[]} 明细字段和对应值的映射数组
|
||
*/
|
||
function getDetailValueMapping(configItem) {
|
||
let detailIdsStr = WfForm.getDetailAllRowIndexStr(configItem.table);
|
||
let detailIdArr = detailIdsStr.split(",")
|
||
let result = []
|
||
for (let i = 0; i < detailIdArr.length; i++) {
|
||
let fieldValueMapping = getValueByConfig(configItem.filedMapping, configItem.table, detailIdArr[i], configItem.targetTable)
|
||
result.push(fieldValueMapping)
|
||
}
|
||
return result
|
||
}
|
||
|
||
/**
|
||
* 通过配置数据获取值
|
||
* @param fieldMapping 字段映射规则数组
|
||
* @param tableName 表名称
|
||
* @param detailIndex 明细表下标
|
||
* @param targetTable 目标表
|
||
* @returns {*[]} 对应明细行的值数组
|
||
*/
|
||
function getValueByConfig(fieldMapping, tableName, detailIndex, targetTable) {
|
||
let result = []
|
||
fieldMapping.forEach(item => {
|
||
let fieldValue = Utils.getFiledValueByName({
|
||
fieldName: item.source,
|
||
table: tableName
|
||
}, detailIndex)
|
||
result.push({
|
||
targetField: item.target,
|
||
value: fieldValue,
|
||
targetTable: targetTable
|
||
})
|
||
})
|
||
return result
|
||
}
|
||
|
||
|
||
})
|
||
|
||
/* ******************* 流程明细数据整合插入end ******************* */
|
||
|
||
|
||
/* ******************* 当明细数据未加载完成时 控制流程提交 start ******************* */
|
||
$(() => {
|
||
const config = {
|
||
table: 'detail_1',
|
||
field: ['fj']
|
||
}
|
||
|
||
function check() {
|
||
let detailRowIndexStr = WfForm.getDetailAllRowIndexStr(config.table);
|
||
let rowIndexArr = detailRowIndexStr.split(",");
|
||
try {
|
||
rowIndexArr.forEach(item => {
|
||
config.field.forEach(field => {
|
||
let value = WfForm.getFieldValue(WfForm.convertFieldNameToId(field, <table></table>) + "_" + item)
|
||
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" //自定义取消按钮名称
|
||
});
|
||
}
|
||
})
|
||
})
|
||
/* ******************* 当明细数据未加载完成时 控制流程提交 end ******************* */ |