From fda152b544ed0b3ceb8309df5b7eca2de888f3f1 Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期二, 10 六月 2025 11:39:55 +0800
Subject: [PATCH] 开票登记编辑功能开发

---
 src/components/RightToolbar/index.vue |  117 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 92 insertions(+), 25 deletions(-)

diff --git a/src/components/RightToolbar/index.vue b/src/components/RightToolbar/index.vue
index 78caa84..e5dae99 100644
--- a/src/components/RightToolbar/index.vue
+++ b/src/components/RightToolbar/index.vue
@@ -1,14 +1,31 @@
 <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>
+              <!-- 鍏ㄩ��/鍙嶉�� 鎸夐挳 -->
+              <el-dropdown-item>
+                <el-checkbox :indeterminate="isIndeterminate" v-model="isChecked" @change="toggleCheckAll"> 鍒楀睍绀� </el-checkbox>
+              </el-dropdown-item>
+              <div class="check-line"></div>
+              <template v-for="item in columns" :key="item.key">
+                <el-dropdown-item>
+                  <el-checkbox v-model="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,67 +41,117 @@
 
 <script setup>
 const props = defineProps({
+  /* 鏄惁鏄剧ず妫�绱㈡潯浠� */
   showSearch: {
     type: Boolean,
-    default: true,
+    default: true
   },
+  /* 鏄鹃殣鍒椾俊鎭� */
   columns: {
-    type: Array,
+    type: Array
+  },
+  /* 鏄惁鏄剧ず妫�绱㈠浘鏍� */
+  search: {
+    type: Boolean,
+    default: true
+  },
+  /* 鏄鹃殣鍒楃被鍨嬶紙transfer绌挎妗嗐�乧heckbox澶嶉�夋锛� */
+  showColumnsType: {
+    type: String,
+    default: "checkbox"
+  },
+  /* 鍙冲杈硅窛 */
+  gutter: {
+    type: Number,
+    default: 10
   },
 })
 
-const emits = defineEmits(['update:showSearch', 'queryTable']);
+const emits = defineEmits(['update:showSearch', 'queryTable'])
 
 // 鏄鹃殣鏁版嵁
-const value = ref([]);
+const value = ref([])
 // 寮瑰嚭灞傛爣棰�
-const title = ref("鏄剧ず/闅愯棌");
+const title = ref("鏄剧ず/闅愯棌")
 // 鏄惁鏄剧ず寮瑰嚭灞�
-const open = ref(false);
+const open = ref(false)
+
+const style = computed(() => {
+  const ret = {}
+  if (props.gutter) {
+    ret.marginRight = `${props.gutter / 2}px`
+  }
+  return ret
+})
+
+// 鏄惁鍏ㄩ��/鍗婇�� 鐘舵��
+const isChecked = computed({
+  get: () => props.columns.every(col => col.visible),
+  set: () => {}
+})
+const isIndeterminate = computed(() => props.columns.some((col) => col.visible) && !isChecked.value)
 
 // 鎼滅储
 function toggleSearch() {
-  emits("update:showSearch", !props.showSearch);
+  emits("update:showSearch", !props.showSearch)
 }
 
 // 鍒锋柊
 function refresh() {
-  emits("queryTable");
+  emits("queryTable")
 }
 
 // 鍙充晶鍒楄〃鍏冪礌鍙樺寲
 function dataChange(data) {
   for (let item in props.columns) {
-    const key = props.columns[item].key;
-    props.columns[item].visible = !data.includes(key);
+    const key = props.columns[item].key
+    props.columns[item].visible = !data.includes(key)
   }
 }
 
 // 鎵撳紑鏄鹃殣鍒梔ialog
 function showColumn() {
-  open.value = true;
+  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
+}
+
+// 鍒囨崲鍏ㄩ��/鍙嶉��
+function toggleCheckAll() {
+  const newValue = !isChecked.value
+  props.columns.forEach((col) => (col.visible = newValue))
 }
 </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
+.check-line {
+  width: 90%;
+  height: 1px;
+  background-color: #ccc;
+  margin: 3px auto;
+}
+</style>

--
Gitblit v1.9.3