永康嘉持电器有限公司前端
小小儁爺
2025-06-13 a2bce22a3a4df5f4662c373e57c07fa4268aeee1
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div class="body_left">
        <div style="margin:10px 0">
          <i class="el-icon-s-comment" :style="{color:$store.state.settings.theme}" /> 车间信息:
        </div>
        <el-input
          v-model="filterText"
          placeholder="输入关键字进行过滤"
          style="margin-bottom: 20px"
        />
        <el-tree
          ref="tree"
          class="filter-tree body_left_tree"
          :data="shopTree"
          :props="defaultProps"
          highlight-current
          node-key="torg_code"
          default-expand-all
          :style="{height: contentHeight+'px',overflowY:'auto'}"
          :filter-node-method="filterNode"
          @current-change="currentTreeChange"
        />
      </div>
      <div class="body_right">
        <el-tabs ref="elTabs" type="border-card" @tab-click="tabClick">
          <el-tab-pane v-for="item in AnDengTypeArr" :key="item.id" :label="item.name">
            <div :style="{height: (contentHeight+51)+'px'}">
              <div class="pane_top">
                <div style="display: flex;align-items: center">
                  <div class="bar" :style="{background:$store.state.settings.theme}" />
                  <div>响应人员</div>
 
                  <!--                  <i class="el-icon-circle-plus-outline" />-->
                  <el-button
                    v-waves
                    icon="el-icon-circle-plus-outline"
                    :disabled="allowClose"
                    :style="{color:allowClose?'#6f6e6f':$store.state.settings.theme}"
                    style="height: 30px;line-height: 30px;font-size: 22px;padding:10px;margin-left: 10px;"
                    @click="responseUserClick"
                  />
                </div>
                <div style="display: flex;align-content: center">
                  <div>
                    <el-checkbox v-model="allowClose" @change="allowCloseChange">允许关闭</el-checkbox>
                  </div>
                  <div style="margin-left: 5px;cursor: pointer">
                    <el-tooltip class="item" effect="dark" content="当前呼叫类型(启用/关闭)" placement="top">
                      <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />
                    </el-tooltip>
                  </div>
                </div>
              </div>
              <el-empty v-if="AnDengResponUserArr.length===0" :image-size="200" description="暂无数据" />
              <div v-else class="pane_content" :style="{maxHeight:contentHeight+'px',overflowY: 'scroll'}">
                <el-tag
                  v-for="tag in AnDengResponUserArr"
                  :key="tag.id"
                  :closable="!allowClose"
                  type="success"
                  style="margin-right: 10px;margin-bottom: 10px"
                  :style="{color:$store.state.settings.theme}"
                  @close="val=>tagClose(val,item,tag)"
                >
                  {{ tag.username }}
                </el-tag>
 
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
        <el-button
 
          style="position: absolute;top: 13px;right:15px;z-index: 1000"
          icon="el-icon-setting"
          @click="setting"
        >自定义呼叫类型
        </el-button>
      </div>
    </div>
 
    <!--    自定义呼叫类型-->
    <el-dialog
      v-el-drag-dialog
      title="自定义呼叫类型"
      :visible.sync="settingDialogVisible"
      width="800px"
      top="15vh"
      :close-on-click-modal="false"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-button
        v-waves
        type="primary"
        style="margin-bottom: 10px;"
        icon="el-icon-circle-plus-outline"
        @click="addRow()"
      >新增
      </el-button>
      <el-table
        ref="dialogTableDataArrRef"
        class="tableFixed"
        :data="settingDialogTableData"
        :height="contentHeight-300"
        :style="{width: 100+'%',height:contentHeight-300+'px',}"
        border
        :row-class-name="tableRowClassName"
        highlight-current-row
        :header-cell-style="this.$headerCellStyle"
        :cell-style="this.$cellStyle"
      >
        <el-table-column
          width="50"
          label="序号"
          type="index"
          fixed
        />
 
        <el-table-column
          prop="code"
          label="类型编码"
        >
          <template slot-scope="{row}">
            <el-input
              v-if="row.isVisible===1"
              v-model="row.code"
              oninput="value=value.replace(/[^0-9a-zA-Z]/g,'')"
              placeholder="请输入"
            />
            <div v-if="row.isVisible===0">{{ row.code }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="name"
          label="类型名称"
        >
          <template slot-scope="{row}">
            <el-input
              v-if="row.isVisible===1"
              v-model="row.name"
              placeholder="请输入"
            />
            <div v-if="row.isVisible===0">{{ row.name }}</div>
          </template>
        </el-table-column>
 
        <el-table-column
          label="操作"
          width="120"
          fixed="right"
        >
          <template slot-scope="{row}">
            <div class="operationClass">
              <el-button v-if="row.isVisible===1" v-waves type="text" @click="saveRow(row)">保存</el-button>
              <el-button v-if="row.isVisible===1" v-waves type="text" @click="cancelRow(row)">取消</el-button>
              <!--              <el-button v-waves v-if="row.isVisible===0" type="text" @click="editRow(row)">编辑</el-button>-->
              <el-button v-if="row.isVisible===0" v-waves type="text" @click="delRow(row)">删除</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
 
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleCancel">返 回</el-button>
        </div>
      </span>
    </el-dialog>
 
    <el-dialog
      v-el-drag-dialog
      title="响应人员"
      :visible.sync="userDialogVisible"
      width="800px"
      top="10vh"
      :close-on-click-modal="false"
      @closed="handleUserClose"
      @close="handleUserClose"
    >
      <div
        style=" background-color: #fafafa;  padding: 10px;  min-height: 120px;"
        :style="{maxHeight:(contentHeight-300)+'px',overflowY: 'scroll'}"
      >
        <el-tag
          v-for="tag in userDialogArr"
          :key="tag.usercode"
          closable
          type="success"
          style="margin-right: 10px;margin-bottom: 10px"
          :style="{color:$store.state.settings.theme}"
          @close="val=>userTagClose(val,tag)"
        >
          {{ tag.username }}
        </el-tag>
      </div>
      <div>
        <i class="el-icon-s-comment" :style="{color:$store.state.settings.theme}" style="margin: 20px 10px 20px 0" />人员:
      </div>
      <div
        style=" background-color: #fafafa;  padding: 10px;  min-height: 420px;"
        :style="{maxHeight:(contentHeight-300)+'px'}"
      >
 
        <el-input
          v-model="filterUserText"
          placeholder="输入关键字进行过滤"
          style="margin-bottom: 20px; "
        />
        <el-tree
          ref="userTree"
          class="filter-tree"
          :data="userTree"
          :props="userDefaultProps"
          node-key="usercode"
          show-checkbox
          default-expand-all
          :style="{height: (contentHeight-370)+'px',overflowY:'auto'}"
          :filter-node-method="filterUserNode"
          @check="userTreeCheck"
        />
        <!--        @check-change="handleCheckChange"-->
 
      </div>
 
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleUserCancel">取 消</el-button>
          <el-button
            v-waves
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="dialogVisibleUserConfirm"
          >保 存</el-button>
        </div>
      </span>
    </el-dialog>
 
  </div>
</template>
 
<script>
 
import {
  AddUpdateAnDengType, AnDengDigoResponUserSearch, AnDengDigoResponUserSeave, AnDengResponUserCloseSeave,
  AnDengResponUserDeleteSeave,
  AnDengResponUserSearch,
  AnDengTypeSearch,
  DeleteAnDengType
} from '@/api/basicSettings'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import { PrentOrganization } from '@/api/GeneralBasicData'
 
export default {
  name: 'InstallLampList',
  directives: { elDragDialog, waves },
  data() {
    return {
      mainHeight: 0,
      contentHeight: 0,
      filterText: '',
      shopTree: [], // 树形车间
      defaultProps: {
        children: 'children',
        label: 'torg_name'
      },
      settingDialogVisible: false,
      settingDialogTableData: [],
      allowClose: false, // 允许关闭
      AnDengTypeArr: [], // 安灯类型
      AnDengResponUserArr: [], // 安灯用户
      userDialogVisible: false,
      userDefaultProps: {
        children: 'children',
        label: 'username'
      },
      userDialogArr: [],
      userTree: [],
      filterUserText: '',
      treeCheckedKey: []// 树形复选框选中的usercode
 
    }
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val)
    },
    filterUserText(val) {
      this.$refs.userTree.filter(val)
    }
  },
  activated() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    this.handleRequest()
  },
  created() {
    this.handleRequest()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    handleRequest() {
      this.getShopSearch().then(res => {
        if (res.code === '200') {
          this.getAnDengTypeSearch()
        }
      })
    },
    // 获取左侧车间信息
    async getShopSearch() {
      const res = await PrentOrganization()
      this.shopTree = res.data
      this.$nextTick(() => {
        this.$refs.tree.setCurrentKey(this.shopTree[0].torg_code) // 默认选中节点第一个
      })
      return { code: res.code }
    },
    // 获取安灯类型
    async getAnDengTypeSearch() {
      const { data: res } = await AnDengTypeSearch()
      this.AnDengTypeArr = res
      await this.getAnDengResponUserSearch(this.AnDengTypeArr[0].name)
    },
    // 获取安灯人员
    async getAnDengResponUserSearch(name) {
      const data = {
        wkshopcode: this.$refs.tree.getCurrentKey(),
        calltypecode: this.AnDengTypeArr.find(item => item.name === name).code
      }
      const { data: res } = await AnDengResponUserSearch(data)
      this.AnDengResponUserArr = res || []
 
      this.allowClose = this.AnDengResponUserArr[0] ? this.AnDengResponUserArr[0].enable === 'Y' : false
    },
    // tab切换点击
    tabClick(val) {
      this.getAnDengResponUserSearch(val.label)
    },
    // 安灯系统/响应人员删除
    async tagClose(val, tab, tag) {
      const data = {
        ando_cogfigid: tab.id,
        id: tag.id
      }
      const res = await AnDengResponUserDeleteSeave(data)
      if (res.code === '200') {
        await this.getAnDengResponUserSearch(tab.name)
      }
    },
    // 过滤节点
    filterNode(value, data) {
      if (!value) return true
      return data.torg_name.indexOf(value) !== -1
    },
    // 自定义呼叫类型
    async setting() {
      const { data: res } = await AnDengTypeSearch()
      this.settingDialogTableData = res
      this.settingDialogVisible = true
 
      this.settingDialogTableData.forEach(item => {
        let number = Math.random() * Math.random()// 作为删除时的标识符
        number = number === 0 ? (10 + Math.random()) : number
        item.number = number
        item.isVisible = 0
      })
    },
    addRow() {
      if (this.settingDialogTableData.find(i => i.isVisible === 1)) {
        return this.$message.info('请先保存或取消本条记录!')
      }
      let number = Math.random() * Math.random()// 作为删除时的标识符
      number = number === 0 ? (10 + Math.random()) : number
      this.settingDialogTableData.push({
        number,
        isVisible: 1,
        code: '',
        name: ''
      })
    },
    async saveRow(row) {
      console.log(row)
      if (row.code.toString().trim() === '' || row.name.toString().trim() === '') {
        return this.$message.info('类型编码或名称不能为空!')
      }
      const res = await AddUpdateAnDengType([row])
      if (res.code === '200') {
        await this.setting()
      }
    },
    cancelRow(row) {
      this.settingDialogTableData.splice(this.settingDialogTableData.length - 1, 1)
    },
    delRow(row) {
      if (this.settingDialogTableData.find(i => i.isVisible === 1)) {
        return this.$message.info('请先保存或取消本条记录!')
      }
      DeleteAnDengType({ andengtypecode: row.code }).then(res => {
        this.setting()
      })
    },
    handleClose() {
      this.settingDialogTableData = []
    },
    // 返回
    dialogVisibleCancel() {
      this.settingDialogVisible = false
      this.getAnDengTypeSearch()
    },
    // 允许关闭点击事件
    async allowCloseChange() {
      const data = {
        wkshopcode: this.$refs.tree.getCurrentKey(),
        calltypecode: this.AnDengTypeArr[parseInt(this.$refs.elTabs.currentName)].code,
        enable: this.allowClose ? 'Y' : 'N'
      }
      await AnDengResponUserCloseSeave(data)
    },
    // 树形选中行切换点击
    currentTreeChange(val) {
      this.getAnDengResponUserSearch(this.AnDengTypeArr[parseInt(this.$refs.elTabs.currentName)].name)
    },
    // 响应人员点击
    responseUserClick() {
      const loading = this.$loading({
        lock: true,
        text: '正在加载数据,请稍等...',
        spinner: 'el-icon-loading',
        customClass: 'osloading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
 
      const data = {
        wkshopcode: this.$refs.tree.getCurrentKey(),
        calltypecode: this.AnDengTypeArr[parseInt(this.$refs.elTabs.currentName)].code
      }
      AnDengDigoResponUserSearch(data).then(res => {
        if (res.code === '200') {
          this.userTree.push({
            username: '全部',
            children: res.data
          })
 
          res.data.forEach(item => {
            if (item.flag === 'Y') {
              this.treeCheckedKey.push(item.usercode)
              this.userDialogArr.push(item)
            }
          })
 
          setTimeout(() => {
            loading.close()
            this.userDialogVisible = true
 
            this.$nextTick(() => {
              this.$refs.userTree.setCheckedKeys(this.treeCheckedKey)
            })
          }, 1000)
        }
      })
    },
    handleUserClose() {
      this.userTree = []
      this.userDialogArr = []
      this.treeCheckedKey = []
    },
    dialogVisibleUserCancel() {
      this.userDialogVisible = false
    },
    async dialogVisibleUserConfirm() {
      const data = []
 
      this.$refs.userTree.getCheckedKeys().forEach(i => {
        // console.log(i)
        if (i !== undefined) {
          data.push({
            code: i
          })
        }
      })
      this.$store.state.app.buttonIsDisabled = true
      const res = await AnDengDigoResponUserSeave(this.$refs.tree.getCurrentKey(), this.AnDengTypeArr[parseInt(this.$refs.elTabs.currentName)].code, this.allowClose ? 'Y' : 'N', data)
      if (res.code === '200') {
        // this.$refs.userTree.setCheckedKeys([])
        this.userDialogVisible = false
        this.$message.success('保存成功!')
        this.$store.state.app.buttonIsDisabled = false
        await this.getAnDengResponUserSearch(this.AnDengTypeArr[parseInt(this.$refs.elTabs.currentName)].name)
      }
    },
    userTagClose(val, tag) {
      this.treeCheckedKey = this.treeCheckedKey.filter(i => i !== tag.usercode)
      this.userDialogArr = this.userDialogArr.filter(i => i.usercode !== tag.usercode)
      this.$refs.userTree.setCheckedKeys(this.treeCheckedKey)
    },
    userTreeCheck(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) {
      // console.log(obj, checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys, 6)
      this.treeCheckedKey = checkedKeys.filter(i => i !== undefined)
      this.userTree[0].children.forEach(i => {
        if (this.treeCheckedKey.includes(i.usercode)) {
          i.flag = 'Y'
        } else {
          i.flag = 'N'
        }
      })
      this.userDialogArr = this.userTree[0].children.filter(i => i.flag === 'Y')
    },
    // handleCheckChange(data) {
    //   if (data.children) {
    //     data.children.forEach((item) => {
    //       const node = this.$refs.userTree.getNode(item)
    //       if (!node.visible) {
    //         this.$refs.userTree.setChecked(item, false)
    //       }
    //     })
    //   }
    // },
    // 过滤节点
    filterUserNode(value, data) {
      if (!value) return true
      return data.username.indexOf(value) !== -1
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        this.contentHeight = this.mainHeight - 142
      })
    },
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    }
 
  }
}
</script>
 
<!--本页面单独样式-->
<style lang="scss" scoped>
$main_color: #42b983;
.body {
  display: flex;
  flex-direction: row;
}
 
.body_left {
  width: 360px;
  background-color: #fff;
  margin: 10px 0;
  padding: 10px;
  flex-direction: column;
}
 
.body_right {
  width: 100%;
  background-color: #fff;
  margin: 10px 0 10px 10px;
}
 
.pane_top {
  background-color: #fafafa;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  margin-bottom: 20px;
 
  .bar {
    width: 4px;
    height: 20px;
    border-radius: 2px;
    //background-color: $main_color;
    margin-right: 10px;
  }
}
 
.pane_content {
  background-color: #fafafa;
  padding: 10px;
  min-height: 400px;
}
 
.body_left_tree {
  ::v-deep .is-current > .el-tree-node__content {
    background-color: #dedcdc !important;
    font-weight: bolder;
    //color: #FFFFFF;
  }
}
 
::v-deep .el-button--text {
  font-size: 14px;
  cursor: pointer;
}
</style>