WXL
2024-05-31 49fcdb7178dffc69769e2fb8cb6a03e204cb1e68
src/views/knowledge/questionbank/particulars/index.vue
@@ -7,11 +7,37 @@
            题目设置详情
            <span style="margin-left: 30px"
              ><el-button type="primary" @click="compileissue"
                >保存</el-button
                >保 存</el-button
              ></span
            ><span style="margin-left: 30px"
              ><el-button type="success" round @click="drawer = true"
                >+选择指标</el-button
              ></span
            >
          </div>
          <div style="margin-left: 8%">
            <el-form-item label="问题分类">
              <el-select
                v-model="topicobj.categoryid"
                size="medium"
                filterable
                placeholder="请选择分类"
              >
                <el-option-group
                  v-for="group in classifylist"
                  :key="group.id"
                  :label="group.name"
                >
                  <el-option
                    v-for="item in group.svyLibTopicCategoryList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  >
                  </el-option>
                </el-option-group>
              </el-select>
            </el-form-item>
            <el-row :gutter="10">
              <el-col :span="6"
                ><el-form-item label="题目标题">
@@ -79,14 +105,14 @@
              <el-col :span="6"
                ><el-form-item label="题目类型">
                  <el-select
                    v-model="topicobj.topictype"
                    v-model="topicobj.valueType"
                    size="medium"
                    filterable
                    placeholder="请选择分类"
                  >
                    <el-option
                      class="topicobjaa"
                      v-for="item in xjxsoptions"
                      v-for="item in valuetype"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
@@ -116,9 +142,9 @@
              <el-input
                style="width: 40vw"
                type="textarea"
                id="questiontext"
                id="topicContent"
                v-model="topicobj.topicContent"
                @focus="handleInput('questiontext')"
                @focus="handleInput('topicContent')"
                placeholder="请输入标题"
              ></el-input>
            </el-form-item>
@@ -209,7 +235,7 @@
                </div>
              </el-form-item>
            </el-row>
            <el-form-item label="通知变量" prop="name">
            <!-- <el-form-item label="通知变量" prop="name">
              <div style="margin-bottom: 5px" v-for="item in variablelist">
                <el-row>
                  <el-col :span="5">
@@ -256,77 +282,74 @@
                  </div>
                </div>
              </el-col></el-row
            >
            > -->
          </div>
          <div class="headline">
            选项设置<span style="margin-left: 30px"
              ><el-button type="primary" round @click="addoption"
                >+新增</el-button
              ></span
            ><span style="margin-left: 30px"
              ><el-button type="success" round @click="drawer = true"
                >+选择指标</el-button
              ></span
          <div v-if="topicobj.valueType == 1">
            <div class="headline">
              选项设置<span style="margin-left: 30px"
                ><el-button type="primary" round @click="addoption"
                  >+新增</el-button
                ></span
              >
            </div>
            <div
              class="topicxq"
              v-for="item in topicobj.svyLibTopicoptions"
              v-if="item.isoperation != 3"
            >
          </div>
          <div
            class="topicxq"
            v-for="item in topicobj.svyLibTopicoptions"
            v-if="item.isoperation != 3"
          >
            <el-row :gutter="10">
              <el-col :span="11"
                ><el-form-item label="选项">
                  <el-input
                    type="text"
                    placeholder="请输入选项"
                    v-model="item.optioncontent"
                    show-word-limit
                  >
                  </el-input> </el-form-item
              ></el-col>
              <el-col :span="11"
                ><el-form-item label="分值">
                  <el-input
                    type="text"
                    placeholder="请输入"
                    v-model="item.score"
                    show-word-limit
                  >
                  </el-input> </el-form-item
              ></el-col>
              <el-col :span="2">
                <el-button
                  type="danger"
                  icon="el-icon-delete"
                  circle
                  @click="deletexuanx(item)"
                ></el-button>
              </el-col>
            </el-row>
              <el-row :gutter="10">
                <el-col :span="11"
                  ><el-form-item label="选项">
                    <el-input
                      type="text"
                      placeholder="请输入选项"
                      v-model="item.optioncontent"
                      show-word-limit
                    >
                    </el-input> </el-form-item
                ></el-col>
                <el-col :span="11"
                  ><el-form-item label="分值">
                    <el-input
                      type="text"
                      placeholder="请输入"
                      v-model="item.score"
                      show-word-limit
                    >
                    </el-input> </el-form-item
                ></el-col>
                <el-col :span="2">
                  <el-button
                    type="danger"
                    icon="el-icon-delete"
                    circle
                    @click="deletexuanx(item)"
                  ></el-button>
                </el-col>
              </el-row>
            <el-row :gutter="10">
              <el-form-item label="选中提示">
                <el-input
                  style="width: 40vw"
                  type="textarea"
                  autosize
                  placeholder="请输入内容"
                  v-model="item.prompt"
                >
                </el-input
              ></el-form-item>
            </el-row>
              <el-row :gutter="10">
                <el-form-item label="选中提示">
                  <el-input
                    style="width: 40vw"
                    type="textarea"
                    autosize
                    placeholder="请输入内容"
                    v-model="item.prompt"
                  >
                  </el-input
                ></el-form-item>
              </el-row>
            </div>
          </div>
        </el-form>
      </el-card>
    </div>
    <el-drawer
      title="添加题目"
      title="添加选项"
      :visible.sync="drawer"
      custom-class="demo-drawer"
      width="50%"
      width="66%"
    >
      <div class="preview-left">
        <el-form
@@ -387,7 +410,7 @@
                type="text"
                @click="selectlabel(scope.row)"
                ><span class="button-textxg"
                  ><i class="el-icon-circle-plus-outline"></i>添加</span
                  ><i class="el-icon-circle-plus-outline"></i>选择</span
                ></el-button
              >
            </template>
@@ -415,6 +438,7 @@
  compileissue,
  delissueinfo,
  Followupinfo,
  getissueclassify,
  deltargetillness,
  addtargetillness,
  getillnesslist,
@@ -467,9 +491,9 @@
      optionsillness: [],
      illnesslistapi: [],
      illnesslist: [],
      classifylist: [],
      optionstag: [],
      xjxsoptions: [],
      valuetype: [],
      usable: [],
      mode: [], //方式
    };
@@ -482,18 +506,38 @@
    this.mode = store.getters.mode;
    this.languagelist = store.getters.languagelist;
    this.usable = store.getters.usable;
    this.xjxsoptions = store.getters.xjxsoptions;
    this.valuetype = store.getters.valuetype;
    this.required = store.getters.required;
  },
  methods: {
    // 公共方法---------------
    getIndexInArray(arr, obj) {
      return arr.indexOf(obj);
    },
    // 递归扁平化
    flattenArray(arr) {
      let result = [];
      arr.forEach((item) => {
        result.push(item);
        if (item.svyLibTopicCategoryList) {
          console.log(2);
          result = result.concat(
            this.flattenArray(item.svyLibTopicCategoryList)
          );
          delete item.svyLibTopicCategoryList;
        }
      });
      return result;
    },
    // -----------------------------
    // 获取数据
    getissueinfo() {
      this.id = this.$route.query.id;
      // 分类
      getissueclassify({}).then((res) => {
        this.classifylist = res.rows;
      });
      if (!this.id) {
        return;
      }
@@ -513,6 +557,7 @@
      getillness({ outid: this.id, type: 4 }).then((res) => {
        this.illnesslist = res.rows;
      });
    },
    gettargetInfo() {
      gettargetInfo(this.queryParams).then((res) => {
@@ -592,13 +637,29 @@
    },
    // 选择指标
    selectlabel(row) {
      const labellist = row.targetoptionList;
      labellist.forEach((item) => {
        this.topicobj.svyLibTopicoptions.push({
          optioncontent: item.targetvalue,
          isoperation: 1,
        });
      });
      this.$modal
        .confirm(
          '是否选择标题为"' + row.targetname + '"的指标并替换填充问题信息?'
        )
        .then(() => {
          console.log(row);
          console.log(this.topicobj);
          this.topicobj.topic = row.targetname;
          this.topicobj.valueType = row.valueType;
          this.topicobj.topicContent = row.targetdesc;
          this.topicobj.isavailable = "0";
          this.topicobj.language = "普通话";
          this.topicobj.svyLibTopicoptions = [];
          const labellist = row.targetoptionList;
          labellist.forEach((item) => {
            this.topicobj.svyLibTopicoptions.push({
              optioncontent: item.targetvalue,
              isoperation: 1,
            });
          });
          this.drawer = false;
        })
        .catch(() => {});
    },
    // 标签-----------------
@@ -720,16 +781,17 @@
      let inputValueArr = "";
      let el = document.querySelector("#" + this.currentInputId);
      //el.selectionStart; 这就是当前光标所在的位置(字符串中字符的index)
      if (this.currentInputId == "questiontext") {
        inputValueArr = this.indexform.questiontext.split("");
      if (this.currentInputId == "topicContent") {
        inputValueArr = this.topicobj.topicContent.split("");
        console.log(123);
      } else if (this.currentInputId == "nomatchtext") {
        inputValueArr = this.indexform.nomatchtext.split("");
        inputValueArr = this.topicobj.nomatchtext.split("");
      } else if (this.currentInputId == "sliencetext") {
        inputValueArr = this.indexform.sliencetext.split("");
        inputValueArr = this.topicobj.sliencetext.split("");
      } else if (this.currentInputId == "noclearlytext") {
        inputValueArr = this.indexform.noclearlytext.split("");
        inputValueArr = this.topicobj.noclearlytext.split("");
      } else if (this.currentInputId == "submoduletext") {
        inputValueArr = this.indexform.submoduletext.split("");
        inputValueArr = this.topicobj.submoduletext.split("");
      } else {
        return;
      }
@@ -742,16 +804,16 @@
      // 把数组重新转换为字符串并赋值
      inputValueArr = inputValueArr.join("");
      console.log(inputValueArr);
      if (this.currentInputId == "questiontext") {
        this.indexform.questiontext = inputValueArr;
      if (this.currentInputId == "topicContent") {
        this.topicobj.topicContent = inputValueArr;
      } else if (this.currentInputId == "nomatchtext") {
        this.indexform.nomatchtext = inputValueArr;
        this.topicobj.nomatchtext = inputValueArr;
      } else if (this.currentInputId == "sliencetext") {
        this.indexform.sliencetext = inputValueArr;
        this.topicobj.sliencetext = inputValueArr;
      } else if (this.currentInputId == "noclearlytext") {
        this.indexform.noclearlytext = inputValueArr;
        this.topicobj.noclearlytext = inputValueArr;
      } else if (this.currentInputId == "submoduletext") {
        this.indexform.submoduletext = inputValueArr;
        this.topicobj.submoduletext = inputValueArr;
      } else {
        return;
      }