Parcourir la source

生产备料: 快捷出库

lxf il y a 1 an
Parent
commit
8915ceb3aa

+ 9 - 65
src/views/production/operation/batching/index.vue

@@ -12,19 +12,15 @@
             :loading="loading"
             :searchConfig="searchConfig"
             highlight-current-row
-            :table-events="{
-              select: selectRow,
-              'select-all': selectRow,
-            }"
             :action-list="[
               {
                 text: '打印备料单',
                 action: () => outExcel(),
               },
-              // {
-              //   text: '快捷出库',
-              //   action: () => clickQuickDelivery(),
-              // },
+              {
+                text: '快捷出库',
+                action: () => clickQuickDelivery(),
+              },
             ]"
             @get-list="getList"
             @clickReset="clickReset">
@@ -32,9 +28,6 @@
 
           <table class="table-class" border="0" cellpadding="0" cellspacing="0">
             <tr>
-              <th style="width: 48px">
-                <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange"> </el-checkbox>
-              </th>
               <th style="width: 200px">BOM品号</th>
               <th style="min-width: 320px">BOM品名</th>
               <th style="width: 200px">SKU品号</th>
@@ -43,16 +36,6 @@
             </tr>
             <tbody v-for="(item, index) in sourceList.data" :key="index">
               <tr v-for="(itemSKU, indexSKU) in item.skuInfoList" :key="indexSKU">
-                <td v-if="indexSKU === 0" :rowspan="item.skuInfoList.length">
-                  <el-checkbox
-                    v-model="item.isCheck"
-                    :data-a="isCheck"
-                    @change="
-                      (val) => {
-                        return changeCheck(val, item, index);
-                      }
-                    "></el-checkbox>
-                </td>
                 <td v-if="indexSKU === 0" :rowspan="item.skuInfoList.length">{{ item.bomSpecCode }}</td>
                 <td v-if="indexSKU === 0" :rowspan="item.skuInfoList.length">{{ item.bomSpecName }}</td>
                 <td>{{ itemSKU.skuSpecCode }}</td>
@@ -103,7 +86,7 @@
               <td style="width: 10%; text-align: center">数量总计</td>
             </tr>
           </thead>
-          <tbody v-for="(item, index) in selectData" :key="index">
+          <tbody v-for="(item, index) in sourceList.data" :key="index">
             <tr v-for="(itemSKU, indexSKU) in item.skuInfoList" :key="indexSKU">
               <td :rowspan="item.skuInfoList.length" v-if="indexSKU === 0" style="text-align: center">{{ index + 1 }}</td>
               <td :rowspan="item.skuInfoList.length" v-if="indexSKU === 0">{{ item.bomSpecCode }}</td>
@@ -122,14 +105,13 @@
     </el-dialog>
 
     <el-dialog title="快捷出库" v-if="openQuick" v-model="openQuick" width="90%">
-      <Quick :selectData="sourceList.data" @clickCancel="clickCancel"></Quick>
+      <Quick :pagination="sourceList.pagination" @clickCancel="clickCancel"></Quick>
     </el-dialog>
   </div>
 </template>
 
 <script setup>
 import byTable from "@/components/byTable/index";
-import { ElMessage } from "element-plus";
 import moment from "moment";
 import Quick from "@/views/production/operation/batching/quick";
 
@@ -143,8 +125,6 @@ const sourceList = ref({
     bomSpecName: "",
     skuSpecCode: "",
     skuSpecName: "",
-    departmentId: "",
-    warehouseName: "",
     departmentId: "1689164627162529793",
   },
 });
@@ -162,7 +142,6 @@ const sourceListTwo = ref({
     skuSpecCode: "",
     skuSpecName: "",
     departmentId: "",
-    warehouseName: "",
     width: "",
   },
 });
@@ -366,8 +345,6 @@ const configTwo = computed(() => {
 const getList = async (req, status) => {
   if (status) {
     sourceList.value.pagination = {
-      pageNum: sourceList.value.pagination.pageNum,
-      pageSize: sourceList.value.pagination.pageSize,
       departmentId: "1689164627162529793",
     };
   } else {
@@ -375,7 +352,6 @@ const getList = async (req, status) => {
   }
   loading.value = true;
   proxy.post("/stockPreparation/uncompletedList", sourceList.value.pagination).then((res) => {
-    selectData.value = [];
     if (res && res.length > 0) {
       sourceList.value.data = Object.freeze(
         res.map((item) => {
@@ -440,22 +416,14 @@ const getDemandData = () => {
   });
 };
 getDemandData();
-const selectData = ref([]);
-const selectRow = (data) => {
-  selectData.value = data;
-};
 const openFile = (path) => {
   window.open(path);
 };
 const openPrint = ref(false);
 const printTime = ref("");
 const outExcel = () => {
-  if (selectData.value && selectData.value.length > 0) {
-    printTime.value = moment().format("yyyy-MM-DD HH:mm:ss");
-    openPrint.value = true;
-  } else {
-    return ElMessage("请勾选需要打印备料单的数据");
-  }
+  printTime.value = moment().format("yyyy-MM-DD HH:mm:ss");
+  openPrint.value = true;
 };
 const printObj = ref({
   id: "printMe",
@@ -465,11 +433,7 @@ const printObj = ref({
 });
 const openQuick = ref(false);
 const clickQuickDelivery = () => {
-  if (sourceList.value.data && sourceList.value.data.length > 0) {
-    openQuick.value = true;
-  } else {
-    return ElMessage("列表暂无数据");
-  }
+  openQuick.value = true;
 };
 const clickCancel = (status) => {
   openQuick.value = false;
@@ -477,26 +441,6 @@ const clickCancel = (status) => {
     getList();
   }
 };
-const checkAll = ref(false);
-const isIndeterminate = ref(false);
-const handleCheckAllChange = (val) => {
-  sourceList.value.data = sourceList.value.data.map((item) => {
-    return {
-      ...item,
-      isCheck: val,
-    };
-  });
-  selectData.value = sourceList.value.data.filter((item) => item.isCheck);
-  isIndeterminate.value = false;
-};
-const isCheck = ref(false);
-const changeCheck = () => {
-  isCheck.value = !isCheck.value;
-  selectData.value = sourceList.value.data.filter((item) => item.isCheck);
-  const checkedCount = selectData.value.length;
-  checkAll.value = checkedCount === sourceList.value.data.length;
-  isIndeterminate.value = checkedCount > 0 && checkedCount < sourceList.value.data.length;
-};
 </script>
 
 <style lang="scss" scoped>

+ 55 - 231
src/views/production/operation/batching/quick.vue

@@ -2,56 +2,37 @@
   <div>
     <el-card class="box-card" v-loading="loading">
       <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+        <template #basicInformation>
+          <div style="width: 100%">
+            <el-row>
+              <el-col :span="12">
+                <el-form-item label="事业部" prop="outDepartmentId" style="width: 100%; margin-bottom: 18px">
+                  <el-select v-model="formData.data.outDepartmentId" placeholder="请选择事业部" style="width: 100%" @change="changeDepartment">
+                    <el-option v-for="item in departmentList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
+                  </el-select>
+                </el-form-item>
+                <el-form-item label="申请人" prop="applicant" style="width: 100%; margin-bottom: 18px">
+                  <el-input v-model="formData.data.applicant" placeholder="请输入申请人" />
+                </el-form-item>
+              </el-col>
+              <el-col :span="12">
+                <el-form-item label="备注" prop="remark" style="width: 100%; margin-bottom: 18px">
+                  <el-input v-model="formData.data.remark" :rows="4" type="textarea" placeholder="请输入备注" />
+                </el-form-item>
+              </el-col>
+            </el-row>
+          </div>
+        </template>
         <template #inOutStorageBomList>
           <div style="width: 100%; padding: 0 20px">
-            <div style="margin-bottom: 10px">{{ statisticalQuantity() }}</div>
-            <el-table :data="formData.data.inOutStorageBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
-              <el-table-column type="expand">
-                <template #default="props">
-                  <div style="padding: 0 80px 0 50px">
-                    <el-table
-                      :data="props.row.orderList"
-                      :cell-style="{ padding: '0' }"
-                      :row-style="{ height: '35px' }"
-                      v-loading="loading"
-                      header-row-class-name="tableHeader">
-                      <el-table-column label="订单号" prop="orderCode" width="200" />
-                      <el-table-column label="万里牛单号" prop="orderWlnCode" width="140" />
-                      <el-table-column label="SKU品号" prop="skuSpecCode" width="180" />
-                      <el-table-column label="SKU品名" prop="skuSpecName" min-width="180" />
-                      <el-table-column label="出库数量" width="140">
-                        <template #default="{ row }">
-                          <span>{{ row.quantity }}</span>
-                        </template>
-                      </el-table-column>
-                    </el-table>
-                  </div>
-                </template>
-              </el-table-column>
-              <el-table-column label="品号" prop="bomSpecCode" width="180" />
-              <el-table-column label="品名" prop="bomSpecName" min-width="220" />
-              <el-table-column label="仓库" width="160">
-                <template #default="{ row, $index }">
-                  <el-form-item :prop="'inOutStorageBomList.' + $index + '.warehouseId'" :rules="rules.warehouseId" :inline-message="true" style="width: 100%">
-                    <el-select
-                      v-model="row.warehouseId"
-                      placeholder="请选择仓库"
-                      clearable
-                      style="width: 100%"
-                      @change="
-                        (val) => {
-                          return changeWarehouse(val, row, $index);
-                        }
-                      ">
-                      <el-option v-for="item in warehouseList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
-                    </el-select>
-                  </el-form-item>
-                </template>
-              </el-table-column>
-              <el-table-column label="剩余库存" prop="surplusStock" width="120" />
+            <el-table :data="inOutStorageBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
+              <el-table-column label="BOM品号" prop="bomSpecCode" width="180" />
+              <el-table-column label="BOM品名" prop="bomSpecName" min-width="220" />
+              <el-table-column label="仓库名称" prop="warehouseName" width="160" />
+              <el-table-column label="剩余库存" prop="inventoryQuantity" width="120" />
               <el-table-column label="出库数量" width="140">
                 <template #default="{ row }">
-                  <span :style="row.surplusStock && row.surplusStock < row.quantity ? 'color: red' : ''">{{ row.quantity }}</span>
+                  <span :style="!row.inventoryQuantity || row.inventoryQuantity < row.outQuantity ? 'color: red' : ''">{{ row.outQuantity }}</span>
                 </template>
               </el-table-column>
             </el-table>
@@ -73,9 +54,8 @@ import { ElMessage } from "element-plus";
 const { proxy } = getCurrentInstance();
 const departmentList = ref([{ dictKey: "0", dictValue: "胜德体育" }]);
 const props = defineProps({
-  selectData: Array,
+  pagination: Object,
 });
-const warehouseList = ref([]);
 const submit = ref(null);
 const formOption = reactive({
   inline: true,
@@ -86,13 +66,27 @@ const formOption = reactive({
 });
 const formData = reactive({
   data: {
-    inOutStorageBomList: [],
+    // departmentId: props.departmentId,
+    outDepartmentId: "0",
+    applicant: proxy.useUserStore().user.nickName,
+    ...props.pagination,
   },
 });
+const inOutStorageBomList = ref([]);
 const formConfig = computed(() => {
   return [
     {
       type: "title",
+      title: "出库信息",
+      label: "",
+    },
+    {
+      type: "slot",
+      slotName: "basicInformation",
+      label: "",
+    },
+    {
+      type: "title",
       title: "物料信息",
       label: "",
     },
@@ -104,7 +98,8 @@ const formConfig = computed(() => {
   ];
 });
 const rules = ref({
-  warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
+  outDepartmentId: [{ required: true, message: "请选择事业部", trigger: "change" }],
+  applicant: [{ required: true, message: "请输入申请人", trigger: "blur" }],
 });
 const getDemandData = () => {
   proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
@@ -122,27 +117,17 @@ const getDemandData = () => {
 };
 getDemandData();
 const emit = defineEmits(["clickCancel"]);
-const duplicateRemoval = (arr) => {
-  let list = [];
-  return arr.filter((item) => !list.includes(item) && list.push(item));
-};
 const loading = ref(false);
 const submitForm = () => {
   submit.value.handleSubmit(() => {
-    if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
-      for (let i = 0; i < formData.data.inOutStorageBomList.length; i++) {
-        if (Number(formData.data.inOutStorageBomList[i].surplusStock) < Number(formData.data.inOutStorageBomList[i].quantity)) {
+    if (inOutStorageBomList.value && inOutStorageBomList.value.length > 0) {
+      for (let i = 0; i < inOutStorageBomList.value.length; i++) {
+        if (Number(inOutStorageBomList.value[i].inventoryQuantity) < Number(inOutStorageBomList.value[i].outQuantity)) {
           return ElMessage("出库数量大于剩余库存数量");
         }
       }
       loading.value = true;
-      let orderList = [];
-      for (let j = 0; j < formData.data.inOutStorageBomList.length; j++) {
-        if (formData.data.inOutStorageBomList[j].orderList && formData.data.inOutStorageBomList[j].orderList.length > 0) {
-          orderList = orderList.concat(formData.data.inOutStorageBomList[j].orderList.map((itemOrder) => itemOrder.orderSkuId));
-        }
-      }
-      proxy.post("/stockPreparation/submit", duplicateRemoval(orderList)).then(
+      proxy.post("/stockPreparation/submit", formData.data).then(
         () => {
           ElMessage({ message: "提交完成", type: "success" });
           emit("clickCancel", true);
@@ -160,176 +145,15 @@ const submitForm = () => {
 const clickCancel = () => {
   emit("clickCancel", false);
 };
-const delSomeObjValue = (arr, keyName, valueName) => {
-  const idArr = []; // 相同的id放在同一数组中
-  const resultArr = []; // 最终结果数组
-  for (let i = 0; i < arr.length; i++) {
-    const index = idArr.indexOf(arr[i][keyName]);
-    if (index > -1) {
-      resultArr[index][valueName] += Number(arr[i][valueName]); //取相同id的value累加
-    } else {
-      idArr.push(arr[i][keyName]);
-      resultArr.push(arr[i]);
-    }
-  }
-  return resultArr;
-};
-const getWarehouse = () => {
-  return proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
-    if (res.rows && res.rows.length > 0) {
-      warehouseList.value = res.rows
-        .filter((item) => ["2", "3"].includes(item.type))
-        .map((item) => {
-          return {
-            dictKey: item.id,
-            dictValue: item.name,
-          };
-        });
-    }
-  });
-};
 onMounted(() => {
-  Promise.all([getWarehouse()]).then(async () => {
-    if (props.selectData && props.selectData.length > 0) {
-      formData.data.inOutStorageBomList = delSomeObjValue(
-        props.selectData.map((item) => {
-          let num = 0;
-          if (item.quantity) {
-            num = Number(item.quantity);
-          }
-          return {
-            bomSpecId: item.bomSpecId,
-            quantity: num,
-            bomSpecName: item.bomSpecName,
-            bomSpecCode: item.bomSpecCode,
-            warehouseId: "",
-            surplusStock: 0,
-          };
-        }),
-        "bomSpecId",
-        "quantity"
-      ).map((item) => {
-        return {
-          ...item,
-          orderList: props.selectData
-            .map((item) => {
-              let num = 0;
-              if (item.quantity) {
-                num = Number(item.quantity);
-              }
-              return {
-                bomSpecId: item.bomSpecId,
-                quantity: num,
-                orderSkuId: item.orderSkuId,
-                orderCode: item.orderCode,
-                orderWlnCode: item.orderWlnCode,
-                skuSpecCode: item.skuSpecCode,
-                skuSpecName: item.skuSpecName,
-              };
-            })
-            .filter((itemSelect) => itemSelect.bomSpecId === item.bomSpecId),
-        };
-      });
-      let orderList = [];
-      for (let j = 0; j < formData.data.inOutStorageBomList.length; j++) {
-        if (formData.data.inOutStorageBomList[j].orderList && formData.data.inOutStorageBomList[j].orderList.length > 0) {
-          orderList = orderList.concat(formData.data.inOutStorageBomList[j].orderList.map((itemOrder) => itemOrder.orderSkuId));
-        }
-      }
-      const a = await proxy.post("/stockPreparation/getPackageBomList", orderList).then((res) => {
-        if (res && res.length > 0) {
-          formData.data.inOutStorageBomList = formData.data.inOutStorageBomList.concat(res);
-        }
-      });
-      if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
-        let bomSpecIdList = [];
-        bomSpecIdList = formData.data.inOutStorageBomList.map((item) => item.bomSpecId);
-        proxy
-          .post("/inventory/getQuantity", {
-            departmentId: "0",
-            warehouseId: warehouseList.value[0].dictKey,
-            bomSpecIdList: bomSpecIdList,
-          })
-          .then((resInventory) => {
-            let bomSpecIdTwoList = [];
-            for (let i = 0; i < formData.data.inOutStorageBomList.length; i++) {
-              if (resInventory[formData.data.inOutStorageBomList[i].bomSpecId]) {
-                formData.data.inOutStorageBomList[i].warehouseId = warehouseList.value[0].dictKey;
-                formData.data.inOutStorageBomList[i].surplusStock = resInventory[formData.data.inOutStorageBomList[i].bomSpecId];
-              } else {
-                bomSpecIdTwoList.push(formData.data.inOutStorageBomList[i].bomSpecId);
-              }
-            }
-            if (bomSpecIdTwoList && bomSpecIdTwoList.length > 0) {
-              proxy
-                .post("/inventory/getQuantity", {
-                  departmentId: "0",
-                  warehouseId: warehouseList.value[1].dictKey,
-                  bomSpecIdList: bomSpecIdTwoList,
-                })
-                .then((inventoryTwo) => {
-                  for (let i = 0; i < formData.data.inOutStorageBomList.length; i++) {
-                    if (inventoryTwo[formData.data.inOutStorageBomList[i].bomSpecId]) {
-                      formData.data.inOutStorageBomList[i].warehouseId = warehouseList.value[1].dictKey;
-                      formData.data.inOutStorageBomList[i].surplusStock = inventoryTwo[formData.data.inOutStorageBomList[i].bomSpecId];
-                    }
-                  }
-                });
-            }
-          });
-      }
-    }
+  proxy.post("/stockPreparation/outBomList", formData.data).then((res) => {
+    inOutStorageBomList.value = Object.freeze(res);
   });
 });
-const changeWarehouse = (val, item, index) => {
-  if (val) {
-    proxy
-      .post("/inventory/getQuantity", {
-        departmentId: "0",
-        warehouseId: val,
-        bomSpecIdList: [item.bomSpecId],
-      })
-      .then((res) => {
-        if (res[item.bomSpecId]) {
-          formData.data.inOutStorageBomList[index].surplusStock = res[item.bomSpecId];
-        } else {
-          formData.data.inOutStorageBomList[index].surplusStock = 0;
-        }
-      });
-  } else {
-    formData.data.inOutStorageBomList[index].surplusStock = 0;
-  }
-};
-const statisticalQuantity = () => {
-  let quantity = 0;
-  let material = {};
-  if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
-    for (let i = 0; i < formData.data.inOutStorageBomList.length; i++) {
-      if (formData.data.inOutStorageBomList[i].orderList && formData.data.inOutStorageBomList[i].orderList.length > 0) {
-        if (formData.data.inOutStorageBomList[i].quantity) {
-          quantity = Number(Math.round(quantity + formData.data.inOutStorageBomList[i].quantity));
-        }
-      } else {
-        if (material[formData.data.inOutStorageBomList[i].bomClassifyId]) {
-          material[formData.data.inOutStorageBomList[i].bomClassifyId].quantity = Number(
-            Math.round(material[formData.data.inOutStorageBomList[i].bomClassifyId].quantity + formData.data.inOutStorageBomList[i].quantity)
-          );
-        } else {
-          material[formData.data.inOutStorageBomList[i].bomClassifyId] = {
-            name: formData.data.inOutStorageBomList[i].bomClassifyName,
-            quantity: formData.data.inOutStorageBomList[i].quantity,
-          };
-        }
-      }
-    }
-  }
-  let text = "主材数量: " + quantity;
-  for (let key in material) {
-    if (key && material[key].name) {
-      text = text + ", " + material[key].name + ": " + material[key].quantity;
-    }
-  }
-  return text;
+const changeDepartment = () => {
+  proxy.post("/stockPreparation/outBomList", formData.data).then((res) => {
+    inOutStorageBomList.value = Object.freeze(res);
+  });
 };
 </script>