Selaa lähdekoodia

修改商品信息

huangbin 4 vuotta sitten
vanhempi
commit
bad9a9b129

+ 12 - 11
src/common/setup/table/button.ts

@@ -1,7 +1,7 @@
 import { ModalName } from '@/common/constants/modalName';
 import { OperationTabMenu } from '@/services/go/commonService/interface';
 import { sessionStorageUtil } from "@/utils/storage";
-import { inject, onUnmounted, ref, Ref } from 'vue';
+import { inject, ref, Ref, toRaw, unref } from 'vue';
 import { openModal } from "../modal";
 import { BtnClassName, BtnList, ButtonListKey } from './interface';
 
@@ -24,6 +24,16 @@ function getClassName(val: string): BtnClassName {
     return result
 }
 
+export function getThirdMenuData(): OperationTabMenu[] {
+    const permissionData = inject('thirdMenuList') as Ref<OperationTabMenu[]>;
+    const temp = unref(permissionData)
+    const name = 'permissionData'
+    // 存入sessionStorageUtil 是为了处理页面刷新的情况(这个时候重新从服务获取数据,但页面已经先加载了,vue 中的 依赖注入在异步中不能建立通信)
+    const data: OperationTabMenu[] = temp.length ? toRaw(temp) : sessionStorageUtil.getItem(name)
+    sessionStorageUtil.setItem(name, data)
+    return data;
+}
+
 /**
  * 获取表格操作按钮列表
  * @param menuType 
@@ -32,12 +42,7 @@ function getClassName(val: string): BtnClassName {
  */
 export function getBtnList(menuType: keyof ButtonListKey, hasDetail: boolean) {
     // 获取 数据
-    const permissionData = inject('thirdMenuList') as Ref<OperationTabMenu[]>;
-    const name = 'permissionData'
-    // 存入sessionStorageUtil 是为了处理页面刷新的情况(这个时候重新从服务获取数据,但页面已经先加载了,vue 中的 依赖注入在异步中不能建立通信)
-    const data: OperationTabMenu[] = permissionData.value.length ? permissionData.value : sessionStorageUtil.getItem(name) ? sessionStorageUtil.getItem(name) : []
-    sessionStorageUtil.setItem(name, data)
-
+    const data = getThirdMenuData()
     const commonBtn = ref<BtnList[]>([]); // 通用按钮列表,不用选中数据才显示
     const forDataBtn = ref<BtnList[]>([]); // 针对数据按钮列表,选中某条数据才显示
 
@@ -64,9 +69,5 @@ export function getBtnList(menuType: keyof ButtonListKey, hasDetail: boolean) {
         const { openAction } = openModal('detail')
         forDataBtn.value.push({ lable: '详情', callback: openAction, className: getClassName('') })
     }
-
-    onUnmounted(() => {
-        sessionStorageUtil.removeItem(name)
-    });
     return { commonBtn, forDataBtn }
 }

+ 3 - 0
src/common/setup/table/interface.ts

@@ -21,6 +21,9 @@ export interface ButtonListKey {
     spot_contract_performance: string; // 现货合同 履约中
     spot_contract_finished: string; // 现货合同 已完成
 
+    goods_info_spot_normal: string; // 现货品种 正常
+    goods_info_spot_disable: string; // 现货品种 停用
+
     warehouse_info_normal: string; // 仓库信息 正常
     warehouse_info_disabled: string; // 仓库信息 停用
 

+ 4 - 4
src/services/index.ts

@@ -1,6 +1,6 @@
-import { funCode } from '@/services/funcode/index';
 import { checkTokenLoop } from '@/services/bus/token';
 import { NeedClearSourceDataType, NoClearSourceDataType } from '@/services/dataCenter/interface';
+import { funCode } from '@/services/funcode/index';
 import { serviceURL } from '@/services/request/index';
 import timerUtil from '@/utils/timer/timerUtil';
 import { Callback, MTP2WebSocket, ReconnectChangeState } from '@/utils/websocket/index';
@@ -29,10 +29,10 @@ export default new (class LifeCycleCtr {
         trade: new MTP2WebSocket<Package50>(1),
     };
 
-    constructor() {}
+    constructor() { }
 
     /** 数据中心初始化 */
-    initDataCenter(): void {}
+    initDataCenter(): void { }
 
     /**
      * 从数据中心获取普通数据
@@ -137,7 +137,7 @@ export default new (class LifeCycleCtr {
     closeServer(): void {
         this.Socket['trade'].close();
         this.dataCenter.reset();
-        sessionStorage.clear();
+        // sessionStorage.clear();
         // localStorageUtil.removeItem('loginData');
         timerUtil.clearAll();
     }

+ 1 - 1
src/utils/storage/sessionStorage.ts

@@ -1,4 +1,4 @@
-import { toBase64, parseBase64 } from './base64/index';
+import { parseBase64, toBase64 } from './base64/index';
 
 /**
  * 封装LocalStorage,做了 JSON序列化, URI 组件编码,base-64编码 处理

+ 163 - 0
src/views/information/goods/components/disable/index.vue

@@ -0,0 +1,163 @@
+<template>
+  <!-- 停用客户资料-->
+  <a-modal class="commonModal warehouse-disable"
+           title="停用客户资料"
+           v-model:visible="visible"
+           centered
+           :maskClosable="maskClosableFlag"
+           @cancel="cancel"
+           width="890px">
+    <template #footer>
+      <a-button key="submit"
+                class="cancelBtn"
+                @click="cancel">取消</a-button>
+      <a-button key="submit"
+                type="primary"
+                :loading="loading"
+                @click="submit">确认停用</a-button>
+    </template>
+    <a-form class="inlineForm"
+            :form="form"
+            @submit="handleSearch">
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="客户类型">
+            <span class="white">{{ selectedRow.userinfotype === '2' ? '企业' : '个人' }}</span>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="企业名称">
+            <span class="white">{{ formatValue(selectedRow.customername) }}</span>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="企业简称">
+            <span class="white">{{ formatValue(selectedRow.nickname) }}</span>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="证件类型">
+            <span class="white">{{ formatValue(selectedRow.cardtypename) }}</span>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="法定代表人">
+            <span class="white">{{ formatValue(selectedRow.legalpersonname) }}</span>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="证件号码">
+            <span class="white">{{ formatValue(selectedRow.cardnum) }}</span>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="纳税人识别号">
+            <span class="white">{{ formatValue(selectedRow.taxpayernum) }}</span>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="营业执照">
+            <a class="blue">查看附件</a>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="联系人">
+            <span class="white">{{ formatValue(selectedRow.contactname) }}</span>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="联系人手机号">
+            <span class="white">{{ formatValue(selectedRow.mobile) }}</span>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="联系电话">
+            <span class="white">{{ formatValue(selectedRow.telphone) }}</span>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="状态">
+            <span class="green">{{ formatValue(getStatusName(selectedRow.status)) }}</span>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="24">
+          <a-form-item label="通讯地址">
+            <span class="white">{{ formatValue(selectedRow.address) }}</span>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="24">
+          <a-form-item label="备注">
+            <span class="white">{{ formatValue(selectedRow.remark) }}</span>
+          </a-form-item>
+        </a-col>
+      </a-row>
+    </a-form>
+  </a-modal>
+</template>
+
+<script lang="ts">
+import {defineComponent, PropType, ref} from 'vue';
+import { closeModal } from '@/common/setup/modal/index';
+import {updateUserAccount} from "@/views/information/custom/compoments/setup";
+import {QueryCustomInfoType} from "@/services/go/ermcp/customInfo/interface";
+import {formatValue} from "@/common/methods";
+import {getStatusName} from "@/views/information/custom/setup";
+import {Modal} from "ant-design-vue";
+
+export default defineComponent({
+    name: 'custom-disable',
+    components: {},
+    props: {
+        selectedRow: {
+            type: Object as PropType<QueryCustomInfoType>,
+            default: {},
+        },
+    },
+    setup(props) {
+        const { visible, cancel } = closeModal('custom_info_btn_disable');
+        const maskClosableFlag = ref<boolean>(false);
+        const  {loading, ModifyUserInfo} = updateUserAccount();
+        function submit() {
+            Modal.confirm({
+                title: '是否确认停用客户资料',
+                okText: '确认停用',
+                cancelText: '取消',
+                onOk() {
+                    ModifyUserInfo(props.selectedRow.userid, 6, cancel);
+                },
+                onCancel() {
+                    console.log('Cancel');
+                },
+            });
+        }
+        return {
+            visible,
+            cancel,
+            submit,
+            loading,
+            maskClosableFlag,
+            formatValue,
+            getStatusName,
+        };
+    },
+});
+</script>
+
+<style lang="less">
+.warehouse-disable {
+}
+</style>

+ 4 - 14
src/views/information/goods/components/leftMenu/index.vue

@@ -33,22 +33,13 @@ const handleMenu = (context: SetupContext) => {
     const collapsed = ref<boolean>(false);
     const selectedKeys = ref<string[]>(['1-0']);
     const openKeys = ref<string[]>(['1']);
-    const preOpenKeys = ref<string[]>(['1']);
-
-    // 控制菜单是否隐藏
-    function collapse(collapsed: boolean) {
-        if (collapsed) {
-            preOpenKeys.value = openKeys.value;
-            openKeys.value = [];
-        } else {
-            openKeys.value = preOpenKeys.value;
-        }
-    }
 
     function menuClick(value: any) {
+        console.log('value', value);
+
         context.emit('chooseMenu', value.key);
     }
-    return { collapsed, selectedKeys, openKeys, collapse, menuClick };
+    return { collapsed, selectedKeys, openKeys, menuClick };
 };
 
 export default defineComponent({
@@ -61,12 +52,11 @@ export default defineComponent({
     },
     components: {},
     setup(props, context) {
-        const { collapsed, selectedKeys, openKeys, collapse, menuClick } = handleMenu(context);
+        const { collapsed, selectedKeys, openKeys, menuClick } = handleMenu(context);
 
         return {
             menuClick,
             collapsed,
-            collapse,
             selectedKeys,
             openKeys,
         };

+ 256 - 0
src/views/information/goods/components/modify/index.vue

@@ -0,0 +1,256 @@
+<template>
+  <!-- 修改客户资料 -->
+  <a-modal class="commonModal modify-custom"
+           title="修改客户资料"
+           v-if="visible"
+           v-model:visible="visible"
+           centered
+           :maskClosable="maskClosableFlag"
+           @cancel="cancel"
+           width="890px">
+    <template #footer>
+      <a-button key="submit"
+                type="primary"
+                :loading="loading"
+                @click="submit">完成</a-button>
+    </template>
+    <a-form class="inlineForm"
+            :form="form"
+            @submit="handleSearch">
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="客户类型">
+            <a-select class="typeSelect"
+                      style="width: 200px"
+                      placeholder="请选择客户类型">
+              <a-select-option value="1">
+                客户一
+              </a-select-option>
+              <a-select-option value="2">
+                客户二
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="企业名称">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     placeholder="请输入企业名称" />
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="企业简称">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     placeholder="请输入企业简称" />
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="证件类型">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      placeholder="请选择证件类型">
+              <a-select-option value="1">
+                客户一
+              </a-select-option>
+              <a-select-option value="2">
+                客户二
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="法定代表人">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     placeholder="请输入法定代表人" />
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="证件号码">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     placeholder="请输入证件号码" />
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="纳税人识别号">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     placeholder="请输入纳税人识别号" />
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="营业执照">
+            <div class="upload">
+              <a-upload action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
+                        :transform-file="transformFile">
+                <a-button class="uploadBtn">上传</a-button>
+              </a-upload>
+              <div class="look">查看附件</div>
+            </div>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="联系人">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     placeholder="请输入联系人" />
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="联系人手机号">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     placeholder="请输入联系人手机号" />
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="联系电话">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     placeholder="请输入联系电话" />
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item>
+            &nbsp;
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="24">
+          <a-form-item label="通讯地址">
+            <a-select class="inlineFormSelect"
+                      style="width: 205px"
+                      placeholder="请选择省">
+              <a-select-option value="1">
+                客户一
+              </a-select-option>
+              <a-select-option value="2">
+                客户二
+              </a-select-option>
+            </a-select>
+            <a-select class="inlineFormSelect"
+                      style="width: 205px"
+                      placeholder="请选择市">
+              <a-select-option value="1">
+                客户一
+              </a-select-option>
+              <a-select-option value="2">
+                客户二
+              </a-select-option>
+            </a-select>
+            <a-select class="inlineFormSelect"
+                      style="width: 205px"
+                      placeholder="请选择县(区)">
+              <a-select-option value="1">
+                客户一
+              </a-select-option>
+              <a-select-option value="2">
+                客户二
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="24">
+          <a-form-item label="&nbsp;">
+            <a-input class="dialogInput"
+                     style="width: 635px"
+                     placeholder="请输入详细地址" />
+          </a-form-item>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24">
+        <a-col :span="24">
+          <a-form-item label="备注">
+            <a-input class="dialogInput"
+                     style="width: 635px"
+                     placeholder="请输入备注" />
+          </a-form-item>
+        </a-col>
+      </a-row>
+    </a-form>
+  </a-modal>
+</template>
+
+<script lang="ts">
+import { defineComponent, ref } from 'vue';
+import { closeModal } from '@/common/setup/modal/index';
+import { initData } from '@/common/methods/index';
+
+export default defineComponent({
+    name: 'modify-custom',
+    components: {},
+    props: {
+        // selectedRow: {
+        //   type:
+        // }
+    },
+    setup() {
+        // const { visible, cancel } = closeModal('modifyCustomInfo');
+        const { visible, cancel } = closeModal('custom_info_btn_modify');
+
+        const loading = ref<boolean>(false);
+        const maskClosableFlag = ref<boolean>(false);
+        function submit() {
+            loading.value = true;
+            setTimeout(() => {
+                loading.value = false;
+                cancel();
+            }, 2000);
+        }
+        initData(() => {});
+        return {
+            visible,
+            cancel,
+            submit,
+            loading,
+            maskClosableFlag,
+        };
+    },
+});
+</script>
+
+<style lang="less">
+.modify-custom {
+    .upload {
+        display: inline-flex;
+        .ant-btn.uploadBtn {
+            width: 60px;
+            height: 30px;
+            background: @m-blue0;
+            border: 0;
+            padding: 0;
+            text-align: center;
+            font-size: 14px;
+            color: @m-white0;
+            .rounded-corners(3px);
+            &:hover {
+                background: rgba(@m-blue0, 0);
+                color: rgba(@m-white0, 0.8);
+            }
+        }
+        .look {
+            color: @m-blue0;
+            font-size: 14px;
+            margin-left: 10px;
+            cursor: pointer;
+        }
+    }
+}
+</style
+>;

+ 165 - 0
src/views/information/goods/components/recover/index.vue

@@ -0,0 +1,165 @@
+<template>
+    <!-- 恢复客户资料-->
+    <a-modal class="modify-custom"
+             title="恢复客户资料"
+             v-model:visible="visible"
+             @cancel="cancel"
+             width="890px">
+        <template #footer>
+            <a-button key="submit"
+                      class="cancelBtn"
+                      @click="cancel">取消
+            </a-button>
+            <a-button key="submit"
+                      type="primary"
+                      :loading="loading"
+                      @click="recover">完成
+            </a-button>
+        </template>
+        <a-form class="inlineForm"
+                :form="form"
+                @submit="handleSearch">
+            <a-row :gutter="24">
+                <a-col :span="12">
+                    <a-form-item label="客户类型">
+                        <span class="white">{{ selectedRow.userinfotype === '2' ? '企业' : '个人' }}</span>
+                    </a-form-item>
+                </a-col>
+                <a-col :span="12">
+                    <a-form-item label="企业名称">
+                        <span class="white">{{ formatValue(selectedRow.customername) }}</span>
+                    </a-form-item>
+                </a-col>
+            </a-row>
+            <a-row :gutter="24">
+                <a-col :span="12">
+                    <a-form-item label="企业简称">
+                        <span class="white">{{ formatValue(selectedRow.nickname) }}</span>
+                    </a-form-item>
+                </a-col>
+                <a-col :span="12">
+                    <a-form-item label="证件类型">
+                        <span class="white">{{ formatValue(selectedRow.cardtypename) }}</span>
+                    </a-form-item>
+                </a-col>
+            </a-row>
+            <a-row :gutter="24">
+                <a-col :span="12">
+                    <a-form-item label="法定代表人">
+                        <span class="white">{{ formatValue(selectedRow.legalpersonname) }}</span>
+                    </a-form-item>
+                </a-col>
+                <a-col :span="12">
+                    <a-form-item label="证件号码">
+                        <span class="white">{{ formatValue(selectedRow.cardnum) }}</span>
+                    </a-form-item>
+                </a-col>
+            </a-row>
+            <a-row :gutter="24">
+                <a-col :span="12">
+                    <a-form-item label="纳税人识别号">
+                        <span class="white">{{ formatValue(selectedRow.taxpayernum) }}</span>
+                    </a-form-item>
+                </a-col>
+                <a-col :span="12">
+                    <a-form-item label="营业执照">
+                        <div class="upload">
+                            <div class="look">查看附件</div>
+                        </div>
+                    </a-form-item>
+                </a-col>
+            </a-row>
+            <a-row :gutter="24">
+                <a-col :span="12">
+                    <a-form-item label="联系人">
+                        <span class="white">{{ formatValue(selectedRow.contactname) }}</span>
+                    </a-form-item>
+                </a-col>
+                <a-col :span="12">
+                    <a-form-item label="联系人手机号">
+                        <span class="white">{{ formatValue(selectedRow.mobile) }}</span>
+                    </a-form-item>
+                </a-col>
+            </a-row>
+            <a-row :gutter="24">
+                <a-col :span="12">
+                    <a-form-item label="联系电话">
+                        <span class="white">{{ formatValue(selectedRow.telphone) }}</span>
+                    </a-form-item>
+                </a-col>
+                <a-col :span="12">
+                    <a-form-item label="状态">
+                        <span class="green">{{ formatValue(getStatusName(selectedRow.status)) }}</span>
+                    </a-form-item>
+                </a-col>
+            </a-row>
+            <a-row :gutter="24">
+                <a-col :span="24">
+                    <a-form-item label="通讯地址">
+                        <span class="white">{{ formatValue(selectedRow.address) }}</span>
+                    </a-form-item>
+                </a-col>
+            </a-row>
+            <a-row :gutter="24">
+                <a-col :span="24">
+                    <a-form-item label="备注">
+                        <span class="white">{{ formatValue(selectedRow.remark) }}</span>
+                    </a-form-item>
+                </a-col>
+            </a-row>
+        </a-form>
+    </a-modal>
+</template>
+
+<script lang="ts">
+import {defineComponent, PropType, ref} from 'vue';
+import {closeModal} from '@/common/setup/modal/index';
+import {QueryCustomInfoType} from "@/services/go/ermcp/customInfo/interface";
+import {formatValue} from "@/common/methods";
+import {getStatusName} from "@/views/information/custom/setup";
+import {updateUserAccount} from "@/views/information/custom/compoments/setup";
+import {Modal} from "ant-design-vue";
+
+export default defineComponent({
+    name: 'modify-custom',
+    components: {},
+    props: {
+        selectedRow: {
+            type: Object as PropType<QueryCustomInfoType>,
+            default: {},
+        },
+    },
+    setup(props) {
+        const {visible, cancel} = closeModal('custom_info_btn_recover');
+        const {loading, ModifyUserInfo} = updateUserAccount();
+        // 恢复方法
+        function recover(){
+            Modal.confirm({
+                title: '是否确认恢复客户资料',
+                okText: '确认恢复',
+                cancelText: '取消',
+                onOk() {
+                    ModifyUserInfo(props.selectedRow.userid, 4, cancel);
+                },
+                onCancel() {
+                    console.log('Cancel');
+                },
+            });
+        }
+        return {
+            visible,
+            cancel,
+            recover,
+            loading,
+            formatValue,
+            getStatusName,
+        };
+    },
+});
+</script>
+
+<style lang="less">
+.modify-custom {
+}
+</style
+>;

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

@@ -21,7 +21,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';
@@ -29,7 +29,8 @@ import rightSpot from '@/views/information/goods/components/rightSpot/index.vue'
 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 { handleDG, handleGDStatue } from '../../setup';
+import { getThirdMenuData } from '@/common/setup/table/button';
 
 export default defineComponent({
     name: 'spot-variety',
@@ -40,8 +41,10 @@ export default defineComponent({
         AddGoods,
     },
     setup() {
+        // 控制弹窗
         const { openAction: addAction } = openModal('spot_contract_btn_add');
         const { loading, selctedDeliveryGoods, chooseDG, menuList, queryDG } = handleDG();
+        const { isNormal, changeStatue } = handleGDStatue();
 
         initData(() => {
             // 加载数据在这里

+ 52 - 5
src/views/information/goods/setup.ts

@@ -1,9 +1,10 @@
+import { getThirdMenuData } from '@/common/setup/table/button';
 import { getItemEnum } from '@/services/bus/allEnum';
 import { QueryDeliveryGoodsDetail } from '@/services/go/ermcp/goodsInfo';
 import { ErmcpDeliveryGoodsDetailEx, MenuList } from '@/services/go/ermcp/goodsInfo/interface';
 import { mergeObj } from '@/utils/objHandle';
 import { message } from 'ant-design-vue';
-import { reactive, ref } from 'vue';
+import { reactive, Ref, ref } from 'vue';
 
 /**
  * 初始化 现货品种对象数据
@@ -46,17 +47,41 @@ export function initMenu(): MenuList[] {
     ]
 }
 
+interface MenuType {
+    menuList: Ref<MenuList[]>;
+    menuMap: Map<string, number>;
+}
+/**
+ * 获取菜单数据
+ * @returns MenuType
+ */
+function getInitMenuData(): MenuType {
+    const list = getThirdMenuData();
+    const obj = list.find(e => e.code === 'goods_info_spot'); // 现货品种 数据
+    const menuMap = new Map<string, number>();  // key 正常和停用对应的code,value是它们所在的索引值
+    const menuList = ref<MenuList[]>([])
+    if (obj && obj.children) {
+        obj.children.forEach((e, i) => {
+            const { code, title } = e;
+            menuMap.set(code, i)
+            menuList.value.push({ key: code, title, children: [] })
+        })
+    }
+    return { menuList, menuMap }
+}
+
 /**
  * 获取现货品种数据
  * @returns 
  */
 export function handleDG() {
+    const { menuList, menuMap } = getInitMenuData()
     const loading = ref<boolean>(false);
     // 现货品种列表
     const deliveryGoodsList = ref<ErmcpDeliveryGoodsDetailEx[]>([])
     // 选中的具体某一天现货品种数据
     const selctedDeliveryGoods = reactive<ErmcpDeliveryGoodsDetailEx>(initDG())
-    const menuList = ref<MenuList[]>(initMenu());
+    // const menuList = ref<MenuList[]>(initMenu());
     // 获取现货品种数据
     function queryDG(param?: number) {
         loading.value = true;
@@ -65,9 +90,19 @@ export function handleDG() {
             res.forEach(e => {
                 const { dgstatus, isvalid, deliverygoodsname, deliverygoodsid } = e.data
                 if (isvalid) { // 有效 
-                    const index = dgstatus ? 0 : 1; // 0:未激活 1:正常
-                    const obj = { key: deliverygoodsid.toString(), title: deliverygoodsname }
-                    menuList.value[index].children?.push(obj)
+                    const normal = 'goods_info_spot_normal', disable = 'goods_info_spot_disable';
+                    const result = { key: deliverygoodsid.toString(), title: deliverygoodsname }
+                    if (dgstatus) { //1:正常
+                        if (menuMap.has(normal)) {
+                            const index = menuMap.get(normal) as number;
+                            menuList.value[index].children?.push(result)
+                        }
+                    } else {    // 0:未激活 
+                        if (menuMap.has(disable)) {
+                            const index = menuMap.get(disable) as number;
+                            menuList.value[index].children?.push(result)
+                        }
+                    }
                 }
             })
             // 获取默认第一条数据
@@ -105,4 +140,16 @@ export function getGoodsUnit(unit: number) {
  */
 export function getGoodsUnitList() {
     return getItemEnum('goodsunit')
+}
+
+/**
+ * 处理现货品种的状态
+ * @returns 
+ */
+export function handleGDStatue() {
+    const isNormal = ref<boolean>(true) // true => 正常; false => 停用
+    function changeStatue(value: boolean) {
+        isNormal.value = value;
+    }
+    return { isNormal, changeStatue }
 }