xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
web/src/views/modules/taskReliability/TimeDiagram.vue
@@ -23,6 +23,15 @@
          </zt-form-item>
          <zt-form-item>
            <zt-button @click="getDiagram(null)">查看时序图</zt-button>
            <el-dropdown style="margin-left: 10px" @command="download">
              <el-button type="primary">
                下载xml<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="1">输入xml</el-dropdown-item>
                <el-dropdown-item command="2">输出xml</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </zt-form-item>
        </el-form>
        <div style="display: flex">
@@ -59,6 +68,8 @@
  import ModelView from "./ModelView";
  import textDiagram from "./textDiagram";
  import timeDiagramThumbnail from "./timeDiagramThumbnail"
  import qs from "qs";
  import Cookies from "js-cookie";
  export default {
@@ -132,14 +143,14 @@
    },
    created() {
      let scrollView = this.$refs['scrollView']
      window.addEventListener('scroll', this.handleScroll,true);
      window.addEventListener('scroll', this.handleScroll,{passive:false});
    },
    destroyed() {
      let scrollView = this.$refs['scrollView']
      window.removeEventListener('scroll', this.handleScroll,true);
      window.removeEventListener('scroll', this.handleScroll);
    },
    mounted() {
      this.getProductList()
      this.getProductList(Cookies.get('productId'))
      this.init()
      this.$refs.textDiagram.init()
      this.$refs.timeDiagramThumbnail.init()
@@ -158,6 +169,20 @@
        let top = this.graph.getScrollbarPosition().top
        this.$refs.textDiagram.setScroll(top)
        this.$refs.timeDiagramThumbnail.getNodePointX(left,this.bigWidth)
      },
      getPath(){
        if (Cookies.get('productId') != null){
          this.dataForm.id = Cookies.get('fzId')
          this.dataForm.productId = Cookies.get('productId')
          this.dataForm.taskModelId = Cookies.get('taskModelId')
          console.log(this.dataForm.id)
          this.getTaskList()
          this.$nextTick(() => {
            this.onProductSelected({id:this.dataForm.productId})
            this.onTaskSelected({id:Cookies.get('taskModelId')})
            this.onSimulatSelected({id:Cookies.get('fzId')})
          })
        }
      },
      init() {
        this.graph = new Graph({
@@ -352,10 +377,14 @@
          style.display = 'none'
        })
      },
      async getProductList() {
      async getProductList(productId) {
        let res = await this.$http.get('/basicInfo/XhProductModel/getTaskProductList')
        this.productList = res.data
        this.onProductSelected(this.productList[0])
        if(productId!=null){
          this.getPath()
        }else{
          this.onProductSelected(this.productList[0])
        }
      },
      async getTaskList() {
        let params = {
@@ -439,7 +468,21 @@
      getPoint(x,smallWidth){
        let pointX = Number((x * (this.bigWidth / smallWidth )).toFixed(0))
        this.graph.setScrollbarPosition(pointX, null)
      }
      },
      async download(selsect) {
        if(this.dataForm.id){
          let param = qs.stringify({
            'token': Cookies.get('token'),
            type: 'sxt',
            xml:selsect,
            id: this.dataForm.id
          })
          let apiURL = `/taskReliability/SimulatAssess/downloadXml`
          window.location.href = `${window.SITE_CONFIG['apiURL']}${apiURL}?${param}`
        }else{
          this.$alert('还未选择仿真记录')
        }
      },
    }
  }
</script>