Explorar el Código

修改商品信息

huangbin hace 4 años
padre
commit
ed977fae8c

+ 1 - 1
src/services/go/ermcp/goodsInfo/interface.ts

@@ -102,7 +102,7 @@ export interface ErmcpDeliveryGoods {
 export interface Ermcp3MiddleGoodsDetail2 {
     convertratio: number  // 套保系数(折算系数)
     gplist: Ermcp3GoodsGroupEx[] // 关联商品组列表
-    mg: ErmcpMiddleGoodsModel[] // 套保品种
+    mg: ErmcpMiddleGoodsModel // 套保品种
 }
 
 /**

+ 5 - 5
src/services/request/serviceURL.ts

@@ -75,9 +75,9 @@ export const setServiceURL = (config: URL): void => {
     serviceURL = config;
 
     // 外网环境(175),外包同事使用
-    if (process.env.NODE_ENV === 'development') {
-        serviceURL.goCommonSearchUrl = 'http://218.17.158.45:21001/api';
-        serviceURL.quoteUrl = 'ws://218.17.158.45:21004';
-        serviceURL.tradeUrl = 'ws://218.17.158.45:21005';
-    }
+    // if (process.env.NODE_ENV === 'development') {
+    //     serviceURL.goCommonSearchUrl = 'http://218.17.158.45:21001/api';
+    //     serviceURL.quoteUrl = 'ws://218.17.158.45:21004';
+    //     serviceURL.tradeUrl = 'ws://218.17.158.45:21005';
+    // }
 };

+ 0 - 2
src/utils/objHandle/index.ts

@@ -11,9 +11,7 @@ interface ObjType {
  */
 export function mergeObj(a: ObjType, ...rest: ObjType[]): void {
     Object.keys(a).forEach((key) => {
-        debugger
         rest.forEach((param) => {
-            debugger
             if (Reflect.has(param, key)) {
                 a[key] = param[key];
             }

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

@@ -24,11 +24,11 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref, PropType } from 'vue';
+import { defineComponent, ref, PropType, SetupContext } from 'vue';
 import { MenuList } from '@/services/go/ermcp/goodsInfo/interface';
 
 // 菜单栏
-const handleMenu = () => {
+const handleMenu = (context: SetupContext) => {
     const collapsed = ref<boolean>(false);
     const selectedKeys = ref<string[]>(['1-0']);
     const openKeys = ref<string[]>(['1']);
@@ -45,7 +45,7 @@ const handleMenu = () => {
     }
 
     function menuClick(value: any) {
-        console.log(value);
+        context.emit('chooseMenu', value.key);
     }
     return { collapsed, selectedKeys, openKeys, collapse, menuClick };
 };
@@ -63,7 +63,7 @@ export default defineComponent({
     },
     components: {},
     setup(props, context) {
-        const { collapsed, selectedKeys, openKeys, collapse, menuClick } = handleMenu();
+        const { collapsed, selectedKeys, openKeys, collapse, menuClick } = handleMenu(context);
 
         return {
             menuClick,

+ 253 - 276
src/views/information/goods/components/rightSpot/index.vue

@@ -1,310 +1,287 @@
 <template>
-    <div class="rightSpot">
-        <div class="title">
-            <div class="tltLeft">
-                <span class="blue">
-                    <svg class="icon svg-icon" aria-hidden="true">
-                        <use xlink:href="#icon-shuzhuangtu"></use>
-                    </svg>
-                    铜杆(吨)
-                </span>
-                <span class="green ml10">正常</span>
-            </div>
-            <div class="tltBtns">
-                <a-button class="blueBtn">修改</a-button>
-                <a-button class="redBtn">停用</a-button>
-            </div>
-        </div>
-        <div class="spotCont">
-            <a-collapse class="spotCollapse" :bordered="false">
-                <template #expandIcon="props">
-                    <svg class="icon svg-icon" aria-hidden="true" v-if="props.isActive == 0">
-                        <use xlink:href="#icon-shouqi1"></use>
-                    </svg>
-                    <svg class="icon svg-icon" aria-hidden="true" v-else>
-                        <use xlink:href="#icon-shouqi2"></use>
-                    </svg>
+  <div class="rightSpot">
+    <div class="title">
+      <div class="tltLeft">
+        <span class="blue">
+          <svg class="icon svg-icon"
+               aria-hidden="true">
+            <use xlink:href="#icon-shuzhuangtu"></use>
+          </svg>
+          {{selctedDeliveryGoods.data.deliverygoodsname}}({{getGoodsUnit(selctedDeliveryGoods.data.agreeunit)}})
+        </span>
+        <span class="green ml10">{{selctedDeliveryGoods.data.dgstatus ? '正常' : '停用'}}</span>
+      </div>
+      <div class="tltBtns">
+        <a-button class="blueBtn">修改</a-button>
+        <a-button class="redBtn">停用</a-button>
+      </div>
+    </div>
+    <div class="spotCont">
+      <a-collapse class="spotCollapse"
+                  :bordered="false">
+        <template #expandIcon="props">
+          <svg class="icon svg-icon"
+               aria-hidden="true"
+               v-if="props.isActive == 0">
+            <use xlink:href="#icon-shouqi1"></use>
+          </svg>
+          <svg class="icon svg-icon"
+               aria-hidden="true"
+               v-else>
+            <use xlink:href="#icon-shouqi2"></use>
+          </svg>
+        </template>
+        <a-collapse-panel key="1">
+          <template #header>
+            <a-row class="headRow">
+              <a-col :span="8">品类({{selctedDeliveryGoods.gmlist.length}})</a-col>
+              <a-col :span="8">单位</a-col>
+              <a-col :span="8">标仓系数</a-col>
+            </a-row>
+          </template>
+          <a-row class="contRow"
+                 v-for="(item, i) in selctedDeliveryGoods.gmlist"
+                 :key="i + '11'">
+            <a-col :span="8">{{item.wrstandardname}}</a-col>
+            <a-col :span="8">{{item.enumdicname}}</a-col>
+            <a-col :span="8">{{item.convertfactor}}</a-col>
+          </a-row>
+        </a-collapse-panel>
+        <a-collapse-panel key="2">
+          <template #header>
+            <a-row class="headRow">
+              <a-col :span="24">品牌({{selctedDeliveryGoods.gblist.length}})</a-col>
+            </a-row>
+          </template>
+          <a-row class="contRow"
+                 v-for="(item, i) in selctedDeliveryGoods.gblist"
+                 :key="i + '22'">
+            <a-col :span="24">{{item.brandname}}</a-col>
+          </a-row>
+        </a-collapse-panel>
+        <a-collapse-panel key="3">
+          <template #header>
+            <a-row class="headRow">
+              <a-col :span="8">套保品种({{selctedDeliveryGoods.mgList.length}})</a-col>
+              <a-col :span="8">单位</a-col>
+              <a-col :span="8">套保系数</a-col>
+            </a-row>
+          </template>
+          <template v-for="(item, i) in selctedDeliveryGoods.mgList"
+                    :key="i + '33'">
+            <a-row class="contRow">
+              <a-col :span="8">{{item.mg.middlegoodsname}}</a-col>
+              <a-col :span="8">{{item.mg.enumdicname}}</a-col>
+              <a-col :span="8">{{item.convertratio}}</a-col>
+            </a-row>
+            <a-collapse default-active-key="4-0">
+              <template #expandIcon="props">
+                <svg class="icon svg-icon"
+                     aria-hidden="true"
+                     v-if="props.isActive == 0">
+                  <use xlink:href="#icon-shouqi1"></use>
+                </svg>
+                <svg class="icon svg-icon"
+                     aria-hidden="true"
+                     v-else>
+                  <use xlink:href="#icon-shouqi2"></use>
+                </svg>
+              </template>
+              <a-collapse-panel>
+                <template #header>
+                  <a-row class="headRow">
+                    <a-col :span="8">{{item.mg.relatedgoodstype === 1 ? '期货合约' : '期货品种'}}({{item.gplist.length}})</a-col>
+                    <a-col :span="8">单位</a-col>
+                    <a-col :span="8">品种系数</a-col>
+                  </a-row>
                 </template>
-                <a-collapse-panel key="1">
-                    <template #header>
-                        <a-row class="headRow">
-                            <a-col :span="8">品类(3)</a-col>
-                            <a-col :span="8">单位</a-col>
-                            <a-col :span="8">标仓系数</a-col>
-                        </a-row>
-                    </template>
-                    <a-row class="contRow">
-                        <a-col :span="8">10mm</a-col>
-                        <a-col :span="8">吨</a-col>
-                        <a-col :span="8">1.0</a-col>
-                    </a-row>
-                    <a-row class="contRow">
-                        <a-col :span="8">12mm</a-col>
-                        <a-col :span="8">吨</a-col>
-                        <a-col :span="8">1.1</a-col>
-                    </a-row>
-                    <a-row class="contRow">
-                        <a-col :span="8">15mm</a-col>
-                        <a-col :span="8">吨</a-col>
-                        <a-col :span="8">1.2</a-col>
-                    </a-row>
-                </a-collapse-panel>
-                <a-collapse-panel key="2">
-                    <template #header>
-                        <a-row class="headRow">
-                            <a-col :span="24">品牌(2)</a-col>
-                        </a-row>
-                    </template>
-                    <a-row class="contRow">
-                        <a-col :span="24">江铜</a-col>
-                    </a-row>
-                    <a-row class="contRow">
-                        <a-col :span="24">云铜</a-col>
-                    </a-row>
-                </a-collapse-panel>
-                <a-collapse-panel key="3">
-                    <template #header>
-                        <a-row class="headRow">
-                            <a-col :span="8">套保品种(2)</a-col>
-                            <a-col :span="8">单位</a-col>
-                            <a-col :span="8">套保系数</a-col>
-                        </a-row>
-                    </template>
-                    <a-row class="contRow">
-                        <a-col :span="8">江铜</a-col>
-                        <a-col :span="8">江铜</a-col>
-                        <a-col :span="8">江铜</a-col>
-                    </a-row>
-                    <a-collapse default-active-key="4">
-                        <template #expandIcon="props">
-                            <svg class="icon svg-icon" aria-hidden="true" v-if="props.isActive == 0">
-                                <use xlink:href="#icon-shouqi1"></use>
-                            </svg>
-                            <svg class="icon svg-icon" aria-hidden="true" v-else>
-                                <use xlink:href="#icon-shouqi2"></use>
-                            </svg>
-                        </template>
-                        <a-collapse-panel key="4">
-                            <template #header>
-                                <a-row class="headRow">
-                                    <a-col :span="8">期货品种(2)</a-col>
-                                    <a-col :span="8">单位</a-col>
-                                    <a-col :span="8">品种系数</a-col>
-                                </a-row>
-                            </template>
-                            <a-row class="contRow">
-                                <a-col :span="8">江铜</a-col>
-                                <a-col :span="8">江铜</a-col>
-                                <a-col :span="8">江铜</a-col>
-                            </a-row>
-                        </a-collapse-panel>
-                    </a-collapse>
-                    <a-row class="contRow">
-                        <a-col :span="8">江铜</a-col>
-                        <a-col :span="8">江铜</a-col>
-                        <a-col :span="8">江铜</a-col>
-                    </a-row>
-                    <a-collapse default-active-key="4">
-                        <template #expandIcon="props">
-                            <svg class="icon svg-icon" aria-hidden="true" v-if="props.isActive == 0">
-                                <use xlink:href="#icon-shouqi1"></use>
-                            </svg>
-                            <svg class="icon svg-icon" aria-hidden="true" v-else>
-                                <use xlink:href="#icon-shouqi2"></use>
-                            </svg>
-                        </template>
-                        <a-collapse-panel key="4">
-                            <template #header>
-                                <a-row class="headRow">
-                                    <a-col :span="8">期货品种(2)</a-col>
-                                    <a-col :span="8">单位</a-col>
-                                    <a-col :span="8">品种系数</a-col>
-                                </a-row>
-                            </template>
-                            <a-row class="contRow">
-                                <a-col :span="8">江铜</a-col>
-                                <a-col :span="8">江铜</a-col>
-                                <a-col :span="8">江铜</a-col>
-                            </a-row>
-                            <a-row class="contRow">
-                                <a-col :span="8">江铜</a-col>
-                                <a-col :span="8">江铜</a-col>
-                                <a-col :span="8">江铜</a-col>
-                            </a-row>
-                        </a-collapse-panel>
-                    </a-collapse>
-                </a-collapse-panel>
+                <a-row class="contRow"
+                       v-for="(sub, j) in item.gplist"
+                       :key="j + 'kkk'">
+                  <a-col :span="8">{{sub.goodsgroupname}}</a-col>
+                  <a-col :span="8">{{sub.enumdicname}}</a-col>
+                  <a-col :span="8">{{sub.convertratio}}</a-col>
+                </a-row>
+              </a-collapse-panel>
             </a-collapse>
-        </div>
+          </template>
+        </a-collapse-panel>
+      </a-collapse>
     </div>
+  </div>
 </template>
 
 <script lang="ts">
-    import { defineComponent, ref, PropType } from 'vue';
-    import APP from '@/services';
-    import { initData } from '@/common/methods';
-    import { queryDeliveryGoods } from './setup';
-    export default defineComponent({
-        name: 'rightSpot',
-        props: {},
-        components: {},
-        setup(props, context) {
-            const { goodsList } = queryDeliveryGoods({});
-            initData(() => {});
-            return {
-                goodsList,
-            };
+import { defineComponent, ref, PropType } from 'vue';
+import { handleDG, getGoodsUnit } from '../../setup';
+import { ErmcpDeliveryGoodsDetailEx } from '@/services/go/ermcp/goodsInfo/interface';
+import APP from '@/services';
+import { initData } from '@/common/methods';
+
+export default defineComponent({
+    name: 'rightSpot',
+    props: {
+        selctedDeliveryGoods: {
+            default: handleDG,
+            type: Object as PropType<ErmcpDeliveryGoodsDetailEx>,
         },
-    });
+    },
+    components: {},
+    setup(props, context) {
+        initData(() => {});
+        return { getGoodsUnit };
+    },
+});
 </script>
 
 <style lang="less">
-    .rightSpot {
+.rightSpot {
+    width: 100%;
+    height: 100%;
+    padding: 10px 12px;
+    .flex;
+    flex-direction: column;
+    .title {
         width: 100%;
-        height: 100%;
-        padding: 10px 12px;
+        height: 35px;
         .flex;
-        flex-direction: column;
-        .title {
-            width: 100%;
-            height: 35px;
-            .flex;
-            justify-content: space-between;
-            div {
-                align-self: center;
-                align-items: center;
-            }
-            .tltLeft {
-                font-size: 16px;
-                .icon {
-                    font-size: 20px;
-                    fill: @m-blue0;
-                    margin-right: 10px;
-                }
-            }
-            .tltBtns {
-                .ant-btn + .ant-btn {
-                    margin-left: 10px;
-                }
+        justify-content: space-between;
+        div {
+            align-self: center;
+            align-items: center;
+        }
+        .tltLeft {
+            font-size: 16px;
+            .icon {
+                font-size: 20px;
+                fill: @m-blue0;
+                margin-right: 10px;
             }
         }
-        .spotCont {
-            width: 100%;
-            padding: 0 30px;
+        .tltBtns {
+            .ant-btn + .ant-btn {
+                margin-left: 10px;
+            }
         }
     }
-    .blue {
-        color: @m-blue0;
+    .spotCont {
+        width: 100%;
+        padding: 0 30px;
     }
-    .green {
-        color: @m-green0;
+}
+.blue {
+    color: @m-blue0;
+}
+.green {
+    color: @m-green0;
+}
+.ml10 {
+    margin-left: 10px;
+}
+.blueBtn {
+    width: 80px;
+    height: 26px;
+    text-align: center;
+    background: linear-gradient(0deg, @m-blue2, @m-blue0);
+    box-shadow: -1px 0px 0px 0px #121618;
+    .rounded-corners(3px);
+    border: 0;
+    color: @m-white0;
+    font-size: 14px;
+    &:hover,
+    &:focus {
+        background: linear-gradient(0deg, @m-blue2-hover, @m-blue0-hover);
+        color: @m-white0-hover;
     }
-    .ml10 {
-        margin-left: 10px;
+}
+.redBtn {
+    width: 80px;
+    height: 26px;
+    background: linear-gradient(0deg, @m-red0, @m-red1);
+    .rounded-corners(3px);
+    border: 0;
+    color: @m-white0;
+    font-size: 14px;
+    &:hover,
+    &:focus {
+        background: linear-gradient(0deg, @m-red0-hover, @m-red1-hover);
+        color: @m-white0-hover;
     }
-    .blueBtn {
-        width: 80px;
-        height: 26px;
-        text-align: center;
-        background: linear-gradient(0deg, @m-blue2, @m-blue0);
-        box-shadow: -1px 0px 0px 0px #121618;
-        .rounded-corners(3px);
+}
+.ant-collapse {
+    background-color: transparent;
+    border: 0;
+    .ant-collapse-item {
         border: 0;
-        color: @m-white0;
-        font-size: 14px;
-        &:hover,
-        &:focus {
-            background: linear-gradient(0deg, @m-blue2-hover, @m-blue0-hover);
-            color: @m-white0-hover;
+        .ant-collapse-header {
+            background-color: transparent;
+            border-bottom: 0;
         }
-    }
-    .redBtn {
-        width: 80px;
-        height: 26px;
-        background: linear-gradient(0deg, @m-red0, @m-red1);
-        .rounded-corners(3px);
-        border: 0;
-        color: @m-white0;
-        font-size: 14px;
-        &:hover,
-        &:focus {
-            background: linear-gradient(0deg, @m-red0-hover, @m-red1-hover);
-            color: @m-white0-hover;
+        .ant-collapse-content {
+            background-color: transparent;
+            border-top: 0;
         }
     }
-    .ant-collapse {
-        background-color: transparent;
-        border: 0;
-        .ant-collapse-item {
-            border: 0;
-            .ant-collapse-header {
-                background-color: transparent;
-                border-bottom: 0;
-            }
-            .ant-collapse-content {
-                background-color: transparent;
-                border-top: 0;
+}
+.ant-collapse.spotCollapse.ant-collapse-borderless {
+    margin-top: 10px;
+    background-color: transparent;
+    .ant-collapse-item {
+        border-bottom: 0;
+        .ant-collapse-header {
+            color: @m-grey17;
+            font-size: 14px;
+            border-bottom: 1px solid @m-grey18;
+            padding: 10px 8px 10px 44px;
+            height: 43px;
+            .ant-collapse-arrow {
+                fill: @m-grey17;
+                width: 16px;
+                height: 16px;
+                font-size: 16px;
+                left: 0;
             }
         }
-    }
-    .ant-collapse.spotCollapse.ant-collapse-borderless {
-        margin-top: 10px;
-        background-color: transparent;
-        .ant-collapse-item {
-            border-bottom: 0;
-            .ant-collapse-header {
-                color: @m-grey17;
-                font-size: 14px;
-                border-bottom: 1px solid @m-grey18;
-                padding: 10px 8px 10px 44px;
-                height: 43px;
-                .ant-collapse-arrow {
-                    fill: @m-grey17;
-                    width: 16px;
-                    height: 16px;
+        .ant-collapse-content {
+            .ant-collapse-content-box {
+                padding: 0 0 0 30px;
+                background-color: transparent;
+                .ant-row.contRow {
+                    width: 100%;
+                    height: 40px;
+                    line-height: 40px;
                     font-size: 16px;
-                    left: 0;
-                }
-            }
-            .ant-collapse-content {
-                .ant-collapse-content-box {
-                    padding: 0 0 0 30px;
-                    background-color: transparent;
-                    .ant-row.contRow {
-                        width: 100%;
-                        height: 40px;
-                        line-height: 40px;
-                        font-size: 16px;
-                        color: @m-white1;
-                        margin-bottom: 10px;
-                        background: #0f161c;
-                        border: 1px solid #172b56;
-                        border-radius: 3px;
-                        padding-left: 14px;
-                        padding-right: 12px;
-                        .ant-col:last-child {
-                            text-align: right;
-                        }
-                        .ant-col:first-child {
-                            text-align: left;
-                        }
+                    color: @m-white1;
+                    margin-bottom: 10px;
+                    background: #0f161c;
+                    border: 1px solid #172b56;
+                    border-radius: 3px;
+                    padding-left: 14px;
+                    padding-right: 12px;
+                    .ant-col:last-child {
+                        text-align: right;
                     }
-                    .contRow:first-child {
-                        margin-top: 9px;
-                    }
-                    .contRow:last-child {
-                        margin-bottom: 20px;
+                    .ant-col:first-child {
+                        text-align: left;
                     }
                 }
+                .contRow:first-child {
+                    margin-top: 9px;
+                }
+                .contRow:last-child {
+                    margin-bottom: 20px;
+                }
             }
         }
     }
-    .ant-row.headRow {
-        .ant-col:first-child {
-            text-align: left;
-        }
-        .ant-col:nth-child(3) {
-            text-align: right;
-        }
-    }</style
+}
+.ant-row.headRow {
+    .ant-col:first-child {
+        text-align: left;
+    }
+    .ant-col:nth-child(3) {
+        text-align: right;
+    }
+}
+</style
 >;

+ 0 - 13
src/views/information/goods/components/rightSpot/setup.ts

@@ -1,13 +0,0 @@
-import { QueryDeliveryGoods } from '@/services/go/ermcp/goodsInfo';
-import { ErmcpDeliveryGoodsReq, ErmcpDeliveryGoodsRsp } from '@/services/go/ermcp/goodsInfo/interface';
-import { ref } from 'vue';
-
-export function queryDeliveryGoods(req: ErmcpDeliveryGoodsReq) {
-    let goodsList = ref<ErmcpDeliveryGoodsRsp[] | []>([]);
-    QueryDeliveryGoods(req).then((res) => {
-        goodsList.value = res;
-    });
-    return {
-        goodsList,
-    };
-}

+ 6 - 8
src/views/information/goods/list/spot-variety/index.vue

@@ -9,10 +9,10 @@
     <div class="spotTableCont">
       <div class="leftSpot">
         <leftMenu :menuList="menuList"
-                  @chooseMenu="chooseMenu"></leftMenu>
+                  @chooseMenu="chooseDG"></leftMenu>
       </div>
       <div class="rightCont">
-        <rightSpot></rightSpot>
+        <rightSpot :selctedDeliveryGoods="selctedDeliveryGoods"></rightSpot>
       </div>
     </div>
     <!-- 新增商品 -->
@@ -29,7 +29,7 @@ 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 } from '../../setup';
 
 export default defineComponent({
     name: 'spot-variety',
@@ -41,15 +41,13 @@ export default defineComponent({
     },
     setup() {
         const { openAction: addAction } = openModal('spot_contract_btn_add');
-        const { loading, deliveryGoodsList, menuList, queryDG } = handleDG();
-        function chooseMenu(key: string) {
-            deliveryGoodsList.value.find((e) => e.data.deliverygoodsid === Number(key));
-        }
+        const { loading, selctedDeliveryGoods, chooseDG, menuList, queryDG } = handleDG();
+
         initData(() => {
             // 加载数据在这里
             queryDG();
         });
-        return { addAction, loading, menuList };
+        return { addAction, loading, selctedDeliveryGoods, chooseDG, menuList };
     },
 });
 </script>

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

@@ -1,75 +0,0 @@
-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';
-
-/**
- * 获取现货品种数据
- * @returns 
- */
-export function handleDG() {
-    const loading = ref<boolean>(false);
-    // 现货品种列表
-    const deliveryGoodsList = ref<ErmcpDeliveryGoodsDetailEx[]>([])
-    // 选中的具体某一天现货品种数据
-    const selctedDeliveryGoods = reactive<ErmcpDeliveryGoodsDetailEx>({
-        data: {
-            agreeunit: 0,
-            areauserid: 0,
-            auditflag: 0,
-            categoryid: 0,
-            deliverygoodscode: '',
-            deliverygoodsid: 0,
-            deliverygoodsname: '--',
-            deliverygoodstype: 0,
-            dgstatus: 0,
-            enumdicname: '--',
-            goodsunitid: 0,
-            isvalid: 0,
-            qtydecimalplace: 0,
-            remark: '',
-            standardqty: 0,
-            standardqtyrange: 0
-        },
-        gblist: [],
-        gmlist: [],
-        mgList: [],
-    })
-    const menuList = ref<MenuList[]>([
-        { key: '1', title: '正常', children: [] },
-        { key: '2', title: '停用', children: [] },
-    ]);
-    // 获取现货品种数据
-    function queryDG(param?: number) {
-        loading.value = true;
-        QueryDeliveryGoodsDetail(param).then(res => {
-            deliveryGoodsList.value = res;
-            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)
-                }
-            })
-            // 获取默认第一条数据
-            if (menuList.value[0].children?.length) {
-                chooseDG(menuList.value[0].children[0].key)
-            } else if (menuList.value[1].children?.length) {
-                chooseDG(menuList.value[1].children[0].key)
-            }
-            console.log('selctedDeliveryGoods', selctedDeliveryGoods);
-        }).catch(err => {
-            message.error(err)
-        }).finally(() => loading.value = false)
-    }
-    // 选择某条现货数据
-    function chooseDG(key: string) {
-        const obj = deliveryGoodsList.value.find(e => e.data.deliverygoodsid === Number(key))
-        if (obj) {
-            mergeObj(selctedDeliveryGoods, obj)
-        }
-    }
-    return { loading, deliveryGoodsList, menuList, queryDG, selctedDeliveryGoods, chooseDG }
-}

+ 93 - 0
src/views/information/goods/setup.ts

@@ -0,0 +1,93 @@
+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';
+
+/**
+ * 初始化 现货品种对象数据
+ * @returns 
+ */
+export function initDG(): ErmcpDeliveryGoodsDetailEx {
+    return {
+        data: {
+            agreeunit: 0,
+            areauserid: 0,
+            auditflag: 0,
+            categoryid: 0,
+            deliverygoodscode: '',
+            deliverygoodsid: 0,
+            deliverygoodsname: '--',
+            deliverygoodstype: 0,
+            dgstatus: 0,
+            enumdicname: '--',
+            goodsunitid: 0,
+            isvalid: 0,
+            qtydecimalplace: 0,
+            remark: '',
+            standardqty: 0,
+            standardqtyrange: 0
+        },
+        gblist: [],
+        gmlist: [],
+        mgList: [],
+    }
+}
+
+/**
+ * 获取现货品种数据
+ * @returns 
+ */
+export function handleDG() {
+    const loading = ref<boolean>(false);
+    // 现货品种列表
+    const deliveryGoodsList = ref<ErmcpDeliveryGoodsDetailEx[]>([])
+    // 选中的具体某一天现货品种数据
+    const selctedDeliveryGoods = reactive<ErmcpDeliveryGoodsDetailEx>(initDG())
+    const menuList = ref<MenuList[]>([
+        { key: '1', title: '正常', children: [] },
+        { key: '2', title: '停用', children: [] },
+    ]);
+    // 获取现货品种数据
+    function queryDG(param?: number) {
+        loading.value = true;
+        QueryDeliveryGoodsDetail(param).then(res => {
+            deliveryGoodsList.value = res;
+            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)
+                }
+            })
+            // 获取默认第一条数据
+            if (menuList.value[0].children?.length) {
+                chooseDG(menuList.value[0].children[0].key)
+            } else if (menuList.value[1].children?.length) {
+                chooseDG(menuList.value[1].children[0].key)
+            }
+        }).catch(err => {
+            message.error(err)
+        }).finally(() => loading.value = false)
+    }
+    // 选择某条现货数据
+    function chooseDG(key: string) {
+        debugger
+        const obj = deliveryGoodsList.value.find(e => e.data.deliverygoodsid === Number(key))
+        if (obj) {
+            mergeObj(selctedDeliveryGoods, obj)
+            console.log('selctedDeliveryGoods', selctedDeliveryGoods);
+        }
+    }
+    return { loading, deliveryGoodsList, menuList, queryDG, selctedDeliveryGoods, chooseDG }
+}
+
+/**
+ * 获取合约单位
+ * @returns 
+ */
+export function getGoodsUnit(unit: number) {
+    return getItemEnum('goodsunit').find(e => e.enumitemname === unit)?.enumdicname
+}