hcong
2024-11-08 d7d7da5c09340eafcd2e2c672e6b2c001a4cc0be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
  <span class="description"> {{ description }} </span>
</template>
<script>
import dayjs from 'dayjs';
export default {
  watch: {
    tableData: {
      handler(nv, ov) {
        this.buildDescription()
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    // 段首
    startStr() {
      return `${'  '}`;
    },
    // 段尾
    endStr() {
      return '。';
    },
    buildMonitorNum() {
      let str = '';
      str += this.startStr();
      str += `当前清单包括${this.tableData.length}个监管任务`;
      str += this.endStr();
      return str;
    },
    buildTopTaskNum() {
      let topNames = Array.from(new Set(this.tableData.map((item) => item._topTask.name)))
      let str = '';
      str += this.startStr();
      str += `月度任务有${
        topNames.length
      }个,分别为${topNames.join(',')}`;
      str += this.endStr();
      return str;
    },
    buildScene() {
      let scenes = Array.from(new Set(this.tableData.map(item=>item.sceneType)))
      let str = '';
      str += this.startStr();
      str += `总共${scenes.length}个场景,`;
      str += `包括${scenes.join(',')}场景`;
      str += this.endStr();
      return str;
    },
    buildDescription() {
      let result = '';
      // 监管任务数量
      result += this.buildMonitorNum();
      // 涉及多少总任务
      result += this.buildTopTaskNum();
      // 场景个数和类型
      result += this.buildScene();
      this.description = result
    },
  },
  computed: {
    locationStr() {
      let result = '';
      if (this.location.pName) {
        // result += this.location.pName;
        if (this.location.cName) {
          result += this.location.cName;
          if (this.location.dName) {
            result += this.location.dName;
            if (this.location.tName) {
              result += this.location.tName;
            }
          }
        }
      }
      if (result == '') {
        if (this.location.pName) {
          result += this.location.pName;
        }
      }
      return result;
    },
    time() {
      if (!this.tableData || this.tableData.length == 0) {
        return '';
      } else {
        return dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss');
      }
    }
  },
  props: {
    location: {},
    tableData: []
  },
  data() {
    return {
      description: ''
    };
  }
};
</script>
<style scoped>
.description {
  display: block;
  /* white-space: pre-line; */
  width: 100%;
}
</style>