<template>
|
<GlobalWindow
|
v-loading="isUploading"
|
:title="title"
|
width="60%"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<el-form :model="form" ref="form" :rules="rules" label-width="120px" label-suffix=":" >
|
<el-form-item label="专区名称" prop="title">
|
<el-input v-model="form.title" placeholder="请输入名称" :maxlength="5" v-trim/>
|
</el-form-item>
|
<el-form-item label="展示图" prop="imgFullUrl">
|
<UploadAvatarImage
|
:file="{ 'imgurlfull': form.imgFullUrl, 'imgurl': form.imgurl }"
|
:uploadData="uploadData"
|
@uploadSuccess="uploadAvatarSuccess"
|
@uploadEnd="isUploading = false"
|
@uploadBegin="isUploading = true"
|
/>
|
</el-form-item>
|
<el-form-item label="选中商品" prop="applyIdList" >
|
<span style="font-size: 12px;color: #216EEE" @click="selectGoods">已指定【 {{applyDataList.length}} 】件商品</span>
|
<el-button style="margin-left:30px;display: inline-block;width: 80px;" type="primary" @click="selectGoods">去选择 </el-button>
|
</el-form-item>
|
<el-form-item label="排序码" prop="sortnum">
|
<el-input v-model="form.sortnum" type="number" placeholder="请输入排序码" v-trim/>
|
</el-form-item>
|
</el-form>
|
<OperaCouponGoodsWindow ref="OperaCouponGoodsWindow" @success="doSelect"/>
|
</GlobalWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalWindow from '@/components/common/GlobalWindow'
|
import UploadAvatarImage from '@/components/common/UploadAvatarImage'
|
import OperaCouponGoodsWindow from '@/components/business/OperaCouponGoodsWindow'
|
import {allList as goodsList} from "@/api/business/goods";
|
export default {
|
name: 'OperaBannerWindow',
|
extends: BaseOpera,
|
components: { GlobalWindow, UploadAvatarImage ,OperaCouponGoodsWindow},
|
data () {
|
return {
|
isUploading: false,
|
searchLoading: false,
|
uploadData: {
|
folder: 'banner'
|
},
|
// 表单数据
|
form: {
|
id: null,
|
imgurl: '',
|
title:'',
|
imgFullUrl: '',
|
content: '',
|
position: 3,
|
sortnum: '',
|
objName: '',
|
applyIdList:[]
|
},
|
// 验证规则
|
rules: {
|
title: [
|
{ required: true, message: '请输入专区名称', tigger: 'blur' }
|
],
|
imgFullUrl: [
|
{ required: true, message: '请上传专区图片', tigger: 'change' }
|
],
|
},
|
applyDataList:[]
|
}
|
},
|
created () {
|
this.config({
|
api: '/business/banner',
|
'field.id': 'id'
|
})
|
},
|
methods: {
|
selectGoods () {
|
this.$refs.OperaCouponGoodsWindow.open('选择商品', this.applyDataList)
|
},
|
doSelect (rows) {
|
console.log(rows, this.applyDataList)
|
this.applyDataList = []
|
this.form.applyIdList = []
|
if (rows && rows.length) {
|
rows.forEach(item => {
|
this.applyDataList.push(item)
|
this.form.applyIdList.push(item.id)
|
})
|
}
|
this.$refs.form.clearValidate();
|
},
|
open (title, target) {
|
this.applyDataList = []
|
this.form.applyIdList = []
|
this.title = title
|
this.visible = true
|
this.activities = []
|
this.goods = []
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form.provinceId = ''
|
this.form[this.configData['field.id']] = null
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
this.loadSelectGoods()
|
})
|
},
|
loadSelectGoods () {
|
goodsList({
|
zhuanquId: this.form.id // 商品分类
|
}).then(res => {
|
this.applyDataList = res || []
|
this.applyDataList.forEach(t => {
|
this.form.applyIdList.push(t.id)
|
})
|
})
|
},
|
// 上传图片
|
uploadAvatarSuccess(file) {
|
this.form.imgurl = file.imgurl;
|
this.form.imgFullUrl = file.imgurlfull;
|
}
|
},
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import "@/assets/style/alertstyle.scss";
|
::v-deep .el-select {
|
width: 100%;
|
.el-input__inner {
|
width: 100%;
|
}
|
}
|
</style>
|