乐趣区

关于javascript:js基础

calcSequence() {
            let firstLevel = 0,
                secondLevel = 0,
                thirdLevel = 0;
            const fields = this.$refs[this.pageName].fields;// 所有表单字段
            let ret = {};
            // 数组统一时,不须要从新计算
            if (this.elFieldProps.length == fields.length) {let tmpProps = fields.map((field) => field.prop);
                tmpProps.sort();
                if (tmpProps.join(",") == this.elFieldProps.join(",")) return;
            }
            console.log('calc sequence...');

            this.elFieldProps = fields.map((field) => field.prop);
            this.elFieldProps.sort();
            this.quesIds.map((quesId) => {let question = this.questions[quesId];
                let field = question.field;
                let elField = fields.find((elField) => elField.prop == field);
                if (!elField) return;
                const level = parseInt(question.level);
                if (level == 1) {
                    secondLevel = thirdLevel = 0;
                    firstLevel++;
                    ret[question.id] = this.index + '.' + firstLevel;
                } else if (level == 2) {
                    thirdLevel = 0;
                    secondLevel++;
                    ret[question.id] = this.index + '.' + firstLevel + '.' + secondLevel;
                } else if (level == 3) {
                    thirdLevel++;
                    ret[question.id] = this.index + '.' + firstLevel + '.' + secondLevel + '.' + thirdLevel;
                }
            })
            this.fullSequences = ret;
        },
退出移动版