闫增涛
4 天以前 6227519a1bd9007aedae11b77b0b3b1851837c38
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
<template>
  <div class="user-manage">
    <div>
      <ul class="flex tabs">
        <li
          v-for="item in tabList"
          :key="item.value"
          @click="handleClick(item)"
          :class="item.value == tabActive ? 'activeItem' : 'item'"
        >
          {{ item.lable }}
        </li>
      </ul>
    </div>
    <div class="content" v-if="tabActive == 'menu'">
      <div class="list">
        <div class="firstLvBox">
          <el-checkbox
            v-model="checkObject.modelManagement"
            label="模型管理"
            size="large"
          />
        </div>
        <div class="secondLvBox">
          <el-checkbox
            v-model="checkObject.newModelAdded"
            label="新增型号"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.editType"
            label="编辑型号"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.deleteType"
            label="删除型号"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.addNewModel"
            label="新增模型"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.editModel"
            label="编辑模型"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.deleteModel"
            label="删除模型"
            size="large"
          />
        </div>
        <div class="firstLvBox">
          <el-checkbox
            v-model="checkObject.visualSimulation"
            label="可视化仿真"
            size="large"
          />
        </div>
        <div class="secondLvBox">
          <el-checkbox
            v-model="checkObject.testSimulation"
            label="测试仿真"
            size="large"
          />
        </div>
        <div class="thirdlyLvBox">
          <el-checkbox
            v-model="checkObject.modelRetrieval"
            label="模型检索"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.modelPreview"
            label="模型预览"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.viewModelProperties"
            label="模型属性查看"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.modelSimulation"
            label="模型仿真"
            size="large"
          />
          <el-checkbox
            v-model="checkObject.testReport"
            label="测试报告"
            size="large"
          />
        </div>
      </div>
      <div>
        <el-button type="primary" @click="updateRightConfigFun">保存</el-button>
      </div>
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { ref, onMounted, watch, inject, reactive } from "vue";
const checked1 = ref(false);
const tabList = ref([
  {
    lable: "菜单/功能访问权限",
    value: "menu",
  },
  {
    lable: "模型访问权限",
    value: "model",
  },
]);
const tabActive = ref("menu");
const dataList = ref([]);
import { curStoreInfo } from "@/store/index";
const seleStore = curStoreInfo();
import { useUserStore } from "@/store/index";
import { ElMessage } from "element-plus";
 
const checkObject = reactive({
  newModelAdded: false,
  editType: false,
  deleteType: false,
  addNewModel: false,
  editModel: false,
  deleteModel: false,
  testSimulation: false,
  modelRetrieval: false,
  modelPreview: false,
  visualSimulation: false,
  viewModelProperties: false,
  modelSimulation: false,
  testReport: false,
  modelManagement: false,
});
 
const curRoleConfig = ref(null);
 
const userStore = useUserStore();
import emitter from "../eventBus.js";
onMounted(() => {
  getData();
});
const MG: any = inject("MG");
const config: any = inject("config");
 
watch(
  () => seleStore.curSelectRole,
  (newRoute) => {
    if (newRoute) {
      console.log(newRoute, "curSelectRole");
      getRoleRightList();
    }
  },
  { deep: true }
);
 
const saveConfig = async () => {
  const body = {
    appId: config.appId,
    name: seleStore.curSelectRole?.name,
    description: seleStore.curSelectRole?.description,
    icon: "",
    type: "Normal",
    state: "Normal",
    scope: config.appId + "",
    domain: "roleRights",
    control: true,
    edit: true,
    read: true,
    view: true,
    ban: true,
    beginDate: "2023-08-30T09:09:23.367Z",
    endDate: "2023-08-30T09:09:23.367Z",
    configDomain: "roleRights",
    configScope: config.appId + "",
    config: "[]",
    orgIds: [seleStore.OrgInfo.id],
    departmentIds: [],
    userIds: [userStore.userInfo?.id],
    roleIds: [seleStore.curSelectRole?.id],
  };
  const res = await MG.dps5.NewRightsConfig(body);
  console.log(res, "NewRightsConfig");
  return res;
};
 
const updateRightConfigFun = async () => {
  let configId = null;
  if (curRoleConfig) {
    configId = await saveConfig();
  }
  const body = {
    config: JSON.stringify(checkObject),
    configDomain: "roleRights",
    configId: configId ? configId : curRoleConfig.value.configId,
    configScope: config.appId + "",
  };
  const res = await MG.dps5.UpdateRightsConfig(body);
  emitter.emit("refreshTree");
  if (res) {
    ElMessage({
      message: "权限编辑成功",
      type: "success",
    });
  }
};
 
const getRoleRightList = async () => {
  const body = {
    appId: config.appId,
    roleId: seleStore.curSelectRole.id,
  };
  let res = await MG.dps5.GetRoleRightsConfigList(body);
  if (res && res.length > 0) {
    curRoleConfig.value = res[0];
    const config = JSON.parse(res[0].configDto.config);
    if (config instanceof Array) {
      for (let key in checkObject) {
        checkObject[key] = false;
      }
    } else {
      for (let key in config) {
        checkObject[key] = config[key];
      }
    }
  }
};
 
const defaultProps = {
  children: "children",
  label: "name",
};
 
const getData = () => {
  let list = [
    {
      name: "模型管理",
      sysType: "cmsFolder",
      productLinkPath: "111",
      children: [
        {
          name: "新增型号",
          sysType: "cmsItem",
          productLinkPath: "211",
        },
        {
          name: "编辑型号",
          sysType: "cmsItem",
          productLinkPath: "212",
        },
        {
          name: "删除型号",
          sysType: "cmsItem",
          productLinkPath: "213",
        },
        {
          name: "新增模型",
          sysType: "cmsItem",
          productLinkPath: "214",
        },
        {
          name: "删除模型",
          sysType: "cmsItem",
          productLinkPath: "215",
        },
        {
          name: "删除模型",
          sysType: "cmsItem",
          productLinkPath: "216",
        },
      ],
    },
    {
      name: "可视化仿真",
      sysType: "cmsFolder",
      productLinkPath: "112",
      children: [
        {
          name: "测试仿真",
          sysType: "cmsFolder",
          productLinkPath: "221",
          children: [
            {
              name: "检索模型",
              sysType: "cmsItem",
              productLinkPath: "231",
            },
            {
              name: "模型预览",
              sysType: "cmsItem",
              productLinkPath: "232",
            },
            {
              name: "模型属性查看",
              sysType: "cmsItem",
              productLinkPath: "233",
            },
            {
              name: "模型仿真",
              sysType: "cmsItem",
              productLinkPath: "234",
            },
            {
              name: "测试报告",
              sysType: "cmsItem",
              productLinkPath: "235",
            },
          ],
        },
        {
          name: "测试报告",
          sysType: "cmsFolder",
          productLinkPath: "221",
        },
      ],
    },
  ];
  dataList.value = list;
};
const handleClick = (item) => {
  tabActive.value = item.value;
};
</script>
 
<style lang="less" scoped>
.user-manage {
  padding: 20px;
}
.tabs {
  li {
    width: 140px;
    text-align: center;
    padding: 5px 0;
    margin: 0 15px;
    cursor: pointer;
  }
  .activeItem {
    border-bottom: 2px solid #1890ff;
  }
}
.list {
  margin-top: 20px;
}
.secondLvBox {
  margin-left: 20px;
}
.thirdlyLvBox {
  margin-left: 40px;
}
.content {
  display: flex;
  justify-content: space-between;
}
</style>