|
@@ -1,19 +1,50 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <el-dialog :title="exData.id ? '编辑': '新增'" :visible.sync="dialog" width="450px" :close-on-click-modal="false"
|
|
|
+ <el-dialog :title="exData.id ? '编辑': '新增'"
|
|
|
+ :visible.sync="dialog"
|
|
|
+ width="50%"
|
|
|
+ :close-on-click-modal="false"
|
|
|
top="50px">
|
|
|
- <el-form ref="form" :model="form" label-width="100px" class="bind-phone">
|
|
|
- <el-form-item v-if="!exData.id" label="项目选择:">
|
|
|
- <el-select v-model="form.department_project_id">
|
|
|
- <el-option v-for="(item, index) in projectArr" :key="index" :label="item.project_name"
|
|
|
- :value="item.id"></el-option>
|
|
|
- </el-select>
|
|
|
+ <el-form ref="form"
|
|
|
+ :model="form"
|
|
|
+ :rules="formRules"
|
|
|
+ label-width="160px">
|
|
|
+ <el-form-item prop="bar_name"
|
|
|
+ :rules="formRules.required"
|
|
|
+ label="座位名称:">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-input v-model="form.bar_name"
|
|
|
+ placeholder="请输入座位名称"
|
|
|
+ clearable></el-input>
|
|
|
+ </el-col>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="部门名称:">
|
|
|
- <el-input v-model="form.department_name" placeholder="请输入部门名称"></el-input>
|
|
|
+ <el-form-item label="说明:">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-input type="textarea"
|
|
|
+ :rows="4"
|
|
|
+ placeholder="请输入座位说明"
|
|
|
+ v-model="form.note">
|
|
|
+ </el-input>
|
|
|
+ </el-col>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="部门描述:">
|
|
|
- <el-input v-model="form.department_desc" placeholder="请输入部门描述"></el-input>
|
|
|
+ <el-form-item prop="a"
|
|
|
+ :rules="formRules.InterNum"
|
|
|
+ label="已预定:">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-input v-model="form.a"
|
|
|
+ placeholder="请输入座位数量"
|
|
|
+ clearable></el-input>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="b"
|
|
|
+ :rules="formRules.InterNum"
|
|
|
+ label="开放预定数量:">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-input v-model="form.b"
|
|
|
+ placeholder="请输入人数"
|
|
|
+ @input="form.b=form.b.replace(/[^\d]/g, '').replace(/^0*/, '')"
|
|
|
+ clearable></el-input>
|
|
|
+ </el-col>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer text-center">
|
|
@@ -25,9 +56,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { mapGetters } from 'vuex'
|
|
|
-
|
|
|
export default {
|
|
|
+ components: {},
|
|
|
props: {
|
|
|
value: {
|
|
|
type: Boolean,
|
|
@@ -40,40 +70,68 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- computed: {
|
|
|
- ...mapGetters([
|
|
|
- 'projectArr'
|
|
|
- ])
|
|
|
- },
|
|
|
data () {
|
|
|
return {
|
|
|
dialog: !!this.value,
|
|
|
form: {
|
|
|
- department_project_id: undefined,
|
|
|
- department_name: '',
|
|
|
- department_desc: ''
|
|
|
+ bar_name: '', // 门店名称
|
|
|
+ bar_address: '', // 门店地址
|
|
|
+ bar_status: '1', // 门店状态(0无效1有效)
|
|
|
+ bar_img_url: [], // 门店图片
|
|
|
+ bar_song_start_time: '', // 点歌开始时间
|
|
|
+ bar_song_end_time: '', // 点歌结束时间
|
|
|
+ bar_place_reserve_start_time: '', // 座位预定开始时间
|
|
|
+ bar_place_reserve_end_time: '', // 座位预定结束时间
|
|
|
+ note: '', // 备注
|
|
|
+ domains: [{
|
|
|
+ value: ''
|
|
|
+ }]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- async handleSubmit () {
|
|
|
- let url = this.exData.id ? '/department/edit' : '/department/add'
|
|
|
- const data = await this.$fetch('/api/auth' + url, { ...this.form })
|
|
|
- if (data.code === 200) {
|
|
|
- this.$message.success('提交成功')
|
|
|
- this.$emit('success')
|
|
|
- this.dialog = false
|
|
|
+ removeDomain (item) {
|
|
|
+ var index = this.form.domains.indexOf(item)
|
|
|
+ if (index !== -1) {
|
|
|
+ this.form.domains.splice(index, 1)
|
|
|
}
|
|
|
+ },
|
|
|
+ addDomain () {
|
|
|
+ this.form.domains.push({
|
|
|
+ value: '',
|
|
|
+ key: Date.now()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleSubmit () {
|
|
|
+ const url = this.exData.id ? '/v1/bar/modify' : '/v1/bar/add'
|
|
|
+ this.$refs.form.validate(async valid => {
|
|
|
+ if (valid) {
|
|
|
+ const data = await this.$fetch(url, {
|
|
|
+ ...this.form
|
|
|
+ })
|
|
|
+ if (data.code === 200) {
|
|
|
+ this.$message.success('提交成功')
|
|
|
+ this.$emit('success')
|
|
|
+ this.dialog = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
- if (this.projectArr.length == 0) {
|
|
|
- this.$store.dispatch('common/setProjectArr')
|
|
|
- }
|
|
|
if (this.exData.id) {
|
|
|
- this.form.id = this.exData.id
|
|
|
- this.form.department_name = this.exData.department_name
|
|
|
- this.form.department_desc = this.exData.department_desc
|
|
|
+ this.$set(this.form, 'id', this.exData.id)
|
|
|
+ for (const key in this.exData) {
|
|
|
+ if (this.form.hasOwnProperty(key)) {
|
|
|
+ let value = this.exData[key]
|
|
|
+ if ((Array.isArray(value) && value.length > 0) || value) {
|
|
|
+ if (key === 'bar_status') {
|
|
|
+ value = value.toString()
|
|
|
+ }
|
|
|
+ this.$set(this.form, key, value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
watch: {
|