Browse Source

添加用户机构

asd123a20 3 years ago
parent
commit
18c7be9a88

+ 6 - 0
admin-frame/lib/apps.js

@@ -104,5 +104,11 @@ export default [
     entry: config.dev ? '//localhost:3016/admin-client-user/' : 'admin-client-user',
     container: config.tabs ? '#clientUser' : '#content',
     activeRule: '/admin/clientUser'
+  },
+  {
+    name: 'admin-org',
+    entry: config.dev ? '//localhost:3017/admin-org/' : 'admin-org',
+    container: config.tabs ? '#org' : '#content',
+    activeRule: '/admin/org'
   }
 ];

+ 0 - 1
admin-frame/src/components/transfer.vue

@@ -24,7 +24,6 @@ export default {
   },
   data() {
     return {
-
       value: []
     };
   },

+ 3 - 0
admin-org/.browserslistrc

@@ -0,0 +1,3 @@
+> 1%
+last 2 versions
+not dead

+ 5 - 0
admin-org/.editorconfig

@@ -0,0 +1,5 @@
+[*.{js,jsx,ts,tsx,vue}]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true

+ 2 - 0
admin-org/.env

@@ -0,0 +1,2 @@
+# 窗口使用弹出还是抽屉 (dialog And drawer)
+VUE_APP_WINDOW=dialog

+ 1 - 0
admin-org/.eslintignore

@@ -0,0 +1 @@
+public-path.js

+ 23 - 0
admin-org/.eslintrc.js

@@ -0,0 +1,23 @@
+module.exports = {
+  root: true,
+  env: {
+    node: true
+  },
+  extends: [
+    'plugin:vue/essential',
+    '@vue/standard'
+  ],
+  parserOptions: {
+    parser: 'babel-eslint'
+  },
+  rules: {
+    'no-console': 0,
+    'no-debugger': 0,
+    'comma-dangle': [2, 'never'],
+    'no-extra-parens': 2,
+    'no-extra-semi': 2,
+    semi: [2, 'always'],
+    'space-before-function-paren': [0, 'always'],
+    eqeqeq: 0
+  }
+};

+ 23 - 0
admin-org/.gitignore

@@ -0,0 +1,23 @@
+.DS_Store
+node_modules
+/dist
+
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 24 - 0
admin-org/README.md

@@ -0,0 +1,24 @@
+# admin-role
+
+## Project setup
+```
+npm install
+```
+
+### Compiles and hot-reloads for development
+```
+npm run serve
+```
+
+### Compiles and minifies for production
+```
+npm run build
+```
+
+### Lints and fixes files
+```
+npm run lint
+```
+
+### Customize configuration
+See [Configuration Reference](https://cli.vuejs.org/config/).

+ 5 - 0
admin-org/babel.config.js

@@ -0,0 +1,5 @@
+module.exports = {
+  presets: [
+    '@vue/cli-plugin-babel/preset'
+  ]
+};

File diff suppressed because it is too large
+ 12565 - 0
admin-org/package-lock.json


+ 35 - 0
admin-org/package.json

@@ -0,0 +1,35 @@
+{
+  "name": "admin-org",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "core-js": "^3.6.5",
+    "element-ui": "^2.15.6",
+    "sass": "^1.48.0",
+    "sass-loader": "^10.0.0",
+    "vue": "^2.6.11",
+    "vue-router": "^3.2.0",
+    "vuex": "^3.4.0"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "~4.5.0",
+    "@vue/cli-plugin-eslint": "~4.5.0",
+    "@vue/cli-plugin-router": "~4.5.0",
+    "@vue/cli-plugin-vuex": "~4.5.0",
+    "@vue/cli-service": "~4.5.0",
+    "@vue/eslint-config-standard": "^5.1.2",
+    "babel-eslint": "^10.1.0",
+    "eslint": "^6.7.2",
+    "eslint-plugin-import": "^2.20.2",
+    "eslint-plugin-node": "^11.1.0",
+    "eslint-plugin-promise": "^4.2.1",
+    "eslint-plugin-standard": "^4.0.0",
+    "eslint-plugin-vue": "^6.2.2",
+    "vue-template-compiler": "^2.6.11"
+  }
+}

BIN
admin-org/public/favicon.ico


+ 17 - 0
admin-org/public/index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title><%= htmlWebpackPlugin.options.title %></title>
+  </head>
+  <body>
+    <noscript>
+      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+  </body>
+</html>

+ 24 - 0
admin-org/src/App.vue

@@ -0,0 +1,24 @@
+<template>
+  <div id="app">
+    <router-view></router-view>
+  </div>
+</template>
+
+<script>
+export default {
+  components: {},
+  computed: {},
+  data() {
+    return {};
+  },
+  mounted() {},
+  methods: {}
+};
+</script>
+
+<style lang="scss" scoped>
+#app {
+  width: 100%;
+  height: 100%;
+}
+</style>

BIN
admin-org/src/assets/logo.png


+ 48 - 0
admin-org/src/main.js

@@ -0,0 +1,48 @@
+import Vue from 'vue';
+import App from './App.vue';
+import VueRouter from 'vue-router';
+import routes from './router';
+import store from './store';
+import ElementUI from 'element-ui';
+import 'element-ui/lib/theme-chalk/index.css';
+import './public-path.js';
+import dict from '@lib/dict.js';
+import tree from '@lib/tree.js';
+import resChange from '@lib/resChange.js';
+Vue.config.productionTip = false;
+Vue.use(VueRouter);
+Vue.use(ElementUI);
+Vue.use(dict);
+Vue.use(tree);
+Vue.use(resChange);
+let router = null;
+let instance = null;
+function render (props = {}) {
+  const { container } = props;
+  router = new VueRouter({
+    base: window.__POWERED_BY_QIANKUN__ ? '/admin/org/' : '/',
+    mode: 'history',
+    routes
+  });
+  instance = new Vue({
+    router,
+    store,
+    render: (h) => h(App)
+  }).$mount(container ? container.querySelector('#app') : '#app');
+}
+
+// 独立运行时
+if (!window.__POWERED_BY_QIANKUN__) {
+  render();
+}
+
+export async function bootstrap () {}
+export async function mount (props) {
+  render(props);
+}
+export async function unmount () {
+  instance.$destroy();
+  instance.$el.innerHTML = '';
+  instance = null;
+  router = null;
+}

+ 3 - 0
admin-org/src/public-path.js

@@ -0,0 +1,3 @@
+if (window.__POWERED_BY_QIANKUN__) {
+  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
+}

+ 11 - 0
admin-org/src/router/index.js

@@ -0,0 +1,11 @@
+import home from '../views/home.vue';
+
+const routes = [
+  {
+    path: '/home',
+    name: 'home',
+    component: home
+  }
+];
+
+export default routes;

+ 79 - 0
admin-org/src/store/index.js

@@ -0,0 +1,79 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import $axios from '@lib/axios.js';
+const api = {
+  orgCreate: '/api/org/org/create',
+  orgUpdate: '/api/org/org/update',
+  orgDelete: '/api/org/org/delete',
+  orgQuery: '/api/org/org/query',
+  userQuery: '/api/clientUser/user/query',
+  queryBind: '/api/org/orgbind/query',
+  batchBind: '/api/org/orgbind/create',
+  batchUnBind: '/api/org/orgbind/delete'
+};
+Vue.use(Vuex);
+const state = () => ({
+  Total: 0,
+  orgList: [],
+  userList: [],
+  bindList: []
+});
+
+const actions = {
+  async batchUnBind ({ commit }, payload) {
+    const res = await $axios.post(api.batchUnBind, payload);
+    return res;
+  },
+  async batchBind ({ commit }, payload) {
+    const res = await $axios.post(api.batchBind, payload);
+    return res;
+  },
+  async orgCreate ({ commit }, payload) {
+    const res = await $axios.post(api.orgCreate, payload);
+    return res;
+  },
+  async orgUpdate ({ commit }, payload) {
+    const res = await $axios.post(api.orgUpdate, { ...payload, id: payload._id });
+    return res;
+  },
+  async orgDelete ({ commit }, { id }) {
+    const res = await $axios.post(`${api.orgDelete}/${id}`);
+    return res;
+  },
+  async orgQuery ({ commit }, { filter, paging } = {}) {
+    const res = await $axios.get(api.orgQuery, { ...filter, skip: paging.page, limit: paging.size });
+    commit('orgQuery', res);
+    return res;
+  },
+  async userQuery ({ commit }) {
+    const res = await $axios.get(api.userQuery);
+    commit('userQuery', res.data);
+    return res;
+  },
+  async queryBind ({ commit }, payload) {
+    const res = await $axios.get(api.queryBind, payload);
+    commit('queryBind', res.data);
+    return res;
+  }
+};
+
+const mutations = {
+  orgQuery(state, payload) {
+    state.orgList = payload.data;
+    state.Total = payload.total;
+  },
+  userQuery(state, payload) {
+    state.userList = payload;
+  },
+  queryBind(state, payload) {
+    payload = payload.map(e => e.userList[0].openid);
+    state.bindList = payload;
+  }
+};
+
+export default new Vuex.Store({
+  state,
+  actions,
+  mutations,
+  modules: {}
+});

+ 159 - 0
admin-org/src/views/home.vue

@@ -0,0 +1,159 @@
+<template>
+  <div class="box">
+    <el-card class="box-card">
+      <div slot="header" class="clearfix">
+        <span>机构管理</span>
+        <el-button style="float: right; padding: 3px 0" type="text" @click="addorg">添加机构</el-button>
+      </div>
+      <div class="main">
+        <filterList ref="filterList" :operation="operation" :tableData="orgList" :filed="filed" @bind="userBind" @edit="filtereEdit" @delete="filterDelete" @query="filterQuery" :total="Total"></filterList>
+      </div>
+    </el-card>
+    <dialogAndDrawer :width="'35%'" :title="title" :visibleSync="visibleSync" v-if="visibleSync" @close="visibleSync = false">
+      <template v-slot:windowMain>
+        <formData v-if="!bind" :filed="formfiled" :data="formdata" :rules="formrules" @save="formSave"></formData>
+        <transfer v-else :prop="{key: 'openid',label: 'name'}" :data="userList" :values="values" @change="transferChage"></transfer>
+      </template>
+    </dialogAndDrawer>
+  </div>
+</template>
+<script>
+import filterList from '@components/filterList/index.vue';
+import dialogAndDrawer from '@components/dialogAndDrawer.vue';
+import formData from '@components/formData/index.vue';
+import transfer from '@components/transfer.vue';
+import { mapState, mapActions } from 'vuex';
+export default {
+  components: {
+    filterList,
+    dialogAndDrawer,
+    formData,
+    transfer
+  },
+  data() {
+    return {
+      values: [],
+      bind: false,
+      orgInfo: null,
+      title: '',
+      visibleSync: false,
+      operation: [
+        { name: 'bind', label: '绑定用户', icon: 'el-icon-user' },
+        { name: 'edit', label: '修改', icon: 'el-icon-edit' },
+        { name: 'delete', label: '删除', icon: 'el-icon-delete' }
+      ],
+      filed: [
+        { name: 'name', label: '名称', filter: true },
+        { name: 'code', label: '编码', filter: true }
+      ],
+      formdata: {},
+      formfiled: [
+        { name: 'name', label: '名称' },
+        { name: 'code', label: '编码' }
+      ],
+      formrules: {
+        name: [
+          { required: true, message: '请输入名称', trigger: 'blur' }
+        ],
+        code: [
+          { required: true, message: '请输入编码', trigger: 'blur' }
+        ]
+      }
+    };
+  },
+  computed: {
+    ...mapState(['orgList', 'Total', 'userList', 'bindList'])
+  },
+  async mounted() {
+    await this.filterQuery();
+  },
+  methods: {
+    ...mapActions(['orgQuery', 'orgCreate', 'orgUpdate', 'orgDelete', 'queryBind', 'batchUnBind', 'batchBind', 'userQuery']),
+    // 添加
+    addorg () {
+      this.formdata = {};
+      this.title = '添加机构';
+      this.visibleSync = true;
+    },
+    // 修改
+    filtereEdit (e) {
+      this.formdata = e;
+      this.title = '修改机构';
+      this.visibleSync = true;
+    },
+    // 删除
+    async filterDelete (e) {
+      const res = await this.orgDelete({ id: e?._id });
+      this.$resChange(res, '删除成功');
+      this.filterQuery();
+    },
+    // 查询
+    async filterQuery ({ filter = {}, paging = { page: 0, size: 10 } } = {}) {
+      await this.orgQuery({ filter, paging });
+    },
+    // 表单保存
+    async formSave (e) {
+      if (e.isRevise && e?.isRevise == false) {
+        this.$message.warning('未作修改');
+        return;
+      }
+      this.$delete(e, 'isRevise');
+      let res, msg;
+      // 修改
+      if (e._id) {
+        res = await this.orgUpdate(e);
+        msg = '机构修改成功';
+      } else {
+        res = await this.orgCreate(e);
+        msg = '机构添加成功';
+      }
+      this.$resChange(res, msg);
+      this.filterQuery();
+      this.visibleSync = false;
+    },
+    async userBind (e) {
+      this.orgInfo = e;
+      this.title = '绑定用户';
+      this.visibleSync = true;
+      this.bind = true;
+      await this.userQuery();
+      await this.queryBind({ source: this.orgInfo.code });
+      this.values = this.bindList;
+    },
+    // 穿梭框改变
+    async transferChage (e) {
+      const source = this.orgInfo.code;
+      // 解绑
+      e.filter(i => {
+        this.values = this.values.filter(k => k !== i);
+      });
+      if (this.values.length > 0) {
+        const unbind = await this.batchUnBind({ source, ids: this.values });
+        this.$resChange(unbind, '解绑成功');
+      }
+      // 绑定
+      this.values.filter(y => {
+        e = e.filter(z => z == y);
+      });
+      if (e.length > 0) {
+        const res = await this.batchBind({ source, ids: e });
+        this.$resChange(res, '绑定成功');
+      }
+      await this.queryBind({ source: this.orgInfo.code });
+      this.values = this.bindList;
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.box {
+  width: 100%;
+  height: 100%;
+  .box-card {
+    height: 100%;
+    .el-card__body {
+      height: 100%;
+    }
+  }
+}
+</style>

+ 33 - 0
admin-org/vue.config.js

@@ -0,0 +1,33 @@
+const path = require('path');
+const frameSrc = path.resolve(__dirname, '../admin-frame');
+const packageName = require('./package.json').name;
+module.exports = {
+  publicPath: `/${packageName}/`,
+  outputDir: path.join(frameSrc, `../../admin-web/${packageName}/`),
+  devServer: {
+    port: 3017,
+    headers: {
+      'Access-Control-Allow-Origin': '*'
+    },
+    proxy: {
+      '/api/': {
+        // target: 'http://192.168.0.45:18090'
+        target: 'http://192.168.3.45:18090'
+      }
+    }
+  },
+  configureWebpack: {
+    output: {
+      library: `${packageName}-[name]`,
+      libraryTarget: 'umd',
+      jsonpFunction: `webpackJsonp_${packageName}`
+    },
+    resolve: {
+      alias: {
+        '@components': path.join(frameSrc, '/src/components'),
+        '@style': path.join(frameSrc, '/style'),
+        '@lib': path.join(frameSrc, '/lib')
+      }
+    }
+  }
+};

+ 3 - 0
xms.code-workspace

@@ -48,6 +48,9 @@
 		{
 			"path": "admin-client-user"
 		},
+		{
+			"path": "admin-org"
+		},
 	],
 	"settings": {}
 }