parameter.vue 2.5 KB
<template>
  <div>
    <el-dialog
      title="参数设置"
      :visible.sync="dialogVisible"
      width="60%"
      :before-close="handleClose"
    >
      <span>
        <el-input placeholder="请输入内容" v-model="paramsval" class="input-with-select">
          <el-button
            slot="append"
            icon="el-icon-search"
            @click="$refs.iframe.contentWindow.clickButton(paramsval)"
          ></el-button>
        </el-input>
        <iframe
          id="iframe"
          ref="iframe"
          src="./dynamicParameters.html"
          frameborder="0"
          width="100%"
          height="415"
          scrolling="no"
        ></iframe>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="save">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      paramsval:"",
      dialogVisible: false,
      XMLStr: "",
      basicXml: "",
      taskData: ""
    };
  },
  methods: {
    init(data) {
      this.$store.commit("setocxstate", 0);
      this.dialogVisible = true;
      this.taskData = data;
      let that = this;
      setTimeout(() => {
        that.xmlInit(data);
      }, 800);
    },
    balltaskinit(data) {
      this.$store.commit("setocxstate", 0);
      this.dialogVisible = true;
      setTimeout(() => {
        this.xmlInit(data);
      }, 800);
    },
    xmlInit: function(obj) {
      this.XMLStr =
        obj.config.xml || '<?xml version="1.0" encoding="GBK"?><root></root>';
      if (this.XMLStr.split("@").length > 1) {
        this.XMLStr = '<?xml version="1.0" encoding="GBK"?><root></root>';
      }
      if (obj && obj.basicConfig && obj.basicConfig.xml) {
        this.basicXml = obj.basicConfig.xml;
        this.$refs.iframe.contentWindow.loadParameterTree(
          this.basicXml,
          this.XMLStr
        );
      } else {
        console.error("参数配置存在错误!请检测basicConfig是否为空");
      }
    },
    save: function() {
      this.$refs.iframe.contentWindow.submit();
      //ifram 传递回来的饿xml
      this.XMLStr = this.$refs.iframe.contentWindow.xmlStr;
      this.handleClose();
      this.$parent.submit(this.XMLStr, "config");
    },
    handleClose(done) {
      this.dialogVisible = false;
      this.$store.commit("setocxstate", 1);
    }
  }
};
</script>
<style lang="stylus" scoped>
.input-with-select{
  width 300px
  margin-bottom 5px;
}
</style>