【更新】表头接口列添加搜索, 数据范围添加全选

pull/117/head
15894237752 2 years ago
parent 466c6c67cb
commit 0b03bcefde

@ -5,27 +5,60 @@
:visible="visible" :visible="visible"
:destroy-on-close="true" :destroy-on-close="true"
:show-pagination="false" :show-pagination="false"
@close="onClose" @close="onClose">
> <a-alert message="注:此功能界面需要与代码查询条件配合使用,并非所有接口都需设置数据范围,多用于业务模块!" type="warning" closable/>
<a-alert
message="注:此功能界面需要与代码查询条件配合使用,并非所有接口都需设置数据范围,多用于业务模块!"
type="warning"
closable
/>
<a-spin :spinning="spinningLoading"> <a-spin :spinning="spinningLoading">
<a-table <a-table
class="mt-4" class="mt-4"
size="middle" size="middle"
:columns="columns" :columns="columns"
:data-source="loadDatas" :data-source="loadDatas"
bordered
:row-key="(record) => record.api" :row-key="(record) => record.api"
> bordered>
<template #headerCell="{ column }"> <template #headerCell="{ column }">
<template v-if="column.key === 'api'"> <template v-if="column.key === 'api'">
<a-checkbox @update:checked="(val) => onCheckAllChange(val)"> 接口 </a-checkbox> <a-checkbox @update:checked="(val) => onCheckAllChange(val)"> 接口 </a-checkbox>
</template> </template>
<template v-if="column.key === 'dataScope'">
<span>{{ column.title }}</span>
<a-radio-group v-model:value="scopeRadioValue"
@change="radioChange" style="padding: 0 10px">
<a-radio value="SCOPE_ALL"> 全部 </a-radio>
<a-radio value="SCOPE_SELF"> 仅自已 </a-radio>
<a-radio value="SCOPE_ORG"> 所属机构 </a-radio>
<a-radio value="SCOPE_ORG_CHILD"> 所属机构及以下 </a-radio>
</a-radio-group>
</template>
</template>
<!---->
<template #customFilterDropdown="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }">
<div style="padding: 8px">
<a-input
ref="searchInput"
:placeholder="`Search ${column.dataIndex}`"
:value="selectedKeys[0]"
style="width: 188px; margin-bottom: 8px; display: block"
@change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
@pressEnter="handleSearch(selectedKeys, confirm, column.dataIndex)"
/>
<a-button
type="primary"
size="small"
style="width: 90px; margin-right: 8px"
@click="handleSearch(selectedKeys, confirm, column.dataIndex)"
>
<template #icon><SearchOutlined /></template>
Search
</a-button>
<a-button size="small" style="width: 90px" @click="handleReset(clearFilters)">
Reset
</a-button>
</div>
</template> </template>
<template #customFilterIcon="{ filtered }">
<search-outlined :style="{ color: filtered ? '#108ee9' : undefined }" />
</template>
<!---->
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'api'"> <template v-if="column.dataIndex === 'api'">
<a-checkbox :checked="record.check" @update:checked="(val) => changeApi(record, val)"> <a-checkbox :checked="record.check" @update:checked="(val) => changeApi(record, val)">
@ -38,8 +71,7 @@
<a-radio <a-radio
v-model:checked="item.check" v-model:checked="item.check"
:name="item.title" :name="item.title"
@change="(evt) => changeDataScope(record, evt)" @change="(evt) => changeDataScope(record, evt)">
>
<a-badge <a-badge
v-if=" v-if="
(item.value === 'SCOPE_ORG_DEFINE') & (item.value === 'SCOPE_ORG_DEFINE') &
@ -47,15 +79,13 @@
(item.scopeDefineOrgIdList !== undefined) (item.scopeDefineOrgIdList !== undefined)
" "
:count="item.scopeDefineOrgIdList.length" :count="item.scopeDefineOrgIdList.length"
:number-style="{ backgroundColor: '#52c41a' }" :number-style="{ backgroundColor: '#52c41a' }">
> {{ item.title }}</a-badge>
{{ item.title }}</a-badge
>
<div v-else>{{ item.title }}</div> <div v-else>{{ item.title }}</div>
</a-radio> </a-radio>
</template> </template>
<a-button v-if="record.dataScope[4].check" type="link" size="small" @click="handleDefineOrg(record)" <a-button v-if="record.dataScope[4].check" type="link" size="small" @click="handleDefineOrg(record)"
>选择机构</a-button >选择机构</a-button
> >
</template> </template>
</template> </template>
@ -71,6 +101,7 @@
</template> </template>
<script setup name="grantResourceForm"> <script setup name="grantResourceForm">
import { SearchOutlined } from '@ant-design/icons-vue';
import roleApi from '@/api/sys/roleApi' import roleApi from '@/api/sys/roleApi'
import { remove } from 'lodash-es' import { remove } from 'lodash-es'
import ScopeDefineOrg from './scopeDefineOrg.vue' import ScopeDefineOrg from './scopeDefineOrg.vue'
@ -86,13 +117,29 @@
// 90% // 90%
//(window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) * 0.9 //(window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) * 0.9
let loadDatas = ref([]) let loadDatas = ref([])
// ,
const scopeRadioValue = ref()
const state = reactive({
searchText: '',
searchedColumn: '',
});
const searchInput = ref();
const columns = [ const columns = [
{ {
key: 'api', key: 'api',
title: '接口', title: '接口',
dataIndex: 'api', dataIndex: 'api',
width: 380 width: 380,
customFilterDropdown: true,
onFilter: (value, record) => record.api.includes(value),
onFilterDropdownVisibleChange: visible => {
if (visible) {
setTimeout(() => {
searchInput.value.focus();
}, 100);
}
},
}, },
{ {
key: 'dataScope', key: 'dataScope',
@ -157,13 +204,13 @@
}, },
{ {
id: `SCOPE_ORG_${id}`, id: `SCOPE_ORG_${id}`,
title: '所属组织', title: '所属机构',
value: 'SCOPE_ORG', value: 'SCOPE_ORG',
check: false check: false
}, },
{ {
id: `SCOPE_ORG_CHILD_${id}`, id: `SCOPE_ORG_CHILD_${id}`,
title: '所属组织及以下', title: '所属机构及以下',
value: 'SCOPE_ORG_CHILD', value: 'SCOPE_ORG_CHILD',
check: false check: false
}, },
@ -232,6 +279,7 @@
const onClose = () => { const onClose = () => {
// //
loadDatas.value = [] loadDatas.value = []
scopeRadioValue.value = ''
visible.value = false visible.value = false
} }
// //
@ -319,6 +367,30 @@
submitLoading.value = false submitLoading.value = false
}) })
} }
//
const handleSearch = (selectedKeys, confirm, dataIndex) => {
confirm();
state.searchText = selectedKeys[0];
state.searchedColumn = dataIndex;
}
//
const handleReset = clearFilters => {
clearFilters();
state.searchText = '';
}
// radio-group
const radioChange = (obj) => {
loadDatas.value.forEach((data) => {
data.dataScope.forEach((data) => {
if (obj.target.value === data.value){
data.check = true
}else {
data.check = false
}
})
})
}
// //
defineExpose({ defineExpose({
onOpen onOpen

Loading…
Cancel
Save