WXL
2024-01-16 ad70f145e8bea957b41043b4a1e37ce37cc5ed1e
src/views/knowledge/questionnaire/compilequer/index.vue
@@ -33,14 +33,19 @@
              filterable
              placeholder="请选择分类"
            >
              <el-option
                class="ruleFormaa"
                v-for="item in optionsclass"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              <el-option-group
                v-for="group in optionsclass"
                :key="group.id"
                :label="group.name"
              >
              </el-option>
                <el-option
                  v-for="item in group.svyLibTitleCategoryList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-option-group>
            </el-select>
          </el-form-item>
          <el-form-item label="问卷标题" prop="name">
@@ -265,8 +270,8 @@
                <el-table-column
                  label="序号"
                  align="center"
                  key="topicid"
                  prop="topicid"
                  key="guid"
                  prop="guid"
                />
                <el-table-column
                  label="题目"
@@ -286,22 +291,33 @@
                <el-table-column
                  label="操作"
                  align="center"
                  width="200"
                  width="250"
                  class-name="small-padding fixed-width"
                >
                  <template slot-scope="scope">
                    <el-button
                      icon="el-icon-edit"
                      type="primary"
                      round
                      circle
                      @click="handleUpdate(scope.row)"
                      >修改</el-button
                    >
                    ></el-button>
                    <el-button
                      type="danger"
                      icon="el-icon-delete"
                      circle
                      @click="handleDelete(scope.row)"
                    ></el-button>
                    <el-button
                      @click="syioption(scope.row)"
                      type="success"
                      icon="el-icon-top"
                      circle
                    ></el-button>
                    <el-button
                      @click="xiayioption(scope.row)"
                      type="success"
                      icon="el-icon-bottom"
                      circle
                    ></el-button>
                  </template>
                </el-table-column>
@@ -585,6 +601,7 @@
  compileissue,
  delQtemplateinfo,
  Followupinfo,
  issueinfo,
  getissuelist,
  deltargetillness,
  addtargetillness,
@@ -597,7 +614,7 @@
  data() {
    return {
      sidecolumnrabs: "left", //方向
      Editprogress: 2, //编辑进度
      Editprogress: 1, //编辑进度
      currentVersion: "1.2.3", //当前版本
      loading: false, // 遮罩层
      drawer: false, //控制展开
@@ -687,9 +704,25 @@
  },
  methods: {
    // 公共方法---------------
    getIndexInArray(arr, obj) {
      return arr.indexOf(obj);
    },
    // 递归扁平化
    flattenArray(arr) {
      let result = [];
      arr.forEach((item) => {
        result.push(item);
        if (item.svyLibTitleCategoryList) {
          result = result.concat(
            this.flattenArray(item.svyLibTitleCategoryList)
          );
          delete item.svyLibTitleCategoryList;
        }
      });
      return result;
    },
    // -----------------------------
    // 获取数据
    getissueinfo() {
      this.id = this.$route.query.id;
@@ -712,7 +745,9 @@
      listDept(this.queryParams).then((response) => {
        this.deptList = this.handleTree(response.data, "deptId");
      });
      // 分类
      getQtemplateclassify({}).then((res) => {
        // this.optionsclass = this.flattenArray(res.rows);
        this.optionsclass = res.rows;
      });
    },
@@ -817,10 +852,37 @@
        this.ruleForm.svyLibTopics.indexOf(row),
        1
      );
      this.sortFn();
    },
    handleUpdate(row) {
      console.log(row);
      this.topicobj = row;
      getissuelist({ svyid: row.svyid }).then((res) => {
        this.topicobj = res.rows[0];
      });
    },
    syioption(row) {
      const index = this.getIndexInArray(this.ruleForm.svyLibTopics, row);
      const item = this.ruleForm.svyLibTopics.splice(index, 1)[0]; // 移除指定索引处的元素,并保存到item变量中
      this.ruleForm.svyLibTopics.splice(index - 1, 0, item); // 将item插入到索引位置的前一位
      this.sortFn();
    },
    xiayioption(row) {
      const index = this.getIndexInArray(this.ruleForm.svyLibTopics, row);
      const item = this.ruleForm.svyLibTopics.splice(index, 1)[0]; // 移除指定索引处的元素,并保存到item变量中
      this.ruleForm.svyLibTopics.splice(index + 1, 0, item); // 将item插入到索引位置的前一位
      this.sortFn();
    },
    sortFn() {
      this.ruleForm.svyLibTopics = this.ruleForm.svyLibTopics.map(
        (item, index) => {
          return {
            guid: index + 1,
            svyid: item.svyid,
            topic: item.topic,
            topicContent: item.topicContent,
          };
        }
      );
      console.log(this.ruleForm.svyLibTopics);
    },
    // 修改题目信息