فهرست منبع

[Fix 0000]历史分析记录下拉框bug修复

bobo04052021@163.com 23 ساعت پیش
والد
کامیت
c454079243
1فایلهای تغییر یافته به همراه46 افزوده شده و 5 حذف شده
  1. 46 5
      src/views/vent/home/configurable/components/belt/historyModal.vue

+ 46 - 5
src/views/vent/home/configurable/components/belt/historyModal.vue

@@ -17,7 +17,7 @@
 </template>
 
 <script lang="ts" name="HistoryModal" setup>
-import { watch, ref, defineExpose } from 'vue';
+import { watch, ref, defineExpose, onMounted, computed } from 'vue';
 import { BasicTable } from '/@/components/Table';
 import { useListPage } from '/@/hooks/system/useListPage';
 import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
@@ -32,11 +32,12 @@ const list = (params) =>
     params,
   });
 const vehicleList = (params) => {
-  defHttp.get({
+  return defHttp.get({
     url: '/ventanaly-device/safety/deviceVehiclePass/list',
     params,
   });
 };
+
 // 接收 v-model
 const props = defineProps({
   modelValue: {
@@ -65,6 +66,23 @@ const handlerHistory = ref();
 const columns = ref([]);
 const tableScroll = props.scroll.y ? ref({ y: props.scroll.y - 100 }) : ref({});
 
+// 设备下拉选项
+const deviceOptions = ref([]);
+
+// 获取设备列表并赋值给下拉框
+async function getDeviceList() {
+  try {
+    const res = await vehicleList({ pageNo: 1, pageSize: 999 });
+    console.log('设备列表', res);
+    deviceOptions.value = res.records.map((item) => ({
+      label: item.deviceName,
+      value: item.deviceId,
+    }));
+  } catch (err) {
+    console.error('获取设备失败', err);
+  }
+}
+
 watch(
   () => props.columnsType,
   (newVal) => {
@@ -112,6 +130,16 @@ watch(
   }
 );
 
+// 打开弹窗时重新加载设备列表
+watch(
+  () => props.modelValue,
+  (val) => {
+    if (val) {
+      getDeviceList();
+    }
+  }
+);
+
 const { tableContext } = useListPage({
   tableProps: {
     api: list,
@@ -136,12 +164,21 @@ const { tableContext } = useListPage({
       },
       schemas: [
         {
-          label: '设备名称',
+          label: '查询设备',
           field: 'deviceId',
           component: 'Select',
-          required: true,
-          defaultValue: '1722081013462003713',
+          defaultValue: computed(() => {
+            if (deviceOptions.value.length > 0) {
+              return deviceOptions.value[0].value;
+            }
+            return props.deviceId || '';
+          }),
           componentProps: {
+            showSearch: true,
+            options: computed(() => deviceOptions.value),
+            filterOption: (input: string, option: any) => {
+              return option.label.toLowerCase().includes(input.toLowerCase());
+            },
             placeholder: '请选择设备',
           },
           colProps: { span: 8 },
@@ -188,6 +225,10 @@ const { tableContext } = useListPage({
 
 const [registerTable, { reload, setLoading }] = tableContext;
 defineExpose({ setLoading });
+
+onMounted(() => {
+  getDeviceList();
+});
 </script>
 
 <style scoped lang="less">