From 1c2da6dfb1e23fa38c58ada5d7e98f91ae2d738e Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期三, 11 九月 2024 14:19:21 +0800
Subject: [PATCH] 修改导出文件名称

---
 src/components/RightToolbar/index.vue |   72 +++++++++++++++++++++++++++++-------
 1 files changed, 58 insertions(+), 14 deletions(-)

diff --git a/src/components/RightToolbar/index.vue b/src/components/RightToolbar/index.vue
index 78caa84..8820acb 100644
--- a/src/components/RightToolbar/index.vue
+++ b/src/components/RightToolbar/index.vue
@@ -1,14 +1,26 @@
 <template>
-  <div class="top-right-btn">
+  <div class="top-right-btn" :style="style">
     <el-row>
-      <el-tooltip class="item" effect="dark" :content="showSearch ? '闅愯棌鎼滅储' : '鏄剧ず鎼滅储'" placement="top">
-        <el-button size="mini" circle icon="Search" @click="toggleSearch()" />
+      <el-tooltip class="item" effect="dark" :content="showSearch ? '闅愯棌鎼滅储' : '鏄剧ず鎼滅储'" placement="top" v-if="search">
+        <el-button circle icon="Search" @click="toggleSearch()" />
       </el-tooltip>
       <el-tooltip class="item" effect="dark" content="鍒锋柊" placement="top">
-        <el-button size="mini" circle icon="Refresh" @click="refresh()" />
+        <el-button circle icon="Refresh" @click="refresh()" />
       </el-tooltip>
       <el-tooltip class="item" effect="dark" content="鏄鹃殣鍒�" placement="top" v-if="columns">
-        <el-button size="mini" circle icon="Menu" @click="showColumn()" />
+        <el-button circle icon="Menu" @click="showColumn()" v-if="showColumnsType == 'transfer'"/>
+        <el-dropdown trigger="click" :hide-on-click="false" style="padding-left: 12px" v-if="showColumnsType == 'checkbox'">
+          <el-button circle icon="Menu" />
+          <template #dropdown>
+            <el-dropdown-menu>
+              <template v-for="item in columns" :key="item.key">
+                <el-dropdown-item>
+                  <el-checkbox :checked="item.visible" @change="checkboxChange($event, item.label)" :label="item.label" />
+                </el-dropdown-item>
+              </template>
+            </el-dropdown-menu>
+          </template>
+        </el-dropdown>
       </el-tooltip>
     </el-row>
     <el-dialog :title="title" v-model="open" append-to-body>
@@ -24,12 +36,29 @@
 
 <script setup>
 const props = defineProps({
+  /* 鏄惁鏄剧ず妫�绱㈡潯浠� */
   showSearch: {
     type: Boolean,
     default: true,
   },
+  /* 鏄鹃殣鍒椾俊鎭� */
   columns: {
     type: Array,
+  },
+  /* 鏄惁鏄剧ず妫�绱㈠浘鏍� */
+  search: {
+    type: Boolean,
+    default: true,
+  },
+  /* 鏄鹃殣鍒楃被鍨嬶紙transfer绌挎妗嗐�乧heckbox澶嶉�夋锛� */
+  showColumnsType: {
+    type: String,
+    default: "checkbox",
+  },
+  /* 鍙冲杈硅窛 */
+  gutter: {
+    type: Number,
+    default: 10,
   },
 })
 
@@ -41,6 +70,14 @@
 const title = ref("鏄剧ず/闅愯棌");
 // 鏄惁鏄剧ず寮瑰嚭灞�
 const open = ref(false);
+
+const style = computed(() => {
+  const ret = {};
+  if (props.gutter) {
+    ret.marginRight = `${props.gutter / 2}px`;
+  }
+  return ret;
+});
 
 // 鎼滅储
 function toggleSearch() {
@@ -65,26 +102,33 @@
   open.value = true;
 }
 
-// 鏄鹃殣鍒楀垵濮嬮粯璁ら殣钘忓垪
-for (let item in props.columns) {
-  if (props.columns[item].visible === false) {
-    value.value.push(parseInt(item));
+if (props.showColumnsType == 'transfer') {
+  // 鏄鹃殣鍒楀垵濮嬮粯璁ら殣钘忓垪
+  for (let item in props.columns) {
+    if (props.columns[item].visible === false) {
+      value.value.push(parseInt(item));
+    }
   }
 }
+
+// 鍕鹃��
+function checkboxChange(event, label) {
+  props.columns.filter(item => item.label == label)[0].visible = event;
+}
+
 </script>
 
 <style lang='scss' scoped>
 :deep(.el-transfer__button) {
   border-radius: 50%;
-  padding: 12px;
   display: block;
   margin-left: 0px;
 }
 :deep(.el-transfer__button:first-child) {
   margin-bottom: 10px;
 }
-
-.my-el-transfer {
-  text-align: center;
+:deep(.el-dropdown-menu__item) {
+  line-height: 30px;
+  padding: 0 17px;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3