兰宝车间质量管理系统-前端
LiuHao
2023-06-06 6af68085ff6615e1ec3a5dd18c761250800d6fca
src/views/system/user/authRole.vue
@@ -55,11 +55,10 @@
</template>
<script setup name="AuthRole" lang="ts">
import { RoleVO } from '@/api/system/role/types';
import { getAuthRole, updateAuthRole } from '@/api/system/user';
import { UserForm } from '@/api/system/user/types';
import { ElTable } from "element-plus";
import { ComponentInternalInstance } from 'vue';
import { RoleVO } from "@/api/system/role/types";
import { getAuthRole, updateAuthRole } from "@/api/system/user";
import { UserForm } from "@/api/system/user/types";
const route = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -71,15 +70,16 @@
const roles = ref<RoleVO[]>([]);
const form = ref<Partial<UserForm>>({
    nickName: undefined,
    userName: '',
  userName: "",
    userId: undefined
});
const tableRef = ref(ElTable)
const tableRef = ref<ElTableInstance>();
/** 单击选中行数据 */
const clickRow = (row: RoleVO) => {
    tableRef.value.toggleRowSelection(row);
  // ele的方法有问题,selected应该为可选参数
  tableRef.value?.toggleRowSelection(row);
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: RoleVO[]) => {
@@ -98,7 +98,7 @@
const submitForm = async () => {
    const userId = form.value.userId;
    const rIds = roleIds.value.join(",");
    await updateAuthRole({ userId: userId as string, roleIds: rIds })
  await updateAuthRole({ userId: userId as string, roleIds: rIds });
    proxy?.$modal.msgSuccess("授权成功");
    close();
};
@@ -108,20 +108,20 @@
    if (userId) {
        loading.value = true;
        const res = await getAuthRole(userId as string);
        Object.assign(form.value, res.data.user)
        Object.assign(roles.value, res.data.roles)
    Object.assign(form.value, res.data.user);
    Object.assign(roles.value, res.data.roles);
        total.value = roles.value.length;
        await nextTick(() => {
            roles.value.forEach(row => {
                if (row?.flag) {
                    tableRef.value.toggleRowSelection(row);
          tableRef.value?.toggleRowSelection(row, true);
                }
            });
        });
        loading.value = false;
    }
}
};
onMounted(() => {
    getList();
})
});
</script>