Просмотр исходного кода

更新 首页数据筛选逻辑

wzh 3 лет назад
Родитель
Сommit
38e847949a
2 измененных файлов с 34 добавлено и 8 удалено
  1. 5 0
      src/apis/fetch.js
  2. 29 8
      src/views/index/Index.vue

+ 5 - 0
src/apis/fetch.js

@@ -206,4 +206,9 @@ export default {
   getIndexData(data) {
     return $http("/pc/index", data);
   },
+
+  // 获取首页select
+  getIndexSelect(data) {
+    return $http("/pc/index/select", data);
+  },
 };

+ 29 - 8
src/views/index/Index.vue

@@ -100,12 +100,11 @@
               placeholder="装货港"
               size="small"
               @change="getIndexData(1)"
-              @focus="getPortSelect"
               filterable
               clearable
             >
               <el-option
-                v-for="item in portOptions"
+                v-for="item in loadPortOptions"
                 :key="item"
                 :label="item.value"
                 :value="item.key"
@@ -120,12 +119,11 @@
               placeholder="卸货港"
               size="small"
               @change="getIndexData(1)"
-              @focus="getPortSelect"
               filterable
               clearable
             >
               <el-option
-                v-for="item in portOptions"
+                v-for="item in discPortOptions"
                 :key="item"
                 :label="item.value"
                 :value="item.key"
@@ -166,7 +164,6 @@
               placeholder="货种"
               size="small"
               @change="getIndexData(1)"
-              @focus="getCargoSelect"
               filterable
               clearable
             >
@@ -352,6 +349,14 @@ function drawMarkers() {
 let status = ref(3);
 function changeVoyageType(s) {
   status.value = s;
+  postData.value = {
+    loadPortId: "",
+    discPortId: "",
+    isArrived: "",
+    abnormalStatus: "",
+    cargoId: "",
+  };
+  getIndexSelect();
   getIndexData();
 }
 
@@ -478,6 +483,9 @@ async function getPortSelect() {
   portOptions.value = res.data.result;
 }
 
+let loadPortOptions = ref([]);
+let discPortOptions = ref([]);
+
 let cargoOptions = ref([]);
 async function getCargoSelect() {
   if (cargoOptions.value.length) return;
@@ -593,7 +601,6 @@ async function exportZip() {
 
 function resetFilter() {
   postData.value = {
-    status: 0,
     loadPortId: "",
     discPortId: "",
     isArrived: "",
@@ -602,10 +609,24 @@ function resetFilter() {
   };
   getIndexData();
 }
+
+async function getIndexSelect() {
+  let res = await api.getIndexSelect({
+    status: status.value,
+  });
+  if (res.data.status == 0) {
+    loadPortOptions.value = res.data.result.loadPortSelect;
+    discPortOptions.value = res.data.result.discPortSelect;
+    cargoOptions.value = res.data.result.cargoSelect;
+  } else {
+    loadPortOptions.value = [];
+    discPortOptions.value = [];
+    cargoOptions.value = [];
+  }
+}
 onMounted(() => {
-  getPortSelect();
-  getCargoSelect();
   getIndexData("init");
+  getIndexSelect();
 });
 </script>