|
|
@@ -10,7 +10,7 @@
|
|
|
placeholder="搜索工单编码、风机编号"
|
|
|
v-model="searchKeyword"
|
|
|
@confirm="handleSearch"
|
|
|
- @blur="handleSearchWithPrevent"
|
|
|
+ @blur="handleSearch"
|
|
|
/>
|
|
|
<text v-if="searchKeyword.length > 0" class="clear-icon" @click="clearSearch">✕</text>
|
|
|
</view>
|
|
|
@@ -22,21 +22,21 @@
|
|
|
<text
|
|
|
class="status-txt"
|
|
|
:class="{ 'stauts-sel': orderTypeFilter === '' }"
|
|
|
- @click="filterByOrderTypeWithCheck('')"
|
|
|
+ @click="filterByOrderType('')"
|
|
|
>
|
|
|
全部
|
|
|
</text>
|
|
|
<text
|
|
|
class="status-txt"
|
|
|
:class="{ 'stauts-sel': orderTypeFilter === '1' }"
|
|
|
- @click="filterByOrderTypeWithCheck('1')"
|
|
|
+ @click="filterByOrderType('1')"
|
|
|
>
|
|
|
维修工单
|
|
|
</text>
|
|
|
<text
|
|
|
class="status-txt"
|
|
|
:class="{ 'stauts-sel': orderTypeFilter === '2' }"
|
|
|
- @click="filterByOrderTypeWithCheck('2')"
|
|
|
+ @click="filterByOrderType('2')"
|
|
|
>
|
|
|
维保工单
|
|
|
</text>
|
|
|
@@ -51,14 +51,14 @@
|
|
|
<text
|
|
|
class="time-filter"
|
|
|
:class="{ 'time-filter-sel': timeRange === 'week' }"
|
|
|
- @click="changeTimeRangeWithCheck('week')"
|
|
|
+ @click="changeTimeRange('week')"
|
|
|
>
|
|
|
本周
|
|
|
</text>
|
|
|
<text
|
|
|
class="time-filter"
|
|
|
:class="{ 'time-filter-sel': timeRange === 'month' }"
|
|
|
- @click="changeTimeRangeWithCheck('month')"
|
|
|
+ @click="changeTimeRange('month')"
|
|
|
>
|
|
|
本月
|
|
|
</text>
|
|
|
@@ -193,7 +193,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="uts">
|
|
|
-import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
|
|
|
+import { ref, computed, onLoad, onBeforeUnmount } from 'vue'
|
|
|
import { listOrderHours, getOrderHourStatistics } from '@/api/worktime/index'
|
|
|
import { getDictDataByType } from '@/api/dict/index'
|
|
|
import type { SysDictData } from '@/types/dict'
|
|
|
@@ -213,14 +213,6 @@ const repairHours = ref<number>(0)
|
|
|
const rank = ref<number | null>(null)
|
|
|
const totalRankingUsers = ref<number | null>(null)
|
|
|
|
|
|
-// 防止重复请求的标志位
|
|
|
-const isSearching = ref<boolean>(false)
|
|
|
-const isRequestPending = ref<boolean>(false)
|
|
|
-
|
|
|
-// 添加防抖定时器
|
|
|
-let searchTimer: number | null = null
|
|
|
-let lastRequestTime: number = 0
|
|
|
-
|
|
|
// 弹窗显示状态
|
|
|
const showDatePickerPopup = ref<boolean>(false)
|
|
|
const showStartDatePicker = ref<boolean>(false)
|
|
|
@@ -460,26 +452,22 @@ function getStatistics() {
|
|
|
}
|
|
|
|
|
|
// 方法
|
|
|
-function loadData(isRefresh: boolean) {
|
|
|
- // 防止重复请求的核心机制
|
|
|
- if (loading.value || isRequestPending.value) {
|
|
|
+function loadData(isRefresh: boolean, disablePullDown = false) {
|
|
|
+ // 防止重复请求的核心机制 - 参考工单页面的简单有效方式
|
|
|
+ if (loading.value) {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- // iOS防抖处理,避免短时间内重复请求
|
|
|
- const currentTime = new Date().getTime();
|
|
|
- if (currentTime - lastRequestTime < 300) { // 300ms内不重复请求
|
|
|
- return;
|
|
|
- }
|
|
|
- lastRequestTime = currentTime;
|
|
|
-
|
|
|
- isRequestPending.value = true;
|
|
|
+
|
|
|
const shouldRefresh = isRefresh !== false
|
|
|
|
|
|
loading.value = true
|
|
|
- if (shouldRefresh) {
|
|
|
+ if (shouldRefresh && !disablePullDown) {
|
|
|
currentPage.value = 1
|
|
|
refreshing.value = true
|
|
|
+ } else if (shouldRefresh && disablePullDown) {
|
|
|
+ // 筛选条件变化时,重置页码但不触发下拉刷新
|
|
|
+ currentPage.value = 1
|
|
|
+ refreshing.value = false
|
|
|
} else {
|
|
|
// 对于加载更多操作,不需要显示下拉刷新状态
|
|
|
refreshing.value = false;
|
|
|
@@ -520,19 +508,31 @@ function loadData(isRefresh: boolean) {
|
|
|
// 无论成功还是失败,都重置所有加载状态
|
|
|
loading.value = false;
|
|
|
refreshing.value = false;
|
|
|
- isRequestPending.value = false;
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+function clearSearch() {
|
|
|
+ console.log("clearSearch被触发")
|
|
|
+ // 添加防重复调用检查
|
|
|
+ if (loading.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ searchKeyword.value = "";
|
|
|
+ currentPage.value = 1;
|
|
|
+ loadData(true, true); // 添加true参数表示这是筛选条件变化触发的加载,应禁用下拉刷新
|
|
|
+ getStatistics();
|
|
|
+}
|
|
|
+
|
|
|
function handleSearch() {
|
|
|
- const timer = searchTimer
|
|
|
- if (timer != null) {
|
|
|
- clearTimeout(timer)
|
|
|
+ console.log("handleSearch被触发")
|
|
|
+ // 添加防重复调用检查
|
|
|
+ if (loading.value) {
|
|
|
+ return;
|
|
|
}
|
|
|
- searchTimer = setTimeout(() => {
|
|
|
- loadData(true)
|
|
|
- getStatistics()
|
|
|
- }, 500)
|
|
|
+
|
|
|
+ loadData(true, true); // 添加true参数表示这是筛选条件变化触发的加载,应禁用下拉刷新
|
|
|
+ getStatistics()
|
|
|
}
|
|
|
|
|
|
// 防止iOS中input事件多次触发
|
|
|
@@ -540,7 +540,7 @@ const handleSearchWithPrevent = (() => {
|
|
|
let lastCall = 0;
|
|
|
return () => {
|
|
|
const now = new Date().getTime();
|
|
|
- if (now - lastCall < 500) { // 500ms内最多执行一次
|
|
|
+ if (now - lastCall < 300) { // 300ms内最多执行一次
|
|
|
return;
|
|
|
}
|
|
|
lastCall = now;
|
|
|
@@ -548,40 +548,28 @@ const handleSearchWithPrevent = (() => {
|
|
|
};
|
|
|
})();
|
|
|
|
|
|
-function clearSearch() {
|
|
|
- const timer = searchTimer
|
|
|
- if (timer != null) {
|
|
|
- clearTimeout(timer)
|
|
|
- }
|
|
|
- searchKeyword.value = ""
|
|
|
- searchTimer = setTimeout(() => {
|
|
|
- loadData(true)
|
|
|
- getStatistics()
|
|
|
- }, 500)
|
|
|
-}
|
|
|
-
|
|
|
function filterByOrderType(type: string) {
|
|
|
- const timer = searchTimer
|
|
|
- if (timer != null) {
|
|
|
- clearTimeout(timer)
|
|
|
+ console.log("filterByOrderType被触发")
|
|
|
+ // 添加防重复调用检查
|
|
|
+ if (loading.value) {
|
|
|
+ return;
|
|
|
}
|
|
|
- orderTypeFilter.value = type
|
|
|
- searchTimer = setTimeout(() => {
|
|
|
- loadData(true)
|
|
|
- getStatistics()
|
|
|
- }, 500)
|
|
|
+
|
|
|
+ orderTypeFilter.value = type;
|
|
|
+ loadData(true, true); // 添加true参数表示这是筛选条件变化触发的加载,应禁用下拉刷新
|
|
|
+ getStatistics();
|
|
|
}
|
|
|
|
|
|
function changeTimeRange(range: string) {
|
|
|
- const timer = searchTimer
|
|
|
- if (timer != null) {
|
|
|
- clearTimeout(timer)
|
|
|
+ console.log("changeTimeRange被触发")
|
|
|
+ // 添加防重复调用检查
|
|
|
+ if (loading.value) {
|
|
|
+ return;
|
|
|
}
|
|
|
- timeRange.value = range
|
|
|
- searchTimer = setTimeout(() => {
|
|
|
- loadData(true)
|
|
|
- getStatistics()
|
|
|
- }, 500)
|
|
|
+
|
|
|
+ timeRange.value = range;
|
|
|
+ loadData(true, true); // 添加true参数表示这是筛选条件变化触发的加载,应禁用下拉刷新
|
|
|
+ getStatistics();
|
|
|
}
|
|
|
|
|
|
function filterByOrderTypeWithCheck(type: string) {
|
|
|
@@ -601,6 +589,7 @@ function changeTimeRangeWithCheck(range: string) {
|
|
|
}
|
|
|
|
|
|
function loadMore() {
|
|
|
+ console.log("loadMore被触发")
|
|
|
if (!hasMore.value || loading.value) return
|
|
|
|
|
|
currentPage.value++
|
|
|
@@ -608,6 +597,7 @@ function loadMore() {
|
|
|
}
|
|
|
|
|
|
function handleRefresh() {
|
|
|
+ console.log("handleRefresh被触发")
|
|
|
loadData(true)
|
|
|
}
|
|
|
|
|
|
@@ -651,14 +641,13 @@ function confirmCustomDate() {
|
|
|
closeDatePicker()
|
|
|
timeRange.value = 'custom'
|
|
|
|
|
|
- const timer = searchTimer
|
|
|
- if (timer != null) {
|
|
|
- clearTimeout(timer)
|
|
|
+ // 添加防重复调用检查
|
|
|
+ if (loading.value) {
|
|
|
+ return;
|
|
|
}
|
|
|
- searchTimer = setTimeout(() => {
|
|
|
- loadData(true)
|
|
|
- getStatistics()
|
|
|
- }, 500)
|
|
|
+
|
|
|
+ loadData(true, true); // 添加true参数表示这是筛选条件变化触发的加载,应禁用下拉刷新
|
|
|
+ getStatistics()
|
|
|
}
|
|
|
|
|
|
function showCustomDatePickerWithCheck() {
|
|
|
@@ -785,7 +774,7 @@ function getWorkOrderTypeInfo(item: any | null): string {
|
|
|
}
|
|
|
|
|
|
// 生命周期
|
|
|
-onMounted(() => {
|
|
|
+onLoad((options) => {
|
|
|
loadStatusDictList()
|
|
|
loadInspectionTypeDictList()
|
|
|
loadMaintenanceTypeDictList()
|
|
|
@@ -796,11 +785,7 @@ onMounted(() => {
|
|
|
|
|
|
// 组件销毁时清除定时器
|
|
|
onBeforeUnmount(() => {
|
|
|
- const timer = searchTimer
|
|
|
- if (timer != null) {
|
|
|
- clearTimeout(timer)
|
|
|
- }
|
|
|
- searchTimer = null
|
|
|
+
|
|
|
})
|
|
|
</script>
|
|
|
|