Browse Source

feat ui 新增了菜单管理和订单管理

GaoRunQi 5 months ago
parent
commit
77f69b9295

+ 53 - 0
yudao-ui-admin-vue2/src/api/restaurant/goods/index.js

@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+
+// 创建商品
+export function createGoods(data) {
+  return request({
+    url: '/restaurant/goods/create',
+    method: 'post',
+    data: data
+  })
+}
+
+// 更新商品
+export function updateGoods(data) {
+  return request({
+    url: '/restaurant/goods/update',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除商品
+export function deleteGoods(id) {
+  return request({
+    url: '/restaurant/goods/delete?id=' + id,
+    method: 'delete'
+  })
+}
+
+// 获得商品
+export function getGoods(id) {
+  return request({
+    url: '/restaurant/goods/get?id=' + id,
+    method: 'get'
+  })
+}
+
+// 获得商品分页
+export function getGoodsPage(params) {
+  return request({
+    url: '/restaurant/goods/page',
+    method: 'get',
+    params
+  })
+}
+// 导出商品 Excel
+export function exportGoodsExcel(params) {
+  return request({
+    url: '/restaurant/goods/export-excel',
+    method: 'get',
+    params,
+    responseType: 'blob'
+  })
+}

+ 27 - 0
yudao-ui-admin-vue2/src/api/restaurant/order/index.js

@@ -0,0 +1,27 @@
+import request from '@/utils/request'
+
+// 更新订单状态
+export function updateOrder(data) {
+  return request({
+    url: '/restaurant/order/update',
+    method: 'put',
+    data: data
+  })
+}
+
+// 获得订单分页
+export function pageOrder(params) {
+  return request({
+    url: '/restaurant/order/page',
+    method: 'get',
+    params
+  })
+}
+// 获得商品
+export function getOrder(id) {
+  return request({
+    url: '/restaurant/order/get?id=' + id,
+    method: 'get'
+  })
+}
+

+ 53 - 63
yudao-ui-admin-vue2/src/api/restaurant/type/index.js

@@ -1,63 +1,53 @@
-import request from '@/utils/request'
-
-// 创建商品分类
-export function createType(data) {
-  return request({
-    url: '/restaurant/type/create',
-    method: 'post',
-    data: data
-  })
-}
-
-// 更新商品分类
-export function updateType(data) {
-  return request({
-    url: '/restaurant/type/update',
-    method: 'put',
-    data: data
-  })
-}
-
-// 删除商品分类
-export function deleteType(id) {
-  return request({
-    url: '/restaurant/type/delete?id=' + id,
-    method: 'delete'
-  })
-}
-
-// 获得商品分类
-export function getType(id) {
-  return request({
-    url: '/restaurant/type/get?id=' + id,
-    method: 'get'
-  })
-}
-
-// 获得商品分类分页
-export function getTypePage(params) {
-  return request({
-    url: '/restaurant/type/page',
-    method: 'get',
-    params
-  })
-}
-// 导出商品分类 Excel
-export function exportTypeExcel(params) {
-  return request({
-    url: '/restaurant/type/export-excel',
-    method: 'get',
-    params,
-    responseType: 'blob'
-  })
-}
-
-// ==================== 子表(商品) ====================
-      // 获得商品
-    export function getByGoodsTypeId(goodsTypeId) {
-      return request({
-        url: '/restaurant/type/goods/list-by-goods-type-id?goodsTypeId=' + goodsTypeId,
-        method: 'get'
-      })
-    }
-  
+import request from '@/utils/request'
+
+// 创建商品分类
+export function createType(data) {
+  return request({
+    url: '/restaurant/type/create',
+    method: 'post',
+    data: data
+  })
+}
+
+// 更新商品分类
+export function updateType(data) {
+  return request({
+    url: '/restaurant/type/update',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除商品分类
+export function deleteType(id) {
+  return request({
+    url: '/restaurant/type/delete?id=' + id,
+    method: 'delete'
+  })
+}
+
+// 获得商品分类
+export function getType(id) {
+  return request({
+    url: '/restaurant/type/get?id=' + id,
+    method: 'get'
+  })
+}
+
+// 获得商品分类分页
+export function getTypePage(params) {
+  return request({
+    url: '/restaurant/type/page',
+    method: 'get',
+    params
+  })
+}
+// 导出商品分类 Excel
+export function exportTypeExcel(params) {
+  return request({
+    url: '/restaurant/type/export-excel',
+    method: 'get',
+    params,
+    responseType: 'blob'
+  })
+}

+ 29 - 9
yudao-ui-admin-vue2/src/views/restaurant/goods/GoodsForm.vue

@@ -3,17 +3,19 @@
     <!-- 对话框(添加 / 修改) -->
     <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
       <el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
-                    <el-form-item label="商品分类" prop="goodsTypeId">
-                      <el-input v-model="formData.goodsTypeId" placeholder="请输入商品分类" />
-                    </el-form-item>
                     <el-form-item label="商品名称" prop="goodsName">
                       <el-input v-model="formData.goodsName" placeholder="请输入商品名称" />
                     </el-form-item>
+                    <el-form-item label="商品分类" prop="goodsTypeId">
+                      <el-select v-model="formData.goodsTypeId" placeholder="请选择商品分类">
+                        <el-option v-for="item in typeArray" :key="item.id" :label="item.goodsTypeName" :value="item.id" />
+                      </el-select>
+                    </el-form-item>
                     <el-form-item label="商品价格" prop="goodsPrice">
-                      <el-input v-model="formData.goodsPrice" placeholder="请输入商品价格" />
+                      <el-input-number v-model="formData.goodsPrice" placeholder="请输入商品价格" />
                     </el-form-item>
                     <el-form-item label="商品图标">
-                      <ImageUpload v-model="formData.goodsIcon"/>
+                      <ImageUpload v-model="formData.goodsIcon" :limit="1"/>
                     </el-form-item>
       </el-form>
               <div slot="footer" class="dialog-footer">
@@ -25,8 +27,9 @@
 </template>
 
 <script>
-  import * as GoodsApi from '@/api/restaurant/restaurant';
+  import * as GoodsApi from '@/api/restaurant/goods';
   import ImageUpload from '@/components/ImageUpload';
+  import * as TypeApi from '@/api/restaurant/type';
       export default {
     name: "GoodsForm",
     components: {
@@ -42,7 +45,6 @@
         formLoading: false,
         // 表单参数
         formData: {
-                            goodsTypeId: undefined,
                             goodsName: undefined,
                             goodsPrice: undefined,
                             goodsIcon: undefined,
@@ -50,6 +52,13 @@
         // 表单校验
         formRules: {
         },
+        typeArray:[],
+        queryParams: {
+        pageNo: 1,
+        pageSize: 10,
+        goodsTypeName: null,
+        createTime: [],
+      },
                         };
     },
     methods: {
@@ -57,6 +66,7 @@
      async open(id) {
         this.dialogVisible = true;
         this.reset();
+        this.getType();
         // 修改时,设置数据
         if (id) {
           this.formLoading = true;
@@ -69,8 +79,18 @@
           }
         }
         this.title = "新增商品";
+        
               },
-      /** 提交按钮 */
+      async getType(){
+        try {
+        const res = await TypeApi.getTypePage(this.queryParams);
+        this.typeArray = res.data.list;
+        } finally {
+          
+        }
+        
+      }, 
+       /** 提交按钮 */
       async submitForm() {
         // 校验主表
         await this.$refs["formRef"].validate();
@@ -97,10 +117,10 @@
                       /** 表单重置 */
       reset() {
         this.formData = {
-                            goodsTypeId: undefined,
                             goodsName: undefined,
                             goodsPrice: undefined,
                             goodsIcon: undefined,
+                            goodsTypeId: undefined,
         };
         this.resetForm("formRef");
       }

+ 36 - 17
yudao-ui-admin-vue2/src/views/restaurant/goods/index.vue

@@ -2,18 +2,21 @@
   <div class="app-container">
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
-      <el-form-item label="商品分类" prop="goodsTypeId">
-        <el-input v-model="queryParams.goodsTypeId" placeholder="请输入商品分类" clearable @keyup.enter.native="handleQuery"/>
-      </el-form-item>
       <el-form-item label="商品名称" prop="goodsName">
         <el-input v-model="queryParams.goodsName" placeholder="请输入商品名称" clearable @keyup.enter.native="handleQuery"/>
       </el-form-item>
-      <el-form-item label="商品价格" prop="goodsPrice">
+      <!-- <el-form-item label="商品价格" prop="goodsPrice">
         <el-input v-model="queryParams.goodsPrice" placeholder="请输入商品价格" clearable @keyup.enter.native="handleQuery"/>
-      </el-form-item>
-      <el-form-item label="创建时间" prop="createTime">
+      </el-form-item> -->
+      <!-- <el-form-item label="创建时间" prop="createTime">
         <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
                         range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
+      </el-form-item> -->
+      <el-form-item label="商品分类" prop="goodsTypeId">
+        <!-- <el-input v-model="queryParams.goodsTypeId" placeholder="请输入商品分类Id" clearable @keyup.enter.native="handleQuery"/> -->
+        <el-select v-model="queryParams.goodsTypeId" placeholder="请选择商品分类">
+                        <el-option v-for="item in typeArray" :key="item.id" :label="item.goodsTypeName" :value="item.id" />
+                      </el-select>
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
@@ -25,32 +28,36 @@
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
         <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
-                   v-hasPermi="['restaurant:restaurant:create']">新增</el-button>
+                   v-hasPermi="['restaurant:goods:create']">新增</el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
-                   v-hasPermi="['restaurant:restaurant:export']">导出</el-button>
+                   v-hasPermi="['restaurant:goods:export']">导出</el-button>
       </el-col>
               <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
             <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
-            <el-table-column label="商品编号" align="center" prop="id" />
-      <el-table-column label="商品分类" align="center" prop="goodsTypeId" />
+            <!-- <el-table-column label="商品编号" align="center" prop="id" /> -->
       <el-table-column label="商品名称" align="center" prop="goodsName" />
-      <el-table-column label="商品价格" align="center" prop="goodsPrice" />
-      <el-table-column label="商品图标" align="center" prop="goodsIcon" />
+      <el-table-column label="商品价格" align="center" prop="goodsPrice" >
+        <template v-slot="scope">
+          <span>{{ scope.row.goodsPrice}}</span>
+        </template>
+      </el-table-column>
+      <!-- <el-table-column label="商品图标" align="center" prop="goodsIcon" />
       <el-table-column label="创建时间" align="center" prop="createTime" width="180">
         <template v-slot="scope">
           <span>{{ parseTime(scope.row.createTime) }}</span>
         </template>
-      </el-table-column>
+      </el-table-column> -->
+      <!-- <el-table-column label="商品分类Id" align="center" prop="goodsTypeId" /> -->
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template v-slot="scope">
           <el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)"
-                     v-hasPermi="['restaurant:restaurant:update']">修改</el-button>
+                     v-hasPermi="['restaurant:goods:update']">修改</el-button>
           <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
-                     v-hasPermi="['restaurant:restaurant:delete']">删除</el-button>
+                     v-hasPermi="['restaurant:goods:delete']">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -63,7 +70,8 @@
 </template>
 
 <script>
-import * as GoodsApi from '@/api/restaurant/restaurant';
+import * as GoodsApi from '@/api/restaurant/goods';
+import * as TypeApi from '@/api/restaurant/type';
 import GoodsForm from './GoodsForm.vue';
 export default {
   name: "Goods",
@@ -92,18 +100,29 @@ export default {
       queryParams: {
                     pageNo: 1,
             pageSize: 10,
-        goodsTypeId: null,
         goodsName: null,
         goodsPrice: null,
         goodsIcon: null,
         createTime: [],
+        goodsTypeId: null,
       },
+      typeArray:[],
             };
   },
   created() {
     this.getList();
+    this.getType()
   },
   methods: {
+    async getType(){
+        try {
+        const res = await TypeApi.getTypePage(this.queryParams);
+        this.typeArray = res.data.list;
+        } finally {
+          
+        }
+        
+      }, 
     /** 查询列表 */
     async getList() {
       try {

+ 150 - 0
yudao-ui-admin-vue2/src/views/restaurant/order/index.vue

@@ -0,0 +1,150 @@
+<template>
+  <div class="app-container">
+    <!-- 搜索工作栏 -->
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="订单名称" prop="OrderName">
+        <el-input v-model="queryParams.OrderName" placeholder="请输入订单名称" clearable @keyup.enter.native="handleQuery"/>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <!-- 操作工具栏 -->
+    <el-row :gutter="10" class="mb8">
+      <!-- <el-col :span="1.5">
+        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
+                   v-hasPermi="['restaurant:order:create']">新增</el-button>
+      </el-col> -->
+      <el-col :span="1.5">
+        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
+                   v-hasPermi="['restaurant:order:export']">导出</el-button>
+      </el-col>
+              <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+            <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
+            <!-- <el-table-column label="订单编号" align="center" prop="id" /> -->
+      <el-table-column label="订单名称" align="center" prop="name" />
+      <el-table-column label="取餐人手机尾号" align="center" prop="phone" />
+      <el-table-column label="订单价格" align="center" prop="priceVisable" >
+        <template v-slot="scope">
+          <span>{{ scope.row.priceVisable}}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="订单类型" align="center" prop="type" >
+        <template v-slot="scope">
+          <span v-show="scope.row.type==1">到店</span>
+          <span v-show="scope.row.type==2">配送</span>
+        </template>
+      </el-table-column>
+      <!-- <el-table-column label="订单图标" align="center" prop="OrderIcon" /> -->
+      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
+        <template v-slot="scope">
+          <span>{{ parseTime(scope.row.createTime) }}</span>
+        </template>
+      </el-table-column>
+      <!-- <el-table-column label="订单分类Id" align="center" prop="OrderTypeId" /> -->
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template v-slot="scope">
+          <el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)"
+                     v-hasPermi="['restaurant:order:update']">修改</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页组件 -->
+    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
+                @pagination="getList"/>
+    <!-- 对话框(添加 / 修改) -->
+    <!-- <OrderForm ref="formRef" @success="getList" /> -->
+    </div>
+</template>
+
+<script>
+import * as OrderApi from '@/api/restaurant/order';
+import * as TypeApi from '@/api/restaurant/type';
+// import OrderForm from './OrderForm.vue';
+export default {
+  name: "Order",
+  components: {
+          // OrderForm,
+  },
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 导出遮罩层
+      exportLoading: false,
+      // 显示搜索条件
+      showSearch: true,
+              // 总条数
+        total: 0,
+      // 订单列表
+      list: [],
+      // 是否展开,默认全部展开
+      isExpandAll: true,
+      // 重新渲染表格状态
+      refreshTable: true,
+      // 选中行
+      currentRow: {},
+      // 查询参数
+      queryParams: {
+                    pageNo: 1,
+            pageSize: 10,
+            desc:'true',
+        OrderName: null,
+        OrderPrice: null,
+        OrderIcon: null,
+        createTime: [],
+        OrderTypeId: null,
+      },
+      typeArray:[],
+            };
+  },
+  created() {
+    this.getList();
+    // this.getType()
+  },
+  methods: {
+    /** 查询列表 */
+    async getList() {
+      try {
+      this.loading = true;
+              const res = await OrderApi.pageOrder(this.queryParams);
+              console.log('res',res)
+        this.list = res.list;
+        this.total = res.total;
+      } finally {
+        this.loading = false;
+      }
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNo = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    /** 添加/修改操作 */
+    openForm(id) {
+      this.$refs["formRef"].open(id);
+    },
+    /** 导出按钮操作 */
+    async handleExport() {
+      await this.$modal.confirm('是否确认导出所有订单数据项?');
+      try {
+        this.exportLoading = true;
+        const data = await OrderApi.exportOrderExcel(this.queryParams);
+        this.$download.excel(data, '订单.xls');
+      } catch {
+      } finally {
+        this.exportLoading = false;
+      }
+    },
+              }
+};
+</script>

+ 92 - 111
yudao-ui-admin-vue2/src/views/restaurant/type/TypeForm.vue

@@ -1,111 +1,92 @@
-<template>
-  <div class="app-container">
-    <!-- 对话框(添加 / 修改) -->
-    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
-      <el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
-                    <el-form-item label="商品分类名称" prop="goodsTypeName">
-                      <el-input v-model="formData.goodsTypeName" placeholder="请输入商品分类名称" />
-                    </el-form-item>
-      </el-form>
-                  <!-- 子表的表单 -->
-          <el-tabs v-model="subTabsName">
-                <el-tab-pane label="商品" name="">
-                  <Form ref="FormRef" :goodsTypeId="formData.id" />
-                </el-tab-pane>
-          </el-tabs>
-      <div slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="submitForm" :disabled="formLoading">确 定</el-button>
-        <el-button @click="dialogVisible = false">取 消</el-button>
-      </div>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-  import * as TypeApi from '@/api/restaurant/type';
-          import Form from './components/Form.vue'
-  export default {
-    name: "TypeForm",
-    components: {
-                               Form,
-    },
-    data() {
-      return {
-        // 弹出层标题
-        dialogTitle: "",
-        // 是否显示弹出层
-        dialogVisible: false,
-        // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
-        formLoading: false,
-        // 表单参数
-        formData: {
-                            goodsTypeName: undefined,
-        },
-        // 表单校验
-        formRules: {
-        },
-                              /** 子表的表单 */
-             subTabsName: ''
-      };
-    },
-    methods: {
-      /** 打开弹窗 */
-     async open(id) {
-        this.dialogVisible = true;
-        this.reset();
-        // 修改时,设置数据
-        if (id) {
-          this.formLoading = true;
-          try {
-            const res = await TypeApi.getType(id);
-            this.formData = res.data;
-            this.title = "修改商品分类";
-          } finally {
-            this.formLoading = false;
-          }
-        }
-        this.title = "新增商品分类";
-              },
-      /** 提交按钮 */
-      async submitForm() {
-        // 校验主表
-        await this.$refs["formRef"].validate();
-                          // 校验子表
-                    try {
-                                            await this.$refs['FormRef'].validate();
-                    } catch (e) {
-                      this.subTabsName = '';
-                      return;
-                    }
-        this.formLoading = true;
-        try {
-          const data = this.formData;
-                    // 拼接子表的数据
-              data.goodss = this.$refs['FormRef'].getData();
-          // 修改的提交
-          if (data.id) {
-            await TypeApi.updateType(data);
-            this.$modal.msgSuccess("修改成功");
-            this.dialogVisible = false;
-            this.$emit('success');
-            return;
-          }
-          // 添加的提交
-          await TypeApi.createType(data);
-          this.$modal.msgSuccess("新增成功");
-          this.dialogVisible = false;
-          this.$emit('success');
-        } finally {
-          this.formLoading = false;
-        }
-      },
-                      /** 表单重置 */
-      reset() {
-        this.formData = {
-                            goodsTypeName: undefined,
-        };
-        this.resetForm("formRef");
-      }
-    }
-  };
-</script>
+<template>
+  <div class="app-container">
+    <!-- 对话框(添加 / 修改) -->
+    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
+      <el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
+                    <el-form-item label="商品分类名称" prop="goodsTypeName">
+                      <el-input v-model="formData.goodsTypeName" placeholder="请输入商品分类名称" />
+                    </el-form-item>
+      </el-form>
+              <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm" :disabled="formLoading">确 定</el-button>
+        <el-button @click="dialogVisible = false">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import * as TypeApi from '@/api/restaurant/type';
+      export default {
+    name: "TypeForm",
+    components: {
+                    },
+    data() {
+      return {
+        // 弹出层标题
+        dialogTitle: "",
+        // 是否显示弹出层
+        dialogVisible: false,
+        // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
+        formLoading: false,
+        // 表单参数
+        formData: {
+                            goodsTypeName: undefined,
+        },
+        // 表单校验
+        formRules: {
+        },
+                        };
+    },
+    methods: {
+      /** 打开弹窗 */
+     async open(id) {
+        this.dialogVisible = true;
+        this.reset();
+        // 修改时,设置数据
+        if (id) {
+          this.formLoading = true;
+          try {
+            const res = await TypeApi.getType(id);
+            this.formData = res.data;
+            this.title = "修改商品分类";
+          } finally {
+            this.formLoading = false;
+          }
+        }
+        this.title = "新增商品分类";
+              },
+      /** 提交按钮 */
+      async submitForm() {
+        // 校验主表
+        await this.$refs["formRef"].validate();
+                  this.formLoading = true;
+        try {
+          const data = this.formData;
+                  // 修改的提交
+          if (data.id) {
+            await TypeApi.updateType(data);
+            this.$modal.msgSuccess("修改成功");
+            this.dialogVisible = false;
+            this.$emit('success');
+            return;
+          }
+          // 添加的提交
+          await TypeApi.createType(data);
+          this.$modal.msgSuccess("新增成功");
+          this.dialogVisible = false;
+          this.$emit('success');
+        } finally {
+          this.formLoading = false;
+        }
+      },
+                      /** 表单重置 */
+      reset() {
+        this.formData = {
+                            goodsTypeName: undefined,
+        };
+        this.resetForm("formRef");
+      }
+    }
+  };
+</script>

+ 0 - 120
yudao-ui-admin-vue2/src/views/restaurant/type/components/Form.vue

@@ -1,120 +0,0 @@
-<template>
-  <div class="app-container">
-      <el-form
-        ref="formRef"
-        :model="formData"
-        :rules="formRules"
-        v-loading="formLoading"
-        label-width="0px"
-        :inline-message="true"
-      >
-        <el-table :data="formData" class="-mt-10px">
-          <el-table-column label="序号" type="index" width="100" />
-                       <el-table-column label="商品名称" min-width="150">
-                        <template v-slot="{ row, $index }">
-                          <el-form-item :prop="`${$index}.goodsName`" :rules="formRules.goodsName" class="mb-0px!">
-                            <el-input v-model="row.goodsName" placeholder="请输入商品名称" />
-                          </el-form-item>
-                        </template>
-                      </el-table-column>
-                      <el-table-column label="商品价格" min-width="150">
-                        <template v-slot="{ row, $index }">
-                          <el-form-item :prop="`${$index}.goodsPrice`" :rules="formRules.goodsPrice" class="mb-0px!">
-                            <el-input v-model="row.goodsPrice" placeholder="请输入商品价格" />
-                          </el-form-item>
-                        </template>
-                      </el-table-column>
-                      <el-table-column label="商品图标" min-width="200">
-                        <template v-slot="{ row, $index }">
-                          <el-form-item :prop="`${$index}.goodsIcon`" :rules="formRules.goodsIcon" class="mb-0px!">
-                            <ImageUpload v-model="row.goodsIcon" :limit = '1' />
-                          </el-form-item>
-                        </template>
-                      </el-table-column>
-          <el-table-column align="center" fixed="right" label="操作" width="60">
-            <template v-slot="{ $index }">
-              <el-link @click="handleDelete($index)">—</el-link>
-            </template>
-          </el-table-column>
-        </el-table>
-      </el-form>
-      <el-row justify="center" class="mt-3">
-        <el-button @click="handleAdd" round>+ 添加商品</el-button>
-      </el-row>
-  </div>
-</template>
-
-<script>
-  import * as TypeApi from '@/api/restaurant/type';
-      import ImageUpload from '@/components/ImageUpload';
-  export default {
-    name: "Form",
-    components: {
-          ImageUpload,
-    },
-    props:[
-      'goodsTypeId'
-    ],// 商品分类(主表的关联字段)
-    data() {
-      return {
-        // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
-        formLoading: false,
-        // 表单参数
-        formData: [],
-        // 表单校验
-        formRules: {
-        },
-      };
-    },
-    watch:{/** 监听主表的关联字段的变化,加载对应的子表数据 */
-      goodsTypeId:{
-        
-        handler(val) {
-          // 1. 重置表单
-          console.log('goodsTypeId', val)
-              this.formData = []
-          // 2. val 非空,则加载数据
-          if (!val) {
-            return;
-          }
-          try {
-            this.formLoading = true;
-            // 这里还是需要获取一下 this 的不然取不到 formData
-            const that = this;
-            TypeApi.getByGoodsTypeId(val).then(function (res){
-              that.formData = res.data;
-            })
-          } finally {
-            this.formLoading = false;
-          }
-        },
-        immediate: true
-      }
-    },
-    methods: {
-          /** 新增按钮操作 */
-          handleAdd() {
-            const row = {
-                                goodsTypeId: undefined,
-                                goodsName: undefined,
-                                goodsPrice: undefined,
-                                goodsIcon: undefined,
-            }
-            row.goodsTypeId = this.goodsTypeId;
-            this.formData.push(row);
-          },
-          /** 删除按钮操作 */
-          handleDelete(index) {
-            this.formData.splice(index, 1);
-          },
-      /** 表单校验 */
-      validate(){
-        return this.$refs["formRef"].validate();
-      },
-      /** 表单值 */
-      getData(){
-        return this.formData;
-      }
-    }
-  };
-</script>

+ 5 - 5
yudao-ui-admin-vue2/src/views/restaurant/type/index.vue

@@ -2,13 +2,13 @@
   <div class="app-container">
     <!-- 搜索工作栏 -->
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
-      <el-form-item label="商品分类名称" prop="goodsTypeName">
+      <el-form-item label="分类名称" prop="goodsTypeName">
         <el-input v-model="queryParams.goodsTypeName" placeholder="请输入商品分类名称" clearable @keyup.enter.native="handleQuery"/>
       </el-form-item>
-      <el-form-item label="创建时间" prop="createTime">
+      <!-- <el-form-item label="创建时间" prop="createTime">
         <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
                         range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
@@ -29,8 +29,8 @@
     </el-row>
 
             <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
-            <el-table-column label="商品分类ID" align="center" prop="id" />
-      <el-table-column label="商品分类名称" align="center" prop="goodsTypeName" />
+            <!-- <el-table-column label="商品分类ID" align="center" prop="id" /> -->
+      <el-table-column label="分类名称" align="center" prop="goodsTypeName" />
       <el-table-column label="创建时间" align="center" prop="createTime" width="180">
         <template v-slot="scope">
           <span>{{ parseTime(scope.row.createTime) }}</span>