diff --git a/ruoyi-fastapi-frontend/src/components/RightToolbar/index.vue b/ruoyi-fastapi-frontend/src/components/RightToolbar/index.vue
index 57377ff..32fc644 100644
--- a/ruoyi-fastapi-frontend/src/components/RightToolbar/index.vue
+++ b/ruoyi-fastapi-frontend/src/components/RightToolbar/index.vue
@@ -7,7 +7,7 @@
-
+
@@ -18,9 +18,9 @@
列展示
-
+
-
+
@@ -32,7 +32,7 @@
@@ -46,9 +46,10 @@ const props = defineProps({
type: Boolean,
default: true
},
- /* 显隐列信息 */
+ /* 显隐列信息(数组格式、对象格式) */
columns: {
- type: Array
+ type: [Array, Object],
+ default: () => ({})
},
/* 是否显示检索图标 */
search: {
@@ -82,14 +83,15 @@ const style = computed(() => {
ret.marginRight = `${props.gutter / 2}px`
}
return ret
-});
+})
// 是否全选/半选 状态
const isChecked = computed({
- get: () => props.columns.every(col => col.visible),
+ get: () => Array.isArray(props.columns) ? props.columns.every(col => col.visible) : Object.values(props.columns).every((col) => col.visible),
set: () => {}
})
-const isIndeterminate = computed(() => props.columns.some((col) => col.visible) && !isChecked.value)
+const isIndeterminate = computed(() => Array.isArray(props.columns) ? props.columns.some((col) => col.visible) && !isChecked.value : Object.values(props.columns).some((col) => col.visible) && !isChecked.value)
+const transferData = computed(() => Array.isArray(props.columns) ? props.columns.map((item, index) => ({ key: index, label: item.label })) : Object.keys(props.columns).map((key, index) => ({ key: index, label: props.columns[key].label })))
// 搜索
function toggleSearch() {
@@ -98,14 +100,20 @@ function toggleSearch() {
// 刷新
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)
+ if (Array.isArray(props.columns)) {
+ for (let item in props.columns) {
+ const key = props.columns[item].key
+ props.columns[item].visible = !data.includes(key)
+ }
+ } else {
+ Object.keys(props.columns).forEach((key, index) => {
+ props.columns[key].visible = !data.includes(index)
+ })
}
}
@@ -114,24 +122,40 @@ function showColumn() {
open.value = true
}
-if (props.showColumnsType == 'transfer') {
- // 显隐列初始默认隐藏列
- for (let item in props.columns) {
- if (props.columns[item].visible === false) {
- value.value.push(parseInt(item))
+if (props.showColumnsType == "transfer") {
+ // transfer穿梭显隐列初始默认隐藏列
+ if (Array.isArray(props.columns)) {
+ for (let item in props.columns) {
+ if (props.columns[item].visible === false) {
+ value.value.push(parseInt(item))
+ }
}
+ } else {
+ Object.keys(props.columns).forEach((key, index) => {
+ if (props.columns[key].visible === false) {
+ value.value.push(index)
+ }
+ })
}
}
// 单勾选
-function checkboxChange(event, label) {
- props.columns.filter(item => item.label == label)[0].visible = event
+function checkboxChange(event, key) {
+ if (Array.isArray(props.columns)) {
+ props.columns.filter(item => item.key == key)[0].visible = event
+ } else {
+ props.columns[key].visible = event
+ }
}
// 切换全选/反选
function toggleCheckAll() {
const newValue = !isChecked.value
- props.columns.forEach((col) => (col.visible = newValue))
+ if (Array.isArray(props.columns)) {
+ props.columns.forEach((col) => (col.visible = newValue))
+ } else {
+ Object.values(props.columns).forEach((col) => (col.visible = newValue))
+ }
}
diff --git a/ruoyi-fastapi-frontend/src/views/system/user/index.vue b/ruoyi-fastapi-frontend/src/views/system/user/index.vue
index b464236..d35dbdf 100644
--- a/ruoyi-fastapi-frontend/src/views/system/user/index.vue
+++ b/ruoyi-fastapi-frontend/src/views/system/user/index.vue
@@ -164,14 +164,14 @@
align="center"
key="userId"
prop="userId"
- v-if="columns[0].visible"
+ v-if="columns.userId.visible"
/>
@@ -556,15 +556,16 @@ const upload = reactive({
url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData",
});
// 列显隐信息
-const columns = ref([
- { key: 0, label: `用户编号`, visible: true },
- { key: 1, label: `用户名称`, visible: true },
- { key: 2, label: `用户昵称`, visible: true },
- { key: 3, label: `部门`, visible: true },
- { key: 4, label: `手机号码`, visible: true },
- { key: 5, label: `状态`, visible: true },
- { key: 6, label: `创建时间`, visible: true },
-]);
+
+const columns = ref({
+ userId: { label: "用户编号", visible: true },
+ userName: { label: "用户名称", visible: true },
+ nickName: { label: "用户昵称", visible: true },
+ deptName: { label: "部门", visible: true },
+ phonenumber: { label: "手机号码", visible: true },
+ status: { label: "状态", visible: true },
+ createTime: { label: "创建时间", visible: true },
+});
const data = reactive({
form: {},