傅行帆 il y a 6 ans
Parent
révision
9939764161

+ 16
- 0
VUECODE/smart-operate-manage/src/api/community.js Voir le fichier

@@ -7,3 +7,19 @@ export function fetchList(query) {
7 7
     params: query
8 8
   })
9 9
 }
10
+
11
+export function createCommunity(data) {
12
+  return request({
13
+    url: '/community/add',
14
+    method: 'post',
15
+    data
16
+  })
17
+}
18
+
19
+export function updateCommunity(data) {
20
+  return request({
21
+    url: '/community/update',
22
+    method: 'post',
23
+    data
24
+  })
25
+}

+ 52
- 4
VUECODE/smart-operate-manage/src/store/modules/community.js Voir le fichier

@@ -1,24 +1,52 @@
1
-import { fetchList } from '@/api/community'
1
+import { fetchList, createCommunity, updateCommunity } from '@/api/community'
2 2
 
3 3
 const community = {
4
-  namespace: true,
4
+  namespaced: true,
5 5
   state: {
6 6
     total: '',
7
-    list: []
7
+    list: [],
8
+    detail: {},
8 9
   },
9 10
 
10 11
   mutations: {
11 12
     SET_LIST: (state, list) => {
12 13
       state.list = list
13 14
     },
15
+    Insert_LIST: (state, detail) => {
16
+      state.list = [detail, ...list]
17
+    },
18
+    UpdateList: (state, detail) => {
19
+      state.list = state.list.map(item => {
20
+        if (item.id === detail.id) {
21
+          return detail
22
+        }
23
+        return item
24
+      })
25
+    },
14 26
     SET_TOTAL: (state, total) => {
15 27
       state.total = total
28
+    },
29
+    setDetail: (state, item) => {
30
+      state.detail = item
31
+    },
32
+    resetDetail: (state) => {
33
+      state.detail = {
34
+        ...{
35
+          id: undefined,
36
+          importance: 1,
37
+          remark: '',
38
+          timestamp: new Date(),
39
+          title: '',
40
+          status: 'published',
41
+          type: ''
42
+        }
43
+      }
16 44
     }
17 45
   },
18 46
 
19 47
   actions: {
20 48
     // fetchList,获取社区列表
21
-    FetchList({ commit }, listQuery) {
49
+    FetchCommunityList({ commit }, listQuery) {
22 50
       return new Promise((resolve, reject) => {
23 51
         fetchList(listQuery).then(response => {
24 52
           const data = response.data
@@ -29,6 +57,26 @@ const community = {
29 57
           reject(error)
30 58
         })
31 59
       })
60
+    },
61
+
62
+    CreateCommunity({ commit }, datail) {
63
+      return new Promise((resolve, reject) => {
64
+        createCommunity(datail).then(response => {
65
+          resolve()
66
+        }).catch(error => {
67
+          reject(error)
68
+        })
69
+      })
70
+    },
71
+
72
+    UpdateCommunity({ commit }, datail) {
73
+      return new Promise((resolve, reject) => {
74
+        updateCommunity(datail).then(response => {
75
+          resolve()
76
+        }).catch(error => {
77
+          reject(error)
78
+        })
79
+      })
32 80
     }
33 81
   }
34 82
 }

+ 87
- 63
VUECODE/smart-operate-manage/src/views/community/communityTable.vue Voir le fichier

@@ -30,52 +30,52 @@
30 30
         align="center"
31 31
         type="index"
32 32
         width="50"/>
33
-      <el-table-column label="社区编号" prop="id" align="center" width="105">
33
+      <el-table-column label="社区编号" align="center" width="105">
34 34
         <template slot-scope="scope">
35 35
           <span>{{ scope.row.id }}</span>
36 36
         </template>
37 37
       </el-table-column>
38
-      <el-table-column label="社区名称" prop="id" align="center" width="105">
38
+      <el-table-column label="社区名称" align="center" width="105">
39 39
         <template slot-scope="scope">
40 40
           <span>{{ scope.row.communityName }}</span>
41 41
         </template>
42 42
       </el-table-column>
43
-      <el-table-column label="社区别名" prop="id" align="center" width="105">
43
+      <el-table-column label="社区别名" align="center" width="105">
44 44
         <template slot-scope="scope">
45 45
           <span>{{ scope.row.communityAlias }}</span>
46 46
         </template>
47 47
       </el-table-column>
48
-      <el-table-column label="所在地区" prop="id" align="center" width="305">
48
+      <el-table-column label="所在地区" align="center" width="305">
49 49
         <template slot-scope="scope">
50
-          <span>{{ scope.row.province_id }}{{ scope.row.city_id }}{{ scope.row.district_id }}</span>
50
+          <span>{{ scope.row.provinceId }}{{ scope.row.cityId }}{{ scope.row.districtId }}</span>
51 51
         </template>
52 52
       </el-table-column>
53
-      <el-table-column label="物业人员数量" prop="id" align="center" width="105">
53
+      <el-table-column label="物业人员数量" align="center" width="105">
54 54
         <template slot-scope="scope">
55 55
           <span>52</span>
56 56
         </template>
57 57
       </el-table-column>
58
-      <el-table-column label="已核业主数量" prop="id" align="center" width="105">
58
+      <el-table-column label="已核业主数量" align="center" width="105">
59 59
         <template slot-scope="scope">
60 60
           <span>123</span>
61 61
         </template>
62 62
       </el-table-column>
63
-      <el-table-column label="已核家属数量" prop="id" align="center" width="105">
63
+      <el-table-column label="已核家属数量" align="center" width="105">
64 64
         <template slot-scope="scope">
65 65
           <span>345</span>
66 66
         </template>
67 67
       </el-table-column>
68
-      <el-table-column label="已核租客数量" prop="id" align="center" width="105">
68
+      <el-table-column label="已核租客数量" align="center" width="105">
69 69
         <template slot-scope="scope">
70 70
           <span>234</span>
71 71
         </template>
72 72
       </el-table-column>
73
-      <el-table-column label="物业管理员" prop="id" align="center" width="105">
73
+      <el-table-column label="物业管理员" align="center" width="105">
74 74
         <template slot-scope="scope">
75 75
           <span>{{ scope.row.userName }}</span>
76 76
         </template>
77 77
       </el-table-column>
78
-      <el-table-column label="高德坐标" prop="id" align="center" width="105">
78
+      <el-table-column label="高德坐标" align="center" width="105">
79 79
         <template slot-scope="scope">
80 80
           <span>{{ scope.row.longitude }},{{ scope.row.latitude }}</span>
81 81
         </template>
@@ -96,28 +96,29 @@
96 96
     <pagination v-show="total>0" :total="total" :pageNum.sync="listQuery.pageNum" :pageSize.sync="listQuery.pageSize" @pagination="getList" />
97 97
 
98 98
     <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
99
-      <el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="70px" style="width: 400px; margin-left:50px;">
100
-        <el-form-item label="类型" prop="type">
101
-          <el-select v-model="temp.type" class="filter-item" placeholder="Please select">
102
-            <el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
103
-          </el-select>
99
+      <el-form ref="dataForm" :rules="rules" :model="detail" label-position="left" label-width="100px" style="width: 400px; margin-left:50px;">
100
+        <el-form-item label="社区名称">
101
+           <el-input v-model="detail.communityName"/>
104 102
         </el-form-item>
105
-        <el-form-item label="时间" prop="timestamp">
106
-          <el-date-picker v-model="temp.timestamp" type="datetime" placeholder="Please pick a date"/>
103
+        <el-form-item label="社区别名">
104
+          <el-input v-model="detail.communityAlias"/>
107 105
         </el-form-item>
108
-        <el-form-item label="标题" prop="title">
109
-          <el-input v-model="temp.title"/>
106
+        <!-- <el-form-item label="所在区县" prop="title">
107
+          <el-input v-model="detail.title"/>
108
+        </el-form-item> -->
109
+        <el-form-item label="高德坐标">
110
+          <el-input v-model="detail.longitude"
111
+                    placeholder="经度"/>
112
+          <el-input v-model="detail.latitude"
113
+                    placeholder="纬度"/>
110 114
         </el-form-item>
111
-        <el-form-item label="状态">
112
-          <el-select v-model="temp.status" class="filter-item" placeholder="Please select">
113
-            <el-option v-for="item in statusOptions" :key="item" :label="item" :value="item"/>
114
-          </el-select>
115
+        <el-form-item label="管理员姓名">
116
+          <el-input v-model="detail.userName"
117
+                    placeholder="建议先填写运营人员姓名"/>
115 118
         </el-form-item>
116
-        <el-form-item label="重要性">
117
-          <el-rate v-model="temp.importance" :colors="['#99A9BF', '#F7BA2A', '#FF9900']" :max="3" style="margin-top:8px;"/>
118
-        </el-form-item>
119
-        <el-form-item label="点评">
120
-          <el-input :autosize="{ minRows: 2, maxRows: 4}" v-model="temp.remark" type="textarea" placeholder="Please input"/>
119
+        <el-form-item label="管理员账号">
120
+          <el-input v-model="detail.loginName"
121
+                    placeholder="建议先填写运营人员手机号"/>
121 122
         </el-form-item>
122 123
       </el-form>
123 124
       <div slot="footer" class="dialog-footer">
@@ -140,6 +141,7 @@
140 141
 </template>
141 142
 
142 143
 <script>
144
+import { mapState, mapActions, mapMutations } from 'vuex'
143 145
 import waves from '@/directive/waves' // Waves directive
144 146
 import { parseTime } from '@/utils'
145 147
 import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
@@ -174,11 +176,16 @@ export default {
174 176
       return calendarTypeKeyValue[type]
175 177
     }
176 178
   },
179
+  computed: {
180
+    ...mapState('community', {
181
+      list: s => s.list,
182
+      detail: s => s.detail,
183
+      total: s => s.total,
184
+    }),
185
+  },
177 186
   data() {
178 187
     return {
179 188
       tableKey: 0,
180
-      list: null,
181
-      total: 0,
182 189
       listLoading: true,
183 190
       listQuery: {
184 191
         pageNum: 1,
@@ -193,15 +200,6 @@ export default {
193 200
       sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
194 201
       statusOptions: ['published', 'draft', 'deleted'],
195 202
       showReviewer: false,
196
-      temp: {
197
-        id: undefined,
198
-        importance: 1,
199
-        remark: '',
200
-        createData: '',
201
-        title: '',
202
-        type: '',
203
-        status: 'published'
204
-      },
205 203
       dialogFormVisible: false,
206 204
       dialogStatus: '',
207 205
       textMap: {
@@ -222,16 +220,22 @@ export default {
222 220
     this.getList()
223 221
   },
224 222
   methods: {
223
+    ...mapMutations('community',{
224
+      resetDetail: 'resetDetail',
225
+      setDetail: 'setDetail',
226
+    }),
227
+    ...mapActions('community', [
228
+      'FetchCommunityList',
229
+      'CreateCommunity',
230
+      'UpdateCommunity',
231
+    ]),
232
+    setCurrent(item) {
233
+      this.setDetail({...item})
234
+    },
225 235
     getList() {
226 236
       this.listLoading = true
227
-      this.$store.dispatch('community/FetchList', this.listQuery).then((data) => {
228
-        this.list = data.items
229
-        this.total = data.total
230
-
231
-        // Just to simulate the time of the request
232
-        setTimeout(() => {
233
-          this.listLoading = false
234
-        }, 1.5 * 1000)
237
+      this.FetchCommunityList(this.listQuery).then(() => {
238
+        this.listLoading = false 
235 239
       }).catch(() => {
236 240
         this.loading = false
237 241
         console.log('get list error')
@@ -262,34 +266,54 @@ export default {
262 266
       }
263 267
       this.handleFilter()
264 268
     },
265
-    resetTemp() {
266
-      this.temp = {
267
-        id: undefined,
268
-        importance: 1,
269
-        remark: '',
270
-        timestamp: new Date(),
271
-        title: '',
272
-        status: 'published',
273
-        type: ''
274
-      }
275
-    },
276
-    handleCreate() {
277
-      this.resetTemp()
269
+   handleCreate() {
270
+      this.resetDetail()
278 271
       this.dialogStatus = 'create'
279 272
       this.dialogFormVisible = true
280 273
       this.$nextTick(() => {
281 274
         this.$refs['dataForm'].clearValidate()
282 275
       })
283 276
     },
277
+    createData() {
278
+      this.$refs['dataForm'].validate((valid) => {
279
+        if (valid) {
280
+          this.CreateCommunity(this.detail).then(() => {
281
+            this.dialogFormVisible = false
282
+            this.$notify({
283
+              title: '成功',
284
+              message: '创建成功',
285
+              type: 'success',
286
+              duration: 2000
287
+            })
288
+            this.getList()
289
+          })
290
+        }
291
+      })
292
+    },
284 293
     handleUpdate(row) {
285
-      this.temp = Object.assign({}, row) // copy obj
286
-      this.temp.timestamp = new Date(this.temp.timestamp)
294
+      this.setCurrent(row)
287 295
       this.dialogStatus = 'update'
288 296
       this.dialogFormVisible = true
289 297
       this.$nextTick(() => {
290 298
         this.$refs['dataForm'].clearValidate()
291 299
       })
292 300
     },
301
+    updateData() {
302
+      this.$refs['dataForm'].validate((valid) => {
303
+        if (valid) {
304
+          this.UpdateCommunity(this.detail).then(() => {
305
+            this.dialogFormVisible = false
306
+            this.$notify({
307
+              title: '成功',
308
+              message: '更新成功',
309
+              type: 'success',
310
+              duration: 2000
311
+            })
312
+            this.getList()
313
+          })
314
+        }
315
+      })
316
+    },
293 317
     handleDelete(row) {
294 318
       this.$notify({
295 319
         title: '成功',