qq_41295110
2026-01-13 4e5527d8bf8d89b7b8a3ca2a00ba95e9ca37b5aa
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
<template>
  <div style="padding: 10px;">
    <el-row>
      <el-button type="primary" @click="handleSaver">保存</el-button>
      <el-button type="primary" @click="close">退出</el-button>
    </el-row>
    <el-row>
      <el-col :span="8" style="padding-right:10px ;">
        <el-tree :data="treeOptions" :props="defaultProps" :expand-on-click-node="false"
          :default-checked-keys="['权限管理-用户']" :filter-node-method="filterNode" ref="tree" node-key="id"
          :default-expand-all="false" highlight-current @node-click="handleNodeClick" />
      </el-col>
      <el-col :span="16">
        <el-table :data="queryData" ref="queryMultipleTable" max-height="800" @selection-change="handleQueryChange"
          border v-if="tableQueryShow">
          <el-table-column type="selection" width="55" prop="AuthorityID" align="center" />
          <el-table-column align="center" prop="AuthorityID" label="是否权限" show-overflow-tooltip>
            <template slot-scope="scope">
              <span style="color: green;" v-if="scope.row.AuthorityID == 1">是</span>
              <span v-else-if="scope.row.AuthorityID == 0">否</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="gnms" label="功能说明" show-overflow-tooltip />
        </el-table>
      </el-col>
    </el-row>
  </div>
</template>
 
<script>
import axios from 'axios'
export default {
  name: 'PowerInformation',
  components: {},
  props: {
    HSouceBillType: { type: String, },
    linterid: {},
  },
  data() {
    return {
      powerShow: false,
      HModName: 'Xt_UserRightQuery',
      selQueryRows: [],
      nodeData: {},
      queryData: [],
      tableQueryShow: false,
      //树结构
      treeOptions: [],
      defaultProps: {
        children: "children",
        label: "title"
      },
      tableShow: true,
      sGnbm: '',
      organizationList: JSON.parse(sessionStorage.getItem('organizationList')),//组织列表
      baseURL: process.env.VUE_APP_BASE_API,
      rowForm: {},
      // 弹出层标题
      title: "",
      // 选中数组
      ids: [],
      // 遮罩层
      loading: true,
      tyResList: [],//列表(接口数据)
      btList: [],//表头列表显示
      btResList: [],
      tableData: [],//列表(分页显示)
      allTableData: [],
      pageSizes: [50, 100, 500, 5000, 50000],
      page: 1,
      pageSize: 0,
      total: 0,
    };
  },
  created() {
    this.getTreeselect()
  },
  methods: {
    getTreeselect() {
      console.log(1)
      axios.get(this.baseURL + 'Gy_MaintenanceMode/PowerLoadTree').then(response => {
        let data1 = response.data
        if (data1.count == 1) {
          let map = {};
          let treeData = [];
          data1.data.forEach(it => {
            map[it.id.toUpperCase()] = it;    //ID为每个节点的id
          })
          //生成结果集
          data1.data.forEach(it => {
            const parent = map[it.ParentID.toUpperCase()];   //ParentID为父节点的id
            if (parent) {
              if (!Array.isArray(parent.children)) parent.children = [];
              parent.children.push(it);
            } else {
              treeData.push(it)
            }
          })
          this.treeOptions = treeData
          this.powerShow = true
          this.handleNodeClick()
        }
      }).catch(error => {
        console.log(error)
        this.$modal.msgError("接口请求失败!");
      });
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.nodeData = data
      if (!data) {
        this.sGnbm = '权限管理-用户'
      } else {
        this.sGnbm = data.id
      }
      this.queryData = []
      let text = ''
      axios.get(this.baseURL + '/PublicPageMethod/PowerList', {
        params: {
          czybm: this.linterid,
          sGnbm: this.sGnbm,
          HSouceBillType: this.HSouceBillType,
        },
      }).then(response => {
        this.queryData = response.data.data
        this.tableQueryShow = true
        this.$nextTick(() => {
          if (this.queryData.length > 0) {
            this.queryData.forEach(row => {
              if (row.AuthorityID) {
                this.$refs.queryMultipleTable.toggleRowSelection(row);
              }
            });
          } else {
            this.$refs.queryMultipleTable.clearSelection();
          }
 
        })
      }).catch(error => {
        console.log(error)
        this.$modal.msgError("接口请求失败!");
      });
    },
    handleQueryChange(selection) {
      this.selQueryRows = selection
      this.queryData.forEach(row => {
        row.AuthorityHID = this.selQueryRows.some(selectedRow => selectedRow.hgnbm === row.hgnbm) ? 1 : 0;
      });
    },
    //退出
    close() {
      // const obj = { fullPath: this.$route.path, path: this.$route.path, name: this.$route.name, };
      // this.$tab.closePage(obj).then(res => {
      //   const latestView = res.visitedViews.slice(-1)[0]
      //   if (latestView) {
      //     this.$router.push(latestView.fullPath)
      //   } else {
      //     if (obj.name === 'Dashboard') {
      //       this.$router.replace({ path: '/redirect' + obj.fullPath })
      //     } else {
      //       this.$router.push('/')
      //     }
      //   }
      // });
      this.powerShow = false
      this.$emit('editQueryClose', false)
    },
    handleSaver() {
      var sSubStr = JSON.stringify(this.queryData);
      var sMainSub = this.sGnbm + ';' + sSubStr + ';' + this.linterid + ";" + this.HSouceBillType;
      axios({
        method: 'post',
        url: this.baseURL + "/Gy_MaintenanceMode/SaverPower",
        data: {
          'msg': sMainSub
        },
      }).then(response => {
        if (response.data.count == 1) {
          this.subDisabled = true//设置保存按钮不可用
          this.$modal.msgSuccess(response.data.Message);
          this.handleNodeClick(this.nodeData)
        }
      }).catch(error => {
        this.$modal.msgError("接口请求失败!");
      });
    },
    //导出
    handleExport() {
      const ws = this.$XLSX.utils.json_to_sheet(this.tyResList); // 将数据转换为工作表
      const wb = this.$XLSX.utils.book_new(); // 创建一个新的工作簿
      this.$XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); // 将工作表添加到工作簿中,并命名为"Sheet1"
      this.$XLSX.writeFile(wb, this.HSouceBillType + `_${new Date().getTime()}.xlsx`); // 导出文件      
    },
  }
};
</script>
<style>
.xsckdBox .el-date-editor.el-input {
  width: 100%;
}
 
.btnQueryBox {
  margin-top: 10px;
  padding: 5px;
  border-top: 1px solid #ebebeb;
  display: flex;
  justify-content: right;
}
</style>