|
@@ -8,7 +8,7 @@
|
|
|
<cButton @toAdd="toAdd"></cButton>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="thr">
|
|
|
- <cTable :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @del="toDel"></cTable>
|
|
|
+ <cTable :fields="fields" :opera="opera" :list="list" :total="total" @query="search" @edit="toEdit" @del="toDel"></cTable>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -16,15 +16,17 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
// 基础
|
|
|
+import _ from 'lodash';
|
|
|
import type { Ref } from 'vue';
|
|
|
import { onMounted, ref } from 'vue';
|
|
|
-import router from '@/router';
|
|
|
-
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
+import router from '@/router';
|
|
|
// 接口
|
|
|
import { RoleStore } from '@common/src/stores/system/role';
|
|
|
+import { DictDataStore } from '@common/src/stores/system/dictData';
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
const roleAxios = RoleStore();
|
|
|
+const dictAxios = DictDataStore();
|
|
|
|
|
|
// 分页数据
|
|
|
const list: Ref<any> = ref([]);
|
|
@@ -34,7 +36,10 @@ const limit = 10;
|
|
|
const fields: Ref<any> = ref([
|
|
|
{ label: '角色名称', model: 'name', isSearch: true },
|
|
|
{ label: '角色编码', model: 'code' },
|
|
|
- { label: '简介', model: 'brief' }
|
|
|
+ { label: '简介', model: 'brief' },
|
|
|
+ { label: '账号类型', model: 'account_type', format: (i) => getDict(i, 'account_type') },
|
|
|
+ { label: '项目名称', model: 'menu', format: (i) => getDict(i, 'menu') },
|
|
|
+ { label: '是否启用', model: 'is_use', format: (i) => getDict(i, 'is_use') }
|
|
|
]);
|
|
|
const opera: Ref<any> = ref([
|
|
|
{ label: '修改', method: 'edit', type: 'warning' },
|
|
@@ -42,9 +47,14 @@ const opera: Ref<any> = ref([
|
|
|
]);
|
|
|
// 查询
|
|
|
const searchInfo: Ref<any> = ref({});
|
|
|
+// 字典表
|
|
|
+const is_useList: Ref<any> = ref([]);
|
|
|
+const typeList: Ref<any> = ref([]);
|
|
|
+const menuList: Ref<any> = ref([]);
|
|
|
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
+ await searchOther();
|
|
|
await search({ skip, limit });
|
|
|
});
|
|
|
const search = async (e: { skip: number; limit: number }) => {
|
|
@@ -59,6 +69,29 @@ const toSearch = (e) => {
|
|
|
searchInfo.value = e;
|
|
|
search({ skip, limit });
|
|
|
};
|
|
|
+const getDict = (e, model) => {
|
|
|
+ if (model == 'is_use') {
|
|
|
+ let data = is_useList.value.find((i) => i.value == e);
|
|
|
+ if (data) return data.label;
|
|
|
+ else return '暂无';
|
|
|
+ } else if (model == 'account_type') {
|
|
|
+ let data = typeList.value.find((i) => i.value == e);
|
|
|
+ if (data) return data.label;
|
|
|
+ else return '暂无';
|
|
|
+ } else if (model == 'menu') {
|
|
|
+ const array = [];
|
|
|
+ for (const p1 of e) {
|
|
|
+ array.push({ id: p1[0] });
|
|
|
+ }
|
|
|
+ let list = _.uniqBy(array, 'id');
|
|
|
+ let arr = [];
|
|
|
+ for (const val of list) {
|
|
|
+ const r = menuList.value.find((f) => f._id == val.id);
|
|
|
+ if (r) arr.push(r.name);
|
|
|
+ }
|
|
|
+ return arr.join(';');
|
|
|
+ }
|
|
|
+};
|
|
|
// 添加
|
|
|
const toAdd = () => {
|
|
|
router.push({ path: '/system/role/detail' });
|
|
@@ -78,6 +111,20 @@ const toDel = async (e) => {
|
|
|
ElMessage({ message: `${res.errmsg}`, type: 'error' });
|
|
|
}
|
|
|
};
|
|
|
+// 查询其他信息
|
|
|
+const searchOther = async () => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ // 是否使用
|
|
|
+ res = await dictAxios.query({ type: 'common_use' });
|
|
|
+ if (res.errcode == '0') is_useList.value = res.data;
|
|
|
+ // 账号类型
|
|
|
+ res = await dictAxios.query({ type: 'account_type' });
|
|
|
+ if (res.errcode == '0') typeList.value = res.data;
|
|
|
+ // 菜单
|
|
|
+ res = await roleAxios.am();
|
|
|
+ console.log(res.data);
|
|
|
+ if (res.errcode == '0') menuList.value = res.data;
|
|
|
+};
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|
|
|
.main {
|