yuhaitao14 7 years ago
parent
commit
89e157c164

+ 12 - 1
shop/src/main/java/com/zskk/shop/controller/admin/FAQController.java

@@ -34,6 +34,9 @@ public class FAQController extends AbstractController{
 	@ResponseBody
 	public ControllerResult all(@RequestParam("status") Integer status, @RequestParam("page") Integer page, @RequestParam("pageSize") Integer pageSize){
 		PageBean bean = new PageBean();
+		if (status == -1){
+			status = null;
+		}
 		bean.setList(faqService.queryAll(status, page, pageSize));
 		bean.setTotalCount(faqService.queryAllCount(status));
 		return new ControllerResult(bean);
@@ -57,7 +60,15 @@ public class FAQController extends AbstractController{
 		if (StringUtils.isBlank(question) || StringUtils.isBlank(answer)){
 			throw new ZSKKException(ErrorConstant.PARAM_ERROR);
 		}
-		faqService.save(this.getUser(), faq.getQuestion(), faq.getAnswer());
+		if (faq.getId() != null && !faq.getId().equals(0)){
+			FAQ old = faqService.queryFAQ(faq.getId());
+			if (old == null){
+				throw new ZSKKException(ErrorConstant.PARAM_ERROR);
+			}
+			faqService.update(old, faq.getAnswer(), faq.getQuestion(), faq.getStatus());
+		}else{
+			faqService.save(this.getUser(), faq.getQuestion(), faq.getAnswer());
+		}
 		return new ControllerResult(Boolean.TRUE);
 	}
 }

+ 1 - 1
shop/src/main/java/com/zskk/shop/controller/admin/GoodsManagerController.java

@@ -92,7 +92,7 @@ public class GoodsManagerController extends AbstractController{
 	 */
 	@RequestMapping("editbase")
 	@ResponseBody
-	public ControllerResult exitbase(GoodBase base, @RequestParam("price") BigDecimal price, @RequestParam("discountPrice") BigDecimal discountPrice){
+	public ControllerResult editbase(GoodBase base, @RequestParam("price") BigDecimal price, @RequestParam("discountPrice") BigDecimal discountPrice){
 		UserBean user = this.getUser();
 		goodService.saveGoodBase(user, base, price, discountPrice);
 		return new ControllerResult(Boolean.TRUE);

+ 3 - 3
shop/src/main/java/com/zskk/shop/dao/FAQMapper.java

@@ -10,14 +10,14 @@ package com.zskk.shop.dao;
 
 import java.util.List;
 
-import org.springframework.web.bind.annotation.RequestParam;
+import org.apache.ibatis.annotations.Param;
 
 import com.zskk.shop.dao.entry.FAQ;
 
 public interface FAQMapper {
-	List<FAQ> queryAll(@RequestParam("status") Integer status, @RequestParam("start") Integer start, @RequestParam("pageSize") Integer pageSize);
+	List<FAQ> queryAll(@Param("status") Integer status, @Param("start") Integer start, @Param("pageSize") Integer pageSize);
 	FAQ queryFAQ(Integer id);
-	Integer queryAllCount(@RequestParam("status") Integer status);
+	Integer queryAllCount(@Param("status") Integer status);
 	void add(FAQ faq);
 	int update(FAQ faq);
 }

+ 3 - 0
shop/static/manager/src/api/index.js

@@ -81,4 +81,7 @@ export default {
     setGoodLabels: (params, vue) => post(`${serverPath}manage/setGoodLabels`, params, vue),
     setRecommand: (params, vue) => post(`${serverPath}manage/setRecommand`, params, vue),
     getuser: (params, vue) => post(`${serverPath}/manage/muser/getuser`, params, vue),
+    getAllFaq: (params, vue) => post(`${serverPath}/manage/faq/all`, params, vue),
+    geFaq: (params, vue) => post(`${serverPath}/manage/faq/get`, params, vue),
+    saveFaq: (params, vue) => post(`${serverPath}/manage/faq/save`, params, vue),
 }

+ 1 - 0
shop/static/manager/src/components/Sidebar.vue

@@ -42,6 +42,7 @@ export default {
       items.push({ icon: '', index: '/goodsManager', title: '商品管理'})
       items.push({ icon: '', index: '/sysLabelManager', title: '系统标签'})
       items.push({ icon: '', index: '/manageUser', title: '用户管理'})
+      items.push({ icon: '', index: '/faqManage', title: '常见问题'})
       this.items  = items
       for (var i in items){
           var item = items[i]

+ 5 - 1
shop/static/manager/src/components/page/EditGoods.vue

@@ -95,10 +95,14 @@ export default {
   },
   mounted: function() {
     var gid = this.$route.query.gid
+    this.form.gid = gid;
+    if (gid === 0){
+      return;
+    }
+
     this.$http.getOneGood({gid:gid}, this).then(res=>{
         if (res.code === 0){
             var base = res.obj;
-            this.form.gid = base.gid;
             this.form.name = base.name
             this.form.describe = base.describe
             this.form.price = base.price.price

+ 5 - 0
shop/static/manager/src/components/page/GoodsManager.vue

@@ -19,6 +19,8 @@
             </el-col>
             <el-col :span="4">
                 <el-button type="primary" @click="getItems">查询</el-button>
+
+                <el-button type="primary" @click="goAdd">添加</el-button>
             </el-col>
         </el-row>
         <el-table :data="items">
@@ -174,6 +176,9 @@ export default {
     goBindPackage: function(row) {
       this.$router.push({ path: '/bindPackage', query: { gid: row.gid } })
     },
+    goAdd: function(){
+         this.$router.push({ path: '/editGoods', query: { gid: 0 } })
+    },
     setRecommand: function(row) {
       var msg = row.isRecommend
         ? '您是否要停止推荐此商品吗?'

+ 76 - 0
shop/static/manager/src/components/page/faq/EditFAQ.vue

@@ -0,0 +1,76 @@
+<template>
+    <el-form ref="form" :model="form" label-width="120px">
+        <el-form-item label="问题">
+            <el-input v-model="form.question"></el-input>
+        </el-form-item>
+        <el-form-item label="答案">
+            <el-input type="textarea" v-model="form.answer" :rows="3"></el-input>
+        </el-form-item>
+        <el-form-item label="标签状态">
+            <el-switch v-model="form.status" active-color="#13ce66" inactive-color="#ff4949">
+            </el-switch>
+        </el-form-item>
+        <el-form-item>
+            <el-button type="primary" @click="save">保存</el-button>
+            <el-button @click="goBack">取消</el-button>
+        </el-form-item>
+    </el-form>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      form: {
+        id: 0,
+        question: '',
+        answer: '',
+        status:true
+      }
+    }
+  },
+  methods: {
+    save: function() {
+      var param = {
+        id: this.form.id,
+        question: this.form.question,
+        answer: this.form.answer,
+        status: this.form.status? 1: 0
+      }
+      var that = this
+      this.$http.saveFaq(param, this).then(res => {
+        if (res.code === 0) {
+          this.$message({
+            message: '操作成功',
+            type: 'success',
+            duration: 1000,
+            onClose: function() {
+              that.goBack()
+            }
+          })
+        }
+      })
+    },
+    goBack: function() {
+      this.$router.back()
+    }
+  },
+  mounted: function() {
+    var id = this.$route.query.id
+    this.form.id = id
+    if (id === 0) {
+      return
+    }
+
+    this.$http.geFaq({ id: id }, this).then(res => {
+      if (res.code  === 0) {
+        this.form.question = res.obj.question
+        this.form.answer = res.obj.answer
+        this.form.status = res.obj.status === 1;
+      }
+    })
+  }
+}
+</script>
+<style>
+</style>

+ 90 - 0
shop/static/manager/src/components/page/faq/FAQManage.vue

@@ -0,0 +1,90 @@
+<template>
+    <div>
+        <el-select v-model="status">
+            <el-option value="-1" label="全部"></el-option>
+            <el-option value="1" label="在线"></el-option>
+            <el-option value="0" label="离线"></el-option>
+        </el-select>
+        <el-button type="primary" @click="getItems">查询</el-button>
+        <el-button type="primary" @click="goAdd">添加</el-button>
+        <el-table :data="items">
+            <el-table-column label="问题" prop="question"></el-table-column>
+            <el-table-column label="答案" prop="answer"></el-table-column>
+            <el-table-column label="状态">
+                <template slot-scope="scope">
+                    <template v-if="scope.row.status === 1">
+                        <p class="online">启用</p>
+                    </template>
+                    <template v-else>
+                        <p class="offline">禁用</p>
+                    </template>
+                </template>
+            </el-table-column>
+            <el-table-column label="操作">
+                <template slot-scope="scope">
+                    <el-button type="text" size="small" @click="goEdit(scope.row)">编辑</el-button>
+                </template>
+            </el-table-column>
+        </el-table>
+        <div class="page">
+            <el-pagination background layout="total, prev, pager, next,jumper" @current-change="nextPage" :total="totalCount">
+            </el-pagination>
+        </div>
+    </div>
+</template>
+<script>
+export default {
+  data() {
+    return {
+      items: [],
+      status: '-1',
+      page: 1,
+      pageSize: 20,
+      totalCount: 0
+    }
+  },
+  methods: {
+    goAdd: function() {
+        var row = {id:0}
+        this.goEdit(row)
+    },
+    getItems: function() {
+      this.$http
+        .getAllFaq(
+          { status: this.status, page: this.page, pageSize: this.pageSize },
+          this
+        )
+        .then(res => {
+          if (res.code === 0) {
+            this.items = res.obj.list
+            this.totalCount = res.obj.totalCount
+          }
+        })
+    },
+    nextPage: function(currentPage) {
+      this.page = currentPage
+      this.getItems()
+    },
+    goEdit: function(row) {
+      this.$router.push({ path: '/editFAQ', query: { id: row.id } })
+    }
+  },
+  mounted: function() {
+    this.getItems()
+  }
+}
+</script>
+
+<style>
+.page {
+  margin-top: 10px;
+  text-align: center;
+}
+.online {
+  color: #67c23a;
+}
+.offline {
+  color: #f56c6c;
+}
+</style>
+

+ 8 - 0
shop/static/manager/src/router/index.js

@@ -45,6 +45,14 @@ export default new Router({
                 {
                     path: '/bindPackage',
                     component: resolve => require(['../components/page/BindPackage'], resolve)
+                },
+                {
+                    path: '/faqManage',
+                    component: resolve => require(['../components/page/faq/FAQManage'], resolve)
+                },
+                {
+                    path: '/editFAQ',
+                    component: resolve => require(['../components/page/faq/EditFAQ'], resolve)
                 }
             ]
         },