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;
        },

***["definite", "public"].includes(type) --元素是否在数组中
let sets = [1,4,6,4,4,6,9];
console.log(Array.from(new Set(sets)))  --数组去重
const arr = [
        "young",
        "direct",
        "indirect",
        "sense",
        "c3",
        "public",
        "definite",
        "useMethod",
        "device",
      ];
      let has = {};
      --arr map()的使用
      arr.map((key) => {
        let field = "has" + key.slice(0, 1).toUpperCase() + key.slice(1);
        has[field] = this.has(key);
      });
二级联动的使用

computed: {
    firstCats() {
      return this.options.templateCat.filter((cat) => cat.pid == 0);
    },
    secondCats() {
      let pid = this.dataItem.bCatId;//一级联动的选择后就获取到了bCatId
      if (!pid) return [];
      return this.options.templateCat.filter((cat) => cat.pid == pid);
    },
  },

兰亭
3 声望0 粉丝

认识的人越多,我就越喜欢狗