许成详 6 years ago
parent
commit
05d27ea78c

+ 5
- 4
src/pages/system/goodsManager/goodsSpecManager/add.vue View File

@@ -56,12 +56,13 @@ export default {
56 56
   },
57 57
   computed: {
58 58
     ...mapState({
59
-      cases: x => x.app.cases,
59
+      cases: x => x.app.cases.list,
60
+      defaultCaseId: x => x.app.cases.default,
60 61
       OrgId: x => x.app.user.OrgId,
61 62
     }),
62 63
     CaseId: {
63 64
       get () {
64
-        return this.postData.CaseId === '' ? (((this.cases || []).filter(x => x.IsBelong === 1))[0] || {}).CaseId || '' : this.postData.CaseId
65
+        return this.postData.CaseId === '' ? this.defaultCaseId || '' : this.postData.CaseId
65 66
       },
66 67
       set (val) {
67 68
         this.postData.CaseId = val
@@ -73,8 +74,8 @@ export default {
73 74
     submit () { // 提交数据
74 75
       this.postData.OrgId = this.OrgId
75 76
       if (this.postData.CaseId === '') this.postData.CaseId = this.CaseId
76
-      this.$ajax(this.$api.system.addGoodsSpec.url, {
77
-        method: this.$api.system.addGoodsSpec.method,
77
+      this.$ajax(this.$api.goodsManager.addGoodsSpec.url, {
78
+        method: this.$api.goodsManager.addGoodsSpec.method,
78 79
         data: this.postData
79 80
       }).then(res => {
80 81
         this.$message({

+ 35
- 4
src/pages/system/goodsManager/goodsSpecManager/edit.vue View File

@@ -8,7 +8,7 @@
8 8
             <div style="width:50%">
9 9
               <el-input
10 10
                 placeholder="请输入规格名"
11
-                v-model="postData.goodsSpec"
11
+                v-model="postData.SpecName"
12 12
                 clearable>
13 13
               </el-input>
14 14
             </div>
@@ -29,14 +29,45 @@ export default {
29 29
   data () {
30 30
     return {
31 31
       postData: {
32
-        goodsSpec: ''
32
+        SpecId: '',
33
+        SpecName: '',
34
+        Status: '',
35
+        OrgId: '',
36
+        CaseId: ''
33 37
       }
34 38
     }
35 39
   },
36 40
   components: {},
41
+  created () {
42
+    this.getInfo()
43
+  },
37 44
   methods: {
38
-    submit () {
39
-      console.log(this.postData)
45
+    getInfo () { // 获取规格信息
46
+      this.$ajax(this.$api.goodsManager.getGoodsSpecById.url, {
47
+        method: this.$api.goodsManager.getGoodsSpecById.method,
48
+        data: { id: this.$route.query.id }
49
+      }).then(res => {
50
+        this.postData = res
51
+      })
52
+    },
53
+    submit () { // 提交数据
54
+      if (this.postData.SpecName === '') {
55
+        this.$message({
56
+          type: 'error',
57
+          message: '规格名称不能为空'
58
+        })
59
+        return false
60
+      }
61
+      this.$ajax(this.$api.goodsManager.editGoodsSpec.url, {
62
+        method: this.$api.goodsManager.editGoodsSpec.method,
63
+        data: this.postData
64
+      }).then(res => {
65
+        this.$message({
66
+          type: 'success',
67
+          message: '操作成功'
68
+        })
69
+        this.$router.push({ name: 'goodsSpecManager' })
70
+      })
40 71
     },
41 72
     cancel () {
42 73
       this.$router.go(-1)

+ 47
- 41
src/pages/system/goodsManager/goodsSpecManager/index.vue View File

@@ -8,29 +8,29 @@
8 8
         <ul>
9 9
           <li>
10 10
             <span>选择案场:</span>
11
-            <el-select v-model="tableSearch.caseId" placeholder="请选择">
11
+            <el-select v-model="CaseId" placeholder="请选择">
12 12
               <el-option
13
-                v-for="item in caseList"
14
-                :key="item.value"
15
-                :label="item.label"
16
-                :value="item.value">
13
+                v-for="item in cases"
14
+                :key="item.CaseId"
15
+                :label="item.CaseName"
16
+                :value="item.CaseId">
17 17
               </el-option>
18 18
             </el-select>
19 19
           </li>
20 20
         </ul>
21 21
         <el-button
22 22
           size="mini"
23
-          type="primary" @click="getList">搜索</el-button>
23
+          type="primary" @click="search">搜索</el-button>
24 24
       </div>
25 25
       <div class="moreFilter"></div>
26 26
     </div>
27 27
     <div class="system-table-box">
28 28
       <el-table
29
-        :data="tableData"
29
+        :data="currentList"
30 30
         stripe
31 31
         style="width: 100%">
32 32
         <el-table-column
33
-          prop="specName"
33
+          prop="SpecName"
34 34
           label="规格名">
35 35
         </el-table-column>
36 36
         <el-table-column label="操作">
@@ -48,68 +48,74 @@
48 48
       </el-table>
49 49
     </div>
50 50
     <el-pagination
51
-      @size-change="handleSizeChange"
52 51
       @current-change="handleCurrentChange"
53
-      :current-page.sync="currentPage"
54
-      :page-size="10"
52
+      :current-page.sync="postData.page+1"
53
+      :page-size="postData.pagesize"
55 54
       layout="prev, pager, next, jumper"
56
-      :total="100">
55
+      :total="total">
57 56
     </el-pagination>
58 57
   </div>
59 58
 </template>
60 59
 
61 60
 <script>
62 61
 import tableSearch from '@/components/tableSearch/index'
63
-import { createNamespacedHelpers } from 'vuex'
64
-
65
-const { mapState: mapCaseState } = createNamespacedHelpers('case')
62
+import { mapState } from 'vuex'
66 63
 
67 64
 export default {
68 65
   name: '',
69 66
   data () {
70 67
     return {
71
-      currentPage: 0, // 当前页码
72
-      tableSearch: { // 表格搜索条件
73
-        key: '', // 搜索关键字
74
-        caseId: '', // 案场id
68
+      total: 0,
69
+      postData: { // 表格搜索条件
70
+        CaseId: '', // 案场id
71
+        page: 0, // 当前页码
72
+        pagesize: 10, // 请求数据量
75 73
       },
76
-      tableData: [{
77
-        specName: 'xxx'
78
-      }, {
79
-        specName: 'xxx'
80
-      }, {
81
-        specName: 'xxx'
82
-      }, {
83
-        specName: 'xxx'
84
-      }]
74
+      currentList: []
85 75
     }
86 76
   },
77
+  created () {
78
+    this.getList()
79
+  },
87 80
   computed: {
88
-    ...mapCaseState({
89
-      caseList: x => x.caseList,
90
-    })
81
+    ...mapState({
82
+      cases: x => x.app.cases.list,
83
+      defaultCaseId: x => x.app.cases.default
84
+    }),
85
+    CaseId: {
86
+      get () {
87
+        return this.postData.CaseId || this.defaultCaseId
88
+      },
89
+      set (val) {
90
+        this.postData.CaseId = val
91
+      }
92
+    }
91 93
   },
92 94
   components: {
93 95
     tableSearch,
94 96
   },
95 97
   methods: {
98
+    search () {
99
+      this.postData.page = 0
100
+      this.currentList = []
101
+      this.getList()
102
+    },
96 103
     getList () {
97
-      this.$ajax(this.$api.system.getGoodsSpecList.url, {
98
-        method: this.$api.system.getGoodsSpecList.method,
99
-        data: this.tableSearch
104
+      this.$ajax(this.$api.goodsManager.getGoodsSpecList.url, {
105
+        method: this.$api.goodsManager.getGoodsSpecList.method,
106
+        data: { ...this.postData, CaseId: this.CaseId }
100 107
       }).then(res => {
101
-        console.log(JSON.stringify(res))
108
+        this.currentList = res.list
109
+        this.postData.page = res.page
110
+        this.total = res.pagenum
102 111
       })
103 112
     },
104
-    handleSizeChange (val) {
105
-      console.log(`每页 ${val} 条`)
106
-    },
107 113
     handleCurrentChange (val) {
108
-      console.log(`当前页: ${val}`)
114
+      this.postData.page = val - 1
115
+      this.getList()
109 116
     },
110 117
     handleEdit (index, row) { // 编辑
111
-      console.log(index, row)
112
-      this.$router.push({ name: 'editGoodsSpec' })
118
+      this.$router.push({ name: 'editGoodsSpec', query: {id: row.SpecId} })
113 119
     },
114 120
     handleDelete (index, row) { // 删除
115 121
       console.log(index, row)

+ 6
- 2
src/store/app.js View File

@@ -25,7 +25,9 @@ function packChildren (data) {
25 25
     for (let i = 0; i < cp.length; i += 1) {
26 26
       if (cp[i].MenuId === it.FatherId) {
27 27
         found = true
28
-        cp[i].children = [...(cp[i].children || []), cp[inx]]
28
+        if (it.IsShow === 1) {
29
+          cp[i].children = [...(cp[i].children || []), cp[inx]]
30
+        }
29 31
         break
30 32
       }
31 33
     }
@@ -55,13 +57,15 @@ export default {
55 57
       state.menusRaw = data.menus
56 58
       state.roles = data.roles
57 59
       state.user = data.user
58
-      let defaultCase = 0
59 60
       state.menus = packChildren(data.menus)
61
+
62
+      let defaultCase = 0
60 63
       for (let i = 0; i < data.cases.length; i++) {
61 64
         if (data.cases[i].IsBelong === 1) {
62 65
           defaultCase = data.cases[i].CaseId
63 66
         }
64 67
       }
68
+
65 69
       state.cases = {
66 70
         list: data.cases,
67 71
         default: defaultCase

+ 8
- 2
src/util/api.js View File

@@ -10,7 +10,9 @@ const $api = {
10 10
     init: { // 初始化菜单
11 11
       method: 'get',
12 12
       url: `${baseUrl}/common/system/init`
13
-    },
13
+    }
14
+  },
15
+  goodsManager: {
14 16
     getGoodsSpecList: { // 商品规格列表
15 17
       method: 'get',
16 18
       url: `${baseUrl}/common/spec/goods`
@@ -19,9 +21,13 @@ const $api = {
19 21
       method: 'POST',
20 22
       url: `${baseUrl}/common/spec/goods`
21 23
     },
24
+    getGoodsSpecById: { // 根据id获取商品规格
25
+      method: 'get',
26
+      url: `${baseUrl}/common/spec/goods/:id`
27
+    },
22 28
     editGoodsSpec: { // 编辑商品规格
23 29
       method: 'put',
24
-      url: `${baseUrl}/common/spec/goods`
30
+      url: `${baseUrl}/common/spec/goods/:id`
25 31
     }
26 32
   },
27 33
   cms: {