|
@@ -9,46 +9,111 @@
|
|
|
:model="form"
|
|
|
:rules="formRules"
|
|
|
label-width="160px">
|
|
|
- <el-form-item prop="bar_name"
|
|
|
+ <el-form-item prop="place_time"
|
|
|
+ :rules="formRules.time"
|
|
|
+ label="开放预定日期:">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="form.place_time"
|
|
|
+ align="right"
|
|
|
+ type="date"
|
|
|
+ placeholder="选择日期"
|
|
|
+ :picker-options="pickerOptions"
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ :readonly="form.id">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="place_name"
|
|
|
:rules="formRules.required"
|
|
|
label="座位名称:">
|
|
|
<el-col :span="16">
|
|
|
- <el-input v-model="form.bar_name"
|
|
|
+ <el-input v-model="form.place_name"
|
|
|
placeholder="请输入座位名称"
|
|
|
clearable></el-input>
|
|
|
</el-col>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="说明:">
|
|
|
+ <el-form-item prop="place_desc"
|
|
|
+ :rules="formRules.required"
|
|
|
+ label="说明:">
|
|
|
<el-col :span="16">
|
|
|
<el-input type="textarea"
|
|
|
:rows="4"
|
|
|
placeholder="请输入座位说明"
|
|
|
- v-model="form.note">
|
|
|
+ v-model="form.place_desc">
|
|
|
</el-input>
|
|
|
</el-col>
|
|
|
</el-form-item>
|
|
|
- <el-form-item prop="a"
|
|
|
+ <el-form-item prop="place_user_max"
|
|
|
:rules="formRules.InterNum"
|
|
|
- label="已预定:">
|
|
|
+ label="单桌人数:">
|
|
|
<el-col :span="16">
|
|
|
- <el-input v-model="form.a"
|
|
|
- placeholder="请输入座位数量"
|
|
|
+ <el-input v-model="form.place_user_max"
|
|
|
+ placeholder="请输入人数"
|
|
|
+ @input="form.place_user_max=form.place_user_max.replace(/[^\d]/g, '').replace(/^0*/, '')"
|
|
|
clearable></el-input>
|
|
|
</el-col>
|
|
|
</el-form-item>
|
|
|
- <el-form-item prop="b"
|
|
|
- :rules="formRules.InterNum"
|
|
|
- label="开放预定数量:">
|
|
|
+ <el-form-item prop="place_price"
|
|
|
+ :rules="formRules.numPot2"
|
|
|
+ label="单价(元):">
|
|
|
<el-col :span="16">
|
|
|
- <el-input v-model="form.b"
|
|
|
- placeholder="请输入人数"
|
|
|
- @input="form.b=form.b.replace(/[^\d]/g, '').replace(/^0*/, '')"
|
|
|
+ <el-input v-model="form.place_price"
|
|
|
+ placeholder="请输入单价"
|
|
|
+ @input="form.place_price=form.place_price.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"
|
|
|
+ clearable></el-input>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="place_latest_time"
|
|
|
+ :rules="formRules.required"
|
|
|
+ label="最晚到店时间:">
|
|
|
+ <el-time-select placeholder="请选择最晚到店时间"
|
|
|
+ v-model="form.place_latest_time"
|
|
|
+ :picker-options="{start: '00:00', step: '00:05', end: '23:59'}">
|
|
|
+ </el-time-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="place_max_time"
|
|
|
+ :rules="formRules.checkInterNum"
|
|
|
+ label="最晚保留时间(分钟):">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-input v-model="form.place_max_time"
|
|
|
+ placeholder="请输入分钟数"
|
|
|
+ @input="form.place_max_time=form.place_max_time.replace(/[^\d]/g, '').replace(/^0*/, '')"
|
|
|
+ clearable></el-input>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="place_name"
|
|
|
+ :rules="formRules.required"
|
|
|
+ label="已预定:"
|
|
|
+ v-if="form.id">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-input v-model="form.place_name"
|
|
|
+ readonly
|
|
|
+ placeholder=""
|
|
|
clearable></el-input>
|
|
|
</el-col>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item :label="!form.id ? '桌号设置:' : '开放预定数量:'" required></el-form-item>
|
|
|
+ <el-form-item v-for="(desk, index) in form.place_number"
|
|
|
+ :label="(index + 1) + '桌'"
|
|
|
+ :key="index"
|
|
|
+ :prop="'place_number.' + index + '.value'"
|
|
|
+ :rules="formRules.required">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-input v-model="desk.value"
|
|
|
+ :readonly="form.id"
|
|
|
+ placeholder="请设置桌号"></el-input>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="7" :offset="1">
|
|
|
+ <el-button type="warning"
|
|
|
+ @click.prevent="removeDeskNum(desk)">删除
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer text-center">
|
|
|
<el-button @click="dialog = false">取 消</el-button>
|
|
|
+ <el-button @click.prevent="addDomain">新增桌号</el-button>
|
|
|
<el-button type="primary" @click="handleSubmit">确 定</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
@@ -56,6 +121,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { fen2Yuan, yuan2Fen } from '@/utils'
|
|
|
+
|
|
|
export default {
|
|
|
components: {},
|
|
|
props: {
|
|
@@ -73,41 +140,71 @@ export default {
|
|
|
data () {
|
|
|
return {
|
|
|
dialog: !!this.value,
|
|
|
- form: {
|
|
|
- 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: ''
|
|
|
+ pickerOptions: {
|
|
|
+ disabledDate (time) {
|
|
|
+ return time.getTime() < Date.now() - 8.64e7
|
|
|
+ },
|
|
|
+ shortcuts: [{
|
|
|
+ text: '今天',
|
|
|
+ onClick (picker) {
|
|
|
+ picker.$emit('pick', new Date())
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ text: '昨天',
|
|
|
+ onClick (picker) {
|
|
|
+ const date = new Date()
|
|
|
+ date.setTime(date.getTime() - 3600 * 1000 * 24)
|
|
|
+ picker.$emit('pick', date)
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ text: '一周前',
|
|
|
+ onClick (picker) {
|
|
|
+ const date = new Date()
|
|
|
+ date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
|
|
|
+ picker.$emit('pick', date)
|
|
|
+ }
|
|
|
}]
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ place_time: '2021-05-23', // 年月日
|
|
|
+ place_name: '10人卡座', // 座位名称
|
|
|
+ place_desc: '卡座台费3200元', // 座位描述
|
|
|
+ place_user_max: '10', // 最多到店人数
|
|
|
+ place_price: '1000', // 座位价格(单位为分)
|
|
|
+ place_latest_time: '2021-05-23 21:15:00', // 最晚到店时间
|
|
|
+ place_max_time: '30', // 最晚保留时间
|
|
|
+ // 座位编号(数组)
|
|
|
+ place_number: [
|
|
|
+ {
|
|
|
+ value: 'AF0004'
|
|
|
+ }
|
|
|
+ ]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- removeDomain (item) {
|
|
|
- var index = this.form.domains.indexOf(item)
|
|
|
+ removeDeskNum (item) {
|
|
|
+ var index = this.form.place_number.indexOf(item)
|
|
|
+ if (this.form.place_number.length <= 1) {
|
|
|
+ this.$message.warning('桌数不能小于1')
|
|
|
+ return
|
|
|
+ }
|
|
|
if (index !== -1) {
|
|
|
- this.form.domains.splice(index, 1)
|
|
|
+ this.form.place_number.splice(index, 1)
|
|
|
}
|
|
|
},
|
|
|
addDomain () {
|
|
|
- this.form.domains.push({
|
|
|
- value: '',
|
|
|
- key: Date.now()
|
|
|
+ this.form.place_number.push({
|
|
|
+ value: ''
|
|
|
})
|
|
|
},
|
|
|
handleSubmit () {
|
|
|
- const url = this.exData.id ? '/v1/bar/modify' : '/v1/bar/add'
|
|
|
+ const url = this.exData.id ? '/v1/bar/place/modify' : '/v1/bar/place/add'
|
|
|
this.$refs.form.validate(async valid => {
|
|
|
if (valid) {
|
|
|
const data = await this.$fetch(url, {
|
|
|
- ...this.form
|
|
|
+ ...this.form,
|
|
|
+ place_price: yuan2Fen(this.form.place_price)
|
|
|
})
|
|
|
if (data.code === 200) {
|
|
|
this.$message.success('提交成功')
|
|
@@ -124,9 +221,9 @@ export default {
|
|
|
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()
|
|
|
+ if ((Array.isArray(value) && value.length > 0) || value === 0 || value) {
|
|
|
+ if (key === 'place_price') {
|
|
|
+ value = fen2Yuan(value)
|
|
|
}
|
|
|
this.$set(this.form, key, value)
|
|
|
}
|