WXL
2024-08-01 41b1f5280255ac539e40d4cd794532ae1829ce17
src/views/knowledge/questionbank/particulars/index.vue
@@ -6,6 +6,9 @@
          <div class="headline">
            题目设置详情
            <span style="float: right; margin-right: 30px"
              ><el-button type="success" @click="Saveproblem">预览</el-button>
            </span>
            <span style="float: right; margin-right: 30px"
              ><el-button type="primary" @click="Saveproblem">保 存</el-button>
            </span>
          </div>
@@ -88,7 +91,7 @@
                  </el-select> </el-form-item
              ></el-col>
              <el-col :span="8"
                ><el-form-item label="语言(缺)">
                ><el-form-item label="语言">
                  <el-select
                    v-model="topicobj.language"
                    size="medium"
@@ -146,11 +149,9 @@
              <el-col :span="8"
                ><el-form-item label="适用方式">
                  <el-select
                    v-model="suitwaylist"
                    size="medium"
                    filterable
                    multiple
                    placeholder="请选择分类"
                    v-model="topicobj.suitway"
                    disabled
                    placeholder="请选择"
                  >
                    <el-option
                      class="topicobjaa"
@@ -187,11 +188,15 @@
                  class="upload-demo"
                  :action="uploadImgUrl"
                  :headers="headers"
                  :accept="'image/*,video/*'"
                  accept=".jpg,.png,image/*"
                  :on-success="handleChangetg"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">
                    只能上传jpg/png类型文件
                  </div>
                </el-upload>
                <div style="margin: 20px">
                  <el-image
                    style="width: 100px; height: 100px"
@@ -207,14 +212,14 @@
              <el-form-item label="标签" prop="desc">
                <div class="xinz-inf">
                  <el-tag
                    :key="tag"
                    :key="tag.tagname"
                    type="success"
                    v-for="tag in dynamicTags"
                    closable
                    :disable-transitions="false"
                    @close="handleClosetag(tag)"
                  >
                    {{ tag }}
                    {{ tag.tagname }}
                  </el-tag>
                  <el-select
                    v-model="inputValue"
@@ -247,7 +252,7 @@
                </div>
              </el-form-item>
            </el-row>
            <el-row>
            <!-- <el-row>
              <el-form-item label="适用疾病" prop="region">
                <div class="xinz-inf">
                  <el-tag
@@ -289,19 +294,26 @@
                  >
                </div>
              </el-form-item>
            </el-row>
            </el-row> -->
            <el-form-item label="选中指标:">
              <span style="margin-left: 30px"
                ><el-tag type="success" effect="dark">{{
                  topicobj.targetname ? topicobj.targetname : "未选择"
                }}</el-tag></span
              >
              <span style="margin-left: 30px"
                ><el-button type="success" round @click="gettargetInfo"
                  >+选择指标</el-button
                ></span
              >
            </el-form-item>
          </div>
          <div v-if="topicobj.scriptType != 3">
          <div v-if="topicobj.scriptType != 3 && topicobj.scriptType != 4">
            <div class="headline">
              选项设置<span style="margin-left: 30px"
                ><el-button type="primary" round @click="addoption"
                  >+新增</el-button
                ></span
              >
              <span style="margin-left: 30px">选中指标:{{topicobj.scriptTopic}}</span>
              <span style="margin-left: 30px"
                ><el-button type="success" round @click="gettargetInfo"
                  >+选择指标</el-button
                ></span
              >
            </div>
@@ -352,7 +364,8 @@
                    </el-radio-group>
                  </el-form-item>
                </el-col>
                <el-col :span="2">
                <el-col :span="2" :offsset="topicobj.scoretype == 4 ? 11 : 0">
                  <el-button
                    type="danger"
                    icon="el-icon-delete"
@@ -361,7 +374,14 @@
                  ></el-button>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-form-item label="预警值">
                  <el-radio-group v-model="item.isabnormal">
                    <el-radio :label="1">是</el-radio>
                    <el-radio :label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-row>
              <el-row :gutter="10">
                <el-form-item label="选中提示">
                  <el-input
@@ -380,7 +400,7 @@
                    class="upload-demo"
                    :action="uploadImgUrl"
                    :headers="headers"
                    :accept="'image/*,video/*'"
                    accept=".jpg,.png,image/*"
                    :on-success="handleChange.bind(this, item)"
                  >
                    <el-button size="small" type="primary">点击上传</el-button>
@@ -414,9 +434,27 @@
          :inline="true"
          label-width="98px"
        >
          <el-form-item label="标题" prop="userName">
          <el-form-item label="指标名称" prop="userName">
            <el-input
              v-model="queryParams.targetname"
              placeholder="请输入"
              clearable
              style="width: 200px"
              @keyup.enter.native="gettargetInfo"
            />
          </el-form-item>
          <el-form-item label="指标说明" prop="userName">
            <el-input
              v-model="queryParams.targetdesc"
              placeholder="请输入"
              clearable
              style="width: 200px"
              @keyup.enter.native="gettargetInfo"
            />
          </el-form-item>
          <el-form-item label="指标标签" prop="userName">
            <el-input
              v-model="queryParams.tagName"
              placeholder="请输入"
              clearable
              style="width: 200px"
@@ -439,17 +477,53 @@
        </el-form>
        <el-table v-loading="loading" :data="targetList">
          <el-table-column
            label="标题"
            label="指标名称"
            align="center"
            key="targetname"
            prop="targetname"
            width="100"
          />
          <el-table-column
            label="问题内容"
            label="指标说明"
            align="center"
            key="targetdesc"
            prop="targetdesc"
            width="200"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="语言"
            align="center"
            key="language"
            prop="language"
            width="200"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="是否可用"
            align="center"
            key="isAvailable"
            prop="isAvailable"
          >
            <template slot-scope="scope">
              <dict-tag :options="usable" :value="scope.row.isAvailable" />
            </template>
          </el-table-column>
          <el-table-column
            label="问题类型"
            align="center"
            key="scriptType"
            prop="scriptType"
          >
            <template slot-scope="scope">
              <dict-tag :options="valuetype" :value="scope.row.scriptType" />
            </template>
          </el-table-column>
          <el-table-column
            label="选项说明"
            align="center"
            key="optionDesc"
            prop="optionDesc"
            width="200"
            :show-overflow-tooltip="true"
          />
@@ -507,6 +581,8 @@
    return {
      topicobj: {
        svyLibScriptOptions: [],
        svyLibScriptTagList: [],
        suitway: "1",
      },
      headers: {
        Authorization: "Bearer " + getToken(),
@@ -562,6 +638,7 @@
        { label: "分数", value: "1" },
        { label: "ABC等级", value: "2" },
        { label: "优良等级", value: "3" },
        { label: "无", value: "4" },
      ],
      optionstag: [],
      valuetype: [],
@@ -585,6 +662,9 @@
    // 公共方法---------------
    getIndexInArray(arr, obj) {
      return arr.indexOf(obj);
    },
    processElement(element) {
      return { ...element, isoperation: 1 };
    },
    // 递归扁平化
    flattenArray(arr) {
@@ -615,8 +695,9 @@
      }
      getissuelist({ id: this.id }).then((res) => {
        this.topicobj = res.rows[0];
        this.dynamicTags = this.topicobj.tag.split(",");
        this.suitwaylist = this.topicobj.suitway.split(",");
        this.dynamicTags = this.topicobj.svyLibScriptTagList.map(
          this.processElement
        );
        this.variablelist = JSON.parse(this.topicobj.otherdata)
          ? JSON.parse(this.topicobj.otherdata)
          : this.variablelist;
@@ -632,6 +713,13 @@
      });
    },
    gettargetInfo() {
      if (!this.topicobj.scriptType) {
        this.$message({
          message: "请先选择题目类型",
          type: "error",
        });
        return;
      }
      this.queryParams.scriptType = this.topicobj.scriptType;
      gettargetInfo(this.queryParams).then((res) => {
        this.targetList = res.rows;
@@ -649,9 +737,11 @@
          return item;
        }
      );
      this.topicobj.targetoptions = this.topicobj.svyLibScriptOptions
        .filter((item) => item.isoperation != 3)
        .map((item) => item.optioncontent)
        .join(", ");
      this.topicobj.otherdata = JSON.stringify(this.variablelist);
      this.topicobj.tag = this.dynamicTags.join(",");
      this.topicobj.suitway = this.suitwaylist.join(",");
      if (this.id) {
        this.topicobj.isoperation = 2;
        compileissue(this.topicobj).then((res) => {
@@ -701,12 +791,12 @@
        if (score.score) {
          console.log(Number(score.score), this.topicobj.score, "分值");
          if (
            Number(score.score) <= 0 ||
            Number(score.score) < 0 ||
            Number(score.score) > Number(this.topicobj.score)
          ) {
            console.log(score, "错误分值");
            this.$message({
              message: "选项分值必须大于0小于等于" + this.topicobj.score + "分",
              message: "选项分值必须在0到" + this.topicobj.score + "分之间",
              type: "warning",
            });
            return false;
@@ -730,16 +820,12 @@
    },
    Saveproblem() {
      if (this.topicobj.scoretype == 1) {
        console.log(321);
        this.Scorejudgment();
      } else {
        this.compileissue();
      }
    },
    // 删除标签
    handleClose(tag) {
      this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
    },
    // 删除选项
    deletexuanx(row) {
      const index = this.getIndexInArray(
@@ -764,14 +850,17 @@
    selectlabel(row) {
      this.$modal
        .confirm(
          '是否选择标题为"' + row.targetname + '"的指标并替换填充问题信息?'
          '是否选择标题为"' +
            row.targetname +
            '"的指标并替换填充问题及选项信息?'
        )
        .then(() => {
          console.log(row);
          console.log(this.topicobj);
          this.topicobj.scriptTopic = row.targetname;
          this.topicobj.valueType = row.valueType;
          this.topicobj.scriptContent = row.targetdesc;
          this.topicobj.targetid = row.id;
          this.topicobj.targetname = row.targetname;
          this.topicobj.isavailable = "0";
          this.topicobj.language = "普通话";
          this.topicobj.svyLibScriptOptions = [];
@@ -795,14 +884,16 @@
        tagcategoryid: "0",
      };
      listtag(tagqueryParams).then((response) => {
        console.log(response);
        console.log(response, "待选标签");
        this.optionstag = response.rows;
      });
    },
    handleClosetag(tag) {
      console.log(tag);
      console.log(this.dynamicTags.indexOf(tag));
      const lindex = this.dynamicTags.indexOf(tag);
      this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
      this.topicobj.svyLibScriptTagList[lindex].delFlag = 1;
    },
    handleInputConfirm() {
      let tagvalue = {};
@@ -824,7 +915,8 @@
            };
          }
          // this.dynamicTags.push(tagvalue);
          this.dynamicTags.push(tagvalue.tagname);
          this.topicobj.svyLibScriptTagList.push(tagvalue);
          this.dynamicTags.push(tagvalue);
        });
      }
      this.inputVisible = false;
@@ -900,7 +992,13 @@
    //   this.illnessVisible = false;
    //   this.$modal.msgSuccess("编辑成功");
    // },
    resetQuery() {},
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
      };
      this.gettargetInfo();
    },
    // 便捷标签
    tsgnameto(row) {
      let inputValueArr = "";
@@ -1011,10 +1109,14 @@
    handleChange(item, response, file, fileList) {
      console.log(response);
      if (response.code == 200) {
        console.log(item);
        let index = this.topicobj.svyLibScriptOptions.findIndex(
          (obj) => obj.id == item.id && obj.name == item.name
          (obj) => obj.optioncontent == item.optioncontent
        );
        console.log(index);
        this.topicobj.svyLibScriptOptions[index].picturePath = response.url;
        console.log(this.topicobj.svyLibScriptOptions[index]);
        this.$forceUpdate();
      } else {
        this.$message.error("图片插入失败");
      }
@@ -1044,12 +1146,12 @@
    margin: 15px 0;
  }
  .topicxq {
    width: 68%;
    width: 72%;
    background-color: #e2f5fc;
    border-radius: 4px;
    margin-top: 15px;
    margin-left: 10%;
    padding-left: 10px;
    padding-left: 20px;
    padding-top: 15px;
    border: 1px solid #dcdfe6;
    -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),