huangbin 4 سال پیش
والد
کامیت
5c6b3e0d01

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

@@ -18,3 +18,23 @@ export function mergeObj(a: ObjType, ...rest: ObjType[]): void {
         });
     });
 }
+
+/**
+ * 合并两个对象
+ * @param a 
+ * @param b 
+ * @param callBack 
+ */
+export function mergeTwoObj(a: any, b: any, callBack?: Function) {
+    const obj: ObjType = {};
+    Object.keys(a).forEach((el) => {
+        const key = el.toLocaleLowerCase();
+        if (Reflect.has(b, key)) {
+            obj[el] = b[key];
+        } else {
+            console.warn(`为找到对应的key:${key}`);
+            callBack && callBack(el)
+        }
+    });
+    Object.assign(a, obj);
+}

+ 90 - 39
src/views/information/warehouse-info/compoments/modify/index.vue

@@ -1,9 +1,9 @@
 <template>
   <!-- 修改仓库信息-->
-  <a-modal class="modify-custom"
+  <a-modal class="modify-custom commonModal"
            title="修改仓库信息"
            v-model:visible="visible"
-            centered
+           centered
            :maskClosable="maskClosableFlag"
            @cancel="cancel"
            width="890px">
@@ -14,52 +14,62 @@
                 @click="submit">完成</a-button>
     </template>
     <a-form class="inlineForm"
-            :form="form"
-            @submit="handleSearch">
+            ref="formRef"
+            :model="formState"
+            :rules="rules">
       <a-row :gutter="24">
         <a-col :span="12">
-          <a-form-item label="仓库类型">
+          <a-form-item label="仓库类型"
+                       name="warehousetype">
             <a-select class="typeSelect"
                       style="width: 200px"
+                      v-model:value="formState.warehousetype"
                       placeholder="请选择仓库类型">
-              <a-select-option value="1">
-                仓库一
-              </a-select-option>
-              <a-select-option value="2">
-                仓库二
+              <a-select-option v-for="item in warehouseType"
+                               :key="item.enumitemname"
+                               :value="item.enumitemname">
+                {{item.enumdicname}}
               </a-select-option>
             </a-select>
           </a-form-item>
         </a-col>
         <a-col :span="12">
-          <a-form-item label="仓库名称">
+          <a-form-item label="仓库名称"
+                       name="warehousename">
             <a-input class="dialogInput"
                      style="width: 200px"
+                     v-model:value="formState.warehousename"
                      placeholder="请输入仓库名称" />
           </a-form-item>
         </a-col>
       </a-row>
       <a-row :gutter="24">
         <a-col :span="12">
-          <a-form-item label="仓库简称">
+          <a-form-item label="仓库简称"
+                       name="warehousecode">
             <a-input class="dialogInput"
                      style="width: 200px"
+                     v-model:value="formState.warehousecode"
                      placeholder="请输入仓库简称" />
           </a-form-item>
         </a-col>
         <a-col :span="12">
-          <a-form-item label="联系人">
+          <a-form-item label="联系人"
+                       name="contactname">
             <a-input class="dialogInput"
                      style="width: 200px"
+                     v-model:value="formState.contactname"
                      placeholder="请输入联系人" />
           </a-form-item>
         </a-col>
       </a-row>
       <a-row :gutter="24">
         <a-col :span="24">
-          <a-form-item label="联系电话">
+          <a-form-item label="联系电话"
+                       name="contactnum">
             <a-input class="dialogInput"
                      style="width: 200px"
+                     v-model:value="formState.contactnum"
                      placeholder="请输入联系电话" />
           </a-form-item>
         </a-col>
@@ -69,32 +79,34 @@
           <a-form-item label="所在地区">
             <a-select class="inlineFormSelect"
                       style="width: 205px"
+                      v-model:value="formState.provinceid"
+                      @change="getCityList"
                       placeholder="请选择省">
-              <a-select-option value="1">
-                广东省
-              </a-select-option>
-              <a-select-option value="2">
-                湖南省
+              <a-select-option v-for="item in provinceList"
+                               :key="item.autoid"
+                               :value="item.autoid">
+                {{item.divisionname}}
               </a-select-option>
             </a-select>
             <a-select class="inlineFormSelect ml9"
                       style="width: 205px"
+                      v-model:value="formState.cityid"
+                      @change="getDistrictList"
                       placeholder="请选择市">
-              <a-select-option value="1">
-                深圳市
-              </a-select-option>
-              <a-select-option value="2">
-                岳阳市
+              <a-select-option v-for="item in cityList"
+                               :key="item.autoid"
+                               :value="item.autoid">
+                {{item.divisionname}}
               </a-select-option>
             </a-select>
             <a-select class="inlineFormSelect ml9"
+                      v-model:value="formState.districtid"
                       style="width: 205px"
                       placeholder="请选择县(区)">
-              <a-select-option value="1">
-                区一
-              </a-select-option>
-              <a-select-option value="2">
-                区二
+              <a-select-option v-for="item in districtList"
+                               :key="item.autoid"
+                               :value="item.autoid">
+                {{item.divisionname}}
               </a-select-option>
             </a-select>
           </a-form-item>
@@ -102,8 +114,10 @@
       </a-row>
       <a-row :gutter="24">
         <a-col :span="24">
-          <a-form-item label="详细地址">
+          <a-form-item label="详细地址"
+                       name="address">
             <a-input class="dialogInput"
+                     v-model:value="formState.address"
                      style="width: 635px"
                      placeholder="请输入详细地址" />
           </a-form-item>
@@ -114,29 +128,66 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref } from 'vue';
+import { defineComponent, PropType, ref, toRaw, watchEffect } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
+import { initData } from '@/common/methods/index';
+import { getAddress } from '@/services/go/adress';
+import { handleForm, getWarehouseType, FormState, warehouseApply } from '../setup';
+import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
+import { AllEnums } from '@/services/go/commonService/interface';
+import { WarehouseApplyReq } from '@/services/proto/warehouse/interface';
+import { ErmcpWareHouseInfo } from '@/services/go/ermcp/warehouse-info/interface';
+import { mergeTwoObj } from '@/utils/objHandle';
 
 export default defineComponent({
     name: 'warehouse_info_btn_modify',
+    props: {
+        selectedRow: {
+            type: Object as PropType<ErmcpWareHouseInfo>,
+            default: {},
+        },
+    },
     components: {},
-    setup() {
+    setup(props) {
         const { visible, cancel } = closeModal('warehouse_info_btn_modify');
         const loading = ref<boolean>(false);
-        const maskClosableFlag = ref<boolean>(false);
+        const { cityList, districtList, provinceList, getCityList, getDistrictList } = getAddress();
+        const warehouseType = ref<AllEnums[]>(getWarehouseType());
+        const { formRef, formState, rules } = handleForm();
+        watchEffect(() => {
+            if (props.selectedRow.warehousename) {
+                console.log('props.selectedRow,', props.selectedRow);
+                mergeTwoObj(formState, props.selectedRow);
+            }
+        });
         function submit() {
-            loading.value = true;
-            setTimeout(() => {
-                loading.value = false;
-                cancel();
-            }, 2000);
+            formRef.value
+                .validate()
+                .then(() => {
+                    const param = toRaw(formState) as WarehouseApplyReq;
+                    param.type = 2;
+                    warehouseApply(param, loading);
+                    console.log('param', param);
+                })
+                .catch((error: ValidateErrorEntity<FormState>) => {
+                    console.log('error', error);
+                });
         }
         return {
             visible,
             cancel,
             submit,
             loading,
-            maskClosableFlag,
+            maskClosableFlag: false,
+            cityList,
+            districtList,
+            provinceList,
+            getCityList,
+            getDistrictList,
+            formRef,
+            formState,
+            rules,
+            warehouseType,
         };
     },
 });

+ 2 - 1
src/views/information/warehouse-info/list/normal-use/index.vue

@@ -34,7 +34,8 @@
     <Detail :selectedRow="selectedRow"
             @refresh="queryTable" />
     <!-- 修改仓息库信 -->
-    <Modify />
+    <Modify :selectedRow="selectedRow"
+            @refresh="queryTable" />
   </div>
 </template>