|
@@ -40,11 +40,8 @@
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="图片" prop="picUrl">
|
|
<el-form-item label="图片" prop="picUrl">
|
|
<image-upload
|
|
<image-upload
|
|
|
|
+ v-model="bannerPicUrl"
|
|
:limit="1"
|
|
:limit="1"
|
|
- :value="form.picUrl"
|
|
|
|
- :file-size="50"
|
|
|
|
- :is-public="true"
|
|
|
|
- @input="pictureSelect"
|
|
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="类型" prop="type">
|
|
<el-form-item label="类型" prop="type">
|
|
@@ -91,7 +88,7 @@
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
import CustomFieldsMixin from "@/mixins/CustomFields";
|
|
import CustomFieldsMixin from "@/mixins/CustomFields";
|
|
-import { goodsBannerCreate } from "@/api/business/banner";
|
|
|
|
|
|
+import { goodsBannerCreate, goodsBannerDetail, goodsBannerUpdate } from "@/api/business/banner";
|
|
import { goodsTagItems } from "@/api/business/tag";
|
|
import { goodsTagItems } from "@/api/business/tag";
|
|
export default {
|
|
export default {
|
|
mixins: [CustomFieldsMixin],
|
|
mixins: [CustomFieldsMixin],
|
|
@@ -101,16 +98,16 @@ export default {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
default: false,
|
|
default: false,
|
|
},
|
|
},
|
|
- },
|
|
|
|
- created() {
|
|
|
|
- this.getBannerLocation();
|
|
|
|
- this.getGoodsTagItems();
|
|
|
|
|
|
+ // ID
|
|
|
|
+ bannerId: {
|
|
|
|
+ type:[Number, String],
|
|
|
|
+ default: ''
|
|
|
|
+ }
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
loading: false,
|
|
loading: false,
|
|
form: {
|
|
form: {
|
|
- picUrl: [],
|
|
|
|
type: 'link',
|
|
type: 'link',
|
|
sort: 0
|
|
sort: 0
|
|
},
|
|
},
|
|
@@ -133,7 +130,6 @@ export default {
|
|
],
|
|
],
|
|
picUrl: [
|
|
picUrl: [
|
|
{
|
|
{
|
|
- type: "array",
|
|
|
|
required: true,
|
|
required: true,
|
|
message: "请上传banner图片",
|
|
message: "请上传banner图片",
|
|
trigger: "change",
|
|
trigger: "change",
|
|
@@ -151,6 +147,35 @@ export default {
|
|
},
|
|
},
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ bannerPicUrl: {
|
|
|
|
+ get() {
|
|
|
|
+ return this.form.picUrl ? this.form.picUrl.split(',').map(item => {
|
|
|
|
+ return {
|
|
|
|
+ fileName: item
|
|
|
|
+ }
|
|
|
|
+ }) : []
|
|
|
|
+ },
|
|
|
|
+ set(val) {
|
|
|
|
+ this.$set(this.form, 'picUrl', val.map(item => { return item.fileName }).toString())
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.getBannerLocation();
|
|
|
|
+ this.getGoodsTagItems();
|
|
|
|
+ if(this.bannerId){
|
|
|
|
+ goodsBannerDetail({ bannerId: this.bannerId }).then(res => {
|
|
|
|
+ console.log('res', res)
|
|
|
|
+ const { location, name, sort, picUrl, type, linkUrl, goodsTags } = res.data
|
|
|
|
+ this.form = {
|
|
|
|
+ location: JSON.parse(location).value,
|
|
|
|
+ goodsTags: goodsTags ? goodsTags.split(',').map(item => Number(item)) : [],
|
|
|
|
+ name, sort, picUrl, type, linkUrl
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
getBannerLocation() {
|
|
getBannerLocation() {
|
|
this.getDicts("banner_location").then((res) => {
|
|
this.getDicts("banner_location").then((res) => {
|
|
@@ -199,13 +224,16 @@ export default {
|
|
submitForm(form) {
|
|
submitForm(form) {
|
|
let data = {
|
|
let data = {
|
|
... form,
|
|
... form,
|
|
- picUrl: this.form.picUrl[0].fileName,
|
|
|
|
goodsTags: form.goodsTags ? form.goodsTags.join(',') : ''
|
|
goodsTags: form.goodsTags ? form.goodsTags.join(',') : ''
|
|
};
|
|
};
|
|
- goodsBannerCreate(data)
|
|
|
|
|
|
+ let request = this.bannerId ? goodsBannerUpdate : goodsBannerCreate
|
|
|
|
+ if(this.bannerId){
|
|
|
|
+ data.bannerId = this.bannerId
|
|
|
|
+ }
|
|
|
|
+ request(data)
|
|
.then((res) => {
|
|
.then((res) => {
|
|
if (res.code == 0) {
|
|
if (res.code == 0) {
|
|
- this.msgSuccess("添加成功");
|
|
|
|
|
|
+ this.msgSuccess(this.bannerId ? "修改成功" : '添加成功');
|
|
this.close();
|
|
this.close();
|
|
}
|
|
}
|
|
})
|
|
})
|