jinlin
2024-08-07 38d87eb232eadb24fdcc7602609a6ec3592df7bd
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
<template>
  <div>
    <el-row :gutter="16">
      <el-col :span="14">
        <div class="mod-taskReliability-operatCondit}">
          <div class="fa-card-a">
            <div style="margin-top: 10px">
              <zt-select v-model="dataForm.productId" placeholder="请选择产品节点" :datas="productList"
                         @change="onProductSelected"/>
            </div>
            <zt-table-wraper ref="tableObj" query-url="/taskReliability/OperatCondit/page" defaultNotQuery="true"
                             delete-url="/taskReliability/OperatCondit/"
                             v-slot="{ table }" :paging='false'>
              <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
                <el-form-item>
                  <zt-button v-if="dataForm.productId" type="query" @click="table.query()"/>
                  <zt-button v-if="dataForm.productId" type="add" @click="add()"/>
                  <zt-button v-if="dataForm.productId" type="delete" @click="table.deleteHandle()"/>
                </el-form-item>
              </el-form>
              <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px"
                        :row-class-name="tableRowClassName"
                        v-adaptive="{bottomOffset:70}"
                        border @row-click="selectOperatCondit" @selection-change="table.selectionChangeHandle">
                <el-table-column type="selection" width="40" align="center"/>
                <el-table-column prop="name" label="工况名称"/>
                <el-table-column prop="remark" label="备注"
                />
                <zt-table-column-handle :table="table"
                                        delete-perm="taskReliability::delete"/>
              </el-table>
              <!-- 弹窗, 新增 / 修改 -->
              <add-or-update @refreshDataList="table.query" ref="AddOrUpdate"/>
            </zt-table-wraper>
          </div>
        </div>
      </el-col>
      <el-col :span="10">
        <div class="fa-card-a">
          <opera-condit-model ref="model"/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
 
<script>
  import AddOrUpdate from './OperatCondit-AddOrUpdate'
  import OperaConditModel from "./OperatConditModel";
 
  export default {
    data() {
      return {
        productList: [],
        dataForm: {
          productId: '',
        },
        isSelect: false,
        currentId: ''
      }
    },
    mounted() {
      this.getTaskProductList()
    },
    components: {
      OperaConditModel,
      AddOrUpdate
    },
    methods: {
      add() {
        this.$refs.AddOrUpdate.$refs.dialog.init(null, {productId: this.dataForm.productId})
      },
      onProductSelected(data) {
        this.dataForm.productId = data.id
        this.$refs.tableObj.query()
      },
      async getTaskProductList() {
        let res = await this.$http.get('/basicInfo/XhProductModel/getTaskProductList')
        this.productList = res.data
        console.log(this.productList, ' async getTaskProductList()')
        this.onProductSelected(this.productList[0])
      },
      selectOperatCondit(row) {
        if (this.$refs.model.isChange) {
          this.$alert("有未保存的工况模型")
          return;
        }
        this.currentId = row.id
        this.$emit('selectOperatCondit', 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>