傅行帆 6 年前
父节点
当前提交
9939764161

+ 16
- 0
VUECODE/smart-operate-manage/src/api/community.js 查看文件

7
     params: query
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 查看文件

1
-import { fetchList } from '@/api/community'
1
+import { fetchList, createCommunity, updateCommunity } from '@/api/community'
2
 
2
 
3
 const community = {
3
 const community = {
4
-  namespace: true,
4
+  namespaced: true,
5
   state: {
5
   state: {
6
     total: '',
6
     total: '',
7
-    list: []
7
+    list: [],
8
+    detail: {},
8
   },
9
   },
9
 
10
 
10
   mutations: {
11
   mutations: {
11
     SET_LIST: (state, list) => {
12
     SET_LIST: (state, list) => {
12
       state.list = list
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
     SET_TOTAL: (state, total) => {
26
     SET_TOTAL: (state, total) => {
15
       state.total = total
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
   actions: {
47
   actions: {
20
     // fetchList,获取社区列表
48
     // fetchList,获取社区列表
21
-    FetchList({ commit }, listQuery) {
49
+    FetchCommunityList({ commit }, listQuery) {
22
       return new Promise((resolve, reject) => {
50
       return new Promise((resolve, reject) => {
23
         fetchList(listQuery).then(response => {
51
         fetchList(listQuery).then(response => {
24
           const data = response.data
52
           const data = response.data
29
           reject(error)
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 查看文件

30
         align="center"
30
         align="center"
31
         type="index"
31
         type="index"
32
         width="50"/>
32
         width="50"/>
33
-      <el-table-column label="社区编号" prop="id" align="center" width="105">
33
+      <el-table-column label="社区编号" align="center" width="105">
34
         <template slot-scope="scope">
34
         <template slot-scope="scope">
35
           <span>{{ scope.row.id }}</span>
35
           <span>{{ scope.row.id }}</span>
36
         </template>
36
         </template>
37
       </el-table-column>
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
         <template slot-scope="scope">
39
         <template slot-scope="scope">
40
           <span>{{ scope.row.communityName }}</span>
40
           <span>{{ scope.row.communityName }}</span>
41
         </template>
41
         </template>
42
       </el-table-column>
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
         <template slot-scope="scope">
44
         <template slot-scope="scope">
45
           <span>{{ scope.row.communityAlias }}</span>
45
           <span>{{ scope.row.communityAlias }}</span>
46
         </template>
46
         </template>
47
       </el-table-column>
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
         <template slot-scope="scope">
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
         </template>
51
         </template>
52
       </el-table-column>
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
         <template slot-scope="scope">
54
         <template slot-scope="scope">
55
           <span>52</span>
55
           <span>52</span>
56
         </template>
56
         </template>
57
       </el-table-column>
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
         <template slot-scope="scope">
59
         <template slot-scope="scope">
60
           <span>123</span>
60
           <span>123</span>
61
         </template>
61
         </template>
62
       </el-table-column>
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
         <template slot-scope="scope">
64
         <template slot-scope="scope">
65
           <span>345</span>
65
           <span>345</span>
66
         </template>
66
         </template>
67
       </el-table-column>
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
         <template slot-scope="scope">
69
         <template slot-scope="scope">
70
           <span>234</span>
70
           <span>234</span>
71
         </template>
71
         </template>
72
       </el-table-column>
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
         <template slot-scope="scope">
74
         <template slot-scope="scope">
75
           <span>{{ scope.row.userName }}</span>
75
           <span>{{ scope.row.userName }}</span>
76
         </template>
76
         </template>
77
       </el-table-column>
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
         <template slot-scope="scope">
79
         <template slot-scope="scope">
80
           <span>{{ scope.row.longitude }},{{ scope.row.latitude }}</span>
80
           <span>{{ scope.row.longitude }},{{ scope.row.latitude }}</span>
81
         </template>
81
         </template>
96
     <pagination v-show="total>0" :total="total" :pageNum.sync="listQuery.pageNum" :pageSize.sync="listQuery.pageSize" @pagination="getList" />
96
     <pagination v-show="total>0" :total="total" :pageNum.sync="listQuery.pageNum" :pageSize.sync="listQuery.pageSize" @pagination="getList" />
97
 
97
 
98
     <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
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
         </el-form-item>
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
         </el-form-item>
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
         </el-form-item>
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
         </el-form-item>
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
         </el-form-item>
122
         </el-form-item>
122
       </el-form>
123
       </el-form>
123
       <div slot="footer" class="dialog-footer">
124
       <div slot="footer" class="dialog-footer">
140
 </template>
141
 </template>
141
 
142
 
142
 <script>
143
 <script>
144
+import { mapState, mapActions, mapMutations } from 'vuex'
143
 import waves from '@/directive/waves' // Waves directive
145
 import waves from '@/directive/waves' // Waves directive
144
 import { parseTime } from '@/utils'
146
 import { parseTime } from '@/utils'
145
 import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
147
 import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
174
       return calendarTypeKeyValue[type]
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
   data() {
186
   data() {
178
     return {
187
     return {
179
       tableKey: 0,
188
       tableKey: 0,
180
-      list: null,
181
-      total: 0,
182
       listLoading: true,
189
       listLoading: true,
183
       listQuery: {
190
       listQuery: {
184
         pageNum: 1,
191
         pageNum: 1,
193
       sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
200
       sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
194
       statusOptions: ['published', 'draft', 'deleted'],
201
       statusOptions: ['published', 'draft', 'deleted'],
195
       showReviewer: false,
202
       showReviewer: false,
196
-      temp: {
197
-        id: undefined,
198
-        importance: 1,
199
-        remark: '',
200
-        createData: '',
201
-        title: '',
202
-        type: '',
203
-        status: 'published'
204
-      },
205
       dialogFormVisible: false,
203
       dialogFormVisible: false,
206
       dialogStatus: '',
204
       dialogStatus: '',
207
       textMap: {
205
       textMap: {
222
     this.getList()
220
     this.getList()
223
   },
221
   },
224
   methods: {
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
     getList() {
235
     getList() {
226
       this.listLoading = true
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
       }).catch(() => {
239
       }).catch(() => {
236
         this.loading = false
240
         this.loading = false
237
         console.log('get list error')
241
         console.log('get list error')
262
       }
266
       }
263
       this.handleFilter()
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
       this.dialogStatus = 'create'
271
       this.dialogStatus = 'create'
279
       this.dialogFormVisible = true
272
       this.dialogFormVisible = true
280
       this.$nextTick(() => {
273
       this.$nextTick(() => {
281
         this.$refs['dataForm'].clearValidate()
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
     handleUpdate(row) {
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
       this.dialogStatus = 'update'
295
       this.dialogStatus = 'update'
288
       this.dialogFormVisible = true
296
       this.dialogFormVisible = true
289
       this.$nextTick(() => {
297
       this.$nextTick(() => {
290
         this.$refs['dataForm'].clearValidate()
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
     handleDelete(row) {
317
     handleDelete(row) {
294
       this.$notify({
318
       this.$notify({
295
         title: '成功',
319
         title: '成功',