Bläddra i källkod

管理后台-座位管理

panyong 3 år sedan
förälder
incheckning
3292991ee6

+ 3 - 1
htmldev/manage/README.md

@@ -204,4 +204,6 @@ sudo yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.
 npm run build
 ## or
 yarn build
-```
+```
+
+### todo 按钮加锁,防止重复点击

+ 24 - 0
htmldev/manage/src/utils/index.js

@@ -115,3 +115,27 @@ export function param2Obj (url) {
   })
   return obj
 }
+
+export function fen2Yuan (num) {
+  return isNaN(num) ? '' : num * 0.01
+}
+
+export function yuan2Fen (num) {
+  if (isNaN(num)) {
+    return ''
+  }
+  const amount = num.toString()
+  const index = amount.indexOf('.')
+  const arr = amount.split('.')
+  let result = arr[0] * 100
+  if (index > -1) {
+    result += arr[1].split('').reduce((total, cur, index) => {
+      if (index === 0) {
+        return total + cur * 10
+      } else {
+        return total + cur * 1
+      }
+    }, 0)
+  }
+  return result
+}

+ 56 - 64
htmldev/manage/src/views/business/place/list/details.vue

@@ -9,91 +9,77 @@
                :model="form"
                :rules="formRules"
                label-width="160px">
-        <el-form-item prop="bar_name"
+        <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"
-                      :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"
+        <el-form-item prop="place_user_max"
                       :rules="formRules.InterNum"
                       label="单桌人数:">
           <el-col :span="16">
-            <el-input v-model="form.b"
+            <el-input v-model="form.place_user_max"
                       placeholder="请输入人数"
-                      @input="form.b=form.b.replace(/[^\d]/g, '').replace(/^0*/, '')"
+                      @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="c"
+        <el-form-item prop="place_price"
                       :rules="formRules.numPot2"
-                      label="单价:">
+                      label="单价(元):">
           <el-col :span="16">
-            <el-input v-model="form.c"
+            <el-input v-model="form.place_price"
                       placeholder="请输入单价"
-                      @input="form.c=form.c.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"
+                      @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="bar_song_start_time"
+        <el-form-item prop="place_latest_time"
                       :rules="formRules.required"
                       label="最晚到店时间:">
           <el-time-select placeholder="请选择最晚到店时间"
-                          v-model="form.bar_song_start_time"
+                          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="bar_song_end_time"
-                      :rules="formRules.required"
+        <el-form-item prop="place_max_time"
+                      :rules="formRules.checkInterNum"
                       label="最晚保留时间(分钟):">
           <el-col :span="16">
-            <el-input v-model="form.b"
+            <el-input v-model="form.place_max_time"
                       placeholder="请输入分钟数"
-                      @input="form.b=form.b.replace(/[^\d]/g, '').replace(/^0*/, '')"
+                      @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 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="桌号设置" required></el-form-item>
-        <el-form-item v-for="(domain, index) in form.domains"
+        <el-form-item v-for="(desk, index) in form.place_number"
                       :label="(index + 1) + '桌'"
-                      :key="domain.key"
-                      :prop="'domains.' + index + '.value'"
-                      :rules="{required: true, message: '桌号不能为空', trigger: 'blur'}">
+                      :key="index"
+                      :prop="'place_number.' + index + '.value'"
+                      :rules="formRules.required">
           <el-col :span="16">
-            <el-input v-model="domain.value" placeholder="请设置桌号"></el-input>
+            <el-input v-model="desk.value" placeholder="请设置桌号"></el-input>
           </el-col>
           <el-col :span="7" :offset="1">
-            <el-button type="warning" size="small" @click.prevent="removeDomain(domain)">删除</el-button>
+            <el-button type="warning"
+                       @click.prevent="removeDeskNum(desk)">删除
+            </el-button>
           </el-col>
         </el-form-item>
       </el-form>
@@ -107,6 +93,8 @@
 </template>
 
 <script>
+import { fen2Yuan, yuan2Fen } from '@/utils'
+
 export default {
   components: {},
   props: {
@@ -125,40 +113,44 @@ export default {
     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: ''
-        }]
+        place_name: '', // 座位名称
+        place_desc: '', // 座位描述
+        place_user_max: '', // 最多到店人数
+        place_price: '', // 座位价格(单位为分)
+        place_latest_time: '', // 最晚到店时间
+        place_max_time: '', // 最晚保留时间
+        // 座位编号(数组)
+        place_number: [
+          {
+            value: ''
+          }
+        ]
       }
     }
   },
   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/template/modify' : '/v1/bar/place/template/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('提交成功')
@@ -175,9 +167,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)
           }

+ 24 - 16
htmldev/manage/src/views/business/place/list/index.vue

@@ -21,16 +21,19 @@
               border
               :max-height="vheight">
       <el-table-column label="ID" prop="id"></el-table-column>
-      <el-table-column label="座位名称" prop="department_name"></el-table-column>
-      <el-table-column label="座位说明" prop="department_desc"></el-table-column>
-      <el-table-column label="座位数量" prop="department_project_name"></el-table-column>
-      <el-table-column label="单桌人数" prop="department_project_name"></el-table-column>
-      <el-table-column label="单价" prop="department_project_name"></el-table-column>
-      <el-table-column label="最晚到店时间" prop="department_desc"></el-table-column>
-      <el-table-column label="最晚保留时间(分钟)" prop="department_project_name"></el-table-column>
-      <el-table-column label="添加时间" prop="department_project_name"></el-table-column>
-      <el-table-column label="备注" prop="department_desc"></el-table-column>
-      <el-table-column label="操作" width="200">
+      <el-table-column label="座位名称" prop="place_name"></el-table-column>
+      <el-table-column label="座位说明" prop="place_desc"></el-table-column>
+      <el-table-column label="座位数量" prop="place_num"></el-table-column>
+      <el-table-column label="单桌人数" prop="place_user_max"></el-table-column>
+      <el-table-column label="单价(元)">
+        <template slot-scope="scope">
+          <p>{{ scope.row.place_price | fen2Yuan }}</p>
+        </template>
+      </el-table-column>
+      <el-table-column label="最晚到店时间" prop="place_latest_time"></el-table-column>
+      <el-table-column label="最晚保留时间(分钟)" prop="place_max_time"></el-table-column>
+      <el-table-column label="添加时间" prop="created_at"></el-table-column>
+      <el-table-column label="操作" width="220">
         <template slot-scope="scope">
           <el-button type="text"
                      @click="edit(scope.row)">编辑
@@ -38,11 +41,14 @@
           <!--todo 图片单张下载还是ZIP包-->
           <el-dropdown class="el-dropdown"
                        @command="handleCommand">
-            <span class="el-dropdown-link">下载点单二维码<i class="el-icon-arrow-down el-icon--right"></i></span>
+            <span class="el-dropdown-link">下载二维码<i class="el-icon-arrow-down el-icon--right"></i></span>
             <el-dropdown-menu slot="dropdown">
               <el-dropdown-item command="111">黄金糕</el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown>
+          <el-button type="text"
+                     @click="del(scope.row)">删除
+          </el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -57,7 +63,9 @@
       background
       layout="total, sizes, prev, pager, next, jumper"
       :total="totalCount"/>
-    <detail v-if="detailsDialog.show" v-model="detailsDialog.show" :exData="detailsDialog.exData"
+    <detail v-if="detailsDialog.show"
+            v-model="detailsDialog.show"
+            :exData="detailsDialog.exData"
             @success="init"></detail>
   </div>
 </template>
@@ -80,7 +88,7 @@ export default {
       time: [],
       searchForm: {},
       tableData: [],
-      tableUrl: '/department/list'
+      tableUrl: '/v1/bar/place/template/list'
     }
   },
   methods: {
@@ -101,8 +109,8 @@ export default {
         cancelButtonText: '取消',
         type: 'warning'
       }).then(async () => {
-        const data = await this.$fetch('/api/auth/department/del', { id: row.id })
-        if (data.code == 200) {
+        const data = await this.$fetch('/v1/bar/place/template/delete', { id: row.id }, 'get')
+        if (data.code === 200) {
           this.$message.success('删除成功')
           this.init()
         }
@@ -117,7 +125,7 @@ export default {
 
 <style lang="scss" scoped>
 .el-dropdown {
-  margin-left: 10px;
+  margin: 0 10px;
 
   .el-dropdown-link {
     cursor: pointer;