From e6a10ced1ed8db39486dc0a1795191c701ef3224 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 20 十二月 2021 18:11:35 +0800 Subject: [PATCH] 2021-12-20 --- src/utils/utils.js | 69 ++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 0 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index c777212..53170d2 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -2040,6 +2040,75 @@ } /** + * @description 鑾峰彇鏍囪淇℃伅 + */ +export function getMark (marks, record, style = {}) { + let icon = null + let color = null + let position = null + + marks.some(mark => { + let originVal = record[mark.field[0]] + '' + let contrastVal = '' + let result = false + + if (mark.field[1] === 'static') { + contrastVal = mark.contrastValue + '' + } else { + contrastVal = record[mark.field[2]] + '' + } + + if (mark.match === '=') { + result = originVal === contrastVal + } else if (mark.match === '!=') { + result = originVal !== contrastVal + } else if (mark.match === 'like') { + result = originVal.indexOf(contrastVal) > -1 + } else if (mark.match === '>') { + result = parseFloat(originVal) > parseFloat(contrastVal) + } else if (mark.match === '<') { + result = parseFloat(originVal) < parseFloat(contrastVal) + } + + if (!result) return false + + let type = mark.signType[0] + + if (type === 'font') { + style.color = mark.color + } else if (type === 'background') { + style.background = mark.color + if (mark.fontColor) { + style.color = mark.fontColor + } + } else if (type === 'underline') { + style.textDecoration = 'underline' + style.color = mark.color + } else if (type === 'line-through') { + style.textDecoration = 'line-through' + style.color = mark.color + } else if (type.indexOf('icon') > -1) { + icon = mark.signType[mark.signType.length - 1] + color = mark.color + if (type === 'iconfront' || mark.signType[1] === 'front') { + position = 'front' + } else { + position = 'back' + } + } + + return true + }) + + return { + style, + icon, + color, + position + } +} + +/** * @description 鐢熸垚鏇挎崲鍑芥暟鍒楄〃 */ export function setGLOBFuncs () { -- Gitblit v1.8.0