Browse Source

手动出库BUG

lxf 2 years ago
parent
commit
001f8f0f08

+ 28 - 20
src/views/purchaseSales/outAndInWarehouse/inventoryInquiry/index.vue

@@ -9,12 +9,20 @@
         :selectConfig="selectConfig"
         highlight-current-row
         :action-list="[
-          {
-            text: '导出Excel',
-            action: () => deriveExcel(),
-          },
+          selectStatus
+            ? {}
+            : {
+                text: '导出Excel',
+                action: () => deriveExcel(),
+              },
         ]"
         @get-list="getList">
+        <template #btn="{ item }">
+          <div style="width: 100%; text-align: center">
+            <el-button type="primary" @click="checkTheFlow(item)" v-if="!selectStatus" text>查看流水</el-button>
+            <el-button type="primary" @click="clickSelect(item)" v-else text>选择</el-button>
+          </div>
+        </template>
       </byTable>
     </div>
   </div>
@@ -25,6 +33,10 @@ import { computed, ref } from "vue";
 import byTable from "@/components/byTable/index";
 
 const { proxy } = getCurrentInstance();
+const props = defineProps({
+  selectStatus: Boolean,
+  warehouseId: String,
+});
 const warehouseList = ref([]);
 const sourceList = ref({
   data: [],
@@ -38,6 +50,9 @@ const sourceList = ref({
 });
 const loading = ref(false);
 const selectConfig = computed(() => {
+  if (props.warehouseId) {
+    return [];
+  }
   return [
     {
       label: "仓库名称",
@@ -103,24 +118,11 @@ const config = computed(() => {
     {
       attrs: {
         label: "操作",
-        width: "100",
+        slot: "btn",
+        width: 120,
+        fixed: "right",
         align: "center",
       },
-      renderHTML(row) {
-        return [
-          {
-            attrs: {
-              label: "查看流水",
-              type: "primary",
-              text: true,
-            },
-            el: "button",
-            click() {
-              checkTheFlow(row);
-            },
-          },
-        ];
-      },
     },
   ];
 });
@@ -139,6 +141,9 @@ const getDict = () => {
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
+  if (props.warehouseId) {
+    sourceList.value.pagination.id = props.warehouseId;
+  }
   proxy.post("/stock/page", sourceList.value.pagination).then((res) => {
     sourceList.value.data = res.rows;
     sourceList.value.pagination.total = res.total;
@@ -160,6 +165,9 @@ const checkTheFlow = (item) => {
 const deriveExcel = () => {
   console.log("deriveExcel");
 };
+const clickSelect = (item) => {
+  proxy.$emit("select", item);
+};
 </script>
 
 <style lang="scss" scoped>

+ 54 - 32
src/views/purchaseSales/outAndInWarehouse/manualDelivery/index.vue

@@ -10,7 +10,7 @@
         highlight-current-row
         :action-list="[
           {
-            text: '手动',
+            text: '手动出库',
             action: () => openModal(),
           },
         ]"
@@ -18,21 +18,22 @@
       </byTable>
     </div>
 
-    <el-dialog title="手动" v-if="dialogVisible" v-model="dialogVisible" width="1000" v-loading="loadingDialog">
+    <el-dialog title="手动出库" v-if="dialogVisible" v-model="dialogVisible" width="1000" v-loading="loadingDialog">
       <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
         <template #details>
           <div style="width: 100%">
-            <el-button type="primary" @click="openProduct = true">添加明细</el-button>
+            <el-button type="primary" @click="clickAdd()">添加明细</el-button>
             <el-table :data="formData.data.list" style="width: 100%; margin-top: 16px">
               <el-table-column prop="productCode" label="产品编码" width="140" />
-              <el-table-column prop="productName" label="产品名称" min-width="220" />
-              <el-table-column prop="productSpec" label="规格型号" min-width="220" />
+              <el-table-column prop="productName" label="产品名称" min-width="160" />
+              <el-table-column prop="productSpec" label="规格型号" width="160" />
               <el-table-column prop="productUnit" label="单位" width="100" />
-              <el-table-column label="数量" width="160">
+              <el-table-column prop="productQuantity" label="库存数量" width="120" />
+              <el-table-column label="出库数量" width="160">
                 <template #default="{ row, $index }">
                   <div style="width: 100%">
                     <el-form-item :prop="'list.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
-                      <el-input-number v-model="row.quantity" placeholder="请输入数量" style="width: 100%" :precision="0" :controls="false" :min="0" />
+                      <el-input-number v-model="row.quantity" placeholder="请输入出库数量" style="width: 100%" :precision="0" :controls="false" :min="0" />
                     </el-form-item>
                   </div>
                 </template>
@@ -52,8 +53,8 @@
       </template>
     </el-dialog>
 
-    <el-dialog v-model="openProduct" title="选择商品" width="70%" append-to-body>
-      <SelectGoods @cancel="openProduct = false" @pushGoods="pushGoods"></SelectGoods>
+    <el-dialog v-model="openProduct" title="选择商品" width="80%" append-to-body>
+      <InventoryInquiry :selectStatus="true" :warehouseId="formData.data.warehouseId" @cancel="openProduct = false" @select="select"></InventoryInquiry>
     </el-dialog>
   </div>
 </template>
@@ -63,7 +64,7 @@ import { computed, ref } from "vue";
 import byTable from "@/components/byTable/index";
 import byForm from "@/components/byForm/index";
 import { ElMessage } from "element-plus";
-import SelectGoods from "@/components/product/SelectGoods";
+import InventoryInquiry from "@/views/purchaseSales/outAndInWarehouse/inventoryInquiry/index";
 
 const { proxy } = getCurrentInstance();
 const warehouseList = ref([]);
@@ -127,7 +128,7 @@ const config = computed(() => {
     },
     {
       attrs: {
-        label: "数量",
+        label: "出库数量",
         prop: "quantity",
         width: 140,
       },
@@ -197,16 +198,20 @@ const formConfig = computed(() => {
       label: "仓库名称",
       required: true,
       data: warehouseList.value,
+      fn: () => {
+        changeWarehouse();
+      },
     },
     {
       type: "slot",
       slotName: "details",
-      label: "明细",
+      label: "出库明细",
     },
   ];
 });
 const rules = ref({
   warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
+  quantity: [{ required: true, message: "请输入出库数量", trigger: "blur" }],
 });
 const openModal = () => {
   formData.data = {
@@ -216,31 +221,48 @@ const openModal = () => {
   loadingDialog.value = false;
   dialogVisible.value = true;
 };
-const pushGoods = (goods) => {
-  if (goods && goods.length > 0) {
-    formData.data.list = formData.data.list.concat(
-      goods.map((item) => {
-        return {
-          productCode: item.code,
-          productId: item.id,
-          productName: item.name,
-          productSpec: item.spec,
-          productUnit: item.unit,
-          quantity: undefined,
-        };
-      })
-    );
-    ElMessage({
-      message: "添加成功!",
-      type: "success",
-    });
-    openProduct.value = false;
+const clickAdd = () => {
+  if (formData.data.warehouseId) {
+    openProduct.value = true;
   } else {
-    ElMessage("请选择至少一件产品");
+    ElMessage("请先选择仓库");
+  }
+};
+const changeWarehouse = () => {
+  formData.data.list = [];
+};
+const select = (item) => {
+  if (formData.data.list && formData.data.list.length > 0) {
+    let data = formData.data.list.filter((row) => row.productId === item.productId);
+    if (data && data.length > 0) {
+      return ElMessage("请勿重复添加");
+    }
   }
+  formData.data.list.push({
+    productCode: item.productCode,
+    productId: item.productId,
+    productName: item.productName,
+    productSpec: item.productSpec,
+    productUnit: item.productUnit,
+    productQuantity: item.quantity,
+    quantity: undefined,
+  });
+  ElMessage({
+    message: "添加成功!",
+    type: "success",
+  });
 };
 const submitForm = () => {
   submit.value.handleSubmit(() => {
+    if (formData.data.list && formData.data.list.length > 0) {
+      for (let i = 0; i < formData.data.list.length; i++) {
+        if (formData.data.list[i].productQuantity < formData.data.list[i].quantity) {
+          return ElMessage("出库数量不能大于库存数量");
+        }
+      }
+    } else {
+      return ElMessage("请添加出库产品");
+    }
     loadingDialog.value = true;
     proxy.post("/stock/edit", formData.data).then(
       () => {

+ 0 - 1
src/views/purchaseSales/outAndInWarehouse/record/index.vue

@@ -153,7 +153,6 @@ const config = computed(() => {
         return proxy.dictValueLabel(type, typeList.value);
       },
     },
-
     {
       attrs: {
         label: "仓库名称",