소스 검색

出入库登记(生产入库

huangbin 4 년 전
부모
커밋
1ffd9c812b

+ 5 - 0
src/views/information/spot-contract/list/unsubmitted/index.vue

@@ -85,6 +85,7 @@ import { getBizTypeName, getContractStatusName, getContractTypeName, getPriceTyp
 import { Column, ColumnType } from '@/common/setup/table';
 import { formatTime, formatValue } from '@/common/methods';
 import { handlerManagerList } from '@/common/setup/user';
+import { reactive } from '@vue/reactivity';
 
 export default defineComponent({
     name: 'spot-contract-not-commit',
@@ -106,6 +107,10 @@ export default defineComponent({
         const { commonBtn, forDataBtn } = getBtnList('spot_contract_unsubmitted', true);
         // 表格列表数据
         const { loading, tableList, queryTable } = queryTableList(1);
+        console.log(loading);
+        const a = reactive({name: 'hello'})
+        console.log(a);
+                
         // 获取 业务账户
         const { tableList: businessManager, queryTable: queryBusinessManager, findManagerName } = handlerManagerList(loading, 1);
         // 查询

+ 128 - 13
src/views/search/inventory/components/add/index.vue

@@ -1,22 +1,117 @@
 <template>
-  <!-- 新增现货合同 -->
+  <!-- 出入库登记-->
   <a-modal class="commonModal add-spot-contract"
-           title="新增现货合同"
+           :title="`出入库登记(生产${inOrOut()})`"
            v-model:visible="visible"
            centered
            :maskClosable="maskClosableFlag"
-           @cancel="cancel"
+           @cancel="closeAction"
            width="890px">
     <template #footer>
       <a-button key="submit"
                 class="cancelBtn"
-                @click="submit(1)">保存草稿</a-button>
+                @click="cancel">取消</a-button>
       <a-button key="submit"
                 type="primary"
                 :loading="loading"
-                @click="submit(2)">提交审核</a-button>
+                @click="submit(2)">{{inOrOut()}}登记</a-button>
     </template>
-
+    <a-form class="inlineForm"
+            ref="formRef"
+            :model="formState"
+            :rules="rules">
+      <a-row :gutter="24">
+        <a-col :span="12">
+          <a-form-item label="出入库类型"
+                       name="InOutType">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      v-model:value="formState.InOutType"
+                      placeholder="请选择出入库类型">
+              <a-select-option v-for="item in warehouseType"
+                               :key="item.key"
+                               :value="item.key">
+                {{item.name}}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="现货品种"
+                       name="DeliveryGoodsID">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      @change="deliveryGoodsChange"
+                      :getPopupContainer="(triggerNode) => triggerNode.parentNode"
+                      v-model:value="formState.DeliveryGoodsID"
+                      placeholder="请选择现货品种">
+              <a-select-option v-for="item in deliveryGoodsList"
+                               :key="item.deliverygoodsid"
+                               :value="item.deliverygoodsid">
+                {{item.deliverygoodsname}}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="品类"
+                       name="WRStandardID">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      :getPopupContainer="(triggerNode) => triggerNode.parentNode"
+                      @change="WrStandardChange"
+                      v-model:value="formState.WRStandardID"
+                      placeholder="请选择品类">
+              <a-select-option v-for="item in gmlist"
+                               :key="item.wrstandardid"
+                               :value="item.wrstandardid">
+                {{item.wrstandardname}}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="品牌"
+                       name="SpotGoodsBrandID">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      :getPopupContainer="(triggerNode) => triggerNode.parentNode"
+                      v-model:value="formState.SpotGoodsBrandID"
+                      placeholder="请选择品牌">
+              <a-select-option v-for="item in gblist"
+                               :key="item.brandid"
+                               :value="item.brandid">
+                {{item.brandname}}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item :label="`${inOrOut()}仓库`"
+                       name="WarehouseInfo">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      :placeholder="`请选择${inOrOut()}仓库`"
+                      v-model:value="formState.WarehouseInfo">
+              <a-select-option v-for="option in wareHouseList"
+                               :key="option.autoid"
+                               :value="option.autoid">
+                {{option.warehousename}}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item :label="`${inOrOut()}数量`"
+                       name="Qty">
+            <a-input class="dialogInput"
+                     style="width: 200px"
+                     v-model:value="formState.Qty"
+                     :placeholder="`请输入${inOrOut()}数量`" />
+          </a-form-item>
+        </a-col>
+      </a-row>
+    </a-form>
   </a-modal>
 </template>
 
@@ -24,8 +119,11 @@
 import { defineComponent, PropType, ref, toRaw, watchEffect } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods';
-
 import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
+import { handleDeliveryGoods, handleFormState, handleWarehouseList, handleWarehouseType } from './setup';
+import { validateAction } from '@/common/setup/form';
+import { FormState } from './interface';
+import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 
 export default defineComponent({
     name: 'add-spot-contract',
@@ -38,19 +136,36 @@ export default defineComponent({
     },
     setup(props, context) {
         const { visible, cancel } = closeModal('inventory_current_add');
-
+        const { rules, formState, formRef, initFormData } = handleFormState()
+        const { warehouseType, inOrOut } = handleWarehouseType(formState)
+        const { wareHouseList, getWarehouseList } = handleWarehouseList();
+        const { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods(formState);
         const loading = ref<boolean>(false);
-        function submit(OperateType: 1 | 2) {
-            cancel();
+        function submit() {
+            validateAction<FormState>(formRef, formState).then((param) => {
+                // requestResultLoadingAndInfo(QueryAddUserInfoApply, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['新增客户资料成功', '新增客户资料失败:']).then(() => {
+                //     closeAction();
+                //     context.emit('refresh');
+                // });
+            })
         }
-
-        initData(() => {});
+        function closeAction() {
+          Object.assign(formState, initFormData())
+          cancel();
+        }
+        initData(() => {
+            getWarehouseList();
+            getDeliveryGoods();
+        });
         return {
             visible,
-            cancel,
+            closeAction,
             submit,
             loading,
             maskClosableFlag: false,
+            rules, formState, formRef,
+            warehouseType, inOrOut,wareHouseList,
+            deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange 
         };
     },
 });

+ 9 - 0
src/views/search/inventory/components/add/interface.ts

@@ -0,0 +1,9 @@
+export interface FormState {
+    InOutType: number; // int32 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+    WRStandardID: number | undefined; // uint64 现货商品ID
+    SpotGoodsBrandID: number | undefined; // uint64 现货品牌ID
+    DeliveryGoodsID: number | undefined; // uint64 现货品种ID
+    SpotContractID?: number; // uint64 关联现货合同ID [1:采购入库 2:销售出库 ](1,2状态必填)
+    WarehouseInfo: number | undefined; // uint64 现货仓库ID
+    Qty: number | null; // double 数量
+}

+ 130 - 0
src/views/search/inventory/components/add/setup.ts

@@ -0,0 +1,130 @@
+import { getGoodsUnitEnumItemName } from "@/common/constants/enumsName";
+import APP from '@/services';
+import { QueryDeliveryGoods } from "@/services/go/ermcp/goodsInfo";
+import { Ermcp3Brand, Ermcp3Wrstandard, ErmcpDeliveryGoodsDetailEx, ErmcpDeliveryGoodsRsp } from "@/services/go/ermcp/goodsInfo/interface";
+import { QueryWareHouse } from "@/services/go/ermcp/warehouse-info/index";
+import { ErmcpWareHouseInfo } from "@/views/information/warehouse-info/list";
+import { message } from "ant-design-vue";
+import { reactive, ref, UnwrapRef } from "vue";
+import { FormState } from "./interface";
+
+// 表单
+export function handleFormState() {
+    const formRef = ref();
+    function initFormData(): FormState {
+        return {
+            InOutType: 3, // int32 出入库类型 - 1:采购入库 2:销售出库 3:生产入库 4:生产出库
+            WRStandardID: undefined, // uint64 现货商品ID
+            SpotGoodsBrandID: undefined, // uint64 现货品牌ID
+            DeliveryGoodsID: undefined, // uint64 现货品种ID
+            WarehouseInfo: undefined, // uint64 现货仓库ID
+            Qty: null, // double 数量
+        }
+    }
+    const formState: UnwrapRef<FormState> = reactive(initFormData())
+    const rules = {
+        WRStandardID: [{ required: true, message: '请选择现货品类' }],
+        SpotGoodsBrandID: [{ required: true, message: '请选择现货品牌' }],
+        DeliveryGoodsID: [{ required: true, message: '请选择现货品种' }],
+        WarehouseInfo: [{ required: true, message: '请选择现货仓库' }],
+        Qty: [{ required: true, message: '请输入数量' }],
+    }
+    return { rules, formState, formRef, initFormData }
+}
+
+// 仓库类别
+export function handleWarehouseType(formState: UnwrapRef<FormState>) {
+    const warehouseType = [
+        { name: '生产入库', key: 3 },
+        { name: '生产出库', key: 4 },
+    ]
+    /**
+     * 
+     * 是否入库
+     * @return true: 入库; false:出库
+     */
+    function isIn(): boolean {
+        return formState.InOutType === 3
+    }
+    function inOrOut() {
+        return isIn() ? '入库' : '出库'
+    }
+    return { warehouseType, inOrOut }
+}
+
+// 仓库列表
+export function handleWarehouseList() {
+    const wareHouseList = ref<ErmcpWareHouseInfo[]>([]);
+    function getWarehouseList() {
+        QueryWareHouse('1').then((res) => {
+            wareHouseList.value = res;
+        });
+    }
+    return { wareHouseList, getWarehouseList }
+}
+
+/**
+ * 处理现货商品
+ */
+export function handleDeliveryGoods(formState: UnwrapRef<FormState>) {
+    // 现货品种
+    const deliveryGoodsList = ref<ErmcpDeliveryGoodsRsp[]>([])
+    // 品牌
+    const gblist = ref<Ermcp3Brand[]>([])
+    // 品类列表
+    const gmlist = ref<Ermcp3Wrstandard[]>([])
+
+    // 查询现货商品
+    function getDeliveryGoods() {
+        QueryDeliveryGoods({}).then(res => {
+            console.log('查询现货商品', res);
+            deliveryGoodsList.value = res;
+        }).catch(err => {
+            message.error(err)
+        })
+    }
+
+    // 切换现货商品
+    function deliveryGoodsChange(value: number | undefined) {
+        if (value !== undefined) {
+            getDeliveryGoodsDetail(value)
+        } else {
+            gblist.value.length = 0
+            gmlist.value.length = 0
+        }
+        formState.WRStandardID = undefined;
+        formState.SpotGoodsBrandID = undefined;
+    }
+
+    // 查询现货商品详情
+    function getDeliveryGoodsDetail(deliverygoodsid: number) {
+        const temp = APP.get('DeliveryGoodsList').find((e: ErmcpDeliveryGoodsDetailEx) => e.data.deliverygoodsid === deliverygoodsid)
+        if (temp) {
+            gblist.value = temp.gblist
+            gmlist.value = temp.gmlist
+        }
+    }
+
+    const numberUnit = ref<string>('')
+
+    // 品类变更
+    function WrStandardChange(value: number) {
+        const obj = gmlist.value.find((e) => e.wrstandardid === value);
+        if (obj) {
+            //标仓系数
+            // 单位
+            numberUnit.value = getGoodsUnitEnumItemName(obj.unitid)
+        }
+    }
+
+    return {
+        deliveryGoodsList,
+        gblist,
+        gmlist,
+        numberUnit,
+        WrStandardChange,
+        getDeliveryGoods,
+        getDeliveryGoodsDetail,
+        deliveryGoodsChange
+    }
+}