|
@@ -4,13 +4,13 @@
|
|
|
<el-form-item label="藏品名称:" prop="name" style="width: 550px">
|
|
|
<el-input v-model="ruleForm.name" maxlength="20" show-word-limit></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="藏品图片 :" prop="avatar">
|
|
|
+ <!-- <el-form-item label="藏品图片 :" prop="avatar">
|
|
|
<el-upload class="avatar-uploader" action="https://jsonplaceholder.typicode.com/posts/" :show-file-list="false"
|
|
|
:on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
|
|
|
<img v-if="ruleForm.imageUrl" :src="ruleForm.imageUrl" class="avatar" />
|
|
|
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
</el-upload>
|
|
|
- </el-form-item>
|
|
|
+ </el-form-item> -->
|
|
|
<el-form-item label="藏品价格:" prop="price" style="width: 550px">
|
|
|
<el-input v-model="ruleForm.price" show-word-limit>
|
|
|
<template slot="append">¥</template>
|
|
@@ -21,13 +21,7 @@
|
|
|
<template slot="append">份</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
- <!-- 未改 -->
|
|
|
- <el-form-item label="发行方:" prop="number" style="width: 550px">
|
|
|
- <el-select v-model="value" placeholder="请选择">
|
|
|
- <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
+
|
|
|
<el-form-item label="售卖时间:" prop="date" style="width: 550px">
|
|
|
<el-date-picker v-model="ruleForm.date" type="datetimerange" start-placeholder="开始日期" end-placeholder="结束日期"
|
|
|
:default-time="['12:00:00']">
|
|
@@ -40,14 +34,14 @@
|
|
|
</el-form>
|
|
|
<el-backtop :bottom="60">
|
|
|
<div style="{
|
|
|
- height: 100%;
|
|
|
- width: 100%;
|
|
|
- background-color: #f2f5f6;
|
|
|
- box-shadow: 0 0 6px rgba(0,0,0, .12);
|
|
|
- text-align: center;
|
|
|
- line-height: 40px;
|
|
|
- color: #1989fa;
|
|
|
- }">
|
|
|
+ height: 100%;
|
|
|
+ width: 100%;
|
|
|
+ background-color: #f2f5f6;
|
|
|
+ box-shadow: 0 0 6px rgba(0,0,0, .12);
|
|
|
+ text-align: center;
|
|
|
+ line-height: 40px;
|
|
|
+ color: #1989fa;
|
|
|
+ }">
|
|
|
top
|
|
|
</div>
|
|
|
</el-backtop>
|
|
@@ -55,6 +49,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { addCollections } from '../../../api/collection/collections'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -91,7 +86,6 @@ export default {
|
|
|
price: [
|
|
|
{ required: true, message: "请输入藏品价格", trigger: "blur" },
|
|
|
{
|
|
|
- min: 2,
|
|
|
max: 20,
|
|
|
message: "长度在 2 到 20个字符",
|
|
|
trigger: "blur",
|
|
@@ -100,19 +94,18 @@ export default {
|
|
|
number: [
|
|
|
{ required: true, message: "请输入藏品数量", trigger: "blur" },
|
|
|
{
|
|
|
- min: 2,
|
|
|
max: 20,
|
|
|
message: "长度在 2 到 20个字符",
|
|
|
trigger: "blur",
|
|
|
},
|
|
|
],
|
|
|
- avatar: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: "请按照规范上传尺寸为750px*750px的图片",
|
|
|
- trigger: "blur",
|
|
|
- },
|
|
|
- ],
|
|
|
+ // avatar: [
|
|
|
+ // {
|
|
|
+ // required: true,
|
|
|
+ // message: "请按照规范上传尺寸为400px*400px的图片",
|
|
|
+ // trigger: "blur",
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
date: [
|
|
|
{
|
|
|
required: true,
|
|
@@ -128,29 +121,46 @@ export default {
|
|
|
submitForm(formName) {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- alert("submit!");
|
|
|
+ addCollections({
|
|
|
+ addName: this.ruleForm.name,
|
|
|
+ addDate: this.ruleForm.date,
|
|
|
+ // addImagUrl: this.ruleForm.imageUrl,
|
|
|
+ addDesc: this.ruleForm.desc,
|
|
|
+ addPrice: this.ruleForm.price,
|
|
|
+ addNumber: this.ruleForm.number
|
|
|
+ }).then((res) => {
|
|
|
+ this.$message({
|
|
|
+ message: '添加成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ console.log(res);
|
|
|
+ this.$refs[formName].resetFields();
|
|
|
+ this.$router.push({ name: "collections" });
|
|
|
+ }).catch((e) => {
|
|
|
+ console.log(e);
|
|
|
+ })
|
|
|
} else {
|
|
|
console.log("error submit!!");
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- handleAvatarSuccess(res, file) {
|
|
|
- console.log(res);
|
|
|
- this.imageUrl = URL.createObjectURL(file.raw);
|
|
|
- },
|
|
|
- beforeAvatarUpload(file) {
|
|
|
- const isJPG = file.type === "image/jpeg";
|
|
|
- const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
+ // handleAvatarSuccess(res, file) {
|
|
|
+ // console.log(res);
|
|
|
+ // 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;
|
|
|
- },
|
|
|
+ // if (!isJPG) {
|
|
|
+ // this.$message.error("上传头像图片只能是 JPG 格式!");
|
|
|
+ // }
|
|
|
+ // if (!isLt2M) {
|
|
|
+ // this.$message.error("上传头像图片大小不能超过 2MB!");
|
|
|
+ // }
|
|
|
+ // return isJPG && isLt2M;
|
|
|
+ // },
|
|
|
},
|
|
|
};
|
|
|
</script>
|