WXL
2024-01-16 ad70f145e8bea957b41043b4a1e37ce37cc5ed1e
src/views/repositoryai/verbaltrick/particulars/index.vue
@@ -44,7 +44,7 @@
                  placeholder="请选择状态"
                >
                  <el-option
                    v-for="item in qyoptions"
                    v-for="item in usable"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
@@ -60,16 +60,23 @@
              <el-form-item label="问题分类" prop="status">
                <el-select
                  v-model="indexform.assortid"
                  placeholder="请选择状态"
                  filterable
                  placeholder="请选择分类"
                >
                <el-option-group
                  v-for="group in questionclass"
                  :key="group.id"
                  :label="group.indexAssortName"
                >
                  <el-option
                    v-for="item in questionclass"
                    v-for="item in group.ivrLibaScriptAssortList"
                    :key="item.id"
                    :label="item.indexAssortName"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
                </el-option-group>
              </el-select>
              </el-form-item>
            </el-col>
@@ -136,49 +143,51 @@
            </div>
          </el-form-item>
          <el-form-item label="通知变量" prop="name">
            <el-row v-for="item in variablelist">
              <el-col :span="4">
                <el-input
                  v-model="item.name"
                  placeholder="请输入变量名"
                ></el-input>
              </el-col>
              <el-col :span="8" :offset="1">
                <el-input
                  v-model="item.value"
                  placeholder="请输入变量内容"
                ></el-input>
              </el-col>
              <el-col :span="4" :offset="1">
                <el-button
                  type="success"
                  icon="el-icon-plus"
                  circle
                  @click="addvariable(item)"
                ></el-button>
                <el-button
                  v-if="item"
                  type="danger"
                  icon="el-icon-delete"
                  circle
                  @click="delvariable(item)"
                ></el-button>
              </el-col>
            </el-row>
            <div style="margin-bottom: 5px" v-for="item in variablelist">
              <el-row>
                <el-col :span="5">
                  <el-input
                    v-model="item.variatename"
                    placeholder="请输入变量名"
                  ></el-input>
                </el-col>
                <el-col :span="8" :offset="1">
                  <el-input
                    v-model="item.variate"
                    placeholder="请输入变量内容"
                  ></el-input>
                </el-col>
                <el-col :span="8" :offset="1">
                  <el-button
                    type="success"
                    icon="el-icon-plus"
                    circle
                    @click="addvariable(item)"
                  ></el-button>
                  <el-button
                    v-if="!item.default"
                    type="danger"
                    icon="el-icon-delete"
                    circle
                    @click="delvariable(item)"
                  ></el-button>
                </el-col>
              </el-row>
            </div>
          </el-form-item>
          <el-row>
            <el-col :span="12">
            <el-col :span="6">
              <el-form-item label="仅限院区" prop="region">
                <el-select
                  v-model="indexform.courtyard"
                  v-model="indexform.campus"
                  size="medium"
                  filterable
                  placeholder="请选择"
                >
                  <el-option
                    class="indexformaa"
                    v-for="item in options"
                    v-for="item in courtyardlist"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
@@ -187,7 +196,24 @@
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
            <el-col :span="6">
              <el-form-item label="适用方式" prop="status">
                <el-select
                  v-model="indexform.suitway"
                  multiple
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in mode"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="关联指标" prop="region">
                <el-select
                  v-model="indexform.targetid"
@@ -196,13 +222,14 @@
                  reserve-keyword
                  placeholder="请输入关键词"
                  :remote-method="remoteMethod"
                  @change="targetchange"
                  :loading="loading"
                >
                  <el-option
                    v-for="item in targetlist"
                    :key="item.targetid"
                    :key="item.id"
                    :label="item.targetname"
                    :value="item.targetid"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
@@ -219,7 +246,7 @@
                  class="tsgname"
                  @click="tsgnameto(item)"
                >
                  {{ item.name }}
                  {{ item.variatename }}
                </div>
              </div>
            </el-col></el-row
@@ -377,8 +404,9 @@
          >
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="nextstep">确 定</el-button>
          <el-button type="primary" @click="nextstep">下一步</el-button>
          <el-button @click="closeFm">关 闭</el-button>
          <el-button @click="Saveproblem()">保存数据</el-button>
        </div>
      </div>
      <!-- 指标设置 -->
@@ -518,7 +546,7 @@
        </div>
        <el-button type="primary" @click="laststep()">上一步</el-button>
        <el-button type="info" @click="closeFm()">关闭</el-button>
        <el-button @click="Saveproblem()">保存指标数据</el-button>
        <el-button @click="Saveproblem()">保存数据</el-button>
      </div>
    </div>
  </div>
@@ -556,7 +584,7 @@
      mode: [],
      questionclass: [],
      currentInputId: "",
      courtyardlist: [],
      // 总条数
      total: 1,
@@ -576,9 +604,13 @@
          url: "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
      ],
      qyoptions: [],
      usable: [],
      options: [],
      variablelist: [],
      variablelist: [
        { variatename: "姓名", variate: "${name}", default: 1 },
        { variatename: "电话", variate: "${phone}", default: 1 },
        { variatename: "病情", variate: "${illness}", default: 1 },
      ],
      addvalue: "添加题目",
      languagelist: [], //语言列表
@@ -601,7 +633,8 @@
    this.mode = store.getters.mode;
    this.valuetype = store.getters.valuetype;
    this.languagelist = store.getters.languagelist;
    this.qyoptions = store.getters.usable;
    this.usable = store.getters.usable;
    this.courtyardlist = store.getters.courtyardlist;
  },
  methods: {
@@ -610,20 +643,20 @@
      let id = this.$route.query.id;
      getverbaltrick({ id: id }).then((res) => {
        this.indexform = res.data;
        this.indexform.suitway = this.indexform.suitway.split(",");
        this.indexform.assortid = parseInt(this.indexform.assortid);
        this.variablelist = JSON.parse(this.indexform.parameter)
          ? JSON.parse(this.indexform.parameter)
          : [{ name: "", value: "" }];
        this.variablelist = JSON.parse(this.indexform.otherdata).length
          ? JSON.parse(this.indexform.otherdata)
          : this.variablelist;
        this.dynamicTags = this.indexform.ivrLibaScriptTagList.map(
          this.processElement
        );
        this.targetlist = [
          {
            targetid: this.indexform.targetid,
            id: this.indexform.targetid,
            targetname: this.indexform.targetname,
          },
        ];
        console.log(this.targetlist);
      });
      // 树
      getbaltrickclassify({}).then((res) => {
@@ -634,12 +667,20 @@
    // 保存详细信息
    Saveproblem() {
      console.log(this.variablelist);
      this.indexform.otherdata = JSON.stringify(this.variablelist);
      this.indexform.suitway = this.indexform.suitway.join(",");
      if (this.indexform.id) {
        this.indexform.isoperation = 2;
        this.indexform.parameter = JSON.stringify(this.variablelist);
        compileverbaltrick(this.indexform).then((res) => {
          if (res.code == 200) {
            this.$modal.msgSuccess("修改成功");
            this.$router.go(-1);
          } else {
            this.$message({
              message: "修改失败",
              type: "error",
            });
          }
        });
      } else {
@@ -647,6 +688,12 @@
        compileverbaltrick(this.indexform).then((res) => {
          if (res.code == 200) {
            this.$modal.msgSuccess("新增成功");
            this.$router.go(-1);
          } else {
            this.$message({
              message: "新增失败",
              type: "error",
            });
          }
        });
      }
@@ -664,6 +711,24 @@
        this.targetlist = [];
      }
    },
    targetchange(res) {
      console.log(res);
      gettargetInfo({ id: res }).then((res) => {
        this.indexform.targetname = res.rows[0].targetname;
        this.$modal
          .confirm('是否添加"' + this.indexform.targetname + '"指标的选项?')
          .then(() => {
            this.indexform.isenable = res.rows[0].isenable;
            res.rows[0].targetoptionList.forEach((item) => {
              item.isoperation = 1;
              this.indexform.ivrLibaScriptTargetoptionList.push(item);
            });
          })
          .catch(() => {
            this.$modal.msgSuccess("已取消");
          });
      });
    },
    // 下一步
    nextstep() {
@@ -671,14 +736,7 @@
        if (this.indexform.ivrLibaScriptTargetoptionList.length) {
          return this.Editprogress++;
        }
        gettargetInfo({ targetid: this.indexform.targetid }).then((res) => {
          this.indexform.isenable = res.rows[0].isenable;
          this.indexform.targetname = res.rows[0].targetname;
          res.rows[0].targetoptionList.forEach((item) => {
            item.isoperation = 1;
            this.indexform.ivrLibaScriptTargetoptionList.push(item);
          });
        });
        return this.Editprogress++;
      } else {
        this.$message.warning("请先选择关联指标");
@@ -779,7 +837,6 @@
    showInput() {
      this.inputVisible = true;
    },
    // --------------------------
    //测试表单 --------------------------
    gettagerlist() {
      gettagerlist({ targetname: this.targetname }).then((response) => {
@@ -796,7 +853,7 @@
      });
      this.sortFn();
    },
    deloption() {
    deloption(item) {
      const index = this.indexform.ivrLibaScriptTargetoptionList.indexOf(item);
      if (index !== -1) {
        this.indexform.ivrLibaScriptTargetoptionList.splice(index, 1); // 从索引位置删除一个元素
@@ -870,7 +927,7 @@
      // 拿到选中文字的长度(后续可以用来替换选中的文字)
      let selectLength = el.selectionEnd - el.selectionStart;
      // 将要插入/替换的文字插入/替换(value.name是要插入/替换的字符串)
      inputValueArr.splice(el.selectionStart, selectLength, `${row.value}`);
      inputValueArr.splice(el.selectionStart, selectLength, `${row.variate}`);
      // 把数组重新转换为字符串并赋值
      inputValueArr = inputValueArr.join("");
      console.log(inputValueArr);
@@ -892,8 +949,8 @@
    // 新增变量
    addvariable() {
      this.variablelist.push({
        variable: "",
        value: "",
        variatename: "",
        variate: "",
      });
    },
    // 删除变量