From 1b29075752cff967d98eb8dd4263a6c11d60c43b Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Wed, 13 Nov 2024 14:05:55 +0800
Subject: [PATCH] 救援物质页面优化

---
 src/views/supplies/components/box/dataContent.vue |  121 ++++++++++++++++++++++-----------------
 1 files changed, 68 insertions(+), 53 deletions(-)

diff --git a/src/views/supplies/components/box/dataContent.vue b/src/views/supplies/components/box/dataContent.vue
index 5ac17b0..846919a 100644
--- a/src/views/supplies/components/box/dataContent.vue
+++ b/src/views/supplies/components/box/dataContent.vue
@@ -1,33 +1,24 @@
-<!--
- * @Author: shuishen 1109946754@qq.com
- * @Date: 2023-03-13 14:54:26
- * @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2023-03-13 15:00:55
- * @FilePath: \forest-fire\src\views\statistics\components\box\dataContent.vue
- * @Description: 
- * 
- * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
--->
-
-
 <template>
   <public-content>
     <template #content>
       <div class="content_box">
         <div class="list_box">
-          <ul>
-            <li v-for="( item, index ) in  tilteList " :key="index" :class="[currentIndex === index ? 'active' : '']"
-              @click="handleClick(item, index)">
-              {{ item.label }}
-            </li>
-          </ul>
+          <span class="content_span" @click="scrollLeft">《</span>
+          <el-scrollbar ref="scrollbarRef" @scroll="scroll">
+            <div class="scrollbar-flex-content">
+              <p v-for="(item, index) in tilteList" @click="handleClick(item, index)" :key="index"
+                class="scrollbar-demo-item" :class="{ active: index === currentIndex }">
+                {{ item.label }}
+              </p>
+            </div>
+          </el-scrollbar>
+          <span class="content_span" @click="scrollRight">》</span>
         </div>
 
         <div class="page_box">
           <div>
             <el-table v-if="formInline.ownership == 1" :data="tableData" style="width: 100%"
               :header-cell-style="headerCellStyle" :cell-style="tableCellStyle">
-
               <el-table-column fixed prop="name" label="物资名称" />
               <el-table-column fixed prop="personInCha" label="负责人" />
               <el-table-column fixed prop="personInChaPhone" label="负责人电话" />
@@ -37,7 +28,6 @@
 
             <el-table v-else :data="tableData" style="width: 100%" :header-cell-style="headerCellStyle"
               :cell-style="tableCellStyle">
-
               <el-table-column fixed prop="firmName" label="企业名称" />
               <el-table-column fixed prop="name" label="物资名称" />
               <el-table-column fixed prop="personInCha" label="负责人" />
@@ -47,7 +37,6 @@
             </el-table>
           </div>
         </div>
-
       </div>
     </template>
   </public-content>
@@ -57,7 +46,8 @@
 import publicContent from "./publicContent.vue";
 import { getList } from "@/api/emergencySupplies/emergencySupplies";
 import { getPage } from '@/api/indParkInfo'
-import { reactive } from "vue";
+import { reactive, ref, onMounted } from "vue";
+import { ElScrollbar } from 'element-plus';
 
 const loading = ref(false);
 
@@ -80,11 +70,20 @@
   getCompanyPages()
 });
 
+const scrollbarRef = ref(null);
+
+const inputSlider = (number) => {
+  if (scrollbarRef.value) {
+    scrollbarRef.value.setScrollTop(number);
+  }
+}
+
 // 搜索条件
 const formInline = reactive({
   firmId: '',
   ownership: 1,
 });
+
 function getCompanyPages(param = {}) {
   param.current = pages.page;
   param.size = pages.pageSize;
@@ -115,10 +114,12 @@
   }
   getLists(formInline);
 }
+
 // 表格样式
 const tableCellStyle = ({ row, column }) => {
   return { background: "#152851", color: "#fff" };
 };
+
 // 表格表头样式
 const headerCellStyle = ({ }) => {
   return {
@@ -127,26 +128,18 @@
   };
 };
 
-
-// 提交查询
-// const onSubmit = () => {
-//   pages.page = 1
-//   pages.pageSize = 13
-//   pages.total = 0
-//   console.log("submit!");
-//   getLists(formInline);
-// };
-
 // 分页树改变
 const handleSizeChange = (val) => {
   pages.pageSize = val;
   getLists(formInline);
 }
+
 // 分页改变
 const handleCurrentChange = (val) => {
   pages.page = val;
   getLists(formInline);
 }
+
 // 重置条件
 const clearBtn = () => {
   formInline.name = ''
@@ -181,6 +174,24 @@
       console.log(err);
     });
 }
+
+// 滚动到左边
+const scrollLeft = () => {
+  if (scrollbarRef.value) {
+    const currentScrollLeft = scrollbarRef.value.wrapRef.scrollLeft;
+    const step = 500; // 每次滚动的距离
+    scrollbarRef.value.wrapRef.scrollLeft = currentScrollLeft - step;
+  }
+}
+
+// 滚动到右边
+const scrollRight = () => {
+  if (scrollbarRef.value) {
+    const currentScrollLeft = scrollbarRef.value.wrapRef.scrollLeft;
+    const step = 500; // 每次滚动的距离
+    scrollbarRef.value.wrapRef.scrollLeft = currentScrollLeft + step;
+  }
+}
 </script>
 
 
@@ -189,41 +200,45 @@
   color: #fff;
 }
 
-.list_box {
-  overflow-x: auto;
-  white-space: nowrap;
-  // scrollbar-width: thin;
-  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
-}
-
-.list_box ul {
+.content_box .list_box {
   display: flex;
-  /* 使用 Flexbox 布局 */
-  padding: 0;
-  margin: 0;
-  list-style: none;
+  text-align: center;
 }
 
-.list_box li {
-  padding: 10px;
-  margin-right: 10px;
-  cursor: pointer;
+.scrollbar-flex-content {
+  display: flex;
 }
 
-.list_box li.active {
+.scrollbar-demo-item {
+  flex-shrink: 0;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  height: 50px;
+  margin: 10px;
+  padding: 0 5px;
+  text-align: center;
+  border-radius: 4px;
+  // background: var(--el-color-danger-light-9);
   background-color: rgba(117, 116, 116, 0.3);
-  color: white;
+  // color: var(--el-color-danger);
+  // color: #000;
+}
+
+.content_box .content_span {
+  line-height: 70px;
+  margin: 0 15px;
 }
 
 .page_box .el-table {
   width: 100%;
-  height: 700px;
+  height: 680px;
   background-color: rgba(117, 116, 116, 0.3);
 }
 
 .active {
-  background-color: #fff;
-  color: #000;
+  background-color: rgba(255, 255, 255, 0.3);
+  color: #fff;
   border-radius: 10px;
 }
 </style>

--
Gitblit v1.9.3