张延森 hace 6 años
padre
commit
10852e5498

+ 22
- 0
src/config/api.js Ver fichero

@@ -95,6 +95,28 @@ const apis = {
95 95
       url: `${commPrefix}/image`
96 96
     },
97 97
   },
98
+  apartment: {
99
+    list: {
100
+      method: 'get',
101
+      url: `${commPrefix}/buildingApartment/buildingId/:buildingId`
102
+    },
103
+    detail: {
104
+      method: 'get',
105
+      url: `${commPrefix}/buildingApartment/:id`
106
+    },
107
+    add: {
108
+      method: 'post',
109
+      url: `${commPrefix}/buildingApartment/add`
110
+    },
111
+    edit: {
112
+      method: 'put',
113
+      url: `${commPrefix}/buildingApartment/update`
114
+    },
115
+    delete: {
116
+      method: 'delete',
117
+      url: `${commPrefix}/apartment/deleted/:id`
118
+    }
119
+  }
98 120
 }
99 121
 
100 122
 export default apis

+ 9
- 0
src/main.js Ver fichero

@@ -10,6 +10,7 @@ import store from './store'
10 10
 import 'normalize.css/normalize.css'
11 11
 import './theme.scss'
12 12
 import './assets/iconfont.css'
13
+import VueAMap from 'vue-amap'
13 14
 
14 15
 Vue.use(Element)
15 16
 
@@ -18,6 +19,14 @@ Vue.component('v-chart', ECharts)
18 19
 Vue.component('xm-icon', XMIcon)
19 20
 Vue.component('xm-rtl', XMRightLay)
20 21
 Vue.component('xm-search', XMSearchForm)
22
+Vue.use(VueAMap)
23
+
24
+VueAMap.initAMapApiLoader({
25
+  key: 'f0d1d4f82432504003ebf46e5e36ff03',
26
+  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
27
+  // 默认高德 sdk 版本为 1.4.4
28
+  v: '1.4.4'
29
+})
21 30
 
22 31
 new Vue({
23 32
   render: h => h(App),

+ 2
- 1
src/store/index.js Ver fichero

@@ -1,12 +1,13 @@
1 1
 import Vue from 'vue'
2 2
 import Vuex from 'vuex'
3 3
 import system from './system'
4
-
4
+import apartment from './modules/apartment'
5 5
 Vue.use(Vuex)
6 6
 
7 7
 const store = new Vuex.Store({
8 8
   ...system,
9 9
   modules: {
10
+    apartment,
10 11
     persons: require('./modules/persons').default,
11 12
     dynamic: require('./modules/dynamic').default,
12 13
     building: require('./modules/building').default,

+ 92
- 0
src/store/modules/apartment.js Ver fichero

@@ -0,0 +1,92 @@
1
+import request from '../../utils/request'
2
+import apis from '../../config/api'
3
+
4
+export default {
5
+  namespaced: true,
6
+  state: {
7
+    apartmentts: [],
8
+    detail: {}
9
+  },
10
+  mutations: {
11
+    updateList (state, payload) {
12
+      state.apartments = payload
13
+    },
14
+    updateDetail (state, payload) {
15
+      state.detail = payload
16
+    }
17
+  },
18
+  actions: {
19
+    setDetailNull ({ commit }) {
20
+      commit('updateDetail', {})
21
+    },
22
+    getApartments ({ commit }, payload) {
23
+      return new Promise((resolve, reject) => {
24
+        request({
25
+          ...apis.apartment.list,
26
+          urlData: payload,
27
+        }).then((data) => {
28
+          commit('updateList', data)
29
+          resolve(data)
30
+        }).catch(({ message }) => {
31
+          if (typeof message === 'string') {
32
+            reject(message)
33
+          }
34
+        })
35
+      })
36
+    },
37
+    getApartmentDetail ({ commit }, payload) {
38
+      return new Promise((resolve, reject) => {
39
+        request({
40
+          ...apis.apartment.detail,
41
+          urlData:payload
42
+        }).then((data) => {
43
+          commit('updateDetail', data)
44
+          resolve(data)
45
+        }).catch(({ message }) => {
46
+          if (typeof message === 'string') {
47
+            reject(message)
48
+          }
49
+        })
50
+      })
51
+    },
52
+    addApartment (_, payload) {
53
+      return new Promise((resolve, reject) => {
54
+        request({
55
+          ...apis.apartment.add,
56
+          data:payload
57
+        }).then((data) => {
58
+          
59
+          resolve(data)
60
+        }).catch(() => {
61
+          reject()
62
+        })
63
+      })
64
+    },
65
+    editApartment (_, payload) {
66
+      return new Promise((resolve, reject) => {
67
+        request({
68
+          ...apis.apartment.edit,
69
+          urlData:{id:payload.apartmentId},
70
+          data:payload
71
+        }).then((data) => {
72
+          resolve(data)
73
+        }).catch(() => {
74
+          reject()
75
+        })
76
+      })
77
+    },
78
+    deleteApartment (_, payload) {
79
+      return new Promise((resolve, reject) => {
80
+        // const api = replaceApiParams(lodash.get(apis, 'apartment.'), payload)
81
+        request({
82
+          ...apis.apartment.delete,
83
+          urlData:payload
84
+        }).then(() => {
85
+          resolve()
86
+        }).catch(() => {
87
+          reject()
88
+        })
89
+      })
90
+    },
91
+  }
92
+}

+ 11
- 12
src/store/modules/building.js Ver fichero

@@ -25,10 +25,10 @@ export default {
25 25
           ...apis.building.list,
26 26
           params: payload,
27 27
         }).then((data) => {
28
-          commit('updateList', data)
28
+          window.console.log(data)
29
+          commit('updateList', { ...data, list: data.records})
29 30
           resolve(data)
30
-        }).catch((err) => {
31
-          const message = err.message || err.msg
31
+        }).catch(({ message }) => {
32 32
           if (typeof message === 'string') {
33 33
             reject(message)
34 34
           }
@@ -41,10 +41,10 @@ export default {
41 41
           ...apis.building.detail,
42 42
           urlData: payload,
43 43
         }).then((data) => {
44
+          window.console.log(data)
44 45
           commit('updateDetail', data)
45 46
           resolve(data)
46
-        }).catch((err) => {
47
-          const message = err.message || err.msg
47
+        }).catch(({ message }) => {
48 48
           if (typeof message === 'string') {
49 49
             reject(message)
50 50
           }
@@ -54,7 +54,7 @@ export default {
54 54
     addBuilding (_, payload) {
55 55
       const { onSuccess } = payload
56 56
       request({
57
-        ...apis.building.add, 
57
+        ...apis.building.add,
58 58
         data: payload.detail,
59 59
       }).then((data) => {
60 60
         onSuccess(data)
@@ -63,8 +63,9 @@ export default {
63 63
     editBuilding (_, payload) {
64 64
       const { onSuccess } = payload
65 65
       request({
66
-        ...apis.building.edit, 
67
-        data: payload.detail,
66
+        ...apis.building.edit,
67
+        urlData: { id: payload.detail.buildingId },
68
+        data: payload.detail
68 69
       }).then((data) => {
69 70
         onSuccess(data)
70 71
       })
@@ -76,8 +77,7 @@ export default {
76 77
           urlData: payload,
77 78
         }).then((data) => {
78 79
           resolve(data)
79
-        }).catch((err) => {
80
-          const message = err.message || err.msg
80
+        }).catch(({ message }) => {
81 81
           if (typeof message === 'string') {
82 82
             reject(message)
83 83
           }
@@ -91,8 +91,7 @@ export default {
91 91
           data: payload,
92 92
         }).then((data) => {
93 93
           resolve(data)
94
-        }).catch((err) => {
95
-          const message = err.message || err.msg
94
+        }).catch(({ message }) => {
96 95
           if (typeof message === 'string') {
97 96
             reject(message)
98 97
           }

+ 1
- 2
src/store/modules/img.js Ver fichero

@@ -1,4 +1,3 @@
1
-
2 1
 import request from '../../utils/request'
3 2
 import apis from '../../config/api'
4 3
 
@@ -8,9 +7,9 @@ export default {
8 7
   actions: {
9 8
     uploadImg (_, payload) {
10 9
       return new Promise((resolve, reject) => {
10
+        // const api = lodash.get(apis, 'file.upload')
11 11
         const fm = new FormData()
12 12
         fm.append('file', payload)
13
-
14 13
         request({
15 14
           ...apis.file.upload,
16 15
           data: fm,

+ 3
- 3
src/utils/request.js Ver fichero

@@ -22,7 +22,7 @@ function request(params = {}) {
22 22
       }
23 23
     }).then(({ data: res }) => {
24 24
 
25
-      // 服务端返回包含 code, msg, data 字段
25
+      // 服务端返回包含 code, message, data 字段
26 26
       const { code, data } = res
27 27
 
28 28
       // 业务处理正确则返回 1000
@@ -35,9 +35,9 @@ function request(params = {}) {
35 35
     }).catch((error) => {
36 36
       // 异常情况
37 37
       if (error.response) {
38
-        reject({ msg: error.response.statusText })
38
+        reject({ message: error.response.statusText })
39 39
       } else {
40
-        reject({ msg: error.message })
40
+        reject({ message: error.message })
41 41
       }
42 42
     })
43 43
   })

+ 559
- 0
src/views/building/edit.vue Ver fichero

@@ -0,0 +1,559 @@
1
+<template>
2
+  <el-tabs v-model="activeName">
3
+    <el-tab-pane label="基础信息" name="detail">
4
+      <el-form ref="form" :model="building" label-width="160px">
5
+        <el-form-item label="楼盘编号">
6
+          <el-input v-model="building.code"></el-input>
7
+        </el-form-item>
8
+        <el-form-item label="楼盘名称">
9
+          <el-input v-model="building.buildingName"></el-input>
10
+        </el-form-item>
11
+        <el-form-item label="别名">
12
+          <el-input v-model="building.name"></el-input>
13
+        </el-form-item>
14
+        <el-form-item label="均价">
15
+          <el-input v-model="building.price"></el-input>
16
+        </el-form-item>
17
+        <el-form-item label="开盘时间">
18
+          <el-date-picker
19
+            v-model="building.openingDate"
20
+            type="date"
21
+            placeholder="选择日期">
22
+          </el-date-picker>
23
+        </el-form-item>
24
+        <el-form-item label="电话">
25
+          <el-input v-model="building.tel"></el-input>
26
+        </el-form-item>
27
+        <el-form-item label="项目动态">
28
+          <el-input v-model="building.dynamic"></el-input>
29
+        </el-form-item>
30
+        <el-form-item label="物业类型">
31
+          <el-select v-model="buildingProperty" multiple placeholder="请选择">
32
+            <el-option v-for="(t,i) in propertyType" :key="i" :label="t.name" :value="t.id"></el-option>
33
+          </el-select>
34
+        </el-form-item>
35
+        <el-form-item label="销售状态">
36
+          <el-input v-model="building.marketStatus"></el-input>
37
+        </el-form-item>
38
+        <el-form-item label="标签">
39
+          <el-select
40
+            v-model="tags"
41
+            multiple
42
+            filterable
43
+            allow-create
44
+            default-first-option
45
+            placeholder="请输入标签">
46
+          </el-select>
47
+        </el-form-item>
48
+        <el-form-item label="项目主图">
49
+          <el-upload
50
+            :action="upFileUrl"
51
+            name='file'
52
+            list-type="picture-card"
53
+            :file-list="imgList"
54
+            :show-file-list="true"
55
+            :before-upload="beforeImgUpload"
56
+            :on-success="handleAvatarSuccess"
57
+            :on-remove="handleRemove">
58
+            <i class="el-icon-plus"></i>
59
+          </el-upload>
60
+          <el-dialog :visible.sync="dialogVisible">
61
+            <img width="100%" :src="dialogImageUrl" alt="">
62
+          </el-dialog>
63
+        </el-form-item>
64
+        <el-form-item label="地址图片">
65
+          <el-upload
66
+            class="avatar-uploader"
67
+            :action="upFileUrl"
68
+            name='file'
69
+            :show-file-list="false"
70
+            :before-upload="beforeImgUpload"
71
+            :on-success="handleMapImgSuccess">
72
+            <img v-if="building.mapImg" :src="building.mapImg" class="avatar">
73
+            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
74
+          </el-upload>
75
+        </el-form-item>
76
+        <el-form-item label="排序">
77
+          <el-input v-model="building.orderNo"></el-input>
78
+        </el-form-item>
79
+        <el-form-item label="优惠信息">
80
+          <el-input v-model="building.discount"></el-input>
81
+        </el-form-item>
82
+        <el-form-item label="首页推荐">
83
+          <el-radio-group v-model="building.isMain">
84
+            <el-radio :label="1">是</el-radio>
85
+            <el-radio :label="0">否</el-radio>
86
+          </el-radio-group>
87
+        </el-form-item>
88
+        <el-form-item label="项目备注">
89
+          <div id="websiteEditorElem" style="height: 400px"></div>
90
+        </el-form-item>
91
+        <el-form-item label="楼盘区域">
92
+          <el-input v-model="building.buildingArea"></el-input>
93
+        </el-form-item>
94
+        <el-form-item label="项目地址">
95
+          <el-input v-model="building.address"></el-input>
96
+        </el-form-item>
97
+        <el-form-item label="项目坐标">
98
+          <el-input v-model="building.coordinate" :disabled="true"></el-input>
99
+        </el-form-item>
100
+        <el-form-item label="项目地址">
101
+          <div class="search">
102
+            <el-amap-search-box class="search-box" :search-option="searchOption" :on-search-result="onSearchResult"></el-amap-search-box>
103
+          </div>
104
+          <div class="flex-item">
105
+            <div style="width: 100%;">
106
+              <el-amap ref="map" vid="amapDemo" :center="mapCenter" :zoom="12" :events="events" class="amap-demo">
107
+                <el-amap-marker v-for="(item,index) in markers" :key="index" :position="item" ></el-amap-marker>
108
+              </el-amap>
109
+            </div>
110
+          </div>  
111
+        </el-form-item>
112
+        <el-form-item>
113
+          <el-button type="primary" @click="onSubmit">保存</el-button>
114
+          <el-button @click="onCancel">取消</el-button>
115
+        </el-form-item>
116
+      </el-form>
117
+    </el-tab-pane>
118
+    <el-tab-pane label="图片设置" name="apartment" v-if="detail.buildingId">
119
+      <div class="system-table-search">
120
+        <div class="flex-h">
121
+          <div class="flex-item flex-h">
122
+            <el-button size="mini" type="success" @click='addHx'>新增图片库</el-button>
123
+          </div>
124
+        </div>
125
+      </div>
126
+      <el-table
127
+        :data="aparments"
128
+        style="width: 100%">
129
+        <el-table-column
130
+          prop="apartmentName"
131
+          label="名称"
132
+        >
133
+        </el-table-column>
134
+        <el-table-column
135
+          prop="apartmentType"
136
+          label="类型"
137
+        >
138
+          <template slot-scope="scope">
139
+            <span>{{scope.row.apartmentType == 'apart'?'户型':'相册'}}</span>
140
+          </template>
141
+        </el-table-column>
142
+        <el-table-column
143
+          prop="marketStatus"
144
+          label="销售状态"
145
+        >
146
+          <template slot-scope="scope">
147
+            <span>{{getSaleTypeName(scope.row.marketStatus)}}</span>
148
+          </template>
149
+        </el-table-column>
150
+        <el-table-column
151
+          prop="remark"
152
+          label="备注"
153
+        >
154
+        </el-table-column>
155
+        <el-table-column
156
+          prop="createDate"
157
+          label="创建时间"
158
+        >
159
+        </el-table-column>
160
+        <el-table-column
161
+          fixed="right"
162
+          label="操作"
163
+          width="180">
164
+          <template slot-scope="scope">
165
+            <el-button type="text" @click="handleEdit(scope.row)" size="small">编辑</el-button>
166
+            <el-button @click="handleDel(scope.row)" type="text" size="small">删除</el-button>
167
+          </template>
168
+        </el-table-column>
169
+      </el-table>
170
+      <el-dialog title="图片信息" :visible.sync="showHx">
171
+        <el-form ref="form" :model="aparmentInfo" label-width="160px">
172
+          <el-form-item label="名称">
173
+            <el-input v-model="aparmentInfo.apartmentName"></el-input>
174
+          </el-form-item>
175
+          <el-form-item label="类型">
176
+            <el-select v-model="aparmentInfo.apartmentType" placeholder="请选择">
177
+              <el-option label="户型" value="apart"></el-option>
178
+              <el-option label="相册" value="photo"></el-option>
179
+            </el-select>
180
+          </el-form-item>
181
+          <el-form-item label="销售状态">
182
+            <el-select v-model="aparmentInfo.marketStatus" placeholder="请选择">
183
+              <el-option v-for="(type,i) in saleType" :key="i" :label="type.name" :value="type.id"></el-option>
184
+            </el-select>
185
+          </el-form-item>
186
+          <el-form-item label="图片">
187
+            <el-upload
188
+              :action="upFileUrl"
189
+              name='file'
190
+              list-type="picture-card"
191
+              :file-list="aparmentImg"
192
+              :show-file-list="true"
193
+              :before-upload="beforeImgUpload"
194
+              :on-success="handleAparmentSuccess"
195
+              :on-remove="handleAparmentRemove">
196
+              <i class="el-icon-plus"></i>
197
+            </el-upload>
198
+            <el-dialog :visible.sync="dialogApartVisible">
199
+              <img width="100%" :src="dialogApartImageUrl" alt="">
200
+            </el-dialog>
201
+          </el-form-item>
202
+          <el-form-item label="备注">
203
+            <el-input type="textarea" v-model="aparmentInfo.remark"></el-input>
204
+          </el-form-item>
205
+          <el-form-item>
206
+            <el-button type="primary" @click="saveAparment">保存</el-button>
207
+            <el-button @click="showHx = false">取消</el-button>
208
+          </el-form-item>
209
+        </el-form>
210
+      </el-dialog>
211
+    </el-tab-pane>
212
+  </el-tabs>
213
+</template>
214
+
215
+<script>
216
+import { createNamespacedHelpers } from 'vuex'
217
+import apis from '../../config/api'
218
+import { mapState } from 'vuex'
219
+import E from 'wangeditor'
220
+
221
+const { mapState: mapBuildingState, mapActions: mapBuildingActions, mapMutations: mapBuildingMutations } = createNamespacedHelpers('building')
222
+
223
+const { mapActions: mapApartmentActions } = createNamespacedHelpers('apartment')
224
+
225
+const { mapActions: mapImgActions } = createNamespacedHelpers('img')
226
+
227
+export default {
228
+  data () {
229
+    var _self = this
230
+    return {
231
+      upFileUrl: apis.file.upload.url,
232
+      commPrefix: '',
233
+      imgurl: '',
234
+      loadingZm: false,
235
+      activeName: 'detail',
236
+      dialogImageUrl: '',
237
+      dialogVisible: false,
238
+      dialogApartImageUrl: '',
239
+      dialogApartVisible: false,
240
+      showHx: false,
241
+      markers: [],
242
+      imgList: [],
243
+      tags: [],
244
+      buildingProperty: [],
245
+      aparments: [],
246
+      aparmentInfo: {},
247
+      aparmentImg: [],
248
+      searchOption: {
249
+        city: '南京',
250
+        citylimit: false
251
+      },
252
+      mapCenter: [118.789509, 32.019989],
253
+      events: {
254
+        click: (e) => {
255
+          _self.updateDetail({..._self.building, coordinate: e.lnglat.lat + ',' + e.lnglat.lng})
256
+        }
257
+      },
258
+    }
259
+  },
260
+  computed: {
261
+    ...mapBuildingState({
262
+      detail: x => x.detail,
263
+    }),
264
+    ...mapState({
265
+      dicts: x =>  x.dicts,
266
+    }),
267
+    building: {
268
+      get () {
269
+        return this.detail
270
+      },
271
+      set (val) {
272
+        return this.updateDetail(val)
273
+      }
274
+    },
275
+    propertyType () {
276
+      return (this.dicts || []).filter(x => x.type === 'propertyType')
277
+    },
278
+    saleType () {
279
+      return (this.dicts || []).filter(x => x.type === 'saleType')
280
+    }
281
+  },
282
+  methods: {
283
+    ...mapBuildingMutations([
284
+      'updateDetail'
285
+    ]),
286
+    ...mapBuildingActions([
287
+      'getDetail',
288
+      'addBuilding',
289
+      'editBuilding'
290
+    ]),
291
+    ...mapApartmentActions([
292
+      'getApartments',
293
+      'getApartmentDetail',
294
+      'addApartment',
295
+      'editApartment',
296
+      'deleteApartment'
297
+    ]),
298
+    ...mapImgActions([
299
+      'uploadImg'
300
+    ]),
301
+    getSaleTypeName (id) {
302
+      return ((this.dicts || []).filter(x => x.type === 'saleType' && x.id == id) [0] || {}).name
303
+    },
304
+    onCancel () {
305
+      this.$router.push({name: 'buildinglist'})
306
+    },
307
+    handleRemove (file, fileList) {
308
+      this.imgList = fileList
309
+    },
310
+    handleAparmentRemove (file, fileList) {
311
+      this.aparmentImg = fileList
312
+    },
313
+    onSearchResult (pois) { // 搜索地图
314
+      let latSum = 0
315
+      let lngSum = 0
316
+      if (pois.length > 0) {
317
+        pois.forEach(poi => {
318
+          let { lng, lat } = poi
319
+          lngSum += lng
320
+          latSum += lat
321
+          this.markers.push([poi.lng, poi.lat])
322
+        })
323
+        let center = {
324
+          lng: lngSum / pois.length,
325
+          lat: latSum / pois.length
326
+        }
327
+        this.mapCenter = [center.lng, center.lat]
328
+      }
329
+    },
330
+    beforeImgUpload (file) {
331
+      if (file.type !== 'image/jpeg' && file.type !== 'image/png') {
332
+        this.$message.error('上传图片只能是 JPG 或 PNG 格式!')
333
+        return false
334
+      }
335
+      // if (file.size / 1024 > 300) {
336
+      //   this.$message.error('图片大小不允许超过300k!')
337
+      //   return false
338
+      // }
339
+      this.loading = this.$loading({
340
+        lock: true,
341
+        text: '上传中...',
342
+        spinner: 'el-icon-loading',
343
+        background: 'rgba(0, 0, 0, 0.7)'
344
+      })
345
+
346
+      return true
347
+    },
348
+    handleAvatarSuccess (res) {
349
+      this.imgList = [...this.imgList, {
350
+        url: res.data
351
+      }]
352
+      this.loading.close()
353
+    },
354
+    handleMapImgSuccess(res) {
355
+      this.building = {...this.building, mapImg: res.data }
356
+      this.loading.close()
357
+    },
358
+    handleAparmentSuccess (res) {
359
+      this.aparmentImg = [...this.aparmentImg, {
360
+        url: res.data
361
+      }]
362
+      this.loading.close()
363
+    },
364
+    onSubmit () {
365
+      const imgs = this.imgList.map((x, i) => {
366
+        return {
367
+          imgType: 'banner',
368
+          url: x.url,
369
+          orderNo: (i + 1)
370
+        }
371
+      })
372
+      const tag = this.tags.map(x => {
373
+        return {
374
+          tagName: x
375
+        }
376
+      })
377
+      const building = {...this.building, img: imgs, propertyType: this.buildingProperty.join(','), tag}
378
+      if (!building.buildingId) {
379
+        // 新增
380
+        this.addBuilding({
381
+          onSuccess: this.onCancel,
382
+          detail: JSON.stringify(building)
383
+        })
384
+      } else {
385
+        // 修改
386
+        this.editBuilding({
387
+          onSuccess: this.onCancel,
388
+          detail: JSON.stringify(building)
389
+        })
390
+      }
391
+    },
392
+    FormatDate (date) {
393
+      return (date || '').split('T')[0] === '0001-01-01' ? '' : (date || '').split('T')[0]
394
+    },
395
+    saveAparment () {
396
+      const imgs = this.aparmentImg.map((x, i) => {
397
+        return {
398
+          imgType: 'aparment',
399
+          url: x.url,
400
+          orderNo: (i + 1)
401
+        }
402
+      })
403
+      if (!this.aparmentInfo.apartmentId) {
404
+        this.addApartment(JSON.stringify({
405
+          ...this.aparmentInfo,
406
+          img: imgs
407
+        })).then(() => {
408
+          this.getAparmentList()
409
+          this.showHx = false
410
+        })
411
+      } else {
412
+        this.editApartment(JSON.stringify({
413
+          ...this.aparmentInfo,
414
+          img: imgs
415
+        })).then(() => {
416
+          this.getAparmentList()
417
+          this.showHx = false
418
+        })
419
+      }
420
+    },
421
+    addHx () {
422
+      this.aparmentImg = []
423
+      this.aparmentInfo = {buildingId: this.building.buildingId}
424
+      this.showHx = true
425
+    },
426
+    getAparmentList () {
427
+      this.getApartments({buildingId: this.$route.query.id}).then(data => {
428
+        this.aparments = data
429
+      })
430
+    },
431
+    handleEdit (row) {
432
+      this.aparmentImg = []
433
+      this.getApartmentDetail({
434
+        id: row.apartmentId
435
+      }).then(data => {
436
+        console.log("...",data)
437
+        this.aparmentImg = data.buildingImgList.map(x => {
438
+          return {
439
+            name: x.imgId,
440
+            url: x.url
441
+          }
442
+        })
443
+        this.aparmentInfo = data
444
+        this.showHx = true
445
+      })
446
+    },
447
+    handleDel (row) {
448
+      this.$confirm('确认删除此数据?', '提示', {
449
+        confirmButtonText: '确定',
450
+        cancelButtonText: '取消',
451
+        type: 'warning'
452
+      }).then(() => {
453
+        if (this.building.status === 1) {
454
+          this.$message.error('当前楼盘处于发布状态,不允许删除!')
455
+          return false
456
+        }
457
+        this.deleteApartment({
458
+          id: row.apartmentId
459
+        }).then(() => {
460
+          this.getAparmentList()
461
+        })
462
+      })
463
+    }
464
+  },
465
+  mounted () {
466
+    const _that = this
467
+    const phoneEditor = new E('#websiteEditorElem')
468
+    phoneEditor.customConfig.onchange = function (html) {
469
+      _that.building = {..._that.building, remark: html}
470
+    }
471
+    phoneEditor.customConfig.customUploadImg = function (files, insert) {
472
+      _that.uploadImg(files[0]).then(data => {
473
+        insert(data[0])
474
+      })
475
+    }
476
+    phoneEditor.customConfig.menus = [
477
+      'head',  // 标题
478
+      'bold',  // 粗体
479
+      'fontSize',  // 字号
480
+      'fontName',  // 字体
481
+      'italic',  // 斜体
482
+      'underline',  // 下划线
483
+      'strikeThrough',  // 删除线
484
+      'foreColor',  // 文字颜色
485
+      'backColor',  // 背景颜色
486
+      'justify',  // 对齐方式
487
+      'image',  // 插入图片
488
+    ]
489
+    phoneEditor.create()
490
+    if ((this.$route.query.id || '') !== '') {
491
+      this.getAparmentList()
492
+      window.console.log(this.getDetail)
493
+      this.getDetail({id: this.$route.query.id}).then(data => {
494
+        this.buildingProperty = data.propertyType.split(',')
495
+        phoneEditor.txt.html(data.remark)
496
+        this.imgList = data.buildingImg.map(x => {
497
+          return {
498
+            name: x.imgId,
499
+            url: x.url
500
+          }
501
+        })
502
+        this.tags = data.buildingTag.map(x => x.tagName)
503
+      })
504
+    } else {
505
+      phoneEditor.txt.html('')
506
+    }
507
+  }
508
+}
509
+</script>
510
+
511
+<style lang="scss">
512
+.header{
513
+  width: 50px;
514
+  height: 50px;
515
+  img{
516
+    width: 100%;
517
+    height: 100%;
518
+  }
519
+}
520
+.avatar-uploader .el-upload {
521
+  border: 1px dashed #d9d9d9;
522
+  border-radius: 6px;
523
+  cursor: pointer;
524
+  position: relative;
525
+  overflow: hidden;
526
+}
527
+.avatar-uploader .el-upload:hover {
528
+  border-color: #409EFF;
529
+}
530
+.avatar-uploader-icon {
531
+  font-size: 28px;
532
+  color: #8c939d;
533
+  width: 178px;
534
+  height: 178px;
535
+  line-height: 178px;
536
+  text-align: center;
537
+}
538
+.avatar {
539
+  width: 178px;
540
+  height: 178px;
541
+  display: block;
542
+}
543
+
544
+.flex-item .amap-demo{
545
+  height: 300px;
546
+}
547
+
548
+.el-select{
549
+  width: 100% !important;
550
+}
551
+
552
+.el-select-dropdown{
553
+  z-index: 10003 !important;
554
+}
555
+
556
+.el-date-picker{
557
+  z-index: 10002 !important;
558
+}
559
+</style>

+ 273
- 0
src/views/building/list.vue Ver fichero

@@ -0,0 +1,273 @@
1
+<template>
2
+  <div>
3
+    <div class="system-table-search">
4
+      <div class="flex-h">
5
+        <div class="flex-item flex-h">
6
+          <el-button size="mini" type="success" @click='addBuilding'>新增楼盘</el-button>
7
+        </div>
8
+        <ul>
9
+          <li>
10
+            <el-input v-model="code" placeholder="楼盘编号"></el-input>
11
+          </li>
12
+          <li>
13
+            <el-input v-model="name" placeholder="楼盘名称"></el-input>
14
+          </li>
15
+        </ul>
16
+        <el-button
17
+          size="mini"
18
+          type="primary" @click="search">搜索</el-button>
19
+      </div>
20
+      <div class="moreFilter"></div>
21
+    </div>
22
+    <el-table
23
+      :data="buildings.list || []"
24
+      style="width: 100%">
25
+      <el-table-column
26
+        type="index"
27
+        width="50">
28
+        <template slot-scope="scope">
29
+          <span>{{ GetIndex(scope.$index) }}</span>
30
+        </template>
31
+      </el-table-column>
32
+      <el-table-column
33
+        prop="code"
34
+        label="楼盘编号">
35
+      </el-table-column>
36
+      <el-table-column
37
+        prop="buildingName"
38
+        label="楼盘名称"
39
+        width="180">
40
+      </el-table-column>
41
+      <el-table-column
42
+        prop="price"
43
+        label="均价"
44
+        width="180">
45
+        <template slot-scope="scope">
46
+          <span style="color:red">{{scope.row.price}}</span>
47
+        </template>
48
+      </el-table-column>
49
+      <el-table-column
50
+        prop="openingDate"
51
+        label="开盘时间">
52
+        <template slot-scope="scope">
53
+          <span>{{(scope.row.openingDate || '').split(' ')[0]}}</span>
54
+        </template>
55
+      </el-table-column>
56
+      <el-table-column
57
+        prop="address"
58
+        label="项目地址">
59
+      </el-table-column>
60
+      <el-table-column
61
+        prop="propertyType"
62
+        label="物业类型">
63
+        <template slot-scope="scope">
64
+          <span>{{getPropertyType(scope.row.propertyType)}}</span>
65
+        </template>
66
+      </el-table-column>
67
+      <el-table-column
68
+        prop="tel"
69
+        label="销售电话">
70
+      </el-table-column>
71
+      <el-table-column
72
+        prop="createDate"
73
+        label="录入时间">
74
+        <template slot-scope="scope">
75
+          <span>{{(scope.row.createDate || '').split(' ')[0]}}</span>
76
+        </template>
77
+      </el-table-column>
78
+      <el-table-column
79
+        label="发布状态">
80
+        <template slot-scope="scope">
81
+          <span>{{scope.row.status == 1 ? '已发布' : '未发布'}}</span>
82
+        </template>
83
+      </el-table-column>
84
+      <el-table-column
85
+        fixed="right"
86
+        label="操作"
87
+        width="180">
88
+        <template slot-scope="scope">
89
+          <el-button type="text" @click="handleEdit(scope.row)" size="small">编辑</el-button>
90
+          <el-button type="text" @click="handlePulic(scope.row)" size="small" v-if="scope.row.status === 0">发布</el-button>
91
+          <el-button type="text" @click="handleUnPulic(scope.row)" size="small" v-if="scope.row.status === 1">取消发布</el-button>
92
+          <el-button @click="handleDel(scope.row)" type="text" size="small">删除</el-button>
93
+        </template>
94
+      </el-table-column>
95
+    </el-table>
96
+    <el-pagination
97
+      small
98
+      style="margin-top:10px;"
99
+      layout="prev, pager, next"
100
+      :current-page.sync="currentPage"
101
+      :pageSize="pageSize"
102
+      :total="buildings.total || 0"
103
+      @current-change="getList"
104
+    >
105
+    </el-pagination>
106
+  </div>
107
+</template>
108
+
109
+<script>
110
+import { createNamespacedHelpers } from 'vuex';
111
+const {mapState: mapBuildingState, mapActions: mapBuildingActions} = createNamespacedHelpers('building')
112
+import { mapState } from 'vuex'
113
+
114
+export default {
115
+  data() {
116
+    return {
117
+      pageSize: 20,
118
+      currentPage: 1,
119
+      code: '',
120
+      name: ''
121
+    }
122
+  },
123
+  computed: {
124
+    ...mapBuildingState({
125
+      buildings: x => x.buildings
126
+    }),
127
+    ...mapState({
128
+      dicts: x =>  x.dicts,
129
+    }),
130
+  },
131
+  methods: {
132
+    ...mapBuildingActions([
133
+      'setDetailNull',
134
+      'getBuildings',
135
+      'updateBuildingStatus',
136
+      'delBuilding'
137
+    ]),
138
+    getPropertyType (types) {
139
+      let typeNames = ''
140
+      let typeArr = types.split(',')
141
+      const _that = this
142
+      typeArr.map(x => {
143
+        const name = ((_that.dicts || []).filter(d => d.type === 'propertyType' && d.id == x)[0] || {}).name
144
+        if (name) {
145
+          typeNames = typeNames + (typeNames===''?'':',') + name
146
+        }
147
+      })
148
+      return typeNames
149
+    },
150
+    GetIndex (inx) {
151
+      return (this.currentPage - 1) * this.pageSize + inx + 1
152
+    },
153
+    // FormatDate (date) {
154
+    //   if (date) {
155
+    //     return date.split(' ')[0] === '0001-01-01' ? '' : date.split(' ')[0]
156
+    //   } else {
157
+    //     return ''
158
+    //   }
159
+    // },
160
+    getList () {
161
+      this.getBuildings({
162
+        pageNum: this.currentPage,
163
+        pageSize: this.pageSize,
164
+        code: this.code,
165
+        name: this.name
166
+      })
167
+    },
168
+    search () {
169
+      this.currentPage = 1
170
+      this.getList()
171
+    },
172
+    addBuilding () {
173
+      this.setDetailNull()
174
+      this.$router.push({name: 'buildingedit'})
175
+    },
176
+    handleEdit (row) {
177
+      this.setDetailNull()
178
+      this.$router.push({name: 'buildingedit', query: {id: row.buildingId}})
179
+    },
180
+    handlePulic (row) {
181
+      this.$confirm('确认发布此数据?', '提示', {
182
+        confirmButtonText: '确定',
183
+        cancelButtonText: '取消',
184
+        type: 'warning'
185
+      }).then(() => {
186
+        this.updateBuildingStatus({
187
+          id: row.buildingId,
188
+          status: 1
189
+        }).then(() => {
190
+          this.getList()
191
+        })
192
+      })
193
+    },
194
+    handleUnPulic (row) {
195
+      this.$confirm('确认取消发布此数据?', '提示', {
196
+        confirmButtonText: '确定',
197
+        cancelButtonText: '取消',
198
+        type: 'warning'
199
+      }).then(() => {
200
+        this.updateBuildingStatus({
201
+          id: row.buildingId,
202
+          status: 0
203
+        }).then(() => {
204
+          this.getList()
205
+        })
206
+      })
207
+    },
208
+    handleDel (row) {
209
+      this.$confirm('确认删除此数据?', '提示', {
210
+        confirmButtonText: '确定',
211
+        cancelButtonText: '取消',
212
+        type: 'warning'
213
+      }).then(() => {
214
+        if (row.status === 1) {
215
+          this.$message.error('当前楼盘处于发布状态,不允许删除!')
216
+          return false
217
+        }
218
+        this.delBuilding({
219
+          id: row.buildingId
220
+        }).then(() => {
221
+          this.getList()
222
+        })
223
+      })
224
+    }
225
+  },
226
+  created () {
227
+    this.getList()
228
+  }
229
+}
230
+</script>
231
+
232
+<style lang="scss" scoped>
233
+.list{
234
+    .header{
235
+      width: 50px;
236
+      height: 50px;
237
+      img{
238
+        width: 100%;
239
+        height: 100%;
240
+      }
241
+    }
242
+  }
243
+
244
+.system-table-search{
245
+  width: calc(100% - 40px);
246
+  margin: 20px auto 0;
247
+}
248
+
249
+.system-table-search li{
250
+  margin-right: 20px;
251
+}
252
+
253
+.system-table-search ul{
254
+  font-size: 0;
255
+  white-space: nowrap;
256
+}
257
+
258
+.system-table-search ul>li{
259
+  display: inline-block;
260
+}
261
+
262
+.flex-h {
263
+  display: flex;
264
+  display: -webkit-flex;
265
+}
266
+
267
+.flex-item {
268
+  flex: 1;
269
+  -webkit-flex: 1;
270
+  position: relative;
271
+  overflow: hidden;
272
+}
273
+</style>

+ 17
- 0
src/views/index.js Ver fichero

@@ -65,6 +65,23 @@ const pages = [
65 65
           menuShow: false,
66 66
           title: '项目动态编辑',
67 67
         },
68
+      },
69
+      {
70
+        path: 'buildinglist',
71
+        name: 'buildinglist',
72
+        component: () => import('./building/list.vue'),
73
+        meta: {
74
+          menuShow: true,
75
+          title: '楼盘列表',
76
+        },
77
+      },
78
+      {
79
+        path: 'buildingedit',
80
+        name: 'buildingedit',
81
+        component: () => import('./building/edit.vue'),
82
+        meta: {
83
+          menuShow: false,
84
+        },
68 85
       }
69 86
     ]
70 87
   },