Skip to content

Commit 3ccac8d

Browse files
committed
fix: bug fix
1 parent a2ddda4 commit 3ccac8d

File tree

2 files changed

+78
-20
lines changed

2 files changed

+78
-20
lines changed

frontend/src/views/system/permission/SelectPermission.vue

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
</el-input>
1919
<div class="mt-8 max-height_workspace">
2020
<el-checkbox
21-
v-if="!search"
2221
v-model="checkAll"
2322
class="mb-8"
2423
:indeterminate="isIndeterminate"
@@ -55,14 +54,14 @@
5554
<div class="p-16 w-full">
5655
<div class="flex-between mb-16">
5756
<span class="lighter">
58-
{{ $t('workspace.selected_2_people', { msg: checkedWorkspace.length }) }}
57+
{{ $t('workspace.selected_2_people', { msg: checkTableList.length }) }}
5958
</span>
6059

6160
<el-button text @click="clearWorkspaceAll">
6261
{{ $t('workspace.clear') }}
6362
</el-button>
6463
</div>
65-
<div v-for="ele in checkedWorkspace" :key="ele.name" class="flex-between">
64+
<div v-for="ele in checkTableList" :key="ele.name" class="flex-between">
6665
<div class="flex align-center ellipsis" style="width: 100%">
6766
<el-icon size="28">
6867
<avatar_personal></avatar_personal>
@@ -84,7 +83,7 @@
8483
</template>
8584

8685
<script lang="ts" setup>
87-
import { ref, computed } from 'vue'
86+
import { ref, computed, watch } from 'vue'
8887
import { workspaceUserList } from '@/api/workspace'
8988
import avatar_personal from '@/assets/svg/avatar_personal.svg'
9089
import Close from '@/assets/svg/icon_close_outlined_w.svg'
@@ -97,32 +96,63 @@ const workspace = ref<any[]>([])
9796
const search = ref('')
9897
const loading = ref(false)
9998
const centerDialogVisible = ref(false)
99+
const checkTableList = ref([] as any[])
100100
101101
const workspaceWithKeywords = computed(() => {
102102
return workspace.value.filter((ele: any) => (ele.name as string).includes(search.value))
103103
})
104+
105+
watch(search, () => {
106+
const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name)
107+
checkedWorkspace.value = checkTableList.value.filter((ele) => tableNameArr.includes(ele.name))
108+
const checkedCount = checkedWorkspace.value.length
109+
checkAll.value = checkedCount === workspaceWithKeywords.value.length
110+
isIndeterminate.value = checkedCount > 0 && checkedCount < workspaceWithKeywords.value.length
111+
})
104112
const handleCheckAllChange = (val: CheckboxValueType) => {
105-
checkedWorkspace.value = val ? workspace.value : []
113+
const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name)
114+
checkedWorkspace.value = val
115+
? [
116+
...new Set([
117+
...workspaceWithKeywords.value,
118+
...checkedWorkspace.value.filter((ele) => !tableNameArr.includes(ele.name)),
119+
]),
120+
]
121+
: []
106122
isIndeterminate.value = false
107-
if (!val) {
108-
clearWorkspaceAll()
109-
}
123+
checkTableList.value = val
124+
? [
125+
...new Set([
126+
...workspaceWithKeywords.value,
127+
...checkTableList.value.filter((ele) => !tableNameArr.includes(ele.name)),
128+
]),
129+
]
130+
: checkTableList.value.filter((ele) => !tableNameArr.includes(ele.name))
110131
}
111132
const handleCheckedWorkspaceChange = (value: CheckboxValueType[]) => {
112133
const checkedCount = value.length
113-
checkAll.value = checkedCount === workspace.value.length
114-
isIndeterminate.value = checkedCount > 0 && checkedCount < workspace.value.length
134+
checkAll.value = checkedCount === workspaceWithKeywords.value.length
135+
isIndeterminate.value = checkedCount > 0 && checkedCount < workspaceWithKeywords.value.length
136+
const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name)
137+
checkTableList.value = [
138+
...new Set([
139+
...checkTableList.value.filter((ele) => !tableNameArr.includes(ele.name)),
140+
...value,
141+
]),
142+
]
115143
}
116144
117145
const open = async (user: any) => {
118146
loading.value = true
119147
checkedWorkspace.value = []
120148
checkAll.value = false
149+
checkTableList.value = []
121150
isIndeterminate.value = false
122151
const systemWorkspaceList = await workspaceUserList({}, 1, 1000)
123152
workspace.value = systemWorkspaceList.items as any
124153
if (user?.length) {
125154
checkedWorkspace.value = workspace.value.filter((ele) => user.includes(ele.id))
155+
checkTableList.value = [...checkedWorkspace.value]
126156
handleCheckedWorkspaceChange(checkedWorkspace.value)
127157
}
128158
loading.value = false

frontend/src/views/system/workspace/AuthorizedWorkspaceDialog.vue

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
</el-input>
2929
<div class="mt-8 max-height_workspace">
3030
<el-checkbox
31-
v-if="!search"
3231
v-model="checkAll"
3332
class="mb-8"
3433
:indeterminate="isIndeterminate"
@@ -65,14 +64,14 @@
6564
<div class="p-16 w-full">
6665
<div class="flex-between mb-16">
6766
<span class="lighter">
68-
{{ $t('workspace.selected_2_people', { msg: checkedWorkspace.length }) }}
67+
{{ $t('workspace.selected_2_people', { msg: checkTableList.length }) }}
6968
</span>
7069

7170
<el-button text @click="clearWorkspaceAll">
7271
{{ $t('workspace.clear') }}
7372
</el-button>
7473
</div>
75-
<div v-for="ele in checkedWorkspace" :key="ele.name" class="flex-between align-center">
74+
<div v-for="ele in checkTableList" :key="ele.name" class="flex-between align-center">
7675
<div
7776
:title="`${ele.name}(${ele.account})`"
7877
class="flex align-center ellipsis"
@@ -106,7 +105,7 @@
106105
</template>
107106

108107
<script lang="ts" setup>
109-
import { ref, computed } from 'vue'
108+
import { ref, computed, watch } from 'vue'
110109
import { workspaceOptionUserList, workspaceUwsCreate } from '@/api/workspace'
111110
import avatar_personal from '@/assets/svg/avatar_personal.svg'
112111
import Close from '@/assets/svg/icon_close_outlined_w.svg'
@@ -120,23 +119,51 @@ const listType = ref(0)
120119
const search = ref('')
121120
const loading = ref(false)
122121
const centerDialogVisible = ref(false)
122+
const checkTableList = ref([] as any[])
123123
124124
const workspaceWithKeywords = computed(() => {
125125
return workspace.value.filter((ele: any) =>
126126
(ele.name.toLowerCase() as string).includes(search.value.toLowerCase())
127127
)
128128
})
129+
watch(search, () => {
130+
const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name)
131+
checkedWorkspace.value = checkTableList.value.filter((ele) => tableNameArr.includes(ele.name))
132+
const checkedCount = checkedWorkspace.value.length
133+
checkAll.value = checkedCount === workspaceWithKeywords.value.length
134+
isIndeterminate.value = checkedCount > 0 && checkedCount < workspaceWithKeywords.value.length
135+
})
129136
const handleCheckAllChange = (val: CheckboxValueType) => {
130-
checkedWorkspace.value = val ? workspace.value : []
137+
const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name)
138+
checkedWorkspace.value = val
139+
? [
140+
...new Set([
141+
...workspaceWithKeywords.value,
142+
...checkedWorkspace.value.filter((ele) => !tableNameArr.includes(ele.name)),
143+
]),
144+
]
145+
: []
131146
isIndeterminate.value = false
132-
if (!val) {
133-
clearWorkspaceAll()
134-
}
147+
checkTableList.value = val
148+
? [
149+
...new Set([
150+
...workspaceWithKeywords.value,
151+
...checkTableList.value.filter((ele) => !tableNameArr.includes(ele.name)),
152+
]),
153+
]
154+
: checkTableList.value.filter((ele) => !tableNameArr.includes(ele.name))
135155
}
136156
const handleCheckedWorkspaceChange = (value: CheckboxValueType[]) => {
137157
const checkedCount = value.length
138-
checkAll.value = checkedCount === workspace.value.length
139-
isIndeterminate.value = checkedCount > 0 && checkedCount < workspace.value.length
158+
checkAll.value = checkedCount === workspaceWithKeywords.value.length
159+
isIndeterminate.value = checkedCount > 0 && checkedCount < workspaceWithKeywords.value.length
160+
const tableNameArr = workspaceWithKeywords.value.map((ele: any) => ele.name)
161+
checkTableList.value = [
162+
...new Set([
163+
...checkTableList.value.filter((ele) => !tableNameArr.includes(ele.name)),
164+
...value,
165+
]),
166+
]
140167
}
141168
let oid: any = null
142169
@@ -145,6 +172,7 @@ const open = async (id: any) => {
145172
search.value = ''
146173
oid = id
147174
checkedWorkspace.value = []
175+
checkTableList.value = []
148176
checkAll.value = false
149177
isIndeterminate.value = false
150178
const systemWorkspaceList = await workspaceOptionUserList({ oid }, 1, 1000)

0 commit comments

Comments
 (0)