ソースを参照

Add 商铺管理增加搜索功能

enilu 6 年 前
コミット
b541020ed1

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

@@ -14,6 +14,7 @@ import cn.enilu.flash.service.front.PositionService;
 import cn.enilu.flash.utils.BeanUtil;
 import cn.enilu.flash.utils.Lists;
 import cn.enilu.flash.utils.Maps;
+import cn.enilu.flash.utils.StringUtils;
 import cn.enilu.flash.utils.factory.Page;
 import cn.enilu.flash.utils.gps.Distance;
 import org.nutz.json.Json;
@@ -51,14 +52,18 @@ public class ShopController extends BaseController {
     @RequestMapping(value = "restaurants", method = RequestMethod.GET)
     public Object listShop(@RequestParam(value = "latitude", required = false) String latitude,
                            @RequestParam(value = "longitude", required = false) String longitude,
+                           @RequestParam(value="name",required = false) String name,
                            @RequestParam(value = "restaurant_category_ids[]",required = false) Long[] categoryIds) {
-        if (com.google.common.base.Strings.isNullOrEmpty(latitude) || "undefined".equals(latitude)
-                || com.google.common.base.Strings.isNullOrEmpty(longitude) || "undefined".equals(longitude)) {
+        Map<String,Object> params = Maps.newHashMap();
+        if(StringUtils.isNotEmpty(name)){
+            params.put("name",name);
+        }
+        if (StringUtils.isEmpty(latitude) || "undefined".equals(latitude)
+                || StringUtils.isEmpty(longitude) || "undefined".equals(longitude)) {
             Page<Shop> page = new PageFactory<Shop>().defaultPage();
-            return Rets.success(mongoRepository.queryPage(page, Shop.class));
+            return Rets.success(mongoRepository.queryPage(page, Shop.class,params));
         } else {
             //查询指定经纬度范围内的餐厅
-            Map<String,Object> params = Maps.newHashMap();
             if(categoryIds!=null&&categoryIds.length>0){
                 Map map = (Map) mongoRepository.findOne(categoryIds[0],"categories");
                 if(map!=null) {

+ 2 - 1
flash-waimai-api/src/main/resources/logback.xml

@@ -15,7 +15,8 @@
 	<!-- 向文件输出日志 -->
 	<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
 		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-			<fileNamePattern>/data/flash-waimai/runtime/log/api_%d{yyyy-MM-dd}.log</fileNamePattern>
+			<!-- <fileNamePattern>/data/flash-waimai/runtime/log/api_%d{yyyy-MM-dd}.log</fileNamePattern> -->
+			<fileNamePattern>/Users/maggie/flash-waimai/runtime/log/api_%d{yyyy-MM-dd}.log</fileNamePattern>
 			<maxHistory>1000</maxHistory>
 		</rollingPolicy>
 		<encoder>

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

@@ -1,6 +1,17 @@
 <template>
   <div class="app-container">
     <div class="block">
+      <el-row  :gutter="20">
+        <el-col :span="6">
+          <el-input v-model="listQuery.name" placeholder="店铺名称"></el-input>
+        </el-col>
+
+        <el-col :span="6">
+          <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>
       <div class="table_container">
         <el-table
           :data="tableData"
@@ -47,7 +58,7 @@
             label="店铺介绍"
             prop="description">
           </el-table-column>
-          <el-table-column label="操作" width="300">
+          <el-table-column label="操作" width="350">
             <template slot-scope="scope">
               <el-button
                 size="mini"
@@ -61,6 +72,11 @@
               </el-button>
               <el-button
                 size="mini"
+                type="info"
+                @click="viewFood(scope.$index, scope.row)">查看食品
+              </el-button>
+              <el-button
+                size="mini"
                 type="danger"
                 @click="handleDelete(scope.$index, scope.row)">删除
               </el-button>

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

@@ -29,7 +29,8 @@ export default {
       total: 0,
       listQuery: {
         page: 1,
-        limit: 20
+        limit: 20,
+        name:undefined
       }
     }
   },
@@ -82,7 +83,7 @@ export default {
     async fetchData() {
       const latitude = ''
       const longitude = ''
-      getResturants({ page: this.listQuery.page, limit: this.listQuery.limit }).then(response => {
+      getResturants(this.listQuery).then(response => {
         const restaurants = response.data.records
         this.total = response.data.total
         this.tableData = []
@@ -101,6 +102,14 @@ export default {
         })
       })
     },
+
+    search() {
+      this.fetchData()
+    },
+    reset() {
+      this.listQuery.name = ''
+      this.fetchData()
+    },
     handleSizeChange(val) {
       console.log(`每页 ${val} 条`)
     },
@@ -127,7 +136,7 @@ export default {
     },
     handleEdit(index, row) {
       this.selectTable = row
-      this.selectTable.image = getApiUrl() + '/file/getImgStream?fileName=' + row.image_path    
+      this.selectTable.image = getApiUrl() + '/file/getImgStream?fileName=' + row.image_path
       this.address.address = row.address
       this.dialogFormVisible = true
       this.selectedCategory = row.category.split('/')
@@ -138,6 +147,9 @@ export default {
     addFood(index, row) {
       this.$router.push({ path: '/data/food/add', query: { restaurant_id: row.id }})
     },
+    viewFood(index,row) {
+      this.$router.push({path:'/data/food',query:{restaurant_id:row.id}})
+    },
     async handleDelete(index, row) {
       try {
         const res = await deleteResturant(row.id)
@@ -181,7 +193,7 @@ export default {
     handleServiceAvatarScucess(res, file) {
       this.selectTable.image_path = res.data.realFileName
       this.selectTable.image =  getApiUrl() + '/file/getImgStream?fileName=' + res.data.realFileName
-      
+
     },
     beforeAvatarUpload(file) {
       const isRightType = (file.type === 'image/jpeg') || (file.type === 'image/png')
@@ -199,7 +211,7 @@ export default {
       this.dialogFormVisible = false
       try {
         Object.assign(this.selectTable, this.address)
-        this.selectTable.category = this.selectedCategory.join('/')         
+        this.selectTable.category = this.selectedCategory.join('/')
         updateResturant(this.selectTable).then(response => {
           this.$message({
             type: 'success',

+ 83 - 0
flash-waimai-mobile/src/page/msite/index.js

@@ -0,0 +1,83 @@
+
+import {mapMutations} from 'vuex'
+// import {imgBaseUrl} from 'src/config/env'
+import headTop from 'src/components/header/head'
+import footGuide from 'src/components/footer/footGuide'
+import shopList from 'src/components/common/shoplist'
+import {msiteAddress, msiteFoodTypes, cityGuess} from 'src/service/getData'
+import 'src/plugins/swiper.min.js'
+import 'src/style/swiper.min.css'
+
+export default {
+  data(){
+    return {
+      geohash: '', // city页面传递过来的地址geohash
+      msiteTitle: '请选择地址...', // msite页面头部标题
+      foodTypes: [], // 食品分类列表
+      hasGetData: false, //是否已经获取地理位置数据,成功之后再获取商铺列表信息
+      imgBaseUrl: 'https://fuss10.elemecdn.com', //图片域名地址
+    }
+  },
+  async beforeMount(){
+  if (!this.$route.query.geohash) {
+    const address = await cityGuess();
+    this.geohash = address.latitude + ',' + address.longitude;
+  }else{
+    this.geohash = this.$route.query.geohash
+  }
+  //保存geohash 到vuex
+  this.SAVE_GEOHASH(this.geohash);
+  //获取位置信息
+  let res = await msiteAddress(this.geohash);
+  this.msiteTitle = res.name;
+  // 记录当前经度纬度
+  this.RECORD_ADDRESS(res);
+
+  this.hasGetData = true;
+},
+mounted(){
+  //获取导航食品类型列表
+  msiteFoodTypes(this.geohash).then(res => {
+    console.log('res',res)
+  let resLength = res.length;
+  console.log(resLength)
+  let resArr = [...res]; // 返回一个新的数组
+  let foodArr = [];
+  for (let i = 0, j = 0; i < resLength; i += 8, j++) {
+    foodArr[j] = resArr.splice(0, 8);
+  }
+  this.foodTypes = foodArr;
+}).then(() => {
+    //初始化swiper
+    new Swiper('.swiper-container', {
+      pagination: '.swiper-pagination',
+      loop: true
+    });
+})
+},
+components: {
+  headTop,
+    shopList,
+    footGuide,
+},
+computed: {
+
+},
+methods: {
+...mapMutations([
+    'RECORD_ADDRESS', 'SAVE_GEOHASH'
+  ]),
+    // 解码url地址,求去restaurant_category_id值
+    getCategoryId(url){
+    let urlData = decodeURIComponent(url.split('=')[1].replace('&target_name',''));
+    if (/restaurant_category_id/gi.test(urlData)) {
+      return JSON.parse(urlData).restaurant_category_id.id
+    }else{
+      return ''
+    }
+  }
+},
+watch: {
+
+}
+}

+ 1 - 85
flash-waimai-mobile/src/page/msite/msite.vue

@@ -40,91 +40,7 @@
     </div>
 </template>
 
-<script>
-import {mapMutations} from 'vuex'
-// import {imgBaseUrl} from 'src/config/env'
-import headTop from 'src/components/header/head'
-import footGuide from 'src/components/footer/footGuide'
-import shopList from 'src/components/common/shoplist'
-import {msiteAddress, msiteFoodTypes, cityGuess} from 'src/service/getData'
-import 'src/plugins/swiper.min.js'
-import 'src/style/swiper.min.css'
-
-export default {
-	data(){
-        return {
-        	geohash: '', // city页面传递过来的地址geohash
-            msiteTitle: '请选择地址...', // msite页面头部标题
-            foodTypes: [], // 食品分类列表
-            hasGetData: false, //是否已经获取地理位置数据,成功之后再获取商铺列表信息
-            imgBaseUrl: 'https://fuss10.elemecdn.com', //图片域名地址
-        }
-    },
-    async beforeMount(){
-		if (!this.$route.query.geohash) {
-			const address = await cityGuess();
-			this.geohash = address.latitude + ',' + address.longitude;
-		}else{
-			this.geohash = this.$route.query.geohash
-		}
-		//保存geohash 到vuex
-		this.SAVE_GEOHASH(this.geohash);
-    	//获取位置信息
-    	let res = await msiteAddress(this.geohash);
-    	this.msiteTitle = res.name;
-    	// 记录当前经度纬度
-    	this.RECORD_ADDRESS(res);
-
-    	this.hasGetData = true;
-    },
-    mounted(){
-        //获取导航食品类型列表
-       	msiteFoodTypes(this.geohash).then(res => {
-       	  console.log('res',res)
-       		let resLength = res.length;
-       	  console.log(resLength)
-       		let resArr = [...res]; // 返回一个新的数组
-       		let foodArr = [];
-    		for (let i = 0, j = 0; i < resLength; i += 8, j++) {
-    			foodArr[j] = resArr.splice(0, 8);
-    		}
-    		this.foodTypes = foodArr;
-        }).then(() => {
-        	//初始化swiper
-        	new Swiper('.swiper-container', {
-		        pagination: '.swiper-pagination',
-		        loop: true
-		    });
-        })
-    },
-    components: {
-    	headTop,
-    	shopList,
-    	footGuide,
-    },
-    computed: {
-
-    },
-    methods: {
-    	...mapMutations([
-    		'RECORD_ADDRESS', 'SAVE_GEOHASH'
-    	]),
-    	// 解码url地址,求去restaurant_category_id值
-    	getCategoryId(url){
-    		let urlData = decodeURIComponent(url.split('=')[1].replace('&target_name',''));
-    		if (/restaurant_category_id/gi.test(urlData)) {
-    			return JSON.parse(urlData).restaurant_category_id.id
-    		}else{
-    			return ''
-    		}
-    	}
-    },
-    watch: {
-
-    }
-}
-
-</script>
+<script src="./index.js"></script>
 
 <style lang="scss" scoped>
     @import 'src/style/mixin';