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
147
148
149
150
151
152
153
154
155
156
157
158
159
<template>
  <zt-dialog ref="dialog" column="3" title="二项参数" @confirm="handleSaveRows" append-to-body :editAble="true"
             :hasConfirm="false">
    <el-row :gutter="5">
      <el-col :span="6">
        <el-form :inline="true" :model="dataForm" style="padding: 0">
          <el-form-item style="margin: 0">
            <span style="font-size: 17px">二项分布设备列表</span>
          </el-form-item>
        </el-form>
        <el-table :data="sbData" @row-click="selectSb" border highlight-current-row
                  :header-cell-style="{'text-align':'center'}">
          <el-table-column prop="namePath" label="二项分布设备" align="left"/>
        </el-table>
      </el-col>
      <el-col :span="18">
        <el-form :inline="true" :model="dataForm" style="padding: 0">
          <el-form-item style="margin: 0">
            <span style="font-size: 17px">二项分布设备参数</span>
          </el-form-item>
          <el-form-item style="float: right;margin: 0">
            <el-button type="primary" @click="tongXia()">与第一行总次数和成功次数相同</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="loading" :data="tableData" border @cell-click="handleCellClick"
                  height="600px"
                  :header-cell-style="{'text-align':'center'}">
          <!--        <el-table-column type="selection" width="40"/>-->
          <el-table-column prop="phaseName" label="阶段" align="center"/>
          <el-table-column prop="operatConditName" label="工况" align="center"/>
          <el-table-column prop="productName" label="二项分布设备" align="center"/>
          <el-table-column prop="successRate" label="成功率" width="100" align="right">
            <template slot-scope="scope">
                    <span
                      v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property">
                       <el-input ref="editInput"
                                 autosize v-model="scope.row.successRate"
                                 placeholder="成功率"></el-input>
                    </span>
              <span v-else>{{scope.row.successRate}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="simulatTimes" label="总次数" align="center" width="100">
            <template slot-scope="scope">
                    <span
                      v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property">
                       <el-input ref="editInput"
                                 autosize v-model="scope.row.simulatTimes"
                                 placeholder="总次数"></el-input>
                    </span>
              <span v-else>{{scope.row.simulatTimes}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="successTimes" label="成功次数" align="center" width="100">
            <template slot-scope="scope">
                    <span
                      v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property">
                       <el-input ref="editInput"
                                 autosize v-model="scope.row.successTimes"
                                 placeholder="成功次数"></el-input>
                    </span>
              <span v-else>{{scope.row.successTimes}}</span>
            </template>
          </el-table-column>
<!--          <el-table-column>-->
<!--            <template slot-scope="scope">-->
<!--              <zt-table-button @click="tongXia(scope.row,scope.$index)">同下</zt-table-button>-->
<!--              {{scope.$index+1}}-->
<!--            </template>-->
<!--          </el-table-column>-->
        </el-table>
      </el-col>
    </el-row>
  </zt-dialog>
</template>
 
<script>
  export default {
    name: 'taskBinoParam',
    data() {
      return {
        dataForm: {
          id: '',
          taskId: '',
          shipId: '',
          successRate: '',
          simulatTimes: '',
          successTimes: '',
          dataThreeList: []
        },
        loading: false,
        editingCell: null,
        tableData: [],
        dataList: [],
        sbData: [],
        originalTableData: [],
        originalData: null,
      }
    },
    components: {},
    methods: {
      async init(id, row) {
        this.dataForm.taskId = row.taskId
        this.dataForm.shipId = row.shipId
        let params = {
          shipId: this.dataForm.shipId
        }
        let res = await this.$http.get('/taskReliability/TaskBinoParam/getSb', {params: params})
        if (res.success) {
          this.sbData = res.data
        }
      },
      async selectSb(row) {
        this.loading = true
        let params = {
          productId: row.id,
          taskId: this.dataForm.taskId
        }
        let res = await this.$http.get('/taskReliability/TaskBinoParam/page', {params: params})
        if (res.success) {
          this.loading = false
          this.tableData = res.data
        }
      },
      async handleSaveRows() {
        this.dataForm.dataThreeList = this.tableData
        console.log(this.dataForm, 'this.dataForm this.dataForm')
        let res = await this.$http.post('/taskReliability/TaskBinoParam/save', this.dataForm)
        if (res.success) {
          console.log(res.data)
          await this.$tip.success()
          this.originalData = null
          this.dataForm.dataThreeList = null
          this.$refs.tableObj.query()
          this.originalTableData = JSON.parse(JSON.stringify(this.dataList)); // 更新初始数据为当前数据
          console.log(this.originalTableData, 'this.originalTableData 当前表格json数据')
        }
      },
      tongXia(row,index){
        console.log(this.tableData[0].simulatTimes,'this.tableData[0].simulatTimes')
        console.log(this.tableData[0].successTimes,'this.tableData[0].successTimes')
        for(let i=1;i<this.tableData.length; i++){
          this.tableData[i].simulatTimes = this.tableData[0].simulatTimes
          this.tableData[i].successTimes = this.tableData[0].successTimes
        }
        this.handleSaveRows()
      },
      handleCellClick(row, column) {
        this.editingCell = {row, column}
        this.$nextTick(() => {
          if (this.$refs.editInput) {
            this.$refs.editInput.focus()
          }
        })
        console.log(this.editingCell, 'this.editingCell')
      },
    }
  }
</script>