增加自动填充

This commit is contained in:
lai
2024-07-23 18:05:25 +08:00
parent c7606df740
commit 3dafe8d1f6
2 changed files with 54 additions and 6 deletions

View File

@@ -18,6 +18,7 @@ import saveAs from 'file-saver';
import PQueue from 'p-queue';
import useUserStore from '@/store/modules/user';
import { TENANTADMIN_ROLE_KEY } from '@/constants/admin-constants';
import { listTenant } from '@/api/system/tenant';
const { t } = useI18n();
const { getDict } = useDictStore();
const ws = new WS();
@@ -42,6 +43,7 @@ let queryRangePicker = ref<[string, string]>(['', '']);
/**查询参数 */
let queryParams = reactive({
tenantNameArr: <Record<string, any>[]>[],
/**网元类型 */
neType: 'AMF',
neId: '001',
@@ -64,6 +66,7 @@ let queryParams = reactive({
function fnQueryReset() {
eventTypes.value = [];
queryParams = Object.assign(queryParams, {
tenantNameArr: [],
eventType: '',
imsi: '',
tenantName: '',
@@ -408,6 +411,11 @@ function wsMessage(res: Record<string, any>) {
}
}
//自动完成框不区分大小写
function filterOption(input: string, option: any) {
return option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0;
}
onMounted(() => {
// 初始字典数据
Promise.allSettled([
@@ -440,6 +448,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,
});
}
});
}
});
});
onBeforeUnmount(() => {
@@ -487,10 +510,11 @@ onBeforeUnmount(() => {
:label="t('views.neUser.sub.tenantName')"
name="tenantName "
>
<a-input
allow-clear
<a-auto-complete
v-model:value="queryParams.tenantName"
></a-input>
:options="queryParams.tenantNameArr"
:filter-option="filterOption"
></a-auto-complete>
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :xs="24">

View File

@@ -16,6 +16,7 @@ import { parseDateToStr } from '@/utils/date-utils';
import { OptionsType, WS } from '@/plugins/ws-websocket';
import saveAs from 'file-saver';
import PQueue from 'p-queue';
import { listTenant } from '@/api/system/tenant';
const { t } = useI18n();
const { getDict } = useDictStore();
@@ -41,6 +42,7 @@ let queryRangePicker = ref<[string, string]>(['', '']);
/**查询参数 */
let queryParams = reactive({
tenantNameArr: <Record<string, any>[]>[],
/**网元类型 */
neType: 'MME',
neId: '001',
@@ -63,6 +65,7 @@ let queryParams = reactive({
function fnQueryReset() {
eventTypes.value = [];
queryParams = Object.assign(queryParams, {
tenantNameArr:[],
eventType: '',
imsi: '',
tenantName: '',
@@ -407,6 +410,11 @@ function wsMessage(res: Record<string, any>) {
}
}
//自动完成框不区分大小写
function filterOption(input: string, option: any) {
return option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0;
}
onMounted(() => {
// 初始字典数据
Promise.allSettled([
@@ -429,6 +437,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,
});
}
});
}
});
});
onBeforeUnmount(() => {
@@ -476,10 +499,11 @@ onBeforeUnmount(() => {
:label="t('views.neUser.sub.tenantName')"
name="tenantName "
>
<a-input
allow-clear
<a-auto-complete
v-model:value="queryParams.tenantName"
></a-input>
:options="queryParams.tenantNameArr"
:filter-option="filterOption"
></a-auto-complete>
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :xs="24">