guhongwei 2 年之前
父節點
當前提交
a5befc7aec

+ 20 - 0
src/router/module/system.js

@@ -4,6 +4,26 @@ export default [
     meta: { title: '角色管理' },
     component: () => import('@/views/system/role/index.vue')
   },
+  {
+    path: '/system/role/detail',
+    meta: { title: '信息管理' },
+    component: () => import('@/views/system/role/detail.vue')
+  },
+  {
+    path: '/system/module',
+    meta: { title: '平台项目管理' },
+    component: () => import('@/views/system/module/index.vue')
+  },
+  {
+    path: '/system/module/detail',
+    meta: { title: '信息管理' },
+    component: () => import('@/views/system/module/detail.vue')
+  },
+  {
+    path: '/system/module/menus',
+    meta: { title: '菜单管理' },
+    component: () => import('@/views/system/module/menus.vue')
+  },
   {
     path: '/system/dict',
     meta: { title: '字典表设置', is_filter: true },

+ 89 - 0
src/views/system/module/detail.vue

@@ -0,0 +1,89 @@
+<template>
+  <el-row>
+    <el-col :span="24" class="main animate__animated animate__backInRight">
+      <el-col :span="24" class="one">
+        <cSearch :is_back="true" @toBack="toBack"></cSearch>
+      </el-col>
+      <el-col :span="24" class="two">
+        <cForm :fields="fields" :rules="rules" :form="form" labelWidth="auto" @save="toSave">
+          <template #is_use>
+            <el-option v-for="i in is_useList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+          </template>
+        </cForm>
+      </el-col>
+    </el-col>
+  </el-row>
+</template>
+
+<script setup lang="ts">
+// 基础
+import type { Ref } from 'vue';
+import { onMounted, ref, reactive } from 'vue';
+import { useRoute } from 'vue-router';
+import type { FormRules } from 'element-plus';
+import { ElMessage } from 'element-plus';
+// 接口
+import { ModuleStore } from '@common/src/stores/system/module';
+import { DictDataStore } from '@common/src/stores/system/dictData';
+import type { IQueryResult } from '@/util/types.util';
+const moduleAxios = ModuleStore();
+const dictAxios = DictDataStore();
+
+// 路由
+let route = useRoute();
+// 表单
+const fields: Ref<any> = ref([
+  { label: '模块名称', model: 'name' },
+  { label: '模块地址', model: 'url' },
+  { label: '模块简介', model: 'brief' },
+  { label: '是否使用', model: 'is_use', type: 'select' }
+]);
+const form: Ref<any> = ref({});
+const rules = reactive<FormRules>({
+  name: [{ required: true, message: '模块名称', trigger: 'blur' }],
+  url: [{ required: true, message: '模块地址', trigger: 'blur' }],
+  brief: [{ required: true, message: '模块简介', trigger: 'blur' }]
+});
+// 字典表
+const is_useList: Ref<any> = ref([]);
+
+// 请求
+onMounted(async () => {
+  await searchOther();
+  await search();
+});
+const search = async () => {
+  let id = route.query.id;
+  let res: IQueryResult;
+  if (id) {
+    res = await moduleAxios.fetch(id);
+    if (res.errcode == '0') form.value = res.data;
+  }
+};
+// 提交保存
+const toSave = async (data) => {
+  let res: IQueryResult;
+  if (data._id) {
+    res = await moduleAxios.update(data);
+  } else res = await moduleAxios.create(data);
+  if (res.errcode == '0') {
+    ElMessage({ message: `信息维护成功`, type: 'success' });
+    toBack();
+  } else {
+    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;
+};
+
+// 返回上一页
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
+<style scoped lang="scss"></style>

+ 120 - 0
src/views/system/module/index.vue

@@ -0,0 +1,120 @@
+<template>
+  <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">
+          <template #is_use>
+            <el-option v-for="i in is_useList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+          </template>
+        </cSearch>
+      </el-col>
+      <el-col :span="24" class="two">
+        <cButton @toAdd="toAdd"></cButton>
+      </el-col>
+      <el-col :span="24" class="thr">
+        <cTable :fields="fields" :opera="opera" :list="list" :total="total" @query="search" @edit="toEdit" @del="toDel" @menu="toMenu"></cTable>
+      </el-col>
+    </el-col>
+  </el-row>
+</template>
+
+<script setup lang="ts">
+// 基础
+import type { Ref } from 'vue';
+import { onMounted, ref } from 'vue';
+import router from '@/router';
+
+import { ElMessage } from 'element-plus';
+// 接口
+import { ModuleStore } from '@common/src/stores/system/module';
+import { DictDataStore } from '@common/src/stores/system/dictData';
+import type { IQueryResult } from '@/util/types.util';
+const moduleAxios = ModuleStore();
+const dictAxios = DictDataStore();
+
+// 分页数据
+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: 'url' },
+  { label: '模块简介', model: 'brief' },
+  { label: '是否使用', model: 'is_use', format: (i) => getDict(i, 'is_use'), type: 'select', isSearch: true }
+]);
+const opera: Ref<any> = ref([
+  { label: '菜单管理', method: 'menu' },
+  { label: '修改', method: 'edit', type: 'warning' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger' }
+]);
+// 查询
+const searchInfo: Ref<any> = ref({});
+// 字典表
+const is_useList: 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, ...searchInfo.value };
+  const res: IQueryResult = await moduleAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+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.dict_value == e);
+    if (data) return data.dict_label;
+    else return '暂无';
+  }
+};
+
+// 添加
+const toAdd = () => {
+  router.push({ path: '/system/module/detail' });
+};
+
+// 修改
+const toEdit = (e) => {
+  router.push({ path: '/system/module/detail', query: { id: e._id } });
+};
+// 删除
+const toDel = async (e) => {
+  let res: IQueryResult;
+  res = await moduleAxios.del(e._id);
+  if (res.errcode == '0') {
+    ElMessage({ message: `删除信息成功`, type: 'success' });
+    search({ skip, limit });
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+};
+// 菜单管理
+const toMenu = (e) => {
+  router.push({ path: '/system/module/menus', query: { id: e._id } });
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 是否使用
+  res = await dictAxios.query({ type: 'common_use' });
+  if (res.errcode == '0') is_useList.value = res.data;
+};
+</script>
+<style scoped lang="scss">
+.main {
+  .two {
+    margin: 0 0 10px 0;
+  }
+}
+</style>

+ 135 - 0
src/views/system/module/menus.vue

@@ -0,0 +1,135 @@
+<template>
+  <div id="menus">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_back="true" @toBack="toBack"> </cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cButton @toAdd="toAdd"></cButton>
+        </el-col>
+        <el-col :span="24" class="thr"> 列表 </el-col>
+      </el-col>
+    </el-row>
+    <cDialog :dialog="dialog" @handleClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :fields="fields" :form="form" labelWidth="auto" @save="toSave" @dataChange="dataChange">
+            <template #type>
+              <el-option v-for="(i, index) in typeList" :key="`t${index}`" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <!--     <template #parent_id>
+              <el-option v-for="(i, index) in getOneDimensionList()" :key="`m${index}`" :label="i.name" :value="i._id"></el-option>
+            </template>
+            <template #icon>
+              <el-option v-for="i in iconList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value">
+                <span style="float: left" :class="['iconfont', i.dict_label]"></span>
+                <span style="float: right; color: #8492a6; font-size: 13px">{{ i.dict_label }}</span>
+              </el-option>
+            </template>
+            <template #status>
+              <el-radio-group v-model="form.status">
+                <el-radio label="0">使用</el-radio>
+                <el-radio label="1">禁用</el-radio>
+              </el-radio-group>
+            </template> -->
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
+  </div>
+</template>
+
+<script setup lang="ts">
+// 基础
+import type { Ref } from 'vue';
+import { onMounted, ref } from 'vue';
+import { useRoute } from 'vue-router';
+
+// 接口
+import { MenusStore } from '@common/src/stores/system/menus';
+import type { IQueryResult } from '@/util/types.util';
+const menusAxios = MenusStore();
+
+// 路由
+const route = useRoute();
+
+// 模块id
+const module_id: Ref<any> = ref(['']);
+// 菜单列表
+const list: Ref<any> = ref([]);
+
+// 弹框
+const dialog: Ref<any> = ref({ title: '菜单管理', show: false, type: '1' });
+const form: Ref<any> = ref({});
+const fields: Ref<any> = ref([
+  { label: '菜单名称', model: 'name' },
+  { label: '菜单类型', model: 'type', type: 'select' },
+  { label: '父级菜单', model: 'parent_id', type: 'select' },
+  { label: '顺序', model: 'order_num', type: 'number' },
+  { label: '图标', model: 'icon', type: 'select' },
+  { label: '状态', model: 'status', custom: true },
+  { label: '备注', model: 'remark', type: 'textarea' }
+]);
+
+// 字典
+const typeList: Ref<any> = ref([
+  { label: '目录', value: '0' },
+  { label: '菜单', value: '1' },
+  { label: '子页面', value: '2' }
+]);
+// 请求
+onMounted(async () => {
+  let id = route.query.id;
+  if (id) module_id.value = id;
+  await search();
+});
+const search = async () => {
+  if (module_id.value) {
+    let res: IQueryResult;
+    res = await menusAxios.query({ module_id: module_id.value });
+    if (res.errcode == '0') {
+      list.value = res.data;
+    }
+  }
+};
+
+// 添加
+const toAdd = () => {
+  form.value = { module_id: module_id.value };
+  dialog.value = { title: '菜单管理', show: true, type: '1' };
+};
+// 选择
+const dataChange = ({ model, value }) => {
+  if (model == 'type') {
+    if (value == '0') {
+      fields.value = fields.value.filter((i) => i.model != 'path' && i.model != 'component');
+    } else {
+      let data = fields.value.find((i) => i.model == 'path');
+      if (!data) {
+        fields.value.splice(3, 0, { label: '路由地址', model: 'path' }, { label: '组件地址', model: 'component' });
+      }
+    }
+  }
+};
+// 提交保存
+const toSave = async (e) => {
+  console.log(e);
+};
+// 关闭弹框
+const toClose = () => {
+  dialog.value = { title: '菜单管理', show: false, type: '1' };
+  search();
+};
+// 返回上一页
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
+<style scoped lang="scss">
+.main {
+  .two {
+    margin: 0 0 10px 0;
+  }
+}
+</style>

+ 112 - 0
src/views/system/role/detail.vue

@@ -0,0 +1,112 @@
+<template>
+  <el-row>
+    <el-col :span="24" class="main animate__animated animate__backInRight">
+      <el-col :span="24" class="one">
+        <cSearch :is_back="true" @toBack="toBack"></cSearch>
+      </el-col>
+      <el-col :span="24" class="two">
+        <cForm :fields="fields" :rules="rules" :form="form" labelWidth="auto" @save="toSave">
+          <template #menu>
+            <el-cascader
+              v-model="form.menu"
+              :options="menuList"
+              :props="{ multiple: true, value: '_id', label: 'name', children: 'children' }"
+              clearable
+              collapse-tags
+              style="width: 100%"
+            ></el-cascader>
+          </template>
+          <template #account_type>
+            <el-option v-for="i in typeList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
+          </template>
+          <template #is_use>
+            <el-option v-for="i in is_useList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
+          </template>
+        </cForm>
+      </el-col>
+    </el-col>
+  </el-row>
+</template>
+
+<script setup lang="ts">
+// 基础
+import type { Ref } from 'vue';
+import { onMounted, ref, reactive } from 'vue';
+import { useRoute } from 'vue-router';
+import type { FormRules } from 'element-plus';
+import { ElMessage } from 'element-plus';
+// 接口
+import { RoleStore } from '@common/src/stores/system/role';
+import type { IQueryResult } from '@/util/types.util';
+const roleAxios = RoleStore();
+
+// 路由
+let route = useRoute();
+// 表单
+const fields: Ref<any> = ref([
+  { label: '角色名称', model: 'name' },
+  { label: '角色编码', model: 'code' },
+  { label: '简介', model: 'brief' },
+  { label: '菜单', model: 'menu', custom: true },
+  { label: '账号类型', model: 'account_type', type: 'select' },
+  { label: '是否使用', model: 'is_use', type: 'select' }
+]);
+const form: Ref<any> = ref({});
+const rules = reactive<FormRules>({
+  name: [{ required: true, message: '角色名称', trigger: 'blur' }],
+  code: [{ required: true, message: '角色编码', trigger: 'blur' }],
+  is_use: [{ required: true, message: '是否使用', trigger: 'change' }],
+  account_type: [{ required: true, message: '账号类型', trigger: 'change' }]
+});
+// 字典表
+const is_useList: Ref<any> = ref([]);
+const menuList: Ref<any> = ref([]);
+const typeList: Ref<any> = ref([]);
+
+// 请求
+onMounted(async () => {
+  await searchOther();
+  await search();
+});
+const search = async () => {
+  let id = route.query.id;
+  let res: IQueryResult;
+  if (id) {
+    res = await roleAxios.fetch(id);
+    if (res.errcode == '0') form.value = res.data;
+  }
+};
+// 提交保存
+const toSave = async (data) => {
+  let res: IQueryResult;
+  if (data._id) {
+    res = await roleAxios.update(data);
+  } else res = await roleAxios.create(data);
+  if (res.errcode == '0') {
+    ElMessage({ message: `信息维护成功`, type: 'success' });
+    toBack();
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  console.log(res + '查询字典表');
+  // 是否使用
+  // res = await dictAxios.query({ dict_type: 'common_use' });
+  // if (res.errcode == '0') is_useList.value = res.data;
+  // // 类型
+  // res = await dictAxios.query({ dict_type: 'role_type' });
+  // if (res.errcode == '0') typeList.value = res.data;
+  // // 菜单
+  // res = await roleAxios.am();
+  // if (res.errcode == '0') menuList.value = res.data;
+};
+
+// 返回上一页
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
+<style scoped lang="scss"></style>

+ 5 - 15
src/views/system/role/index.vue

@@ -32,12 +32,9 @@ 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' }
+  { label: '角色名称', model: 'name', isSearch: true },
+  { label: '角色编码', model: 'code' },
+  { label: '简介', model: 'brief' }
 ]);
 const opera: Ref<any> = ref([
   { label: '修改', method: 'edit', type: 'warning' },
@@ -48,16 +45,14 @@ 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, ...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;
+    list.value = res.data;
+    total.value = res.total;
   }
 };
 const toSearch = (e) => {
@@ -83,11 +78,6 @@ const toDel = async (e) => {
     ElMessage({ message: `${res.errmsg}`, type: 'error' });
   }
 };
-// 查询其他信息
-const searchOther = async () => {
-  let res: IQueryResult;
-  console.log(res);
-};
 </script>
 <style scoped lang="scss">
 .main {