WXL
2024-05-31 49fcdb7178dffc69769e2fb8cb6a03e204cb1e68
src/views/knowledge/questionnaire/compilequer/index.vue
@@ -2,14 +2,27 @@
  <div class="Questionnairemanagement">
    <!-- 左侧栏 -->
    <div class="sidecolumn">
      <div style="height: 400px">
        <el-steps direction="vertical" :active="Editprogress">
          <el-step title="基础信息"></el-step>
          <el-step title="问卷题目"></el-step>
          <el-step
            title="问卷预览"
            description="查看问卷预览,可导出PDF"
          ></el-step>
      <div>
        <el-steps finish-status="success" :active="Editprogress" simple>
          <el-step>
            <template slot="title">
              <span style="cursor: pointer" @click="Editprogress = 1"
                >基础信息</span
              >
            </template>
          </el-step>
          <el-step>
            <template slot="title">
              <span style="cursor: pointer" @click="Editprogress = 2"
                >问卷题目</span
              >
            </template>
          </el-step>
          <el-step description="查看问卷预览,可导出PDF">
            <span slot="title" style="cursor: pointer" @click="Editprogress = 3"
              >问卷预览</span
            >
          </el-step>
        </el-steps>
      </div>
    </div>
@@ -33,14 +46,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 +283,8 @@
                <el-table-column
                  label="序号"
                  align="center"
                  key="topicid"
                  prop="topicid"
                  key="guid"
                  prop="guid"
                />
                <el-table-column
                  label="题目"
@@ -286,22 +304,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>
@@ -441,7 +470,7 @@
        >
        <el-button type="primary" @click="laststep()">上一步</el-button>
        <el-button type="info" @click="closeFm('ruleForm')">关闭</el-button>
        <el-button @click="submitForm('ruleForm')">保存题目数据</el-button>
        <el-button @click="Departmenttreatment('ruleForm')">保存题目数据</el-button>
      </div>
      <!-- 问卷预览 -->
      <div v-if="Editprogress == 3">
@@ -512,9 +541,9 @@
          :inline="true"
          label-width="98px"
        >
          <el-form-item label="标题" prop="userName">
          <el-form-item label="问题标题" prop="topic">
            <el-input
              v-model="queryParams.userName"
              v-model="queryParams.topic"
              placeholder="请输入"
              clearable
              style="width: 200px"
@@ -585,6 +614,7 @@
  compileissue,
  delQtemplateinfo,
  Followupinfo,
  issueinfo,
  getissuelist,
  deltargetillness,
  addtargetillness,
@@ -597,7 +627,7 @@
  data() {
    return {
      sidecolumnrabs: "left", //方向
      Editprogress: 2, //编辑进度
      Editprogress: 1, //编辑进度
      currentVersion: "1.2.3", //当前版本
      loading: false, // 遮罩层
      drawer: false, //控制展开
@@ -659,11 +689,12 @@
      illnessVisible: false, //指标疾病弹框
      deptOptions: [],
      optionsillness: [],
      delScriptVOList: [],
      illnesslistapi: [],
      illnesslist: [],
      tempDetpRelevanceslist: [],
      optionstag: [],
      xjxsoptions: [],
      valuetype: [],
      usable: [],
      required: [],
      mode: [], //方式
@@ -682,14 +713,30 @@
    this.languagelist = store.getters.languagelist;
    this.usable = store.getters.usable;
    this.required = store.getters.required;
    this.xjxsoptions = store.getters.xjxsoptions;
    this.valuetype = store.getters.valuetype;
    this.courtyardlist = store.getters.courtyardlist;
  },
  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 +759,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;
      });
    },
@@ -738,10 +787,14 @@
    Departmenttreatment() {
      this.ruleForm.deptNames = JSON.stringify(this.tempDetpRelevanceslist);
      console.log(this.tempDetpRelevanceslist);
      this.ruleForm.svyLibTopics = this.ruleForm.svyLibTopics.concat(
        this.delScriptVOList
      );
      console.log(this.ruleForm.svyLibTopics, "this.ruleForm.svyLibTopics");
      const result = this.tempDetpRelevanceslist.map(
        (subArr) => subArr[subArr.length - 1]
      );
      console.log(result);
      console.log(result, "result");
      // id数组查数组对象
      result.forEach((item) => {
        const condition = this.ruleForm.tempDetpRelevances.some(
@@ -760,6 +813,7 @@
      this.ruleForm.tempDetpRelevances.forEach((item) => {
        const condition = result.some((obj) => obj === item.deptId);
        if (!condition) {
          console.log(condition);
          const index = this.ruleForm.tempDetpRelevances.indexOf(item);
          this.ruleForm.tempDetpRelevances[index].delFlag = 1;
        }
@@ -768,7 +822,6 @@
      setTimeout(() => {
        this.submitForm();
      }, 1000);
      // this.submitForm();
    },
    // 下一步
    nextstep() {
@@ -810,17 +863,48 @@
    // 新增题目
    addtopic(row) {
      row.isoperation = 1;
      row.svyLibTopicoptions.forEach((item) => {
        item.isoperation = 1;
      });
      this.ruleForm.svyLibTopics.push(row);
    },
    handleDelete(row) {
      this.ruleForm.svyLibTopics.splice(
        this.ruleForm.svyLibTopics.indexOf(row),
        1
      );
      let index = this.ruleForm.svyLibTopics.indexOf(row);
      this.ruleForm.svyLibTopics.splice(index, 1);
      row.isoperation=3;
      this.delScriptVOList.push(row);
      this.sortFn();
    },
    handleUpdate(row) {
      console.log(row);
      this.topicobj = row;
      // getissuelist({ svyid: row.svyid }).then((res) => {
      // });
    },
    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);
    },
    // 修改题目信息
@@ -974,28 +1058,23 @@
<style lang="scss" scoped>
.Questionnairemanagement {
  display: flex;
  // display: flex;
}
.sidecolumn {
  width: 300px;
  min-height: 100vh;
  text-align: center;
  //   display: flex;
  //   margin-top: 20px;
  margin: 20px;
  margin-bottom: 0;
  padding: 30px;
  padding: 20px;
  background: #edf1f7;
  border: 1px solid #dcdfe6;
  -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
    0 0 6px 0 rgba(0, 0, 0, 0.04);
}
.leftvlue {
  //   display: flex;
  //   flex: 1;
  width: 80%;
  margin-top: 20px;
  //   margin: 20px;
  // //   display: flex;
  // //   flex: 1;
  // width: 80%;
  // margin-top: 20px;
  margin: 20px;
  padding: 30px;
  background: #ffff;
  border: 1px solid #dcdfe6;