Bladeren bron

feat: 平台数据的部门筛选框

wyf 1 jaar geleden
bovenliggende
commit
14b706fdd7

+ 18 - 1
src/views/datamanager/platformdata/components/common/PlatformTable.vue

@@ -17,6 +17,18 @@
           </el-select>
         </template>
       </el-input>
+      <div>
+        <span>请选择组织:</span>
+        <el-tree-select
+          v-model="tableQueryDept"
+          :data="props.departmentList"
+          :render-after-expand="false"
+          :default-expand-all="true"
+          check-strictly
+          placeholder="请选择组织"
+          class="protocal-select"
+        />
+      </div>
       <div style="float: right">
         <el-button type="primary" @click="submitTableQuery" style="width: 65px; height: 32px"
           >搜 索</el-button
@@ -36,12 +48,14 @@
       <el-table-column label="工号" prop="username" align="center"></el-table-column>
       <el-table-column label="部门" prop="deptName" align="center"></el-table-column>
       <el-table-column
+        v-if="tableLabel === '访问次数'"
         :label="'当日' + props.tableLabel"
         prop="statisticDay"
         sortable="custom"
         align="right"
       ></el-table-column>
       <el-table-column
+        v-if="tableLabel === '访问次数'"
         :label="'本月' + tableLabel"
         prop="statisticMonth"
         sortable="custom"
@@ -51,7 +65,7 @@
         :label="'累计' + tableLabel"
         prop="statisticAll"
         sortable="custom"
-        align="right"
+        :align="tableLabel === '访问次数' ? 'right' : 'center'"
       ></el-table-column>
       <el-table-column v-if="tableLabel === '访问次数'" label="访问次数统计图" align="center">
         <template #default="scope">
@@ -125,6 +139,7 @@
 
   // 获取下拉菜单数据和表格数据
   const props = defineProps<{
+    departmentList: any[];
     workshopList: any[];
     tableData: UserAccessRecordList;
     tableLabel: string;
@@ -196,6 +211,8 @@
     };
     emits('tableParamsChanged', tableQueryParams.value);
   }
+  // 组织列表筛选数据
+  const tableQueryDept = ref<string>();
 
   // dialog显示和画图
   const chartTitle = ref('');

+ 14 - 3
src/views/datamanager/platformdata/components/query/Query.vue

@@ -4,6 +4,7 @@
     <el-button type="primary" @click="showCameraData()">相机统计数据</el-button>
     <PlatformTable
       v-if="flattenedWorkshops.length > 0 && tableData !== undefined"
+      :department-list="departmentList"
       :workshop-list="flattenedWorkshops"
       :table-data="tableData"
       table-label="访问次数"
@@ -39,7 +40,7 @@
   import PlatformTable from '../common/PlatformTable.vue';
   import DialogNavBar from '../common/DialogNavBar.vue';
   import BarChart from '../../charts/BarChart.vue';
-  import { ref, onBeforeMount, watch } from 'vue';
+  import { ref, onMounted, watch } from 'vue';
   import { useSceneInfos } from '@/hooks/useSceneInfos';
   import {
     type UserAccessRecordQueryParams,
@@ -50,12 +51,22 @@
     getWorkshopVisitedTimes,
   } from '@/api/datamanagement/dataplatform';
   import { formatWorkshopChart, formatCameraChart } from '@/utils/platformUtils';
+  import { deptTreeList } from '@/api/auth/dept';
+
+  const departmentList = ref<any[]>([]);
 
   // 下拉菜单车间列表数据
   const sceneInfos = useSceneInfos();
-  const { flattenedWorkshops, getScenesTree } = sceneInfos;
-  onBeforeMount(() => {
+  const { flattenedWorkshops, getScenesTree, calculateTreeData } = sceneInfos;
+  onMounted(() => {
     getScenesTree({ level: 1, valueKey: 'code', labelKey: 'name', disabled: true });
+    deptTreeList().then((res) => {
+      departmentList.value = calculateTreeData(
+        res,
+        { level: 3, valueKey: 'deptId', labelKey: 'deptName' },
+        1,
+      );
+    });
   });
 
   // dialog显示