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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<template>
  <div>
    <div class="mod-baseReliability-paramDataBasic fa-card-a" style="margin-left: 5px;">
      <zt-table-wraper :defaultNotQuery='true' ref="tableObj"
                       v-slot="{ table }" :paging='false'>
        <el-form :inline="true" :model="dataForm" ref="dataForm" :disabled="dataForm.disabled" label-width="80px">
          <zt-form-item label="产品节点" prop="productId">
            <zt-select v-model="dataForm.productId" :datas="productList" @change="onProductSelected"/>
          </zt-form-item>
          <zt-form-item label="总体任务" prop="taskModelId">
            <zt-select v-model="dataForm.taskId" :datas="taskList" @change="onTaskSelected"/>
          </zt-form-item>
          <zt-form-item label="评定数据" prop="itemId">
            <zt-select v-model="dataForm.itemId" :datas="assessDataList" @change="onAssessDataSelected"/>
          </zt-form-item>
          <zt-form-item label="置信度" prop="confidence">
            <el-input v-model="dataForm.confidence" placeholder="置信度" clearable></el-input>
          </zt-form-item>
          <el-button type="primary" @click="assess()">评定</el-button>
          <el-button type="primary" @click="add()">新增评定数据</el-button>
          <el-button type="primary" @click="handleExpand()">{{expandText}}</el-button>
          <el-dropdown style="margin-left: 10px" @command="download">
            <el-button type="primary">
              下载xml<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="1">输入xml</el-dropdown-item>
              <el-dropdown-item command="2">输出xml</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-form>
        <el-table ref="multipleTable" v-loading="table.dataLoading" :data="dataList" height="100px" v-adaptive="{bottomOffset:70}"
                  row-key="id"
                  :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                  :header-cell-style="{'text-align':'center'}"
                  :expand-row-keys="defultKey"
                  border @selection-change="table.selectionChangeHandle">
          <el-table-column prop="name" label="名称"/>
          <el-table-column prop="runNum" label="试验次数(成败型)" align="right">
          </el-table-column>
          <el-table-column prop="runTimes" label="试验时长(非成败型)" align="right">
          </el-table-column>
          <el-table-column prop="failNum" label="失败次数" align="right">
          </el-table-column>
          <el-table-column prop="assessResult" label="评定结果" align="right">
          </el-table-column>
        </el-table>
        <add-or-update @refreshDataList="refreshData" ref="AddOrUpdate"/>
      </zt-table-wraper>
      <el-dialog v-dialogDrag :close-on-click-modal="false" top="8vh" :visible.sync="dialogVisible" title="模型检查"
                 width="60%" @close="dialogVisible = false">
        <el-tag type="danger" style="margin-bottom: 10px">模型定义/参数配置/评定数据里存在以下问题:</el-tag>
        <el-table :data="modelCheckResult" height="350"
                  :header-cell-style="{'text-align':'center'}">
          <el-table-column prop="category" label="检查结果" align="center" width="150"/>
          <el-table-column prop="taskName" label="任务名称" align="center"/>
          <el-table-column prop="taskPhaseName" label="任务阶段名称" align="center"/>
          <el-table-column prop="gkName" label="工况名称" align="center"/>
          <el-table-column prop="nodeName" label="节点名称" align="center"/>
          <el-table-column prop="modelName" label="模型名称" align="center"/>
          <el-table-column prop="deviceName" label="设备名称" align="center"/>
          <el-table-column prop="paramName" label="参数名称" align="center"/>
        </el-table>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="dialogVisible = false">关 闭</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
  import AddOrUpdate from './RelisbilityAssess-AddOrUpdate'
  import qs from "qs";
  import Cookies from "js-cookie";
 
  export default {
    data() {
      return {
        dataForm: {
          productId: '',
          shipName: '',
          taskId: '',
          itemId: '',
          name: '',
          runTimes: '',
          failNum: '',
          runNum: '',
          assessResult: '',
          confidence: '',
        },
        productList: [],
        taskList: [],
        assessDataList: [],
        dataList: [],
        flag1: false,
        flag2: false,
        defultKey: [],
        isExpand:false,
        expandText:"一键展开",
        dialogVisible: false,
        modelCheckResult: [],
      }
    },
    components: {
      AddOrUpdate
    },
    mounted() {
      this.getProductList()
    },
    methods: {
      async page() {
        let res = await this.$http.post('/taskReliability/ReliabilityAssess/page', this.dataForm)
        console.log(res.data)
        this.dataList = res.data
      },
      // 获取信息
      async onProductSelected(data) {
        this.defultKey = []
        console.log(data, ' onProductSelected(data)')
        this.dataForm.productId = data.id
        this.dataForm.shipName = data.name
        this.setDefultKey()
        await this.zhixin().then(() => {
          if (this.dataForm.taskId&& this.dataForm.itemId) {
            this.page()
          }else{
            this.dataList = []
          }
        })
      },
      async zhixin() {
        await this.getTaskList()
        await this.getAssessDataList()
      },
      setDefultKey() {
        this.defultKey.push(this.dataForm.productId + "")
        console.log(this.defultKey,"this.defultKey")
      },
      onTaskSelected(data) {
        console.log(data, ' onProductSelected(data)')
        this.dataForm.taskId = data.id
        if (this.dataForm.taskId&& this.dataForm.itemId) {
          this.page()
        }
      },
      onAssessDataSelected(data) {
        this.dataForm.itemId = data.id
        if (this.dataForm.taskId&& this.dataForm.itemId) {
          this.page()
        }
      },
      refreshData() {
        this.getAssessDataList();
      },
      async getAssessDataList() {
        let params = {
          productId: this.dataForm.productId
        }
        let res = await this.$http.get('/taskReliability/ReliabilityAssess/getAssessDataList', {params: params})
        this.assessDataList = res.data
        if (this.assessDataList.length > 0) {
          this.dataForm.itemId = this.assessDataList[0].id
        } else {
          this.dataForm.itemId = ''
        }
        this.flag2 = true
      },
      add() {
        this.$refs.AddOrUpdate.$refs.dialog.init(null, {
          productId: this.dataForm.productId,
          shipName: this.dataForm.shipName
        })
      },
      async assess() {
        this.dialogVisible = false
        this.modelCheckResult = []
        if (!this.dataForm.productId || !this.dataForm.taskId || !this.dataForm.itemId || !this.dataForm.confidence) {
          this.$tip.alert("有未填写的数据")
          return
        }
        let res = await this.$http.post('/taskReliability/ReliabilityAssess/assessCheck', this.dataForm)
        if (res.success) {
          if (res.data && res.data.length > 0) {
            this.modelCheckResult = res.data
            this.dialogVisible = true
          } else {
            let res = await this.$http.post('/taskReliability/ReliabilityAssess/assess', this.dataForm)
            if (res.success) {
              console.log(res.data)
              this.dataList = res.data
              this.$alert('评定成功', '提示', {
                confirmButtonText: '确定'
              })
            }
          }
        }
      },
      async getProductList() {
        let res = await this.$http.get('/basicInfo/XhProductModel/getTaskProductList')
        this.productList = res.data
        await this.onProductSelected(this.productList[0])
      },
      async getTaskList() {
        let params = {
          productId: this.dataForm.productId
        }
        let res = await this.$http.get('/taskReliability/Task/getTaskList', {params: params})
        console.log(res.data)
        this.taskList = res.data
        if (this.taskList.length > 0) {
          this.dataForm.taskId = this.taskList[0].id
        } else {
          this.dataForm.taskId = ''
        }
        this.flag1 = true
      },
      handleExpand() {
        this.isExpand = !this.isExpand
        this.$nextTick(() => {
          this.forArr(this.dataList, this.isExpand)
        })
        if (this.isExpand === true) {
          this.expandText = '一键折叠'
        }
        if (this.isExpand === false) {
          this.expandText = '一键展开'
        }
      },
      // 遍历
      forArr(arr, isExpand) {
        arr.forEach(i => {
          this.$refs.multipleTable.toggleRowExpansion(i, isExpand)
          if (i.children) {
            this.forArr(i.children, isExpand)
          }
        })
      },
      async download(selsect) {
        if (!this.dataForm.productId || !this.dataForm.taskId || !this.dataForm.itemId ) {
          this.$tip.alert("有未填写的数据")
          return
        }
          let param = qs.stringify({
            'token': Cookies.get('token'),
            productId: this.dataForm.productId,
            taskId: this.dataForm.taskId,
            itemId: this.dataForm.itemId,
            xml:selsect
          })
          let apiURL = `/taskReliability/ReliabilityAssess/downloadXml`
          window.location.href = `${window.SITE_CONFIG['apiURL']}${apiURL}?${param}`
        }
      },
  }
</script>