wangting
2024-12-04 ed52d8cb0db78eb8bff70329ac01a38d50d7f672
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
<template>
  <el-container>
    <el-aside>
      <basic-container>
        <div ref="TreeBox" style="height: calc(100vh - 154px);!important;">
          <!-- 左侧树         -->
          <div style="height:  calc(100vh - 190px);">
            <avue-tree :data="treeData" :option="treeOption" @node-click="nodeClick">
              <span slot-scope="{ node, data }" class="el-tree-node__label">
               <span style="font-size: 15px">
                  <i class="el-icon-s-promotion"></i>
                    {{ (node || {}).label }}
                </span>
              </span>
            </avue-tree>
          </div>
        </div>
      </basic-container>
    </el-aside>
 
    <el-main>
      <basic-container cardBodyStyle="padding-bottom:0;">
        <avue-crud
          ref="crud"
          :data="data"
          :option="option"
          :table-loading="tableLoading"
          @refresh-change="handleRefresh"
          @current-row-change="rowClickHandler">
          <template slot="menuLeft">
            <el-button icon="el-icon-plus" size="small" type="primary" @click="addHandler">添加</el-button>
            <el-button icon="el-icon-plus" size="small" type="primary" @click="editHandler">修改</el-button>
            <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delHandler">删除</el-button>
            <el-button icon="el-icon-view" plain size="small" type="primary" @click="chekView">查看授权结果</el-button>
          </template>
        </avue-crud>
        <div style="margin-top: 15px;">
          <data-view key="dataView" :btmNode="nodeRow" :selectRow="selectRow" :actionMap="actionMap" :readOnly="true" :height="clientHeight-260-220"></data-view>
        </div>
        <!-- 新增 && 编辑 -->
        <el-dialog
          v-dialogDrag
          :title="title === 'add' ? '创建' : '修改'"
          :visible.sync="visible"
          append-to-body="true"
          class="avue-dialog"
          width="70%"
          @close="addDialogClose">
            <div>
              <data-view ref="editView" key="editView" :btmNode="nodeRow" :selectRow="title === 'add'?{}:selectRow" :actionMap="actionMap" :readOnly="false" :height="clientHeight-260"></data-view>
            </div>
            <span slot="footer" class="dialog-footer">
               <el-button size="small" type="primary" @click="addDialogSavaHandler">确 定</el-button>
               <el-button size="small" @click="addDialogClose">取 消</el-button>
            </span>
        </el-dialog>
        <!-- 查看授权结果    -->
        <el-dialog
          v-dialogDrag
          v-loading="checkViewLoading"
          :visible.sync="checkViewVisible"
          append-to-body="true"
          class="avue-dialog"
          title="查看使用范围"
          width="60%"
        >
          <avue-crud
            ref="checkViewCrud"
            :data="checkViewData"
            :option="checkViewOption"
            @search-change="checkHandleSearch"
            @search-reset="checkHandleReset"
          >
 
          </avue-crud>
        </el-dialog>
      </basic-container>
    </el-main>
 
  </el-container>
</template>
 
<script>
import {getBizTree} from "@/api/UI/uiDefine";
import basicOption from "@/util/basic-option";
import dataView from "./dataView";
import {getData,saveGrand,delGrand} from "@/api/authority/ui/dataAuthor";
import func from "@/util/func";
import {getUsedEnumList} from "@/api/modeling/enumType/api";
export default {
  name: "index",
  components:{dataView},
  data:function (){
    return{
      clientHeight:Math.max(document.body.clientHeight,700),
      treeOption: {
        height: 'auto',
        defaultExpandAll: true,
        menu: false,
        addBtn: false,
        props: {
          label: 'text',
          value: 'oid',
          children: 'children'
        }
      },
      nodeRow: {},
      treeData: [],
      tableLoading: false,
      selectRow: {},
      option: {
        ...basicOption,
        height:280,
        highlightCurrentRow:true,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        filterBtn:false,
        columnBtn:false,
        gridBtn:false,
        tip: false,
        index:false,
        selection:false,
        menu:false,
        align:'center',
        column: [{
          label: '规则名称',
          prop: 0,
          overHidden: true
        },{
          label: '规则类型',
          prop: 1,
          overHidden: true
        }]
      },
      data: [],
      title: '',
      visible: false,
      form:{},
      actionMap:{},
      switchDic:[{
        label:'',
        value:false
      },{
        label:'',
        value:true
      }]
    }
  },
  created() {
    this.getTreeList();
  },
  methods: {
    //树表查询
    getTreeList() {
      const loading = this.$loading({});
      getBizTree().then(res => {
        this.treeData = [res.data.obj];
        loading.close();
      }).catch(error => {
        loading.close();
      })
    },
    // 树点击
    nodeClick(row) {
      if (row.oid) {
        this.nodeRow = row;
        this.getTableList();
      }
    },
    getTableList() {
      getData(this.nodeRow.attributes.name).then(res => {
        if(typeof res.data == 'string'){
          res.data=eval('('+res.data +')')
        }
        if(res.data.obj.tableHeader){
          this.option.column=[ {
            label: '规则名称',
            prop: 0,
            overHidden: true
          },{
              label: '规则类型',
              prop: 1,
              overHidden: true
            }];
          res.data.obj.tableHeader.forEach((item,i)=>{
            if(i<=1) return;
            if(i=='rules') return;
            this.option.column.push({
              label: item,
              prop: i,
              overHidden: true,
              width:'auto',
              html:true,
              formatter:(val)=> {
                return '<label class="el-checkbox is-disabled ' + (val[i] == true ? 'is-checked' : '') + '"><span class="el-checkbox__input is-disabled ' + (val[i] == true ? 'is-checked' : '') + '"><span class="el-checkbox__inner"></span><input type="checkbox" aria-hidden="false" class="el-checkbox__original" value="' + val[i] + '"></span></label>'
              }
            })
          })
        }
        this.data = res.data.obj.rowList;
        this.$refs.crud.clearSelection();
        this.tableLoading = false;
        this.actionMap=res.data.obj.actionMap;
        this.selectRow={}
      })
    },
    handleRefresh() {
      this.getTableList();
    },
    // 行点击
    rowClickHandler(row) {
      this.selectRow=row
    },
    // 查看授权结果
    chekView() {
      if (this.selectRow=={}) {
        this.$message.warning('请选择一条数据');
        return;
      }
 
      getUsedEnumList({enumName: this.selectRow.id}).then(res => {
        if (res.data.code === 200) {
          this.checkViewVisible = true;
          this.checkViewData = res.data.data;
          this.checkViewDataSearch = res.data.data;
        }
      })
    },
 
    // 查看授权结果查询
    checkHandleSearch(params, done) {
      const {source} = params;
 
      if (!params.source) {
        this.checkViewData = this.checkViewDataSearch;
        return done();
      }
 
      this.checkViewData = this.checkViewData.filter(item => {
        return item.source && item.source.includes(source);
      });
 
      done();
 
    },
    //创建
    addHandler(){
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请选择要添加的节点');
        return;
      }
      this.title = 'add';
      this.visible = true;
    },
    //修改
    editHandler(){
      if (func.isEmptyObject(this.selectRow)) {
        this.$message.error('请选择一条数据');
        return;
      }
      this.title = 'edit';
      this.visible = true;
    },
    // 新增编辑保存
    addDialogSavaHandler() {
      saveGrand(this.viewData).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.obj);
          this.getTableList();
          this.addDialogClose();
        }
      })
    },
    // 新增编辑对话框取消
    addDialogClose() {
      this.visible = false;
    },
    //删除
    delHandler(){
      if (func.isEmptyObject(this.selectRow)) {
        this.$message.error('请选择数据');
        return;
      }
      this.$confirm('您确定要删除所选择的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delGrand({name:this.templateForm}).then(res => {
          if (res.data.code === 200) {
            this.$message.success(res.data.obj);
            this.getTableList();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 查看使用范围重置
    checkHandleReset() {
      this.checkViewData = this.checkViewDataSearch;
    },
  }
}
</script>
 
<style lang="scss" scoped>
::v-deep {
  .el-scrollbar__wrap {
    overflow: auto !important;
  }
}
 
</style>