Browse Source

客户提出功能: 选择当页、反选当页、取消全选

master_hella_20240701
yufei0306 5 months ago
parent
commit
6f7a9c836f
  1. 46
      src/components/SearchTable/src/SearchTable.vue
  2. 40
      src/components/Table/src/Table.vue
  3. 3
      src/locales/en-US.ts
  4. 3
      src/locales/zh-CN.ts
  5. 40
      src/utils/disposition/defaultButtons.ts

46
src/components/SearchTable/src/SearchTable.vue

@ -10,6 +10,7 @@
:HeadButttondata="HeadButttondata" :HeadButttondata="HeadButttondata"
:routeName="routeName" :routeName="routeName"
@searchFormClick="searchFormClick" @searchFormClick="searchFormClick"
@buttonBaseClick="buttonBaseClick"
:allSchemas="allSchemasRef" :allSchemas="allSchemasRef"
/> />
<ContentWrap> <ContentWrap>
@ -26,6 +27,7 @@
v-model:sort="tableObjectRef.sort" v-model:sort="tableObjectRef.sort"
:searchTableSelectionsList="searchTableSelectionsList" :searchTableSelectionsList="searchTableSelectionsList"
:selection="true" :selection="true"
:selectionTotal="multipleBol"
:reserveSelection="true" :reserveSelection="true"
row-key="id" row-key="id"
/> />
@ -53,10 +55,18 @@ routeName.value = route.name
const searchDialogVisible = ref(false) // const searchDialogVisible = ref(false) //
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const multipleBol = ref(false)
// //
const HeadButttondata = ref([ const HeadButttondata = ref(multipleBol.value?
[
defaultButtons.defaultWhenPageBtn(null), //
defaultButtons.defaultUnselectPageBtn(null), //
defaultButtons.defaultDeselectAllBtn(null), //
defaultButtons.defaultFilterBtn(null), // defaultButtons.defaultFilterBtn(null), //
]:[
defaultButtons.defaultFilterBtn(null) //
]) ])
/** 打开弹窗 */ /** 打开弹窗 */
@ -71,26 +81,37 @@ const searchFieldRef = ref()
const typeRef = ref() const typeRef = ref()
const rowRef = ref() const rowRef = ref()
const allSchemasRef = ref() const allSchemasRef = ref()
const multipleBol = ref(false)
const searchConditionRef = ref() const searchConditionRef = ref()
const searchTableSelectionsList = ref()// const searchTableSelectionsList = ref()//
const openData = (titleName: any, tableObject:any ,allSchemas: any,multiple: any) => { const openData = (titleName: any, tableObject:any ,allSchemas: any,multiple: any) => {
dialogWidth.value = '80%' dialogWidth.value = '80%'
HeadButttondata.value = [ multipleBol.value = multiple
HeadButttondata.value = multiple?[
defaultButtons.defaultWhenPageBtn(null), //
defaultButtons.defaultUnselectPageBtn(null), //
defaultButtons.defaultDeselectAllBtn(null), //
defaultButtons.defaultFilterBtn(null), //
]:[
defaultButtons.defaultFilterBtn(null), // defaultButtons.defaultFilterBtn(null), //
] ]
dialogTitle.value = t(`ts.${titleName}`).replace('ts.','') dialogTitle.value = t(`ts.${titleName}`).replace('ts.','')
tableObjectRef.value = tableObject tableObjectRef.value = tableObject
searchDialogVisible.value = true searchDialogVisible.value = true
multipleBol.value = multiple
allSchemasRef.value = allSchemas allSchemasRef.value = allSchemas
searchSchema.value = allSchemas.searchSchema searchSchema.value = allSchemas.searchSchema
tableColumns.value = allSchemas.tableColumns tableColumns.value = allSchemas.tableColumns
} }
const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, searchField: any,multiple: any, type: any, row: any, searchCondition:any , isCountRequestRe:any,isConcatDetailSchemas=false,detailSchemas: any, searchTableSelections:any) => { const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, searchField: any,multiple: any, type: any, row: any, searchCondition:any , isCountRequestRe:any,isConcatDetailSchemas=false,detailSchemas: any, searchTableSelections:any) => {
dialogWidth.value = '80%' dialogWidth.value = '80%'
HeadButttondata.value = [ multipleBol.value = multiple
HeadButttondata.value = multiple?[
defaultButtons.defaultWhenPageBtn(null), //
defaultButtons.defaultUnselectPageBtn(null), //
defaultButtons.defaultDeselectAllBtn(null), //
defaultButtons.defaultFilterBtn(null), //
]:
[
defaultButtons.defaultFilterBtn(null), // defaultButtons.defaultFilterBtn(null), //
] ]
searchDialogVisible.value = true searchDialogVisible.value = true
@ -108,7 +129,6 @@ const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, s
getPage.value = getApiPage getPage.value = getApiPage
typeRef.value = type typeRef.value = type
rowRef.value = row rowRef.value = row
multipleBol.value = multiple
// dialogTitle.value = t('action.' + type) // dialogTitle.value = t('action.' + type)
dialogTitle.value = t(`ts.${titleName}`).replace('ts.','') dialogTitle.value = t(`ts.${titleName}`).replace('ts.','')
searchTableSelectionsList.value = searchTableSelections searchTableSelectionsList.value = searchTableSelections
@ -175,6 +195,20 @@ const searchFormClick = (searchData) => {
} }
getListRef.value() // getListRef.value() //
} }
const buttonBaseClick = (val, item) => {
//
if (val == 'DeselectAll') {
//
searchTableRef.value.clearSelection()
} else if (val == 'UnselectPage') {
//
searchTableRef.value.togglePageSelection()
} else if (val == 'WhenPage') {
//
searchTableRef.value.toggleAllSelection(true)
}
}
defineExpose({ open,openData,hiddenFilterButton ,changeDialogWidth}) // open defineExpose({ open,openData,hiddenFilterButton ,changeDialogWidth}) // open

40
src/components/Table/src/Table.vue

@ -21,6 +21,8 @@ export default defineComponent({
currentPage: propTypes.number.def(1), currentPage: propTypes.number.def(1),
// //
selection: propTypes.bool.def(false), selection: propTypes.bool.def(false),
//
selectionTotal: propTypes.bool.def(false),
// schemashowOverflowTooltip, // schemashowOverflowTooltip,
showOverflowTooltip: propTypes.bool.def(true), showOverflowTooltip: propTypes.bool.def(true),
// //
@ -115,12 +117,36 @@ export default defineComponent({
const selections = ref<Recordable[]>([]) const selections = ref<Recordable[]>([])
const sortRef = ref() const sortRef = ref()
//
const selectRow = ()=>{ const selectRow = ()=>{
emit('getSelectionRows', currentPageRef.value,elTableRef.value?.getSelectionRows()) emit('getSelectionRows', currentPageRef.value,elTableRef.value?.getSelectionRows())
} }
const selectAll = (val)=>{ //
const selectAll = ()=>{
emit('getSelectionRows', currentPageRef.value,elTableRef.value?.getSelectionRows()) emit('getSelectionRows', currentPageRef.value,elTableRef.value?.getSelectionRows())
} }
//
const togglePageSelection = ()=>{
unref(getProps).data.forEach(row=>{
elTableRef.value!.toggleRowSelection(row)
})
}
// /
const toggleAllSelection = (isAll)=>{
if(isAll){
//
if(elTableRef.value?.getSelectionRows().length<unref(getProps).data.length){
elTableRef.value!.toggleAllSelection()
}
}
}
//
const clearSelection = ()=>{
console.log('clearSelection')
elTableRef.value!.clearSelection()
}
const selectionChange = (selection: Recordable[]) => { const selectionChange = (selection: Recordable[]) => {
selections.value = selection selections.value = selection
} }
@ -134,7 +160,11 @@ export default defineComponent({
setProps, setProps,
setColumn, setColumn,
selections, selections,
toggleRowSelection toggleRowSelection,
selectAll,
toggleAllSelection,
togglePageSelection,
clearSelection
}) })
const pagination = computed(() => { const pagination = computed(() => {
@ -358,13 +388,15 @@ export default defineComponent({
append: () => getSlot(slots, 'append') append: () => getSlot(slots, 'append')
}} }}
</ElTable> </ElTable>
{unref(getProps).selectionTotal ? (
<div class="mt-5px">已选{selections.value.length}条数据</div>
):undefined}
{unref(getProps).pagination ? ( {unref(getProps).pagination ? (
// update by Pagination // update by Pagination
<ElPagination <ElPagination
v-model:pageSize={pageSizeRef.value} v-model:pageSize={pageSizeRef.value}
v-model:currentPage={currentPageRef.value} v-model:currentPage={currentPageRef.value}
class="float-right mb-15px mt-15px" class="float-right mt-15px"
{...unref(pagination)} {...unref(pagination)}
></ElPagination> ></ElPagination>
) : undefined} ) : undefined}

3
src/locales/en-US.ts

@ -864,6 +864,9 @@ export default {
:'Export', :'Export',
:'Refresh', :'Refresh',
:'Filter', :'Filter',
:'As Page',
:'Unselect Page',
:'Deselect All',
:'Settings', :'Settings',
:'Confirm', :'Confirm',
'确 定':'Confirm', '确 定':'Confirm',

3
src/locales/zh-CN.ts

@ -864,6 +864,9 @@ export default {
:'导出', :'导出',
:'刷新', :'刷新',
:'筛选', :'筛选',
:'选择当页',
:'反选当页',
:'取消全选',
:'设置', :'设置',
:'确定', :'确定',
'确 定':'确 定', '确 定':'确 定',

40
src/utils/disposition/defaultButtons.ts

@ -159,7 +159,45 @@ export function defaultSearchResetBtn(option:any) {
hasPermi: '' hasPermi: ''
}) })
} }
// 选择当页
export function defaultWhenPageBtn(option:any) {
return __defaultBtnOption(option,{
label: t(`ts.选择当页`).replace('ts.', ''),
name: 'WhenPage',
hide: false,
type: 'primary',
color: '',
float:'right',
link: false, // 文本展现按钮
hasPermi: ''
})
}
// 反选当页
export function defaultUnselectPageBtn(option:any) {
return __defaultBtnOption(option,{
label: t(`ts.反选当页`).replace('ts.', ''),
name: 'UnselectPage',
hide: false,
type: 'primary',
color: '',
float:'right',
link: false, // 文本展现按钮
hasPermi: ''
})
}
// 取消全选
export function defaultDeselectAllBtn(option:any) {
return __defaultBtnOption(option,{
label: t(`ts.取消全选`).replace('ts.', ''),
name: 'DeselectAll',
hide: false,
type: 'primary',
color: '',
float:'right',
link: false, // 文本展现按钮
hasPermi: ''
})
}
// form表单-保存按钮 // form表单-保存按钮
export function formSaveBtn(option:any) { export function formSaveBtn(option:any) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{

Loading…
Cancel
Save