jinlin
2024-07-22 3a4536445096cdb80d586a67df3c00ab4a0faecb
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
<template>
  <div ref="" style="position: absolute;top:0;right:0;background:#cccccc;width: 400px;"
       :style="'height:'+ left_p + 'px'">
    <el-card style="height: 100%">
      <el-tabs v-model="activeName" id="tabPane">
        <el-tab-pane label="属性" name="first">
          <el-form :model="globalGridAttr">
            <el-form-item v-show="shape!=='custom-circle1'" label="节点名称" prop="nodeText" label-width="80px">
              <el-input v-model="globalGridAttr.nodeText" style="width:100%" @change="onTextChange"></el-input>
            </el-form-item>
            <el-form-item v-show="nodeType=='vote' || (nodeType=='node' && showNumberInput)" label="表决数量" prop="voteNum"
                          label-width="80px">
              <el-input type="number" v-model="globalGridAttr.voteNum" @change="onNumberInputValue"
                        placeholder="请输入数字"></el-input>
            </el-form-item>
            <div v-show="globalGridAttr.productType!=='product_xdy'">
              <el-form-item v-show="nodeType=='node'" label="可靠性分布类型" prop="reliabDistribType" label-width="125px">
                <zt-dict style="width: 100%" v-model="globalGridAttr.reliabDistribType" @input="onReliabDistribType"
                         dict="ReliabDistribType" placeholder="可靠性分布类型" clearable/>
              </el-form-item>
              <el-form-item v-show="nodeType=='node'" label="MTBCF" prop="taskMtbcf" label-width="80px">
                <el-input v-model="globalGridAttr.taskMtbcf" @change="onTaskMtbcfChange"></el-input>
              </el-form-item>
              <el-form-item v-show="nodeType=='node'" label="参数2" prop="taskMtbcfOtherParams2" label-width="80px">
                <el-input v-model="globalGridAttr.taskMtbcfOtherParams2" @change="onTaskMtbcfOther2Change"></el-input>
              </el-form-item>
              <el-form-item v-show="nodeType=='node'" label="参数3" prop="taskMtbcfOtherParams3" label-width="80px">
                <el-input v-model="globalGridAttr.taskMtbcfOtherParams3" @change="onTaskMtbcfOther3Change"></el-input>
              </el-form-item>
              <el-form-item v-show="nodeType=='node'" label="是否可维修" prop="isRepair" label-width="100px">
                <el-select style="width: 100%" v-model="globalGridAttr.isRepair" @change="onIsRepairChange">
                  <el-option
                    v-for="item in isRepair"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
              <div v-show="nodeType=='node' && showRepairInput">
                <el-form-item label="可维修性分布类型" prop="repairDistribType" label-width="140px">
                  <zt-dict v-model="globalGridAttr.repairDistribType" dict="RepairDistribType"
                           @input="onRepairDistribTypeChange" placeholder="维修性分布类型" clearable/>
                </el-form-item>
                <el-form-item label="MTTCR" prop="repairMttcr" label-width="80px">
                  <el-input v-model="globalGridAttr.repairMttcr" @change="onRepairMttcrChange"></el-input>
                </el-form-item>
                <el-form-item label="参数2" prop="repairMttcrOtherParams2" label-width="80px">
                  <el-input v-model="globalGridAttr.repairMttcrOtherParams2" @change="onRepairMttcrOther2Change"></el-input>
                </el-form-item>
                <el-form-item label="参数2" prop="repairMttcrOtherParams3" label-width="80px">
                  <el-input v-model="globalGridAttr.repairMttcrOtherParams3" @change="onRepairMttcrOther3Change"></el-input>
                </el-form-item>
              </div>
            </div>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="样式" name="second">
          <el-row :gutter="5" align="middle" style="margin-top:20px">
            <el-col :span=8 style="font-size: 16px;line-height: 38px">文本大小</el-col>
            <el-col :span=16>
              <el-slider :min=8 :max=20 :step=1 v-model="globalGridAttr.nodeFontSize"
                         @change="onFontSizeChange"></el-slider>
            </el-col>
          </el-row>
          <el-row :gutter="5" align="middle" style="margin-top:20px">
            <el-col :span=8 style="font-size: 16px;line-height: 40px">字体颜色</el-col>
            <el-col :span=16>
              <el-color-picker v-model="globalGridAttr.nodeColor" style="width: 100%"
                               @change="onColorChange"></el-color-picker>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>
 
<script>
  export default {
    name: "configNode",
    data() {
      return {
        globalGridAttr: {
          nodeText: '',
          nodeStroke: '',
          nodeStrokeWidth: '',
          nodeFill: '',
          nodeFontSize: '',
          nodeColor: '',
          nodeUsers: '',
          nodeDate: '',
          dataId: '',
          inspectName: '',
          nodeTypeExt: '',
          statusImg: '',
          reliabDistribType: '',
          repairDistribType: '',
          repairMttcr: '',
          repairMttcrOtherParams2: '',
          repairMttcrOtherParams3: '',
          taskMtbcfOtherParams2: '',
          taskMtbcfOtherParams3: '',
          taskMtbcf: '',
          isRepair: '',
          voteNum: 0,
          productType: ''
        },
        data: {
          dataId: '',
          finishDate: '',
          inspectName: ''
        },
        showNumberInput: false,
        showRepairInput: false,
        isRepair: [
          {
            value: 0,
            label: '否'
          }, {
            value: 1,
            label: '是'
          }
        ],
        text: '',
        dialogVisible: false,
        activeName: 'first',
        curCel: null,
        left_p: document.documentElement.clientHeight * 0.75,
      }
    },
    components: {},
    props: {
    },
    watch: {
    },
    mounted() {
    },
    methods: {
      // 改变字体大小
      onFontSizeChange(e) {
        let val = e
        this.globalGridAttr.nodeFontSize = val
        this.curCel.attr('text/fontSize', val)
        this.curCel.attr('title/fontSize', val)
      },
      // 改变字体颜色
      onColorChange(e) {
        let val = e
        this.globalGridAttr.nodeColor = val
        this.curCel.attr('text/fill', val)
        this.curCel.attr('title/fill', val)
        this.curCel.attr('text/style/color', val)
        this.curCel.attr('title/style/color', val)
      },
      // 改变文本
      onTextChange(e) {
        this.text = e
        this.curCel.attr('text/text', this.text)
      },
      onNodeTypeExtChange(e) {
        if (this.globalGridAttr.nodeTypeExt === 'vote') {
          this.showNumberInput = true;
        } else {
          this.showNumberInput = false;
          this.globalGridAttr.numberInputValue = '';
        }
        this.globalGridAttr.nodeTypeExt = e
        let nodeTypeExt = {
          nodeTypeExt: this.globalGridAttr.nodeTypeExt
        }
        this.curCel.setData(nodeTypeExt)
      },
      // 表决数量
      onNumberInputValue(e) {
        this.globalGridAttr.voteNum = e
        let voteNum = {
          voteNum: this.globalGridAttr.voteNum
        }
        this.curCel.setData(voteNum)
      },
      // 可靠性分布类型
      onReliabDistribType(e) {
        this.globalGridAttr.reliabDistribType = e
        let reliabDistribType = {
          reliabDistribType: this.globalGridAttr.reliabDistribType
        }
        this.curCel.setData(reliabDistribType)
      },
      // mtbf
      onTaskMtbcfChange(e) {
        const numberRegex = /^-?\d+(\.\d+)?$/
        if (numberRegex.test(e)) {
          this.globalGridAttr.taskMtbcf = e
          let taskMtbcf = {
            taskMtbcf: this.globalGridAttr.taskMtbcf
          }
          this.curCel.setData(taskMtbcf)
        } else {
          this.$message.error('输入格式有误,请输入实数')
        }
      },
      // 参数2
      onTaskMtbcfOther2Change(e) {
        const numberRegex = /^-?\d+(\.\d+)?$/
        console.log(e, 'eeeee')
        if (numberRegex.test(e)) {
          this.globalGridAttr.taskMtbcfOtherParams2 = e
          let taskMtbcfOtherParams2 = {
            taskMtbcfOtherParams2: this.globalGridAttr.taskMtbcfOtherParams2
          }
          this.curCel.setData(taskMtbcfOtherParams2)
        } else {
          this.$message.error('输入格式有误,请输入实数')
        }
      },
      onTaskMtbcfOther3Change(e) {
        const numberRegex = /^-?\d+(\.\d+)?$/
        console.log(e, 'eeeee')
        if (numberRegex.test(e)) {
          this.globalGridAttr.taskMtbcfOtherParams3 = e
          let taskMtbcfOtherParams3 = {
            taskMtbcfOtherParams3: this.globalGridAttr.taskMtbcfOtherParams3
          }
          this.curCel.setData(taskMtbcfOtherParams3)
        } else {
          this.$message.error('输入格式有误,请输入实数')
        }
      },
      // 是否可维修
      onIsRepairChange(e) {
        this.showRepairInput = this.globalGridAttr.isRepair === 1;
        this.globalGridAttr.isRepair = e
        let isRepair = {
          isRepair: this.globalGridAttr.isRepair
        }
        this.curCel.setData(isRepair)
      },
      // 可维修性分布类型
      onRepairDistribTypeChange(e) {
        this.globalGridAttr.repairDistribType = e
        let repairDistribType = {
          repairDistribType: this.globalGridAttr.repairDistribType
        }
        this.curCel.setData(repairDistribType)
      },
      // Mttcr
      onRepairMttcrChange(e) {
        const numberRegex = /^-?\d+(\.\d+)?$/
        if (numberRegex.test(e)) {
          this.globalGridAttr.repairMttcr = e
          let repairMttcr = {
            repairMttcr: this.globalGridAttr.repairMttcr
          }
          this.curCel.setData(repairMttcr)
        } else {
          this.$message.error('输入格式有误,请输入实数')
        }
 
      },
      // 可维修性分布类型 参数2
      onRepairMttcrOther2Change(e) {
        const numberRegex = /^-?\d+(\.\d+)?$/
        if (numberRegex.test(e)) {
          this.globalGridAttr.repairMttcrOtherParams2 = e
          let repairMttcrOtherParams2 = {
            repairMttcrOtherParams2: this.globalGridAttr.repairMttcrOtherParams2
          }
          this.curCel.setData(repairMttcrOtherParams2)
        } else {
          this.$message.error('输入格式有误,请输入实数')
        }
      },
      // 可维修性分布类型 参数2
      onRepairMttcrOther3Change(e) {
        const numberRegex = /^-?\d+(\.\d+)?$/
        if (numberRegex.test(e)) {
          this.globalGridAttr.repairMttcrOtherParams3 = e
          let repairMttcrOtherParams3 = {
            repairMttcrOtherParams3: this.globalGridAttr.repairMttcrOtherParams3
          }
          this.curCel.setData(repairMttcrOtherParams3)
        } else {
          this.$message.error('输入格式有误,请输入实数')
        }
      },
      onStatusImgChange(e) {
        this.globalGridAttr.statusImg = e
        let statusImg = {
          statusImg: this.globalGridAttr.statusImg
        }
        this.curCel.setData(statusImg)
        console.log(this.globalGridAttr.statusImg, 'this.globalGridAttr.statusImg')
        console.log(this.curCel, 'this.curCel')
        console.log(this.curCel.attr, 'this.curCel.attr')
        this.curCel.removeTools()
        this.curCel.addTools([
          {
            name: 'button',
            args: {
              markup: [
                {
                  tagName: 'image',
                  selector: 'icon',
                  attrs: {
                    // 'xlink:href': 'https://gw.alipayobjects.com/mdn/rms_43231b/afts/img/A*evDjT5vjkX0AAAAAAAAAAAAAARQnAQ',
                    'xlink:href': statusImg.statusImg,
                    width: 30,
                    height: 30,
                    x: 0,
                    y: 0
                  }
                }
              ]
            }
          }
        ])
      },
      loadData(cell) {
        this.curCel = cell
        if (cell.id) {
          this.nodeType = cell.getData().nodeType
          this.showNumberInput = false
          this.globalGridAttr.nodeStroke = cell.attr('body/stroke')
          this.globalGridAttr.nodeStrokeWidth = cell.attr('body/strokeWidth')
          this.globalGridAttr.nodeFill = cell.attr('body/fill')
          // globalGridAttr.nodeFontSize = cell.attr('text/fontSize')
          // globalGridAttr.nodeFontSize = cell.attr('title/fontSize')
          this.globalGridAttr.nodeFontSize = cell.attr('text/fontSize') ? cell.attr('text/fontSize') : cell.attr('title/fontSize')
          this.globalGridAttr.nodeColor = cell.attr('text/fill') ? cell.attr('text/fill') : cell.attr('title/fill') ? cell.attr('title/fill') : cell.attr('label/text/fill')
          // globalGridAttr.nodeColor = cell.attr('text/fill')
          // globalGridAttr.nodeColor = cell.attr('title/fill')
          // globalGridAttr.nodeColor = cell.attr('text/style/color')
          // globalGridAttr.nodeColor =  cell.attr('title/style/color')
          this.globalGridAttr.nodeUsers = cell.attr('approve/users')
          this.globalGridAttr.nodeText = cell.attr('text/text')
          this.globalGridAttr.nodeDate = cell.attr('title/text')
          this.globalGridAttr.dataId = cell.getData().dataId
          this.globalGridAttr.inspectName = cell.getData().inspectName
          this.globalGridAttr.nodeTypeExt = cell.getData().nodeTypeExt
          this.globalGridAttr.statusImg = cell.getData().statusImg
          this.globalGridAttr.reliabDistribType = cell.getData().reliabDistribType
          this.globalGridAttr.repairDistribType = cell.getData().repairDistribType
          this.globalGridAttr.repairMttcr = cell.getData().repairMttcr
          this.globalGridAttr.repairMttcrOther = cell.getData().repairMttcrOther
          this.globalGridAttr.taskMtbcf = cell.getData().taskMtbcf
          this.globalGridAttr.taskMtbcfOther = cell.getData().taskMtbcfOther
          this.globalGridAttr.isRepair = cell.getData().isRepair
          this.globalGridAttr.voteNum = cell.getData().voteNum
          this.globalGridAttr.productType = cell.getData().productType
          if (this.nodeType === 'vote' || this.globalGridAttr.nodeTypeExt === 'vote' || (cell.getData().voteNum !== undefined && cell.getData().voteNum !== '')) {
            console.log(cell.getData().voteNum, 'cell.getData().voteNum')
            this.showNumberInput = true
          }
          this.showRepairInput = cell.getData().isRepair
          cell.removeTools()
          cell.addTools([
            {
              name: 'button',
              args: {
                markup: [
                  {
                    tagName: 'image',
                    selector: 'icon',
                    attrs: {
                      // 'xlink:href': 'https://gw.alipayobjects.com/mdn/rms_43231b/afts/img/A*evDjT5vjkX0AAAAAAAAAAAAAARQnAQ',
                      'xlink:href': this.globalGridAttr.statusImg,
                      width: 30,
                      height: 30,
                      x: 0,
                      y: 0
                    }
                  }
                ]
              }
            }
          ])
        }
      }
    }
  }
</script>
 
<style>
  #tabPane .el-tabs__header.is-top .el-tabs__nav-scroll {
    width: 100% !important;
  }
 
  #tabPane .el-color-picker__trigger {
    width: 100%;
  }
</style>