Ver código fonte

Merge remote-tracking branch 'origin/master'

xkwg 4 anos atrás
pai
commit
e521114ff9

+ 5 - 0
src/common/constants/buttonType.ts

@@ -9,6 +9,11 @@ export interface ButtonType {
     custom_info_btn_cancel: string; // 客户资料 撤销
     custom_info_btn_check: string; // 客户资料 审核
 
+    goods_info_spot_normal_add: string; // 现货品种 新增
+    goods_info_spot_normal_modify: string; // 现货品种 修改
+    goods_info_spot_normal_disable: string; // 现货品种 停用
+    goods_info_spot_disable_recover: string; // 现货品种 恢复
+
     spot_contract_btn_add: string; // 现货合同 添加
     spot_contract_btn_resubmit: string; // 现货合同 重新提交
     spot_contract_btn_modify: string; // 现货合同 修改

+ 8 - 5
src/views/information/goods/components/add/index.vue

@@ -307,8 +307,8 @@
                           v-model:value="domain.middlegoodsid"
                           placeholder="请选择套保品种">
                   <a-select-option v-for="item in goodsGroup"
-                                   :value="item.groupcategroyid"
-                                   :key="item.groupcategroyid">
+                                   :value="item.goodsgroupid"
+                                   :key="item.goodsgroupid">
                     {{item.goodsgroupname}}
                   </a-select-option>
                 </a-select>
@@ -436,9 +436,9 @@ export default defineComponent({
         PlusOutlined,
         MinusOutlined,
     },
-    setup() {
+    setup(props, context) {
         // 控制关闭弹窗
-        const { visible, cancel } = closeModal('spot_contract_btn_add');
+        const { visible, cancel } = closeModal('goods_info_spot_normal_add');
         // 下单方法
         const { loading, addAction } = handleAdd();
         // 单位列表
@@ -527,7 +527,10 @@ export default defineComponent({
                 .validate()
                 .then(() => {
                     const param = toRaw(formState);
-                    addAction(param);
+                    addAction(param).then(() => {
+                        cancel();
+                        context.emit('refresh', true);
+                    });
                     console.log('param', param);
                 })
                 .catch((error: ValidateErrorEntity<FormState>) => {

+ 13 - 14
src/views/information/goods/components/add/setup.ts

@@ -2,7 +2,7 @@ import { getItemEnum } from '@/services/bus/allEnum';
 import { QueryGoodsfGroup } from '@/services/go/ermcp/goodsInfo';
 import { Ermcp3GoodsGroup } from '@/services/go/ermcp/goodsInfo/interface';
 import { addDeliveryGoodsApply } from '@/services/proto/delivery';
-import {DeliveryGoodsApplyReq, GLDWRStandardEx} from '@/services/proto/delivery/interface';
+import { DeliveryGoodsApplyReq } from '@/services/proto/delivery/interface';
 import { message } from 'ant-design-vue';
 import { reactive, ref, UnwrapRef } from 'vue';
 import { FormState } from './interface';
@@ -13,18 +13,18 @@ import { FormState } from './interface';
  */
 export function handleAdd() {
     const loading = ref<boolean>(false);
-    function addAction(param: FormState) {
+    function addAction(param: FormState): Promise<void> {
         const unitid = param.unitid === undefined ? 0 : param.unitid
-        const reqParam :DeliveryGoodsApplyReq = {
+        const reqParam: DeliveryGoodsApplyReq = {
             deliverygoodscode: param.deliverygoodscode,
             deliverygoodsname: param.deliverygoodsname,
-            deliverygoodsid:   param.deliverygoodsid,
+            deliverygoodsid: param.deliverygoodsid,
             unitid: unitid,
             type: 1,
             remark: param.remark,
             gldwrstandards: param.gldwrstandards.map(value => {
-                let gldunitid = value.unitid === undefined ? 0 : value.unitid
-                let convertfactors: any = value.convertfactor === null ? 0 : value.convertfactor
+                const gldunitid = value.unitid === undefined ? 0 : value.unitid
+                const convertfactors: any = value.convertfactor === null ? 0 : value.convertfactor
                 return {
                     wrstandardid: value.wrstandardid,
                     wrstandardname: value.wrstandardname,
@@ -34,22 +34,21 @@ export function handleAdd() {
             }),
             glddgfactoryItems: param.glddgfactoryItems,
             wrsconvertdetails: param.wrsconvertdetails.map(value => {
-                let middlegoodsid = value.middlegoodsid === undefined ? 0 : value.middlegoodsid
-                let convertratio: any = value.convertratio === null ? 0 : value.convertratio
-                let wrsunitid = value.unitid === null ? 0 : value.unitid
+                const middlegoodsid = value.middlegoodsid === undefined ? 0 : value.middlegoodsid
+                const convertratio: any = value.convertratio === null ? 0 : value.convertratio
+                const wrsunitid = value.unitid === null ? 0 : value.unitid
                 return {
                     middlegoodsid: middlegoodsid,
-                    convertratio:  (convertratio as string) ? Number(convertratio) : convertratio,
+                    convertratio: (convertratio as string) ? Number(convertratio) : convertratio,
                     unitid: wrsunitid
                 }
             })
         }
         loading.value = true;
-        addDeliveryGoodsApply(reqParam).then(() => {
+        return addDeliveryGoodsApply(reqParam).then(() => {
             message.success('新增现货品种成功!')
-        }).catch(err => {
-            message.error(err.message)
-        }).finally(() => loading.value = false)
+            Promise.resolve()
+        }).catch(err => message.error(err.message)).finally(() => loading.value = false)
     }
     return { loading, addAction }
 }

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

@@ -110,13 +110,13 @@
 </template>
 
 <script lang="ts">
-import {defineComponent, PropType, ref} from 'vue';
+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";
+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',
@@ -128,16 +128,16 @@ export default defineComponent({
         },
     },
     setup(props) {
-        const { visible, cancel } = closeModal('custom_info_btn_disable');
+        const { visible, cancel } = closeModal('goods_info_spot_normal_disable');
         const maskClosableFlag = ref<boolean>(false);
-        const  {loading, ModifyUserInfo} = updateUserAccount();
+        const { loading, ModifyUserInfo } = updateUserAccount();
         function submit() {
             Modal.confirm({
                 title: '是否确认停用客户资料',
                 okText: '确认停用',
                 cancelText: '取消',
                 onOk() {
-                    ModifyUserInfo(props.selectedRow.userid, 6, cancel);
+                    ModifyUserInfo(props.selectedRow.userid, 6);
                 },
                 onCancel() {
                     console.log('Cancel');

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

@@ -35,9 +35,8 @@ const handleMenu = (context: SetupContext) => {
     const openKeys = ref<string[]>(['1']);
 
     function menuClick(value: any) {
-        console.log('value', value);
-
-        context.emit('chooseMenu', value.key);
+        const is = value.keyPath.includes('goods_info_spot_normal') ? true : false;
+        context.emit('chooseMenu', { key: value.key, is });
     }
     return { collapsed, selectedKeys, openKeys, menuClick };
 };

+ 1 - 2
src/views/information/goods/components/modify/index.vue

@@ -201,8 +201,7 @@ export default defineComponent({
         // }
     },
     setup() {
-        // const { visible, cancel } = closeModal('modifyCustomInfo');
-        const { visible, cancel } = closeModal('custom_info_btn_modify');
+        const { visible, cancel } = closeModal('goods_info_spot_normal_modify');
 
         const loading = ref<boolean>(false);
         const maskClosableFlag = ref<boolean>(false);

+ 25 - 5
src/views/information/goods/components/rightSpot/index.vue

@@ -12,8 +12,15 @@
         <span class="green ml10">{{selctedDeliveryGoods.data.dgstatus ? '正常' : '停用'}}</span>
       </div>
       <div class="tltBtns">
-        <a-button class="blueBtn">修改</a-button>
-        <a-button class="redBtn">停用</a-button>
+        <template v-if="isNormal">
+          <a-button class="blueBtn"
+                    @click="modifyAction">修改</a-button>
+          <a-button class="redBtn"
+                    @click="disableAction">停用</a-button>
+        </template>
+        <template>
+          <a-button class="blueBtn">恢复</a-button>
+        </template>
       </div>
     </div>
     <div class="spotCont">
@@ -108,6 +115,8 @@
         </a-collapse-panel>
       </a-collapse>
     </div>
+    <Modify />
+    <Disable />
   </div>
 </template>
 
@@ -115,8 +124,10 @@
 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';
+import { openModal } from '@/common/setup/modal/index';
+import Modify from '../modify/index.vue';
+import Disable from '../disable/index.vue';
 
 export default defineComponent({
     name: 'rightSpot',
@@ -125,11 +136,20 @@ export default defineComponent({
             default: handleDG,
             type: Object as PropType<ErmcpDeliveryGoodsDetailEx>,
         },
+        isNormal: {
+            default: true,
+            type: Boolean,
+        },
+    },
+    components: {
+        Modify,
+        Disable,
     },
-    components: {},
     setup(props, context) {
+        const { openAction: modifyAction } = openModal('goods_info_spot_normal_modify');
+        const { openAction: disableAction } = openModal('goods_info_spot_normal_disable');
         initData(() => {});
-        return { getGoodsUnit };
+        return { getGoodsUnit, modifyAction, disableAction };
     },
 });
 </script>

+ 9 - 10
src/views/information/goods/list/spot-variety/index.vue

@@ -4,6 +4,7 @@
        :loading="loading">
     <filterCustomTable @search="search">
       <a-button class="operBtn"
+                v-if="isNormal"
                 @click="addAction">新增</a-button>
     </filterCustomTable>
     <div class="spotTableCont">
@@ -12,25 +13,24 @@
                   @chooseMenu="chooseDG"></leftMenu>
       </div>
       <div class="rightCont">
-        <rightSpot :selctedDeliveryGoods="selctedDeliveryGoods"></rightSpot>
+        <rightSpot :selctedDeliveryGoods="selctedDeliveryGoods"
+                   :isNormal="isNormal"></rightSpot>
       </div>
     </div>
     <!-- 新增商品 -->
-    <AddGoods />
+    <AddGoods @refresh="queryDG" />
   </div>
 </template>
 
 <script lang="ts">
-import { defineComponent, ref } from 'vue';
-
+import { defineComponent } 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';
 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, handleGDStatue } from '../../setup';
-import { getThirdMenuData } from '@/common/setup/table/button';
+import { handleDG } from '../../setup';
 
 export default defineComponent({
     name: 'spot-variety',
@@ -42,15 +42,14 @@ export default defineComponent({
     },
     setup() {
         // 控制弹窗
-        const { openAction: addAction } = openModal('spot_contract_btn_add');
-        const { loading, selctedDeliveryGoods, chooseDG, menuList, queryDG } = handleDG();
-        const { isNormal, changeStatue } = handleGDStatue();
+        const { openAction: addAction } = openModal('goods_info_spot_normal_add');
+        const { loading, selctedDeliveryGoods, chooseDG, isNormal, menuList, queryDG } = handleDG();
 
         initData(() => {
             // 加载数据在这里
             queryDG();
         });
-        return { addAction, loading, selctedDeliveryGoods, chooseDG, menuList };
+        return { addAction, loading, selctedDeliveryGoods, chooseDG, isNormal, menuList };
     },
 });
 </script>

+ 10 - 16
src/views/information/goods/setup.ts

@@ -81,6 +81,7 @@ export function handleDG() {
     const deliveryGoodsList = ref<ErmcpDeliveryGoodsDetailEx[]>([])
     // 选中的具体某一天现货品种数据
     const selctedDeliveryGoods = reactive<ErmcpDeliveryGoodsDetailEx>(initDG())
+    const isNormal = ref<boolean>(true) // true => 正常; false => 停用
     // const menuList = ref<MenuList[]>(initMenu());
     // 获取现货品种数据
     function queryDG(param?: number) {
@@ -107,23 +108,28 @@ export function handleDG() {
             })
             // 获取默认第一条数据
             if (menuList.value[0].children?.length) {
-                chooseDG(menuList.value[0].children[0].key)
+                chooseDG({ key: menuList.value[0].children[0].key, is: true })
             } else if (menuList.value[1].children?.length) {
-                chooseDG(menuList.value[1].children[0].key)
+                chooseDG({ key: menuList.value[1].children[0].key, is: false })
             }
         }).catch(err => {
             message.error(err)
         }).finally(() => loading.value = false)
     }
+    interface Value {
+        key: string;
+        is: boolean;
+    }
     // 选择某条现货数据
-    function chooseDG(key: string) {
+    function chooseDG({ key, is }: Value) {
+        isNormal.value = is
         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 }
+    return { loading, deliveryGoodsList, menuList, queryDG, isNormal, selctedDeliveryGoods, chooseDG }
 }
 
 /**
@@ -141,15 +147,3 @@ 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 }
-}