增加租户名的自动完成框

This commit is contained in:
lai
2024-07-15 15:51:46 +08:00
parent af5ac7d29a
commit 51226fbfb4
3 changed files with 89 additions and 58 deletions

View File

@@ -10,6 +10,7 @@ import useNeInfoStore from '@/store/modules/neinfo';
import useI18n from '@/hooks/useI18n';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import TableColumnsDnd from '@/components/TableColumnsDnd/index.vue';
import { listTenant } from '@/api/system/tenant';
import useUserStore from '@/store/modules/user';
const { t } = useI18n();
@@ -19,6 +20,7 @@ let neOtions = ref<Record<string, any>[]>([]);
/**查询参数 */
let queryParams = reactive({
tenantNameArr: <Record<string, any>[]>[],
/**网元ID */
neId: undefined,
/**IMSI */
@@ -36,6 +38,7 @@ let queryParams = reactive({
/**查询参数重置 */
function fnQueryReset() {
queryParams = Object.assign(queryParams, {
tenantNameArr: [],
imsi: '',
msisdn: '',
tenantName: '',
@@ -260,6 +263,11 @@ function fnGetList(pageNum?: number) {
});
}
//自动完成框不区分大小写
function filterOption(input: string, option: any) {
return option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0;
}
onMounted(() => {
// 获取网元网元列表
useNeInfoStore()
@@ -289,6 +297,21 @@ onMounted(() => {
// 获取列表数据
fnGetList();
});
//查询租户
listTenant({ parentId: 0 }).then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
queryParams.tenantNameArr = []; //上面置为空数组时会报错 故在此
res.data.forEach((item: any) => {
if (item.parentId === '0') {
queryParams.tenantNameArr.push({
value: item.tenantName,
label: item.tenantName,
});
}
});
}
});
});
</script>
@@ -327,10 +350,11 @@ onMounted(() => {
:label="t('views.neUser.sub.tenantName')"
name="tenantName "
>
<a-input
<a-auto-complete
v-model:value="queryParams.tenantName"
allow-clear
></a-input>
:options="queryParams.tenantNameArr"
:filter-option="filterOption"
></a-auto-complete>
</a-form-item>
</a-col>