WXL
2024-06-21 4fffa66d14a2b2943b35aca961317f3bed6649a0
src/views/knowledge/questionnaire/compilequer/index.vue
@@ -39,28 +39,48 @@
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item label="问卷分类" prop="region">
            <el-select
              v-model="ruleForm.categoryid"
              size="medium"
              filterable
              placeholder="请选择分类"
            >
              <el-option-group
                v-for="group in optionsclass"
                :key="group.id"
                :label="group.name"
              >
                <el-option
                  v-for="item in group.svyLibTitleCategoryList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
          <el-row :gutter="10">
            <el-col :span="10">
              <el-form-item label="问卷分类" prop="region">
                <el-select
                  v-model="ruleForm.categoryid"
                  size="medium"
                  filterable
                  placeholder="请选择分类"
                >
                </el-option>
              </el-option-group>
            </el-select>
          </el-form-item>
                  <el-option-group
                    v-for="group in optionsclass"
                    :key="group.id"
                    :label="group.name"
                  >
                    <el-option
                      v-for="item in group.svyLibTemplateCategoryList"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-option-group>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item label="评价类型">
                <el-select
                  v-model="ruleForm.scoreType"
                  placeholder="请选择分类"
                >
                  <el-option
                    v-for="group in appraiselist"
                    :key="group.value"
                    :label="group.label"
                    :value="group.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="问卷标题" prop="name">
            <div style="width: 30%">
              <el-input v-model="ruleForm.svyname"></el-input>
@@ -267,19 +287,36 @@
      <div v-if="Editprogress == 2">
        <div class="leftvlue-jbxx">问卷题目设置</div>
        <el-divider></el-divider>
        <div class="addtopic">
          <el-button
            type="primary"
            icon="el-icon-plus"
            round
            @click="getaddtopiclist"
            >添加题目</el-button
          >
        <div style="display: flex; justify-content: space-between">
          <div>
            <el-button
              type="primary"
              icon="el-icon-plus"
              round
              @click="getaddtopiclist"
              >添加题目</el-button
            >
          </div>
          <div style="display: flex">
            <span
              style="
                width: 180px;
                font-size: 20px;
                font-weight: normal;
                color: red;
              "
              >问卷总分:</span
            >
            <el-input
              v-model="ruleForm.scriptScore"
              placeholder="请输入分数"
            ></el-input>
          </div>
        </div>
        <div class="presentation">
          <div class="presentation-left">
            <el-card class="box-card" style="min-height: 688px">
              <el-table v-loading="loading" :data="ruleForm.svyLibTopics">
              <el-table v-loading="loading" :data="ruleForm.svyLibScripts">
                <el-table-column
                  label="序号"
                  align="center"
@@ -287,17 +324,17 @@
                  prop="guid"
                />
                <el-table-column
                  label="题目"
                  label="题目标题"
                  align="center"
                  key="topic"
                  prop="topic"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  label="主要内容"
                  label="题目内容"
                  align="center"
                  key="topicContent"
                  prop="topicContent"
                  key="script"
                  prop="script"
                  :show-overflow-tooltip="true"
                />
@@ -393,7 +430,7 @@
                <div class="headline">选项设置</div>
                <div
                  class="topicxq"
                  v-for="item in topicobj.svyLibTopicoptions"
                  v-for="item in topicobj.svyLibTemplateTargetoptions"
                >
                  <el-row :gutter="10">
                    <el-col :span="11"
@@ -401,7 +438,7 @@
                        <el-input
                          type="text"
                          placeholder="请输入"
                          v-model="item.topicid"
                          v-model="item.id"
                          show-word-limit
                        >
                        </el-input> </el-form-item
@@ -470,7 +507,9 @@
        >
        <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">
@@ -531,7 +570,7 @@
      title="添加题目"
      :visible.sync="drawer"
      custom-class="demo-drawer"
      width="50%"
      size="50%"
    >
      <div class="preview-left">
        <el-form
@@ -541,9 +580,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"
@@ -575,8 +614,8 @@
          <el-table-column
            label="问题内容"
            align="center"
            key="topicContent"
            prop="topicContent"
            key="script"
            prop="script"
            width="200"
            :show-overflow-tooltip="true"
          />
@@ -595,6 +634,13 @@
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getaddtopiclist"
        />
      </div>
    </el-drawer>
  </div>
@@ -648,6 +694,11 @@
        { value: "topic", table: "topic" },
        { value: "topic", table: "topic" },
      ],
      appraiselist: [
        { label: "分数", value: "1" },
        { label: "ABC等级", value: "2" },
        { label: "优良等级", value: "3" },
      ],
      fileList: [
        {
@@ -689,11 +740,12 @@
      illnessVisible: false, //指标疾病弹框
      deptOptions: [],
      optionsillness: [],
      delScriptVOList: [],
      illnesslistapi: [],
      illnesslist: [],
      tempDetpRelevanceslist: [],
      optionstag: [],
      xjxsoptions: [],
      valuetype: [],
      usable: [],
      required: [],
      mode: [], //方式
@@ -708,11 +760,11 @@
  created() {
    this.gettabList();
    this.getissueinfo();
    this.mode = store.getters.mode;
    this.mode = store.getters.Askmode;
    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;
  },
@@ -726,11 +778,11 @@
      let result = [];
      arr.forEach((item) => {
        result.push(item);
        if (item.svyLibTitleCategoryList) {
        if (item.svyLibTemplateCategoryList) {
          result = result.concat(
            this.flattenArray(item.svyLibTitleCategoryList)
            this.flattenArray(item.svyLibTemplateCategoryList)
          );
          delete item.svyLibTitleCategoryList;
          delete item.svyLibTemplateCategoryList;
        }
      });
      return result;
@@ -765,6 +817,8 @@
      });
    },
    submitForm(formName) {
      this.$modal.loading("正在上传数据,请稍候...");
      this.ruleForm.labelInfo = this.dynamicTags.join(",");
      this.ruleForm.suitway = this.ruleForm.suitway.join(",");
@@ -772,12 +826,16 @@
        this.ruleForm.isoperation = 2;
        compileQtemplate(this.ruleForm).then((response) => {
          this.$modal.msgSuccess("修改成功");
          this.$modal.closeLoading();
          this.$router.go(-1);
        });
      } else {
        this.ruleForm.isoperation = 1;
        compileQtemplate(this.ruleForm).then((response) => {
          this.$modal.msgSuccess("新增成功");
          this.$modal.closeLoading();
          this.$router.go(-1);
        });
      }
@@ -786,10 +844,12 @@
    Departmenttreatment() {
      this.ruleForm.deptNames = JSON.stringify(this.tempDetpRelevanceslist);
      console.log(this.tempDetpRelevanceslist);
      this.ruleForm.svyLibScripts = this.ruleForm.svyLibScripts.concat(
        this.delScriptVOList
      );
      const result = this.tempDetpRelevanceslist.map(
        (subArr) => subArr[subArr.length - 1]
      );
      console.log(result, "result");
      // id数组查数组对象
      result.forEach((item) => {
        const condition = this.ruleForm.tempDetpRelevances.some(
@@ -803,7 +863,6 @@
          });
        }
      });
      console.log(this.ruleForm.tempDetpRelevances);
      // 数组对象查id数组
      this.ruleForm.tempDetpRelevances.forEach((item) => {
        const condition = result.some((obj) => obj === item.deptId);
@@ -813,11 +872,9 @@
          this.ruleForm.tempDetpRelevances[index].delFlag = 1;
        }
      });
      console.log(this.ruleForm.tempDetpRelevances);
      setTimeout(() => {
        this.submitForm();
      }, 1000);
      // this.submitForm();
    },
    // 下一步
    nextstep() {
@@ -859,42 +916,49 @@
    // 新增题目
    addtopic(row) {
      row.isoperation = 1;
      this.ruleForm.svyLibTopics.push(row);
      row.svyLibScriptOptions.forEach((item) => {
        item.isoperation = 1;
      });
      this.ruleForm.svyLibScripts.push(row);
      this.$modal.msgSuccess("新增成功");
    },
    handleDelete(row) {
      let index = this.ruleForm.svyLibTopics.indexOf(row);
      this.ruleForm.svyLibTopics[index].isoperation = 3;
      let index = this.ruleForm.svyLibScripts.indexOf(row);
      this.ruleForm.svyLibScripts.splice(index, 1);
      row.isoperation = 3;
      this.delScriptVOList.push(row);
      this.sortFn();
    },
    handleUpdate(row) {
      getissuelist({ svyid: row.svyid }).then((res) => {
        this.topicobj = res.rows[0];
      });
      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插入到索引位置的前一位
      const index = this.getIndexInArray(this.ruleForm.svyLibScripts, row);
      const item = this.ruleForm.svyLibScripts.splice(index, 1)[0]; // 移除指定索引处的元素,并保存到item变量中
      this.ruleForm.svyLibScripts.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插入到索引位置的前一位
      const index = this.getIndexInArray(this.ruleForm.svyLibScripts, row);
      const item = this.ruleForm.svyLibScripts.splice(index, 1)[0]; // 移除指定索引处的元素,并保存到item变量中
      this.ruleForm.svyLibScripts.splice(index + 1, 0, item); // 将item插入到索引位置的前一位
      this.sortFn();
    },
    sortFn() {
      this.ruleForm.svyLibTopics = this.ruleForm.svyLibTopics.map(
      this.ruleForm.svyLibScripts = this.ruleForm.svyLibScripts.map(
        (item, index) => {
          return {
            guid: index + 1,
            svyid: item.svyid,
            topic: item.topic,
            topicContent: item.topicContent,
            script: item.script,
            script: item.script,
          };
        }
      );
      console.log(this.ruleForm.svyLibTopics);
      console.log(this.ruleForm.svyLibScripts);
    },
    // 修改题目信息