Selaa lähdekoodia

后台商品管理优化

lex-xin 4 vuotta sitten
vanhempi
commit
21e767ea82

+ 3 - 0
src/router/notKeepAliveList.js

@@ -51,4 +51,7 @@ export default [
   '/insideSetting/helpContent', // 帮助中心
   '/insideSetting/helpCategory', // 帮助中心分类
   '/shopManager/shopManager', // 商品管理
+  '/shopManager/shopOperation', // 商品详情
+  '/shopManager/purchaseLlist', // 进货清单
+  '/shopManager/shopCategory',
 ]

+ 28 - 31
src/views/businessManager/shopManager/purchase-llist.vue

@@ -8,9 +8,11 @@
       <el-button v-permission="'goods/addGoodsProcurement'"
                  type="primary"
                  @click="editVisible = true">新增</el-button>
-      <el-form inline
+      <save-form inline
                class="searchForm"
-               v-model="searchForm"
+               :model="searchForm"
+               @submit="search"
+               @reset="onReSet"
                style="margin-top: 20px">
         <el-form-item>
           <el-input clearable
@@ -30,12 +32,10 @@
           </el-date-picker>
         </el-form-item>
         <el-form-item>
-          <el-button @click="search"
-                     type="danger">搜索</el-button>
-          <el-button @click="onReSet"
-                     type="primary">重置</el-button>
+          <el-button native-type="submit" type="danger">搜索</el-button>
+          <el-button native-type="reset" type="primary">重置</el-button>
         </el-form-item>
-      </el-form>
+      </save-form>
       <div class="tableWrap">
         <el-table :data="tableList"
                   style="width: 100%"
@@ -112,8 +112,8 @@ import dayjs from 'dayjs'
 import purchaseForm from './purchase-form'
 import { getGoodsProcurements } from '@/api/businessManager'
 const initSearchForm = {
-  startTime: null,
-  endTime: null,
+  enterStorageStartTime: null,
+  enterStorageEndTime: null,
   search: '',
 }
 
@@ -142,38 +142,39 @@ export default {
       orderDate: []
     }
   },
-  activated () {
-    this.init()
-  },
   mounted () {
     this.init()
   },
   methods: {
     init () {
-      this.orderDate = [
-        dayjs().format('YYYY-MM-DD'),
-        dayjs().format('YYYY-MM-DD'),
-      ]
+      const searchForm = this.searchForm
+      // 判断是否在默认值
+      if(!searchForm.enterStorageStartTime) {
+        this.orderDate = [
+          dayjs().format('YYYY-MM-DD'),
+          dayjs().format('YYYY-MM-DD'),
+        ]
+        searchForm.enterStorageStartTime = this.orderDate[0]
+        searchForm.enterStorageEndTime = this.orderDate[1]
+      } else {
+        this.orderDate = [
+          searchForm.enterStorageStartTime,
+          searchForm.enterStorageEndTime
+        ]
+      }
       let query = this.$route.query
       this.goodsId = query.goodsId
       this.goodsName = query.name
-      if (query.search) {
-        this.Fsearch = query.search;
-      }
-      if (query.pageInfo) {
-        this.Frules = query.pageInfo
-      }
       this.getList()
     },
     searchOrderDate (val) {
-      console.log(val)
+      this.searchForm.enterStorageStartTime = (val ? val[0] : '')
+      this.searchForm.enterStorageEndTime = (val ? val[1] : '')
     },
     getList () {
       const form = {
         ...this.searchForm,
-        goodsId: this.goodsId,
-        enterStorageStartTime: (this.orderDate ? this.orderDate[0] : ''),
-        enterStorageEndTime: (this.orderDate ? this.orderDate[1] : ''),
+        goodsId: this.goodsId
       }
       getGoodsProcurements({
         rows: this.pageInfo.limit,
@@ -189,11 +190,7 @@ export default {
     },
     onCancel () {
       this.$router.push({
-        path: '/shopManager/shopManager',
-        query: {
-          pageInfo: this.Frules,
-          searchForm: this.Fsearch
-        }
+        path: '/shopManager/shopManager'
       })
     },
     onReSet () {

+ 1 - 13
src/views/businessManager/shopManager/shopCategory.vue

@@ -34,7 +34,7 @@
             </template>
           </el-table-column>
         </el-table>
-        <pagination :total="pageInfo.total"
+        <pagination sync :total.sync="pageInfo.total"
                     :page.sync="pageInfo.page"
                     :limit.sync="pageInfo.limit"
                     :page-sizes="pageInfo.page_size"
@@ -239,18 +239,6 @@ export default {
 }
 </script>
 <style lang="scss" scoped>
-.el-button--primary {
-  background: #14928a;
-  border-color: #14928a;
-  color: #fff;
-  &:hover,
-  &:active,
-  &:focus {
-    background: #14928a;
-    border-color: #14928a;
-    color: #fff;
-  }
-}
 /deep/.el-date-editor.el-input {
   width: 100% !important;
 }

+ 30 - 51
src/views/businessManager/shopManager/shopList.vue

@@ -25,14 +25,17 @@
                  permission="'goods/update'"
                  @click="onShopComAdd">添加组合商品</el-button>
       <!-- 搜索类型 -->
-      <el-form :inline="true"
+      <save-form :inline="true"
                class="searchForm"
-               v-model.trim="searchForm">
-        <el-form-item>
-          <el-input v-model.trim="searchForm.search"
+               ref="searchForm"
+               @submit="onSearch"
+               @reset="onReset"
+               :model="searchForm">
+        <el-form-item prop="search">
+          <el-input v-model.trim="searchForm.search" clearable
                     placeholder="商品编号/货号/商品名称"></el-input>
         </el-form-item>
-        <el-form-item>
+        <el-form-item prop="type">
           <el-select v-model.trim="searchForm.type"
                      clearable
                      placeholder="商品类型">
@@ -42,7 +45,7 @@
                        :value="item.value"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item>
+        <el-form-item prop="goodsCategoryId">
           <el-select v-model.trim="searchForm.goodsCategoryId"
                      clearable
                      placeholder="商品分类">
@@ -52,7 +55,7 @@
                        :value="item.value"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item>
+        <el-form-item prop="status">
           <el-select v-model.trim="searchForm.status"
                      clearable
                      placeholder="是否是上架">
@@ -62,7 +65,7 @@
                        value="0"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item>
+        <el-form-item prop="groupGoods">
           <el-select v-model.trim="searchForm.groupGoods"
                      clearable
                      placeholder="是否是组合商品">
@@ -72,7 +75,7 @@
                        value="0"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item>
+        <el-form-item prop="clientShow">
           <el-select v-model.trim="searchForm.clientShow"
                      clearable
                      placeholder="学生端是否是展示">
@@ -82,7 +85,7 @@
                        value="0"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item>
+        <el-form-item prop="educationalShow">
           <el-select v-model.trim="searchForm.educationalShow"
                      clearable
                      placeholder="教务端是否是展示">
@@ -92,7 +95,7 @@
                        value="0"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item>
+        <el-form-item prop="musicGroupShow">
           <el-select v-model.trim="searchForm.musicGroupShow"
                      clearable
                      placeholder="乐团是否是展示">
@@ -108,12 +111,10 @@
             end-placeholder="结束日期"></el-date-picker>
         </el-form-item> -->
         <el-form-item>
-          <el-button type="danger"
-                     @click="onSearch">搜索</el-button>
-          <el-button type="primary"
-                     @click="onReset">重置</el-button>
+          <el-button type="danger" native-type="submit">搜索</el-button>
+          <el-button type="primary" native-type="reset">重置</el-button>
         </el-form-item>
-      </el-form>
+      </save-form>
       <!-- 列表 -->
       <div class="tableWrap">
         <el-table :data='tableList'
@@ -300,7 +301,7 @@
             </template>
           </el-table-column>
         </el-table>
-        <pagination :total="pageInfo.total"
+        <pagination sync :total.sync="pageInfo.total"
                     :page.sync="pageInfo.page"
                     :limit.sync="pageInfo.limit"
                     :page-sizes="pageInfo.page_size"
@@ -728,28 +729,14 @@ export default {
       selectGoodsList: []
     }
   },
-  created () {
-    this.init()
-  },
-  activated () {
-    this.init()
-  },
   mounted () {
-
+    this.init()
   },
   methods: {
     permission (str) {
       return permission(str);
     },
     init () {
-      if (this.$route.query.searchForm) {
-        this.$route.query.searchForm instanceof Object ? this.searchForm = this.$route.query.searchForm : this.searchForm =
-          JSON.parse(this.$route.query.searchForm);
-      }
-      if (this.$route.query.pageInfo) {
-        this.$route.query.pageInfo instanceof Object ? this.pageInfo = this.$route.query.pageInfo : this.pageInfo =
-          JSON.parse(this.$route.query.pageInfo);
-      }
       this.getList()
       this.getCategory()
     },
@@ -789,15 +776,11 @@ export default {
       });
     },
     onPurchaseList (row) {
-      let pageInfo = JSON.stringify(this.pageInfo)
-      let search = JSON.stringify(this.searchForm)
       this.$router.push({
         path: '/shopManager/purchaseLlist',
         query: {
           name: row.name,
-          goodsId: row.id,
-          pageInfo,
-          search
+          goodsId: row.id
         }
       })
     },
@@ -860,15 +843,7 @@ export default {
       this.getList()
     },
     onReset () { // 重置
-      this.searchForm = {
-        search: null,
-        groupGoods: null,
-        type: null,
-        status: null,
-        goodsCategoryId: null,
-        startTime: null,
-        endTime: null
-      }
+      this.$refs.searchForm.resetFields()
       this.getList()
     },
     onShopComAdd () {
@@ -925,8 +900,6 @@ export default {
       if (row) {
         params.id = row.id
       }
-      let pageInfo = JSON.stringify(this.pageInfo)
-      let searchForm = JSON.stringify(this.searchForm)
       let paramInfo = JSON.stringify(params)
       this.addType = type
       this.addDisabled = type == 'look' ? true : false
@@ -951,13 +924,19 @@ export default {
         this.onValidGoodsStatus()
         this.getAllGoodsList()
       } else {
+        let pageTitle = '添加'
+        if(type == 'update') {
+          pageTitle = '修改'
+        } else if(type == 'look') {
+          pageTitle = '查看'
+        }
         this.$router.push({
           path: '/shopManager/shopOperation',
           query: {
-            searchForm,
-            paramInfo,
-            pageInfo
+            paramInfo
           }
+        }, (route) => {
+          route.meta.title = pageTitle + '商品'
         })
       }
     },

+ 2 - 18
src/views/businessManager/shopManager/shopOperation.vue

@@ -376,14 +376,8 @@ export default {
       imageHeightM: 400
     }
   },
-  created () {
-    this.init()
-  },
-  activated () {
-    this.init()
-  },
   mounted () {
-
+    this.init()
   },
   methods: {
     init () {
@@ -394,12 +388,6 @@ export default {
         this.id = paramInfo.id
       }
       this.pageDisabled = this.pageType == 'look' ? true : false
-      if (query.search) {
-        this.Fsearch = query.search;
-      }
-      if (query.pageInfo) {
-        this.Frules = query.pageInfo
-      }
       this.getList()
       this.getCatagory()
     },
@@ -440,11 +428,7 @@ export default {
     },
     onCancel () {
       this.$router.push({
-        path: '/shopManager/shopManager',
-        query: {
-          pageInfo: this.Frules,
-          searchForm: this.Fsearch
-        }
+        path: '/shopManager/shopManager'
       })
     },
     onReSet (formName) {