Просмотр исходного кода

更新 子账户管理;角色管理

wzh 3 лет назад
Родитель
Сommit
1ed2f0290f

+ 15 - 0
src/apis/fetch.js

@@ -63,6 +63,11 @@ export default {
     return $http("/role/permission/list", data);
   },
 
+  // 获取角色下拉列表
+  getRoleSelect(data) {
+    return $http("/role/permission/getRoleSelect", data);
+  },
+
   // 修改角色信息
   updateRole(data) {
     return $http("/role/permission/updateRole", data);
@@ -97,4 +102,14 @@ export default {
   addSubAccount(data) {
     return $http("/user/cargo/add/loginAccount", data);
   },
+
+  // 修改货主子账户
+  updateSubAccount(data) {
+    return $http("/user/cargo/update/loginAccount", data);
+  },
+
+  // 获取角色详情
+  getRoleDetail(data) {
+    return $http("/role/permission/getRoleDetail", data);
+  },
 };

+ 0 - 17
src/store/index.js

@@ -11,7 +11,6 @@ const store = createStore({
     currentMenuItem: "/cargoOwnerManage/cargoOwnerList",
     baseurl,
     basePermissionData: [],
-    currentPermissionData: [],
   },
   mutations: {
     changefirstTitle(state, text) {
@@ -29,21 +28,6 @@ const store = createStore({
     setBasePermissionData(state, data) {
       state.basePermissionData = data;
     },
-    setCurrentPermissionData(state, data) {
-      state.currentPermissionData = data;
-    },
-    updateCurrentPermissionData(state, params) {
-      function update(data) {
-        for (let i of data) {
-          i.status = true;
-          if (i.children.length) {
-            update(i.children);
-          }
-        }
-      }
-      let { status, code } = params;
-      console.log(status);
-    },
   },
   actions: {
     GetBasePermissionData({ commit }, loginAccountId) {
@@ -60,7 +44,6 @@ const store = createStore({
           }
           let data = exchange(e.data.result);
           commit("setBasePermissionData", data);
-          commit("setCurrentPermissionData", data);
         });
       });
     },

+ 77 - 29
src/views/accountManage/subAccountList.vue

@@ -14,7 +14,12 @@
       <el-button type="primary" @click="visable = true">添加账号</el-button>
     </div>
 
-    <el-dialog v-model="visable" title="添加账号" width="550px">
+    <el-dialog
+      v-model="visable"
+      :title="accountId ? '修改角色' : '添加账号'"
+      width="550px"
+      @close="resetForm()"
+    >
       <template v-slot:default>
         <div class="df jcc">
           <el-form
@@ -33,6 +38,21 @@
                 v-model="ruleForm.phone"
               ></el-input>
             </el-form-item>
+
+            <el-form-item prop="roleId" label="角色">
+              <el-select
+                style="width: 280px"
+                v-model="ruleForm.roleId"
+                placeholder="请选择角色"
+              >
+                <el-option
+                  v-for="item in roleSelect"
+                  :key="item"
+                  :label="item.value"
+                  :value="item.key"
+                />
+              </el-select>
+            </el-form-item>
           </el-form>
         </div>
       </template>
@@ -51,37 +71,37 @@
         <el-table-column
           type="index"
           label="序号"
-          min-width="80"
+          min-width="40"
           align="center"
         ></el-table-column>
         <el-table-column
           prop="userName"
           label="姓名"
-          min-width="100"
+          min-width="80"
           align="center"
         ></el-table-column>
         <el-table-column
-          prop="contactName"
+          prop="phone"
           label="手机号"
           min-width="100"
           align="center"
         ></el-table-column>
         <el-table-column
-          prop="phone"
+          prop="password"
           label="密码"
           min-width="80"
           align="center"
         ></el-table-column>
         <el-table-column
-          prop="createTime"
+          prop="role_name"
           label="角色权限"
-          min-width="160"
+          min-width="80"
           align="center"
         ></el-table-column>
         <el-table-column label="操作" min-width="120" align="center">
           <template v-slot="scope">
-            <div class="df aic">
-              <el-switch
+            <div class="df aic jcsa">
+              <!-- <el-switch
                 v-model="scope.row.accountStatus"
                 active-color="#13ce66"
                 inactive-color="#ff4949"
@@ -101,18 +121,13 @@
                 "
               >
                 删除
-              </div>
-              <div
-                style="
-                  color: blue;
-                  margin-left: 10px;
-                  font-size: 14px;
-                  text-decoration: underline;
-                  cursor: pointer;
-                "
+              </div> -->
+              <el-button
+                @click="showUpdateModal(scope.row)"
+                size="small"
+                type="primary"
+                >修改角色权限</el-button
               >
-                修改角色权限
-              </div>
             </div>
           </template>
         </el-table-column>
@@ -139,9 +154,11 @@ let currentPage = ref(1);
 let total = ref(0);
 let term = ref("");
 let loginAccountId = ref(0);
+let accountId = ref("");
 let ruleForm = ref({
   name: "",
   phone: "",
+  roleId: "",
 });
 const rules = reactive({
   name: [
@@ -154,7 +171,14 @@ const rules = reactive({
   phone: [
     {
       required: true,
-      message: "请填联手机号",
+      message: "请填写手机号",
+      trigger: "blur",
+    },
+  ],
+  roleId: [
+    {
+      required: true,
+      message: "请选择角色",
       trigger: "blur",
     },
   ],
@@ -169,6 +193,11 @@ async function getSubAccountList() {
   });
   if (res.data.status == 0) {
     tableData.value = res.data.result;
+    for (let i of tableData.value) {
+      if (i.roleId == 0) {
+        i.roleId = "";
+      }
+    }
     total.value = res.data.total;
   } else {
     tableData.value = [];
@@ -183,12 +212,16 @@ function pageChange(e) {
 let visable = ref(false);
 let form = ref(null);
 async function addSubAccount() {
-  console.log(ruleForm.value);
-  let res = await api.addSubAccount({
+  let postData = {
     ...ruleForm.value,
     loginAccountId: loginAccountId.value,
-  });
-  console.log(res);
+  };
+  if (accountId.value) {
+    postData.accountId = accountId.value;
+  }
+  let res = await api[accountId.value ? "updateSubAccount" : "addSubAccount"](
+    postData
+  );
   let status = res.data.status == 0;
   ElNotification({
     title: status ? "成功" : "失败",
@@ -201,18 +234,33 @@ async function addSubAccount() {
 }
 function resetForm() {
   visable.value = false;
+  accountId.value = "";
   form.value.resetFields();
 }
 
-function closeModal() {
-  proxyName.value = "";
-  contactPhone.value = "";
-  contactName.value = "";
+function showUpdateModal(item) {
+  visable.value = true;
+  accountId.value = item.id;
+  ruleForm.value = {
+    name: item.userName,
+    phone: item.phone,
+    roleId: item.roleId,
+  };
+}
+
+let roleSelect = ref([]);
+
+async function getRoleSelect() {
+  let res = await api.getRoleSelect({
+    loginAccountId: loginAccountId.value,
+  });
+  roleSelect.value = res.data.result;
 }
 
 onMounted(() => {
   loginAccountId.value = localStorage.loginAccountId;
   getSubAccountList();
+  getRoleSelect();
 });
 </script>
 

+ 4 - 15
src/views/agencyManage/agencyCompanyList.vue

@@ -89,8 +89,8 @@
         ></el-table-column>
         <el-table-column label="操作" min-width="120" align="center">
           <template v-slot="scope">
-            <div class="df aic">
-              <el-switch
+            <div class="df aic jcsa">
+              <!-- <el-switch
                 v-model="scope.row.accountStatus"
                 active-color="#13ce66"
                 inactive-color="#ff4949"
@@ -98,19 +98,8 @@
                 inactive-text="禁用"
                 :active-value="1"
                 :inactive-value="0"
-              />
-
-              <div
-                style="
-                  color: red;
-                  margin-left: 10px;
-                  font-size: 14px;
-                  text-decoration: underline;
-                  cursor: pointer;
-                "
-              >
-                删除
-              </div>
+              /> -->
+              <el-button disabled size="small" type="danger">删除</el-button>
             </div>
           </template>
         </el-table-column>

+ 75 - 16
src/views/authManage/addRole.vue

@@ -19,23 +19,26 @@
     <h4 class="mb30">权限设置</h4>
     <el-tree
       ref="treeRef"
-      :data="currentPermissionData"
+      :data="basePermissionData"
       show-checkbox
       default-expand-all
       node-key="code"
       highlight-current
       :props="defaultProps"
+      :default-checked-keys="checkedNodes"
       style="display: flex; justify-content: space-between"
       @check="getTree"
-  /></el-card>
+    />
+    <div class="df aic jcfe mt50">
+      <el-button type="primary" @click="addRole">{{
+        roleId ? "修改角色" : "添加角色"
+      }}</el-button>
+    </div>
+  </el-card>
 
-  <el-card class="mt30" style="display: none">
+  <!-- <el-card class="mt30">
     <h4>权限设置</h4>
-    <div
-      v-for="(item, index) in currentPermissionData"
-      :key="item"
-      class="mt30"
-    >
+    <div v-for="(item, index) in basePermissionData" :key="item" class="mt30">
       <div class="df aic mb20">
         <div class="mr20">{{ item.label }}</div>
         <el-switch
@@ -75,15 +78,19 @@
         </div>
       </div>
     </div>
-  </el-card>
+  </el-card> -->
 </template>
 
 <script setup>
 import api from "../../apis/fetch";
 import store from "../../store";
+import router from "../../router";
 import { ref, onMounted, reactive, computed } from "vue";
 import { ElNotification, ElMessageBox } from "element-plus";
 import { mapGetters } from "vuex";
+import { useRoute } from "vue-router";
+
+const route = useRoute();
 
 let loginAccountId = ref(0);
 let form = ref(null);
@@ -107,23 +114,75 @@ const rules = reactive({
     },
   ],
 });
+let roleId = ref("");
 let treeRef = ref(null);
-function getTree(checkedNodes, checkedKeys) {
-  let postData = [...checkedKeys.checkedKeys, ...checkedKeys.halfCheckedKeys];
-  console.log(postData);
-}
 const defaultProps = {
   children: "children",
   label: "label",
 };
 
-function change(status, code) {
-  store.commit("updateCurrentPermissionData", { status, code });
+let basePermissionData = computed(() => store.state.basePermissionData);
+let permissionCodes = ref([]);
+let checkedNodes = ref([]);
+function getTree(checked, checkedKeys) {
+  permissionCodes.value = [
+    ...checkedKeys.checkedKeys,
+    ...checkedKeys.halfCheckedKeys,
+  ];
+}
+
+async function getRoleDetail(roleId) {
+  let res = await api.getRoleDetail({
+    loginAccountId: loginAccountId.value,
+    roleId,
+  });
+  if (res.data.status == 0) {
+    let { code, roleName, permission } = res.data.result;
+    ruleForm.value = {
+      roleCode: code,
+      roleName,
+    };
+    checkedNodes.value = permission.split(",");
+  }
+}
+
+async function addRole() {
+  let postData = {
+    loginAccountId: loginAccountId.value,
+    ...ruleForm.value,
+    permissionCodes: permissionCodes.value.join(","),
+  };
+  if (roleId.value) {
+    postData.roleId = roleId.value;
+  }
+  let res = await api[roleId.value ? "updateRole" : "addRole"](postData);
+  if (res.data.status == 0) {
+    ElNotification({
+      title: "成功",
+      duration: 1500,
+      message: res.data.msg,
+      type: "success",
+    });
+    router.replace("/authManage/roleList");
+  } else {
+    console.log(res);
+    ElNotification({
+      title: "失败",
+      duration: 1500,
+      message: res.data.msg,
+      type: "error",
+    });
+  }
 }
 
-let currentPermissionData = computed(() => store.state.currentPermissionData);
 onMounted(() => {
   loginAccountId.value = localStorage.loginAccountId;
+  let id = route.query.roleId;
+  if (id) {
+    getRoleDetail(id);
+    roleId.value = id;
+    store.commit("changefirstTitle", "修改角色");
+  }
 });
 </script>
 

+ 13 - 12
src/views/authManage/roleList.vue

@@ -41,17 +41,12 @@
         ></el-table-column>
         <el-table-column label="操作" min-width="120" align="center">
           <template v-slot="scope">
-            <div
-              style="
-                color: red;
-                font-size: 14px;
-                text-decoration: underline;
-                cursor: pointer;
-              "
-              @click="roleDetail(scope.row)"
+            <el-button
+              @click="roleDetail(scope.row.id)"
+              size="small"
+              type="primary"
+              >详情</el-button
             >
-              详情
-            </div>
           </template>
         </el-table-column>
       </el-table>
@@ -72,6 +67,7 @@ import api from "../../apis/fetch";
 import { ref, onMounted, reactive } from "vue";
 import { ElNotification, ElMessageBox } from "element-plus";
 import router from "../../router";
+import store from "../../store";
 
 let tableData = ref([]);
 let currentPage = ref(1);
@@ -104,8 +100,13 @@ function addRole() {
   router.push("/authManage/addRole");
 }
 
-function roleDetail(item) {
-  console.log(item);
+function roleDetail(roleId) {
+  router.push({
+    path: "/authManage/addRole",
+    query: {
+      roleId,
+    },
+  });
 }
 
 onMounted(() => {

+ 4 - 15
src/views/cargoManage/cargoList.vue

@@ -36,8 +36,8 @@
         ></el-table-column>
         <el-table-column label="操作" min-width="80" align="center">
           <template v-slot="scope">
-            <div class="df aic">
-              <el-switch
+            <div class="df aic jcsa">
+              <!-- <el-switch
                 v-model="scope.row.status"
                 active-color="#13ce66"
                 inactive-color="#ff4949"
@@ -45,19 +45,8 @@
                 inactive-text="禁用"
                 :active-value="1"
                 :inactive-value="0"
-              />
-
-              <div
-                style="
-                  color: red;
-                  margin-left: 10px;
-                  font-size: 14px;
-                  text-decoration: underline;
-                  cursor: pointer;
-                "
-              >
-                删除
-              </div>
+              /> -->
+              <el-button disabled size="small" type="danger">删除</el-button>
             </div>
           </template>
         </el-table-column>

+ 1 - 0
src/views/voyage/voyageList.vue

@@ -293,6 +293,7 @@ export default {
       tableData.value = [];
 
       let res = await api.getVoyageList({
+        loginAccountId: localStorage.loginAccountId,
         cargoOwnerId: localStorage.userId,
         shipId: 0,
         status: status.value,