Commit e9bf2238 authored by Junling Bu's avatar Junling Bu
Browse files

perf[litemall-admin]: 调整管理员页面效果

parent 2d7a3f81
...@@ -12,16 +12,19 @@ ...@@ -12,16 +12,19 @@
<!-- 查询结果 --> <!-- 查询结果 -->
<el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit highlight-current-row> <el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit highlight-current-row>
<el-table-column align="center" width="100px" label="管理员ID" prop="id" sortable> <el-table-column align="center" label="管理员ID" prop="id" sortable>
</el-table-column> </el-table-column>
<el-table-column align="center" min-width="100px" label="管理员名称" prop="username"> <el-table-column align="center" label="管理员名称" prop="username">
</el-table-column> </el-table-column>
<el-table-column align="center" min-width="100px" label="管理员头像" prop="avatar"> <el-table-column align="center" label="管理员头像" prop="avatar">
<template slot-scope="scope">
<img :src="scope.row.avatar" width="40" v-if="scope.row.avatar"/>
</template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button> <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button> <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
...@@ -49,9 +52,9 @@ ...@@ -49,9 +52,9 @@
<el-input type="password" v-model="dataForm.checkPassword" auto-complete="off"></el-input> <el-input type="password" v-model="dataForm.checkPassword" auto-complete="off"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="管理员头像" prop="avatar"> <el-form-item label="管理员头像" prop="avatar">
<el-input v-model="dataForm.avatar"></el-input> <el-upload class="avatar-uploader" :action="uploadPath" list-type="picture-card" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" :on-success="uploadAvatar">
<el-upload action="#" list-type="picture" :show-file-list="false" :limit="1" :http-request="uploadAvatar"> <img v-if="dataForm.avatar" :src="dataForm.avatar" class="avatar">
<el-button size="small" type="primary">点击上传</el-button> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -65,9 +68,35 @@ ...@@ -65,9 +68,35 @@
</div> </div>
</template> </template>
<style>
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #20a0ff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 120px;
height: 120px;
line-height: 120px;
text-align: center;
}
.avatar {
width: 120px;
height: 120px;
display: block;
}
</style>
<script> <script>
import { listAdmin, createAdmin, updateAdmin, deleteAdmin } from '@/api/admin' import { listAdmin, createAdmin, updateAdmin, deleteAdmin } from '@/api/admin'
import { createStorage } from '@/api/storage' import { uploadPath } from '@/api/storage'
export default { export default {
name: 'Admin', name: 'Admin',
...@@ -92,6 +121,7 @@ export default { ...@@ -92,6 +121,7 @@ export default {
} }
} }
return { return {
uploadPath,
list: null, list: null,
total: null, total: null,
listLoading: true, listLoading: true,
...@@ -166,14 +196,8 @@ export default { ...@@ -166,14 +196,8 @@ export default {
avatar: undefined avatar: undefined
} }
}, },
uploadAvatar(item) { uploadAvatar: function(response) {
const formData = new FormData() this.dataForm.avatar = response.data.url
formData.append('file', item.file)
createStorage(formData).then(res => {
this.dataForm.avatar = res.data.data.url
}).catch(() => {
this.$message.error('上传失败,请重新上传')
})
}, },
handleCreate() { handleCreate() {
this.resetForm() this.resetForm()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment