HighlightContent.vue 1.83 KB
Newer Older
liuxin committed
1
<template>
潘际乾 committed
2 3 4
  <div @click="handleClick" :id="id" :class="{'c-highlight-content': true, 'highlight': highlight, 'change-light': highlightChanges}">
    <slot></slot>
  </div>
liuxin committed
5 6 7 8 9 10 11
</template>

<script>
export default {
  props: ['id', 'path'],
  data: function () {
    return {
潘际乾 committed
12 13
      // process: '0'
      process: '1'
liuxin committed
14 15 16 17 18
    }
  },
  computed: {
    showHighlight: {
      get () {
潘际乾 committed
19 20
        // return this.process == '1' || this.process == '2'
        return this.$route.path.startsWith("/review")
liuxin committed
21 22 23
      }
    },
    highlight () {
潘际乾 committed
24
      return this.$store.state.Status.highlights.indexOf(this.id) !== -1 && this.showHighlight
liuxin committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38
    },
    highlightChanges () {
      let flag = false
      this.$store.state.Status.highlightChanges.forEach(item => {
        if (item == this.path || item.indexOf(this.path) == 0) {
          flag = true
        }
      })
      return flag
    }
  },
  created: function () {
    if (this.$route.query.routeParams) {
      this.process = this.$route.query.routeParams.process;
潘际乾 committed
39
      // this.busiTempInfoSriNo = this.$route.query.routeParams.busiTempInfoSriNo;
liuxin committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
    }
    // this.process = '1'
  },
  methods: {
    handleClick: function () {
      if (this.showHighlight) {
        this.updateHighlights(this.id)
      }
    },
    updateHighlights(id) {
      let list = this.$store.state.Status.highlights;
      if (list.indexOf(id) == -1) {
        list.push(id)
        this.$store.commit('updateRemark', id)
      } else {
        let index = list.indexOf(id)
        list.splice(index, 1)
      }
      this.$store.commit('setHighlights', list)
    },
  }
}
</script>
<style>
.c-highlight-content {
  /* overflow: hidden; */
潘际乾 committed
66 67 68
  border: 1px solid rgba(0,0,0,0);
  border-radius: 5px;
  margin: -1px;
liuxin committed
69 70 71 72 73 74 75 76 77
}
.c-highlight-content.change-light {
  border: 1px solid rgb(201, 171, 1);
}
.c-highlight-content.highlight {
  border: 1px solid red;
}

</style>