|
@@ -1,33 +1,98 @@
|
|
|
<template>
|
|
|
- <div id="index">
|
|
|
- <el-row>
|
|
|
- <el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
- <el-col :span="24" class="one">系统首页</el-col>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"></cSearch>
|
|
|
</el-col>
|
|
|
- </el-row>
|
|
|
- </div>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <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>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
// 基础
|
|
|
-// import type { Ref } from 'vue';
|
|
|
-// reactive, ref, onMounted
|
|
|
-import { onMounted } from 'vue';
|
|
|
+import type { Ref } from 'vue';
|
|
|
+import { onMounted, ref } from 'vue';
|
|
|
+import router from '@/router';
|
|
|
+
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
// 接口
|
|
|
-import { TestStore } from '@common/src/stores/test';
|
|
|
+import { RoleStore } from '@common/src/stores/system/role';
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
-const testAxios = TestStore();
|
|
|
+const roleAxios = RoleStore();
|
|
|
+
|
|
|
// 分页数据
|
|
|
+const list: Ref<any> = ref([]);
|
|
|
+const total: Ref<any> = ref(0);
|
|
|
const skip = 0;
|
|
|
const limit = 10;
|
|
|
+const fields: Ref<any> = ref([
|
|
|
+ { label: '角色名称', model: 'name', isSearch: true }
|
|
|
+ // { label: '角色编码', model: 'code' },
|
|
|
+ // { label: '简介', model: 'brief' },
|
|
|
+ // { label: '项目名称', model: 'menu', format: (i) => getMenuName(i), showTip: false },
|
|
|
+ // { label: '角色状态', model: 'status', format: (i) => getStatus(i) },
|
|
|
+ // { label: '账号类型', model: 'account_type', format: (i) => getType(i), isSearch: true, type: 'select' }
|
|
|
+]);
|
|
|
+const opera: Ref<any> = ref([
|
|
|
+ { label: '修改', method: 'edit', type: 'warning' },
|
|
|
+ { label: '删除', method: 'del', confirm: true, type: 'danger' }
|
|
|
+]);
|
|
|
+// 查询
|
|
|
+const searchInfo: Ref<any> = ref({});
|
|
|
+
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
+ await searchOther();
|
|
|
await search({ skip, limit });
|
|
|
});
|
|
|
const search = async (e: { skip: number; limit: number }) => {
|
|
|
- const info = { skip: e.skip, limit: e.limit };
|
|
|
- const res: IQueryResult = await testAxios.query(info);
|
|
|
+ const info = { skip: e.skip, limit: e.limit, ...searchInfo.value };
|
|
|
+ const res: IQueryResult = await roleAxios.query(info);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ console.log(res.data);
|
|
|
+ // list.value = res.data;
|
|
|
+ // total.value = res.total;
|
|
|
+ }
|
|
|
+};
|
|
|
+const toSearch = (e) => {
|
|
|
+ searchInfo.value = e;
|
|
|
+ search({ skip, limit });
|
|
|
+};
|
|
|
+// 添加
|
|
|
+const toAdd = () => {
|
|
|
+ router.push({ path: '/system/role/detail' });
|
|
|
+};
|
|
|
+// 修改
|
|
|
+const toEdit = (e) => {
|
|
|
+ router.push({ path: '/system/role/detail', query: { id: e._id } });
|
|
|
+};
|
|
|
+// 删除
|
|
|
+const toDel = async (e) => {
|
|
|
+ let res: IQueryResult;
|
|
|
+ res = await roleAxios.del(e._id);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ ElMessage({ message: `删除信息成功`, type: 'success' });
|
|
|
+ search({ skip, limit });
|
|
|
+ } else {
|
|
|
+ ElMessage({ message: `${res.errmsg}`, type: 'error' });
|
|
|
+ }
|
|
|
+};
|
|
|
+// 查询其他信息
|
|
|
+const searchOther = async () => {
|
|
|
+ let res: IQueryResult;
|
|
|
console.log(res);
|
|
|
};
|
|
|
</script>
|
|
|
-<style scoped lang="scss"></style>
|
|
|
+<style scoped lang="scss">
|
|
|
+.main {
|
|
|
+ .two {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|