Commit 8623daee by haojie

1

parent 4bb0c461
......@@ -69,6 +69,7 @@
:edit_page="form.edit_page"
:checkbox="form.checkbox"
@ChangeList="ChangeList"
@ChoseList="ChoseList"
>
<template #title="{ row }">
<slot name="title" :row="row"></slot>
......@@ -103,6 +104,8 @@ const store = useStore();
const filterBoxStatus = ref(false);
const defaultWidth = ref();
const adminFilter = ref();
// 选中的行
const SelectedRows = ref([]);
// 重新加载页面
const onReload = () => {
store.commit('progress/reload');
......@@ -111,6 +114,10 @@ const onReload = () => {
const onReset = () => {
emit('reset');
};
// 选中的行
const ChoseList = (list: any[]) => {
SelectedRows.value = list;
};
// 筛选盒子是否显示
const filterChange = () => {
......
......@@ -15,7 +15,11 @@
></TCheckbox>
</template>
<template #checkbox="{ row }">
<TCheckbox v-model="row.is_check" class="check-all-box"></TCheckbox>
<TCheckbox
v-model="row.is_check"
class="check-all-box"
@change="CheckOne(row)"
></TCheckbox>
</template>
<template #title="{ row }">
<slot name="title" :row="row"></slot>
......@@ -62,7 +66,7 @@ const props = withDefaults(
checkbox: true,
}
);
// const emit = defineEmits(['ChangeList']);
const emit = defineEmits(['ChangeList', 'ChoseList']);
const router = useRouter();
// 获取本地的page
const getPage = () => {
......@@ -90,6 +94,34 @@ const CheckAll = () => {
tableList.list.forEach((item: any) => {
item.is_check = is_check_all.value;
});
if (is_check_all.value) {
// 通知父组件
emit('ChoseList', tableList.list);
} else {
emit('ChoseList', []);
}
};
// 选择行
const CheckOne = (row: any) => {
// 如果全部未选择
const not_check_list = tableList.list.filter(
(item: any) => item.is_check == false
);
if (not_check_list.length === tableList.list.length) {
emit('ChoseList', []);
} else {
// 找到所有选择项
const list = tableList.list.filter((item: any) => item.is_check == true);
emit('ChoseList', list);
}
// 判断是否全选
const check_list = tableList.list.filter(
(item: any) => item.is_check == true
);
if (check_list.length === tableList.list.length) {
is_check_all.value = true;
}
};
// 打开编辑页面
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment