parameter.vue 2.03 KB
<template>
  <div>
   <el-dialog
      title="参数设置"
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose">
      <span>
         <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 {
        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.mtasks[0].scenes[0]);
      },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>'
				console.log('XML:'+this.XMLStr.split('@').length)
				if (this.XMLStr.split('@').length>1) {
					this.XMLStr =  '<?xml version="1.0" encoding="GBK"?><root></root>'
				}
        this.basicXml = obj.basicConfig.xml;
        this.$refs.iframe.contentWindow.loadParameterTree(this.basicXml,this.XMLStr);
    },
    save:function () {
				this.$refs.iframe.contentWindow.submit();
        //ifram 传递回来的饿xml
				this.XMLStr = this.$refs.iframe.contentWindow.xmlStr;
        this.dialogVisible = false;
        this.$parent.submit(this.XMLStr,'config')
			},
    handleClose(done) {
      this.dialogVisible = false;
      this.$store.commit('setocxstate',1)
    }
  }
}
</script>
<style lang="stylus" scoped>

</style>