许成详 6 years ago
parent
commit
05d27ea78c

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

56
   },
56
   },
57
   computed: {
57
   computed: {
58
     ...mapState({
58
     ...mapState({
59
-      cases: x => x.app.cases,
59
+      cases: x => x.app.cases.list,
60
+      defaultCaseId: x => x.app.cases.default,
60
       OrgId: x => x.app.user.OrgId,
61
       OrgId: x => x.app.user.OrgId,
61
     }),
62
     }),
62
     CaseId: {
63
     CaseId: {
63
       get () {
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
       set (val) {
67
       set (val) {
67
         this.postData.CaseId = val
68
         this.postData.CaseId = val
73
     submit () { // 提交数据
74
     submit () { // 提交数据
74
       this.postData.OrgId = this.OrgId
75
       this.postData.OrgId = this.OrgId
75
       if (this.postData.CaseId === '') this.postData.CaseId = this.CaseId
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
         data: this.postData
79
         data: this.postData
79
       }).then(res => {
80
       }).then(res => {
80
         this.$message({
81
         this.$message({

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

8
             <div style="width:50%">
8
             <div style="width:50%">
9
               <el-input
9
               <el-input
10
                 placeholder="请输入规格名"
10
                 placeholder="请输入规格名"
11
-                v-model="postData.goodsSpec"
11
+                v-model="postData.SpecName"
12
                 clearable>
12
                 clearable>
13
               </el-input>
13
               </el-input>
14
             </div>
14
             </div>
29
   data () {
29
   data () {
30
     return {
30
     return {
31
       postData: {
31
       postData: {
32
-        goodsSpec: ''
32
+        SpecId: '',
33
+        SpecName: '',
34
+        Status: '',
35
+        OrgId: '',
36
+        CaseId: ''
33
       }
37
       }
34
     }
38
     }
35
   },
39
   },
36
   components: {},
40
   components: {},
41
+  created () {
42
+    this.getInfo()
43
+  },
37
   methods: {
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
     cancel () {
72
     cancel () {
42
       this.$router.go(-1)
73
       this.$router.go(-1)

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

8
         <ul>
8
         <ul>
9
           <li>
9
           <li>
10
             <span>选择案场:</span>
10
             <span>选择案场:</span>
11
-            <el-select v-model="tableSearch.caseId" placeholder="请选择">
11
+            <el-select v-model="CaseId" placeholder="请选择">
12
               <el-option
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
               </el-option>
17
               </el-option>
18
             </el-select>
18
             </el-select>
19
           </li>
19
           </li>
20
         </ul>
20
         </ul>
21
         <el-button
21
         <el-button
22
           size="mini"
22
           size="mini"
23
-          type="primary" @click="getList">搜索</el-button>
23
+          type="primary" @click="search">搜索</el-button>
24
       </div>
24
       </div>
25
       <div class="moreFilter"></div>
25
       <div class="moreFilter"></div>
26
     </div>
26
     </div>
27
     <div class="system-table-box">
27
     <div class="system-table-box">
28
       <el-table
28
       <el-table
29
-        :data="tableData"
29
+        :data="currentList"
30
         stripe
30
         stripe
31
         style="width: 100%">
31
         style="width: 100%">
32
         <el-table-column
32
         <el-table-column
33
-          prop="specName"
33
+          prop="SpecName"
34
           label="规格名">
34
           label="规格名">
35
         </el-table-column>
35
         </el-table-column>
36
         <el-table-column label="操作">
36
         <el-table-column label="操作">
48
       </el-table>
48
       </el-table>
49
     </div>
49
     </div>
50
     <el-pagination
50
     <el-pagination
51
-      @size-change="handleSizeChange"
52
       @current-change="handleCurrentChange"
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
       layout="prev, pager, next, jumper"
54
       layout="prev, pager, next, jumper"
56
-      :total="100">
55
+      :total="total">
57
     </el-pagination>
56
     </el-pagination>
58
   </div>
57
   </div>
59
 </template>
58
 </template>
60
 
59
 
61
 <script>
60
 <script>
62
 import tableSearch from '@/components/tableSearch/index'
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
 export default {
64
 export default {
68
   name: '',
65
   name: '',
69
   data () {
66
   data () {
70
     return {
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
   computed: {
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
   components: {
94
   components: {
93
     tableSearch,
95
     tableSearch,
94
   },
96
   },
95
   methods: {
97
   methods: {
98
+    search () {
99
+      this.postData.page = 0
100
+      this.currentList = []
101
+      this.getList()
102
+    },
96
     getList () {
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
       }).then(res => {
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
     handleCurrentChange (val) {
113
     handleCurrentChange (val) {
108
-      console.log(`当前页: ${val}`)
114
+      this.postData.page = val - 1
115
+      this.getList()
109
     },
116
     },
110
     handleEdit (index, row) { // 编辑
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
     handleDelete (index, row) { // 删除
120
     handleDelete (index, row) { // 删除
115
       console.log(index, row)
121
       console.log(index, row)

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

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

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

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