jinlin
2024-11-19 195bb5267a6ece13363303e177fee7d1fa3941aa
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
143
144
145
146
<template>
  <div>
    <el-row :gutter="5">
      <el-col :span="8">
        <div class="fa-card-a" style="margin-right: 5px;">
          <task @onTaskSelected="onTaskSelected" ref="task"/>
        </div>
      </el-col>
      <el-col :span="10">
        <div class="mod-taskReliability-taskPhase fa-card-a" style="margin-left: 5px;margin-right: 5px;">
          <zt-table-wraper ref="tableObj" defaultNotQuery="true" query-url="/taskReliability/TaskPhase/page"
                           delete-url="/taskReliability/TaskPhase/"
                           @dataLoaded="dataLoaded"
                           :paging='false' v-slot="{ table }">
            <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
              <el-form-item>
                <zt-button v-if="dataForm.taskId" type="add" @click="add()"/>
                <zt-button v-if="dataForm.taskId" type="delete" @click="table.deleteHandle()"/>
              </el-form-item>
            </el-form>
            <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" v-adaptive="{bottomOffset:30}" border
                      :row-class-name="tableRowClassName"
                      @row-click="selectPhase" @selection-change="table.selectionChangeHandle">
              <el-table-column type="selection" width="40" align="center"/>
              <el-table-column prop="phaseName" label="阶段名称" align="center"/>
              <el-table-column prop="phaseDurationRate" label="阶段时长比" align="right" width="120"/>
                <el-table-column prop="remark" label="备注" align="center" width="100"/>
              <zt-table-column-handle :table="table" edit-perm="testReviewComment:update"
                                      delete-perm="taskReliability::delete" width="100">
                <template v-slot="{row}">
                  <zt-table-button type="primary" @click="openEditWin(row)">修改</zt-table-button>
                </template>
              </zt-table-column-handle>
            </el-table>
            <!-- 弹窗, 新增 / 修改 -->
            <add-or-update @refreshDataList="refreshData" ref="AddOrUpdate"/>
          </zt-table-wraper>
        </div>
      </el-col>
      <el-col :span="6">
        <task-phase-model @getList="refreshData" ref="model"/>
      </el-col>
    </el-row>
  </div>
</template>
 
<script>
  import AddOrUpdate from './TaskPhase-AddOrUpdate'
  import Task from "./Task";
  import TaskPhaseModel from "./TaskPhaseModel";
 
  export default {
    data() {
      return {
        dataForm: {
          id: '',
          taskId: '',
          productId: ''
        },
        dataList: [],
        time: null,
        currentId: '',
        isChange: ''
      }
    },
    components: {
      TaskPhaseModel,
      Task,
      AddOrUpdate
    },
    methods: {
      refreshData() {
        this.$refs.tableObj.query()
        this.$refs.task.$refs.tableObj.query()
      },
      dataLoaded(data) {
        this.time = null
        this.dataList = data
        for (let i = 0; i < this.dataList.length; i++) {
          this.time = this.time + Number(this.dataList[i].phaseDurationRate)
        }
        console.log(this.time)
      },
      add() {
        this.$refs.AddOrUpdate.$refs.dialog.init(null, {
          taskId: this.dataForm.taskId,
          productId: this.dataForm.productId,
          time: this.time
        })
      },
      openEditWin(row) {
        console.log(row)
        this.$refs.AddOrUpdate.$refs.dialog.init(row.id, {
          taskId: this.dataForm.taskId,
          productId: this.dataForm.productId,
          time: this.time
        })
      },
      onTaskSelected(row) {
        this.isChange = this.$refs.model.isChange
        this.$refs.task.init(this.isChange)
        if (this.isChange) {
          this.$alert("有未保存的工况模型")
          return;
        }
        this.dataForm.taskId = row.id
        this.dataForm.productId = row.productId
        this.$refs.tableObj.query()
        let param = {
          row: {id: 0},
          productId: 0
        }
        this.$refs.model.init(param)
      },
      selectPhase(row) {
        if (this.$refs.model.isChange) {
          this.$alert("有未保存的工况模型")
          return;
        }
        this.currentId = row.id
        this.$emit('selectPhase', row)
        let param = {
          row: row,
          productId: this.dataForm.productId
        }
        this.$refs.model.init(param)
      },
      tableRowClassName(
        {
          row,
          rowIndex
        }) {
        if (row.id == this.currentId) {
          return 'select-row';
        } else {
          return 'not-select-row';
        }
      }
    }
  }
</script>
<style>
  .el-table .select-row {
    background: rgba(23, 179, 163, 0.2) !important;
  }
</style>