xyc
2024-10-14 3d72db70fcb406e02b283c4b624e8282ed301422
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
<template>
  <zt-dialog ref="dialog" column="3" title="二项参数" @confirm="handleSaveRows" append-to-body :editAble="true" :hasConfirm="false">
    <zt-table-wraper :paging='false' ref="tableObj" query-url="/taskReliability/TaskBinoParam/page" delete-url="/taskReliability/TaskBinoParam"
                     v-slot="{ table }" >
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
      </el-form>
      <el-table v-loading="table.dataLoading" :data="table.dataList"
                height="600px"
                border @selection-change="table.selectionChangeHandle" @cell-click="handleCellClick"
                :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>
    </zt-table-wraper>
  </zt-dialog>
</template>
 
<script>
  export default {
    name: 'taskBinoParam',
    data() {
      return {
        dataForm: {
          id: '',
          taskId: '',
          successRate: '',
          simulatTimes: '',
          successTimes: '',
          dataThreeList:[]
        },
        editingCell: null,
        dataList: [],
        originalTableData: [],
        originalData: null,
      }
    },
    components: {},
    methods: {
      init(id, row) {
        this.dataForm.taskId = row.taskId
      },
      async handleSaveRows() {
        this.dataForm.dataThreeList = this.$refs.tableObj.dataList
        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数据')
        }
      },
      handleCellClick(row, column) {
        this.editingCell = {row, column}
        this.$nextTick(() => {
          if (this.$refs.editInput) {
            this.$refs.editInput.focus()
          }
        })
        console.log(this.editingCell, 'this.editingCell')
      },
    }
  }
</script>