<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>
|