ソースを参照

Add 添加商铺

enilu 6 年 前
コミット
72108a7f8c

+ 10 - 0
README.md

@@ -16,3 +16,13 @@
 ```
 mongorestore.exe -d flash-waimai e:\\elm
 ```
+## 模块
+- flash-waimai-admin原版后台管理系统
+- flash-waimai-manage改版的后台管理系统:在flash-waimai-admin的基础上完善后台管理功能,并且把后台接口从nodejs服务更改为java接口,java接口服务未flash-waimai-api
+- flash-waimai-api java接口服务
+- flash-waimai-core 底层核心模块
+- flash-waimai-generate 代码生成模块
+- flash-waimai-mobile 手机端站点
+## todo
+- 改造 flash-waimai-manage 
+- 改造 flash-waimai-mobile

+ 2 - 4
flash-waimai-api/src/main/java/cn/enilu/flash/api/controller/business/FoodController.java

@@ -79,7 +79,7 @@ public class FoodController extends BaseController {
          mongoRepository.delete("foods", Maps.newHashMap("item_id",id));
         return Rets.success();
     }
-    //todo 未完成
+
     @RequestMapping(value = "/v2/updatefood",method = RequestMethod.POST)
     public Object update(@ModelAttribute @Valid FoodVo food){
         List<SpecVo> specVoList = Json.fromJsonAsList(SpecVo.class,food.getSpecsJson());
@@ -92,15 +92,13 @@ public class FoodController extends BaseController {
             specFood.setSpecs_name(specVo.getSpecs());
             specList.add(specFood);
         }
-        Food old = mongoRepository.findOne(Food.class,"item_id",food.getId());
-        System.out.println(Json.toJson(food));
 
+        Food old = mongoRepository.findOne(Food.class,"item_id",food.getId());
         old.setName(food.getName());
         old.setDescription(food.getDescript());
         old.setCategory_id(food.getIdMenu());
         old.setImage_path(food.getImagePath());
         old.setSpecfoods(specList);
-        System.out.println(Json.toJson(old));
         mongoRepository.update(old);
         return Rets.success();
     }

+ 6 - 6
flash-waimai-api/src/main/java/cn/enilu/flash/api/controller/business/PositionController.java

@@ -55,19 +55,19 @@ public class PositionController extends BaseController {
 
     }
     @RequestMapping(value = "/v1/cities/{id}",method = RequestMethod.GET)
-
     public Object getCity(@PathVariable("id")Integer id){
-        return positionService.findById(id);
+        return Rets.success(positionService.findById(id));
     }
-    @RequestMapping(value = "/v1/pois",method = RequestMethod.GET)
 
+    @RequestMapping(value = "/v1/pois",method = RequestMethod.GET)
     public Object getPoiByCityAndKeyword(@RequestParam(value = "type",defaultValue = "search")String type,
-                       @RequestParam("city_id")Integer cityId,
-                       @RequestParam("keyword")String keyword){
+                       @RequestParam(value = "city_id")Integer cityId,
+                       @RequestParam(value = "keyword")String keyword){
 
         Map map =   positionService.findById(cityId);
-        return positionService.searchPlace(map.get("name").toString(),keyword);
+        return Rets.success(positionService.searchPlace(map.get("name").toString(),keyword));
     }
+
     //todo 未完成
     @RequestMapping(value = "/v2/pois/{geoHash}",method = RequestMethod.GET)
 

+ 10 - 4
flash-waimai-api/src/main/java/cn/enilu/flash/api/controller/business/ShopController.java

@@ -6,6 +6,7 @@ import cn.enilu.flash.bean.entity.front.Ids;
 import cn.enilu.flash.bean.entity.front.Menu;
 import cn.enilu.flash.bean.entity.front.Shop;
 import cn.enilu.flash.bean.vo.business.CityInfo;
+import cn.enilu.flash.bean.vo.business.ShopVo;
 import cn.enilu.flash.bean.vo.front.Rets;
 import cn.enilu.flash.dao.MongoRepository;
 import cn.enilu.flash.service.front.IdsService;
@@ -15,6 +16,7 @@ import cn.enilu.flash.utils.factory.Page;
 import com.google.common.collect.Lists;
 import org.nutz.json.Json;
 import org.nutz.lang.Strings;
+import org.nutz.mapl.Mapl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.geo.GeoResult;
 import org.springframework.data.geo.GeoResults;
@@ -97,11 +99,15 @@ public class ShopController extends BaseController {
 
     @RequestMapping(value = "/addShop",method = RequestMethod.POST)
 
-    public Object addShop(HttpServletRequest request) {
-        String json = getRequestPayload();
-        Map data = (Map) Json.fromJson(json);
-        Shop shop = Json.fromJson(Shop.class, json);
+    public Object addShop(@ModelAttribute @Valid ShopVo shopVo) {
+        System.out.println(Json.toJson(shopVo));
+        Map data = (Map) Mapl.toMaplist(shopVo);
+        Shop shop = new Shop();
         shop.setId(idsService.getId(Ids.RESTAURANT_ID));
+        System.out.println(Json.toJson(shop));
+        if(1==1){
+            return Rets.success();
+        }
         List<Map> supports = new ArrayList<Map>(4);
         if ((boolean) data.get("bao")) {
             supports.add(buildSupport("已加入“外卖保”计划,食品安全有保障", "999999", "保", 7, "外卖保"));

+ 29 - 0
flash-waimai-api/src/main/resources/application-local.properties

@@ -0,0 +1,29 @@
+## 开发环境配置
+debug=true
+spring.datasource.url=jdbc:mysql://localhost:3306/flash-waimai?useUnicode=true&characterEncoding=UTF8
+spring.datasource.username=root
+spring.datasource.password=root
+
+#spring.jpa.hibernate.ddl-auto=create
+#默认使用InnoDB引擎
+spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
+spring.datasource.sql-script-encoding=utf-8
+spring.jpa.show-sql=true
+#server.servlet.context-path=/api
+
+spring.data.mongodb.uri=mongodb://localhost:27017/flash-waimai
+
+
+##全局参数
+cfg.tencentkey=RLHBZ-WMPRP-Q3JDS-V2IQA-JNRFH-EJBHL
+cfg.tencentkey2=RRXBZ-WC6KF-ZQSJT-N2QU7-T5QIT-6KF5X
+cfg.tencentkey3=OHTBZ-7IFRG-JG2QF-IHFUK-XTTK6-VXFBN
+cfg.baidukey=fjke3YUipM9N64GdOIh1DNeK2APO2WcT
+cfg.baidukey2=fjke3YUipM9N64GdOIh1DNeK2APO2WcT
+
+## api
+api.qq.get.location=http://apis.map.qq.com/ws/location/v1/ip
+api.qq.search.place=http://apis.map.qq.com/ws/place/v1/search
+
+## 图片地址
+img.dir=/data/springboot-elm/img/

+ 1 - 1
flash-waimai-api/src/main/resources/application.properties

@@ -1,5 +1,5 @@
 ##打包部署的时候将该配置更改为prod
-spring.profiles.active=dev
+spring.profiles.active=local
 
 server.port=8082
 server.tomcat.max-threads=800

+ 0 - 17
flash-waimai-api/src/main/resources/application_bak.properties

@@ -1,17 +0,0 @@
-server.port=8011
-logging.level.root=INFO
-spring.data.mongodb.uri=mongodb://localhost:27017/elm
-
-##全局参数
-cfg.tencentkey=RLHBZ-WMPRP-Q3JDS-V2IQA-JNRFH-EJBHL
-cfg.tencentkey2=RRXBZ-WC6KF-ZQSJT-N2QU7-T5QIT-6KF5X
-cfg.tencentkey3=OHTBZ-7IFRG-JG2QF-IHFUK-XTTK6-VXFBN
-cfg.baidukey=fjke3YUipM9N64GdOIh1DNeK2APO2WcT
-cfg.baidukey2=fjke3YUipM9N64GdOIh1DNeK2APO2WcT
-
-## api
-api.qq.get.location=http://apis.map.qq.com/ws/location/v1/ip
-api.qq.search.place=http://apis.map.qq.com/ws/place/v1/search
-
-## 图片地址
-img.dir=/data/springboot-elm/img/

+ 1 - 1
flash-waimai-api/src/main/resources/import.sql

@@ -54,7 +54,7 @@ INSERT INTO `t_cms_contacts` VALUES ('1', null, '2019-07-31 17:44:27', null, '20
 -- Records of t_sys_cfg
 -- ----------------------------
 INSERT INTO `t_sys_cfg` VALUES ('1', null, null, '1', '2019-04-15 21:36:07', '应用名称update by 2019-03-27 11:47:04', 'system.app.name', 'web-flash');
-INSERT INTO `t_sys_cfg` VALUES ('2', null, null, '1', '2019-04-15 21:36:17', '系统默认上传文件路径', 'system.file.upload.path', '/data/web-flash/runtime/upload');
+INSERT INTO `t_sys_cfg` VALUES ('2', null, null, '1', '2019-04-15 21:36:17', '系统默认上传文件路径', 'system.file.upload.path', '/data/flash-waimai/runtime/upload');
 INSERT INTO `t_sys_cfg` VALUES ('3', null, null, '1', '2019-04-15 21:36:17', '腾讯sms接口appid', 'api.tencent.sms.appid', '1400219425');
 INSERT INTO `t_sys_cfg` VALUES ('4', null, null, '1', '2019-04-15 21:36:17', '腾讯sms接口appkey', 'api.tencent.sms.appkey', '5f71ed5325f3b292946530a1773e997a');
 INSERT INTO `t_sys_cfg` VALUES ('5', null, null, '1', '2019-04-15 21:36:17', '腾讯sms接口签名参数', 'api.tencent.sms.sign', '需要去申请咯');

+ 43 - 0
flash-waimai-core/src/main/java/cn/enilu/flash/bean/vo/business/ShopVo.java

@@ -0,0 +1,43 @@
+package cn.enilu.flash.bean.vo.business;
+
+import cn.enilu.flash.bean.entity.front.Shop;
+import lombok.Data;
+
+/**
+ * @author :enilu
+ * @date :Created in 2019/9/8 19:21
+ */
+@Data
+public class ShopVo extends Shop {
+    private String activitiesJson;
+    private String delivery_mode;
+    private Boolean news;
+    private Boolean bao;
+    private Boolean zhun;
+    private Boolean piao;
+}
+
+
+//name: 小梦鲜花
+//        address: 上海市杨浦区昆明路739号
+//        description: 店铺简洁
+//        phone: 15029292929
+//        promotion_info: 店铺标语
+//        float_delivery_fee: 5
+//        float_minimum_order_amount: 20
+//        is_premium: true
+//        delivery_mode: true
+//        new: true
+//        bao: true
+//        zhun: true
+//        piao: true
+//        startTime: 05:45
+//        endTime: 10:30
+//        image_path: 27c8c711-dec4-45de-ba13-cad3c62299bf.jpg
+//        business_license_image: 3ec157ee-d647-4cb7-b522-1907fdcf6062.jpg
+//        catering_service_license_image: f3dea320-c3c1-4478-9e5a-71234ca707b7.jpg
+//        cateringServiceLicenseImage: http://127.0.0.1:8082/file/getImgStream?fileName=f3dea320-c3c1-4478-9e5a-71234ca707b7.jpg
+//        businessLicenseImage: http://127.0.0.1:8082/file/getImgStream?fileName=3ec157ee-d647-4cb7-b522-1907fdcf6062.jpg
+//        imagePath: http://127.0.0.1:8082/file/getImgStream?fileName=27c8c711-dec4-45de-ba13-cad3c62299bf.jpg
+//        category: 快餐便当/简餐
+//        activitiesJson: [{"icon_name":"减","name":"满减优惠","description":"满30减5,满60减8"}]

+ 12 - 0
flash-waimai-manage/src/api/business/food.js

@@ -1,6 +1,18 @@
 import request from '@/utils/request'
 
 /**
+ * 添加食品
+ */
+
+// export const addFood = data => fetch('/shopping/addfood', data, 'POST');
+export function addFood(params) {
+  return request({
+    url: '/shopping/addfood',
+    method: 'post',
+    params
+  })
+}
+/**
  * 获取食品列表
  */
 

+ 100 - 0
flash-waimai-manage/src/api/business/shop.js

@@ -1,6 +1,105 @@
 import request from '@/utils/request'
 
 /**
+ * 获取搜索地址
+ */
+
+// export const searchplace = (cityid, value) => fetch('/v1/pois', {
+// 	type: 'search',
+// 	city_id: cityid,
+// 	keyword: value
+// });
+
+export function searchplace(cityid, value) {
+  return request({
+    url: '/v1/pois',
+    method: 'get',
+    params: {
+      type: 'search',
+      city_id: cityid,
+      keyword: value
+    }
+  })
+}
+
+/**
+ * category 种类列表
+ */
+
+// export const foodCategory = (latitude, longitude) => fetch('/shopping/v2/restaurant/category');
+
+export function foodCategory(params) {
+  return request({
+    url: '/shopping/v2/restaurant/category',
+    method: 'get'
+  })
+}
+
+/**
+ * 获取餐馆列表
+ */
+
+// export const getResturants = data => fetch('/shopping/restaurants', data);
+
+export function getResturants(params) {
+  return request({
+    url: '/shopping/restaurants',
+    method: 'get',
+    params
+  })
+}
+
+/**
+ * 获取餐馆数量
+ */
+// export const getResturantsCount = () => fetch('/shopping/restaurants/count');
+
+export function getResturantsCount(params) {
+  return request({
+    url: '/shopping/restaurants/count',
+    method: 'get'
+  })
+}
+/**
+ * 添加商铺
+ */
+
+// export const addShop = data => fetch('/shopping/addShop', data, 'POST')
+export function addShop(params) {
+  return request({
+    url: '/shopping/addShop',
+    method: 'post',
+    params
+  })
+}
+
+/**
+ * 更新餐馆信息
+ */
+
+// export const updateResturant = data => fetch('/shopping/updateshop', data, 'POST');
+export function updateResturant(params) {
+  return request({
+    url: '/shopping/updateshop',
+    method: 'post',
+    params
+  })
+}
+
+/**
+ * 删除餐馆
+ */
+
+// export const deleteResturant = restaurant_id => fetch('/shopping/restaurant/' + restaurant_id, {}, 'DELETE');
+
+export function deleteResturant(id) {
+  return request({
+    url: '/shopping/restaurant/' + id,
+    method: 'delete'
+  })
+}
+
+/**
  * 获取餐馆详细信息
  */
 
@@ -34,3 +133,4 @@ export function getMenuById(category_id) {
     method: 'get'
   })
 }
+

+ 1 - 73
flash-waimai-manage/src/api/getData.js

@@ -22,85 +22,13 @@ export function cityGuess() {
  * 获取搜索地址
  */
 
-// export const searchplace = (cityid, value) => fetch('/v1/pois', {
-// 	type: 'search',
-// 	city_id: cityid,
-// 	keyword: value
-// });
-
 export function searchplace(cityid, value) {
   return request({
     url: '/v1/pois',
-    method: 'get',
+    type: 'search',
     params: {
-      type: 'search',
       city_id: cityid,
       keyword: value
     }
   })
 }
-
-/**
- * category 种类列表
- */
-
-// export const foodCategory = (latitude, longitude) => fetch('/shopping/v2/restaurant/category');
-
-export function foodCategory(params) {
-  return request({
-    url: '/shopping/v2/restaurant/category',
-    method: 'get'
-  })
-}
-
-/**
- * 获取餐馆列表
- */
-
-// export const getResturants = data => fetch('/shopping/restaurants', data);
-
-export function getResturants(params) {
-  return request({
-    url: '/shopping/restaurants',
-    method: 'get',
-    params
-  })
-}
-
-/**
- * 获取餐馆数量
- */
-// export const getResturantsCount = () => fetch('/shopping/restaurants/count');
-
-export function getResturantsCount(params) {
-  return request({
-    url: '/shopping/restaurants/count',
-    method: 'get'
-  })
-}
-
-/**
- * 更新餐馆信息
- */
-
-// export const updateResturant = data => fetch('/shopping/updateshop', data, 'POST');
-export function updateResturant(params) {
-  return request({
-    url: '/shopping/updateshop',
-    method: 'post',
-    params
-  })
-}
-
-/**
- * 删除餐馆
- */
-
-// export const deleteResturant = restaurant_id => fetch('/shopping/restaurant/' + restaurant_id, {}, 'DELETE');
-
-export function deleteResturant(id) {
-  return request({
-    url: '/shopping/restaurant/' + id,
-    method: 'delete'
-  })
-}

+ 33 - 24
flash-waimai-manage/src/router/index.js

@@ -34,14 +34,14 @@ export const constantRouterMap = [
       component: () => import('@/views/dashboard/index'),
       meta: { title: 'dashboard', icon: 'dashboard', noCache: true }
     },
-    {
-      path: '/account/profile',
-      name: '个人资料',
-      component: () => import('@/views/account/profile.vue'),
-      hidden: true,
-      meta: { title: '个人资料' }
+      {
+        path: '/account/profile',
+        name: '个人资料',
+        component: () => import('@/views/account/profile.vue'),
+        hidden: true,
+        meta: { title: '个人资料' }
 
-    },
+      },
       {
         path: '/account/timeline',
         name: '最近活动',
@@ -70,25 +70,37 @@ export const constantRouterMap = [
       roles: ['administrator', 'developer'],
       title: '业务管理',
       icon: 'message'
-  },
+    },
     children: [
       {
         path: 'shop',
         name: 'shop',
-        component:() => import('@/views/business/shop/index'),
+        component: () => import('@/views/business/shop/index'),
         meta: { title: '商铺管理' }
       },
       {
         path: 'food',
         name: 'food',
-        component:() => import('@/views/business/food/index'),
+        component: () => import('@/views/business/food/index'),
         meta: { title: '食品管理' }
       },
       {
         path: 'order',
         name: 'order',
-        component:() => import('@/views/business/order/index'),
+        component: () => import('@/views/business/order/index'),
         meta: { title: '订单管理' }
+      },
+      {
+        path: 'shop/add',
+        name: 'shop_add',
+        component: () => import('@/views/business/shop/add.vue'),
+        meta: { title: '添加商铺' }
+      },
+      {
+        path: 'food/add',
+        name: 'food_add',
+        component: () => import('@/views/business/food/add.vue'),
+        meta: { title: '添加食品' }
       }
     ]
   },
@@ -102,9 +114,6 @@ export default new Router({
   routes: constantRouterMap
 })
 
-
-
-
 export const asyncRouterMap = [
   {
     path: '/system',
@@ -138,7 +147,7 @@ export const asyncRouterMap = [
         path: 'mgr',
         name: 'Account',
         component: () => import('@/views/system/user/index'),
-        meta: {title: 'userMgr' }
+        meta: { title: 'userMgr' }
       },
       {
         path: 'role',
@@ -150,7 +159,7 @@ export const asyncRouterMap = [
         path: 'task',
         name: 'Task',
         component: () => import('@/views/system/task/index'),
-        meta: { title: 'taskMgr' },
+        meta: { title: 'taskMgr' }
       },
       {
         path: 'taskLog',
@@ -216,13 +225,13 @@ export const asyncRouterMap = [
       {
         path: 'contacts',
         name: 'Contacts',
-        component:() => import('@/views/cms/contacts/index'),
+        component: () => import('@/views/cms/contacts/index'),
         meta: { title: 'contactsMgr' }
       },
       {
         path: 'file',
         name: 'File',
-        component:  () => import('@/views/cms/file/index'),
+        component: () => import('@/views/cms/file/index'),
         meta: {
           title: 'fileMgr'
         }
@@ -244,13 +253,13 @@ export const asyncRouterMap = [
       {
         path: 'druid',
         name: 'druid',
-        component:() => import('@/views/operation/druid/index'),
+        component: () => import('@/views/operation/druid/index'),
         meta: { title: 'druid' }
       },
       {
         path: 'swagger',
         name: 'swagger',
-        component:() => import('@/views/operation/api/index'),
+        component: () => import('@/views/operation/api/index'),
         meta: { title: 'swagger' }
       },
       {
@@ -282,13 +291,13 @@ export const asyncRouterMap = [
       {
         path: 'history',
         name: 'message',
-        component:() => import('@/views/message/message/index'),
+        component: () => import('@/views/message/message/index'),
         meta: { title: 'historyMessage' }
       },
       {
         path: 'template',
         name: 'template',
-        component:() => import('@/views/message/template/index'),
+        component: () => import('@/views/message/template/index'),
         meta: { title: 'messageTemplate' }
       },
       {
@@ -299,6 +308,6 @@ export const asyncRouterMap = [
       }
     ]
   },
-  {path: '/404', component: () => import('@/views/404'), hidden: true}
-];
+  { path: '/404', component: () => import('@/views/404'), hidden: true }
+]
 

+ 223 - 0
flash-waimai-manage/src/views/business/food/add.js

@@ -0,0 +1,223 @@
+import { getApiUrl } from '@/utils/utils'
+import { getCategory, addCategory, addFood } from '@/api/business/food'
+
+export default {
+  data() {
+    return {
+      restaurant_id: 1,
+      categoryForm: {
+        categoryList: [],
+        categorySelect: '',
+        name: '',
+        description: ''
+      },
+      foodForm: {
+        name: '',
+        description: '',
+        image_path: '',
+        activity: '',
+        attributes: [],
+        specs: [{
+          specs: '默认',
+          packing_fee: 0,
+          price: 20
+        }]
+      },
+      foodrules: {
+        name: [
+          { required: true, message: '请输入食品名称', trigger: 'blur' }
+        ]
+      },
+      attributes: [{
+        value: '新',
+        label: '新品'
+      }, {
+        value: '招牌',
+        label: '招牌'
+      }],
+      showAddCategory: false,
+      foodSpecs: 'one',
+      dialogFormVisible: false,
+      specsForm: {
+        specs: '',
+        packing_fee: 0,
+        price: 20
+      },
+      specsFormrules: {
+        specs: [
+          { required: true, message: '请输入规格', trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  created() {
+    if (this.$route.query.restaurant_id) {
+      this.restaurant_id = this.$route.query.restaurant_id
+    } else {
+      this.restaurant_id = Math.ceil(Math.random() * 10)
+      this.$msgbox({
+        title: '提示',
+        message: '添加食品需要选择一个商铺,先去就去选择商铺吗?',
+        showCancelButton: true,
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        beforeClose: (action, instance, done) => {
+          if (action === 'confirm') {
+            this.$router.push('/data/shop')
+            done()
+          } else {
+            this.$message({
+              type: 'info',
+              message: '取消'
+            })
+            done()
+          }
+        }
+      })
+    }
+    this.initData()
+  },
+  computed: {
+    selectValue: function() {
+      return this.categoryForm.categoryList[this.categoryForm.categorySelect] || {}
+    }
+  },
+  methods: {
+    async initData() {
+      try {
+        const result = await getCategory(this.restaurant_id)
+        if (result.status == 1) {
+          result.category_list.map((item, index) => {
+            item.value = index
+            item.label = item.name
+          })
+          this.categoryForm.categoryList = result.category_list
+        } else {
+          console.log(result)
+        }
+      } catch (err) {
+        console.log(err)
+      }
+    },
+    addCategoryFun() {
+      this.showAddCategory = !this.showAddCategory
+    },
+    submitcategoryForm(categoryForm) {
+      this.$refs[categoryForm].validate(async(valid) => {
+        if (valid) {
+          const params = {
+            name: this.categoryForm.name,
+            description: this.categoryForm.description,
+            restaurant_id: this.restaurant_id
+          }
+          try {
+            const result = await addCategory(params)
+            if (result.status == 1) {
+              this.initData()
+              this.categoryForm.name = ''
+              this.categoryForm.description = ''
+              this.showAddCategory = false
+              this.$message({
+                type: 'success',
+                message: '添加成功'
+              })
+            }
+          } catch (err) {
+            console.log(err)
+          }
+        } else {
+          this.$notify.error({
+            title: '错误',
+            message: '请检查输入是否正确',
+            offset: 100
+          })
+          return false
+        }
+      })
+    },
+    uploadImg(res, file) {
+      if (res.status == 1) {
+        this.foodForm.image_path = res.image_path
+      } else {
+        this.$message.error('上传图片失败!')
+      }
+    },
+    beforeImgUpload(file) {
+      const isRightType = (file.type === 'image/jpeg') || (file.type === 'image/png')
+      const isLt2M = file.size / 1024 / 1024 < 2
+
+      if (!isRightType) {
+        this.$message.error('上传头像图片只能是 JPG 格式!')
+      }
+      if (!isLt2M) {
+        this.$message.error('上传头像图片大小不能超过 2MB!')
+      }
+      return isRightType && isLt2M
+    },
+    addspecs() {
+      this.foodForm.specs.push({ ...this.specsForm })
+      this.specsForm.specs = ''
+      this.specsForm.packing_fee = 0
+      this.specsForm.price = 20
+      this.dialogFormVisible = false
+    },
+    handleDelete(index) {
+      this.foodForm.specs.splice(index, 1)
+    },
+    tableRowClassName(row, index) {
+      if (index === 1) {
+        return 'info-row'
+      } else if (index === 3) {
+        return 'positive-row'
+      }
+      return ''
+    },
+    addFood(foodForm) {
+      this.$refs[foodForm].validate(async(valid) => {
+        if (valid) {
+          const params = {
+            ...this.foodForm,
+            category_id: this.selectValue.id,
+            restaurant_id: this.restaurant_id
+          }
+          try {
+            const result = await addFood(params)
+            if (result.status == 1) {
+              console.log(result)
+              this.$message({
+                type: 'success',
+                message: '添加成功'
+              })
+              this.foodForm = {
+                name: '',
+                description: '',
+                image_path: '',
+                activity: '',
+                attributes: [],
+                specs: [{
+                  specs: '默认',
+                  packing_fee: 0,
+                  price: 20
+                }]
+              }
+            } else {
+              this.$message({
+                type: 'error',
+                message: result.message
+              })
+            }
+          } catch (err) {
+            console.log(err)
+          }
+        } else {
+          this.$notify.error({
+            title: '错误',
+            message: '请检查输入是否正确',
+            offset: 100
+          })
+          return false
+        }
+      })
+    }
+  }
+}

+ 230 - 0
flash-waimai-manage/src/views/business/food/add.vue

@@ -0,0 +1,230 @@
+<template>
+
+  <div class="app-container">
+    <div class="block">
+      <el-row>
+        <el-col :span="14" :offset="4">
+          <header class="form_header">选择食品种类</header>
+          <el-form :model="categoryForm" ref="categoryForm" label-width="110px" class="form">
+            <el-row class="category_select">
+              <el-form-item label="食品种类">
+                <el-select v-model="categoryForm.categorySelect" :placeholder="selectValue.label" style="width:100%;">
+                  <el-option
+                    v-for="item in categoryForm.categoryList"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value">
+                  </el-option>
+                </el-select>
+              </el-form-item>
+            </el-row>
+            <el-row class="add_category_row" :class="showAddCategory? 'showEdit': ''">
+              <div class="add_category">
+                <el-form-item label="食品种类" prop="name">
+                  <el-input v-model="categoryForm.name"></el-input>
+                </el-form-item>
+                <el-form-item label="种类描述" prop="description">
+                  <el-input v-model="categoryForm.description"></el-input>
+                </el-form-item>
+                <el-form-item>
+                  <el-button type="primary" @click="submitcategoryForm('categoryForm')">提交</el-button>
+                </el-form-item>
+              </div>
+            </el-row>
+            <div class="add_category_button" @click="addCategoryFun">
+              <i class="el-icon-caret-top edit_icon" v-if="showAddCategory"></i>
+              <i class="el-icon-caret-bottom edit_icon" v-else slot="icon"></i>
+              <span>添加食品种类</span>
+            </div>
+          </el-form>
+          <header class="form_header">添加食品</header>
+          <el-form :model="foodForm" :rules="foodrules" ref="foodForm" label-width="110px" class="form food_form">
+            <el-form-item label="食品名称" prop="name">
+              <el-input v-model="foodForm.name"></el-input>
+            </el-form-item>
+            <el-form-item label="食品活动" prop="activity">
+              <el-input v-model="foodForm.activity"></el-input>
+            </el-form-item>
+            <el-form-item label="食品详情" prop="description">
+              <el-input v-model="foodForm.description"></el-input>
+            </el-form-item>
+            <el-form-item label="上传食品图片">
+              <el-upload
+                class="avatar-uploader"
+                :action="fileMgrUrl"
+                :show-file-list="false"
+                :on-success="uploadImg"
+                :before-upload="beforeImgUpload">
+                <img v-if="foodForm.image_path" :src="baseImgPath + foodForm.image_path" class="avatar">
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+              </el-upload>
+            </el-form-item>
+            <el-form-item label="食品特点">
+              <el-select v-model="foodForm.attributes" multiple placeholder="请选择">
+                <el-option
+                  v-for="item in attributes"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item label="食品规格">
+              <el-radio class="radio" v-model="foodSpecs" label="one">单规格</el-radio>
+              <el-radio class="radio" v-model="foodSpecs" label="more">多规格</el-radio>
+            </el-form-item>
+            <el-row v-if="foodSpecs == 'one'">
+              <el-form-item label="包装费">
+                <el-input-number v-model="foodForm.specs[0].packing_fee" :min="0" :max="100"></el-input-number>
+              </el-form-item>
+              <el-form-item label="价格">
+                <el-input-number v-model="foodForm.specs[0].price" :min="0" :max="10000"></el-input-number>
+              </el-form-item>
+            </el-row>
+            <el-row v-else style="overflow: auto; text-align: center;">
+              <el-button type="primary" @click="dialogFormVisible = true" style="margin-bottom: 10px;">添加规格</el-button>
+              <el-table
+                :data="foodForm.specs"
+                style="margin-bottom: 20px;"
+                :row-class-name="tableRowClassName">
+                <el-table-column
+                  prop="specs"
+                  label="规格">
+                </el-table-column>
+                <el-table-column
+                  prop="packing_fee"
+                  label="包装费">
+                </el-table-column>
+                <el-table-column
+                  prop="price"
+                  label="价格">
+                </el-table-column>
+                <el-table-column label="操作">
+                  <template slot-scope="scope">
+                    <el-button
+                      size="small"
+                      type="danger"
+                      @click="handleDelete(scope.$index)">删除
+                    </el-button>
+                  </template>
+                </el-table-column>
+              </el-table>
+            </el-row>
+            <el-form-item>
+              <el-button type="primary" @click="addFood('foodForm')">确认添加食品</el-button>
+            </el-form-item>
+          </el-form>
+          <el-dialog title="添加规格" v-model="dialogFormVisible">
+            <el-form :rules="specsFormrules" :model="specsForm">
+              <el-form-item label="规格" label-width="100px" prop="specs">
+                <el-input v-model="specsForm.specs" auto-complete="off"></el-input>
+              </el-form-item>
+              <el-form-item label="包装费" label-width="100px">
+                <el-input-number v-model="specsForm.packing_fee" :min="0" :max="100"></el-input-number>
+              </el-form-item>
+              <el-form-item label="价格" label-width="100px">
+                <el-input-number v-model="specsForm.price" :min="0" :max="10000"></el-input-number>
+              </el-form-item>
+            </el-form>
+            <div slot="footer" class="dialog-footer">
+              <el-button @click="dialogFormVisible = false">取 消</el-button>
+              <el-button type="primary" @click="addspecs">确 定</el-button>
+            </div>
+          </el-dialog>
+        </el-col>
+      </el-row>
+    </div>
+  </div>
+</template>
+
+<script src="./add.js"></script>
+
+<style lang="less">
+  .form {
+    min-width: 400px;
+    margin-bottom: 30px;
+
+    &:hover {
+      box-shadow: 0 0 8px 0 rgba(232, 237, 250, .6), 0 2px 4px 0 rgba(232, 237, 250, .5);
+      border-radius: 6px;
+      transition: all 400ms;
+    }
+  }
+
+  .food_form {
+    border: 1px solid #eaeefb;
+    padding: 10px 10px 0;
+  }
+
+  .form_header {
+    text-align: center;
+    margin-bottom: 10px;
+  }
+
+  .category_select {
+    border: 1px solid #eaeefb;
+    padding: 10px 30px 10px 10px;
+    border-top-right-radius: 6px;
+    border-top-left-radius: 6px;
+  }
+
+  .add_category_row {
+    height: 0;
+    overflow: hidden;
+    transition: all 400ms;
+    background: #f9fafc;
+  }
+
+  .showEdit {
+    height: 185px;
+  }
+
+  .add_category {
+    background: #f9fafc;
+    padding: 10px 30px 0px 10px;
+    border: 1px solid #eaeefb;
+    border-top: none;
+  }
+
+  .add_category_button {
+    text-align: center;
+    line-height: 40px;
+    border-bottom-right-radius: 6px;
+    border-bottom-left-radius: 6px;
+    border: 1px solid #eaeefb;
+    border-top: none;
+    transition: all 400ms;
+
+  }
+
+  .avatar-uploader .el-upload {
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+  }
+
+  .avatar-uploader .el-upload:hover {
+    border-color: #20a0ff;
+  }
+
+  .avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 120px;
+    height: 120px;
+    line-height: 120px;
+    text-align: center;
+  }
+
+  .avatar {
+    width: 120px;
+    height: 120px;
+    display: block;
+  }
+
+  .cell {
+    text-align: center;
+  }
+</style>

+ 3 - 7
flash-waimai-manage/src/views/business/food/food.js

@@ -2,11 +2,7 @@ import { getApiUrl } from '@/utils/utils'
 import { baseUrl, baseImgPath } from '@/config/env'
 import { getToken } from '@/utils/auth'
 
-import {
-  getFoods,
-  updateFood,
-  deleteFood
-} from '@/api/business/food'
+import { getFoods, updateFood, deleteFood } from '@/api/business/food'
 import { getResturantDetail, getMenuById, getMenu } from '@/api/business/shop'
 import { Loading } from 'element-ui'
 
@@ -15,7 +11,7 @@ export default {
     return {
       baseUrl,
       baseImgPath,
-      uploadUrl: '',
+      fileMgrUrl: '',
       uploadHeaders: {
         'Authorization': ''
       },
@@ -53,7 +49,7 @@ export default {
   created() {
     this.restaurant_id = this.$route.query.restaurant_id
     this.initData()
-    this.uploadUrl = getApiUrl() + '/file'
+    this.fileMgrUrl = getApiUrl() + '/file'
     this.uploadHeaders['Authorization'] = getToken()
   },
   computed: {

+ 1 - 1
flash-waimai-manage/src/views/business/food/index.vue

@@ -98,7 +98,7 @@
               class="avatar-uploader"
 
               :show-file-list="false"
-              :action="uploadUrl"
+              :action="fileMgrUrl"
               :headers="uploadHeaders"
               :before-upload="handleBeforeUpload"
               :on-success="handleUploadSuccess">

+ 283 - 0
flash-waimai-manage/src/views/business/shop/add.js

@@ -0,0 +1,283 @@
+import { getApiUrl } from '@/utils/utils'
+import { getToken } from '@/utils/auth'
+import { cityGuess, searchplace } from '@/api/getData'
+import { addShop, foodCategory } from '@/api/business/shop'
+
+export default {
+  data() {
+    return {
+      city: {},
+      fileMgrUrl: getApiUrl() + '/file',
+      uploadHeaders: {
+        'Authorization': ''
+      },
+      formData: {
+        name: '', //店铺名称
+        address: '', //地址
+        latitude: '',
+        longitude: '',
+        description: '', //介绍
+        phone: '',
+        promotion_info: '',
+        float_delivery_fee: 5, //运费
+        float_minimum_order_amount: 20, //起价
+        is_premium: true,
+        delivery_mode: true,
+        new: true,
+        bao: true,
+        zhun: true,
+        piao: true,
+        startTime: '',
+        endTime: '',
+        image_path: '',
+        business_license_image: '',
+        catering_service_license_image: ''
+
+      },
+      rules: {
+        name: [
+          { required: true, message: '请输入店铺名称', trigger: 'blur' }
+        ],
+        address: [
+          { required: true, message: '请输入详细地址', trigger: 'blur' }
+        ],
+        phone: [
+          { required: true, message: '请输入联系电话' },
+          { type: 'number', message: '电话号码必须是数字' }
+        ]
+      },
+      options: [{
+        value: '满减优惠',
+        label: '满减优惠'
+      }, {
+        value: '优惠大酬宾',
+        label: '优惠大酬宾'
+      }, {
+        value: '新用户立减',
+        label: '新用户立减'
+      }, {
+        value: '进店领券',
+        label: '进店领券'
+      }],
+      activityValue: '满减优惠',
+      activities: [{
+        icon_name: '减',
+        name: '满减优惠',
+        description: '满30减5,满60减8'
+      }],
+      categoryOptions: [],
+      selectedCategory: ['快餐便当', '简餐']
+    }
+  },
+  mounted() {
+    this.initData()
+    this.uploadHeaders['Authorization'] = getToken()
+  },
+  methods: {
+    async initData() {
+      try {
+        const cityResponse = await cityGuess()
+        this.city = cityResponse.data
+        const categoriesResponse = await foodCategory()
+        const categories = categoriesResponse.data
+        categories.forEach(item => {
+          if (item.sub_categories.length) {
+            const addnew = {
+              value: item.name,
+              label: item.name,
+              children: []
+            }
+            item.sub_categories.forEach((subitem, index) => {
+              if (index === 0) {
+                return
+              }
+              addnew.children.push({
+                value: subitem.name,
+                label: subitem.name
+              })
+            })
+            this.categoryOptions.push(addnew)
+          }
+        })
+      } catch (err) {
+        console.log(err)
+      }
+    },
+    async querySearchAsync(queryString, cb) {
+      if (queryString) {
+        try {
+          const cityListResponse = await searchplace(this.city.id, queryString)
+          const cityList = cityListResponse.data
+          if (cityList instanceof Array) {
+            cityList.map(item => {
+              item.value = item.address
+              return item
+            })
+            cb(cityList)
+          }
+        } catch (err) {
+          console.log(err)
+        }
+      }
+    },
+    addressSelect(address) {
+      this.formData.latitude = address.latitude
+      this.formData.longitude = address.longitude
+      console.log(this.formData.latitude, this.formData.longitude)
+    },
+    handleShopAvatarScucess(res, file) {
+      console.log('res', res)
+      this.formData.imagePath = getApiUrl() + '/file/getImgStream?fileName=' + res.data.realFileName
+      this.formData.image_path = res.data.realFileName
+    },
+    handleBusinessAvatarScucess(res, file) {
+      this.formData.business_license_image = res.data.realFileName
+      this.formData.businessLicenseImage = getApiUrl() + '/file/getImgStream?fileName=' + res.data.realFileName
+    },
+    handleServiceAvatarScucess(res, file) {
+      this.formData.catering_service_license_image = res.data.realFileName
+      this.formData.cateringServiceLicenseImage = getApiUrl() + '/file/getImgStream?fileName=' + res.data.realFileName
+    },
+    beforeAvatarUpload(file) {
+      const isRightType = (file.type === 'image/jpeg') || (file.type === 'image/png')
+      const isLt2M = file.size / 1024 / 1024 < 2
+
+      if (!isRightType) {
+        this.$message.error('上传头像图片只能是 JPG 格式!')
+      }
+      if (!isLt2M) {
+        this.$message.error('上传头像图片大小不能超过 2MB!')
+      }
+      return isRightType && isLt2M
+    },
+    tableRowClassName(row, index) {
+      if (index === 1) {
+        return 'info-row'
+      } else if (index === 3) {
+        return 'positive-row'
+      }
+      return ''
+    },
+    selectActivity() {
+      this.$prompt('请输入活动详情', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消'
+      }).then(({ value }) => {
+        if (value === null) {
+          this.$message({
+            type: 'info',
+            message: '请输入活动详情'
+          })
+          return
+        }
+        let newObj = {}
+        switch (this.activityValue) {
+          case '满减优惠':
+            newObj = {
+              icon_name: '减',
+              name: '满减优惠',
+              description: value
+            }
+            break
+          case '优惠大酬宾':
+            newObj = {
+              icon_name: '特',
+              name: '优惠大酬宾',
+              description: value
+            }
+            break
+          case '新用户立减':
+            newObj = {
+              icon_name: '新',
+              name: '新用户立减',
+              description: value
+            }
+            break
+          case '进店领券':
+            newObj = {
+              icon_name: '领',
+              name: '进店领券',
+              description: value
+            }
+            break
+        }
+        this.activities.push(newObj)
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '取消输入'
+        })
+      })
+    },
+    handleDelete(index) {
+      this.activities.splice(index, 1)
+    },
+    submitForm(formName) {
+      this.$refs[formName].validate(async(valid) => {
+        if (valid) {
+          Object.assign(this.formData, { activities: this.activities }, {
+            category: this.selectedCategory.join('/')
+          })
+          const activities = this.formData.activities
+          const activitiesJson = JSON.stringify(activities)
+          delete this.formData.activities
+          this.formData.activitiesJson = activitiesJson
+          console.log(this.formData)
+
+          try {
+            const result = addShop(this.formData)
+            if (result.code === 20000) {
+              this.$message({
+                type: 'success',
+                message: '添加成功'
+              })
+              this.formData = {
+                name: '', //店铺名称
+                address: '', //地址
+                latitude: '',
+                longitude: '',
+                description: '', //介绍
+                phone: '',
+                promotion_info: '',
+                float_delivery_fee: 5, //运费
+                float_minimum_order_amount: 20, //起价
+                is_premium: true,
+                delivery_mode: true,
+                new: true,
+                bao: true,
+                zhun: true,
+                piao: true,
+                startTime: '',
+                endTime: '',
+                image_path: '',
+                business_license_image: '',
+                catering_service_license_image: ''
+              }
+              this.selectedCategory = ['快餐便当', '简餐']
+              this.activities = [{
+                icon_name: '减',
+                name: '满减优惠',
+                description: '满30减5,满60减8'
+              }]
+            } else {
+              this.$message({
+                type: 'error',
+                message: result.message
+              })
+            }
+            console.log(result)
+          } catch (err) {
+            console.log(err)
+          }
+        } else {
+          this.$notify.error({
+            title: '错误',
+            message: '请检查输入是否正确',
+            offset: 100
+          })
+          return false
+        }
+      })
+    }
+  }
+}

+ 213 - 0
flash-waimai-manage/src/views/business/shop/add.vue

@@ -0,0 +1,213 @@
+<template>
+  <div class="app-container">
+    <div class="block">
+      <el-row>
+        <el-col :span="12" :offset="4">
+          <el-form :model="formData" :rules="rules" ref="formData" label-width="110px" class="demo-formData">
+            <el-form-item label="店铺名称" prop="name">
+              <el-input v-model="formData.name"></el-input>
+            </el-form-item>
+            <el-form-item label="详细地址" prop="address">
+              <el-autocomplete
+                v-model="formData.address"
+                :fetch-suggestions="querySearchAsync"
+                placeholder="请输入地址"
+                style="width: 100%;"
+                @select="addressSelect"
+              ></el-autocomplete>
+              <span>当前城市:{{city.name}}</span>
+            </el-form-item>
+            <el-form-item label="联系电话" prop="phone">
+              <el-input v-model.number="formData.phone" maxLength="11"></el-input>
+            </el-form-item>
+            <el-form-item label="店铺简介" prop="description">
+              <el-input v-model="formData.description"></el-input>
+            </el-form-item>
+            <el-form-item label="店铺标语" prop="promotion_info">
+              <el-input v-model="formData.promotion_info"></el-input>
+            </el-form-item>
+            <el-form-item label="店铺分类">
+              <el-cascader
+                :options="categoryOptions"
+                v-model="selectedCategory"
+                change-on-select
+              ></el-cascader>
+            </el-form-item>
+            <el-form-item label="店铺特点" style="white-space: nowrap;">
+              <span>品牌保证</span>
+              <el-switch on-text="" off-text="" v-model="formData.is_premium"></el-switch>
+              <span>蜂鸟专送</span>
+              <el-switch on-text="" off-text="" v-model="formData.delivery_mode"></el-switch>
+              <span>新开店铺</span>
+              <el-switch on-text="" off-text="" v-model="formData.new"></el-switch>
+            </el-form-item>
+            <el-form-item style="white-space: nowrap;">
+              <span>外卖保</span>
+              <el-switch on-text="" off-text="" v-model="formData.bao"></el-switch>
+              <span>准时达</span>
+              <el-switch on-text="" off-text="" v-model="formData.zhun"></el-switch>
+              <span>开发票</span>
+              <el-switch on-text="" off-text="" v-model="formData.piao"></el-switch>
+            </el-form-item>
+            <el-form-item label="配送费" prop="float_delivery_fee">
+              <el-input-number v-model="formData.float_delivery_fee" :min="0" :max="20"></el-input-number>
+            </el-form-item>
+            <el-form-item label="起送价" prop="float_minimum_order_amount">
+              <el-input-number v-model="formData.float_minimum_order_amount" :min="0" :max="100"></el-input-number>
+            </el-form-item>
+            <el-form-item label="营业时间" style="white-space: nowrap;">
+              <el-time-select
+                placeholder="起始时间"
+                v-model="formData.startTime"
+                :picker-options="{
+							start: '05:30',
+							step: '00:15',
+							end: '23:30'
+							}">
+              </el-time-select>
+              <el-time-select
+                placeholder="结束时间"
+                v-model="formData.endTime"
+                :picker-options="{
+							start: '05:30',
+							step: '00:15',
+							end: '23:30',
+							minTime: formData.startTime
+							}">
+              </el-time-select>
+            </el-form-item>
+
+            <el-form-item label="上传店铺头像">
+              <el-upload
+                class="avatar-uploader"
+                :action="fileMgrUrl"
+                :headers="uploadHeaders"
+                :show-file-list="false"
+                :on-success="handleShopAvatarScucess"
+                :before-upload="beforeAvatarUpload">
+                <img v-if="formData.image_path" :src="formData.imagePath" class="avatar">
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+              </el-upload>
+            </el-form-item>
+            <el-form-item label="上传营业执照">
+              <el-upload
+                class="avatar-uploader"
+                :action="fileMgrUrl"
+                :headers="uploadHeaders"
+                :show-file-list="false"
+                :on-success="handleBusinessAvatarScucess"
+                :before-upload="beforeAvatarUpload">
+                <img v-if="formData.business_license_image" :src="formData.businessLicenseImage"
+                     class="avatar">
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+              </el-upload>
+            </el-form-item>
+            <el-form-item label="上传餐饮服务许可证">
+              <el-upload
+                class="avatar-uploader"
+                :action="fileMgrUrl"
+                :headers="uploadHeaders"
+                :show-file-list="false"
+                :on-success="handleServiceAvatarScucess"
+                :before-upload="beforeAvatarUpload">
+                <img v-if="formData.catering_service_license_image"
+                     :src="formData.cateringServiceLicenseImage" class="avatar">
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+              </el-upload>
+            </el-form-item>
+            <el-form-item label="优惠活动">
+              <el-select v-model="activityValue" @change="selectActivity" :placeholder="activityValue">
+                <el-option
+                  v-for="item in options"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+            <el-table
+              :data="activities"
+              style="min-width: 600px;margin-bottom: 20px;"
+              align="cneter"
+              :row-class-name="tableRowClassName">
+              <el-table-column
+                prop="icon_name"
+                label="活动标题"
+                align="cneter"
+                width="120">
+              </el-table-column>
+              <el-table-column
+                prop="name"
+                label="活动名称"
+                align="cneter"
+                width="120">
+              </el-table-column>
+              <el-table-column
+                prop="description"
+                align="cneter"
+                label="活动详情">
+              </el-table-column>
+              <el-table-column
+                label="操作"
+                width="120">
+                <template slot-scope="scope">
+                  <el-button
+                    size="small"
+                    type="danger"
+                    @click="handleDelete(scope.$index)">删除
+                  </el-button>
+                </template>
+              </el-table-column>
+            </el-table>
+            <el-form-item class="button_submit">
+              <el-button type="primary" @click="submitForm('formData')">立即创建</el-button>
+            </el-form-item>
+          </el-form>
+        </el-col>
+      </el-row>
+    </div>
+  </div>
+</template>
+
+<script src="./add.js"></script>
+
+<style lang="less">
+  .button_submit {
+    text-align: center;
+  }
+
+  .avatar-uploader .el-upload {
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+  }
+
+  .avatar-uploader .el-upload:hover {
+    border-color: #20a0ff;
+  }
+
+  .avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 120px;
+    height: 120px;
+    line-height: 120px;
+    text-align: center;
+  }
+
+  .avatar {
+    width: 120px;
+    height: 120px;
+    display: block;
+  }
+
+  .el-table .info-row {
+    background: #c9e5f5;
+  }
+
+  .el-table .positive-row {
+    background: #e2f0e4;
+  }
+</style>

+ 177 - 168
flash-waimai-manage/src/views/business/shop/index.vue

@@ -1,133 +1,134 @@
 <template>
-
   <div class="app-container">
     <div class="block">
-    <div class="fillcontain">
-        <div class="table_container">
-            <el-table
-                :data="tableData"
-                style="width: 100%">
-                <el-table-column type="expand">
-                  <template slot-scope="props">
-                    <el-form label-position="left" inline class="demo-table-expand">
-                      <el-form-item label="店铺名称">
-                        <span>{{ props.row.name }}</span>
-                      </el-form-item>
-                      <el-form-item label="店铺地址">
-                        <span>{{ props.row.address }}</span>
-                      </el-form-item>
-                      <el-form-item label="店铺介绍">
-                        <span>{{ props.row.description }}</span>
-                      </el-form-item>
-                      <el-form-item label="店铺 ID">
-                        <span>{{ props.row.id }}</span>
-                      </el-form-item>
-                      <el-form-item label="联系电话">
-                        <span>{{ props.row.phone }}</span>
-                      </el-form-item>
-                      <el-form-item label="评分">
-                        <span>{{ props.row.rating }}</span>
-                      </el-form-item>
-                      <el-form-item label="销售量">
-                        <span>{{ props.row.recent_order_num }}</span>
-                      </el-form-item>
-                      <el-form-item label="分类">
-                        <span>{{ props.row.category }}</span>
-                      </el-form-item>
-                    </el-form>
-                  </template>
-                </el-table-column>
-                <el-table-column
-                  label="店铺名称"
-                  prop="name">
-                </el-table-column>
-                <el-table-column
-                  label="店铺地址"
-                  prop="address">
-                </el-table-column>
-                <el-table-column
-                  label="店铺介绍"
-                  prop="description">
-                </el-table-column>
-                <el-table-column label="操作" width="300">
-                  <template slot-scope="scope">
-                    <el-button
-                      size="mini"
-                      type="primary"
-                      @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
-                    <el-button
-                      size="mini"
-                      type="success"
-                      @click="addFood(scope.$index, scope.row)">添加食品</el-button>
-                    <el-button
-                      size="mini"
-                      type="danger"
-                      @click="handleDelete(scope.$index, scope.row)">删除</el-button>
-                  </template>
-                </el-table-column>
-            </el-table>
-          <el-pagination
-            background
-            layout="total, sizes, prev, pager, next, jumper"
-            :page-sizes="[10, 20, 50, 100,500]"
-            :page-size="listQuery.limit"
-            :total="total"
-            @size-change="changeSize"
-            @current-change="fetchPage"
-            @prev-click="fetchPrev"
-            @next-click="fetchNext">
-          </el-pagination>
-            <el-dialog title="修改店铺信息"
-                       :visible.sync="dialogFormVisible"
-            >
-                <el-form :model="selectTable">
+      <div class="table_container">
+        <el-table
+          :data="tableData"
+          style="width: 100%">
+          <el-table-column type="expand">
+            <template slot-scope="props">
+              <el-form label-position="left" inline class="demo-table-expand">
+                <el-form-item label="店铺名称">
+                  <span>{{ props.row.name }}</span>
+                </el-form-item>
+                <el-form-item label="店铺地址">
+                  <span>{{ props.row.address }}</span>
+                </el-form-item>
+                <el-form-item label="店铺介绍">
+                  <span>{{ props.row.description }}</span>
+                </el-form-item>
+                <el-form-item label="店铺 ID">
+                  <span>{{ props.row.id }}</span>
+                </el-form-item>
+                <el-form-item label="联系电话">
+                  <span>{{ props.row.phone }}</span>
+                </el-form-item>
+                <el-form-item label="评分">
+                  <span>{{ props.row.rating }}</span>
+                </el-form-item>
+                <el-form-item label="销售量">
+                  <span>{{ props.row.recent_order_num }}</span>
+                </el-form-item>
+                <el-form-item label="分类">
+                  <span>{{ props.row.category }}</span>
+                </el-form-item>
+              </el-form>
+            </template>
+          </el-table-column>
+          <el-table-column
+            label="店铺名称"
+            prop="name">
+          </el-table-column>
+          <el-table-column
+            label="店铺地址"
+            prop="address">
+          </el-table-column>
+          <el-table-column
+            label="店铺介绍"
+            prop="description">
+          </el-table-column>
+          <el-table-column label="操作" width="300">
+            <template slot-scope="scope">
+              <el-button
+                size="mini"
+                type="primary"
+                @click="handleEdit(scope.$index, scope.row)">编辑
+              </el-button>
+              <el-button
+                size="mini"
+                type="success"
+                @click="addFood(scope.$index, scope.row)">添加食品
+              </el-button>
+              <el-button
+                size="mini"
+                type="danger"
+                @click="handleDelete(scope.$index, scope.row)">删除
+              </el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <el-pagination
+          background
+          layout="total, sizes, prev, pager, next, jumper"
+          :page-sizes="[10, 20, 50, 100,500]"
+          :page-size="listQuery.limit"
+          :total="total"
+          @size-change="changeSize"
+          @current-change="fetchPage"
+          @prev-click="fetchPrev"
+          @next-click="fetchNext">
+        </el-pagination>
+        <el-dialog title="修改店铺信息"
+                   :visible.sync="dialogFormVisible"
+        >
+          <el-form :model="selectTable">
 
-                    <el-form-item label="店铺名称" label-width="100px">
-                        <el-input v-model="selectTable.name" auto-complete="off"></el-input>
-                    </el-form-item>
+            <el-form-item label="店铺名称" label-width="100px">
+              <el-input v-model="selectTable.name" auto-complete="off"></el-input>
+            </el-form-item>
 
-                    <el-form-item label="详细地址" label-width="100px">
-                        <el-autocomplete
-                          v-model="address.address"
-                          :fetch-suggestions="querySearchAsync"
-                          placeholder="请输入地址"
-                          style="width: 100%;"
-                          @select="addressSelect"
-                        ></el-autocomplete>
-                        <span>当前城市:{{city.name}}</span>
-                    </el-form-item>
-                    <el-form-item label="店铺介绍" label-width="100px">
-                        <el-input v-model="selectTable.description"></el-input>
-                    </el-form-item>
-                    <el-form-item label="联系电话" label-width="100px">
-                        <el-input v-model="selectTable.phone"></el-input>
-                    </el-form-item>
-                    <el-form-item label="店铺分类" label-width="100px">
-                        <el-cascader
-                          :options="categoryOptions"
-                          v-model="selectedCategory"
-                          change-on-select
-                        ></el-cascader>
-                    </el-form-item>
-                    <el-form-item label="商铺图片" label-width="100px">
-                        <el-upload
-                          class="avatar-uploader"
-                          :action="baseUrl + '/v1/addimg/shop'"
-                          :show-file-list="false"
-                          :on-success="handleServiceAvatarScucess"
-                          :before-upload="beforeAvatarUpload">
-                          <img v-if="selectTable.image_path" :src="selectTable.image" class="avatar">
-                          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
-                        </el-upload>
-                    </el-form-item>
-                </el-form>
-              <div slot="footer" class="dialog-footer">
-                <el-button @click="dialogFormVisible = false">取 消</el-button>
-                <el-button type="primary" @click="updateShop">确 定</el-button>
-              </div>
-            </el-dialog>
-        </div>
-    </div>
+            <el-form-item label="详细地址" label-width="100px">
+              <el-autocomplete
+                v-model="address.address"
+                :fetch-suggestions="querySearchAsync"
+                placeholder="请输入地址"
+                style="width: 100%;"
+                @select="addressSelect"
+              ></el-autocomplete>
+              <span>当前城市:{{city.name}}</span>
+            </el-form-item>
+            <el-form-item label="店铺介绍" label-width="100px">
+              <el-input v-model="selectTable.description"></el-input>
+            </el-form-item>
+            <el-form-item label="联系电话" label-width="100px">
+              <el-input v-model="selectTable.phone"></el-input>
+            </el-form-item>
+            <el-form-item label="店铺分类" label-width="100px">
+              <el-cascader
+                :options="categoryOptions"
+                v-model="selectedCategory"
+                change-on-select
+              ></el-cascader>
+            </el-form-item>
+            <el-form-item label="商铺图片" label-width="100px">
+              <el-upload
+                class="avatar-uploader"
+                :action="fileMgrUrl + '/v1/addimg/shop'"
+                :show-file-list="false"
+                :on-success="handleServiceAvatarScucess"
+                :before-upload="beforeAvatarUpload">
+                <img v-if="selectTable.image_path" :src="selectTable.image" class="avatar">
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+              </el-upload>
+            </el-form-item>
+          </el-form>
+          <div slot="footer" class="dialog-footer">
+            <el-button @click="dialogFormVisible = false">取 消</el-button>
+            <el-button type="primary" @click="updateShop">确 定</el-button>
+          </div>
+        </el-dialog>
+
+      </div>
     </div>
   </div>
 </template>
@@ -136,47 +137,55 @@
 
 
 <style lang="less">
-    .demo-table-expand {
-        font-size: 0;
-    }
-    .demo-table-expand label {
-        width: 90px;
-        color: #99a9bf;
-    }
-    .demo-table-expand .el-form-item {
-        margin-right: 0;
-        margin-bottom: 0;
-        width: 50%;
-    }
-    .table_container{
-        padding: 20px;
-    }
-    .Pagination{
-        display: flex;
-        justify-content: flex-start;
-        margin-top: 8px;
-    }
-    .avatar-uploader .el-upload {
-        border: 1px dashed #d9d9d9;
-        border-radius: 6px;
-        cursor: pointer;
-        position: relative;
-        overflow: hidden;
-    }
-    .avatar-uploader .el-upload:hover {
-        border-color: #20a0ff;
-    }
-    .avatar-uploader-icon {
-        font-size: 28px;
-        color: #8c939d;
-        width: 120px;
-        height: 120px;
-        line-height: 120px;
-        text-align: center;
-    }
-    .avatar {
-        width: 120px;
-        height: 120px;
-        display: block;
-    }
+  .demo-table-expand {
+    font-size: 0;
+  }
+
+  .demo-table-expand label {
+    width: 90px;
+    color: #99a9bf;
+  }
+
+  .demo-table-expand .el-form-item {
+    margin-right: 0;
+    margin-bottom: 0;
+    width: 50%;
+  }
+
+  .table_container {
+    padding: 20px;
+  }
+
+  .Pagination {
+    display: flex;
+    justify-content: flex-start;
+    margin-top: 8px;
+  }
+
+  .avatar-uploader .el-upload {
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+  }
+
+  .avatar-uploader .el-upload:hover {
+    border-color: #20a0ff;
+  }
+
+  .avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 120px;
+    height: 120px;
+    line-height: 120px;
+    text-align: center;
+  }
+
+  .avatar {
+    width: 120px;
+    height: 120px;
+    display: block;
+  }
 </style>

+ 4 - 4
flash-waimai-manage/src/views/business/shop/shop.js

@@ -1,13 +1,13 @@
 import { getApiUrl } from '@/utils/utils'
+import { cityGuess } from '@/api/getData'
 import {
-  cityGuess,
   getResturants,
   getResturantsCount,
   foodCategory,
   updateResturant,
   searchplace,
   deleteResturant
-} from '@/api/getData'
+} from '@/api/business/shop'
 
 export default {
   data() {
@@ -17,7 +17,7 @@ export default {
       // offset: 0,
       // limit: 20,
       count: 0,
-      baseUrl: getApiUrl(),
+      fileMgrUrl: getApiUrl(),
       tableData: [],
       currentPage: 1,
       selectTable: {},
@@ -137,7 +137,7 @@ export default {
       }
     },
     addFood(index, row) {
-      this.$router.push({ path: 'addGoods', query: { restaurant_id: row.id } })
+      this.$router.push({ path: '/data/food/add', query: { restaurant_id: row.id }})
     },
     async handleDelete(index, row) {
       try {