guoyujia 1 vuosi sitten
vanhempi
commit
5a389fae2d

+ 8 - 0
src/api/business/planDetailSubDetail.js

@@ -20,6 +20,14 @@ export function getPlanDetailSubDetail(id) {
   })
 }
 
+//查询生产子计划是否含有尾批
+export function getLastLotStatus(id) {
+  return request({
+    url: baseUrl + '/business/planDetailSubDetail/getLastLotStatus/' + id,
+    method: 'get'
+  })
+}
+
 // 登陆人员工段
 export function getDept() {
   return request({

+ 9 - 0
src/api/business/productionPlanDetail.js

@@ -39,6 +39,15 @@ export function updateProductionPlanDetail(data) {
   })
 }
 
+//修改生产计划批号状态
+export function updateLotCodeStatus(data) {
+  return request({
+    url: baseUrl + '/business/productionPlanDetail/updateLotCodeStatus',
+    method: 'put',
+    data: data
+  })
+}
+
 // 删除生产计划明细
 export function delProductionPlanDetail(id) {
   return request({

+ 1 - 1
src/views/business/daywork/index.vue

@@ -21,7 +21,7 @@
           <el-table ref="dayworkTable" :data="dayworkList" v-loading="dayworkLoading" highlight-current-row height="100%" @current-change="handleDayworkCurrentChange">
             <el-table-column label="客户简称" prop="companyAlias" width="160" align="center" />
             <el-table-column label="生产计划单号" prop="productionPlanNo" width="100" align="center" />
-            <el-table-column label="批次号" prop="lotCode" width="100" align="center" />
+            <el-table-column label="批次号" prop="lotCode" width="120" align="center" />
             <el-table-column label="产品描述" prop="productDescription" align="center" />
             <el-table-column label="图纸版本" prop="technologyVersion" width="60" align="center" />
             <el-table-column label="投产量" prop="productionQuantity" width="60" align="center" />

+ 11 - 11
src/views/business/equipment/index.vue

@@ -4,14 +4,14 @@
     <section class="list-part-container" style="flex: 1">
       <!-- 搜索区域 -->
       <el-form class="list-search-container" :inline="true" style="display: flex;padding-right: 0px;">
-        <el-form-item class="section-title" label="设备类别" />
-        <el-form-item style="margin-left: 40px;">
+        <el-form-item class="section-title" label="设备类别"/>
+        <el-form-item style="margin: 0 10px 0 20px ;">
            <el-button type="primary" icon="Plus" v-hasPermi="['business:equipment:add']" @click="handleShowEquipmentCategoryDialog(null)">
           新增
         </el-button>
         </el-form-item>
         <el-form-item label="设备类别名称:">
-          <el-input placeholder="请输入设备类别名称" v-model.trim="queryEquipmentCategoryParams.name" @keydown.enter.prevent @keyup.enter="handleRefreshEquipmentCategory" clearable style="width: 220px" />
+          <el-input placeholder="请输入设备类别名称" v-model.trim="queryEquipmentCategoryParams.name" @keydown.enter.prevent @keyup.enter="handleRefreshEquipmentCategory" clearable style="width: 210px" />
         </el-form-item>
         <el-form-item>
           <el-button type="info" icon="Search" @click="handleRefreshEquipmentCategory">搜索</el-button>
@@ -42,13 +42,13 @@
     <!-- 右侧区域 -->
     <section class="list-part-container" style="flex: 2">
       <!-- 搜索区域 -->
-      <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true" style="display: flex;">
-        <el-form-item class="section-title" label="设备档案管理" />
-        <el-form-item>
+      <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true" style="display: flex;padding-right: 0px;">
+        <el-form-item class="section-title" label="设备档案管理" style="margin-right: 0px;" />
+        <el-form-item style="margin: 0 10px 0 10px ;" >
           <el-button type="primary" icon="Plus" @click="handleShowEquipmentDocDialog(null)" v-hasPermi="['business:equipment:add']">新增</el-button>
-        </el-form-item>
-        <el-form-item label="设备名称:">
-          <el-input placeholder="请输入设备名称" v-model.trim="queryParams.keywords" @keydown.enter.prevent @keyup.enter="handleRefreshEquipment" clearable style="width: 180px" />
+        </el-form-item >
+        <el-form-item label="设备名称:" >
+          <el-input placeholder="请输入设备名称" v-model.trim="queryParams.keywords" @keydown.enter.prevent @keyup.enter="handleRefreshEquipment" clearable style="width: 120px" />
         </el-form-item>
         <el-form-item>
           <el-button type="info" icon="Search" @click="handleRefreshEquipment">搜索</el-button>
@@ -62,8 +62,8 @@
         <div class="el-table-inner-container">
           <el-table ref="equipmentTable" v-loading="equipmentLoading" :data="equipmentList" height="100%">
             <el-table-column label="行号" type="index" width="50" align="center" />
-            <el-table-column label="设备名称" prop="equipmentName" width="220" align="center" header-align="center" />
-            <el-table-column label="设备规格" prop="standard" width="150" align="center" />
+            <el-table-column label="设备名称" prop="equipmentName" width="200" align="center" header-align="center" />
+            <el-table-column label="设备规格" prop="standard" width="130" align="center" />
             <el-table-column label="设备数量" prop="equipmentNumber" width="80" align="center" />
             <el-table-column label="备注" prop="remark" align="center" />
             <el-table-column label="操作" width="220" align="center">

+ 107 - 18
src/views/business/productionBatch/form.vue

@@ -4,7 +4,7 @@
     title="投产"
     height="400px"
     v-model="visible"
-    width="800px"
+    width="900px"
     append-to-body
     draggable
   >
@@ -24,10 +24,10 @@
             <el-form-item label="当前投产批数" prop="lotNumber">
               <el-input-number
                 v-model="form.lotNumber"
-                :precision="0"
                 controls-position="right"
                 style="width: 150px"
                 @input="handleUpdateLotNumber"
+                :min="0"
               />
             </el-form-item>
             <el-form-item label="下达日期" prop="issuanceDate">
@@ -49,10 +49,24 @@
               <el-input-number
                 v-model="form.productionQuantity"
                 :precision="0"
+                :disabled="true"
                 controls-position="right"
                 style="width: 150px"
               />
             </el-form-item>
+            <el-form-item label="尾批" style="align-items: center;" prop="lastLotStatus">  
+              <el-switch
+                v-model="form.lastLotStatus"
+                :disabled ="detailsRow.lastLot || detailsRow.status"
+                size="large"
+                style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
+                active-text="是"
+                inactive-text="否"
+                active-value="1"
+                inactive-value="0"
+                @change="handleUpdateLastLotStatus"
+              />
+            </el-form-item>
           </el-col>
         </el-row>
       </el-form>
@@ -66,8 +80,9 @@
   </el-dialog>
 </template>
 <script setup>
-import { savePlanDetailSubDetail } from "@/api/business/planDetailSubDetail.js";
+import { savePlanDetailSubDetail,getLastLotStatus } from "@/api/business/planDetailSubDetail.js";
 import { listPlanDetailSubDetail } from "@/api/business/planDetailSubDetail.js";
+import { updateLotCodeStatus } from "@/api/business/productionPlanDetail.js";
 
 const { proxy } = getCurrentInstance();
 const emit = defineEmits(["handleSaveSuccess"]);
@@ -79,7 +94,9 @@ const visible = ref(false);
 const validateLotNumber = (rule, value, callback) => {
   const min = 0;
   const max = detailsRow.value.lotNumber;
-  if (value <= min) {
+  if (!Number.isInteger(value)) {
+    callback(new Error(`当前投产批数不能是小数`));
+  } else if (value <= min) {
     callback(new Error("当前投产批数应大于0"));
   } else if (value > max) {
     callback(new Error(`当前投产批数不能超过` + max));
@@ -88,7 +105,12 @@ const validateLotNumber = (rule, value, callback) => {
   }
 };
 const validateproductionQuantity = (rule, value, callback) => {
-  const max = detailsRow.value.productionQuantity;
+  if(form.value.lastLotStatus == 1) {
+    var max = detailsRow.value.productionQuantity + detailsRow.value.lastLotQuantity;
+  }
+  else {
+    var max = detailsRow.value.productionQuantity;
+  }
   if (value <= 0) {
     callback(new Error("当前投产量应大于0"));
   } else if (value > max) {
@@ -97,6 +119,23 @@ const validateproductionQuantity = (rule, value, callback) => {
     callback();
   }
 };
+const validateSwitch = (rule, value, callback) => {
+  if(detailsRow.value.status) {
+    callback();
+  }
+  else {
+  if(form.value.lastLotStatus == 0) {
+      if (form.value.lotNumber + detailsRow.value.lotTotalNumber == detailsRow.value.totalLotNumber && !detailsRow.value.lastLot) {
+        callback(new Error('此次投产应选尾批'));
+      } else {
+        callback();
+      }
+    }
+    else {
+        callback();
+      }
+    }
+  }
 const data = reactive({
   form: {
     deptId: null,
@@ -114,6 +153,10 @@ const data = reactive({
       { required: true, message: "当前投产量不能为空", trigger: "blur" },
       { validator: validateproductionQuantity, trigger: "blur" },
     ],
+    lastLotStatus: [
+          { required: false, message: '请选择是否尾批', trigger: ['change', 'blur'] },
+          { validator: validateSwitch, trigger: 'blur' }, // 使用自定义验证函数进行验证
+        ],
   },
 });
 const { form, rules } = toRefs(data);
@@ -132,18 +175,19 @@ function reset() {
     productionQuantity: 0,
     issuanceDate: proxy.moment().format("YYYY-MM-DD"),
     remark: null,
+    lastLotStatus: 0,
   };
   proxy.resetForm("productRef");
 }
 
 /** 打开抽屉 */
-function open(row, Info) {
+function open(row) {
   reset();
   visible.value = true;
   loading.value = true;
-
   if (row) {
     detailsRow.value = proxy.deepClone(row);
+    console.log(detailsRow.value)
     form.value.id = row.id;
     form.value.productionPlanNo = row.productionPlanNo;
     form.value.productionPlanDetailId = row.productionPlanDetailId;
@@ -151,35 +195,76 @@ function open(row, Info) {
     form.value.deptId = row.deptId;
     form.value.technologicalProcessId = row.technologicalProcessId;
     form.value.technologyVersion = row.technologyVersion;
+    form.value.lastLotStatus = row.lastLotStatus
     if (typeof row.pickUpQuantity === "undefined") {
       detailsRow.value.pickUpQuantity = 0;
     }
     if (typeof row.lotTotalNumber === "undefined") {
-      detailsRow.value.lotTotalNumber = 0
+      detailsRow.value.lotTotalNumber = 0;
     }
     //通过editStatus判断是否是编辑状态
     if (row.status) {
       form.value.lotNumber = row.lotNumber;
-      detailsRow.value.lotNumber = detailsRow.value.totalLotNumber - detailsRow.value.lotTotalNumber + row.lotNumber;
+      detailsRow.value.lotNumber =
+        detailsRow.value.totalLotNumber -
+        detailsRow.value.lotTotalNumber +
+        row.lotNumber;
       form.value.productionQuantity = row.productionQuantity;
-      detailsRow.value.productionQuantity =detailsRow.value.productionQuantityTotal - detailsRow.value.pickUpQuantity + detailsRow.value.productionQuantity;
+      if(detailsRow.value.lastLot) {
+        detailsRow.value.productionQuantity = detailsRow.value.productionQuantityTotal - detailsRow.value.pickUpQuantity + detailsRow.value.productionQuantity ;
+      }
+      else {
+          detailsRow.value.productionQuantity = detailsRow.value.productionQuantityTotal - detailsRow.value.pickUpQuantity + detailsRow.value.productionQuantity - detailsRow.value.lastLotQuantity;
+      }
+    
     } else {
       detailsRow.value.lotNumber = detailsRow.value.totalLotNumber - detailsRow.value.lotTotalNumber;
-      detailsRow.value.productionQuantity = detailsRow.value.productionQuantityTotal - detailsRow.value.pickUpQuantity
+        //子计划已经有尾批
+        if(detailsRow.value.lastLot) {
+          detailsRow.value.productionQuantity =
+        detailsRow.value.productionQuantityTotal -
+        detailsRow.value.pickUpQuantity 
+        console.log(detailsRow.value.productionQuantity)
+        }
+        else {
+           detailsRow.value.productionQuantity =
+        detailsRow.value.productionQuantityTotal -
+        detailsRow.value.pickUpQuantity - detailsRow.value.lastLotQuantity;
+        }
+        
+     
     }
   }
   loading.value = false;
 }
 
-
 function handleUpdateLotNumber(data) {
-  if (data * detailsRow.value.oneLotQuantity >  detailsRow.value.productionQuantity) {
-    form.value.productionQuantity = detailsRow.value.productionQuantity
-  }
-  else {
-    form.value.productionQuantity = data * detailsRow.value.oneLotQuantity;
-  }
+  if (data <= 0) {
+    form.value.productionQuantity = 0;
+  } else {
+    //该批为尾批
+    if(form.value.lastLotStatus == 1) {
+      if ((data-1) * detailsRow.value.oneLotQuantity >detailsRow.value.productionQuantity) {
+      form.value.productionQuantity = detailsRow.value.productionQuantity + detailsRow.value.lastLotQuantity;
+    } else {
+      form.value.productionQuantity = (data-1) * detailsRow.value.oneLotQuantity + detailsRow.value.lastLotQuantity ;
+    }
+    
+    }
+    else{
+      if (data * detailsRow.value.oneLotQuantity >detailsRow.value.productionQuantity) {
+      form.value.productionQuantity = detailsRow.value.productionQuantity;
+    } else {
+      form.value.productionQuantity = data * detailsRow.value.oneLotQuantity;
+    }
+   
+    }
   }
+}
+
+function handleUpdateLastLotStatus () {
+  handleUpdateLotNumber(form.value.lotNumber)
+}
 
 /** 提交按钮 */
 function handleSave() {
@@ -191,6 +276,10 @@ function handleSave() {
           proxy.$modal.msgSuccess("保存成功!");
           visible.value = false;
           //detailsRow.value.id = detailsRow.value.productionPlanDetailId
+          if(detailsRow.value.lotTotalNumber == 0) {
+            updateLotCodeStatus({ id: detailsRow.value.productionPlanDetailId, lotCodeStatusCode: 'OKK' }).then((res) => {
+            })
+          }
           emit("handleSaveSuccess");
         }
       });

+ 27 - 6
src/views/business/productionBatch/index.vue

@@ -7,7 +7,7 @@
         <!-- <el-form-item label="生产计划单号:">
           <el-input placeholder="请输入生产计划单号" v-model.trim="queryParams.keywords" @keyup.enter="handleQuery" @keydown.enter.prevent clearable style="width: 200px" />
         </el-form-item> -->
-        <el-form-item label="产品描述:">
+        <el-form-item label="产品描述">
           <el-input placeholder="请输入产品描述" v-model.trim="queryParams.keywords" @keyup.enter="handleQuery" @keydown.enter.prevent clearable style="width: 200px" />
         </el-form-item>
 
@@ -52,7 +52,7 @@
             <el-table-column label="下达日期" prop="issueDate" width="120" align="center" />
             <el-table-column label="操作" width="70" align="center" fixed="right">
               <template #default="scope">
-                <el-button link type="primary" icon="Postcard" @click="handleAddSubDetail(scope.row)" v-hasPermi="['business:productionBatch:add']">投产 </el-button>
+                <el-button link type="primary" icon="Postcard" @click="handleAddSubDetail(scope.row)" :disabled="scope.row.totalLotNumber == scope.row.lotTotalNumber" v-hasPermi="['business:productionBatch:add']">投产 </el-button>
               </template>
             </el-table-column>
           </el-table>
@@ -158,9 +158,10 @@
 <script setup name="ProductionBatch">
 import { ref } from 'vue'
 import { listProductionPlanDetail } from '@/api/business/productionPlanDetail.js'
-import { savePlanDetailSubDetail, listPlanDetailSubDetail, delPlanDetailSubDetail, getDept } from '@/api/business/planDetailSubDetail.js'
+import { savePlanDetailSubDetail, listPlanDetailSubDetail, delPlanDetailSubDetail, getDept,getLastLotStatus } from '@/api/business/planDetailSubDetail.js'
 import { saveBatchEquipment, listEquipment, delEquipment } from '@/api/business/productionPlanDetailEquipment.js'
 import { listTechnologicalProcessDetail } from '@/api/business/technologicalProcessDetail.js'
+import { updateLotCodeStatus } from "@/api/business/productionPlanDetail.js";
 import equipment from '@/views/dialog/equipment.vue'
 import productionLotForm from './form'
 const { proxy } = getCurrentInstance()
@@ -289,7 +290,6 @@ function handlePlanDetailCurrentChange(row) {
     }).then((res) => {
       subList.value = res.rows
       subDetailsLoading.value = false
-
       if (subList.value.length > 0) {
         proxy.$refs.subDetailsTable.setCurrentRow(subList.value[0])
       }
@@ -367,8 +367,18 @@ function handleAddSubDetail(row) {
   newDetail.technologyVersion = row.technologyVersion
   newDetail.pickUpQuantity = row.pickUpQuantity
   newDetail.lotTotalNumber = row.lotTotalNumber
- newDetail.status = false
-  proxy.$refs.productionRef.open(newDetail)
+  newDetail.lastLotQuantity = row.lastLotQuantity
+  newDetail.status = false
+  
+            //新增时查询生产子计划数据
+            getLastLotStatus(row.id).then((response) => {
+          if(response.code == 200) {
+            //如果为true,生产子计划已有尾批
+            newDetail.lastLot = response.data 
+               proxy.$refs.productionRef.open(newDetail)
+          }
+        })
+  
 }
 
 /** 修改 生产子计划 事件 */
@@ -383,7 +393,12 @@ function handleShowSubDetailDialog(row) {
   row.productionQuantityTotal = currentPlanDetail.value.productionQuantity
   //生产计划总批数
   row.totalLotNumber = currentPlanDetail.value.totalLotNumber
+  //生产计划尾批数
+  row.lastLotQuantity = currentPlanDetail.value.lastLotQuantity
+  //生产计划id
+  row.productionPlanDetailId = currentPlanDetail.value.id
   row.status = true
+  row.lastLot = false
    proxy.$refs.productionRef.open(row)
 }
 
@@ -401,12 +416,18 @@ function handleSaveSubDetail(row) {
 /** 删除子计划事件 */
 function handleDelSubDetail(row) {
   const _ids = row.id || ids.value
+  var subInfo = subList.value.filter(item => !item.id.includes(_ids));
   proxy.$modal
     .confirm('是否确认删除选中的数据项?')
     .then(function () {
       return delPlanDetailSubDetail(_ids)
     })
     .then(() => {
+      if(subInfo.length == 0) {
+        updateLotCodeStatus({ id: currentPlanDetail.value.id, lotCodeStatusCode: 'NA' }).then((res) => {
+         
+            })
+      }
       handleFresh()
       //handlePlanDetailCurrentChange(currentPlanDetail.value)
 

+ 1 - 1
src/views/business/productionPlan/index.vue

@@ -33,7 +33,7 @@
     <!-- 搜索区 -->
     <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true">
       <el-form-item label="计划单号:">
-        <el-input placeholder="请输入计划单号" @keydown.enter.prevent @keyup.enter="handleQuery" clearable v-model.trim="queryParams.productionPlanNo" />
+        <el-input placeholder="请输入计划单号" @keydown.enter.prevent @keyup.enter="handleQuery" clearable v-model.trim="queryParams.productionPlanNo" style="width: 160px" />
       </el-form-item>
       <el-form-item label="状态:">
         <el-select-v2 v-model="queryParams.status" clearable filterable :options="plan_status" placeholder="全部状态" @change="handleQuery" style="width: 120px" />