perf: cleancode
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
9b8fa55e4c
commit
e775d922e8
|
@ -103,14 +103,13 @@ const arrayData = useURL.value
|
|||
: ref(null);
|
||||
onMounted(async () => {
|
||||
setOptions(options.value);
|
||||
if (!$props.options) fetchFilter($props.modelValue);
|
||||
if (useURL.value) {
|
||||
arrayData.store.userFilter = $props.where;
|
||||
arrayData.store.filter.where = $props.where;
|
||||
const { data } = await arrayData.fetch({ append: true });
|
||||
setOptions(data);
|
||||
return;
|
||||
}
|
||||
if (!$props.options) fetchFilter($props.modelValue);
|
||||
});
|
||||
|
||||
watch(modelValue, (newValue) => {
|
||||
|
@ -125,7 +124,7 @@ function filter(val, options) {
|
|||
|
||||
if (!search) return options;
|
||||
|
||||
const optionsFiltered = options.filter((row) => {
|
||||
return options.filter((row) => {
|
||||
if ($props.filterOptions.length) {
|
||||
return $props.filterOptions.some((prop) => {
|
||||
const propValue = String(row[prop]).toLowerCase();
|
||||
|
@ -138,16 +137,15 @@ function filter(val, options) {
|
|||
|
||||
return id == search || optionLabel.includes(search);
|
||||
});
|
||||
|
||||
return optionsFiltered;
|
||||
}
|
||||
|
||||
async function fetchFilter(val) {
|
||||
if (!useURL.value || !dataRef.value) return;
|
||||
|
||||
const { fields, sortBy, limit } = $props;
|
||||
let key = null;
|
||||
if (new RegExp(/\d/g).test(val)) key = optionFilter.value ?? optionValue.value;
|
||||
let key = new RegExp(/\d/g).test(val)
|
||||
? optionFilter.value ?? optionValue.value
|
||||
: optionValue.value;
|
||||
|
||||
const where = { ...{ [key]: { like: `%${val}%` } }, ...$props.where };
|
||||
return dataRef.value.fetch({ fields, where, order: sortBy, limit });
|
||||
|
|
Loading…
Reference in New Issue