<template>
|
<GlobalAlertWindow
|
v-loading="isUploading"
|
:title="title"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<el-form :model="form" ref="form" :rules="rules" label-width="120px" label-suffix=":" inline>
|
<el-form-item label="所属品牌" prop="parentId" v-if="form.type === 15">
|
<el-select v-model="form.parentId" placeholder="请选择所属品牌" >
|
<el-option
|
v-for="item in labels()"
|
:key="item.id"
|
:value="item.id"
|
:label="item.name"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="名称" prop="name">
|
<el-input v-model="form.name" placeholder="请输入名称" :maxlength="5" v-trim/>
|
</el-form-item>
|
<el-form-item label="展示图" prop="imgurlfull">
|
<UploadAvatarImage
|
:file="{ 'imgurlfull': form.imgFullurl, 'imgurl': form.imgurl }"
|
:upload-data="{folder:'labels'}"
|
@uploadSuccess="uploadAvatarSuccess"
|
@uploadEnd="isUploading=false"
|
@uploadBegin="isUploading = true"
|
/>
|
</el-form-item>
|
<el-form-item label="排序码" prop="sortnum">
|
<el-input type="number" v-model="form.sortnum" placeholder="请输入排序码" v-trim/>
|
</el-form-item>
|
<el-form-item label="备注" prop="info">
|
<el-input type="textarea" v-model="form.info" placeholder="请输入备注" :maxlength="200" v-trim/>
|
</el-form-item>
|
</el-form>
|
</GlobalAlertWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalAlertWindow from '@/components/common/GlobalAlertWindow'
|
import UploadAvatarImage from '@/components/common/UploadAvatarImage'
|
export default {
|
name: 'OperaLabelsWindow',
|
extends: BaseOpera,
|
components: { GlobalAlertWindow, UploadAvatarImage },
|
data () {
|
return {
|
isUploading: false,
|
// 表单数据
|
form: {
|
id: null,
|
name: '',
|
info: '',
|
type: null,
|
status: '',
|
parentId: null,
|
sortnum: null,
|
imgFullurl: null,
|
imgurl: ''
|
},
|
// 验证规则
|
rules: {
|
parentId: [{ required: true, message: '请选择所属品牌' }],
|
name: [{ required: true, message: '请输入名称', tigger: 'blur' }]
|
}
|
}
|
},
|
inject: ['labels'],
|
created () {
|
this.config({
|
api: '/business/labels',
|
'field.id': 'id'
|
})
|
},
|
methods: {
|
open (title, target, type) {
|
this.title = title
|
this.visible = true
|
this.form.imgFullurl =null
|
this.form.imgurl =null
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form.provinceId = ''
|
this.form[this.configData['field.id']] = null
|
this.form.type = type
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
this.form.type = type
|
})
|
},
|
// 上传图片
|
uploadAvatarSuccess (file) {
|
this.form.imgurl = file.imgurl
|
this.form.imgFullurl = file.imgurlfull
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import "@/assets/style/alertstyle.scss";
|
$image-width: 100px;
|
|
::v-deep .el-select {
|
width: 100%;
|
.el-input__inner {
|
width: 100%;
|
}
|
}
|
.avatar-uploader {
|
width: $image-width;
|
height: $image-width;
|
}
|
::v-deep .el-upload {
|
border: 1px dashed #d9d9d9;
|
border-radius: 6px;
|
cursor: pointer;
|
position: relative;
|
width: $image-width;
|
height: $image-width;
|
overflow: hidden;
|
}
|
.avatar-uploader .el-upload:hover {
|
border-color: #409EFF;
|
}
|
.avatar-uploader-icon {
|
font-size: 28px;
|
color: #8c939d;
|
width: $image-width;
|
height: $image-width;
|
line-height: $image-width;
|
text-align: center;
|
}
|
.avatar {
|
width: $image-width;
|
height: $image-width;
|
display: block;
|
}
|
</style>
|