Explorar el Código

feat(产品管理): 添加默认仓库设置功能

yusheng hace 7 meses
padre
commit
f530cef785

+ 22 - 11
src/api/material/product.js

@@ -1,7 +1,7 @@
 import request from '@/utils/request';
 
 // 产品关联物料
-export async function productTieUpMaterial (data) {
+export async function productTieUpMaterial(data) {
   const res = await request.post(`/main/category/productTieUpMaterial`, data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -9,7 +9,7 @@ export async function productTieUpMaterial (data) {
   return Promise.reject(new Error(res.data.message));
 }
 // 查询产品已关联物料信息
-export async function getRelatesInformationList (data) {
+export async function getRelatesInformationList(data) {
   const res = await request.post(
     `/main/category/getRelatesInformationList`,
     data
@@ -20,7 +20,7 @@ export async function getRelatesInformationList (data) {
   return Promise.reject(new Error(res.data.message));
 }
 // 查询未关联产品物料信息
-export async function unassociated (data) {
+export async function unassociated(data) {
   const res = await request.post(`/main/category/unassociated`, data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -28,9 +28,8 @@ export async function unassociated (data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 获取产品bom信息
-export async function getCategoryBom (categoryId) {
+export async function getCategoryBom(categoryId) {
   const res = await request.get(`/main/category/getCategoryBom/${categoryId}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -39,7 +38,7 @@ export async function getCategoryBom (categoryId) {
 }
 
 // 周转车 货位
-export async function categoryVehicle (data) {
+export async function categoryVehicle(data) {
   const res = await request.post(`/main/categoryvehicle/save`, data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -47,7 +46,7 @@ export async function categoryVehicle (data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-export async function categoryVehicleList (id) {
+export async function categoryVehicleList(id) {
   const res = await request.get(`/main/categoryvehicle/getByCategoryId/${id}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -57,7 +56,7 @@ export async function categoryVehicleList (id) {
 
 // 干燥区 库位
 
-export async function aridRegion (data) {
+export async function aridRegion(data) {
   const res = await request.post(`/main/aridregion/save`, data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -65,7 +64,7 @@ export async function aridRegion (data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-export async function aridRegionList (id) {
+export async function aridRegionList(id) {
   const res = await request.get(`/main/aridregion/getByCategoryId/${id}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -74,11 +73,23 @@ export async function aridRegionList (id) {
 }
 // 修改物品采购员
 
-export async function updateCheckPersonAndGroup (data) {
-  const res = await request.post(`/main/category/updateCheckPersonAndGroup`, data);
+export async function updateCheckPersonAndGroup(data) {
+  const res = await request.post(
+    `/main/category/updateCheckPersonAndGroup`,
+    data
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
+// 修改物品默认仓库
+
+export async function updatewarehouseId(data) {
+  const res = await request.post(`/main/category/updatewarehouseId`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 12 - 0
src/api/warehouseManagement/index.js

@@ -477,5 +477,17 @@ export default {
       return res.data.data;
     }
     return Promise.reject(new Error(res.data.message));
+  },
+  /**
+   * 查询仓库列表
+   */
+  getWarehouseList: async (data) => {
+    const res = await request.post(`/wms/warehouse/select/warehouseList`, {
+      params: { status: 1 }
+    });
+    if (res.data.code == 0) {
+      return res.data.data;
+    }
+    return Promise.reject(new Error(res.data.message));
   }
 };

+ 18 - 0
src/views/material/product/components/WarehouseInfo.vue

@@ -121,6 +121,18 @@
             </div>
           </el-form-item>
         </el-col>
+        <el-col :span="8">
+          <el-form-item label="默认仓库" prop="warehouseId">
+            <el-select v-model="form.warehouseId"  style="width: 100%">
+              <el-option
+                v-for="item in warehouseList"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
+            </el-select>
+            
+          </el-form-item>
+        </el-col>
       </el-row>
       <div class="rules_box">
         <el-button type="primary" @click="addPackingRules"
@@ -277,6 +289,7 @@
   import personSelect from '@/components/CommomSelect/person-select.vue';
   import { deletePackageDisposition } from '@/api/material/list.js';
   import { getCode } from '@/api/codeManagement/index.js';
+  import storage from '@/api/warehouseManagement/index.js';
   export default {
     components: { deptSelect, personSelect },
     props: {
@@ -397,6 +410,7 @@
             value: 'KG'
           }
         ],
+        warehouseList: [],
         hasPushed: false
       };
     },
@@ -414,6 +428,10 @@
       if (this.packageDispositionVOList.length == 0) {
         this.hasPushed = false;
       }
+      storage.getWarehouseList().then((res) => {
+        console.log(res, '仓库列表');
+        this.warehouseList = res;
+      });
       console.log(this.hasPushed, 'has');
     },
     mounted() {},

+ 17 - 1
src/views/material/product/components/index-data.vue

@@ -93,6 +93,16 @@
         >
           设置采购员
         </el-button>
+        <el-button
+          size="small"
+          :disabled="selection.length == 0"
+          icon="el-icon-thumb"
+          class="ele-btn-icon"
+          @click="warehouseOpen"
+          v-if="$hasPermission('main:category:update')"
+        >
+          设置默认仓库
+        </el-button>
         <!-- <el-button
           v-if="rootTreeId == 9"
           size="small"
@@ -287,6 +297,7 @@
     <!-- 产品管理 -->
     <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
     <DialogMoveTo ref="DialogMoveToRef" @success="success"></DialogMoveTo>
+    <warehouseDialog ref="warehouseDialogRef" @success="success"></warehouseDialog>
   </div>
 </template>
 
@@ -313,6 +324,7 @@
   import importDialog from '@/components/upload/import-dialogNew.vue';
   import { fieldModel } from '@/api/codeManagement';
   import DialogMoveTo from './DialogMoveTo.vue';
+  import warehouseDialog from './warehouseDialog.vue';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import { produceTypeList } from '@/enum/dict.js';
   import request from '@/utils/request';
@@ -371,7 +383,7 @@
       goodsAllocation,
       aridRegion,
       BomDetailsPop,
-      DialogMoveTo
+      DialogMoveTo,warehouseDialog
     },
     props: {
       // 物料组id
@@ -770,6 +782,10 @@
       moveTo() {
         this.$refs.DialogMoveToRef.open(this.selection);
       },
+      //仓库
+      warehouseOpen() {
+        this.$refs.warehouseDialogRef.open(this.selection);
+      },
       successUpload(response) {
         this.isLoading = false;
       },

+ 89 - 0
src/views/material/product/components/warehouseDialog.vue

@@ -0,0 +1,89 @@
+<template>
+  <div class="dialog-moveto">
+    <el-dialog
+      title="设置默认仓库"
+      :visible.sync="dialogVisible"
+      width="30%"
+      class="fullscreen"
+    >
+      <div class="form">
+        <el-form
+          label-width="120px"
+          :rules="rules"
+          :model="addForm"
+          ref="form"
+          class="ele-form-search"
+        >
+          <el-form-item label="仓库名称" prop="warehouseId">
+            <el-select v-model="addForm.warehouseId" style="width: 100%">
+              <el-option
+                v-for="item in warehouseList"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-form>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisible = false">取 消</el-button>
+        <el-button type="primary" @click="submit" :loading="loading"
+          >确 定</el-button
+        >
+      </span>
+    </el-dialog>
+  </div>
+</template>
+<script>
+  import storage from '@/api/warehouseManagement/index.js';
+  import { updatewarehouseId } from '@/api/material/product.js';
+
+  export default {
+    components: {},
+    data() {
+      return {
+        dialogVisible: false,
+        addForm: {},
+        loading: false,
+        selection: [],
+        warehouseList: [],
+        rules: {
+          warehouseId: [
+            { required: true, message: '请选择仓库', trigger: 'blur' }
+          ]
+        }
+      };
+    },
+    methods: {
+      submit() {
+        this.$refs.form.validate(async (flag) => {
+          if (flag) {
+            try {
+              this.loading = true;
+              updatewarehouseId({
+                id: this.selection.map((item) => item.id),
+                warehouseId: this.addForm.warehouseId
+              });
+              this.$message.success('成功!');
+              this.dialogVisible = false;
+              this.$emit('success', true);
+            } finally {
+              this.loading = false;
+            }
+          } else {
+            return false;
+          }
+        });
+      },
+
+      open(arr) {
+        storage.getWarehouseList().then((res) => {
+          this.warehouseList = res;
+        });
+        this.selection = arr;
+        this.addForm = {};
+        this.dialogVisible = true;
+      }
+    }
+  };
+</script>

+ 10 - 5
src/views/material/product/detail.vue

@@ -1039,11 +1039,16 @@
           let modeHight = modelArr[2]?.substr(0, modelArr[2].indexOf('mm')); // model规格高度
           modeHight = Number(modeHight);
           let volume = (modelLong * modeWide * modeHight) / 1000;
-          this.$set(
-            this.form,
-            'netWeight',
-            parseFloat((volume * 7.85) / 1000).toFixed(4)
-          );
+          if (volume) {
+            this.$set(
+              this.form,
+              'netWeight',
+              parseFloat((volume * 7.85) / 1000).toFixed(4)
+            );
+          }else{
+            this.$set(this.form, 'netWeight', 0);
+          }
+
           this.$nextTick(() => {
             // this.$refs.warehouseRefs &&
             //   this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);