<template>
|
<GlobalAlertWindow :title="title" :visible.sync="visible" :confirm-working="isWorking" width="600px" @confirm="confirm">
|
<el-form :model="form" ref="form" label-width="150px" label-suffix=":" :rules="rules">
|
<el-form-item label="品牌名称" prop="name">
|
<el-input v-model="form.name" maxlength="20" placeholder="请输入,不超过20个字符" v-trim />
|
</el-form-item>
|
<el-form-item label="品牌图标" prop="imgurl">
|
<UploadAvatarImage
|
:file="{ 'imgurlfull': form.imgfullurl, 'imgurl': form.imgurl }"
|
:uploadData="uploadData"
|
tipsLabel=""
|
@uploadSuccess="uploadReverseSuccess"
|
@uploadEnd="end"
|
@uploadBegin="begin"
|
/>
|
只能上传图片格式,png格式,建议尺寸200px*200px
|
</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>
|
</GlobalAlertWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import UploadAvatarImage from '../common/UploadAvatarImage.vue'
|
import GlobalAlertWindow from '@/components/common/GlobalAlertWindow'
|
export default {
|
name: 'OperaBrandWindow',
|
extends: BaseOpera,
|
components: { GlobalAlertWindow, UploadAvatarImage },
|
data() {
|
return {
|
action: process.env.VUE_APP_API_PREFIX + '/public/uploadLocal',
|
// 表单数据
|
form: {
|
id: null,
|
name: '',
|
sortnum: '',
|
imgurl: '',
|
imgfullurl: '',
|
type: 1
|
},
|
uploadData: {
|
folder: 'brand_img',
|
type: 'image'
|
},
|
// 验证规则
|
rules: {
|
name: [
|
{ required: true, message: '不能为空', trigger: 'blur' }
|
]
|
}
|
}
|
},
|
created() {
|
this.config({
|
api: '/business/brand',
|
'field.id': 'id'
|
})
|
},
|
methods: {
|
open (title, target) {
|
this.title = title
|
this.visible = true
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form.imgfullurl = ''
|
this.form[this.configData['field.id']] = null
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
})
|
},
|
begin() {
|
this.isUploading=true
|
},
|
end() {
|
this.isUploading=false
|
},
|
// 上传图片
|
uploadReverseSuccess(file) {
|
this.form.imgurl = file.imgurl;
|
this.form.imgfullurl = file.imgurlfull;
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
</style>
|
|