田源
2025-01-15 78fa1f005a9ec2581611e53d7eba8efeacb4df6e
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
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
<template>
  <el-container>
    <el-aside>
      <basic-container>
        <div ref="TreeBox" style="height: calc(100vh - 154px);!important;">
          <!-- 左侧树         -->
          <div style="height:  calc(100vh - 190px);">
            <avue-tree v-loading="loading" :data="treeData" :option="treeOption" @node-click="nodeClick">
              <span slot-scope="{ node, data }" class="el-tree-node__label">
               <span>
                 <icon-show :name="data.icon"></icon-show>
                    {{ (node || {}).label }}
                </span>
              </span>
            </avue-tree>
          </div>
        </div>
      </basic-container>
    </el-aside>
 
    <el-main>
      <basic-container>
        <avue-crud
          ref="crud"
          :data="data"
          :option="option"
          :page.sync="page"
          :table-loading="tableLoading"
          @size-change="sizeChange"
          @current-change="currentChange"
          @selection-change="selectChangeHandler"
          @search-change="handleSearch"
          @search-reset="handleReset"
          @row-click="rowClickHandler">
          <template slot="menuLeft">
            <el-button v-if="permissionList.addBtn" class="button-custom-icon" size="small" type="primary"
                       @click="addHandler">
              <icon-show :name="permissionList.addBtn.source"></icon-show>
              创建
            </el-button>
            <el-button v-if="permissionList.importBtn" class="button-custom-icon" plain size="small" type="primary"
                       @click="upLoadClickHandler">
              <icon-show :name="permissionList.importBtn.source"></icon-show>
              导入
            </el-button>
            <el-button v-if="permissionList.exportBtn" class="button-custom-icon" plain size="small" type="primary"
                       @click="exportClickHandler">
              <icon-show :name="permissionList.exportBtn.source"></icon-show>
              导出
            </el-button>
            <el-button v-if="permissionList.RIGHTBtn" class="button-custom-icon" plain size="small" type="primary"
                       @click="uiAuthorHandler">
              <icon-show :name="permissionList.RIGHTBtn.source"></icon-show>
              授权
            </el-button>
          </template>
          <template slot="menu" slot-scope="scope">
            <el-button v-if="permissionList.editBtn" size="small" type="text"
                       @click="rowEditBtnClick(scope.row)">
              <icon-show :name="permissionList.editBtn.source"></icon-show>
              编辑
            </el-button>
            <el-button v-if="permissionList.delBtn" size="small" type="text"
                       @click="rowDeleteHandler(scope.row)">
              <icon-show :name="permissionList.delBtn.source"></icon-show>
              删除
            </el-button>
            <el-button v-if="permissionList.cloneBtn" size="small" type="text"
                       @click="rowCloneHandler(scope.row)">
              <icon-show :name="permissionList.cloneBtn.source"></icon-show>
              克隆
            </el-button>
          </template>
          <template slot="plName" slot-scope="{row}">
            <el-link type="primary" @click="linkClickHandler(row)">{{ row.plName }}</el-link>
          </template>
        </avue-crud>
        <!-- 创建编辑自定义对话框    -->
        <el-dialog
          v-dialogDrag
          v-loading="dialogLoading"
          :close-on-click-modal="false"
          :title="dialogType === 'add' ? ' 创建 上下文' : '编辑 上下文'"
          :visible.sync="dialogVisible"
          append-to-body="true"
          class="avue-dialog"
          width="500px"
          @close="dialogClose"
        >
          <el-form ref="form" :model="form" :rules="rules" label-width="95px" size="small">
            <el-form-item label="名称:" prop="plName">
              <el-input v-model="form.plName"></el-input>
            </el-form-item>
            <el-form-item label="UI上下文:" prop="plCode">
              <el-input v-model="form.plCode"></el-input>
            </el-form-item>
            <el-form-item label="显示:" prop="plIsShow">
              <el-checkbox-group v-model="form.plIsShow">
                <el-checkbox label="导航区"></el-checkbox>
                <el-checkbox label="控制区"></el-checkbox>
                <el-checkbox label="操作区"></el-checkbox>
              </el-checkbox-group>
            </el-form-item>
            <el-form-item label="描述:" prop="plDesc">
              <el-input v-model="form.plDesc" :rows="5" type="textarea"></el-input>
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogClose">取 消</el-button>
            <el-button type="primary" @click="saveHandler">确 定</el-button>
          </span>
        </el-dialog>
        <!-- 克隆    -->
        <el-dialog
          key="cloneDialog"
          v-dialogDrag
          :visible.sync="cloneDialogVisible"
          append-to-body="true"
          class="avue-dialog"
          title="克隆"
          width="500px"
          @close="cloneDialogClose"
        >
          <avue-form ref="cloneForm" v-model="cloneForm" :option="cloneOption"></avue-form>
          <span slot="footer" class="dialog-footer">
            <el-button @click="cloneDialogClose">取 消</el-button>
            <el-button type="primary" @click="cloneSaveHandler">确 定</el-button>
          </span>
        </el-dialog>
        <!-- 导出    -->
        <el-dialog
          key="cloneDialog"
          v-dialogDrag
          :visible.sync="expDialogVisible"
          append-to-body="true"
          class="avue-dialog"
          title="导出"
          width="500px"
          @close="expDialogVisible=false"
        >
          <div style="height:  70%;min-height: 300px">
            <avue-tree ref="expTree" :data="expTreeData" :option="expOption"></avue-tree>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button @click="expDialogVisible=false">取 消</el-button>
            <el-button type="primary" @click="exportData">确 定</el-button>
          </span>
        </el-dialog>
      </basic-container>
      <!-- 导入 -->
      <upload-file ref="upload" :fileData="fileData" :fileType="upFileType" :fileUrl="fileUrl" :tipList="tipList"
                   title="导入"
                   @updata="getTableList" @upfaildata="upFail"></upload-file>
      <!--页签窗口-->
      <el-dialog v-dialogDrag
                 :append-to-body="true"
                 :close-on-click-modal="false"
                 :destroy-on-close="true"
                 :fullscreen="true"
                 :title="dialog.title"
                 :visible.sync="dialog.showDialog"
                 class="avue-dialog"
                 @close="dialog.showDialog=false">
        <pl-show :uiDefineData="dialog.uiDefineData"></pl-show>
      </el-dialog>
      <!--ui授权-->
      <ui-author ref="uiAuthor"></ui-author>
    </el-main>
 
  </el-container>
</template>
 
<script>
import {
  getBizTree,
  gridUIContextData,
  saveUIContextData,
  updateUIContextData,
  delUIContextData,
  cloneUIContextData,
  getExpContextTree,
  expUIContextData
} from "@/api/UI/uiDefine";
import basicOption from "@/util/basic-option";
import func from "@/util/func";
import plShow from "@/views/modelingMenu/ui/uiDefine/rightRegion/plShow";
import uiAuthor from "@/views/authority/ui/uiAuthorization/UIDialog"
import {mapGetters} from "vuex";
 
export default {
  name: "index",
  components: {plShow, uiAuthor},
  data() {
    return {
      loading: false,
      dialog: {
        showDialog: false,
        title: "上下文详情",
        loading: false,
        uiDefineData: null
      },
      tipList: [],
      upFileType: ['xls'],
      fileUrl: 'api/uiManagerController/impUIContextData',
      fileData: {},
      lastIndex: null,
      treeOption: {
        height: 'auto',
        defaultExpandAll: true,
        menu: false,
        addBtn: false,
        props: {
          label: 'text',
          value: 'oid',
          children: 'children'
        }
      },
      nodeRow: {},
      treeData: [],
      searchParams: {
        'conditionMap[txtName]': '',
        'conditionMap[txtCode]': '',
      },
      tableLoading: false,
      page: {
        currentPage: 1,
        pageSize: 50,
        total: 0,
        pageSizes: [10, 30, 50, 100],
      },
      selectList: [],
      option: {
        ...basicOption,
        calcHeight: -50,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        searchMenuSpan: 6,
        align: 'left',
        column: [{
          label: '名称',
          prop: 'plName',
          search: true,
          overHidden:true
        }, {
          label: 'UI上下文',
          prop: 'plCode',
          search: true,
          sortable: true,
          overHidden:true
        }, {
          label: '导航区',
          prop: 'plIsShowNavigator',
          width: 130,
          align: 'center',
          formatter: function (row, value) {
            if (row.plIsShowNavigator == 0) {
              return '不显示'
            } else {
              return '显示'
            }
          }
        }, {
          label: '控制区',
          prop: 'plIsShowForm',
          width: 130,
          align: 'center',
          formatter: function (row, value) {
            if (row.plIsShowForm == 0) {
              return '不显示'
            } else {
              return '显示'
            }
          }
        }, {
          label: '操作区',
          prop: 'plIsShowTab',
          width: 130,
          align: 'center',
          formatter: function (row, value) {
            if (row.plIsShowTab == 0) {
              return '不显示'
            } else {
              return '显示'
            }
          }
        }]
      },
      data: [],
      dialogLoading: false,
      dialogVisible: false,
      dialogType: '',
      form: {
        plName: '',
        plCode: '',
        plIsShow: [],
      },
      rules: {
        plName: [{
          required: true,
          message: '请输入名称',
          trigger: 'blur'
        }],
        plCode: [{
          required: true,
          message: '请输入UI上下文',
          trigger: 'blur'
        }],
        plIsShow: [{
          required: true,
          message: '请选择显示区域',
          trigger: 'blur'
        }]
      },
      cloneDialogVisible: false,
      cloneOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [{
          label: '克隆目标',
          prop: 'cloneTargetName',
          span: 24,
          type: 'tree',
          clearable: true,
          dicData: [],
          defaultExpandAll: true,
          rules: [
            {
              required: true,
              message: '请选择克隆目标',
              trigger: 'blur'
            }
          ]
        }, {
          label: 'UI名称',
          prop: 'cloneName',
          span: 24,
          type: 'input',
          rules: [
            {
              required: true,
              message: '请输入UI名称',
              trigger: 'blur'
            }
          ]
        }, {
          label: 'UI上下文',
          prop: 'cloneContextCode',
          span: 24,
          type: 'input',
          rules: [
            {
              required: true,
              message: '请输入UI上下文',
              trigger: 'blur'
            }
          ]
        }]
      },
      cloneForm: {
        //克隆的源对象的信息
        sourcePLUILayout: null,
        cloneTargetName: 'n',
        cloneName: '',
        cloneContextCode: ''
      },
      expDialogVisible: false,
      expTreeData: [],
      expOption: {
        height: 'auto',
        filter: false,
        multiple: true,
        defaultExpandAll: true,
        menu: false,
        addBtn: false,
        props: {
          label: 'text',
          value: 'oid',
          children: 'children'
        }
      }
    }
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission[this.$route.query.id].ADD, false),
        delBtn: this.vaildData(this.permission[this.$route.query.id].DELETE, false),
        editBtn: this.vaildData(this.permission[this.$route.query.id].EDIT, false),
        exportBtn: this.vaildData(this.permission[this.$route.query.id].EXPORT, false),
        importBtn: this.vaildData(this.permission[this.$route.query.id].IMPORT, false),
        cloneBtn: this.vaildData(this.permission[this.$route.query.id].CLONE, false),
        RIGHTBtn: this.vaildData(this.permission[this.$route.query.id].RIGHT, false),
      };
    },
  },
  created() {
    this.getTreeList();
  },
  methods: {
    //树表查询
    getTreeList() {
      this.loading = true;
      getBizTree().then(res => {
        this.treeData = [res.data.obj];
        const dicData = res.data.obj.children.map(item => {
          item.label = item.attributes.name;
          item.value = item.attributes.name;
          return item;
        });
        this.cloneOption.column[0].dicData = [{
          label: '业务类型树',
          value: '业务类型树',
          disabled: true,
          children: dicData
        }];
        this.loading = false;
      }).catch(error => {
        this.loading = false;
      })
    },
    // 树点击
    nodeClick(row) {
      if (row.oid) {
        this.nodeRow = row;
        this.tableLoading = true;
        this.getTableList();
      }
    },
    getTableList() {
      const params = Object.assign(this.searchParams, {
        'conditionMap[btmName]': this.nodeRow.attributes.name,
      })
      gridUIContextData(this.page.currentPage, this.page.pageSize, params).then(res => {
        this.data = res.data.data;
        this.page.total = res.data.total;
        this.$refs.crud.clearSelection();
        this.tableLoading = false;
      })
    },
    linkClickHandler(row) {
      this.dialog.title = '【' + row.plName + ' - ' + row.plCode + '】详情'
      this.dialog.uiDefineData = row;
      this.dialog.showDialog = true;
      return false;
      this.$router.push({
        path: '/UIDefineShow/:' + row.plOId,
        name: row.plName + '详情'
      });
    },
    sizeChange(val) {
      this.page.pageSize = val;
    },
    // 页码
    currentChange(val) {
      this.page.currentPage = val;
    },
    // 多选
    selectChangeHandler(row) {
      this.selectList = row;
    },
    // 搜索
    handleSearch(params, done) {
      this.searchParams = {
        'conditionMap[txtName]': params.plName,
        'conditionMap[txtCode]': params.plCode,
      };
      this.getTableList()
      done();
    },
 
    // 重置搜索条件
    handleReset() {
      this.searchParams = {};
      this.getTableList();
    },
    // 行点击
    rowClickHandler(row) {
      func.rowClickHandler(
        row,
        this.$refs.crud,
        this.lastIndex,
        (newIndex) => {
          this.lastIndex = newIndex;
        },
        () => {
          this.selectList = [row];
        }
      );
    },
 
    //创建
    addHandler() {
      if (this.nodeRow && this.nodeRow.oid) {
        this.form.plIsShow = [];
        this.form.plRelatedType = this.nodeRow.attributes.name;
        this.dialogType = 'add';
        this.dialogVisible = true;
      } else {
        this.$message.error('请选择业务类型');
      }
 
    },
    editHandler() {
      if (this.selectList.length != 0) {
        this.rowEditBtnClick(this.selectList[0]);
      } else {
        this.$message.error('请选择一条数据进行编辑');
      }
    },
    delHandler() {
      if (this.selectList.length <= 0) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      const params = {
        oids: this.selectList.map(item => item.plOId).join(',')
      }
      this.$confirm('您确定要删除所选择的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delUIContextData(params).then(res => {
          if (res.data.code === 200) {
            this.$message.success('删除成功');
            this.getTableList();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
 
    // 关闭对话框
    dialogClose() {
      this.dialogVisible = false;
      this.$refs.form.clearValidate();
      this.form = {
        plName: '',
        plCode: '',
        plDesc: '',
        plIsShow: [],
      }
    },
    // 保存UI上下文
    saveHandler() {
      this.$refs.form.validate((valid, done) => {
        if (valid) {
          let params = {
            ...this.form
          }
          if (this.form.plIsShow.includes('导航区')) {
            params.plIsShowNavigator = 1
          } else {
            params.plIsShowNavigator = 0
          }
          if (this.form.plIsShow.includes('控制区')) {
            params.plIsShowForm = 1;
          } else {
            params.plIsShowForm = 0;
          }
          if (this.form.plIsShow.includes('操作区')) {
            params.plIsShowTab = 1;
          } else {
            params.plIsShowTab = 0;
          }
          delete params.plIsShow;
          if (this.dialogType === 'add') {
            saveUIContextData(params).then(res => {
              if (res.data.code === 200) {
                this.$message.success('添加成功');
                this.dialogClose();
                this.getTableList();
              }
            })
          } else if (this.dialogType === 'edit') {
            updateUIContextData(params).then(res => {
              if (res.data.code === 200) {
                this.$message.success('修改成功');
                this.dialogClose()
                this.getTableList();
              }
            })
          }
        } else {
          return false;
        }
      });
    },
    // 导出
    exportClickHandler() {
      if (this.selectList.length <= 0) {
        this.$message.error('请选择数据');
        return;
      }
      const params = {
        expDatas: this.selectList.map(item => item.plOId).join(',')
      }
      getExpContextTree(params).then(res => {
        this.expTreeData = [res.data.obj];
      })
      this.expDialogVisible = true;
    },
    exportData() {
      const params = {}
      const checkedDatas = this.$refs.expTree.getCheckedNodes();
      if (checkedDatas.length <= 0) {
        this.$message.error('请选择数据');
        return;
      }
      this.selectList.forEach(item => {
        params[item.plOId] = checkedDatas.filter(checkitem => checkitem.parentId == item.plOId).map(checkitem => checkitem.oid).join(',')
      })
      expUIContextData(params).then(res => {
        func.downloadFileByBlobHandler(res);
        this.$message.success('导出成功');
        this.expDialogVisible = false;
      });
    },
 
    // 导入
    upLoadClickHandler() {
      this.fileData = {
        isCovered: false,
        selectBtm: this.nodeRow.attributes.name
      }
      this.$refs.upload.visible = true;
    },
    //导入失败
    upFail(response) {
 
    },
    //ui授权
    uiAuthorHandler() {
      if (this.selectList.length != 1) {
        this.$message.error('请选择一条数据');
        return;
      }
      this.$refs.uiAuthor.openDialog(this.nodeRow.attributes.name, this.selectList[0].plCode);
    },
    // 编辑按钮
    rowEditBtnClick(row) {
      this.form = {
        ...row,
        plIsShow: [],
      };
      if (row.plIsShowNavigator) {
        this.form.plIsShow.push('导航区')
      }
      if (row.plIsShowForm) {
        this.form.plIsShow.push('控制区')
      }
      if (row.plIsShowTab) {
        this.form.plIsShow.push('操作区')
      }
      this.dialogType = 'edit';
      this.dialogVisible = true;
    },
    // 删除按钮
    rowDeleteHandler(row) {
      this.$confirm('您确定要删除所选择的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delUIContextData({oids: row.plOId}).then(res => {
          if (res.data.code === 200) {
            this.$message.success('删除成功');
            this.getTableList();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    //克隆
    rowCloneHandler(row) {
      this.cloneForm = {
        sourcePLUILayout: row,
        cloneTargetName: '',
        cloneName: row.plName + '_copy(0)',
        cloneContextCode: row.plCode + '_copy(0)',
      }
      this.cloneDialogVisible = true;
    },
    cloneSaveHandler() {
      this.$refs.cloneForm.validate((valid, done) => {
        if (valid) {
          cloneUIContextData(this.cloneForm).then(res => {
            if (res.data.code === 200) {
              this.$message.success('克隆成功');
              this.cloneDialogClose();
              this.getTableList();
            }
          })
        } else {
          return false;
        }
      });
    },
    cloneDialogClose() {
      this.cloneDialogVisible = false;
      this.cloneForm = {
        //克隆的源对象的信息
        sourcePLUILayout: null,
        cloneTargetName: '',
        cloneName: '',
        cloneContextCode: ''
      }
    }
  }
}
</script>
 
<style lang="scss" scoped>
::v-deep {
  .el-scrollbar__wrap {
    overflow: auto !important;
  }
}
</style>