Kaynağa Gözat

购房资格页面,对接接口

魏熙美 5 yıl önce
ebeveyn
işleme
7eedb9cbee

+ 22
- 0
src/config/api.js Dosyayı Görüntüle

@@ -448,6 +448,28 @@ const apis = {
448 448
       method: `post`,
449 449
       url: `${commPrefix}/taBuildingIntentionAddOrUpdate/:id`
450 450
     }
451
+  },
452
+  policy: { // 购房政策
453
+    list: {
454
+      method: `get`,
455
+      url: `${commPrefix}/taPolicy`
456
+    },
457
+    add: {
458
+      method: `post`,
459
+      url: `${commPrefix}/taPolicy`
460
+    },
461
+    update: {
462
+      method: `put`,
463
+      url: `${commPrefix}/taPolicy/:id`
464
+    },
465
+    delete: {
466
+      method: `delete`,
467
+      url: `${commPrefix}/taPolicy/:id`
468
+    },
469
+    getById: {
470
+      method: `get`,
471
+      url: `${commPrefix}/taPolicy/:id`
472
+    }
451 473
   }
452 474
 }
453 475
 export default apis

+ 2
- 1
src/store/index.js Dosyayı Görüntüle

@@ -22,7 +22,8 @@ const store = new Vuex.Store({
22 22
     indexEcharts: require('./modules/indexEcharts').default,
23 23
     message: require('./modules/message').default,
24 24
     report: require('./modules/report').default,
25
-    news
25
+    news,
26
+    policy: require('./modules/policy').default
26 27
 
27 28
   }
28 29
 })

+ 80
- 0
src/store/modules/policy.js Dosyayı Görüntüle

@@ -0,0 +1,80 @@
1
+import request from '../../utils/request'
2
+import apis from '../../config/api'
3
+
4
+export default {
5
+
6
+    namespaced: true,
7
+    state: {
8
+        policyList: []
9
+    },
10
+    mutations: {
11
+        updateList(state, payload) {
12
+            state.policyList = payload.records
13
+        }
14
+    },
15
+    actions: {
16
+        getPolicyList ({ commit }, payload) {
17
+            return new Promise((resolve, reject) => {
18
+                request({
19
+                    ...apis.policy.list,
20
+                    params: payload,
21
+                }).then((data) => {
22
+                    commit('updateList', data)
23
+                    resolve(data)
24
+                }).catch((err) => {
25
+                    reject(err)
26
+                })
27
+            })
28
+        },
29
+        addPolicy ({ commit }, payload) {
30
+            return new Promise((resolve, reject) => {
31
+                request({
32
+                    ...apis.policy.add,
33
+                    data: payload,
34
+                }).then((data) => {
35
+                    resolve(data)
36
+                }).catch((err) => {
37
+                    reject(err)
38
+                })
39
+            })
40
+        },
41
+        updatePolicy ({ commit }, payload) {
42
+            return new Promise((resolve, reject) => {
43
+                request({
44
+                    ...apis.policy.update,
45
+                    urlData: { id: payload.policyId },
46
+                    data: payload,
47
+                }).then((data) => {
48
+                    resolve(data)
49
+                }).catch((err) => {
50
+                    reject(err)
51
+                })
52
+            })
53
+        },
54
+        deletePolicy ({ commit }, payload) {
55
+            return new Promise((resolve, reject) => {
56
+                request({
57
+                    ...apis.policy.delete,
58
+                    urlData: { id: payload.policyId },
59
+                }).then((data) => {
60
+                    resolve(data)
61
+                }).catch((err) => {
62
+                    reject(err)
63
+                })
64
+            })
65
+        },
66
+        getByIdPolicy ({ commit }, payload) {
67
+            return new Promise((resolve, reject) => {
68
+                request({
69
+                    ...apis.policy.getById,
70
+                    urlData: { id: payload.policyId },
71
+                }).then((data) => {
72
+                    resolve(data)
73
+                }).catch((err) => {
74
+                    reject(err)
75
+                })
76
+            })
77
+        },
78
+    }
79
+
80
+}

+ 18
- 0
src/views/index.js Dosyayı Görüntüle

@@ -374,6 +374,24 @@ const pages = [
374 374
           title: '意向值',
375 375
         },
376 376
       },
377
+      {
378
+        path: 'housingPolicy',
379
+        name: 'housingPolicy',
380
+        component: () => import('./systemManagement/policy/housingPolicy.vue'),
381
+        meta: {
382
+          menuShow: true,
383
+          title: '购房政策维护',
384
+        },
385
+      },
386
+      {
387
+        path: 'housingPolicyEdi',
388
+        name: 'housingPolicyEdi',
389
+        component: () => import('./systemManagement/policy/edi/index.vue'),
390
+        meta: {
391
+          menuShow: false,
392
+          title: '编辑购房政策',
393
+        },
394
+      },
377 395
     ]
378 396
   },
379 397
   {

+ 177
- 0
src/views/systemManagement/policy/edi/index.vue Dosyayı Görüntüle

@@ -0,0 +1,177 @@
1
+<template>
2
+    <div id="root">
3
+        <el-form ref="form" :model="form" label-width="80px" class="form-class">
4
+            <el-form-item label="城市">
5
+                <el-select v-model="form.cityId" filterable  placeholder="城市">
6
+                    <el-option
7
+                            v-for="item in cityList"
8
+                            :key="item.id"
9
+                            :label="item.name"
10
+                            :value="item.id">
11
+                    </el-option>
12
+                </el-select>
13
+            </el-form-item>
14
+            <el-form-item label="政策图片">
15
+                <el-upload
16
+                        class="avatar-uploader"
17
+                        :headers="uploadHeaders"
18
+                        :action="upFileUrl"
19
+                        :show-file-list="false"
20
+                        :on-success="handleAvatarSuccess">
21
+                    <img v-if="imageUrl" :src="imageUrl" class="avatar">
22
+                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
23
+                </el-upload>
24
+            </el-form-item>
25
+            <el-form-item label="政策标题">
26
+                <el-input v-model="form.title"></el-input>
27
+            </el-form-item>
28
+            <el-form-item label="政策详情">
29
+                <rich-editor v-model="form.body" style="height: 400px; width: 1000px;"></rich-editor>
30
+            </el-form-item>
31
+            <el-form-item label="状态">
32
+                <el-select v-model="form.publishStatus" >
33
+                    <el-option
34
+                            v-for="item in publishStatusList"
35
+                            :key="item.id"
36
+                            :label="item.name"
37
+                            :value="item.id">
38
+                    </el-option>
39
+                </el-select>
40
+            </el-form-item>
41
+            <el-form-item>
42
+                <el-button type="primary" @click="onSubmit">确认</el-button>
43
+                <el-button @click="$router.go(-1)">取消</el-button>
44
+            </el-form-item>
45
+        </el-form>
46
+    </div>
47
+</template>
48
+
49
+<script>
50
+    import apis from '../../../../config/api'
51
+    export default {
52
+        name: "policyEdi",
53
+        computed: {
54
+            uploadHeaders () {
55
+                const token = localStorage.getItem('x-token') || ''
56
+                return {
57
+                    Authorization: `Bearer ${token}`
58
+                }
59
+            }
60
+        },
61
+        data() {
62
+            return {
63
+                upFileUrl: apis.file.upload.url,
64
+                cityList: [],
65
+                form: {
66
+                    cityId: '',
67
+                    title: '',
68
+                    body: '',
69
+                    publishStatus: '',
70
+                    policyImg: '',
71
+                    policyId: ''
72
+                },
73
+                imageUrl: '',
74
+                publishStatusList: [
75
+                    {
76
+                        id: 0,
77
+                        name: '未发布'
78
+                    },
79
+                    {
80
+                        id: 1,
81
+                        name: '已发布'
82
+                    }
83
+                ]
84
+            }
85
+
86
+        },
87
+        methods: {
88
+            onSubmit() {
89
+                // 添加
90
+                if ( this.form.policyId === undefined || this.form.policyId === '' ) {
91
+                    this.$store.dispatch('policy/addPolicy', this.form).then((res) => {
92
+                        this.$notify.success('操作成功')
93
+                        this.$router.go(-1)
94
+                    }).catch((err) => {
95
+                        this.$notify.error(err.msg || err.message);
96
+                    })
97
+
98
+                    return
99
+                }
100
+
101
+                // 修改
102
+                this.$store.dispatch('policy/updatePolicy', this.form).then((res) => {
103
+                    this.$notify.success('操作成功')
104
+                    this.$router.go(-1)
105
+                }).catch((err) => {
106
+                    this.$notify.error(err.msg || err.message);
107
+                })
108
+
109
+            },
110
+            getCityName() { // 查询城市
111
+                this.$store.dispatch('building/getCityName').then((res) => {
112
+                    this.cityList = res
113
+                }).catch((err) => {
114
+                    this.$notify.error(err.msg || err.message)
115
+                })
116
+            },
117
+            handleAvatarSuccess(res, file) { // 资讯图
118
+                if (res.code !== 1000) {
119
+                    this.$notify.error(res.msg || res.message)
120
+                    return
121
+                }
122
+                this.imageUrl = URL.createObjectURL(file.raw);
123
+                // console.log(res)
124
+                this.form.policyImg = res.data
125
+            },
126
+            getInfo() {
127
+                this.$store.dispatch('policy/getByIdPolicy', this.form).then((res) => {
128
+                    this.form = res
129
+                    this.imageUrl = res.policyImg
130
+                }).catch((err) => {
131
+                    this.$notify.error(err.msg || err.message);
132
+                })
133
+            }
134
+        },
135
+        mounted() {
136
+            this.form.policyId = this.$route.query.id
137
+            if (this.form.policyId !== undefined || this.form.policyId !== '' ) {
138
+                this.getInfo()
139
+            }
140
+            this.getCityName()
141
+        }
142
+    }
143
+</script>
144
+<style lang="scss" scoped>
145
+    .form-class {
146
+        width: 1000px;
147
+        margin-right: auto;
148
+        margin-left: auto;
149
+
150
+    }
151
+</style>
152
+
153
+<style lang="scss">
154
+    .avatar-uploader .el-upload {
155
+        border: 1px dashed #d9d9d9;
156
+        border-radius: 6px;
157
+        cursor: pointer;
158
+        position: relative;
159
+        overflow: hidden;
160
+    }
161
+    .avatar-uploader .el-upload:hover {
162
+        border-color: #409EFF;
163
+    }
164
+    .avatar-uploader-icon {
165
+        font-size: 28px;
166
+        color: #8c939d;
167
+        width: 178px;
168
+        height: 178px;
169
+        line-height: 178px;
170
+        text-align: center;
171
+    }
172
+    .avatar {
173
+        width: 178px;
174
+        height: 178px;
175
+        display: block;
176
+    }
177
+</style>

+ 178
- 0
src/views/systemManagement/policy/housingPolicy.vue Dosyayı Görüntüle

@@ -0,0 +1,178 @@
1
+<template>
2
+    <div id="root">
3
+        <el-select v-model="form.cityId" filterable  placeholder="城市" @change="getList">
4
+            <el-option
5
+                    v-for="item in cityList"
6
+                    :key="item.id"
7
+                    :label="item.name"
8
+                    :value="item.id">
9
+            </el-option>
10
+        </el-select>
11
+        <div style="margin-top: 20px;">
12
+            <el-button type="primary" @click="toEdi">新增</el-button>
13
+        </div>
14
+
15
+        <el-table
16
+                :data="list"
17
+                border
18
+                style="width: 100%;margin-top: 20px;">
19
+            <el-table-column
20
+                    align="center"
21
+                    prop="policyImg"
22
+                    label="购房政策主图">
23
+                <template slot-scope="scope">
24
+                    <el-image
25
+                            style="width: 100px; height: 100px;"
26
+                            :src="scope.row.policyImg"
27
+                            fit="fill"></el-image>
28
+                </template>
29
+            </el-table-column>
30
+            <el-table-column
31
+                    align="center"
32
+                    prop="title"
33
+                    label="标题">
34
+            </el-table-column>
35
+            <el-table-column
36
+                    align="center"
37
+                    prop="cityName"
38
+                    label="城市">
39
+            </el-table-column>
40
+            <el-table-column
41
+                    align="center"
42
+                    prop="createDate"
43
+                    label="创建时间">
44
+                <template slot-scope="scope">{{ formateDate(scope.row.createDate) }}</template>
45
+            </el-table-column>
46
+            <el-table-column
47
+                    align="center"
48
+                    prop="status"
49
+                    label="状态">
50
+                <template slot-scope="scope">{{ scope.row.publishStatus === 1 ? '已发布' : '未发布' }}</template>
51
+            </el-table-column>
52
+            <el-table-column
53
+                    align="center"
54
+                    prop="status"
55
+                    label="操作">
56
+                <template slot-scope="scope">
57
+                    <router-link :to="{ name: 'housingPolicyEdi', query:{ id: scope.row.policyId} }">
58
+                        编辑
59
+                    </router-link>
60
+                    &nbsp;
61
+                    <a href="javascript:void(0)" @click="deletePolicy(scope.row)">删除</a>
62
+                    &nbsp;
63
+                    <!-- 状态为 0 显示发布,1 显示未发布资源!因为这是发布 和 取消发布按钮 -->
64
+                    <a href="javascript:void(0)" @click="publicOrNoPublic(scope.row)">{{ scope.row.publishStatus === 0 ? '发布' : '取消发布' }}</a>
65
+                    &nbsp;
66
+                    <a href="javascript:void(0)" @click="top(scope.row)">{{ (scope.row.weight === 0 || scope.row.weight === null || scope.row.weight === undefined) ? '置顶' : '取消置顶' }}</a>
67
+                </template>
68
+            </el-table-column>
69
+        </el-table>
70
+
71
+        <el-pagination
72
+                layout="prev, pager, next"
73
+                @current-change="handleCurrentChange"
74
+                :current-page="form.pageNumber"
75
+                :page-size="form.pageSize"
76
+                :total="total">
77
+        </el-pagination>
78
+    </div>
79
+</template>
80
+
81
+<script>
82
+    import dayjs from 'dayjs'
83
+    export default {
84
+        name: "housingPolicy",
85
+        data() {
86
+          return {
87
+              form: {
88
+                  cityId: '',
89
+                  pageNumber: 1,
90
+                  pageSize: 20
91
+              },
92
+              cityList: [],
93
+              list: [],
94
+              total: 0
95
+          }
96
+        },
97
+        methods: {
98
+            formateDate(dt) {
99
+                return !dt ? '' : dayjs(dt).format('YYYY-MM-DD HH:mm')
100
+            },
101
+            getCityName() { // 查询城市
102
+                this.$store.dispatch('building/getCityName').then((res) => {
103
+                    this.cityList = res
104
+                }).catch((err) => {
105
+                    this.$notify.error(err.msg || err.message)
106
+                })
107
+            },
108
+            handleCurrentChange(val) {
109
+                console.log(`当前页: ${val}`);
110
+                this.form.pageNumber = val
111
+                this.getList()
112
+            },
113
+            getList() {
114
+                this.$store.dispatch('policy/getPolicyList', this.form).then((res) => {
115
+                    this.list = res.records
116
+                    this.form.pageNumber = res.current
117
+                    this.form.pageSize = res.size
118
+                    this.total = res.total
119
+                }).catch((err) => {
120
+                    this.$notify.error(err)
121
+                })
122
+            },
123
+            toEdi() {
124
+                this.$router.push({ name: 'housingPolicyEdi' })
125
+            },
126
+            deletePolicy(row) {
127
+                row.status = 0
128
+                this.$store.dispatch('policy/deletePolicy', row).then((res) => {
129
+                    this.$notify.success('操作成功')
130
+                    this.getList()
131
+                }).catch((err) => {
132
+                    this.$notify.error(err)
133
+                })
134
+            },
135
+            top(row, bool) { // 置顶
136
+                let weight = ''
137
+                if (bool) {
138
+                    weight = Math.abs(row.weight + 1)
139
+                } else {
140
+                    weight = Math.abs(row.weight - 1)
141
+                }
142
+
143
+                row.weight = weight
144
+                this.$store.dispatch('policy/updatePolicy', row).then((res) => {
145
+                    this.$notify.success('操作成功')
146
+                    this.getList()
147
+                }).catch((err) => {
148
+                    this.$notify.error(err)
149
+                })
150
+            },
151
+            publicOrNoPublic(row) { // 发布 或 取消发布
152
+                if (row.publishStatus === 1) {
153
+                    // 未发布
154
+                    row.publishStatus = 0
155
+                } else {
156
+                    // 发布
157
+                    row.publishStatus = 1
158
+                }
159
+
160
+                this.$store.dispatch('policy/updatePolicy', row).then((res) => {
161
+                    this.$notify.success('操作成功')
162
+                    this.getList()
163
+                }).catch((err) => {
164
+                    this.$notify.error(err)
165
+                })
166
+            }
167
+        },
168
+        mounted() {
169
+            this.getCityName()
170
+            this.getList()
171
+        }
172
+
173
+    }
174
+</script>
175
+
176
+<style scoped>
177
+
178
+</style>