<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="110px" label-suffix=":" inline>
|
<el-form-item label="店铺名称" prop="name">
|
<el-input v-model="form.name" placeholder="请输入店铺名称,20字以内" :maxlength="20" v-trim/>
|
</el-form-item>
|
<el-form-item label="店铺LOGO" prop="imgurl">
|
<UploadAvatarImage
|
:file="{ 'imgurlfull': form.imgurlfull, 'imgurl': form.imgurl }"
|
:uploadData="uploadData"
|
@uploadSuccess="uploadAvatarSuccess"
|
@uploadEnd="isUploading = false"
|
@uploadBegin="isUploading = true"
|
/>
|
</el-form-item>
|
<el-form-item label="店铺地址" prop="addr">
|
<el-input v-model="form.addr" placeholder="请输入地址" v-trim/>
|
</el-form-item>
|
<el-form-item label="店铺负责人" prop="memberId">
|
<el-select
|
v-model="form.memberId"
|
placeholder="请输入会员昵称/手机号,再选择"
|
filterable
|
remote
|
reserve-keyword
|
:remote-method="remoteMethod"
|
:loading="searchLoading"
|
>
|
<el-option
|
v-for="item in users"
|
:key="item.id"
|
:label="item.nickname"
|
:value="item.id">
|
</el-option>
|
</el-select>
|
</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'
|
import { findAll } from '@/api/business/member'
|
export default {
|
name: 'OperaShopWindow',
|
extends: BaseOpera,
|
components: { GlobalAlertWindow, UploadAvatarImage },
|
data () {
|
let memberRule = (rule, value, callBack) => {
|
if (!value) {
|
callBack(new Error())
|
} else {
|
callBack()
|
}
|
}
|
return {
|
isUploading: false,
|
searchLoading: false,
|
uploadData: {
|
folder: 'shop'
|
},
|
// 表单数据
|
form: {
|
id: null,
|
name: '',
|
imgurl: '',
|
imgurlfull: '',
|
addr: '',
|
memberId: ''
|
},
|
users: [],
|
// 验证规则
|
rules: {
|
name: [
|
{ required: true, message: '请输入店铺名称', tigger: 'blur' }
|
],
|
imgurl: [
|
{ required: true, message: '请上传店铺LOGO', tigger: 'change' }
|
],
|
memberId: [
|
{ required: true, validator: memberRule, message: '请选择关联用户', tigger: 'change' }
|
],
|
}
|
}
|
},
|
created () {
|
this.config({
|
api: '/business/shop',
|
'field.id': 'id'
|
})
|
},
|
methods: {
|
open (title, target) {
|
this.title = title
|
this.visible = true
|
// this.isEdit = false
|
this.form.imgurlfull = ''
|
this.form.imgurl = ''
|
// 新建
|
if (target == null) {
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.form[this.configData['field.id']] = null
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
this.isEdit = true
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
this.form.imgurlfull = target.imgFullUrl + target.imgurl
|
this.remoteMethod(target.nikeName)
|
})
|
},
|
uploadAvatarSuccess(file) {
|
this.form.imgurl = file.imgurl
|
this.form.imgurlfull = file.imgurlfull
|
},
|
remoteMethod(query) {
|
if (query !== '') {
|
this.searchLoading = true
|
findAll({
|
model: {
|
nickname: query,
|
status: 0
|
}
|
})
|
.then(res => {
|
this.users = res
|
})
|
.finally(() => {
|
this.searchLoading = false
|
})
|
}
|
}
|
},
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import "@/assets/style/alertstyle.scss";
|
::v-deep .el-select {
|
width: 100%;
|
.el-input__inner {
|
width: 100%;
|
}
|
}
|
</style>
|