perf: refresh token && delete console

This commit is contained in:
xingyu
2022-08-03 00:41:59 +08:00
parent 2bf09cbfc2
commit 21cf922723
10 changed files with 100 additions and 63 deletions

View File

@ -6,12 +6,12 @@ import { ElRow, ElCol, ElUpload, ElMessage, ElDialog } from 'element-plus'
import { propTypes } from '@/utils/propTypes'
import { uploadAvatarApi } from '@/api/system/user/profile'
const cropper = ref()
const dialogVisible = ref(false)
const cropperVisible = ref(false)
const props = defineProps({
img: propTypes.string.def('')
})
const state = reactive({
dialogVisible: false,
cropperVisible: false,
const options = reactive({
dialogTitle: '编辑头像',
options: {
img: props.img, //裁剪图片的地址
@ -27,8 +27,11 @@ const state = reactive({
})
/** 编辑头像 */
const editCropper = () => {
state.dialogVisible = true
state.cropperVisible = true
dialogVisible.value = true
}
// 打开弹出层结束时的回调
const modalOpened = () => {
cropperVisible.value = true
}
/** 向左旋转 */
const rotateLeft = () => {
@ -44,7 +47,7 @@ const changeScale = (num: number) => {
cropper.value.changeScale(num)
}
// 覆盖默认的上传行为
const requestUpload = () => {}
const requestUpload: any = () => {}
/** 上传预处理 */
const beforeUpload = (file: Blob) => {
if (file.type.indexOf('image/') == -1) {
@ -54,64 +57,65 @@ const beforeUpload = (file: Blob) => {
reader.readAsDataURL(file)
reader.onload = () => {
if (reader.result) {
state.options.img = reader.result as string
options.options.img = reader.result as string
}
}
}
}
/** 上传图片 */
const uploadImg = () => {
cropper.value.getCropBlob((data) => {
cropper.value.getCropBlob((data: any) => {
let formData = new FormData()
formData.append('avatarfile', data)
uploadAvatarApi(formData)
})
}
/** 实时预览 */
const realTime = (data) => {
state.previews = data
const realTime = (data: any) => {
options.previews = data
}
watch(
() => props.img,
() => {
if (props.img) {
state.options.img = props.img
state.previews.img = props.img
state.previews.url = props.img
options.options.img = props.img
options.previews.img = props.img
options.previews.url = props.img
}
}
)
</script>
<template>
<div class="user-info-head" @click="editCropper()">
<img :src="state.options.img" title="点击上传头像" class="img-circle img-lg" alt="" />
<img :src="options.options.img" title="点击上传头像" class="img-circle img-lg" alt="" />
</div>
<el-dialog
v-model="state.dialogVisible"
:title="state.dialogTitle"
width="50%"
:maxHeight="350"
v-model="dialogVisible"
:title="options.dialogTitle"
width="800px"
append-to-body
style="padding: 30px 20px"
@opened="modalOpened"
>
<el-row>
<el-col :xs="24" :md="12" style="height: 350px">
<VueCropper
ref="cropper"
:img="state.options.img"
:img="options.options.img"
:info="true"
:autoCrop="state.options.autoCrop"
:autoCropWidth="state.options.autoCropWidth"
:autoCropHeight="state.options.autoCropHeight"
:fixedBox="state.options.fixedBox"
:autoCrop="options.options.autoCrop"
:autoCropWidth="options.options.autoCropWidth"
:autoCropHeight="options.options.autoCropHeight"
:fixedBox="options.options.fixedBox"
@real-time="realTime"
v-if="state.cropperVisible"
v-if="cropperVisible"
/>
</el-col>
<el-col :xs="24" :md="12" style="height: 350px">
<div class="avatar-upload-preview">
<img
:src="state.previews.url"
:style="state.previews.img"
:src="options.previews.url"
:style="options.previews.img"
style="!max-width: 100%"
alt=""
/>

View File

@ -47,7 +47,6 @@ const getTree = async () => {
const res = await MenuApi.listSimpleMenusApi()
const menu = { id: 0, name: '主类目', children: [] as any[] }
menu.children = handleTree(res)
console.info(menu)
menuOptions.value = menu
}
// ========== 查询 ==========

View File

@ -155,7 +155,7 @@ getList()
</Table>
</ContentWrap>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<Dialog v-model="dialogVisible" :title="dialogTitle" width="60%" maxHeight="420px">
<!-- 对话框(添加 / 修改) -->
<Form
v-if="['create', 'update'].includes(actionType)"

View File

@ -110,7 +110,7 @@ const defaultProps = {
label: 'name',
value: 'id'
}
const treeOptions = ref([]) // 菜单树形结构
const treeOptions = ref<any[]>([]) // 菜单树形结构
const treeRef = ref<InstanceType<typeof ElTree>>()
const dialogScopeVisible = ref(false)
const dialogScopeTitle = ref('数据权限')
@ -133,7 +133,6 @@ const handleScope = async (type: string, row: RoleVO) => {
const menuRes = await listSimpleMenusApi()
treeOptions.value = handleTree(menuRes)
const role = await PermissionApi.listRoleMenusApi(row.id)
console.info(role)
if (role) {
// treeRef.value!.setCheckedKeys(role as unknown as Array<number>)
defaultCheckedKeys.value = role
@ -142,7 +141,6 @@ const handleScope = async (type: string, row: RoleVO) => {
const deptRes = await listSimpleDeptApi()
treeOptions.value = handleTree(deptRes)
const role = await RoleApi.getRoleApi(row.id)
console.info(role)
dataScopeForm.dataScope = role.dataScope
if (role.dataScopeDeptIds) {
// treeRef.value!.setCheckedKeys(role.dataScopeDeptIds as unknown as Array<number>, false)
@ -155,7 +153,6 @@ const handleScope = async (type: string, row: RoleVO) => {
// 保存权限
const submitScope = async () => {
const keys = treeRef.value!.getCheckedKeys(false) as unknown as Array<number>
console.info(keys)
if ('data' === actionScopeType.value) {
const data = ref<PermissionAssignRoleDataScopeReqVO>({
roleId: dataScopeForm.id,

View File

@ -19,7 +19,7 @@ const defaultProps = {
value: 'id'
}
// ========== 创建菜单树结构 ==========
const menuOptions = ref([]) // 树形结构
const menuOptions = ref<any[]>([]) // 树形结构
const treeRef = ref<InstanceType<typeof ElTree>>()
const treeNodeAll = ref(false)
// 全选/全不选
@ -84,11 +84,9 @@ const submitForm = async () => {
if (actionType.value === 'create') {
await TenantPackageApi.createTenantPackageTypeApi(data)
ElMessage.success(t('common.createSuccess'))
console.log('new data')
} else {
await TenantPackageApi.updateTenantPackageTypeApi(data)
ElMessage.success(t('common.updateSuccess'))
console.log('edit data')
}
// 操作成功,重新加载列表
dialogVisible.value = false