Browse Source

yyl update

tom_glb 4 years ago
parent
commit
dab65ee5d6
3 changed files with 26 additions and 20 deletions
  1. 8 13
      src/api/ajax.js
  2. 7 2
      src/api/index.js
  3. 11 5
      src/components/PatrolmanStatistics/5.vue

+ 8 - 13
src/api/ajax.js

@@ -5,7 +5,12 @@ import storageUtil from '../util/storageUtil'
 export default function ajax (url, data={}, type='GET') {
 
     return new Promise(function (resolve, reject) {
-        let promise
+        const deptArray = storageUtil.read('dept-array');
+        if(deptArray) {
+            data[ 'dept' + deptArray.length - 1 ] = deptArray[deptArray.length - 1];
+        }
+
+        let promise;
         if (type === 'GET') {
             let dataStr = ''
             Object.keys(data).forEach(key => {
@@ -14,21 +19,11 @@ export default function ajax (url, data={}, type='GET') {
             if (dataStr !== '') {
                 dataStr = dataStr.substring(0, dataStr.lastIndexOf('&'))
                 url = url + '?' + dataStr;
-            } else {
-                url = url;
             }
 
-            promise = axios.get(url, {
-                headers: {
-                    'cipherText': storageUtil.read("userInfo")
-                }
-            })
+            promise = axios.get(url)
         } else {
-            promise = axios.post(url, qs.stringify(data), {
-                headers: {
-                    'cipherText': storageUtil.read("userInfo")
-                }
-            });
+            promise = axios.post(url, qs.stringify(data));
         }
         promise.then(function (response) {
             resolve(response.data);

+ 7 - 2
src/api/index.js

@@ -1,7 +1,12 @@
 import ajax from './ajax'
-const BASE_URL = 'http://10.16.4.8'
+const BASE_URL = 'http://10.16.4.12'
 
 /**
- * 用户登录
+ * 获取地区
  */
 export const findDept = (params, requestMethod) => ajax(`${BASE_URL}/chart/dept/findDept`, params, requestMethod);
+
+/**
+ * 巡防员信息统计  --->   老年人健康状况
+ */
+export const oldPersonHealth = (params, requestMethod) => ajax(`${BASE_URL}/chart/visit/health`, params, requestMethod);

+ 11 - 5
src/components/PatrolmanStatistics/5.vue

@@ -3,15 +3,13 @@
 </template>
 
 <script>
+    import { oldPersonHealth } from '../../api'
+
     export default {
         name: "OldPersonHealthCount",
         data() {
           return {
-            dataArr: [
-              { label: '健康', value: '25%' },
-              { label: '一般', value: '25%' },
-              { label: '较差', value: '50%' }
-            ],
+            dataArr: [],
             colorArr: [
               { color1: '#0f0', color2: '#C4FFBC' },
               { color1: '#ff0', color2: '#FFFC83' },
@@ -19,7 +17,15 @@
             ]
           }
         },
+        methods: {
+          async loadData() {
+              const result = await this.oldPersonHealth({}, 'POST');
+              this.dataArr = result;
+          }
+        },
         mounted() {
+          this.loadData();
+
           const legendArr = [];
           const chartDataArr = [];