diff --git a/src/components/RightToolbar/index.vue b/src/components/RightToolbar/index.vue
index e5dae99..86ba246 100644
--- a/src/components/RightToolbar/index.vue
+++ b/src/components/RightToolbar/index.vue
@@ -18,9 +18,9 @@
列展示
-
+
-
+
@@ -32,7 +32,7 @@
@@ -46,9 +46,9 @@ const props = defineProps({
type: Boolean,
default: true
},
- /* 显隐列信息 */
+ /* 显隐列信息(数组格式、对象格式) */
columns: {
- type: Array
+ type: [Array, Object]
},
/* 是否显示检索图标 */
search: {
@@ -86,10 +86,11 @@ const style = computed(() => {
// 是否全选/半选 状态
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() {
@@ -103,9 +104,15 @@ function refresh() {
// 右侧列表元素变化
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 +121,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/src/views/system/user/index.vue b/src/views/system/user/index.vue
index cac6f5d..62a2031 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -58,12 +58,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
{{ parseTime(scope.row.createTime) }}
@@ -257,15 +257,15 @@ 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: {},