duhuizhe
2023-10-16 3aa55dd3f62cee2c1c4c0aa74e1570acf83f8927
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<template>
  <win-lg :title="setting.title" @close="close" :width="'800px'">
    <el-table
      v-loading="loading"
      border
      height="calc(100vh - 400px)"
      :span-method="spanMethod"
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="stageName"
        align="center"
        label="阶段"/>
      <el-table-column
        prop="nodeName"
        align="center"
        label="节点"/>
      <el-table-column
        prop="nodeTimeStart"
        align="center"
        label="自项目开始第n天"
        width="130"/>
      <el-table-column
        prop="nodeTimeDays"
        align="center"
        label="持续天数"
        width="80"/>
      <el-table-column
        align="center"
        label="完成后提醒"
        width="95">
        <template slot-scope="{row}">
          {{ row.completeNotifyStatus === 1 ? '是' : '否' }}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="提醒节点"
        width="240">
        <template slot-scope="{row,$index}">
          <div>阶段:{{ row.notifyStage.join("、") }}</div>
          <div>节点:{{ row.notifyNode.join("、") }}</div>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="临期预警"
        width="80">
        <template slot-scope="{row}">
          {{ row.warnNeed === 1 ? '是' : '否' }}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="附件必传"
        width="80">
        <template slot-scope="{row}">
          {{ row.fileNeed === 1 ? '是' : '否' }}
        </template>
      </el-table-column>
    </el-table>
    <div slot="footer" align="center" class="dialog-footer">
      <my-button name="取消" site="form" @click="close"/>
    </div>
  </win-lg>
</template>
 
<script>
import winLg from '@/components/win/win-lg'
import {getStageNode} from "@/api/projectConfig/buildPlanNode";
import myButton from "@/components/myButton/myButton";
 
export default {
  name: 'detail',
  components: {winLg, myButton},
  props: {
    // setting 中须至少包含控制dialog显示或隐藏的属性,其余属性可拓展
    // 将添加/修改的大量数据及逻辑从列表页面中分离出来,避免列表页面代码过多,审查困难
    // 若此页面须回传数据至父页面,可在引用组件时添加事件,本页面使用this.$emit('事件名',参数1,参数2...)回传数据
    setting: {
      type: Object,
      default: () => {
      }
    }
  },
  data() {
    return {
      loading: false,
      tableData: [],
      spanArr: [],
      pos: 0
    }
  },
  mounted() {
    this.loading = true
    getStageNode({id: this.setting.id}).then(res => {
      this.loading = false
      this.tableData = res
      this.getSpanArr(res)
    }).catch(() => {
      this.loading = false
    })
  },
  methods: {
    close() {
      this.$emit('close')
    },
    spanMethod({row, column, rowIndex, columnIndex}) {
      if (columnIndex === 0) {
        const rowspan = this.spanArr[rowIndex]
        const colspan = rowspan > 0 ? 1 : 0
        return {
          rowspan, //行
          colspan //列
        };
      }
    },
    getSpanArr(data) {
      this.spanArr = [];
      for (let i = 0; i < data.length; i++) {
        if (i === 0) {
          this.spanArr.push(1);
          this.pos = 0;
        } else {
          // 判断当前元素与上一个元素是否相同
          if (data[i].id === data[i - 1].id && data[i].id) {
            this.spanArr[this.pos] += 1;
            this.spanArr.push(0);
          } else {
            this.spanArr.push(1);
            this.pos = i;
          }
        }
      }
    },
  }
}
</script>
 
<style scoped>
 
</style>