huangbin 4 gadi atpakaļ
vecāks
revīzija
84fa9054c3

+ 38 - 0
src/common/setup/matket/router.ts

@@ -0,0 +1,38 @@
+import { TabList } from '@/common/components/description/interface';
+import { EnumRouterName } from '@/common/constants/enumRouterName';
+import { initData } from '@/common/methods';
+import { getThirdMenuData } from '@/common/setup/table/button';
+import { ref } from 'vue';
+import { useRoute, useRouter } from 'vue-router';
+
+export function handleMartketThirdRouter(code: EnumRouterName) {
+    const list = getThirdMenuData();
+    const item = list.find((e) => e.code === code);
+    const tabList = item
+        ? item.children.map((e) => {
+            return { lable: e.title, code: e.code };
+        })
+        : [];
+    const router = useRouter();
+    const route = useRoute();
+    const index = ref<string>('0');
+    initData(() => {
+        if (tabList.length) {
+            const name = route.name as string;
+            const result = tabList.findIndex((e) => e.code === name);
+            // 处理页面刷新
+            if (result !== -1) {
+                router.push({ name });
+                index.value = result.toString();
+            } else {
+                router.push({ name: tabList[0].code });
+                index.value = '0';
+            }
+        }
+    });
+    // 切换tab 跳转路由
+    function changeTab(index: number, current: TabList) {
+        router.push({ name: current.code });
+    }
+    return { index, tabList, changeTab }
+}

+ 4 - 34
src/views/market/spot_trade/warehouse_pre_sale/index.vue

@@ -9,48 +9,18 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref } from 'vue';
-import { getThirdMenuData } from '@/common/setup/table/button';
-import { TabList } from '@/common/components/description/interface';
+import { defineComponent } from 'vue';
 import ThridMenu from '@/common/components/thirdMenu/index.vue';
-import { useRoute, useRouter } from 'vue-router';
-import { initData } from '@/common/methods';
 import { EnumRouterName } from '@/common/constants/enumRouterName';
+import { handleMartketThirdRouter } from '@/common/setup/matket/router';
 
 export default defineComponent({
-    name: EnumRouterName.warehouse_receipt_trade,
+    name: EnumRouterName.warehouse_pre_sale,
     components: {
         ThridMenu,
     },
     setup() {
-        const list = getThirdMenuData();
-        const item = list.find((e) => e.code === EnumRouterName.warehouse_receipt_trade);
-        const tabList = item
-            ? item.children.map((e) => {
-                  return { lable: e.title, code: e.code };
-              })
-            : [];
-        const router = useRouter();
-        const route = useRoute();
-        const index = ref<string>('0');
-        initData(() => {
-            if (tabList.length) {
-                const name = route.name as string;
-                const result = tabList.findIndex((e) => e.code === name);
-                // 处理页面刷新
-                if (result !== -1) {
-                    router.push({ name });
-                    index.value = result.toString();
-                } else {
-                    router.push({ name: tabList[0].code });
-                    index.value = '0';
-                }
-            }
-        });
-        function changeTab(index: number, current: TabList) {
-            router.push({ name: current.code });
-        }
-        return { tabList, changeTab, index };
+        return { ...handleMartketThirdRouter(EnumRouterName.warehouse_pre_sale) };
     },
 });
 </script>

+ 6 - 1
src/views/market/spot_trade/warehouse_pre_sale/warehouse_pre_sale_floating_price/index.vue

@@ -15,4 +15,9 @@ export default defineComponent({
         return {};
     },
 });
-</script>
+</script>
+<style lang="less">
+.warehouse_pre_sale_floating_price {
+    height: calc(100% - 28px);
+}
+</style>

+ 6 - 1
src/views/market/spot_trade/warehouse_pre_sale/warehouse_pre_sale_price/index.vue

@@ -15,4 +15,9 @@ export default defineComponent({
         return {};
     },
 });
-</script>
+</script>
+<style lang="less">
+.warehouse_pre_sale_price {
+    height: calc(100% - 28px);
+}
+</style>

+ 3 - 33
src/views/market/spot_trade/warehouse_receipt_trade/index.vue

@@ -9,13 +9,10 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref } from 'vue';
-import { getThirdMenuData } from '@/common/setup/table/button';
-import { TabList } from '@/common/components/description/interface';
+import { defineComponent } from 'vue';
 import ThridMenu from '@/common/components/thirdMenu/index.vue';
-import { useRoute, useRouter } from 'vue-router';
-import { initData } from '@/common/methods';
 import { EnumRouterName } from '@/common/constants/enumRouterName';
+import { handleMartketThirdRouter } from '@/common/setup/matket/router';
 
 export default defineComponent({
     name: EnumRouterName.warehouse_receipt_trade,
@@ -23,34 +20,7 @@ export default defineComponent({
         ThridMenu,
     },
     setup() {
-        const list = getThirdMenuData();
-        const item = list.find((e) => e.code === EnumRouterName.warehouse_receipt_trade);
-        const tabList = item
-            ? item.children.map((e) => {
-                  return { lable: e.title, code: e.code };
-              })
-            : [];
-        const router = useRouter();
-        const route = useRoute();
-        const index = ref<string>('0');
-        initData(() => {
-            if (tabList.length) {
-                const name = route.name as string;
-                const result = tabList.findIndex((e) => e.code === name);
-                // 处理页面刷新
-                if (result !== -1) {
-                    router.push({ name });
-                    index.value = result.toString();
-                } else {
-                    router.push({ name: tabList[0].code });
-                    index.value = '0';
-                }
-            }
-        });
-        function changeTab(index: number, current: TabList) {
-            router.push({ name: current.code });
-        }
-        return { tabList, changeTab, index };
+        return { ...handleMartketThirdRouter(EnumRouterName.warehouse_receipt_trade) };
     },
 });
 </script>