This commit is contained in:
faiz 2024-06-27 19:55:57 +08:00
parent ff630901e4
commit 280ed83056
1 changed files with 73 additions and 0 deletions

View File

@ -44,6 +44,28 @@
<el-form-item label="状态">
<el-switch v-model="anchors.status" :active-value="1" :inactive-value="0" active-color="#13ce66" inactive-color="#ff4949" />
</el-form-item>
<el-form-item label="上传图片">
<el-upload
class="avatar-uploader"
action="admin/index/avatar"
:show-file-list="false"
:on-success="handleAvatarSuccess"
>
<img v-if="imageUrl" :src="imageUrl" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
<el-form-item label="上传行程">
<el-upload
class="avatar-uploader"
action="admin/index/avatar"
:show-file-list="false"
:on-success="handleSuccess"
>
<img v-if="imageUrls" :src="imageUrls" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button v-loading="loading" type="primary" @click="onSave"> </el-button>
@ -64,6 +86,28 @@
<el-form-item label="状态">
<el-switch v-model="anchors.status" :active-value="1" :inactive-value="0" active-color="#13ce66" inactive-color="#ff4949" />
</el-form-item>
<el-form-item label="上传图片">
<el-upload
class="avatar-uploader"
action="admin/index/avatar"
:show-file-list="false"
:on-success="handleAvatarSuccess"
>
<img v-if="imageUrl" :src="imageUrl" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
<el-form-item label="上传行程">
<el-upload
class="avatar-uploader"
action="admin/index/avatar"
:show-file-list="false"
:on-success="handleSuccess"
>
<img v-if="imageUrls" :src="imageUrls" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button v-loading="loading" type="primary" @click="onSave"> </el-button>
@ -96,6 +140,8 @@ export default {
dialogCreate: false,
dialogEdit: false,
item: {},
imageUrl:'',
imageUrls:'',
anchors: {}
}
},
@ -115,6 +161,13 @@ export default {
this.listLoading = false
})
},
handleAvatarSuccess(res, file) {
this.imageUrl = URL.createObjectURL(file.raw)
console.log(this.imageUrl);
},
handleSuccess(res, file) {
this.imageUrls = URL.createObjectURL(file.raw)
},
onAdd() {
this.anchors = { sort: 0 } // 0
this.dialogCreate = true
@ -172,4 +225,24 @@ export default {
.search {
margin-left: 10px;
}
.avatar-uploader .el-upload {
border: 1px solid #131313;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
.avatar-uploader-icon {
border: 1px solid #979797;
border-radius: 15px;
font-size: 28px;
color: #8c939d;
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
}
</style>