许成详 6 years ago
parent
commit
a62fbe77ed

+ 85
- 22
src/pages/system/caseManager/caseAreaManager/add.vue View File

@@ -8,7 +8,7 @@
8 8
             <div style="width:50%">
9 9
               <el-input
10 10
                 placeholder="请输入区域名"
11
-                v-model="postData.areaName"
11
+                v-model="postData.AreaName"
12 12
                 clearable>
13 13
               </el-input>
14 14
             </div>
@@ -18,12 +18,12 @@
18 18
           <span>案场:</span>
19 19
           <div class="flex-item">
20 20
             <div style="width:50%">
21
-              <el-select v-model="postData.case" placeholder="请选择">
21
+              <el-select v-model="CaseId" placeholder="请选择">
22 22
                 <el-option
23
-                  v-for="item in caseList"
24
-                  :key="item.value"
25
-                  :label="item.label"
26
-                  :value="item.value">
23
+                  v-for="item in cases"
24
+                  :key="item.CaseId"
25
+                  :label="item.CaseName"
26
+                  :value="item.CaseId">
27 27
                 </el-option>
28 28
               </el-select>
29 29
             </div>
@@ -33,11 +33,14 @@
33 33
           <span>图片:</span>
34 34
           <div class="flex-item">
35 35
             <div>
36
-              <a class="formImg">
37
-                <img src="" class="centerLabel contain" alt="">
38
-                <i class="iconfont icon-quxiao"></i>
39
-              </a>
40
-              <el-button type="success" size="mini">上传图片</el-button>
36
+              <el-upload
37
+                class="avatar-uploader"
38
+                :action='$api.file.image.url'
39
+                :show-file-list="false"
40
+                :on-success="handleAvatarSuccess">
41
+                <img v-if="postData.AreaIcon" :src="postData.AreaIcon" class="avatar">
42
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
43
+              </el-upload>
41 44
             </div>
42 45
           </div>
43 46
         </li>
@@ -45,11 +48,14 @@
45 48
           <span>黑白图片:</span>
46 49
           <div class="flex-item">
47 50
             <div>
48
-              <a class="formImg">
49
-                <img src="" class="centerLabel contain" alt="">
50
-                <i class="iconfont icon-quxiao"></i>
51
-              </a>
52
-              <el-button type="success" size="mini">上传图片</el-button>
51
+              <el-upload
52
+                class="avatar-uploader"
53
+                :action='$api.file.image.url'
54
+                :show-file-list="false"
55
+                :on-success="handleAvatarSuccesser">
56
+                <img v-if="postData.AreaIconWhite" :src="postData.AreaIconWhite" class="avatar">
57
+                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
58
+              </el-upload>
53 59
             </div>
54 60
           </div>
55 61
         </li>
@@ -63,13 +69,19 @@
63 69
 </template>
64 70
 
65 71
 <script>
72
+import { mapState } from 'vuex'
73
+
66 74
 export default {
67 75
   name: '',
68 76
   data () {
69 77
     return {
70 78
       postData: {
71
-        areaName: '',
72
-        case: ''
79
+        AreaId: '', // 区域id
80
+        CaseId: '', // 案场id
81
+        OrgId: '', // 机构id
82
+        AreaName: '', // 区域名称
83
+        AreaIcon: '', // 区域图标
84
+        AreaIconWhite: '', // 区域图标灰白
73 85
       },
74 86
       caseList: [{
75 87
         value: '0',
@@ -83,16 +95,67 @@ export default {
83 95
       }],
84 96
     }
85 97
   },
98
+  computed: {
99
+    ...mapState({
100
+      cases: x => x.app.cases.list,
101
+      defaultCaseId: x => x.app.cases.default
102
+    }),
103
+    CaseId: {
104
+      get () {
105
+        return this.postData.CaseId || this.defaultCaseId
106
+      },
107
+      set (val) {
108
+        this.postData.CaseId = val
109
+      }
110
+    }
111
+  },
86 112
   components: {},
87 113
   methods: {
88
-    submit () {
89
-      console.log(this.postData)
114
+    handleAvatarSuccesser (res, file) {
115
+      this.postData.AreaIconWhite = res.result.url
116
+    },
117
+    handleAvatarSuccess (res, file) {
118
+      this.postData.AreaIcon = res.result.url
119
+    },
120
+    submit () { // 提交数据
121
+      if (this.postData.AreaName === '') {
122
+        this.$message({
123
+          type: 'error',
124
+          message: '区域名称不能为空'
125
+        })
126
+        return false
127
+      }
128
+      if (this.postData.AreaIcon === '') {
129
+        this.$message({
130
+          type: 'error',
131
+          message: '区域图标不能为空'
132
+        })
133
+        return false
134
+      }
135
+      if (this.postData.AreaIconWhite === '') {
136
+        this.$message({
137
+          type: 'error',
138
+          message: '区域图标灰白不能为空'
139
+        })
140
+        return false
141
+      }
142
+      this.postData.OrgId = this.OrgId
143
+      this.$ajax(this.$api.caseManager.addCaseArea.url, {
144
+        method: this.$api.caseManager.addCaseArea.method,
145
+        queryData: { ...this.postData, CaseId: this.CaseId }
146
+      }).then(res => {
147
+        this.$message({
148
+          type: 'success',
149
+          message: '操作成功!'
150
+        })
151
+        this.$router.push({name: 'caseAreaManager'})
152
+      })
90 153
     },
91 154
     cancel () {
92
-      this.$router.go(-1)
155
+      this.$router.push({name: 'caseAreaManager'})
93 156
     }
94 157
   },
95
-  mounted () {}
158
+  mounted () { }
96 159
 }
97 160
 </script>
98 161
 

+ 57
- 53
src/pages/system/caseManager/caseAreaManager/index.vue View File

@@ -8,40 +8,42 @@
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
-        <tableSearch value="请输入区域名" @exportSearchKey="searchList"></tableSearch>
21
+        <el-button
22
+          size="mini"
23
+          type="primary" @click="search">搜索</el-button>
22 24
       </div>
23 25
       <div class="moreFilter"></div>
24 26
     </div>
25 27
     <div class="system-table-box">
26 28
       <el-table
27
-        :data="tableData"
29
+        :data="currentList"
28 30
         stripe
29 31
         style="width: 100%">
30 32
         <el-table-column
31
-          prop="areaName"
33
+          prop="AreaName"
32 34
           label="区域名">
33 35
         </el-table-column>
34 36
         <el-table-column
35
-          prop="icon"
37
+          prop="AreaIcon"
36 38
           label="图标">
37 39
           <template slot-scope="scope">
38 40
             <a class="tableImg">
39
-              <img src="" class="centerLabel contain" alt="">
41
+              <img :src="scope.row" class="centerLabel contain" alt="">
40 42
             </a>
41 43
           </template>
42 44
         </el-table-column>
43 45
         <el-table-column
44
-          prop="case"
46
+          prop="CaseName"
45 47
           label="案场">
46 48
         </el-table-column>
47 49
         <el-table-column label="操作">
@@ -59,64 +61,69 @@
59 61
       </el-table>
60 62
     </div>
61 63
     <el-pagination
62
-      @size-change="handleSizeChange"
63 64
       @current-change="handleCurrentChange"
64
-      :current-page.sync="currentPage"
65
-      :page-size="10"
65
+      :current-page.sync="postData.page"
66
+      :page-size="postData.pagesize"
66 67
       layout="prev, pager, next, jumper"
67
-      :total="100">
68
+      :total="total">
68 69
     </el-pagination>
69 70
   </div>
70 71
 </template>
71 72
 
72 73
 <script>
73
-import { createNamespacedHelpers } from 'vuex'
74
-import tableSearch from '@/components/tableSearch/index'
75
-
76
-const { mapState: mapCaseState } = createNamespacedHelpers('case')
74
+import { mapState } from 'vuex'
77 75
 
78 76
 export default {
79 77
   name: '',
80 78
   data () {
81 79
     return {
82
-      currentPage: 0, // 当前页码
83
-      tableSearch: { // 表格搜索条件
84
-        key: '', // 搜索关键字
85
-        caseId: '', // 案场id
80
+      total: 0,
81
+      postData: { // 表格搜索条件
82
+        CaseId: '', // 案场id
83
+        page: 1, // 当前页码
84
+        pagesize: 10, // 请求数据量
86 85
       },
87
-      tableData: [{
88
-        areaName: 'xxx',
89
-        icon: 'xxx',
90
-        case: 'xxx'
91
-      }, {
92
-        areaName: 'xxx',
93
-        icon: 'xxx',
94
-        case: 'xxx'
95
-      }, {
96
-        areaName: 'xxx',
97
-        icon: 'xxx',
98
-        case: 'xxx'
99
-      }, {
100
-        areaName: 'xxx',
101
-        icon: 'xxx',
102
-        case: 'xxx'
103
-      }]
86
+      currentList: [],
104 87
     }
105 88
   },
106
-  computed: {
107
-    ...mapCaseState({
108
-      caseList: x => x.caseList,
109
-    })
89
+  created () {
90
+    this.getList()
110 91
   },
111
-  components: {
112
-    tableSearch,
92
+  computed: {
93
+    ...mapState({
94
+      cases: x => x.app.cases.list,
95
+      defaultCaseId: x => x.app.cases.default
96
+    }),
97
+    CaseId: {
98
+      get () {
99
+        return this.postData.CaseId || this.defaultCaseId
100
+      },
101
+      set (val) {
102
+        this.postData.CaseId = val
103
+      }
104
+    }
113 105
   },
114 106
   methods: {
115
-    handleSizeChange (val) {
116
-      console.log(`每页 ${val} 条`)
107
+    search () { // 搜索
108
+      this.postData.page = 1
109
+      this.currentList = []
110
+      this.getList()
111
+    },
112
+    getList () { // 获取列表
113
+      this.$ajax(this.$api.caseManager.getCaseAreaList.url, {
114
+        method: this.$api.caseManager.getCaseAreaList.method,
115
+        queryData: { ...this.postData, CaseId: this.CaseId }
116
+      }).then(res => {
117
+        for (var n = 0; n < res.list.length; n++) {
118
+          res.list[n].CaseName = this.cases.filter(x => x.CaseId === res.list[n].CaseId)[0].CaseName
119
+        }
120
+        this.currentList = res.list
121
+        this.postData.page = res.page
122
+        this.total = res.pagenum
123
+      })
117 124
     },
118
-    handleCurrentChange (val) {
119
-      console.log(`当前页: ${val}`)
125
+    handleCurrentChange (val) { // 跳转到分页
126
+      this.getList()
120 127
     },
121 128
     editItem (index, row) { // 编辑
122 129
       console.log(index, row)
@@ -140,9 +147,6 @@ export default {
140 147
         })
141 148
       })
142 149
     },
143
-    searchList (key) { // 搜索列表
144
-      console.log(key)
145
-    },
146 150
     addCaseArea () {
147 151
       this.$router.push({ name: 'addCaseArea' })
148 152
     }

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

@@ -39,6 +39,14 @@ const $api = {
39 39
       method: 'get',
40 40
       url: `${baseUrl}/common/case/key`
41 41
     },
42
+    getCaseAreaList: { // 获取案场区域列表
43
+      method: 'get',
44
+      url: `${baseUrl}/common/case/area`
45
+    },
46
+    addCaseArea: { // 新增案场区域
47
+      method: 'post',
48
+      url: `${baseUrl}/common/case/area`
49
+    },
42 50
   },
43 51
   goodsManager: {
44 52
     getGoodsSpecList: { // 商品规格列表