Selaa lähdekoodia

Merge branch 'master' of http://git.cc-lotus.info/zkzx/zkzx_admin

YY 2 vuotta sitten
vanhempi
commit
156685e14f
4 muutettua tiedostoa jossa 98 lisäystä ja 34 poistoa
  1. 11 11
      src/components/index.ts
  2. 79 14
      src/views/system/role/index.vue
  3. 0 1
      tsconfig.json
  4. 8 8
      vite.config.ts

+ 11 - 11
src/components/index.ts

@@ -1,14 +1,14 @@
-import type { Component } from 'vue'
-import cButton from '@common/src/components/frame/c-button.vue'
-import cDialog from '@common/src/components/frame/c-dialog.vue'
-import cSearch from '@common/src/components/frame/c-search.vue'
-import cForm from '@common/src/components/frame/c-form.vue'
-import cTable from '@common/src/components/frame/c-table.vue'
-import cUpload from '@common/src/components/frame/c-upload.vue'
-import cEditor from '@common/src/components/frame/wang-editor.vue'
+import type { Component } from 'vue';
+import cButton from '@common/src/components/frame/c-button.vue';
+import cDialog from '@common/src/components/frame/c-dialog.vue';
+import cSearch from '@common/src/components/frame/c-search.vue';
+import cForm from '@common/src/components/frame/c-form.vue';
+import cTable from '@common/src/components/frame/c-table.vue';
+import cUpload from '@common/src/components/frame/c-upload.vue';
+import cEditor from '@common/src/components/frame/wang-editor.vue';
 
 const components: {
-  [propName: string]: Component
-} = { cButton, cDialog, cSearch, cForm, cTable, cUpload, cEditor }
+  [propName: string]: Component;
+} = { cButton, cDialog, cSearch, cForm, cTable, cUpload, cEditor };
 
-export default components
+export default components;

+ 79 - 14
src/views/system/role/index.vue

@@ -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>

+ 0 - 1
tsconfig.json

@@ -23,7 +23,6 @@
       "@common/*": ["../common/*"]
     },
     "isolatedModules": false,
-    "suppressImplicitAnyIndexErrors": true,
     "sourceMap": true,
     "resolveJsonModule": true,
     "esModuleInterop": true,

+ 8 - 8
vite.config.ts

@@ -1,10 +1,10 @@
-import { fileURLToPath, URL } from 'node:url'
-import { defineConfig, loadEnv } from 'vite'
-import vue from '@vitejs/plugin-vue'
-const path = require('path')
-const common = path.resolve(__dirname, '../common')
+import { fileURLToPath, URL } from 'node:url';
+import { defineConfig, loadEnv } from 'vite';
+import vue from '@vitejs/plugin-vue';
+const path = require('path');
+const common = path.resolve(__dirname, '../common');
 export default defineConfig(({ mode }) => {
-  const env = loadEnv(mode, __dirname)
+  const env = loadEnv(mode, __dirname);
   return {
     // 静态路径
     base: env.VITE_BASE_URL,
@@ -33,5 +33,5 @@ export default defineConfig(({ mode }) => {
         '@common': common
       }
     }
-  }
-})
+  };
+});