Procházet zdrojové kódy

前、后台申请、审核页面接口联调

chaihaorui před 1 rokem
rodič
revize
e5f2c4fa4e

+ 16 - 0
src/api/homepage/apply.js

@@ -0,0 +1,16 @@
1
+import axios from "@/util/ajax";
2
+
3
+export default {
4
+    // 申请列表
5
+    applyList(params) {
6
+        return axios.get('/resourceApply/selectFrontApplyList', { params });
7
+    },
8
+    // 申请接口
9
+    applyResource(params) {
10
+        return axios.post('/resourceApply/applyResource', params);
11
+    },
12
+    // 撤销申请
13
+    revokeApply(params) {
14
+        return axios.get('/resourceApply/revokeApply', { params });
15
+    }
16
+}

+ 4 - 0
src/api/homepage/homepage.js

@@ -18,6 +18,10 @@ export default {
18 18
     apiRank(params) {
19 19
         return axios.get('/resourceDirectory/serviceCallNum', { params });
20 20
     },
21
+    // 访问量数据
22
+    visits(params) {
23
+        return axios.get('/resourceApply/selectResourceViews', { params });
24
+    },
21 25
 
22 26
     // 获取用户名
23 27
     getUserName() {

+ 12 - 0
src/api/index/audit.js

@@ -0,0 +1,12 @@
1
+import axios from "@/util/ajax";
2
+
3
+export default {
4
+    // 申请列表
5
+    applyList(params) {
6
+        return axios.get('/resourceApply/selectBackedApplyList', { params });
7
+    },
8
+    // 审核
9
+    applyResource(params) {
10
+        return axios.post('/resourceApply/approveApply', params);
11
+    }
12
+}

+ 51 - 7
src/pages/homepage/apply.vue

@@ -7,8 +7,8 @@
7 7
         label="操作"
8 8
         width="100">
9 9
         <template slot-scope="scope">
10
-            <el-button v-if="scope.row && scope.row.status === ''" @click="handleApply(scope.row)" type="text" size="small">申请</el-button>
11
-            <el-button v-if="scope.row && scope.row.status === '待审核'" @click="handleCancelApply(scope.row)" type="text" size="small">撤销申请</el-button>
10
+            <el-button v-if="scope.row && !scope.row.applyType" @click="handleApply(scope.row)" type="text" size="small">申请</el-button>
11
+            <el-button v-if="scope.row && scope.row.applyType === '1'" @click="handleCancelApply(scope.row)" type="text" size="small">撤销申请</el-button>
12 12
         </template>
13 13
       </el-table-column>
14 14
     </el-table>
@@ -20,6 +20,7 @@
20 20
   </div>
21 21
 </template>
22 22
 <script>
23
+import api from "@/api/homepage/apply.js";
23 24
 
24 25
 export default {
25 26
     components: {},
@@ -28,15 +29,15 @@ export default {
28 29
         columns: [
29 30
           {
30 31
             label: '资源名称',
31
-            key: 'nameCh'
32
+            key: 'resourceName'
32 33
           },
33 34
           {
34 35
             label: '资源类型',
35
-            key: 'nameEn'
36
+            key: 'resourceType'
36 37
           },
37 38
           {
38 39
             label: '状态',
39
-            key: 'status'
40
+            key: 'applyTypeText'
40 41
           }
41 42
         ],
42 43
         tableData: [],
@@ -46,18 +47,61 @@ export default {
46 47
       }
47 48
     },
48 49
     mounted() {
50
+      this.getTableData()
49 51
     },
50 52
     watch: {
51 53
     },
52 54
     methods: {
53 55
       handlePageChange() {
54 56
         console.log('enter handle page change')
57
+        this.getTableData()
55 58
       },
56 59
       handleApply(row) {
57
-        console.log('enter handle apply')
60
+        const {resourceId, resourceName, resourceType} = row
61
+        api.applyResource({resourceId, resourceName, resourceType}).then(res => {
62
+          if (res.success) {
63
+            this.$message({
64
+              message: '申请成功!',
65
+              type: 'success'
66
+            })
67
+            this.getTableData()
68
+          }
69
+        })
58 70
       },
59 71
       handleCancelApply(row) {
60
-        console.log('enter handle cancel apply')
72
+        const {id} = row
73
+        api.revokeApply({id}).then(res => {
74
+          if (res.success){
75
+            this.$message({
76
+              message: '撤销成功!',
77
+              type: 'success'
78
+            })
79
+            this.getTableData()
80
+          }
81
+        })
82
+      },
83
+      getTableData() {
84
+        const {pageNum, pageSize} = this
85
+        api.applyList({pageNum, pageSize}).then(res => {
86
+          this.tableData = []
87
+          res.data.records.map((item, index) => {
88
+            const newItem = {...item}
89
+            newItem.applyTypeText = this.getApplyTypeText(item.applyType)
90
+            this.tableData.push(newItem)
91
+          })
92
+          this.total = res.data.total
93
+        })
94
+      },
95
+      getApplyTypeText(val) {
96
+        if (!val){
97
+          return '未申请'
98
+        }
99
+        const textMap = {
100
+          1: '待审批',
101
+          2: '审批通过',
102
+          3: '审批驳回'
103
+        }
104
+        return textMap[val]
61 105
       }
62 106
     }
63 107
 }

+ 20 - 1
src/pages/homepage/components/cardWrap.vue

@@ -131,6 +131,13 @@
131 131
         </div>
132 132
       </div>
133 133
     </div>
134
+    <el-row class="visits-num">
135
+      <el-col :span="4">用户访问量</el-col>
136
+      <el-col :span="4">主题库:{{visits.themeViews}}</el-col>
137
+      <el-col :span="4">专题库:{{visits.specialSubjectViews}}</el-col>
138
+      <el-col :span="4">指标库:{{visits.indexViews}}</el-col>
139
+      <el-col :span="4">总线服务:{{visits.serviceViews}}</el-col>
140
+    </el-row>
134 141
   </div>
135 142
 </template>
136 143
 <script>
@@ -154,7 +161,8 @@ export default {
154 161
           indicatorStatData: [],
155 162
           rankType: 'API',
156 163
           rankData: [],
157
-          collectTotal: 0
164
+          collectTotal: 0,
165
+          visits: {}
158 166
         }
159 167
     },
160 168
     mounted() {
@@ -162,6 +170,7 @@ export default {
162 170
       this.getCollectTotal()
163 171
       this.getThemeSpecialIndex()
164 172
       this.getApiRankData()
173
+      this.getVisitsData()
165 174
     },
166 175
     watch: {
167 176
 
@@ -247,6 +256,13 @@ export default {
247 256
         this.$router.push({
248 257
           name: "apply", path: "/apply"
249 258
         });
259
+      },
260
+      getVisitsData() {
261
+        api.visits({}).then(res => {
262
+          if(res.success) {
263
+            this.visits = res.data
264
+          }
265
+        })
250 266
       }
251 267
     }
252 268
 }
@@ -465,5 +481,8 @@ export default {
465 481
   .btn-space{
466 482
     margin-left: 20px;
467 483
   }
484
+  .visits-num{
485
+    padding: 20px;
486
+  }
468 487
 }
469 488
 </style>

+ 6 - 3
src/pages/homepage/file.vue

@@ -28,12 +28,12 @@ export default {
28 28
       return {
29 29
         columns: [
30 30
           {
31
-            label: '名',
31
+            label: '文件名',
32 32
             key: 'fileName'
33 33
           },
34 34
           {
35
-            label: '时间',
36
-            key: 'createdTime'
35
+            label: '文件路径',
36
+            key: 'filePath'
37 37
           }
38 38
         ],
39 39
         tableData: [],
@@ -65,6 +65,9 @@ export default {
65 65
                 this.total = res.data.total
66 66
             }
67 67
         })
68
+      },
69
+      getUrl() {
70
+        return process.env.NODE_ENV !== 'development' ? config.build.BASE_API : config.dev.BASE_API;
68 71
       }
69 72
     }
70 73
 }

+ 49 - 23
src/pages/index/audit.vue

@@ -7,7 +7,7 @@
7 7
         label="操作"
8 8
         width="100">
9 9
         <template slot-scope="scope">
10
-            <el-button v-if="scope.row && scope.row.status === ''" @click="handleApply(scope.row)" type="text" size="small">审核</el-button>
10
+            <el-button v-if="scope.row && scope.row.applyType === '1'" @click="handleAudit(scope.row)" type="text" size="small">审核</el-button>
11 11
         </template>
12 12
       </el-table-column>
13 13
     </el-table>
@@ -24,19 +24,8 @@
24 24
         <el-row class="mg-bt">
25 25
             <el-col class="label" :span="4">审核:</el-col>
26 26
             <el-col :span="18">
27
-                <el-radio v-model="radio" label="1">通过</el-radio>
28
-                <el-radio v-model="radio" label="2">驳回</el-radio>
29
-            </el-col>
30
-        </el-row>
31
-        <el-row class="mg-bt">
32
-            <el-col class="label" :span="4">审核意见:</el-col>
33
-            <el-col :span="18">
34
-                <el-input
35
-                    type="textarea"
36
-                    :rows="2"
37
-                    placeholder="请输入内容"
38
-                    v-model="textarea">
39
-                </el-input>
27
+                <el-radio v-model="radio" label="2">通过</el-radio>
28
+                <el-radio v-model="radio" label="3">驳回</el-radio>
40 29
             </el-col>
41 30
         </el-row>
42 31
         <span slot="footer" class="dialog-footer">
@@ -47,6 +36,7 @@
47 36
   </div>
48 37
 </template>
49 38
 <script>
39
+import api from "@/api/index/audit.js";
50 40
 
51 41
 export default {
52 42
     components: {},
@@ -55,27 +45,28 @@ export default {
55 45
         columns: [
56 46
           {
57 47
             label: '资源名称',
58
-            key: 'nameCh'
48
+            key: 'resourceName'
59 49
           },
60 50
           {
61 51
             label: '资源类型',
62
-            key: 'nameEn'
52
+            key: 'resourceType'
63 53
           },
64 54
           {
65 55
             label: '状态',
66
-            key: 'status'
56
+            key: 'applyTypeText'
67 57
           }
68 58
         ],
69 59
         tableData: [],
70 60
         total: 0,
71 61
         pageSize: 10,
72 62
         pageNum: 1,
73
-        radio: '1',
74
-        textarea: '',
75
-        dialogVisible: false
63
+        radio: '2',
64
+        dialogVisible: false,
65
+        selRow: {}
76 66
       }
77 67
     },
78 68
     mounted() {
69
+      this.getTableData()
79 70
     },
80 71
     watch: {
81 72
     },
@@ -83,14 +74,49 @@ export default {
83 74
       handlePageChange() {
84 75
         console.log('enter handle page change')
85 76
       },
86
-      handleApply(row) {
87
-        console.log('enter handle apply')
77
+      handleAudit(row) {
78
+        this.selRow = row
79
+        this.dialogVisible = true
88 80
       },
89 81
       handleCancelApply(row) {
90 82
         console.log('enter handle cancel apply')
91 83
       },
92 84
       handleConfirm() {
93
-        this.dialogVisible = false
85
+        const {id} = this.selRow
86
+        console.log('radio', this.radio)
87
+        api.applyResource({id, applyType: this.radio}).then(res => {
88
+          if(res.success) {
89
+            this.dialogVisible = false
90
+            this.$message({
91
+              message: '审核成功!',
92
+              type: 'success'
93
+            })
94
+            this.getTableData()
95
+          }
96
+        })
97
+      },
98
+      getTableData() {
99
+        const {pageNum, pageSize} = this
100
+        api.applyList({pageNum, pageSize}).then(res => {
101
+          this.tableData = []
102
+          res.data.records.map((item, index) => {
103
+            const newItem = {...item}
104
+            newItem.applyTypeText = this.getApplyTypeText(item.applyType)
105
+            this.tableData.push(newItem)
106
+          })
107
+          this.total = res.data.total
108
+        })
109
+      },
110
+      getApplyTypeText(val) {
111
+        if (!val){
112
+          return '未申请'
113
+        }
114
+        const textMap = {
115
+          1: '待审批',
116
+          2: '审批通过',
117
+          3: '审批驳回'
118
+        }
119
+        return textMap[val]
94 120
       }
95 121
     }
96 122
 }

+ 2 - 2
src/pages/index/file.vue

@@ -52,8 +52,8 @@ export default {
52 52
             key: 'fileName'
53 53
           },
54 54
           {
55
-            label: '时间',
56
-            key: 'createdTime'
55
+            label: '文件路径',
56
+            key: 'filePath'
57 57
           }
58 58
         ],
59 59
         tableData: [],