no message

This commit is contained in:
小陌 2023-07-11 16:33:11 +08:00
parent 600dc3b337
commit de63efb81d
4 changed files with 57 additions and 35 deletions

View File

@ -66,7 +66,7 @@
title: { type: String, default: "" }, title: { type: String, default: "" },
icon: { type: String, default: "el-icon-plus" }, icon: { type: String, default: "el-icon-plus" },
action: { type: String, default: "" }, action: { type: String, default: "" },
apiObj: { type: Object, default: () => {} }, api: { type: String, default: "" },
name: { type: String, default: config.filename }, name: { type: String, default: config.filename },
data: { type: Object, default: () => {} }, data: { type: Object, default: () => {} },
accept: { type: String, default: "image/gif, image/jpeg, image/png" }, accept: { type: String, default: "image/gif, image/jpeg, image/png" },
@ -77,6 +77,7 @@
disabled: { type: Boolean, default: false }, disabled: { type: Boolean, default: false },
round: { type: Boolean, default: false }, round: { type: Boolean, default: false },
onSuccess: { type: Function, default: () => { return true } }, onSuccess: { type: Function, default: () => { return true } },
onRemove: { type: Function, default: () => { return true } },
cropper: { type: Boolean, default: false }, cropper: { type: Boolean, default: false },
compress: {type: Number, default: 1}, compress: {type: Number, default: 1},
aspectRatio: {type: Number, default: NaN} aspectRatio: {type: Number, default: NaN}
@ -148,6 +149,10 @@
delete this.cropperFile.tempCropperFile delete this.cropperFile.tempCropperFile
}, },
handleRemove(){ handleRemove(){
var os = this.onRemove()
if(os!=undefined && os===false){
return false
}
this.clearFiles() this.clearFiles()
}, },
clearFiles(){ clearFiles(){
@ -229,16 +234,13 @@
}) })
}, },
request(param){ request(param){
var apiObj = config.apiObj; var api = this.api ? this.api : config.api;
if(this.apiObj){
apiObj = this.apiObj;
}
const data = new FormData(); const data = new FormData();
data.append(param.filename, param.file); data.append(param.filename, param.file);
for (const key in param.data) { for (const key in param.data) {
data.append(key, param.data[key]); data.append(key, param.data[key]);
} }
apiObj.post(data, { this.$http.post(api,data, {
onUploadProgress: e => { onUploadProgress: e => {
const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10) const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10)
param.onProgress({percent: complete}) param.onProgress({percent: complete})
@ -249,7 +251,6 @@
param.onSuccess(response); param.onSuccess(response);
return ; return ;
} }
param.onError(response.message || "未知错误") param.onError(response.message || "未知错误")
}).catch(err => { }).catch(err => {
param.onError(err) param.onError(err)
@ -262,9 +263,7 @@
<style scoped> <style scoped>
.el-form-item.is-error .x-upload .el-upload--picture-card {border-color: var(--el-color-danger);} .el-form-item.is-error .x-upload .el-upload--picture-card {border-color: var(--el-color-danger);}
.x-upload .el-upload--picture-card {border-radius: 0;} .x-upload .el-upload--picture-card {border-radius: 0;}
.x-upload .uploader,.x-upload:deep(.el-upload) {width: 100%;height: 100%;} .x-upload .uploader,.x-upload:deep(.el-upload) {width: 100%;height: 100%;}
.x-upload__img {width: 100%;height: 100%;position: relative;} .x-upload__img {width: 100%;height: 100%;position: relative;}
.x-upload__img .image {width: 100%;height: 100%;} .x-upload__img .image {width: 100%;height: 100%;}
.x-upload__img-actions {position: absolute;top:0;right: 0;display: none;} .x-upload__img-actions {position: absolute;top:0;right: 0;display: none;}
@ -273,16 +272,13 @@
.x-upload__img-actions .del {background: #F56C6C;} .x-upload__img-actions .del {background: #F56C6C;}
.x-upload__img:hover .x-upload__img-actions {display: block;} .x-upload__img:hover .x-upload__img-actions {display: block;}
.x-upload__img-slot {display: flex;justify-content: center;align-items: center;width: 100%;height: 100%;font-size: 12px;background-color: var(--el-fill-color-lighter);} .x-upload__img-slot {display: flex;justify-content: center;align-items: center;width: 100%;height: 100%;font-size: 12px;background-color: var(--el-fill-color-lighter);}
.x-upload__uploading {width: 100%;height: 100%;position: relative;} .x-upload__uploading {width: 100%;height: 100%;position: relative;}
.x-upload__progress {position: absolute;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;background-color: var(--el-overlay-color-lighter);z-index: 1;padding:10px;} .x-upload__progress {position: absolute;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;background-color: var(--el-overlay-color-lighter);z-index: 1;padding:10px;}
.x-upload__progress .el-progress {width: 100%;} .x-upload__progress .el-progress {width: 100%;}
.x-upload__uploading .image {width: 100%;height: 100%;} .x-upload__uploading .image {width: 100%;height: 100%;}
.x-upload .file-empty {width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;flex-direction: column;} .x-upload .file-empty {width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;flex-direction: column;}
.x-upload .file-empty i {font-size: 28px;} .x-upload .file-empty i {font-size: 28px;}
.x-upload .file-empty h4 {font-size: 12px;font-weight: normal;color: #8c939d;margin-top: 8px;} .x-upload .file-empty h4 {font-size: 12px;font-weight: normal;color: #8c939d;margin-top: 8px;}
.x-upload.x-upload-round {border-radius: 50%;overflow: hidden;} .x-upload.x-upload-round {border-radius: 50%;overflow: hidden;}
.x-upload.x-upload-round .el-upload--picture-card {border-radius: 50%;} .x-upload.x-upload-round .el-upload--picture-card {border-radius: 50%;}
.x-upload.x-upload-round .x-upload__img-actions {top: auto;left: 0;right: 0;bottom: 0;} .x-upload.x-upload-round .x-upload__img-actions {top: auto;left: 0;right: 0;bottom: 0;}

View File

@ -58,13 +58,13 @@
}, },
mounted() { mounted() {
this.$http.post('system/user/get', { uid:this.data.uid }).then((res) => { // this.$http.post('system/user/get', { uid:this.data.uid }).then((res) => {
if (res.code == 200) { // if (res.code == 200) {
this.user = res.data.user; // this.user = res.data.user;
this.token = res.data.token; // this.token = res.data.token;
this.form = res.data.form; // this.form = res.data.form;
} // }
}); // });
}, },
methods: { methods: {
updateParentValue(val) { updateParentValue(val) {

View File

@ -4,14 +4,16 @@
<el-container> <el-container>
<el-header style="height: auto;display: block;"> <el-header style="height: auto;display: block;">
<div class="user-info-top"> <div class="user-info-top">
<el-avatar :size="70" :src="user.avatar"></el-avatar>
<h2>{{ user.nickname || user.username }}</h2>
<p><el-tag effect="dark" round size="large" disable-transitions>{{ user.role }}</el-tag></p>
<x-upload v-model="user.avatar" :data={token:token} v-if="avatarupload" :api="avatarupload" width="100" height="100" icon="el-icon-avatar" ref="uploader" :onRemove="onRemove" class="xuavatar" round :cropper="true" :aspectRatio="1/1">
</x-upload>
<el-avatar :size="100" v-else :src="user.avatar"></el-avatar>
<h2>{{ user.nickname || user.username }}</h2>
<!-- <p><el-tag effect="dark" round size="large" disable-transitions>{{ user.role }}</el-tag></p> -->
<p> <p>
<el-button-group> <el-button-group>
<el-button type="danger" size="small" style="padding:5px" :icon="Edit">发送消息</el-button> <el-button type="info" size="small" style="padding:5px" :icon="Edit">发送消息</el-button>
<el-button type="warning" size="small" style="padding:5px" :icon="Share">行为轨迹</el-button> <el-button type="info" color="#607d8b" size="small" style="padding:5px" :icon="Share">行为轨迹</el-button>
</el-button-group> </el-button-group>
</p> </p>
</div> </div>
@ -43,6 +45,14 @@
</el-container> </el-container>
</template> </template>
<style>
.xuavatar {
margin: auto;
border-radius: 10px !important;
}
.xuavatar .el-upload--picture-card{ --el-upload-picture-card-size:80px; border-radius: 10px !important; }
</style>
<script> <script>
import { defineAsyncComponent } from 'vue' import { defineAsyncComponent } from 'vue'
@ -114,18 +124,38 @@
] ]
}, },
], ],
user: this.modelValue, user: {},
userData: this.modelValue,
token: '',
avatarupload: '',
page: "account" page: "account"
} }
}, },
created() { created() {
this.loaddata();
}, },
methods: { methods: {
updateValue(event) { loaddata(){
const newValue = event.target.value; this.$http.post('system/user/get',{uid: this.userData.uid, type:this.type}).then((res) => {
this.$emit('update:modelValue', newValue); if (res.code==200) {
}, Object.assign(this.$data, res.data);
return false;
}
this.$alert(res.message, "提示", {type: 'error'});
});
},
onRemove(){
this.$http.post('app/avatar/delete',{token: this.token}).then((res) => {
if (res.code==200) {
this.userData.avatar = '';
this.$refs.uploader.clearFiles();
this.$message.success(res.message || "操作成功")
return false;
}
this.$alert(res.message, "提示", {type: 'error'});
});
return false;
},
openPage(item){ openPage(item){
this.page = item.index this.page = item.index
} }

View File

@ -1,9 +1,6 @@
import API from "@/api";
//上传配置 //上传配置
export default { export default {
apiObj: API.common.upload, //上传请求API对象 api: '/app/upload', //上传请求API对象
filename: "files", //form请求时文件的key filename: "files", //form请求时文件的key
successCode: 200, //请求完成代码 successCode: 200, //请求完成代码
maxSize: 10, //最大文件大小 默认10MB maxSize: 10, //最大文件大小 默认10MB
@ -16,6 +13,5 @@ export default {
aid: res.data.aid, //分析图片远程地址结构 aid: res.data.aid, //分析图片远程地址结构
} }
}, },
apiObjFile: API.common.uploadFile, //附件上传请求API对象
maxSizeFile: 10 //最大文件大小 默认10MB maxSizeFile: 10 //最大文件大小 默认10MB
} }