zs 2 lat temu
rodzic
commit
bc637d6e15
2 zmienionych plików z 118 dodań i 32 usunięć
  1. 117 31
      src/views/order/add.vue
  2. 1 1
      src/views/order/index.vue

+ 117 - 31
src/views/order/add.vue

@@ -5,15 +5,34 @@
         <el-col :span="24" class="one">
           <c-search :is_title="true" :is_back="true" @toBack="toBack"></c-search>
         </el-col>
-        <el-col :span="24" class="two">
-          <data-form :fields="fields" :form="form" :rules="{}" @save="toSave">
-            <template #type>
-              <el-option v-for="i in typeList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
-            </template>
-            <template #is_use>
-              <el-option v-for="i in is_useList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
-            </template>
-          </data-form>
+        <el-col :span="12" class="two">
+          <el-col :span="24" class="two_1"><i class="el-icon-s-shop"></i>{{ shopInfo.name }}</el-col>
+          <el-col :span="24" class="two_2">
+            <el-col :span="24" class="left">桌号:{{ form.table_num }}</el-col>
+            <el-col :span="24" class="right">人数:{{ form.num }}人</el-col>
+          </el-col>
+          <el-col :span="24" class="two_3" v-for="(item, index) in form.list" :key="index">
+            <el-col :span="8" class="img">
+              <el-image :src="item.file && item.file.length > 0 ? item.file[0].url : ''" fit="fill"></el-image>
+            </el-col>
+            <el-col :span="8" class="name">
+              <el-col :span="24" class="name_1">{{ item.name }} </el-col>
+              <el-col :span="24" class="name_2"> {{ item.spec }}</el-col>
+            </el-col>
+            <el-col :span="7" class="mtwoy">
+              <el-col :span="24" class="mtwoy_1">¥{{ item.price }} </el-col>
+              <el-col :span="24" class="mtwoy_2"> ×{{ item.num }}</el-col>
+            </el-col>
+          </el-col>
+          <el-col :span="24" class="two_4">
+            <el-col :span="12" class="left">餐位费:×{{ form.num }}</el-col>
+            <el-col :span="12" class="right">¥{{ form.money_num }}</el-col>
+          </el-col>
+          <el-col :span="24" class="two_5"> 合计:¥{{ form.money }} </el-col>
+          <el-col :span="24" class="two_6">
+            <el-col :span="12" class="left">下单时间:{{ form.time }}</el-col>
+            <el-col :span="12" class="right">类型:{{ form.type_name }}</el-col>
+          </el-col>
         </el-col>
       </el-col>
     </el-row>
@@ -24,23 +43,18 @@
 import { is_use, order_type } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('order');
+const { mapActions: shop } = createNamespacedHelpers('shop');
+const { mapActions: table } = createNamespacedHelpers('table');
 export default {
   name: 'add',
   props: {},
-  components: {},
+  comptwonts: {},
   data: function () {
     return {
-      fields: [
-        { label: '节目类型', model: 'type', type: 'select' },
-        { label: '名称', model: 'name' },
-        { label: '简介', model: 'brief', type: 'textarea' },
-        { label: '视频流', model: 'path' },
-        { label: '排序', model: 'sort', type: 'number' },
-        { label: '是否启用', model: 'is_use', type: 'select' },
-      ],
       form: {},
+      shopInfo: {},
       is_useList: is_use,
-      // 节目类型
+      // 订单类型
       typeList: order_type,
     };
   },
@@ -49,23 +63,27 @@ export default {
   },
   methods: {
     ...mapActions(['fetch', 'create', 'update']),
+    ...shop({ sFetch: 'fetch' }),
+    ...table({ tFetch: 'fetch' }),
     async search() {
       if (this.id) {
-        let res = await this.fetch(this.id);
+        let res;
+        res = await this.fetch(this.id);
         if (this.$checkRes(res)) {
-          this.$set(this, `form`, res.data);
+          let table = await this.tFetch(res.data.table);
+          if (this.$checkRes(table)) {
+            let data = this.typeList.find((r) => r.dict_value == res.data.type);
+            if (data) res.data.type_name = data.dict_label;
+            res.data.table_num = table.data.name;
+            this.$set(this, `form`, res.data);
+          }
+        }
+        res = await this.sFetch(this.user.shop);
+        if (this.$checkRes(res)) {
+          this.$set(this, `shopInfo`, res.data);
         }
       }
     },
-
-    // 保存信息
-    async toSave({ data }) {
-      let res;
-      if (data.id) res = await this.update(data);
-      else res = await this.create(data);
-      if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
-    },
-
     // 返回
     toBack() {
       window.history.go('-1');
@@ -90,4 +108,72 @@ export default {
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.main {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  .two {
+    padding: 1vw;
+    border: 1px solid #858585;
+    border-radius: 1vw;
+    .two_1 {
+      padding: 0.5vw 0;
+      font-size: 18px;
+      border-bottom: 1px solid #ccc;
+    }
+    .two_2 {
+      display: flex;
+      justify-content: space-between;
+      padding: 0.5vw 0;
+      font-size: 18px;
+      border-bottom: 1px solid #ccc;
+      .right {
+        text-align: right;
+      }
+    }
+    .two_3 {
+      padding: 0.5vw 0;
+      font-size: 18px;
+      border-bottom: 1px solid #ccc;
+      .name {
+        margin: 0 0 0 1vw;
+        .name_2 {
+          color: #858585;
+        }
+      }
+      .mtwoy {
+        text-align: right;
+        .mtwoy_1 {
+          color: red;
+        }
+      }
+    }
+    .two_4 {
+      padding: 0.5vw 0;
+      font-size: 18px;
+      border-bottom: 1px solid #ccc;
+      .right {
+        color: red;
+        font-size: 20px;
+        text-align: right;
+      }
+    }
+    .two_5 {
+      padding: 0.5vw 0;
+      font-size: 18px;
+      text-align: right;
+      color: red;
+      border-bottom: 1px solid #ccc;
+    }
+    .two_6 {
+      padding: 0.5vw 0;
+      font-size: 18px;
+      border-bottom: 1px solid #ccc;
+      .right {
+        text-align: right;
+      }
+    }
+  }
+}
+</style>

+ 1 - 1
src/views/order/index.vue

@@ -31,7 +31,7 @@ export default {
         { label: '序号', options: { type: 'index' } },
         { label: '订单号', model: '_id', isSearch: true },
         { label: '下单时间', model: 'time' },
-        { label: '下单桌号', model: 'code' },
+        { label: '下单桌号', model: 'table' },
         { label: '支付金额', model: 'money' },
         { label: '用餐人数', model: 'num' },
         {