| 123456789101112131415161718192021222324252627282930313233343536 |
- function selectedScore(methods, assessmentMethod) {
- const method = (methods || []).find(item => String(item.assessmentMethod) === assessmentMethod)
- const option = method && (method.questionOption || []).find(item => item.questionOption === method.answer)
- return option && Number.isFinite(Number(option.number)) ? Number(option.number) : null
- }
- function validateFutureExpectation(methods) {
- const currentScore = selectedScore(methods, '1')
- const futureScore = selectedScore(methods, '2')
- if (currentScore === null || futureScore === null || futureScore < currentScore) {
- return '一年后期待分不得低于现状评分,请注意!'
- }
- return ''
- }
- const AGREEMENT_OPTIONS = {
- 1: '1-强烈不同意(Strongly disagree)',
- 2: '2-不同意(Disagree)',
- 3: '3-中立(Neutral)',
- 4: '4-同意(Agree)',
- 5: '5-完全同意(Totally agree)'
- }
- function normalizeFutureExpectationOptions(methods) {
- return (methods || []).map(method => {
- if (String(method.assessmentMethod) !== '2') return method
- return Object.assign({}, method, {
- questionOption: (method.questionOption || []).map(option => {
- const text = AGREEMENT_OPTIONS[option.number]
- return text ? Object.assign({}, option, { questionOption: text }) : option
- })
- })
- })
- }
- module.exports = { validateFutureExpectation, normalizeFutureExpectationOptions }
|