feat: 对列表数据进行勾选后,界面的状态切换与RP要求不符

pull/7/head
刘释隆 1 year ago
parent 6eb9a6e4c9
commit 38aa8118c6

@ -8,6 +8,7 @@ import {
reactive, reactive,
ref, ref,
unref, unref,
computed,
} from "vue"; } from "vue";
import { NDataTable } from "naive-ui"; import { NDataTable } from "naive-ui";
import type { DataTableColumns, DataTableRowKey } from "naive-ui"; import type { DataTableColumns, DataTableRowKey } from "naive-ui";
@ -26,6 +27,7 @@ const emit = defineEmits<{
}>(); }>();
const show = ref(false); const show = ref(false);
const checkedRowKeys = ref([]);
const cardStyle = { const cardStyle = {
width: "800px", width: "800px",
@ -109,7 +111,7 @@ const pagination = reactive({
}, },
], ],
showQuickJumper: true, showQuickJumper: true,
prefix:()=>`${total.value} 条数据` prefix: () => `${total.value} 条数据`,
}); });
const tableData = ref<Array<RowData>>([]); const tableData = ref<Array<RowData>>([]);
const keyword = ref(""); const keyword = ref("");
@ -119,7 +121,7 @@ async function query(page: number, pageSize: number) {
search_searchname: { value: keyword.value, op: "like", type: "string" }, search_searchname: { value: keyword.value, op: "like", type: "string" },
}; };
const result = await getConditionList({ pageNo: page, pageSize }, searchParam, 1); const result = await getConditionList({ pageNo: page, pageSize }, searchParam, 1);
const { data, pageCount,total:totalCount } = result; const { data, pageCount, total: totalCount } = result;
total.value = totalCount; total.value = totalCount;
tableData.value = data; tableData.value = data;
pagination.page = page; pagination.page = page;
@ -283,6 +285,10 @@ const inputHandler = debounce((word) => {
keyword.value = word; keyword.value = word;
query(1, 5); query(1, 5);
}, 300); }, 300);
const showSearch = computed(() => {
return selectionIds.value.length > 0;
});
</script> </script>
<template> <template>
@ -307,7 +313,7 @@ const inputHandler = debounce((word) => {
<span :style="{ 'margin-left': '18px' }">基本信息</span> <span :style="{ 'margin-left': '18px' }">基本信息</span>
</div> </div>
</div> </div>
<div class="wrapper-form"> <div class="wrapper-form" v-if="!showSearch">
<n-input <n-input
:style="{ width: '360px', border: '1px solid #cad2dd' }" :style="{ width: '360px', border: '1px solid #cad2dd' }"
placeholder="请输入过滤条件名称搜索" placeholder="请输入过滤条件名称搜索"
@ -324,6 +330,21 @@ const inputHandler = debounce((word) => {
</template> </template>
</n-button> </n-button>
</div> </div>
<div class="wrapper-form" v-else>
<div class="del_btn">
<n-button icon-placement="left" size="medium">
<template #icon>
<SvgIcon name="delete-history" size="16" />
</template>
删除</n-button>
</div>
<div class="msg">
<span>已选中 <span style="color:#507afd;font-size:16px">{{ selectionIds.length }}</span> </span>
<a @click="selectionIds = []">清空</a>
</div>
</div>
<div class="wrapper-table"> <div class="wrapper-table">
<NDataTable <NDataTable
ref="tableRef" ref="tableRef"
@ -337,6 +358,7 @@ const inputHandler = debounce((word) => {
@update:page="handlePageChange" @update:page="handlePageChange"
@update-page-size="handlePageSizeChange" @update-page-size="handlePageSizeChange"
@update:checked-row-keys="handleCheck" @update:checked-row-keys="handleCheck"
:checked-row-keys="selectionIds"
/> />
</div> </div>
</div> </div>
@ -378,6 +400,16 @@ const inputHandler = debounce((word) => {
width: 300px; width: 300px;
border: 1px solid gray; border: 1px solid gray;
} }
.del_btn{
}
.msg{
a{
margin-left: 30px;
cursor: pointer;
color: #507afd;
}
}
} }
&-table { &-table {

@ -1,5 +1,14 @@
<script lang="ts" setup> <script lang="ts" setup>
import { defineOptions, h, nextTick, onUnmounted, reactive, ref, unref } from "vue"; import {
computed,
defineOptions,
h,
nextTick,
onUnmounted,
reactive,
ref,
unref,
} from "vue";
import { NDataTable } from "naive-ui"; import { NDataTable } from "naive-ui";
import type { DataTableColumns, DataTableRowKey } from "naive-ui"; import type { DataTableColumns, DataTableRowKey } from "naive-ui";
import type { SortableEvent } from "sortablejs"; import type { SortableEvent } from "sortablejs";
@ -111,7 +120,7 @@ async function query(page: number, pageSize: number) {
search_searchname: { value: keyword.value, op: "like", type: "string" }, search_searchname: { value: keyword.value, op: "like", type: "string" },
}; };
const result = await getConditionList({ pageNo: page, pageSize }, searchParam, 0); const result = await getConditionList({ pageNo: page, pageSize }, searchParam, 0);
const { data, pageCount, total:totalCount } = result; const { data, pageCount, total: totalCount } = result;
tableData.value = data; tableData.value = data;
pagination.page = page; pagination.page = page;
total.value = totalCount; total.value = totalCount;
@ -265,6 +274,7 @@ defineExpose({
showModal, showModal,
}); });
const inputHandler = debounce((word) => { const inputHandler = debounce((word) => {
keyword.value = word; keyword.value = word;
query(1, 5); query(1, 5);
@ -317,6 +327,7 @@ const inputHandler = debounce((word) => {
</template> </template>
</n-button> </n-button>
</div> </div>
<div class="wrapper-table"> <div class="wrapper-table">
<NDataTable <NDataTable
ref="tableRef" ref="tableRef"
@ -331,6 +342,7 @@ const inputHandler = debounce((word) => {
@update:page="handlePageChange" @update:page="handlePageChange"
@update-page-size="handlePageSizeChange" @update-page-size="handlePageSizeChange"
@update:checked-row-keys="handleCheck" @update:checked-row-keys="handleCheck"
/> />
</div> </div>
</div> </div>

Loading…
Cancel
Save