huangbin 4 years ago
parent
commit
f69485e618

+ 7 - 1
src/views/information/goods/components/filterTable/index.vue

@@ -18,9 +18,15 @@ export default defineComponent({
     components: {
         FilterOption,
     },
+    props: {
+        name: {
+            type: String,
+            default: '现货品种',
+        },
+    },
     setup(props, context) {
         const select: SelectList[] = [];
-        const input: InputList[] = [{ value: '', placeholder: '模糊搜索账户', key: 'nickname' }];
+        const input: InputList[] = [{ value: '', placeholder: `模糊搜索${props.name}`, key: 'nickname' }];
         return {
             ...handleFilter(select, input, context),
         };

+ 31 - 5
src/views/information/goods/list/hedging-variety/index.vue

@@ -2,11 +2,12 @@
   <!-- 套保品种 -->
   <div class="hedging-variety spot-variety"
        :loading="loading">
-    <filterCustomTable @search="search">
+    <filterCustomTable @search="search"
+                       :name="'套保品种'">
     </filterCustomTable>
     <div class="spotTableCont">
       <div class="leftSpot">
-        <leftMenu :menuList="menuList"
+        <leftMenu :menuList="filterMenu()"
                   :path="'goods_info_hedge_normal'"
                   @chooseMenu="chooseDG"></leftMenu>
       </div>
@@ -21,7 +22,7 @@
 </template>
 
 <script lang="ts">
-import { defineComponent } from 'vue';
+import { defineComponent, ref } from 'vue';
 import filterCustomTable from '@/views/information/goods/components/filterTable/index.vue';
 import leftMenu from '@/views/information/goods/components/leftMenu/index.vue';
 import RightHedging from '../../components/rightHedging/index.vue';
@@ -29,6 +30,7 @@ import { openModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods/index';
 import AddGoods from '@/views/information/goods/components/add/index.vue';
 import { handleMG } from './setup';
+import { MenuList } from '@/services/go/ermcp/goodsInfo/interface';
 
 export default defineComponent({
     name: 'hedging-variety',
@@ -40,12 +42,36 @@ export default defineComponent({
     },
     setup() {
         const { loading, menuList, isNormal, selctedMG, queryMG, chooseDG, updateDG } = handleMG();
-
+        const cacheSearch = ref<string>('');
+        function filterMenu() {
+            if (cacheSearch.value) {
+                const result: MenuList[] = [];
+                menuList.value.forEach((el, i) => {
+                    const children: MenuList[] = [];
+                    el.children?.forEach((e) => {
+                        if (e.title.includes(cacheSearch.value)) {
+                            children.push(e);
+                        }
+                    });
+                    result.push({ key: el.key, title: el.title, children });
+                });
+                return result;
+            } else {
+                return menuList.value;
+            }
+        }
+        function search(value: any) {
+            if (value && value.nickname && value.nickname.length) {
+                cacheSearch.value = value.nickname[0];
+            } else {
+                cacheSearch.value = '';
+            }
+        }
         initData(() => {
             // 加载数据在这里
             queryMG();
         });
-        return { loading, selctedMG, chooseDG, isNormal, menuList, updateDG };
+        return { loading, selctedMG, chooseDG, isNormal, menuList, updateDG, search, filterMenu };
     },
 });
 </script>

+ 31 - 5
src/views/information/goods/list/spot-variety/index.vue

@@ -2,14 +2,15 @@
   <!-- 现货品种 -->
   <div class="spot-variety"
        :loading="loading">
-    <filterCustomTable @search="search">
+    <filterCustomTable @search="search"
+                       :name="'现货品种'">
       <a-button class="operBtn"
                 v-if="isNormal"
                 @click="addAction">新增</a-button>
     </filterCustomTable>
     <div class="spotTableCont">
       <div class="leftSpot">
-        <leftMenu :menuList="menuList"
+        <leftMenu :menuList="filterMenu()"
                   :path="'goods_info_spot_normal'"
                   @chooseMenu="chooseDG"></leftMenu>
       </div>
@@ -26,7 +27,7 @@
 </template>
 
 <script lang="ts">
-import { defineComponent } from 'vue';
+import { defineComponent, ref } from 'vue';
 import filterCustomTable from '@/views/information/goods/components/filterTable/index.vue';
 import leftMenu from '@/views/information/goods/components/leftMenu/index.vue';
 import rightSpot from '@/views/information/goods/components/rightSpot/index.vue';
@@ -34,6 +35,7 @@ import { openModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods/index';
 import AddGoods from '@/views/information/goods/components/add/index.vue';
 import { handleDG } from './setup';
+import { MenuList } from '@/services/go/ermcp/goodsInfo/interface';
 
 export default defineComponent({
     name: 'spot-variety',
@@ -47,12 +49,36 @@ export default defineComponent({
         // 控制弹窗
         const { openAction: addAction } = openModal('goods_info_spot_normal_add');
         const { loading, selctedDeliveryGoods, chooseDG, isNormal, menuList, queryDG, updateDG } = handleDG();
-
+        const cacheSearch = ref<string>('');
+        function filterMenu() {
+            if (cacheSearch.value) {
+                const result: MenuList[] = [];
+                menuList.value.forEach((el, i) => {
+                    const children: MenuList[] = [];
+                    el.children?.forEach((e) => {
+                        if (e.title.includes(cacheSearch.value)) {
+                            children.push(e);
+                        }
+                    });
+                    result.push({ key: el.key, title: el.title, children });
+                });
+                return result;
+            } else {
+                return menuList.value;
+            }
+        }
+        function search(value: any) {
+            if (value && value.nickname && value.nickname.length) {
+                cacheSearch.value = value.nickname[0];
+            } else {
+                cacheSearch.value = '';
+            }
+        }
         initData(() => {
             // 加载数据在这里
             queryDG();
         });
-        return { addAction, loading, selctedDeliveryGoods, chooseDG, isNormal, menuList, updateDG };
+        return { addAction, loading, selctedDeliveryGoods, chooseDG, isNormal, menuList, updateDG, search, filterMenu };
     },
 });
 </script>

+ 3 - 3
src/views/information/goods/list/spot-variety/setup.ts

@@ -7,7 +7,7 @@ import { getInitMenuData } from '../../setup';
 
 /**
  * 初始化 现货品种对象数据
- * @returns 
+ * @returns
  */
 export function initDG(): ErmcpDeliveryGoodsDetailEx {
     return {
@@ -44,7 +44,7 @@ interface MenuType {
 
 /**
  * 获取现货品种数据
- * @returns 
+ * @returns
  */
 export function handleDG() {
     const { menuList, menuMap } = getInitMenuData('goods_info_spot')
@@ -71,7 +71,7 @@ export function handleDG() {
                     const index = menuMap.get(normal) as number;
                     menuList.value[index].children?.push(result)
                 }
-            } else {    // 0:未激活 
+            } else {    // 0:未激活
                 if (menuMap.has(disable)) {
                     const index = menuMap.get(disable) as number;
                     menuList.value[index].children?.push(result)