瀏覽代碼

Merge branch 'master' of http://git.ius.plus/denny.zhao/VinnoManagementSystem

denny 2 年之前
父節點
當前提交
5b9334877f

+ 81 - 1
VinnoManagementSystem/src/api/wing/adminManage.js

@@ -84,5 +84,85 @@ export default {
                 "params": [data]
             });
         }
-    }
+    },
+    adminRoleList: {
+        method: 'GetAdminRolePagesAsync',
+        name: "查询管理员角色列表",
+        post: async function (params) {
+
+            var data = {
+                'PageIndex': params.page,
+                'PageSize': params.pageSize,
+                'RoleName': params.keyword
+            }
+            return await http.post({
+                "jsonrpc": "2.0",
+                "id": common.guid(),
+                "method": this.method,
+                "params": [data]
+            });
+        }
+    },
+    adminFeatureList: {
+        method: 'GetAdminFeatureList',
+        name: "权限列表",
+        post: async function (data = {}) {
+            return await http.post({
+                "jsonrpc": "2.0",
+                "id": common.guid(),
+                "method": this.method,
+                "params": [data]
+            });
+        }
+    },
+    createAdminRole: {
+        method: 'CreateAdminRole',
+        name: "创建管理员角色",
+        post: async function (req) {
+            var data = {
+                'RoleName': req.RoleName,
+                'Description': req.Description,
+                'FeaturesCodeList': req.featuresCodeList
+            }
+            return await http.post({
+                "jsonrpc": "2.0",
+                "id": common.guid(),
+                "method": this.method,
+                "params": [data]
+            });
+        }
+    },
+    modifyAdminRole: {
+        method: 'ModifyAdminRole',
+        name: "修改管理员角色",
+        post: async function (req) {
+            var data = {
+                'RoleCode': req.AdminRoleCode,
+                'RoleName': req.RoleName,
+                'Description': req.Description,
+                'FeaturesCodeList': req.featuresCodeList
+            }
+            return await http.post({
+                "jsonrpc": "2.0",
+                "id": common.guid(),
+                "method": this.method,
+                "params": [data]
+            });
+        }
+    },
+    adminRoleDetail: {
+		method: 'AdminRoleDetail',
+		name: "角色详情",
+		post: async function (roleCode) {
+            var data = {
+                'AdminRoleCode':roleCode
+            }
+            return await http.post({
+                "jsonrpc": "2.0",
+                "id": common.guid(),
+                "method": this.method,
+                "params": [data]
+            });
+        }
+	},
 }

+ 7 - 1
VinnoManagementSystem/src/locales/lang/en.js

@@ -153,7 +153,13 @@ export default {
 		password2:"confirm Password",
 		passwordVaild:"Passwords does not match",
 		adminConfirmDelete: "Are you sure to delete this admin",
-		assignRole: "assign Role"
+		assignRole: "assign Role",
+		roleUserNum: "admin Num",
+		authoritys: "authoritys",
+		checkAll: "checkAll",
+		adminRoleConfirmDelete: "Are you sure to delete this role",
+		adminRoleDel1:"The role is already associated",
+		adminRoleDel2: " administrators, please remove administrators before deleting roles"
 	},
 	organization: {
 		organizationName: "Organization Name",

+ 11 - 4
VinnoManagementSystem/src/locales/lang/zh-cn.js

@@ -149,11 +149,18 @@ export default {
 		adminQueryTypeOption1: "姓名",
 		adminRoleQuery: "管理员角色",
 		adminRoleName: "管理员角色名称",
-		password1:"密码",
-		password2:"确认密码",
-		passwordVaild:"密码不一致",
+		password1: "密码",
+		password2: "确认密码",
+		passwordVaild: "密码不一致",
 		adminConfirmDelete: "确定删除该管理员吗?",
-		assignRole: "分配角色"
+		assignRole: "分配角色",
+		roleUserNum: "角色人数",
+		authoritys: "权限",
+		checkAll: "全选",
+		adminRoleConfirmDelete: "确定删除该管理员角色吗?",
+		adminRoleDel1:"该角色已关联",
+		adminRoleDel2: " 个用户,请先移除用户再删除角色"
+
 	},
 	organization: {
 		organizationName: "机构名称",

+ 1 - 1
VinnoManagementSystem/src/views/adminManage/adminList.vue

@@ -61,7 +61,7 @@
         ref="table"
         :apiObj="apiObj"
         :pageSize="10"
-        row-key="UserCode"
+        row-key="AdminCode"
         @selection-change="selectionChange"
         stripe
       >

+ 171 - 0
VinnoManagementSystem/src/views/adminManage/adminRole.vue

@@ -0,0 +1,171 @@
+<template>
+  <el-container>
+    <el-header>
+      <div class="left-panel">
+        <el-button type="primary" icon="el-icon-plus" @click="add"
+          >{{ $t("create") }}
+        </el-button>
+      </div>
+      <el-form ref="form" class="right-panel">
+        <div class="right-panel-search">
+           <el-input
+            v-model="search.keyword"
+            clearable
+            style="width: 320px"
+            :placeholder="$t('pleaseInput')"
+          >
+            <template #prepend>
+              {{$t('admin.adminRoleName')}}
+            </template>
+          </el-input>
+          <el-button type="primary" icon="el-icon-search" @click="upsearch">{{
+            $t("query")
+          }}</el-button>
+        </div>
+      </el-form>
+    </el-header>
+    <el-main class="nopadding">
+      <scTable
+        ref="table"
+        :apiObj="apiObj"
+        :pageSize="10"
+        row-key="RoleCode"
+        stripe
+      >
+         <el-table-column
+          :label="$t('admin.adminRoleName')"
+          prop="RoleName"
+        ></el-table-column>
+        <el-table-column
+          :label="$t('response.description')"
+          prop="Description"
+        ></el-table-column>
+        <el-table-column
+          :label="$t('admin.roleUserNum')"
+          prop="AdminNum"
+        ></el-table-column>
+        <el-table-column
+          :label="$t('operate')"
+          fixed="right"
+          align="center"
+          width="120"
+        >
+          <template #default="scope">
+            <!-- 编辑 -->
+            <el-button
+              type="text"
+              size="small"
+              @click="table_edit(scope.row, scope.$index)"
+              >{{ $t("edit") }}</el-button
+            >
+            <!-- 删除 -->
+            <el-popconfirm
+              :title="confirmDel"
+              @confirm="table_del(scope.row, scope.$index)"
+            >
+              <template #reference>
+                <el-button
+                  type="text"
+                  size="small"
+                  @click="delValid(scope.row)"
+                  >{{ $t("delete") }}</el-button
+                >
+              </template>
+            </el-popconfirm>
+          </template>
+        </el-table-column>
+      </scTable>
+    </el-main>
+  </el-container>
+
+  <save-dialog
+    v-if="dialog.show"
+    ref="saveDialog"
+    @success="refresh"
+    @closed="dialog.show = false"
+  ></save-dialog>
+</template>
+
+<script>
+import saveDialog from "./saveAdminRole";
+
+
+export default {
+  components: {
+    saveDialog,
+  },
+  data() {
+    return {
+      dialog: {
+        show: false,
+      },
+      apiObj: this.query,
+      search: {
+        keyword: null
+      },
+      confirmDel: "",
+    };
+  },
+  methods: {
+    async query(params) {
+      return await this.$API.adminManage.adminRoleList.post(params);
+    },
+    //搜索
+    upsearch() {
+      this.$refs.table.upData(this.search);
+    },
+    //刷新当前页
+    refresh() {
+      this.$refs.table.refresh();
+    },
+    //增加
+    add() {
+      this.dialog.show = true;
+      this.$nextTick(() => {
+        this.$refs.saveDialog.open();
+      });
+    },
+    //编辑
+    table_edit(row) {
+      this.dialog.show = true;
+      this.$nextTick(() => {
+        this.$refs.saveDialog.open("edit").setData(row);
+      });
+    },
+    //删除
+    async table_del(row) {
+        var res = await this.$API.wing.post("QueryRoleAdminNum", {
+        AdminRoleCode: row.RoleCode,
+      });
+      if(res >0 )
+      {
+          return false;
+      }
+      await this.$API.wing.post(
+        "DeleteAdminRole",
+        {
+          AdminRoleCode: row.RoleCode,
+        },
+        this.refresh
+     );
+    },
+    //删除前验证
+    async delValid(row) {
+      this.confirmDel ="";
+      var res = await this.$API.wing.post("QueryRoleAdminNum", {
+        AdminRoleCode: row.RoleCode,
+      });
+     
+      if (res > 0) {
+        this.confirmDel = this.$t("admin.adminRoleDel1")+res+this.$t("admin.adminRoleDel2");
+        return false;
+      }
+      else
+      {
+        this.confirmDel = this.$t("admin.adminRoleConfirmDelete");
+      }
+    }
+  },
+};
+</script>
+

+ 180 - 0
VinnoManagementSystem/src/views/adminManage/saveAdminRole.vue

@@ -0,0 +1,180 @@
+<template>
+  <el-dialog
+    :title="titleMap[mode]"
+    v-model="visible"
+    :width="700"
+    destroy-on-close
+    @closed="$emit('closed')"
+  >
+    <el-form
+      :model="form"
+      :rules="rules"
+      ref="dialogForm"
+      label-width="150px"
+      label-position="left"
+    >
+      <el-form-item :label="$t('admin.adminRoleName')" prop="RoleName">
+        <el-input
+          v-model="form.RoleName"
+          clearable
+          :placeholder="$t('admin.adminRoleName')"
+          style="width: 60%"
+        ></el-input>
+      </el-form-item>
+      
+      <el-form-item :label="$t('response.description')">
+        <el-input
+          v-model="form.Description"
+          clearable
+          :placeholder="$t('response.description')"
+          style="width: 60%"
+          :autosize="{ minRows: 5}"
+          type="textarea"
+        ></el-input>
+      </el-form-item>
+        <el-form-item :label="$t('admin.authoritys')" style="max-width: 300px">
+          <div>
+            <el-checkbox
+              v-model="checkAll"
+              @change="handleCheckAllChange"
+            >{{ $t('admin.checkAll') }}</el-checkbox>
+          </div>
+          <div style="float:right">
+          <el-tree
+            ref="tree"
+            :data="data"
+            show-checkbox
+            default-expand-all
+            node-key="Id"
+            :props="defaultProps"
+          />
+          </div>
+        </el-form-item>
+    </el-form>
+    <template #footer>
+      <el-button @click="visible = false">{{
+        $t("dialogBox.cancelButtonText")
+      }}</el-button>
+      <el-button
+        v-if="mode != 'show'"
+        type="primary"
+        :loading="isSaveing"
+        @click="submit()"
+        >{{ this.$t("dialogBox.saveButtonText") }}</el-button
+      >
+    </template>
+  </el-dialog>
+</template>
+
+<script>
+export default {
+  emits: ["success", "closed"],
+  data() {
+    return {
+      mode: "add",
+      titleMap: {
+        add: this.$t("dialogBox.addTitle"),
+        edit: this.$t("dialogBox.modifyTitle"),
+      },
+      visible: false,
+      isSaveing: false,
+      data: [],
+      authorityList: [],
+      checkAll: false,
+      defaultProps: {
+        children: 'Children',
+        label: 'Label'
+      },
+      //表单数据
+      form: {
+        RoleName: "",
+        Description: "",
+        featuresCodeList: "",
+        AdminRoleCode: ""
+      },
+      //验证规则
+      rules: {
+        RoleName: [
+          {
+            required: true,
+            message: this.$t("admin.adminRoleName"),
+            trigger: "blur",
+          },
+        ],
+      },
+    };
+  },
+  methods: {
+    //显示
+    open(mode = "add") {
+      this.mode = mode;
+      this.visible = true;
+      this.initFeatures();
+      return this;
+    },
+    // 全选
+    handleCheckAllChange() {
+      if (this.checkAll === true) {
+        // debugger
+        this.$refs.tree.setCheckedKeys(this.authorityList)
+        this.checkedList = this.$refs.tree.getCheckedNodes()
+      } else {
+        this.$refs.tree.setCheckedKeys([])
+      }
+    },
+    //表单提交方法
+    submit() {
+      this.$refs.dialogForm.validate(async (valid) => {
+        if (valid) {
+          this.isSaveing = true;
+          var res = false;
+          //新增或者修改
+          this.form.featuresCodeList = this.$refs.tree.getCheckedKeys()
+          if (this.mode === "add") {
+            res = await this.$API.adminManage.createAdminRole.post(this.form);
+          } else {
+            res = await this.$API.adminManage.modifyAdminRole.post(this.form);
+          }
+          this.isSaveing = false;
+          if (res == true) {
+            this.$emit("success");
+            this.visible = false;
+            this.$message.success(this.$t("response.operateSuccess"));
+          } else {
+            this.$alert(res.message, this.$t("dialogBox.confirmWarningTitle"), {
+              type: "error",
+            });
+          }
+        }
+      });
+    },
+    //表单注入数据
+    async setData(data) {
+      var res = await this.$API.wing.post("AdminRoleDetail", {
+        AdminRoleCode: data.RoleCode
+      });
+      this.form.AdminRoleCode = data.RoleCode;
+      this.form.Description = data.Description;
+      this.form.RoleName = res.RoleName;  
+      if (this.authorityList.length ===res.FeatureList.length) {
+            this.checkAll = true
+          } else {
+            this.checkAll = false
+          }
+          this.$nextTick(() => {
+            this.$refs.tree.setCheckedNodes(res.FeatureList)
+          })
+    },
+    async initFeatures() {
+      this.data = await this.$API.adminManage.adminFeatureList.post();
+      var featureList = await this.$API.wing.post("GetAdminFeatureSelectList");
+      featureList.forEach(element => {
+        this.authorityList.push(element.Key)
+      });
+    },
+  },
+};
+</script>
+
+<style>
+</style>

+ 41 - 13
VinnoManagementSystem/src/views/organizationManage/organizationList.vue

@@ -53,7 +53,11 @@
             <el-option
               v-for="item in stateTypes"
               :key="item"
-              :label="$t('organization.' + item.replace(/^\S/, s => s.toLowerCase()))"
+              :label="
+                $t(
+                  'organization.' + item.replace(/^\S/, (s) => s.toLowerCase())
+                )
+              "
               :value="item"
             />
           </el-select>
@@ -173,22 +177,29 @@
             >
             <!-- 更多 -->
             <el-divider direction="vertical"></el-divider>
-            <el-dropdown>
+            <el-dropdown @command="handleCommand">
               <el-button type="text" size="small"
-                >{{$t('more')}}<el-icon class="el-icon--right"
+                >{{ $t("more")
+                }}<el-icon class="el-icon--right"
                   ><el-icon-arrow-down /></el-icon
               ></el-button>
               <template #dropdown>
                 <el-dropdown-menu>
-                  <el-dropdown-item @click="table_saveUser(scope.row)">{{
-                    $t("organization.setDirector")
-                  }}</el-dropdown-item>
-                  <el-dropdown-item @click="table_Setting(scope.row, 0)">{{
-                    $t("organization.setting0")
-                  }}</el-dropdown-item>
-                  <el-dropdown-item @click="table_Setting(scope.row, 1)">{{
-                    $t("organization.setting1")
-                  }}</el-dropdown-item>
+                  <el-dropdown-item
+                    command="table_saveUser"
+                    @click="table_saveUser(scope.row)"
+                    >{{ $t("organization.setDirector") }}</el-dropdown-item
+                  >
+                  <el-dropdown-item
+                    command="table_Setting0"
+                    @click="table_Setting(scope.row, 0)"
+                    >{{ $t("organization.setting0") }}</el-dropdown-item
+                  >
+                  <el-dropdown-item
+                    command="table_Setting1"
+                    @click="table_Setting(scope.row, 1)"
+                    >{{ $t("organization.setting1") }}</el-dropdown-item
+                  >
                 </el-dropdown-menu>
               </template>
             </el-dropdown>
@@ -254,6 +265,7 @@ export default {
       selection: [],
       confirmDel: this.$t("organization.confirmDelete"),
       organizationCode: "",
+      command: true,
     };
   },
   methods: {
@@ -275,6 +287,9 @@ export default {
         this.$refs.saveDialog.open();
       });
     },
+    handleCommand() {
+      this.command = true;
+    },
     //编辑
     table_edit(row) {
       this.dialog.show = true;
@@ -282,8 +297,18 @@ export default {
         this.$refs.saveDialog.open(true).setData(row);
       });
     },
+    canCommand() {
+      if (!this.command) {
+        return false;
+      }
+      this.command = false;
+      return true;
+    },
     //配置
     table_Setting(row, type) {
+      if (!this.canCommand()) {
+        return;
+      }
       this.dialog.showSetting = true;
       this.$nextTick(() => {
         this.$refs.saveSetting.open(type).setData(row);
@@ -319,9 +344,12 @@ export default {
     },
     //分配责任人
     table_saveUser(row) {
+      if (!this.canCommand()) {
+        return;
+      }
       this.dialog.showUser = true;
       this.organizationCode = row.OrganizationCode;
-        console.log(row)
+      this.command = false;
       this.$nextTick(() => {
         var director = "";
         if (row.Directors.length == 1) {