UNPKG

igi_orion_cignacmb

Version:

Censors words out of text

125 lines (109 loc) 4.02 kB
var CentralWidget = require('./CentralWidget'); var select = $.extend({}, CentralWidget, { //这是一个类,用 new 关键字实例化放到vm的 form 上 type: 'select', //组件的类别,用于service层动态对比配置进行实例化 candidateArray: [], additionalTips: '', setCandidateArray: function (candidateArray) { //设置候选数组。如果已选值不在候选值中,取默认值 var that = this; that.candidateArray = candidateArray; that.fix() }, fix: function () { //自动修复,防止已选项不在候选项中 var that = this; var candidateArray = that.candidateArray; var isValueInCandidateArray = false; //如果已选值不在候选值中,重置选项为空 var valueSelect = [] for (var i = 0; i < candidateArray.length; i++) { var item = candidateArray[i]; if (that.testNotEmpty(item['key']) && item.key == that.value) { isValueInCandidateArray = true; } if (that.testNotEmpty(item['id']) && item.id == that.value) { isValueInCandidateArray = true; } // if (that.selectValue == item.key) { // if (item.value != '其他') { // that.inputValue = item.value; // } else { // that.inputValue = '' // if (that.inputValue == '其他' || that.inputValue == '请选择职级') { // that.inputValue = '' // } // } // } } var testVal = that.candidateArray[0].key; if (that.testNotEmpty(testVal)) { that.defaultValue = testVal } testVal = that.candidateArray[0].id; if (that.testNotEmpty(testVal)) { that.defaultValue = testVal } if (!isValueInCandidateArray) { if (that.testNotEmpty(that.defaultValue)) { that.value = that.defaultValue; } else { that.value = "" } } // that.value = value; // avalon.log(that.value + ':执行了fix操作') }, testNotEmpty: function (testVal) { if (testVal == '0' || (testVal != '' && testVal != null && testVal != undefined)) { return true; } else { return false; } }, fixNoExistInArray: function (index) { var that = this; var flag = true; var _index = index ? index : 0; for (var x in that.candidateArray) { if (that.value == that.candidateArray[x].key) { flag = false; } } if (flag) { that.value = that.candidateArray[_index].key; } } , /** * 根据生日(年龄)决定用户可选择的选项 (for 年金项目) * @param organizationId * @param remark * @param productNo * @param birthday */ fixCandidateArrayByAge: function (organizationId, remark, productNo, birthday, startDate) { var that = this; var age = that.getAge(birthday, startDate); var candidateArray = []; if (age <= 30) { candidateArray = [55, 60, 65]; } else if (age >= 31 && age <= 35) { candidateArray = [55, 60, 65]; } else if (age >= 36 && age <= 40) { candidateArray = [55, 60, 65]; } else if (age >= 41 && age <= 45) { candidateArray = [55, 60, 65]; } else if (age >= 46 && age <= 50) { candidateArray = [60, 65]; } else if (age >= 51 && age <= 55) { candidateArray = [65]; } that.candidateArrays = candidateArray; return; } }); module.exports = select;