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

115 lines
3.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/* ******************* 德尔格 明细物料历史数据折扣带出提示 by youhong.ai ******************* */
$(() => {
let type = {
// 等于
equalTo: (value, target) => value == target,
// 不等于
notEqual: (value, target) => value != target,
// 大于
greaterThan: (value, target) => +value > +target,
// 小于
lessThan: (value, target) => +value < +target
}
// 值类型
let valueType = {
// 固定值
fixValue: 0,
// 流程字段
field: 1
}
let config = {
// 主表填main
table: 'main',
// 明细表明细1为detail_1,明细2为detail_2
detail: 'detail_1',
redField: 'zk',
// 条件集合
conditions: [{
// 所属表
table: 'detail_1',
// 字段
field: 'wllx',
// 对比值
value: 0,
// 值的类型
valueType: valueType.fixValue,
// 值字段所在表
valueTable: '',
// 条件类型
type: type.equalTo
}, {
// 所属表
table: 'detail_1',
// 字段
field: 'zkdc',
// 对比值
value: 'zk',
// 值的类型
valueType: valueType.field,
// 值字段所在表
valueTable: 'detail_1',
// 条件类型
type: type.notEqual
}]
}
runJs()
function runJs() {
let detailAllRowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail);
let rowIndexArr = detailAllRowIndexStr.split(",");
let flag = true
rowIndexArr.forEach(rowIndex => {
if (flag) {
flag = isTrue(rowIndex)
} else {
isTrue(rowIndex)
}
})
if (!flag) {
WfForm.showConfirm("当前订单折扣不等于默认折扣");
}
}
function isTrue(rowIndex) {
let flag = true
for (let i = 0; i < config.conditions.length; i++) {
let item = config.conditions[i]
let fieldId = WfForm.convertFieldNameToId(config, item.table)
let fieldMark = `${fieldId}_${rowIndex}`
let fieldValue = WfForm.getFieldValue(fieldMark)
if (item.valueType == valueType.fixValue) {
if (item.type(fieldValue, item.value)) {
continue
}
renderRed(`${WfForm.convertFieldNameToId(config.redField, config.detail)}_${rowIndex}`)
flag = false
}
if (item.valueType == valueType.field) {
if (item.type(fieldValue, WfForm.getFieldValue(item.value, item.valueTable))) {
continue
}
renderRed(`${WfForm.convertFieldNameToId(config.redField, config.detail)}_${rowIndex}`)
flag = false
}
}
return flag
}
function renderRed(fieldMark) {
$(`#oTable0 .detail_odd_row.detail_data_row div[data-fieldmark='${fieldMark}'] .wf-form-input`).css({
color: '#FFF',
background: 'red',
})
$(`#oTable0 .detail_odd_row.detail_data_row div[data-fieldmark='${fieldMark}'] .wf-form-input input`).css({
'border-color': 'red',
background: 'red',
color: '#FFF'
})
}
})
/* ******************* 德尔格 明细物料历史数据折扣带出提示 end ******************* */