whj 2 years ago
parent
commit
48cb266a7c
2 changed files with 65 additions and 9 deletions
  1. 17 2
      src/api/report/sbinfo.js
  2. 48 7
      src/views/dashboard/SbInfoTypeReport.vue

+ 17 - 2
src/api/report/sbinfo.js

@@ -39,9 +39,24 @@ export function exportMonthReport (parameter) {
  * @param parameter
  * @returns {*}
  */
-export function getSbType () {
+export function getSbType (parameter) {
   return axios({
-    url: '/sb/types',
+    url: '/sb/types?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+/**
+ * page func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function getSbTypeReport (parameter) {
+  return axios({
+    url: '/report/sb/infos/getSbTypeReport?' + stringify(parameter),
     method: 'get',
     headers: {
       'Content-Type': 'application/json;charset=UTF-8'

+ 48 - 7
src/views/dashboard/SbInfoTypeReport.vue

@@ -4,7 +4,7 @@
       <div class="salesCard">
         <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
           <div class="table-operator" style="margin-bottom: 8px;margin-top: 8px;" slot="tabBarExtraContent">
-
+            <!--
             <a-select style="margin-left: 8px;width:150px" v-model="queryParam.useType" placeholder="请选择">
               <a-select-option
                 v-for="(label,value) in useTypeMap"
@@ -12,15 +12,23 @@
                 :label="label"
                 :value="parseInt(value)">{{ label }}
               </a-select-option>
-            </a-select>
-            <a-select style="margin-left: 8px;width:150px" v-model="queryParam.typeId" placeholder="请选择">
+            </a-select> -->
+            <a-cascader
+              :options="typeList"
+              :fieldNames="fieldNames"
+              :load-data="loadData"
+              placeholder="请选择"
+              change-on-select
+              @change="onChange"
+            />
+            <!-- <a-select style="margin-left: 8px;width:150px" v-model="queryParam.typeId" placeholder="请选择">
               <a-select-option
                 v-for="{name,id} in typeList"
                 :key="id"
                 :label="name"
                 :value="id">{{ name }}
               </a-select-option>
-            </a-select>
+            </a-select> -->
             <a-button style="margin-left: 8px" type="default" @click="getData()">查询</a-button>
             <a-button style="margin-left: 8px" type="primary" @click="handlePrint()">打印</a-button>
             <a-button style="margin-left: 8px" type="primary" @click="doExport()">导出</a-button>
@@ -67,7 +75,7 @@
 </template>
 
 <script>
-import { getMonthReport, exportMonthReport, getSbType } from '@/api/report/sbinfo'
+import { getMonthReport, exportMonthReport, getSbType, getSbTypeReport } from '@/api/report/sbinfo'
 import { Chart } from '@antv/g2'
 import PrintInSbInfoTypeReport from '@/views/dashboard/modules/PrintInSbInfoTypeReport'
 import DetailMeasureLogReport from '@/views/dashboard/modules/DetailMeasureLogReport'
@@ -94,6 +102,11 @@ export default {
         useType: 4,
         typeId: ''
       },
+      fieldNames: {
+        label: 'name',
+        value: 'id',
+        children: 'children'
+      },
       typeList: [],
       visible: true,
       chart: null, // 创建一个chart变量
@@ -137,9 +150,15 @@ export default {
   },
   created () {
     this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
-    getSbType().then(res => {
+    getSbType({
+      flag: 1,
+      type: 1
+    }).then(res => {
       console.log(res)
-      this.typeList = res.data
+      this.typeList = res.data.map(item => {
+        item.isLeaf = false
+        return item
+      })
     })
   },
   mounted () {
@@ -220,6 +239,28 @@ export default {
     },
     handleOk () {
       this.visible = true
+    },
+    onChange (value) {
+      console.log(value)
+      if (value.length === 0) return
+      getSbTypeReport({
+        id: value[value.length - 1]
+      }).then(res => {
+        console.log(res)
+      })
+    },
+    loadData (selectedOptions) {
+      const targetOption = selectedOptions[selectedOptions.length - 1]
+      targetOption.loading = true
+      getSbType({
+        flag: 2,
+        type: 2,
+        parentId: targetOption.id
+      }).then(res => {
+        console.log(res)
+        targetOption.loading = false
+        targetOption.children = res.data
+      })
     }
   }
 }