123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <template>
- <div class="message-add" :style="{height:height,width:width}" >
-
- <!-- <el-page-header @back="goBack" content="创建消息"></el-page-header> -->
- <div class="message-add-box">
- <el-form :model="message" :rules="rules" ref="form" label-width="100px">
-
- <el-form-item label="藏品名称:" prop="collectionName">
- <el-input v-model="message.collectionName" style="width: 550px" placeholder="请输入藏品名称"></el-input>
- </el-form-item>
- <el-form-item label="藏品头图:" prop="imageUrl">
- <el-upload
- class="avatar-uploader"
- action="https://jsonplaceholder.typicode.com/posts/"
- :show-file-list="false"
- :on-success="handleAvatarSuccess"
- :before-upload="beforeAvatarUpload"
- >
- <img v-if="imageUrl" :src="imageUrl" class="avatar" />
- <i
- v-else
- class="el-icon-plus avatar-uploader-icon"
- ></i> </el-upload>
- </el-form-item>
-
- <el-form-item>
- <el-button type="primary" @click="addCollection('form')">提交</el-button>
- <el-button @click="resetForm('form')">重置</el-button>
- <el-button @click="importForm('form')">导入</el-button>
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import {addCollection} from '../../api/collection/collection.js'
- export default {
-
- data() {
- return {
- message: {
- collectionName:'',
- imageUrl: ''
- },
- rules:{
- collectionName: [
- { required: true, message: '请输入藏品名称', trigger: 'blur' }
- ],
- }
- }
- },
- mounted() {
- console.log( "-****" , this.message.collectionName);
- console.log( "-****" , this.message.imageUrl);
- },
- methods: {
- handleAvatarSuccess(res, file) {
- this.imageUrl = URL.createObjectURL(file.raw);
- },
- beforeAvatarUpload(file) {
- const isJPG = file.type === 'image/jpeg';
- const isLt2M = file.size / 1024 / 1024 < 2;
- if (!isJPG) {
- this.$message.error('上传头像图片只能是 JPG 格式!');
- }
- if (!isLt2M) {
- this.$message.error('上传头像图片大小不能超过 2MB!');
- }
- return isJPG && isLt2M;
- },
- addCollection() {
- console.log( "-****" , this.message.collectionName);
- console.log( "-****" , this.message.imageUrl);
- addCollection(this.collectionName) .then((res)=>{
- console.log(res);
- })
- },
- resetForm(formName) {
- this.$refs[formName].resetFields();
- },
- // importForm(formName) {
-
- // }
- }
- }
- </script>
- <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: #409EFF;
- }
- .avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- width: 178px;
- height: 178px;
- line-height: 178px;
- text-align: center;
- }
- .avatar {
- width: 178px;
- height: 178px;
- display: block;
- }
- .message-add-box{
- width: 60%;
- height: 100%;
- margin: 50px auto;
- border: 1px solid #ccc;
- padding-top: 40px;
- padding-left: 100px;
- padding-right: 30px;
- }
- /* .users-input-box{
- color:aqua;
- } */
- .quill-editor /deep/ .ql-container {
- min-height: 220px;
- }
- .ql-container {
- min-height: 230px;
- }
- .ql-toolbar.ql-snow {
- border: 1px solid #ccc;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
- padding: 8px;
- width: 450px;
- }
- .ql-toolbar.ql-snow + .ql-container.ql-snow {
- border-top: 0px;
- width: 450px;
- }
- </style>
|