Ver código fonte

更新 添加角色更新基础权限

wzh 3 anos atrás
pai
commit
61ef463ca6

+ 26 - 17
src/views/accountManage/subAccountList.vue

@@ -55,7 +55,7 @@
                 />
               </el-select>
             </el-form-item>
-            <el-form-item v-if="ruleForm.deptId" prop="roleId" label="部门">
+            <el-form-item v-if="ruleForm.deptId" prop="roleId" label="职位">
               <el-select
                 style="width: 280px"
                 v-model="ruleForm.roleId"
@@ -150,7 +150,7 @@
                 删除
               </div> -->
               <el-button
-                @click="showUpdateModal(scope.row)"
+                @click="showUpdateModal(scope.row, 1)"
                 size="small"
                 type="primary"
                 >修改员工权限</el-button
@@ -207,7 +207,7 @@ const rules = reactive({
   roleId: [
     {
       required: true,
-      message: "请选择员工",
+      message: "请选择职位",
       trigger: "blur",
     },
   ],
@@ -268,17 +268,25 @@ async function addSubAccount() {
   let res = await api[accountId.value ? "updateSubAccount" : "addSubAccount"](
     postData
   );
-  let status = res.data.status == 0;
-  ElNotification({
-    title: status ? "成功" : "失败",
-    duration: 1500,
-    message: res.data.msg,
-    type: status ? "success" : "error",
-  });
-  store.dispatch("GetBasePermissionData", localStorage.loginAccountId);
-  store.dispatch("GetUserPermission", localStorage.loginAccountId);
-  resetForm();
-  getSubAccountList();
+  if (res.data.status == 0) {
+    ElNotification({
+      title: "成功",
+      duration: 1500,
+      message: res.data.msg,
+      type: "success",
+    });
+    store.dispatch("GetBasePermissionData", localStorage.loginAccountId);
+    store.dispatch("GetUserPermission", localStorage.loginAccountId);
+    resetForm();
+    getSubAccountList();
+  } else {
+    ElNotification({
+      title: "失败",
+      duration: 1500,
+      message: res.data.msg,
+      type: "error",
+    });
+  }
 }
 function resetForm() {
   visable.value = false;
@@ -286,7 +294,7 @@ function resetForm() {
   form.value.resetFields();
 }
 
-function showUpdateModal(item) {
+function showUpdateModal(item, type) {
   visable.value = true;
   accountId.value = item.id;
   ruleForm.value = {
@@ -295,14 +303,15 @@ function showUpdateModal(item) {
     deptId: item.deptId,
     roleId: item.roleId,
   };
-  getRoleSelect();
+  getRoleSelect(type);
 }
 
 let roleSelect = ref([]);
 
-async function getRoleSelect() {
+async function getRoleSelect(type) {
   roleSelect.value = [];
   if (!ruleForm.value.deptId) return;
+  if (type != 1) ruleForm.value.roleId = "";
   let res = await api.getRoleSelect({
     loginAccountId: loginAccountId.value,
     deptId: ruleForm.value.deptId,

+ 2 - 0
src/views/authManage/addRole.vue

@@ -178,6 +178,8 @@ async function getDepartmentSelect() {
 onMounted(() => {
   loginAccountId.value = localStorage.loginAccountId;
   getDepartmentSelect();
+  store.dispatch("GetBasePermissionData", localStorage.loginAccountId);
+
   let id = route.query.roleId;
   if (id) {
     getRoleDetail(id);