215 lines
5.3 KiB
Vue
215 lines
5.3 KiB
Vue
<template>
|
|
<el-dialog title="修改场馆" :visible.sync="dialogVisible" @close="dialogFormVisible" :close-on-click-modal="false"
|
|
:close-on-press-escape="false">
|
|
<el-form size="small" :model="form" :rules="formRules" ref="form">
|
|
<el-form-item label="选择场馆" prop="ground_id" :label-width="formLabelWidth">
|
|
<el-select v-model="form.ground_id">
|
|
<el-option :value="item.id" :label="item.name" :key="item.id" v-for="item in veuneList"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="场地图" prop="img" :label-width="formLabelWidth">
|
|
<el-row>
|
|
<el-button type="primary" @click="openUpload">选择图片</el-button>
|
|
<div v-if="form.img != ''" class="img">
|
|
<img :src="file_path" width="100" height="100" />
|
|
</div>
|
|
</el-row>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="场地标题" prop="title" :label-width="formLabelWidth">
|
|
<el-input v-model="form.title" autocomplete="off" placeholder="场地标题"></el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="场地价格" prop="price" :label-width="formLabelWidth">
|
|
<el-input v-model="form.price" autocomplete="off" placeholder="请输入场地价格"></el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="灯光价格" prop="light_price" :label-width="formLabelWidth">
|
|
<el-input v-model="form.light_price" autocomplete="off" placeholder="请输入场馆价格"></el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="场地状态" prop="status" :label-width="formLabelWidth">
|
|
<el-select v-model="form.status">
|
|
<el-option :value="1" label="启用"></el-option>
|
|
<el-option :value="0" label="禁用"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button @click="dialogFormVisible">取 消</el-button>
|
|
<el-button type="primary" @click="addUser" :loading="loading">确 定</el-button>
|
|
</div>
|
|
<!--上传图片组件-->
|
|
<Upload v-if="isupload" :isupload="isupload" :type="type" @returnImgs="returnImgsFunc">上传图片</Upload>
|
|
</el-dialog>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import PorductApi from '@/api/product.js';
|
|
import Upload from '@/components/file/Upload';
|
|
import Uediter from '@/components/UE.vue';
|
|
import VenueApi from '@/api/venue.js';
|
|
|
|
export default {
|
|
components: {
|
|
Upload,
|
|
Uediter,
|
|
},
|
|
data() {
|
|
return {
|
|
/*富文本框配置*/
|
|
ueditor: {
|
|
text: '',
|
|
config: {
|
|
initialFrameWidth: 400,
|
|
initialFrameHeight: 500
|
|
},
|
|
},
|
|
form: {
|
|
ground_id: '',
|
|
img: '',
|
|
title: '',
|
|
price: '',
|
|
light_price: '',
|
|
status: '',
|
|
},
|
|
formRules: {
|
|
ground_id: [{
|
|
required: true,
|
|
message: '请选择场地',
|
|
trigger: 'blur'
|
|
}],
|
|
img: [{
|
|
required: true,
|
|
message: '请上传场地图片',
|
|
trigger: 'blur'
|
|
}],
|
|
title: [{
|
|
required: true,
|
|
message: '请输入场地标题',
|
|
trigger: 'blur'
|
|
}],
|
|
price: [{
|
|
required: true,
|
|
message: '请输入场地价格',
|
|
trigger: 'blur'
|
|
}],
|
|
light_price: [{
|
|
required: true,
|
|
message: '请输入灯光价格',
|
|
trigger: 'blur'
|
|
}],
|
|
status: [{
|
|
required: true,
|
|
message: '请选择场地状态',
|
|
trigger: 'blur'
|
|
}],
|
|
},
|
|
/*左边长度*/
|
|
formLabelWidth: '120px',
|
|
/*是否显示*/
|
|
dialogVisible: false,
|
|
loading: false,
|
|
/*是否上传图片*/
|
|
isupload: false,
|
|
veuneList: []
|
|
};
|
|
},
|
|
props: ['open_edit', 'editform'],
|
|
created() {
|
|
this.getVeuneList()
|
|
|
|
this.dialogVisible = this.open_edit;
|
|
console.log(this.editform.model);
|
|
this.form.id = this.editform.id;
|
|
this.form.ground_id = this.editform.ground_id;
|
|
this.form.img = this.editform.img_id;
|
|
this.form.title = this.editform.title;
|
|
this.form.price = this.editform.price;
|
|
this.form.light_price = this.editform.light_price;
|
|
this.form.status = this.editform.status;
|
|
console.log("🚀 ~ this.form:", this.form)
|
|
this.file_path = this.editform.img;
|
|
},
|
|
methods: {
|
|
// 获取场馆列表-不需要分页
|
|
getVeuneList() {
|
|
let self = this;
|
|
VenueApi.gdLists({}, true)
|
|
.then(res => {
|
|
// 确保为数组
|
|
self.veuneList = Array.isArray(res.data) ? res.data : [];
|
|
console.log("🚀 ~ self.veuneList:", self.veuneList)
|
|
})
|
|
.catch(error => {
|
|
self.loading = false;
|
|
});
|
|
},
|
|
|
|
/*添加场地*/
|
|
addUser() {
|
|
let self = this;
|
|
let params = self.form;
|
|
|
|
self.$refs.form.validate((valid) => {
|
|
if (valid) {
|
|
self.loading = true;
|
|
VenueApi.editGroundRoom(params).then(data => {
|
|
self.loading = false;
|
|
self.$message({
|
|
message: '添加成功',
|
|
type: 'success'
|
|
});
|
|
self.dialogFormVisible(true);
|
|
}).catch(error => {
|
|
self.loading = false;
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
/*获取富文本内容*/
|
|
contentChangeFunc(e){
|
|
this.form.textarea1 = e;
|
|
},
|
|
|
|
/*关闭弹窗*/
|
|
dialogFormVisible(e) {
|
|
if (e) {
|
|
this.$emit('closeDialog', {
|
|
type: 'success',
|
|
openDialog: false
|
|
})
|
|
} else {
|
|
this.$emit('closeDialog', {
|
|
type: 'error',
|
|
openDialog: false
|
|
})
|
|
}
|
|
},
|
|
/*上传*/
|
|
openUpload(e) {
|
|
this.type = e;
|
|
this.isupload = true;
|
|
},
|
|
/*获取图片*/
|
|
returnImgsFunc(e) {
|
|
if (e != null && e.length > 0) {
|
|
this.file_path = e[0].file_path;
|
|
this.form.img = e[0].file_id;
|
|
}
|
|
this.isupload = false;
|
|
},
|
|
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
.img {
|
|
margin-top: 10px;
|
|
}
|
|
</style>
|