gaoluyang
2025-02-20 f5ecc0ec0663cf26476c9ee37631539a96f9e6f5
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
<template>
  <div class="ins_order_config">
    <div>
      <el-row class="title">
        <el-col :span="6" style="padding-left: 20px;text-align: left;">电缆配置</el-col>
        <el-col :span="18" style="text-align: right;">
          <el-button size="medium" @click="outConfig">
            <span style="color: #3A7BFA;">返 回</span>
          </el-button>
          <el-button size="medium" type="primary" @click="save">保 存</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="search">
      <el-radio-group v-model="currentTab" size="small" style="margin-left: 20px;" @input="changeTab">
        <el-radio-button label="绝缘">绝 缘</el-radio-button>
<!--        <el-radio-button label="护套">护 套</el-radio-button>-->
      </el-radio-group>
      <div v-if="currentTab=='绝缘'" class="search_thing">
        <div class="search_label">芯数:</div>
        <el-select v-model="insulating.num" allow-create
                   clearable
                   default-first-option
                   filterable
                   multiple
                   size="small">
          <el-option v-for="item in quantityList" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </div>
      <div v-if="currentTab=='绝缘'" class="search_thing">
        <div class="search_label">检验标准:</div>
        <el-select v-model="insulating.standardMethodListId" disabled placeholder="请选择检验标准"
                   size="small"
        @change="(value)=>methodChange(value)">
          <el-option v-for="item in standards" :key="item.id" :label="item.code" :value="item.id">
          </el-option>
        </el-select>
      </div>
<!--      <div class="search_thing" v-if="currentTab=='护套'">-->
<!--        <div class="search_label">检验标准:</div>-->
<!--        <el-select v-model="sheath.standardMethodListId" placeholder="请选择检验标准" size="small"-->
<!--                   disabled-->
<!--        @change="(value)=>methodChange(value)">-->
<!--          <el-option v-for="item in standards" :key="item.id" :label="item.code" :value="item.id">-->
<!--          </el-option>-->
<!--        </el-select>-->
<!--      </div>-->
    </div>
    <div class="table">
      <el-table ref="productTable" :data="productList" :row-class-name="tableRowClassName"
                border class="el-table" height="100%"
        style="margin-bottom: 10px;" tooltip-effect="dark" @select="upProductSelect"
        @selection-change="selectProduct" @select-all="handleAll">
        <el-table-column :selectable="selectable" type="selection" width="65"></el-table-column>
        <el-table-column label="检验项分类" min-width="140" prop="inspectionItemClass" show-overflow-tooltip></el-table-column>
        <el-table-column label="检验项" min-width="140" prop="inspectionItem" show-overflow-tooltip>
          <template slot="header" slot-scope="scope">
            <div style="display: flex;align-items: center;flex-direction: column;font-size: 14px">
              <span>检验项</span>
              <el-input
                v-if="active==1"
                v-model="inspectionItem"
                placeholder="请输入"
                size="mini"
                @input="searchFilterList"/>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="检验项子项" min-width="140" prop="inspectionItemSubclass" show-overflow-tooltip>
          <template slot="header" slot-scope="scope">
            <div style="display: flex;align-items: center;flex-direction: column;font-size: 14px">
              <span>检验项子项</span>
              <el-input
                v-if="active==1"
                v-model="inspectionItemSubclass"
                placeholder="请输入"
                size="mini"
                @input="searchFilterList"/>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="要求描述" min-width="220px" prop="tell">
          <template slot-scope="scope">
            <el-input v-if="active==1&&(isAskOnlyRead || isSpecial)" v-model="scope.row.tell" :autosize="{ minRows: 1, maxRows: 3}" clearable placeholder="要求描述"
                      size="small" type="textarea"></el-input>
            <span v-else>
                <template >{{ scope.row.tell }}</template>
              </span>
          </template>
        </el-table-column>
        <el-table-column label="要求值" min-width="220px" prop="ask">
          <template slot-scope="scope">
            <el-input v-if="active==1&&(isAskOnlyRead || isSpecial)" v-model="scope.row.ask" :autosize="{ minRows: 1, maxRows: 3}" clearable placeholder="要求值"
                      size="small" type="textarea"></el-input>
            <span v-else>{{ scope.row.ask }}</span>
          </template>
        </el-table-column>
        <el-table-column label="条件" min-width="140" prop="radius" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-input v-if="active==1&&(isAskOnlyRead || isSpecial)&&!scope.row.inspectionItem.includes('高温压力试验')" v-model="scope.row.radius" :autosize="{ minRows: 1, maxRows: 3}" clearable placeholder="要求描述"
                      size="small" type="textarea">
            </el-input>
            <el-select v-if="scope.row.inspectionItem.includes('高温压力试验') && active == 1" v-model="scope.row.radius" clearable
                       placeholder="条件"
                       size="small">
              <el-option v-for="(a,i) in JSON.parse(scope.row.radiusList)" :key="i" :label="a" :value="a"></el-option>
            </el-select>
            <span v-if="active != 1">{{scope.row.radius}}</span>
          </template>
        </el-table-column>
        <el-table-column label="试验方法" min-width="120" prop="methodS" show-overflow-tooltip>
          <template slot="header" slot-scope="scope">
            <div style="display: flex;align-items: center;flex-direction: column;font-size: 14px">
              <span>试验方法</span>
              <el-input
                v-if="active==1"
                v-model="methodS"
                placeholder="请输入"
                size="mini"
                @input="searchFilterList"/>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="计量单位" prop="unit" show-overflow-tooltip width="100"></el-table-column>
        <el-table-column label="单价" prop="price" show-overflow-tooltip width="100"></el-table-column>
        <el-table-column label="区间" min-width="120" prop="section" show-overflow-tooltip></el-table-column>
        <el-table-column label="子实验室" min-width="130" prop="sonLaboratory" show-overflow-tooltip></el-table-column>
        <el-table-column :filter-method="filterHandler" :filters="filters" label="子实验室" min-width="130" prop="sonLaboratory"
          show-overflow-tooltip></el-table-column>
        <el-table-column v-if="isSpecial"
          fixed="right"
          label="操作"
          width="100">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="addProductList(productList,scope.row,scope.$index)" v-if="!scope.row.repetitionTag">插入行</el-button>
            <el-button type="text" size="small" v-if="!!scope.row.repetitionTag&&scope.row.delete" @click="deleteProductList(scope.$index,productList)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
 
<script>
import { Tree } from 'element-ui'
export default {
  props: {
    active: {
      type: Number,
      default: () => 0
    },
    sampleSelectionList: {
      type: Array,
      default: () => []
    },
    isSpecial: {
      type: Boolean,
      default: () => false
    },
  },
  data(vm) {
      return {
        standardList:[],
        vaule0:'',
        currentTab:'绝缘',
        upIndex:0,
        productList: [],
        productIds: [],
        sample: [],
        tree: '',
        standards: [],
        insulating: {
          standardMethodListId: null,
          insProduct: [],
          num: []
        },
        // sheath: {
        //   standardMethodListId: null,
        //   insProduct: []
        // },
        isAskOnlyRead: false,
        inspectionItem:null,
        inspectionItemSubclass:null,
        methodS:null,
        filters: [],
        quantityList: [],
      }
  },
  mounted() {
    this.$parent.sampleIds.forEach(a => {
      for (var i = 0; i < this.$parent.sampleList.length; i++) {
        if (this.$parent.sampleList[i].id == a) {
          this.sample.push(this.$parent.sampleList[i])
          if(this.$parent.sampleList[i].insulating !== undefined && this.$parent.sampleList[i].insulating !== null){
            this.insulating = this.$parent.sampleList[i].insulating
          }
          // if(this.$parent.sampleList[i].sheath !== undefined && this.$parent.sampleList[i].sheath !== null){
          //   this.sheath = this.$parent.sampleList[i].sheath
          // }
          break
        }
      }
    })
    this.selectsStandardMethodByFLSSM2()
  },
  methods: {
    // 检验项列表筛选
    searchFilterList () {
      const vtw = {
        inspectionItem: this.inspectionItem, // 检验项
        inspectionItemSubclass: this.inspectionItemSubclass, // 检验项子项
        methodS: this.methodS, // 试验方法
      }
      const isHaveValue = Object.values(vtw).some(item => {
        return item
      })
      if (isHaveValue) {
        for(let i in vtw) {
          if (vtw[i]) {
            this.productList = this.productList0.filter((item) => {
              return item[i] && item[i].includes(vtw[i])
            })
          }
        }
      } else {
        // 没有查询条件时渲染所有数据
        this.productList = this.productList0
      }
    },
    // 要求值变化时
    requestChange(e, row,type) {
      this.sampleList.map(item => {
        if (this.sampleIds.indexOf(item.id) > -1) {
          item.insProduct.map(i => {
            if(i.id == row.id){
              if(row.repetitionTag){
                if(row.repetitionTag==i.repetitionTag){
                  i[type] = e
                }
              }else{
                if(!i.repetitionTag){
                  i[type] = e
                }
              }
            }
            return i
          })
        }
        return item
      })
    },
    outConfig() {
      this.$parent.cableConfigShow = false
    },
    selectProduct(val) {
      this.productIds = []
      val.forEach(a => {
        this.productIds.push(a.id)
      })
    },
    upProductSelect(selection, row) {
      row.state = row.state == 1 ? 0 : 1
    },
    handleAll(e) {
      if (e.length > 0) {
        this.productList.map(m => {
          m.state = 1
          return m
        })
      } else {
        this.productList.map(m => {
          m.state = 0
          return m
        })
      }
      this.$nextTick(() => {
        this.$refs.productTable.doLayout()
      })
    },
    tableRowClassName({
      row,
      rowIndex
    }) {
      if (row.state === 0) {
        return '';
      }
      return 'warning-row';
    },
    selectable() {
      if (this.active > 1) {
        return false
      } else {
        return true
      }
    },
    selectsStandardMethodByFLSSM2() {
      this.standards = []
      this.$axios.post(this.$api.standardTree.selectsStandardMethodByFLSSM, {
        tree: this.$parent.selectTree
      }).then(res => {
        try {
          if (res.data.standardMethodList.length == 0 && this.selectTree.split('-').length == 5) {
            let arr = this.selectTree.split('-')
            let arr0 = arr.slice(0, arr.length - 1)
            let selectTree = arr0.join('-').substring(0, arr0.join('-').length - 1)
            this.$axios.post(this.$api.standardTree.selectsStandardMethodByFLSSM, {
              tree: selectTree
            }).then(ress => {
              this.standards = ress.data.standardMethodList
            })
          } else {
            this.standards = res.data.standardMethodList
          }
        } catch (e) {}
      })
      this.insulating.standardMethodListId = this.sampleSelectionList[0].standardMethodListId
      // 查询检测标准下拉框选项
      if (this.insulating.insProduct.length > 0) {
        this.productList = this.insulating.insProduct
        setTimeout(() => {
          this.productList.forEach(a => {
            if (a.state == 1) this.toggleSelection(a)
          })
        }, 200)
      } else {
        this.methodChange(this.sampleSelectionList[0].standardMethodListId)
      }
    },
    methodChange(val) {
      if (val === null || val === '') return
      let standard = this.standards.find(a => a.id === val)
      if(standard!=null && standard.code==='技术要求'){
        this.isAskOnlyRead = true
      }else{
        this.isAskOnlyRead = false
      }
      let selectTreeList = this.$parent.selectTree.split(" - ")
      this.$parent.addObj.model&&(selectTreeList[selectTreeList.length - 1] = this.$parent.addObj.model)
      const model = this.sampleSelectionList[0].model
      const modelNum = this.sampleSelectionList[0].modelNum
      const cores = this.sampleSelectionList[0].cores
      const conductorMaterial = this.sampleSelectionList[0].conductorMaterial
      const conductorType = this.sampleSelectionList[0].conductorType
      this.$axios.post(this.$api.standardTree.selectStandardProductList, {
        model: this.$parent.addObj.model?this.$parent.addObj.model:model,
        modelNum: modelNum,
        cores: cores,
        conductorMaterial: conductorMaterial,
        conductorType: conductorType,
        standardMethodListId: val,
        factory: selectTreeList.join(" - "),
        isCableTag: '1',
      }, {
        headers: {
          'Content-Type': 'application/json'
        }
      }).then(res => {
        res.data.forEach(a => {
          a.state = 0
        })
        // this.insulating.insProduct = res.data
        // this.sheath.insProduct = res.data
        this.productList = res.data
      })
    },
    toggleSelection(row) {
      this.$refs.productTable.toggleRowSelection(row, true);
    },
    save(){
      // if(this.insulating.insProduct.length === 0 && this.sheath.insProduct.length === 0){
      //   this.$message.error('缺少配置无法保存')
      //   return
      // }
      this.insulating.insProduct = this.productList
      if(this.insulating.insProduct.length !== 0){
        if(this.insulating.num.length === 0){
          this.$message.error('缺少芯数无法保存')
          return
        }
      }
      // this.sample.forEach(a=>{
      //   a.insulating = this.insulating
      //   a.sheath = this.sheath
      // })
      if (this.currentTab === '绝缘') {
        this.sample.forEach(a => {
          a.insulating = this.insulating
        })
      }
      this.$emit('goBackAdd')
      this.$message.success('已保存')
    },
    changeTab(val){
      if(val==='绝缘'){
        this.productList = this.insulating.insProduct
      }
      setTimeout(() => {
        this.productList.forEach(a => {
          if (a.state == 1) this.toggleSelection(a)
        })
      }, 100)
    },
    filterHandler(value, row, column) {
      const property = column['property'];
      return row[property] === value;
    },
    addProductList(productList,row,index){
      let list = productList.filter(m=>{
        if(m.id==row.id){
          m.delete = false
        }
        return m.id==row.id
      })
      let num = list.length
      let obj = this.HaveJson(row)
      obj.repetitionTag = num
      obj.delete = true
      obj.state = 0
      productList.splice(index+num,0,obj)
    },
    deleteProductList(index,list){
      if(list[index-1]&&list[index-1].repetitionTag){
        list[index-1].delete=true
      }
      list.splice(index,1)
    },
  }
}
</script>
 
<style scoped>
.ins_order_config {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }
 
  .ins_order_config::-webkit-scrollbar {
    width: 0;
  }
 
  .title {
    height: 60px;
    line-height: 60px;
  }
 
  .search {
        background-color: #fff;
        height: 80px;
        display: flex;
        align-items: center;
    }
 
    .search_thing {
        width: 300px;
        display: flex;
        align-items: center;
    }
 
    .search_label {
        width: 100px;
        font-size: 14px;
        text-align: right;
    }
 
    .search_input {
        width: calc(100% - 70px);
    }
  .table {
        margin-top: 10px;
        background-color: #fff;
        width: calc(100% - 40px);
        height: calc(100% - 60px - 80px - 26px - 24px);
        padding: 20px;
    }
</style>
<style>
  .ins_order_config .has-gutter .el-table__cell .cell {
    line-height: 30px;
    background-color: #fafafa;
  }
 
  .ins_order_config .has-gutter .el-table__cell {
    background-color: #fafafa !important;
  }
 
  .ins_order_config .el-table__row .cell {
    font-size: 12px;
  }
 
  .ins_order_config .el-table .warning-row .cell {
    color: #3A7BFA;
  }
</style>