WXL
2024-08-09 fe7f65e63714807890ab103fbc84cf5f634ae8d8
src/views/repositoryai/intention/index.vue
@@ -30,7 +30,7 @@
        >
          <span class="custom-tree-node" slot-scope="{ node, data }">
            <span>{{ node.label }}</span>
            <span>
            <span v-if="data.id > 0">
              <el-button
                type="text"
                icon="el-icon-delete"
@@ -38,6 +38,17 @@
                size="mini"
                @click="() => remove(node, data)"
              >
              </el-button>
            </span>
            <span v-if="data.id > 0">
              <el-button
                type="text"
                circle
                size="mini"
                @click="() => altertag(node, data)"
                ><span class="button-textxg"
                  ><i class="el-icon-edit-outline"></i
                ></span>
              </el-button>
            </span>
          </span>
@@ -60,26 +71,24 @@
            >
              <el-form-item label="指标名称" prop="userName">
                <el-input
                  v-model="queryParams.userName"
                  v-model="queryParams.targetname"
                  placeholder="请输入"
                  clearable
                  style="width: 200px"
                  @keyup.enter.native="handleQuery"
                />
              </el-form-item>
              <el-form-item label="标签" prop="sickness">
                <el-select v-model="queryParams.tag" placeholder="请选择">
                  <el-option
                    v-for="item in dynamicTags"
                    :key="item.tagid"
                    :label="item.tagname"
                    :value="item.tagid"
                  >
                  </el-option>
                </el-select>
              <el-form-item label="标签名称" prop="userName">
                <el-input
                  v-model="queryParams.tagName"
                  placeholder="请输入"
                  clearable
                  style="width: 200px"
                  @keyup.enter.native="handleQuery"
                />
              </el-form-item>
              <el-form-item label="适用方式" prop="shape">
                <el-select v-model="queryParams.value" placeholder="请选择">
              <el-form-item label="适用场景" prop="shape">
                <el-select v-model="queryParams.suitWay" placeholder="请选择">
                  <el-option
                    v-for="item in mode"
                    :key="item.value"
@@ -91,7 +100,7 @@
              </el-form-item>
              <el-form-item label="指标类型" prop="classify">
                <el-select
                  v-model="queryParams.classifyvalue"
                  v-model="queryParams.scriptType"
                  placeholder="请选择"
                >
                  <el-option
@@ -103,13 +112,13 @@
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="可用状态" prop="classify">
              <el-form-item label="是否可用" prop="classify">
                <el-select
                  v-model="queryParams.classifyvalue"
                  v-model="queryParams.isAvailable"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="(item, index) in qyoptions"
                    v-for="(item, index) in usable"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
@@ -170,23 +179,26 @@
              @selection-change="handleSelectionChange"
            >
              <el-table-column type="selection" width="50" align="center" />
              <el-table-column
              <!-- <el-table-column
                label="序号"
                fixed
                align="center"
                key="id"
                prop="id"
              />
              /> -->
              <el-table-column
                label="值类型"
                label="指标类型"
                fixed
                align="center"
                key="isenable"
                prop="isenable"
                key="scriptType"
                prop="scriptType"
                :show-overflow-tooltip="true"
              >
                <template slot-scope="scope">
                  <dict-tag :options="valuetype" :value="scope.row.isenable" />
                  <dict-tag
                    :options="valuetypelb"
                    :value="scope.row.scriptType"
                  />
                </template>
              </el-table-column>
              <el-table-column
@@ -198,7 +210,7 @@
              >
              </el-table-column>
              <el-table-column
              <!-- <el-table-column
                label="正常值范围"
                align="center"
                key="warndown"
@@ -208,7 +220,7 @@
                <template slot-scope="scope">
                  <span>{{ scope.row.warnup }}~{{ scope.row.warndown }}</span>
                </template>
              </el-table-column>
              </el-table-column> -->
              <el-table-column
                label="指标描述"
                align="center"
@@ -216,14 +228,14 @@
                prop="targetdesc"
                width="200"
              /><el-table-column
                label="适用方式"
                label="适用场景"
                align="center"
                key="suitWay"
                prop="suitWay"
                key="suitWayList"
                prop="suitWayList"
                width="120"
              >
                <template slot-scope="scope">
                  <dict-tag :options="mode" :value="scope.row.suitWay" />
                  <dict-tag :options="mode" :value="scope.row.suitWayList" />
                </template>
              </el-table-column>
              <el-table-column
@@ -259,10 +271,7 @@
                prop="isAvailable"
              >
                <template slot-scope="scope">
                  <dict-tag
                    :options="qyoptions"
                    :value="scope.row.isAvailable"
                  />
                  <dict-tag :options="usable" :value="scope.row.isAvailable" />
                </template>
              </el-table-column>
@@ -283,7 +292,7 @@
                      ><i class="el-icon-edit"></i>修改</span
                    ></el-button
                  >
                  <el-button
                  <!-- <el-button
                    size="medium"
                    type="text"
                    @click="handlemeasurement(scope.row)"
@@ -291,7 +300,7 @@
                    ><span class="button-textcs"
                      ><i class="el-icon-help"></i>测试</span
                    ></el-button
                  >
                  > -->
                  <el-button
                    size="medium"
                    type="text"
@@ -319,6 +328,7 @@
        <el-dialog
          :title="title"
          :visible.sync="indexopen"
          :close-on-click-modal="false"
          width="900px"
          append-to-body
        >
@@ -330,10 +340,10 @@
          >
            <el-row v-if="!measurement">
              <el-col :span="12">
                <el-form-item label="指标名称" prop="deptId">
                <el-form-item label="指标名称" prop="targetname">
                  <el-input
                    v-model="indexform.targetname"
                    placeholder="请输入指标种类"
                    placeholder="请输入指标名称"
                    maxlength="40"
                  />
                </el-form-item>
@@ -342,7 +352,7 @@
                <el-form-item label="版本号" prop="deptId">
                  <el-input
                    v-model="indexform.version"
                    placeholder="请输入指标种类"
                    placeholder="默认1.0"
                    maxlength="40"
                  />
                </el-form-item>
@@ -351,7 +361,7 @@
            <!-- deptOptions -->
            <el-row v-if="!measurement">
              <el-col :span="8">
                <el-form-item label="指标分类">
                <el-form-item label="指标分类" prop="assortid">
                  <el-select
                    v-model="indexform.assortid"
                    size="medium"
@@ -375,7 +385,7 @@
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="语言" prop="deptId">
                <el-form-item label="语言" prop="language">
                  <el-select
                    v-model="indexform.language"
                    placeholder="请选择语言"
@@ -411,10 +421,17 @@
                  <el-input
                    v-model="indexform.targetdesc"
                    placeholder="请输入指标描述"
                    id="targetdesc"
                    @focus="currentInputId = 'targetdesc'"
                    maxlength="40"
                  />
                </el-form-item> </el-col
            ></el-row>
            <el-form-item label="插入填空" prop="scriptContent">
              <div style="display: flex; margin-bottom: 10px">
                <div class="tsgname" @click="tsgnameto">插入填空</div>
              </div>
            </el-form-item>
            <el-form-item label="标签" prop="desc" v-if="!measurement">
              <div class="xinz-inf">
                <el-tag
@@ -456,7 +473,7 @@
            <el-row v-if="!measurement">
              <el-col :span="24">
                <el-form-item label="值类型">
                  <el-radio-group v-model="indexform.isenable">
                  <el-radio-group v-model="indexform.valueType">
                    <el-radio :label="1">选项</el-radio>
                    <el-radio :label="2">文本</el-radio>
                    <el-radio :label="3">数值</el-radio>
@@ -464,11 +481,32 @@
                </el-form-item>
              </el-col></el-row
            >
            <el-row v-if="!measurement">
              <el-col :span="24">
                <el-form-item label="题目类型">
                  <el-radio-group
                    @input="Changtype"
                    v-model="indexform.scriptType"
                  >
                    <el-radio :label="1">单选</el-radio>
                    <el-radio :label="2">多选</el-radio>
                    <el-radio :label="3">填空</el-radio>
                    <el-radio :label="4">问答</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col></el-row
            >
            <el-row v-if="!measurement">
              <el-col :span="24">
                <el-form-item label="适用方式" prop="email">
                  <el-select v-model="indexform.suitWay" placeholder="请选择">
                <el-form-item label="适用场景" prop="suitWayList">
                  <el-select
                    class="el-select1"
                    v-model="indexform.suitWayList"
                    multiple
                    @change="changeselect"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="index in mode"
                      :key="index.value"
@@ -483,52 +521,54 @@
            <el-card
              class="box-card"
              style="margin-bottom: 20px"
              v-if="indexform.isenable == 1"
              v-if="indexform.scriptType == 1 || indexform.scriptType == 2"
            >
              <Regular
                :TargetoptionList="testuserList"
                :intent="false"
                :hasValue="hasValue"
                @addoption="addoption"
                @deloption="deloption"
                @syioption="syioption"
                @xiayioption="xiayioption"
              />
            </el-card>
            <div v-if="indexform.isenable == 2">
            <div v-if="indexform.scriptType == 3">
              <el-form-item label="收集信息">
                <el-input
                  type="textarea"
                  :rows="2"
                  placeholder="填入收集信息"
                  v-model="indexform.textarea"
                  maxlength="50"
                  show-word-limit
                >
                </el-input
              ></el-form-item>
            </div>
            <div v-if="indexform.isenable == 3">
              <el-form-item label="收集信息">
                <el-input
                  type="text"
                  placeholder="填入收集信息"
                  v-model="indexform.textarea"
                >
                </el-input
              ></el-form-item>
                <el-card class="box-card">
                  <div v-for="item in testuserList" style="margin-bottom: 10px">
                    <el-input
                      type="text"
                      placeholder="填入收集信息"
                      v-model="indexform.optiondesc"
                    >
                      <el-button
                        slot="append"
                        @click="deloption(item)"
                        type="danger"
                        icon="el-icon-delete"
                        circle
                      ></el-button>
                      <span slot="prepend">{{ "(" + item.orderno + ")" }}</span>
                    </el-input>
                  </div>
                </el-card>
              </el-form-item>
            </div>
            <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="测试输入" prop="nickName">
                  <el-input
                    v-model="testvalue"
                    v-model="indexform.content"
                    placeholder="请输入测试内容"
                    maxlength="40"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-button type="success">开始测试</el-button>
                <el-button type="success" @click="testtagerlist"
                  >开始测试</el-button
                >
              </el-col>
            </el-row>
          </el-form>
@@ -626,7 +666,7 @@
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button @click="getDeptTree()">取 消</el-button>
        <el-button type="primary" @click="submitsidecolumn">确 定</el-button>
      </div>
    </el-dialog>
@@ -638,6 +678,7 @@
  gettargetInfo,
  particulartarget,
  gettargetInfoedit,
  testtagerlist,
  addtarget,
  deletetarget,
  getillnesslist,
@@ -647,6 +688,7 @@
  addtargetillness,
  selectIvrLibaTargetAssortList,
  addtreeselectIvrLibaTargetAssort,
  edittreeselectIvrLibaTargetAssort,
  delselectIvrLibaTargetAssort,
} from "@/api/AiCentre/index";
import { getToken } from "@/utils/auth";
@@ -675,6 +717,7 @@
      showSearch: true,
      measurement: false,
      languagelist: [],
      usable: [],
      indexid: null,
      // 总条数
      total: 0,
@@ -686,6 +729,8 @@
      radio: "主分类",
      testvalue: "",
      testgovalue: "",
      creatype: "", //指标临时类型
      hasValue: true,
      classifyform: {
        categoryname: "",
      }, //类别表单
@@ -727,15 +772,30 @@
      mode: [],
      optionstag: [],
      targetoptionList: [],
      Temporarytype: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      valuetypelb: [],
      // 表单校验
      rules: {},
      rules: {
        targetname: [
          { required: true, message: "指标名称不能为空", trigger: "blur" },
        ],
        assortid: [
          { required: true, message: "指标分类不能为空", trigger: "blur" },
        ],
        language: [
          { required: true, message: "指标语言不能为空", trigger: "blur" },
        ],
        isAvailable: [
          { required: true, message: "指标语言不能为空", trigger: "blur" },
        ],
      },
    };
  },
  watch: {
@@ -751,9 +811,10 @@
    this.gettabList();
    this.getDeptTree();
    this.mode = store.getters.mode;
    this.valuetype = store.getters.valuetype;
    this.valuetypelb = store.getters.askvaluetype;
    this.languagelist = store.getters.languagelist;
    this.qyoptions = store.getters.usable;
    this.qyoptions = store.getters.askvaluetype;
    this.usable = store.getters.usable;
  },
  methods: {
    /** 查询指标列表 */
@@ -776,6 +837,10 @@
      // 返回数组中指定元素的索引
      return arr.indexOf(obj);
    },
    changeselect(row) {
      console.log(row);
      this.hasValue = row.includes("2");
    },
    //删除分类
    deletefenlei(row) {
      if (this.deleteVisible) {
@@ -791,7 +856,65 @@
        this.deletefenl = row.title;
      }
    },
    // 便捷标签插入填空
    tsgnameto(row) {
      let inputValueArr = "";
      let value = this.testuserList.length + 1;
      let el = document.querySelector("#" + this.currentInputId);
      //el.selectionStart; 这就是当前光标所在的位置(字符串中字符的index)
      if (this.currentInputId == "targetdesc") {
        inputValueArr = this.indexform.targetdesc.split("");
      } else {
        return;
      }
      //将输入框内容切成数组,方便后续操作
      // inputValueArr = this.inputValue.split("");
      // 拿到选中文字的长度(后续可以用来替换选中的文字)
      let selectLength = el.selectionEnd - el.selectionStart;
      // 将要插入/替换的文字插入/替换(value.name是要插入/替换的字符串)
      inputValueArr.splice(
        el.selectionStart,
        selectLength,
        "__" + value + "__"
      );
      this.testuserList.push({
        orderno: value,
        optiondesc: "",
        isoperation: 1,
      });
      // 把数组重新转换为字符串并赋值
      inputValueArr = inputValueArr.join("");
      console.log(inputValueArr);
      if (this.currentInputId == "targetdesc") {
        this.indexform.targetdesc = inputValueArr;
      } else {
        return;
      }
    },
    Changtype(item) {
      console.log(this.testuserList);
      console.log(item, "选项变更的处理");
      if (item == 3 && this.testuserList[0].targetvalue) {
        this.$modal
          .confirm("更改类型为填空后选项将清空是否继续?")
          .then(() => {
            this.testuserList = [];
            this.Temporarytype = this.indexform.scriptType;
          })
          .catch(() => {
            this.indexform.scriptType = this.Temporarytype;
          });
      } else if (item == 3) {
        this.testuserList = [];
        this.Temporarytype = this.indexform.scriptType;
      }
      {
        this.Temporarytype = this.indexform.scriptType;
      }
    },
    // 疾病-----------------------
    illnessUpdate(row) {
      this.illnessVisible = true;
@@ -878,7 +1001,7 @@
      console.log(this.dynamicTags.indexOf(tag));
      const lindex = this.dynamicTags.indexOf(tag);
      this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
      this.indexform.baseTagList[lindex].isoperation = 3;
      this.indexform.ivrLibaTargetTagList[lindex].delFlag = 3;
    },
    handleInputConfirm() {
      let tagvalue = {};
@@ -900,9 +1023,9 @@
            };
          }
          console.log(tagvalue);
          this.indexform.baseTagList.push(tagvalue);
          this.indexform.ivrLibaTargetTagList.push(tagvalue);
          this.dynamicTags.push(tagvalue);
          console.log(this.indexform.baseTagList);
          console.log(this.indexform.ivrLibaTargetTagList);
          console.log(this.dynamicTags);
        });
      }
@@ -918,9 +1041,12 @@
        guid: 1,
        id: this.indexform.id,
        targettype: this.indexform.targettype,
        isoperation: 1,
        isabnormal: 0,
        targetvalue: "",
        targetregex: "",
        targetregex2: "",
        picturePath: "",
        dynamiccruxs: [],
        nodynamiccruxs: [],
        dynamiccruxsJson: "",
@@ -936,12 +1062,20 @@
      if (index !== -1) {
        this.testuserList[index].isoperation = 3;
        this.targetoptionList.push(this.testuserList[index]);
        console.log(this.targetoptionList, "aaaa.targetoptionList");
        this.testuserList.splice(index, 1); // 从索引位置删除一个元素
        this.sortFn();
        if (this.indexform.scriptType == 3) {
          this.$modal.msgWarning(
            "填空项已删除请手动删除题目内容中对应的填空项"
          );
        }
      } else {
        console.log("未找到该对象");
      }
    },
    syioption(row) {
      const index = this.getIndexInArray(this.testuserList, row);
      const item = this.testuserList.splice(index, 1)[0]; // 移除指定索引处的元素,并保存到item变量中
@@ -961,7 +1095,6 @@
          targetvalue: item.targetvalue,
          targetregex2: item.targetregex2,
          targetregex: item.targetregex,
          targetoptionid: item.targetoptionid,
          id: this.indexform.id,
          targettype: this.indexform.targettype,
          isoperation: item.targetoptionid ? 2 : 1,
@@ -971,6 +1104,9 @@
          nodynamiccruxs: item.nodynamiccruxs,
          dynamiccruxsJson: item.dynamiccruxsJson,
          nodynamiccruxsJson: item.nodynamiccruxsJson,
          targetoptionid: item.targetoptionid,
          isabnormal: item.isabnormal,
          picturePath: item.picturePath,
        };
      });
      console.log(this.testuserList);
@@ -981,6 +1117,7 @@
    getDeptTree() {
      selectIvrLibaTargetAssortList({}).then((res) => {
        this.deptOptions = res.rows;
        this.dialogFormVisible = false;
      });
    },
    // 筛选节点
@@ -990,6 +1127,15 @@
    },
    // 添加类别树
    submitsidecolumn() {
      if (this.classifyform.id) {
        edittreeselectIvrLibaTargetAssort(this.classifyform).then((res) => {
          this.getDeptTree();
          this.$modal.msgSuccess("修改成功");
          this.classifyform = {};
          this.dialogFormVisible = false;
        });
        return;
      }
      let calssvalue = {};
      if (
        this.classifyform.pid &&
@@ -1045,6 +1191,16 @@
          .catch(() => {});
      }
    },
    altertag(a, b) {
      this.dialogFormVisible = true;
      if (!b.pid) {
        this.radio = "主分类";
      } else {
        this.radio = "子分类";
      }
      this.classifyform = b;
      this.dialogFormVisible = true;
    },
    handleNodeClick(data) {
      this.queryParams.assortid = data.id;
      this.getList();
@@ -1052,6 +1208,7 @@
    // 取消按钮
    cancel() {
      this.indexform = null;
      this.indexopen = false;
      this.reset();
    },
@@ -1059,13 +1216,13 @@
    // 表单重置
    reset() {
      this.indexform = {
        suitWay: undefined,
        suitWayList: undefined,
        id: undefined,
        targetdesc: undefined,
        baseTagList: [],
        ivrLibaTargetTagList: [],
        targetoptionList: [],
      };
      this.resetForm("indexform");
      // this.resetForm("indexform");
    },
    /** 搜索按钮操作 */
    handleQuery() {
@@ -1094,7 +1251,7 @@
      this.reset();
      this.title = "新增指标";
      this.indexform = {
        baseTagList: [],
        ivrLibaTargetTagList: [],
        targetoptionList: [],
      };
      this.dynamicTags = [];
@@ -1104,6 +1261,8 @@
          targetvalue: "",
          targetregex: "",
          targetregex2: "",
          isoperation: 1,
          picturePath: "",
          dynamiccruxs: [],
          nodynamiccruxs: [],
          dynamiccruxsJson: "",
@@ -1116,11 +1275,31 @@
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      console.log(row);
      this.title = "指标详情";
      this.indexform = {};
      this.indexform = row;
      this.dynamicTags = row.baseTagList.map(this.processElement);
      this.indexform.scriptType = Number(row.scriptType);
      this.Temporarytype = this.indexform.scriptType;
      if (!row.targetoptionList[0]) {
        row.targetoptionList = [
          {
            targettype: "1",
            targetvalue: "",
            targetregex: "",
            targetregex2: "",
            isoperation: 1,
            orderno: 1,
            dynamiccruxs: [],
            nodynamiccruxs: [],
            dynamiccruxsJson: "",
            nodynamiccruxsJson: "",
          },
        ];
      }
      this.dynamicTags = row.ivrLibaTargetTagList.map(this.processElement);
      this.testuserList = row.targetoptionList;
      console.log(this.testuserList, "bbbb");
      this.testvalue = "";
      this.indexopen = true;
      this.measurement = false;
    },
@@ -1139,18 +1318,31 @@
    /** 更新/修改提交按钮 */
    submitForm: function () {
      // this.indexform.targetoptionList=[]
      this.indexform.targetoptionList = this.indexform.targetoptionList.map(
        (res) => {
          res.isoperation = 2;
          return res;
        }
      );
      // this.indexform.targetoptionList = this.indexform.targetoptionList.map(
      //   (res) => {
      //     res.isoperation = 2;
      //     return res;
      //   }
      // );
      this.$refs["indexform"].validate((valid) => {
        this.indexform.targetoptionList = this.testuserList.concat(
          this.targetoptionList
        );
        console.log(this.indexform.targetoptionList, "11");
        this.indexform.targetoptionList.forEach((item) => {
          if (item.isoperation != 3 && item.targetoptionid) {
            console.log(item, "item");
            item.isoperation = 2;
          } else {
          }
        });
        if (valid) {
          this.indexform.optionDesc = this.testuserList
            .filter((item) => item.isoperation != 3)
            .map((item) => item.targetvalue)
            .join(", ");
          if (!this.indexform.version) this.indexform.version = "1.0";
          if (this.indexform.id != undefined) {
            this.indexform.isoperation = 2;
            gettargetInfoedit(this.indexform).then((response) => {
@@ -1169,6 +1361,21 @@
          }
        }
      });
    },
    // 测试表单
    testtagerlist() {
      if (this.indexform.content) {
        let data = this.indexform;
        data.targetoptionList = this.testuserList.concat(this.targetoptionList);
        testtagerlist(data).then((res) => {
          this.$modal.msgSuccess("测试成功");
          this.testgovalue = res.msg;
          this.getList();
        });
      } else {
        this.$modal.msgError("请填写测试内容");
        return;
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
@@ -1275,6 +1482,21 @@
    display: center !important;
  }
}
.tsgname {
  width: 90px;
  margin-right: 10px;
  text-align: center;
  cursor: pointer;
  height: 40px;
  line-height: 40px;
  background: #66c18c;
  color: #ffff;
  font-size: 18px;
  border-radius: 5px;
}
.tsgname:hover {
  background: #20894d;
}
.qrcode-dialo {
  text-align: center;
  //   display: flex;
@@ -1295,6 +1517,9 @@
    height: 400px;
  }
}
.el-select {
  width: 40%;
}
::v-deep.el-tabs--left,
.el-tabs--right {
  overflow: hidden;