|
@@ -2,13 +2,7 @@
|
|
|
<div>
|
|
|
<div class="addfrom">
|
|
|
<div class="addcenter">
|
|
|
- <el-form
|
|
|
- ref="pubform"
|
|
|
- label-width="100px"
|
|
|
- :style="{ border: '1px soild #ccc' }"
|
|
|
- :model="pubform"
|
|
|
- :rules="rules"
|
|
|
- >
|
|
|
+ <el-form ref="pubform" label-width="100px" :style="{ border: '1px soild #ccc' }" :model="pubform" :rules="rules">
|
|
|
<el-form-item label="发行方名称" prop="collectionTitle">
|
|
|
<el-input v-model="pubform.collectionTitle"></el-input>
|
|
|
</el-form-item>
|
|
@@ -30,41 +24,15 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="上传头像" prop="headPortrait">
|
|
|
- <el-upload
|
|
|
- v-model="pubform.headPortrait"
|
|
|
- action="/file/upload"
|
|
|
- :http-request="customHttpResqust"
|
|
|
- :auto-upload="true"
|
|
|
- list-type="picture-card"
|
|
|
- accept="image/*"
|
|
|
- :limit="1"
|
|
|
- show-file-list
|
|
|
- :file-list="fileList"
|
|
|
- enctype="multipart/form-data"
|
|
|
- >
|
|
|
- <i
|
|
|
- slot="default"
|
|
|
- class="el-icon-plus"
|
|
|
- :style="{
|
|
|
- textAlign: 'center',
|
|
|
- }"
|
|
|
- ></i>
|
|
|
- <div slot="file" slot-scope="{ file }">
|
|
|
- <img
|
|
|
- class="el-upload-list__item-thumbnail"
|
|
|
- :src="file.url"
|
|
|
- alt=""
|
|
|
- />
|
|
|
- </div>
|
|
|
+ <el-upload class="avatar-uploader" action="http://39.105.160.25:10996" :show-file-list="false"
|
|
|
+ :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
|
|
+ <img v-if="this.pubform.headPortrait" :src="this.pubform.headPortrait" class="avatar">
|
|
|
+ <i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
- <el-input
|
|
|
- type="textarea"
|
|
|
- :rows="4"
|
|
|
- v-model="pubform.remark"
|
|
|
- ></el-input>
|
|
|
+ <el-input type="textarea" :rows="4" v-model="pubform.remark"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" @click="submitpub">提交</el-button>
|
|
@@ -75,13 +43,14 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
-<!-- -->
|
|
|
+
|
|
|
<script>
|
|
|
import { addpublish, upload } from "../../api/publisher/publish";
|
|
|
export default {
|
|
|
name: "addPublisher",
|
|
|
data() {
|
|
|
return {
|
|
|
+ imageUrl: '',
|
|
|
fileList: [], //上传的文件列表
|
|
|
pubform: {
|
|
|
collectionTitle: "",
|
|
@@ -105,26 +74,13 @@ export default {
|
|
|
handleAvatarSuccess() {
|
|
|
console.log("上传成功");
|
|
|
},
|
|
|
- async customHttpResqust({ action, data, file, filename }) {
|
|
|
- // console.log(action,data,file,filename)
|
|
|
- console.log(action)
|
|
|
- const fd = new FormData();
|
|
|
-
|
|
|
- for (var k in data) {
|
|
|
- if (data.hasOwnProperty(k)) {
|
|
|
- fd.append(k, data[k]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- fd.append(filename, file);
|
|
|
- let { code, data: d, msg } = await upload(action, fd).catch((err) => err);
|
|
|
- console.log("上传成功");
|
|
|
- console.log(d);
|
|
|
- if (code == 200) {
|
|
|
- console.log(`output->data`, d);
|
|
|
- this.pubform.headPortrait = d.url;
|
|
|
- }
|
|
|
- console.log("上传成功");
|
|
|
+ beforeAvatarUpload(file) {
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append('file', file);
|
|
|
+ upload(formData).then(res => {
|
|
|
+ console.log(res);
|
|
|
+ this.pubform.headPortrait = res.url;
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
submitpub() {
|
|
@@ -144,7 +100,7 @@ export default {
|
|
|
message: "创建消息成功",
|
|
|
type: "success",
|
|
|
});
|
|
|
- this.$router.push("./publisherList");
|
|
|
+ // this.$router.push("./publisherList");
|
|
|
} else {
|
|
|
this.$notify({
|
|
|
title: "警告",
|
|
@@ -166,9 +122,38 @@ export default {
|
|
|
margin-top: 40px;
|
|
|
border-radius: 4px;
|
|
|
}
|
|
|
+
|
|
|
.addcenter {
|
|
|
margin: auto;
|
|
|
width: 60%;
|
|
|
margin-top: 40px;
|
|
|
}
|
|
|
+
|
|
|
+.avatar-uploader .el-upload {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ width: 200px;
|
|
|
+ height: 200px;
|
|
|
+}
|
|
|
+
|
|
|
+.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: 100%;
|
|
|
+ display: block;
|
|
|
+}
|
|
|
</style>
|