update:人员下拉区分租户
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
:options="listData"
|
||||
:placeholder="disabled ? '' : '请输入名称或工号'"
|
||||
filterable
|
||||
remote
|
||||
:remote="remote"
|
||||
:remote-method="getUserDataByKeyFun"
|
||||
clearable
|
||||
:collapse-tags="multiple"
|
||||
@@ -20,9 +20,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { listUserWithKeyWordApi } from '@/api/system/user';
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { listUserWithKeyWordApi, userListUserApi } from '@/api/system/user';
|
||||
import { dataUseRate, dataUserRateSort } from '@/utils/common';
|
||||
import { enableConfigByTenant, TENANT_ENUM } from '@/tenants/tenant';
|
||||
|
||||
interface Props {
|
||||
modelValue: string;
|
||||
@@ -39,24 +40,22 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
const listData = ref<any>([]);
|
||||
const choseList = ref<any>([]);
|
||||
const remote = ref(enableConfigByTenant([TENANT_ENUM.LYRIC]));
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'change', 'clear']);
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val: any) => {
|
||||
if (props.multiple) {
|
||||
choseList.value = val ? String(val).split(',') : [];
|
||||
} else {
|
||||
choseList.value = val;
|
||||
}
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
onMounted(() => {
|
||||
if (!enableConfigByTenant([TENANT_ENUM.LYRIC])) {
|
||||
getAllUsersFun();
|
||||
}
|
||||
});
|
||||
|
||||
const getUserDataByKeyFun = (query: string) => {
|
||||
// 全为两个及以上汉字或者全是四个及以上数组
|
||||
const regex = /^([\u4e00-\u9fa5]{2,}|\d{4,})$/;
|
||||
if (!enableConfigByTenant([TENANT_ENUM.LYRIC])) {
|
||||
return;
|
||||
}
|
||||
// 1个或更多汉字或者4个或更多任意字符
|
||||
const regex = /^([\u4e00-\u9fa5]{1,}|.{4,})$/;
|
||||
if (!query || !regex.test(query)) {
|
||||
listData.value = [];
|
||||
return;
|
||||
@@ -79,6 +78,39 @@ const getUserDataByKeyFun = (query: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getAllUsersFun = () => {
|
||||
const params = {
|
||||
current: 1,
|
||||
size: 9999,
|
||||
};
|
||||
userListUserApi(params).then((res: any) => {
|
||||
if (res.code === 200) {
|
||||
const build = res.data.data.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
value: item.userId,
|
||||
label: item.nickname || item.realName,
|
||||
};
|
||||
});
|
||||
listData.value = build;
|
||||
listData.value = dataUserRateSort('userId', build, 'user');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val: any) => {
|
||||
if (props.multiple) {
|
||||
choseList.value = val ? String(val).split(',') : [];
|
||||
} else {
|
||||
choseList.value = val;
|
||||
}
|
||||
getUserDataByKeyFun(val);
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
|
||||
const changeFun = () => {
|
||||
if (props.multiple) {
|
||||
const ids = choseList.value.join(',');
|
||||
|
||||
Reference in New Issue
Block a user