Browse Source

Add 添加后台管理-订单管理功能

enilu 6 years ago
parent
commit
6aba7410c3

+ 15 - 0
flash-waimai-api/src/main/java/cn/enilu/flash/api/controller/business/AddressController.java

@@ -3,10 +3,15 @@ package cn.enilu.flash.api.controller.business;
 import cn.enilu.flash.api.controller.BaseController;
 import cn.enilu.flash.bean.entity.front.Address;
 import cn.enilu.flash.bean.entity.front.Ids;
+import cn.enilu.flash.bean.enumeration.BizExceptionEnum;
+import cn.enilu.flash.bean.exception.GunsException;
 import cn.enilu.flash.bean.vo.front.Rets;
 import cn.enilu.flash.dao.MongoRepository;
 import cn.enilu.flash.service.front.IdsService;
 import cn.enilu.flash.utils.Maps;
+import cn.enilu.flash.utils.ToolUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -20,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 public class AddressController extends BaseController {
+    private Logger logger = LoggerFactory.getLogger(AddressController.class);
     @Autowired
     private MongoRepository mongoRepository;
     @Autowired
@@ -41,4 +47,13 @@ public class AddressController extends BaseController {
         mongoRepository.delete("addresses", Maps.newHashMap("user_id",userId,"id",addressId));
         return Rets.success("删除地址成功");
     }
+
+    @RequestMapping(value="/address/{id}",method = RequestMethod.GET)
+    public Object get(@PathVariable Long id){
+        logger.info("id:{}",id);
+        if (ToolUtil.isEmpty(id)) {
+            throw new GunsException(BizExceptionEnum.REQUEST_NULL);
+        }
+         return Rets.success(mongoRepository.findOne(Address.class,id));
+    }
 }

+ 14 - 10
flash-waimai-api/src/main/java/cn/enilu/flash/api/controller/business/OrderController.java

@@ -7,11 +7,12 @@ import cn.enilu.flash.bean.vo.front.Rets;
 import cn.enilu.flash.dao.MongoRepository;
 import cn.enilu.flash.utils.Maps;
 import cn.enilu.flash.utils.factory.Page;
-
 import org.nutz.lang.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Map;
+
 /**
  * Created  on 2018/1/5 0005.
  *
@@ -26,7 +27,7 @@ public class OrderController extends BaseController {
     @RequestParam("offset")Integer offset){
         Page<Order> page = new PageFactory<Order>().defaultPage();
        return Rets.success(mongoRepository.queryPage(page, Order.class,Maps.newHashMap("user_id", userId)));
-        // return mongoRepository.findAll(Order.class,"user_id",userId);
+
 
     }
     @RequestMapping(value = "/bos/orders/count",method = RequestMethod.GET)
@@ -40,15 +41,18 @@ public class OrderController extends BaseController {
         return Rets.success("count",count);
     }
     @RequestMapping(value="/bos/orders",method = RequestMethod.GET)
-    public Object list(@RequestParam("restaurant_id") String restaurantId,
-                       @RequestParam(value = "offset", defaultValue = "0") Integer offset,
-                       @RequestParam(value = "limit", defaultValue = "20") Integer limit) {
-        restaurantId="11";
-        if (Strings.isBlank(restaurantId)||Strings.equals("undefined",restaurantId)){
-            return Rets.success(mongoRepository.findAll(Order.class,"restaurant_id",Long.valueOf(restaurantId)));
-        } else {
-            return Rets.success(mongoRepository.findAll(Order.class));
+    public Object list(@RequestParam(value = "restaurant_id",required = false) Long restaurantId,
+                       @RequestParam(value = "id",required = false) Long orderId) {
+        Page<Order> page =  new PageFactory<Order>().defaultPage();
+        Map<String,Object> params = Maps.newHashMap();
+        if (restaurantId!=null){
+            params.put("restaurant_id",restaurantId);
+        }
+        if (orderId!=null){
+            params.put("id",orderId);
         }
+        page = mongoRepository.queryPage(page,Order.class,params);
+        return Rets.success(page);
     }
 
 }

+ 1 - 1
flash-waimai-api/src/main/java/cn/enilu/flash/api/controller/business/User2Controller.java

@@ -49,7 +49,7 @@ public class User2Controller extends BaseController {
 
     @RequestMapping(method = RequestMethod.GET)
     public Object getUser(@RequestParam("user_id") Long userId) {
-        return getSession("currentUser");
+          return Rets.success(mongoRepository.findOne(FrontUser.class,"user_id",userId));
     }
 
     @RequestMapping(value = "/list", method = RequestMethod.GET)

+ 7 - 244
flash-waimai-core/src/main/java/cn/enilu/flash/bean/entity/front/Order.java

@@ -3,15 +3,18 @@ package cn.enilu.flash.bean.entity.front;
 import cn.enilu.flash.bean.entity.front.sub.OrderBasket;
 import cn.enilu.flash.bean.entity.front.sub.OrderStatusBar;
 import cn.enilu.flash.bean.entity.front.sub.OrderTimelineNode;
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
 import org.springframework.data.annotation.Id;
 import org.springframework.data.mongodb.core.mapping.Document;
 
 /**
  * Created  on 2018/1/5 0005.
- * todo 未完成
- * @author zt
+ *
+ * @author enilu
  */
 @Document(collection = "orders")
+@Data
 public class Order extends BaseMongoEntity {
     @Id
     private String _id;
@@ -45,252 +48,12 @@ public class Order extends BaseMongoEntity {
     private String restaurant_name;
     private Integer restaurant_type;
     private Integer status_code;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Double getTotal_amount() {
-        return total_amount;
-    }
-
-    public void setTotal_amount(Double total_amount) {
-        this.total_amount = total_amount;
-    }
-
-    public Double getTotal_quantity() {
-        return total_quantity;
-    }
-
-    public void setTotal_quantity(Double total_quantity) {
-        this.total_quantity = total_quantity;
-    }
-
-    public Long getUnique_id() {
-        return unique_id;
-    }
-
-    public void setUnique_id(Long unique_id) {
-        this.unique_id = unique_id;
-    }
-
-    public Long getUser_id() {
-        return user_id;
-    }
-
-    public void setUser_id(Long user_id) {
-        this.user_id = user_id;
-    }
-
-    public Long getAddress_id() {
-        return address_id;
-    }
-
-    public void setAddress_id(Long address_id) {
-        this.address_id = address_id;
-    }
-
-    public Integer getTop_show() {
-        return top_show;
-    }
-
-    public void setTop_show(Integer top_show) {
-        this.top_show = top_show;
-    }
-
-    public OrderBasket getBasket() {
-        return basket;
-    }
-
-    public void setBasket(OrderBasket basket) {
-        this.basket = basket;
-    }
-
-    public OrderStatusBar getStatus_bar() {
-        return status_bar;
-    }
-
-    public void setStatus_bar(OrderStatusBar status_bar) {
-        this.status_bar = status_bar;
-    }
-
-    public OrderTimelineNode getTimeline_node() {
-        return timeline_node;
-    }
-
-    public void setTimeline_node(OrderTimelineNode timeline_node) {
-        this.timeline_node = timeline_node;
-    }
-
-    public String getFormatted_create_at() {
-        return formatted_create_at;
-    }
-
-    public void setFormatted_create_at(String formatted_create_at) {
-        this.formatted_create_at = formatted_create_at;
-    }
-
-    public Double getOrder_time() {
-        return order_time;
-    }
-
-    public void setOrder_time(Double order_time) {
-        this.order_time = order_time;
-    }
-
-    public Integer getTime_pass() {
-        return time_pass;
-    }
-
-    public void setTime_pass(Integer time_pass) {
-        this.time_pass = time_pass;
-    }
-
-    public Integer getIs_brand() {
-        return is_brand;
-    }
-
-    public void setIs_brand(Integer is_brand) {
-        this.is_brand = is_brand;
-    }
-
-    public Integer getIs_deletable() {
-        return is_deletable;
-    }
-
-    public void setIs_deletable(Integer is_deletable) {
-        this.is_deletable = is_deletable;
-    }
-
-    public Integer getIs_new_pay() {
-        return is_new_pay;
-    }
-
-    public void setIs_new_pay(Integer is_new_pay) {
-        this.is_new_pay = is_new_pay;
-    }
-
-    public Integer getIs_pindan() {
-        return is_pindan;
-    }
-
-    public void setIs_pindan(Integer is_pindan) {
-        this.is_pindan = is_pindan;
-    }
-
-    public Integer getOperation_confirm() {
-        return operation_confirm;
-    }
-
-    public void setOperation_confirm(Integer operation_confirm) {
-        this.operation_confirm = operation_confirm;
-    }
-
-    public Integer getOperation_rate() {
-        return operation_rate;
-    }
-
-    public void setOperation_rate(Integer operation_rate) {
-        this.operation_rate = operation_rate;
-    }
-
-    public Integer getOperation_rebuy() {
-        return operation_rebuy;
-    }
-
-    public void setOperation_rebuy(Integer operation_rebuy) {
-        this.operation_rebuy = operation_rebuy;
-    }
-
-    public Integer getOperation_upload_photo() {
-        return operation_upload_photo;
-    }
-
-    public void setOperation_upload_photo(Integer operation_upload_photo) {
-        this.operation_upload_photo = operation_upload_photo;
-    }
-
-    public Integer getPay_remain_seconds() {
-        return pay_remain_seconds;
-    }
-
-    public void setPay_remain_seconds(Integer pay_remain_seconds) {
-        this.pay_remain_seconds = pay_remain_seconds;
-    }
-
-    public Integer getRated_point() {
-        return rated_point;
-    }
-
-    public void setRated_point(Integer rated_point) {
-        this.rated_point = rated_point;
-    }
-
-    public Integer getRemind_reply_count() {
-        return remind_reply_count;
-    }
-
-    public void setRemind_reply_count(Integer remind_reply_count) {
-        this.remind_reply_count = remind_reply_count;
-    }
-
+    @JSONField(name="_id")
     public String get_id() {
         return _id;
     }
-
+    @JSONField(name="_id")
     public void set_id(String _id) {
         this._id = _id;
     }
-
-    public Long getRestaurant_id() {
-        return restaurant_id;
-    }
-
-    public void setRestaurant_id(Long restaurant_id) {
-        this.restaurant_id = restaurant_id;
-    }
-
-    public String getRestaurant_image_hash() {
-        return restaurant_image_hash;
-    }
-
-    public void setRestaurant_image_hash(String restaurant_image_hash) {
-        this.restaurant_image_hash = restaurant_image_hash;
-    }
-
-    public String getRestaurant_image_url() {
-        return restaurant_image_url;
-    }
-
-    public void setRestaurant_image_url(String restaurant_image_url) {
-        this.restaurant_image_url = restaurant_image_url;
-    }
-
-    public String getRestaurant_name() {
-        return restaurant_name;
-    }
-
-    public void setRestaurant_name(String restaurant_name) {
-        this.restaurant_name = restaurant_name;
-    }
-
-    public Integer getRestaurant_type() {
-        return restaurant_type;
-    }
-
-    public void setRestaurant_type(Integer restaurant_type) {
-        this.restaurant_type = restaurant_type;
-    }
-
-    public Integer getStatus_code() {
-        return status_code;
-    }
-
-    public void setStatus_code(Integer status_code) {
-        this.status_code = status_code;
-    }
 }

+ 9 - 221
flash-waimai-core/src/main/java/cn/enilu/flash/bean/entity/front/Shop.java

@@ -1,6 +1,8 @@
 package cn.enilu.flash.bean.entity.front;
 
 import cn.enilu.flash.utils.Lists;
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
 import org.springframework.data.annotation.Id;
 import org.springframework.data.mongodb.core.mapping.Document;
 
@@ -14,6 +16,7 @@ import java.util.Map;
  * @author zt
  */
 @Document(collection = "shops")
+@Data
 public class Shop extends BaseMongoEntity {
     @Id
     private String _id;
@@ -49,228 +52,13 @@ public class Shop extends BaseMongoEntity {
     private Map delivery_mode;
     private List activities;
 
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getAddress() {
-        return address;
-    }
-
-    public void setAddress(String address) {
-        this.address = address;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Double getLatitude() {
-        return latitude;
-    }
-
-    public void setLatitude(Double latitude) {
-        this.latitude = latitude;
-    }
-
-    public Double getLongitude() {
-        return longitude;
-    }
-
-    public void setLongitude(Double longitude) {
-        this.longitude = longitude;
-    }
-
-    public List getLocation() {
-        return location;
+    @JSONField(name="_id")
+    public String get_id() {
+        return _id;
     }
-
-    public void setLocation(List location) {
-        this.location = location;
-    }
-
-    public String getPhone() {
-        return phone;
-    }
-
-    public void setPhone(String phone) {
-        this.phone = phone;
-    }
-
-    public String getCategory() {
-        return category;
+    @JSONField(name="_id")
+    public void set_id(String _id) {
+        this._id = _id;
     }
 
-    public void setCategory(String category) {
-        this.category = category;
-    }
-
-    public List getSupports() {
-        return supports;
-    }
-
-    public void setSupports(List supports) {
-        this.supports = supports;
-    }
-
-    public Integer getStatus() {
-        return status;
-    }
-
-    public void setStatus(Integer status) {
-        this.status = status;
-    }
-
-    public Integer getRecent_order_num() {
-        return recent_order_num;
-    }
-
-    public void setRecent_order_num(Integer recent_order_num) {
-        this.recent_order_num = recent_order_num;
-    }
-
-    public Integer getRating_count() {
-        return rating_count;
-    }
-
-    public void setRating_count(Integer rating_count) {
-        this.rating_count = rating_count;
-    }
-
-    public Double getRating() {
-        return rating;
-    }
-
-    public void setRating(Double rating) {
-        this.rating = rating;
-    }
-
-    public String getPromotion_info() {
-        return promotion_info;
-    }
-
-    public void setPromotion_info(String promotion_info) {
-        this.promotion_info = promotion_info;
-    }
-
-    public Map getPiecewise_agent_fee() {
-        return piecewise_agent_fee;
-    }
-
-    public void setPiecewise_agent_fee(Map piecewise_agent_fee) {
-        this.piecewise_agent_fee = piecewise_agent_fee;
-    }
-
-    public List getOpening_hours() {
-        return opening_hours;
-    }
-
-    public void setOpening_hours(List opening_hours) {
-        this.opening_hours = opening_hours;
-    }
-
-    public Map getLicense() {
-        return license;
-    }
-
-    public void setLicense(Map license) {
-        this.license = license;
-    }
-
-    public Boolean getIs_new() {
-        return is_new;
-    }
-
-    public void setIs_new(Boolean is_new) {
-        this.is_new = is_new;
-    }
-
-    public String getIs_premium() {
-        return is_premium;
-    }
-
-    public void setIs_premium(String is_premium) {
-        this.is_premium = is_premium;
-    }
-
-    public String getImage_path() {
-        return image_path;
-    }
-
-    public void setImage_path(String image_path) {
-        this.image_path = image_path;
-    }
-
-    public Map getIdentification() {
-        return identification;
-    }
-
-    public void setIdentification(Map identification) {
-        this.identification = identification;
-    }
-
-    public String getFloat_minimum_order_amount() {
-        return float_minimum_order_amount;
-    }
-
-    public void setFloat_minimum_order_amount(String float_minimum_order_amount) {
-        this.float_minimum_order_amount = float_minimum_order_amount;
-    }
-
-    public String getFloat_delivery_fee() {
-        return float_delivery_fee;
-    }
-
-    public void setFloat_delivery_fee(String float_delivery_fee) {
-        this.float_delivery_fee = float_delivery_fee;
-    }
-
-    public String getDistance() {
-        return distance;
-    }
-
-    public void setDistance(String distance) {
-        this.distance = distance;
-    }
-
-    public String getOrder_lead_time() {
-        return order_lead_time;
-    }
-
-    public void setOrder_lead_time(String order_lead_time) {
-        this.order_lead_time = order_lead_time;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public Map getDelivery_mode() {
-        return delivery_mode;
-    }
-
-    public void setDelivery_mode(Map delivery_mode) {
-        this.delivery_mode = delivery_mode;
-    }
-
-    public List getActivities() {
-        return activities;
-    }
-
-    public void setActivities(List activities) {
-        this.activities = activities;
-    }
 }

+ 7 - 1
flash-waimai-core/src/main/java/cn/enilu/flash/dao/MongoRepository.java

@@ -79,7 +79,13 @@ public class MongoRepository {
     public <T, P> T findOne(Class<T> klass, P key) {
         return findOne(klass, "id", key);
     }
-
+    public <T> T findOne(Class<T> klass, Map<String,Object> params) {
+        Criteria criteria = criteria(params);
+        if (criteria == null) {
+            return mongoTemplate.findOne(Query.query(criteria), klass);
+        }
+        return null;
+    }
     public <T> T findOne(Class<T> klass, String key, Object value) {
         return mongoTemplate.findOne(Query.query(Criteria.where(key).is(value)), klass);
     }

+ 8 - 0
flash-waimai-manage/src/api/business/address.js

@@ -0,0 +1,8 @@
+import request from '@/utils/request'
+
+export function getAddressById(id) {
+  return request({
+    url: '/address/'+id,
+    method: 'get'
+  })
+}

+ 9 - 0
flash-waimai-manage/src/api/business/order.js

@@ -0,0 +1,9 @@
+import request from '@/utils/request'
+
+export function getList(params) {
+  return request({
+    url: '/bos/orders',
+    method: 'get',
+    params
+  })
+}

+ 9 - 0
flash-waimai-manage/src/api/business/user.js

@@ -0,0 +1,9 @@
+import request from '@/utils/request'
+
+export function getUserInfo(id) {
+  return request({
+    url: '/v1/users',
+    method: 'get',
+    params:{user_id:id}
+  })
+}

+ 68 - 171
flash-waimai-manage/src/views/business/order/index.vue

@@ -1,182 +1,79 @@
 <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">
+      <el-row  :gutter="24">
+        <el-col :span="4">
+          <el-input v-model="listQuery.restaurant_id" placeholder="餐厅id"></el-input>
+        </el-col>
+        <el-col :span="4">
+          <el-input v-model="listQuery.id" placeholder="订单ID"></el-input>
+        </el-col>
 
-                    <el-form-item label="店铺名称" label-width="100px">
-                        <el-input v-model="selectTable.name" auto-complete="off"></el-input>
-                    </el-form-item>
+        <el-col :span="8">
+          <el-button type="success" icon="el-icon-search" @click.native="search">{{ $t('button.search') }}</el-button>
+          <el-button type="primary" icon="el-icon-refresh" @click.native="reset">{{ $t('button.reset') }}</el-button>
+        </el-col>
+      </el-row>
+      <br>
 
-                    <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>
     </div>
+
+    <el-table :data="list" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row
+              @expand-change="expandRow"
+              :expand-row-keys="expandRowData"
+              :row-key="getRowKeys">
+      <el-table-column type="expand">
+        <template slot-scope="props">
+          <el-form label-position="left" inline class="guns-table-expand">
+            <el-form-item label="用户名" >
+              <span>{{ props.row.user_name }}</span>
+            </el-form-item>
+            <el-form-item label="店铺名称">
+              <span>{{ props.row.restaurant_name }}</span>
+            </el-form-item>
+            <el-form-item label="收货地址">
+              <span>{{ props.row.address }}</span>
+            </el-form-item>
+            <el-form-item label="店铺 ID">
+              <span>{{ props.row.restaurant_id }}</span>
+            </el-form-item>
+            <el-form-item label="店铺地址">
+              <span>{{ props.row.restaurant_address }}</span>
+            </el-form-item>
+          </el-form>
+        </template>
+      </el-table-column>
+
+      <el-table-column
+        label="订单id"
+        prop="id">
+      </el-table-column>
+      <el-table-column
+        label="总价格"
+        prop="total_amount">
+      </el-table-column>
+      <el-table-column
+        label="状态"
+        prop="status_bar.title">
+      </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>
+
   </div>
 </template>
 
 <script src="./order.js"></script>
-
-
-<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;
-    }
+<style rel="stylesheet/scss" lang="scss" scoped>
+  @import "src/styles/common.scss";
 </style>

+ 97 - 224
flash-waimai-manage/src/views/business/order/order.js

@@ -1,240 +1,113 @@
-import { getApiUrl } from '@/utils/utils'
-import {baseUrl, baseImgPath} from '@/config/env'
-import {cityGuess, getResturants, getResturantsCount, foodCategory, updateResturant, searchplace, deleteResturant} from '@/api/getData'
+import { getList } from '@/api/business/order'
+import { getResturantDetail } from '@/api/business/shop'
+import { getUserInfo } from '@/api/business/user'
+import { getAddressById } from '@/api/business/address'
+
 export default {
-  data(){
+  data() {
     return {
-      baseUrl,
-      baseImgPath,
-      city: {},
-
-      // offset: 0,
-      // limit: 20,
-      count: 0,
-      tableData: [],
-      currentPage: 1,
-      selectTable: {},
-      dialogFormVisible: false,
-      categoryOptions: [],
-      selectedCategory: [],
-      address: {},
-      total:0,
       listQuery: {
         page: 1,
-        limit: 20
+        limit: 20,
+        id: undefined,
+        restaurant_id:undefined
       },
+      total: 0,
+      list: null,
+      listLoading: true,
+      selRow: {},
+      expandRowData: []
     }
   },
-  created(){
-    this.initData();
+  created() {
+    this.init()
   },
-
   methods: {
-    async initData(){
-  try{
-    cityGuess().then(response =>{
-      console.log('city',response)
-      this.city = response.data
-      console.log(this.city)
-      getResturantsCount().then(response2 => {
-        console.log(response2)
-        this.count = response2.count;
-    this.fetchData();
-  })
-  });
+    init() {
+      this.fetchData()
+    },
+    fetchData() {
+      this.list = []
+      this.listLoading = true
+      getList(this.listQuery).then(response => {
+        let list = response.data.records
+        list.forEach((item,index) =>{
+            item.index = index
+        })
+        this.list = list
+        console.log('list',list)
+        this.listLoading = false
+        this.total = response.data.total
+      })
+    },
+    search() {
+      this.fetchData()
+    },
+    reset() {
+      this.listQuery.id = ''
+      this.listQuery.restaurant_id = ''
+      this.fetchData()
+    },
+    async expandRow(row, status){
+      if(status.length>0) {
+        const restaurant = await getResturantDetail(row.restaurant_id);
+        const userInfo = await getUserInfo(row.user_id);
+        const addressInfo = await getAddressById(row.address_id);
+        this.list.splice(row.index, 1, {
+          ...row, ...{
+            restaurant_name: restaurant.data.name,
+            restaurant_address: restaurant.data.address,
+            address: addressInfo.data.address,
+            user_name: userInfo.data.username
+          }
+        });
+        this.expandRowData = []
+        this.expandRowData.push(row.index);
+      }else{
+        this.expandRowData = []
+      }
 
-    // const countData = await getResturantsCount();
 
-  }catch(err){
-    console.log('获取数据失败', err);
-  }
-},
-async getCategory(){
-  try{
-    const response = await foodCategory();
-    const categories = response.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 fetchData(){
-  console.log(111)
-  console.log(this.city)
-  // const {latitude, longitude} = this.city;
-  const latitude = ''
-  const longitude = ''
-  getResturants({page: this.listQuery.page, limit: this.listQuery.limit}).then( response=> {
-    console.log(response)
-    const restaurants = response.data.records
-    this.total = response.data.total
-    this.tableData = [];
-  restaurants.forEach(item => {
-    const tableData = {};
-  tableData.name = item.name;
-  tableData.address = item.address;
-  tableData.description = item.description;
-  tableData.id = item.id;
-  tableData.phone = item.phone;
-  tableData.rating = item.rating;
-  tableData.recent_order_num = item.recent_order_num;
-  tableData.category = item.category;
-  tableData.image_path = item.image_path;
-  this.tableData.push(tableData);
-})
-})
-  // const restaurants = await getResturants({latitude, longitude, page: this.listQuery.page, limit: this.listQuery.limit});
-  // this.tableData = [];
-  // restaurants.forEach(item => {
-  //     const tableData = {};
-  //     tableData.name = item.name;
-  //     tableData.address = item.address;
-  //     tableData.description = item.description;
-  //     tableData.id = item.id;
-  //     tableData.phone = item.phone;
-  //     tableData.rating = item.rating;
-  //     tableData.recent_order_num = item.recent_order_num;
-  //     tableData.category = item.category;
-  //     tableData.image_path = item.image_path;
-  //     this.tableData.push(tableData);
-  // })
-},
-handleSizeChange(val) {
-  console.log(`每页 ${val} 条`);
-},
-handleCurrentChange(val) {
-  this.currentPage = val;
-  this.offset = (val - 1)*this.limit;
-  this.getResturants()
-},
-fetchNext() {
-  this.listQuery.page = this.listQuery.page + 1
-  this.fetchData()
-},
-fetchPrev() {
-  this.listQuery.page = this.listQuery.page - 1
-  this.fetchData()
-},
-fetchPage(page) {
-  this.listQuery.page = page
-  this.fetchData()
-},
-changeSize(limit) {
-  this.listQuery.limit = limit
-  this.fetchData()
-},
-handleEdit(index, row) {
-  this.selectTable = row;
-  this.selectTable.image = getApiUrl() + '/file/getImgStream?fileName=' + row.image_path
-  console.log(this.selectTable)
-  this.address.address = row.address;
-  this.dialogFormVisible = true;
-  this.selectedCategory = row.category.split('/');
-  if (!this.categoryOptions.length) {
-    this.getCategory();
-  }
-},
-addFood(index, row){
-  this.$router.push({ path: 'addGoods', query: { restaurant_id: row.id }})
-},
-async handleDelete(index, row) {
-  try{
-    const res = await deleteResturant(row.id);
-    if (res.status == 1) {
-      this.$message({
-        type: 'success',
-        message: '删除店铺成功'
-      });
-      this.tableData.splice(index, 1);
-    }else{
-      throw new Error(res.message)
-    }
-  }catch(err){
-    this.$message({
-      type: 'error',
-      message: err.message
-    });
-    console.log('删除店铺失败')
-  }
-},
-async querySearchAsync(queryString, cb) {
-  if (queryString) {
-    try{
-      const cityList = await searchplace(this.city.id, queryString);
-      if (cityList instanceof Array) {
-        cityList.map(item => {
-          item.value = item.address;
-        return item;
+    },
+    getRowKeys(row){
+      return row.index
+    },
+    handleFilter() {
+      this.listQuery.page = 1
+      this.getList()
+    },
+    fetchNext() {
+      this.listQuery.page = this.listQuery.page + 1
+      this.fetchData()
+    },
+    fetchPrev() {
+      this.listQuery.page = this.listQuery.page - 1
+      this.fetchData()
+    },
+    fetchPage(page) {
+      this.listQuery.page = page
+      this.fetchData()
+    },
+    changeSize(limit) {
+      this.listQuery.limit = limit
+      this.fetchData()
+    },
+    clear() {
+      this.$confirm('确定清空数据?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        clear().then(response => {
+          this.$message({
+            message: '清空成功',
+            type: 'sucess'
+          })
+          this.fetchData()
+        })
+      }).catch(() => {
       })
-        cb(cityList)
-      }
-    }catch(err){
-      console.log(err)
     }
-  }
-},
-addressSelect(vale){
-  const {address, latitude, longitude} = vale;
-  this.address = {address, latitude, longitude};
-},
-handleServiceAvatarScucess(res, file) {
-  if (res.status == 1) {
-    this.selectTable.image_path = res.image_path;
-  }else{
-    this.$message.error('上传图片失败!');
-  }
-},
-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;
-},
-async updateShop(){
-  this.dialogFormVisible = false;
-  try{
-    Object.assign(this.selectTable, this.address);
-    this.selectTable.category = this.selectedCategory.join('/');
-    console.log(this.selectTable)
-    updateResturant(this.selectTable).then( response=> {
-        this.$message({
-          type: 'success',
-          message: '更新店铺信息成功'
-     });
-     this.getResturants();
-    })
 
-  }catch(err){
-    console.log('更新餐馆信息失败', err);
-    this.$message({
-      type: 'error',
-      message: err
-    });
   }
-},
-},
 }

+ 2 - 2
flash-waimai-manage/src/views/dashboard/index.vue

@@ -9,9 +9,9 @@
             <svg-icon  icon-class="documentation" ></svg-icon>
           </el-col>
           <el-col :span="12" >
-            <div class="card-panel-text">{{ $t('dashboard.document') }}</div>
+            <div class="card-panel-text">进驻商家</div>
             <div class="card-panel-num">
-              <a href="http://enilu.github.io/web-flash" target="_blank">Document</a>
+              8000
             </div>
           </el-col>
         </el-card>