|
@@ -23,7 +23,7 @@
|
|
|
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" @click="refresh">查询</el-button>
|
|
|
- <el-button type="primary" plain @click="pageProps = initProps">
|
|
|
+ <el-button type="primary" plain @click="pageProps = { ...initProps }">
|
|
|
重置
|
|
|
</el-button>
|
|
|
<el-button type="primary" @click="addHandler"> 添加设备 </el-button>
|
|
@@ -74,7 +74,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { onActivated, ref, watchEffect } from "vue";
|
|
|
+import { onActivated, ref, watch } from "vue";
|
|
|
import {
|
|
|
devicePageFetch,
|
|
|
DevicePageProps,
|
|
@@ -85,6 +85,7 @@ import { Device } from "@/request/type";
|
|
|
import { DeviceTypeDesc } from "@/store/device";
|
|
|
import { ElMessageBox } from "element-plus";
|
|
|
import { deviceEdit } from "./quisk";
|
|
|
+import { debounce } from "@/util";
|
|
|
|
|
|
const initProps: DevicePageProps = {
|
|
|
pageNum: 1,
|
|
@@ -94,11 +95,11 @@ const pageProps = ref({ ...initProps });
|
|
|
const total = ref<number>(0);
|
|
|
const relicsArray = ref<Device[]>([]);
|
|
|
|
|
|
-const refresh = async () => {
|
|
|
+const refresh = debounce(async () => {
|
|
|
const data = await devicePageFetch(pageProps.value);
|
|
|
total.value = data.total;
|
|
|
relicsArray.value = data.records;
|
|
|
-};
|
|
|
+});
|
|
|
|
|
|
const delHandler = async (deviceId: number) => {
|
|
|
const ok = await ElMessageBox.confirm("确定要删除吗", {
|
|
@@ -115,7 +116,7 @@ const addHandler = async () => {
|
|
|
await refresh();
|
|
|
};
|
|
|
|
|
|
-watchEffect(refresh);
|
|
|
+watch(pageProps, refresh, { deep: true, immediate: true });
|
|
|
onActivated(refresh);
|
|
|
</script>
|
|
|
|