licp
2024-10-24 2f11389ca05089b47e8e342c854bc3165edc0980
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
<template>
  <div class="circuit">
    <table border="1" cellpadding="10" class="thermal-table">
      <tr>
        <th :colspan="typeList0.length+4" style="font-size: 18px;">室外分布100-D宽频射灯天线</th>
      </tr>
      <tr>
        <td class="title">样品编号</td>
        <td>1111</td>
        <td class="title">样品型号</td>
        <td>22222</td>
        <td class="title">试验标准</td>
        <td :colspan="typeList0.length">电信</td>
      </tr>
      <tr>
        <td class="title">检验项目</td>
        <td class="title">单位</td>
        <td class="title">标准要求</td>
        <td :colspan="typeList0.length+1" class="title">检验结果</td>
      </tr>
      <!-- 驻波比 -->
      <template>
        <tr>
          <td :rowspan="roadList0.length+2">电压驻波比</td>
          <td :rowspan="roadList0.length+2">/</td>
          <td :rowspan="roadList0.length+2">≤1.5</td>
          <td class="title">最差值</td>
          <td v-for="(item,index) in typeList0" :key="index+'ooo'"><span style="display: inline-block;width: 40%;">{{ item.label }}</span><el-button icon="el-icon-minus" circle size="mini" type="danger" style="margin-left: 4px;" @click="deleteList(index,'端口')"></el-button><el-button icon="el-icon-plus" circle size="mini" type="primary" v-if="index==typeList0.length-1" @click="addInfo('端口')"></el-button></td>
        </tr>
        <tr v-for="(item,index) in roadList0" :key="index+'iiii'">
          <td><span style="display: inline-block;width: 70%;">{{ item.label }}</span><el-button icon="el-icon-minus" circle size="mini" type="danger" @click="deleteList(index,'波段')"></el-button></td>
          <td v-for="(m,i) in typeList0" :key="i+'aaa'">
            <el-input clearable size="small" placeholder="" v-model="value" :disabled="state>1"></el-input>
          </td>
        </tr>
        <tr>
          <td><span style="display: inline-block;width: 70%;" class="title">驻波比最差值</span><el-button icon="el-icon-plus" circle size="mini" type="primary" @click="addInfo('波段')"></el-button></td>
          <td v-for="(m,i) in typeList0" :key="i+'bbb'">
            <span>0</span>
          </td>
        </tr>
      </template>
      <!-- 隔离 -->
      <template>
        <tr>
          <td :rowspan="roadList0.length+2">隔离</td>
          <td :rowspan="roadList0.length+2">dB</td>
          <td :rowspan="roadList0.length+2">≤-25</td>
        </tr>
        <tr v-for="(item,index) in roadList0" :key="index+'eee'">
          <td>{{ item.label }}</td>
          <td :colspan="index<isolationList.length-1?2:(typeList0.length/2>0?3:2)" v-for="(item,index) in isolationList" :key="index+'sss'"><el-input clearable size="small" placeholder="" v-model="item.value" :disabled="state>1"></el-input></td>
        </tr>
        <tr>
          <td class="title">隔离最差值</td>
          <td :colspan="index<isolationList.length-1?2:(typeList0.length/2>0?3:2)" v-for="(item,index) in isolationList" :key="index+'ggg'">{{ item.compValue }}</td>
        </tr>
      </template>
      <!-- 互调 -->
      <template>
        <tr>
          <td :rowspan="bandList0.length+2">互调37dBm</td>
          <td :rowspan="bandList0.length+2">dBm</td>
          <td :rowspan="bandList0.length+2">≤-107</td>
        </tr>
        <tr v-for="(item,index) in bandList0" :key="index+'yyy'">
          <td><span style="display: inline-block;width: 70%;">{{ item.label }}</span><el-button icon="el-icon-minus" circle size="mini" type="danger" @click="deleteList(index,'频段')"></el-button></td>
          <td v-for="(m,i) in typeList0" :key="i+'ccc'"><el-input clearable size="small" placeholder="" v-model="value" :disabled="state>1"></el-input></td>
        </tr>
        <tr>
          <td class="title"><span style="display: inline-block;width: 70%;">互调最差值</span><el-button icon="el-icon-plus" circle size="mini" type="primary" @click="addInfo('频段')"></el-button></td>
          <td v-for="(m,i) in typeList0" :key="i+'hhh'">0</td>
        </tr>
      </template>
    </table>
    <el-dialog
      :title="'选择添加'+currentType"
      :visible.sync="dialogVisible"
      width="20%">
      <el-checkbox-group v-model="checkList" v-if="currentType=='波段'">
        <el-checkbox :label="item.label" v-for="(item,index) in roadList1" :key="index+'lll'">{{ item.label }}</el-checkbox>
      </el-checkbox-group>
      <el-checkbox-group v-model="checkList" v-if="currentType=='频段'">
        <el-checkbox :label="item.label" v-for="(item,index) in bandList1" :key="index+'tttt'">{{ item.label }}</el-checkbox>
      </el-checkbox-group>
      <el-checkbox-group v-model="checkList" v-if="currentType=='端口'">
        <el-checkbox :label="item.label" v-for="(item,index) in typeList1" :key="index+'uuuu'">{{ item.label }}</el-checkbox>
      </el-checkbox-group>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleSure">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      roadList:[],
      typeList:[],
      bandList:[],
      typeList0:[],
      roadList0:[],
      bandList0:[],
      typeList1:[],
      roadList1:[],
      bandList1:[],
      isolationList:[
        {
          compValue:'',
          value:''
        }
      ],
      state: 1,
      value:'',
      dialogVisible:false,
      currentType:'',//波段,频段,端口
      checkList:[],
    }
  },
  watch:{
    roadList0(val){
      this.roadList1 = this.roadList.filter(item=>{
        return !val.find(m=>m.id==item.id)
      })
    },
    typeList0(val){
      this.typeList1 = this.typeList.filter(item=>{
        return !val.find(m=>m.id==item.id)
      })
      this.isolationList = []
      if(val.length<2){
        this.isolationList = [{compValue:'',value:''}]
      }else{
        let num = Math.floor(val.length/2)
        for(let i=0;i<num;i++){
          this.isolationList.push({compValue:'',value:''})
        }
      }
      console.log(this.isolationList)
    },
    bandList0(val){
      this.bandList1 = this.bandList.filter(item=>{
        return !val.find(m=>m.id==item.id)
      })
    },
    dialogVisible(val){
      if(!val){
        this.checkList = []
      }
    }
  },
  mounted() {
    this.getTypeDicts()
  },
  methods: {
    getTypeDicts() {
      this.$axios.post(this.$api.enums.selectEnumByCategory, {
        category: "电路试验波段"
      }).then(res => {
        this.roadList = res.data
        this.roadList0 = this.HaveJson(this.roadList)
      })
      this.$axios.post(this.$api.enums.selectEnumByCategory, {
        category: "电路试验端口"
      }).then(res => {
        this.typeList = res.data
        this.typeList0 = this.HaveJson(this.typeList)
      })
      this.$axios.post(this.$api.enums.selectEnumByCategory, {
        category: "电路试验频段"
      }).then(res => {
        this.bandList = res.data
        this.bandList0 = this.HaveJson(this.bandList)
      })
    },
    deleteList(index,type) {
      switch(type){
        case '波段':
          if(this.roadList0.length>1){
            this.roadList0.splice(index, 1)
          }else{
            this.$message.error('至少保留一条数据')
          }
          break;
        case '频段':
          if(this.bandList0.length>1){
            this.bandList0.splice(index, 1)
          }else{
            this.$message.error('至少保留一条数据')
          }
          break;
        case '端口':
          if(this.typeList0.length>1){
            this.typeList0.splice(index, 1)
          }else{
            this.$message.error('至少保留一条数据')
          }
          break;
      }
    },
    handleSure(){
      switch(this.currentType){
        case '波段':
          this.roadList.forEach((item,index)=>{
            let obj = this.checkList.find(m=>m==item.label)
            if(obj){
              this.roadList0.push(item)
            }
          })
          this.roadList0 = this.handleSortById(this.roadList0)
          break;
        case '频段':
          this.bandList.forEach((item,index)=>{
            let obj = this.checkList.find(m=>m==item.label)
            if(obj){
              this.bandList0.push(item)
            }
          })
          this.bandList0 = this.handleSortById(this.bandList0)
          break;
        case '端口':
          this.typeList.forEach((item,index)=>{
            let obj = this.checkList.find(m=>m==item.label)
            if(obj){
              this.typeList0.push(item)
            }
          })
          this.typeList0 = this.handleSortById(this.typeList0)
          break;
      }
      this.dialogVisible = false
    },
    // 根据Id排序
    handleSortById(arr){
      return arr.sort((a,b)=>{
        if(a.id>b.id){
          return 1;
        }else if(a.id<b.id){
          return -1;
        }else {
          return 0;
        }
      })
    },
    addInfo(type){
      this.currentType = type
      this.dialogVisible = true
    },
  }
}
</script>
 
<style scoped>
.thermal-table{
  min-width: calc(100% - 10px);
  margin: 5px 5px 20px;
  table-layout: fixed;
}
.thermal-table td,.thermal-table th {
  min-width: 150px;
  text-align: center;
  font-size: 14px;
  word-wrap: break-word;
  white-space: normal;
  padding: 5px;
}
.thermal-table .el-input{
  display: flex;
  align-items: center;
}
.title{
  color: #000 !important;
  font-weight: 700 !important;
}
</style>