code refactor

This commit is contained in:
MaysWind
2023-08-13 14:58:11 +08:00
parent fa3e941069
commit f6a2246aab
5 changed files with 22 additions and 44 deletions
+2 -11
View File
@@ -29,6 +29,7 @@
</template>
<script>
import { arrayContainsFieldvalue } from '@/lib/common.js';
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
export default {
@@ -81,17 +82,7 @@ export default {
this.$emit('update:show', false);
},
hasSelectedIcon(row) {
if (!this.currentValue || !row || !row.length) {
return false;
}
for (let i = 0; i < row.length; i++) {
if (row[i].id === this.currentValue) {
return true;
}
}
return false;
return arrayContainsFieldvalue(row, 'id', this.currentValue);
}
}
}
+2 -11
View File
@@ -29,6 +29,7 @@
</template>
<script>
import { arrayContainsFieldvalue } from '@/lib/common.js';
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
export default {
@@ -101,17 +102,7 @@ export default {
this.$emit('update:show', false);
},
hasSelectedIcon(row) {
if (!this.currentValue || !row || !row.length) {
return false;
}
for (let i = 0; i < row.length; i++) {
if (row[i].id === this.currentValue) {
return true;
}
}
return false;
return arrayContainsFieldvalue(row, 'id', this.currentValue);
}
}
}