ezhizao_zx 5 місяців тому
батько
коміт
df2d56fd65

+ 11 - 1
src/api/business/lot.js

@@ -38,7 +38,7 @@ export function getProcessList(query) {
   return request({
     url: baseUrl + '/business/lot/getProcessList',
     method: 'get',
-    params:query
+    params: query
   })
 }
 
@@ -85,6 +85,16 @@ export function getLastLot(query) {
     params: query
   })
 }
+
+// 查找最后一个编号
+export function getLastLotBeforeGen(query) {
+  return request({
+    url: baseUrl + '/business/lot/getLastLotBeforeGen',
+    method: 'get',
+    params: query
+  })
+}
+
 // 修改计划查询
 export function updateLot(data) {
   return request({

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

@@ -73,6 +73,15 @@ export function savePlanDetailSubDetail(data) {
   })
 }
 
+// 新增生产子计划明细 根据投产数量生成批次
+export function savePlanDetailSubDetailByNumber(data) {
+  return request({
+    url: baseUrl + '/business/planDetailSubDetail/saveByNumber',
+    method: 'post',
+    data: data
+  })
+}
+
 // 修改生产子计划明细
 export function updatePlanDetailSubDetail(data) {
   return request({

+ 1 - 0
src/permission.js

@@ -15,6 +15,7 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register'];
 
 router.beforeEach((to, from, next) => {
   NProgress.start()
+  useSettingsStore().initGenLotBySub()
   if (getToken()) {
     to.meta.title && useSettingsStore().setTitle(to.meta.title)
     /* has token*/

+ 9 - 1
src/store/modules/settings.js

@@ -1,5 +1,6 @@
 import defaultSettings from '@/settings'
 import { useDynamicTitle } from '@/utils/dynamicTitle'
+import { getConfigKey } from '@/api/system/config'
 
 const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings
 
@@ -17,7 +18,8 @@ const useSettingsStore = defineStore(
       tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
       fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
       sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
-      dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle
+      dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle,
+      genLotBySub: false
     }),
     actions: {
       // 修改布局设置
@@ -31,6 +33,12 @@ const useSettingsStore = defineStore(
       setTitle(title) {
         this.title = title
         useDynamicTitle();
+      },
+      initGenLotBySub(config) {
+        getConfigKey('business.production.genLotBySub').then(res => {
+          // console.log(res)
+          this.genLotBySub = res.msg == 'true'
+        })
       }
     }
   })

+ 35 - 14
src/views/business/productionBatch/form.vue

@@ -50,12 +50,15 @@
 <script setup>
 import {
   savePlanDetailSubDetail,
+  savePlanDetailSubDetailByNumber,
   getLastLotStatus,
 } from "@/api/business/planDetailSubDetail.js";
+import useSettingsStore from '@/store/modules/settings'
 import { updateLotCodeStatus } from "@/api/business/productionPlanDetail.js";
 import formComputedMaterial from "./computedMaterialForm.vue"
 const { proxy } = getCurrentInstance();
 const emit = defineEmits(["handleSaveSuccess"]);
+const genLotBySub = useSettingsStore().genLotBySub
 
 /** 表单抽屉 页变量 */
 const loading = ref(false);
@@ -292,21 +295,39 @@ function handleSave() {
     if (valid) {
       // /**工艺版本变成P2拉取过来先绑定个假数据 */
       buttonLoading.value = true
-      savePlanDetailSubDetail(form.value).then((res) => {
-        buttonLoading.value = false
-        if (res.code == 200) {
-          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) => { });
+      if (!genLotBySub) {
+        savePlanDetailSubDetail(form.value).then((res) => {
+          buttonLoading.value = false
+          if (res.code == 200) {
+            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");
           }
-          emit("handleSaveSuccess");
-        }
-      });
+        });
+      } else {
+        savePlanDetailSubDetailByNumber(form.value).then((res) => {
+          buttonLoading.value = false
+          if (res.code == 200) {
+            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");
+          }
+        });
+      }
     }
   });
 }

+ 99 - 168
src/views/business/productionBatch/lotInfoForm.vue

@@ -1,15 +1,11 @@
 <template>
-  <el-drawer
-    title="批次信息"
-    :with-header="false"
-    v-model="visible"
-    direction="rtl"
-    size="100%"
-  >
+  <el-drawer title="批次信息" :with-header="false" v-model="visible" direction="rtl" size="100%">
     <div class="page-container form-container">
       <div class="form-btns-container">
         <span class="title-label">
-          <el-icon><Document /></el-icon>
+          <el-icon>
+            <Document />
+          </el-icon>
           <span>批次信息</span>
         </span>
         <el-button type="primary" @click="handleSave()"> 保存 </el-button>
@@ -42,14 +38,11 @@
               <span class="rightInfo">{{ detailInfo.productionQuantity }}</span>
             </el-col>
           </el-row>
-          <el-row
-            :gutter="20"
-            style="
+          <el-row :gutter="20" style="
               margin-top: 15px;
               padding-bottom: 10px;
               border-bottom: 1px solid #999;
-            "
-          >
+            ">
             <el-col :span="4">
               <span class="leftInfo">总批数</span>
               <span class="rightInfo">{{ detailInfo.totalLotNumber }}</span>
@@ -76,10 +69,11 @@
 
           <el-row :gutter="20" style="margin-top: 15px; margin-bottom: 15px">
             <el-col :span="6">
-              <el-button type="primary"  v-hasPermi="['business:productionBatch:addLot']" @click="handleAdd()">
+              <el-button type="primary" v-hasPermi="['business:productionBatch:addLot']" @click="handleAdd()">
                 追增批次
               </el-button>
-              <el-button type="danger"  v-hasPermi="['business:productionBatch:removeLot']" @click="handleMultiplyDelete()">
+              <el-button type="danger" v-hasPermi="['business:productionBatch:removeLot']"
+                @click="handleMultiplyDelete()">
                 删除
               </el-button>
             </el-col>
@@ -87,113 +81,47 @@
         </div>
       </div>
       <div class="el-table-container">
-        <el-table
-          v-loading="loading"
-          :data="lotList"
-          size="small"
-          border
-          height="100%%"
-          @selection-change="handleSelectionChange"
-        >
+        <el-table v-loading="loading" :data="lotList" size="small" border height="100%%"
+          @selection-change="handleSelectionChange">
           <el-table-column type="selection" width="40" align="center" />
-          <el-table-column
-            type="index"
-            label="序号"
-            width="50"
-            align="center"
-          />
-          <el-table-column
-            label="批次号"
-            prop="lotCode"
-            align="center"
-            width="200px"
-          >
+          <el-table-column type="index" label="序号" width="50" align="center" />
+          <el-table-column label="批次号" prop="lotCode" align="center" width="200px">
             <template #default="scope">
-              <el-button v-if="scope.row.id!=null"
-                link
-                type="primary"
-                @click="handleColumnClick(scope.row.lotCode)"
-                ><span>{{ scope.row.lotCode }}</span></el-button
-              >
+              <el-button v-if="scope.row.id != null" link type="primary"
+                @click="handleColumnClick(scope.row.lotCode)"><span>{{ scope.row.lotCode }}</span></el-button>
               <span v-else>{{ scope.row.lotCode }}</span>
             </template>
           </el-table-column>
-          <el-table-column
-            label="投产量"
-            align="center"
-            prop="productionQuantity"
-            width="200px"
-          >
-       <template #default="scope">
-        <el-input-number v-if="scope.row.editStatus"
-                v-model="scope.row.productionQuantity"
-                style="width: 200px"
-                :min="0"
-                :max="99999"
-                :precision="0"
-                controls-position="right"
-              />
+          <el-table-column label="投产量" align="center" prop="productionQuantity" width="200px">
+            <template #default="scope">
+              <el-input-number v-if="scope.row.editStatus" v-model="scope.row.productionQuantity" style="width: 200px"
+                :min="0" :max="99999" :precision="0" controls-position="right" />
               <span v-else>{{ scope.row.productionQuantity }}</span>
-       </template>
-      </el-table-column>
-          <el-table-column
-            label="追增批次"
-            align="center"
-            prop="isSuperaddition"
-            width="200"
-          >
+            </template>
+          </el-table-column>
+          <el-table-column label="追增批次" align="center" prop="isSuperaddition" width="200">
             <template #default="scope">
-              <dict-tag
-                :options="yes_no"
-                :value="scope.row.isSuperaddition"
-              /> </template
-          ></el-table-column>
+              <dict-tag :options="yes_no" :value="scope.row.isSuperaddition" /> </template></el-table-column>
           <el-table-column label="标识" align="center">
             <template #default="scope">
-              <el-tag
-                v-if="scope.row.isWaste == 1"
-                class="spacing"
-                type="danger"
-                >{{ "批废" }}</el-tag
-              >
-              <el-tag
-                v-if="scope.row.isAmend == 1"
-                class="spacing"
-                type="danger"
-                >{{ "工艺修改" }}</el-tag
-              >
-              <el-tag
-                v-if="scope.row.isWasteRecycling == 1"
-                class="spacing"
-                type="primary"
-                >{{ "废品回用" }}</el-tag
-              >
-              <el-tag v-if="scope.row.fromId !=null&&scope.row.fromId != 0  " class="spacing" type="warning">{{ "分批" }}</el-tag>
+              <el-tag v-if="scope.row.isWaste == 1" class="spacing" type="danger">{{ "批废" }}</el-tag>
+              <el-tag v-if="scope.row.isAmend == 1" class="spacing" type="danger">{{ "工艺修改" }}</el-tag>
+              <el-tag v-if="scope.row.isWasteRecycling == 1" class="spacing" type="primary">{{ "废品回用" }}</el-tag>
+              <el-tag v-if="scope.row.fromId != null && scope.row.fromId != 0" class="spacing" type="warning">{{ "分批"
+                }}</el-tag>
             </template>
           </el-table-column>
           <el-table-column label="操作" width="200px" align="center">
             <template #default="scope">
-              <el-button
-                v-if="
-                  !scope.row.editStatus &&
-                  scope.row.isSuperaddition == 1 &&
-                  !scope.row.hasDaywork
-                "
-                link
-                type="primary"
-                v-hasPermi="['business:productionBatch:editLot']"
-                @click="handleUpDate(scope.row)"
-                >修改</el-button
-              >
-              <el-button
-                v-if="scope.row.isSuperaddition == 1 &&
-                  !scope.row.hasDaywork"
-                link
-                type="danger"
-                v-hasPermi="['business:productionBatch:removeLot']"
-                @click="handleDelete(scope.row)"
-                >删除</el-button
-              >
+              <el-button v-if="
+                !scope.row.editStatus &&
+                scope.row.isSuperaddition == 1 &&
+                !scope.row.hasDaywork
+              " link type="primary" v-hasPermi="['business:productionBatch:editLot']"
+                @click="handleUpDate(scope.row)">修改</el-button>
+              <el-button v-if="scope.row.isSuperaddition == 1 &&
+                !scope.row.hasDaywork" link type="danger" v-hasPermi="['business:productionBatch:removeLot']"
+                @click="handleDelete(scope.row)">删除</el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -205,7 +133,7 @@
 </template>
 
 <script setup>
-import { getAllLot,getLastLot } from "@/api/business/lot.js";
+import { getAllLot, getLastLot, getLastLotBeforeGen } from "@/api/business/lot.js";
 import { addLot } from "@/api/business/productionPlanDetail.js";
 import router from "@/router";
 import addLotDialog from "./DialogAddLot.vue"
@@ -251,63 +179,63 @@ function handleMultiplyDelete() {
       flag = false
       proxy.$modal.msgError("不能删除不是追加的批次");
       return;
-    }else{
-    if(item.hasDaywork) {
-      flag = false
-      proxy.$modal.msgError(item.lotCode+"有投产,不能删除");
-      return
+    } else {
+      if (item.hasDaywork) {
+        flag = false
+        proxy.$modal.msgError(item.lotCode + "有投产,不能删除");
+        return
+      }
     }
-  }
   });
-  if(flag) {
-   lotList.value = lotList.value.filter(
+  if (flag) {
+    lotList.value = lotList.value.filter(
       (item) => !selections.value.some((selectedItem) => selectedItem === item))
-      getLastLotCode()
-      //判断列表的追加批次是不是都删完了,如果曾经有,但是删完了,则添加追加批次时的批次号做判断
-      lotList.value.findIndex(item => item.isSuperaddition == 1) == -1 ? hadSuperaddition.value = true : hadSuperaddition.value = false
-      detailInfo.value.superadditionTotalNumber =  detailInfo.value.superadditionTotalNumber - selections.value.length
-   }
+    getLastLotCode()
+    //判断列表的追加批次是不是都删完了,如果曾经有,但是删完了,则添加追加批次时的批次号做判断
+    lotList.value.findIndex(item => item.isSuperaddition == 1) == -1 ? hadSuperaddition.value = true : hadSuperaddition.value = false
+    detailInfo.value.superadditionTotalNumber = detailInfo.value.superadditionTotalNumber - selections.value.length
+  }
 }
 function getLastLotCode() {
   const maxLotCodeObj = lotList.value.reduce((max, current) => {
-  // 提取每个lotCode中间的三位数,并转换为数字
-  const maxCode = parseInt(max.lotCode.substr(8, 3), 10);
-  const currentCode = parseInt(current.lotCode.substr(8, 3), 10);
-  // 比较并返回具有最大值的对象
-  return currentCode > maxCode ? current : max;
-});
+    // 提取每个lotCode中间的三位数,并转换为数字
+    const maxCode = parseInt(max.lotCode.substr(8, 3), 10);
+    const currentCode = parseInt(current.lotCode.substr(8, 3), 10);
+    // 比较并返回具有最大值的对象
+    return currentCode > maxCode ? current : max;
+  });
 
-// 输出最大的lotCode
-console.log(maxLotCodeObj.lotCode);
-lastLot.value = maxLotCodeObj.lotCode
+  // 输出最大的lotCode
+  console.log(maxLotCodeObj.lotCode);
+  lastLot.value = maxLotCodeObj.lotCode
 }
 //删除
 function handleDelete(row) {
   if (row.isSuperaddition == 0) {
-      proxy.$modal.msgError("不能删除不是追加的批次");
-      return;
-    }else{
-    if(row.hasDaywork) {
-      proxy.$modal.msgError(row.lotCode+"有投产,不能删除");
+    proxy.$modal.msgError("不能删除不是追加的批次");
+    return;
+  } else {
+    if (row.hasDaywork) {
+      proxy.$modal.msgError(row.lotCode + "有投产,不能删除");
       return
-    }else{
+    } else {
       lotList.value.splice(lotList.value.indexOf(row), 1);
       getLastLotCode()
       lotList.value.findIndex(item => item.isSuperaddition == 1) == -1 ? hadSuperaddition.value = true : hadSuperaddition.value = false
-      detailInfo.value.superadditionTotalNumber =  detailInfo.value.superadditionTotalNumber - 1
+      detailInfo.value.superadditionTotalNumber = detailInfo.value.superadditionTotalNumber - 1
     }
   }
 }
 //修改
 function handleUpDate(row) {
- row.editStatus = true
+  row.editStatus = true
 }
 
 function getLotList(row) {
   loading.value = true;
-  getAllLot({id:row.id}).then((res) => {
+  getAllLot({ id: row.id }).then((res) => {
     if (res.code == 200) {
-      res.data.forEach(item =>{
+      res.data.forEach(item => {
         item.editStatus = false
       })
       lotList.value = res.data;
@@ -319,31 +247,31 @@ function getLotList(row) {
 function handleSave() {
   let superadditionList = lotList.value.filter(item => item.isSuperaddition == 1)
   let flag = true
-  superadditionList.forEach(item =>{
-    if(item.productionQuantity ==0) {
+  superadditionList.forEach(item => {
+    if (item.productionQuantity == 0) {
       flag = false
-      proxy.$modal.msgError(item.lotCode+"追加批次投产数量不能为0");
-    }
-  })
-  if(flag) {
-  detailInfo.value.lotList = superadditionList
-  console.log(detailInfo.value)
-  addLot(detailInfo.value).then((res) => {
-    if (res.code == 200) {
-      proxy.$modal.msgSuccess("保存成功");
-      emit("handleSaveSuccess");
-      visible.value = false;
+      proxy.$modal.msgError(item.lotCode + "追加批次投产数量不能为0");
     }
   })
+  if (flag) {
+    detailInfo.value.lotList = superadditionList
+    console.log(detailInfo.value)
+    addLot(detailInfo.value).then((res) => {
+      if (res.code == 200) {
+        proxy.$modal.msgSuccess("保存成功");
+        emit("handleSaveSuccess");
+        visible.value = false;
+      }
+    })
   }
 }
 //追加批次
 function handleAdd() {
   //判断如果此时已经追加了,但没保存
-  if(lotList.value.findIndex(item => item.id == null) > -1 ||hadSuperaddition.value) {
+  if (lotList.value.findIndex(item => item.id == null) > -1 || hadSuperaddition.value) {
     proxy.$refs.addLotDialogRef.open(lastLot.value)
-  }else {
-    getLastLot({
+  } else {
+    getLastLotBeforeGen({
       productionPlanDetailId: detailInfo.value.id,
     }).then((res) => {
       if (res.code == 200) {
@@ -356,12 +284,14 @@ function handleAdd() {
 //批次带回
 function handleAddLotNum(data) {
   lastLot.value = data[data.length - 1]
-  detailInfo.value.superadditionTotalNumber =  detailInfo.value.superadditionTotalNumber + data.length
+  detailInfo.value.superadditionTotalNumber = detailInfo.value.superadditionTotalNumber + data.length
   console.log(data)
-  data.forEach(item =>{
-    lotList.value.unshift({id:null,lotCode:item,productionQuantity:detailInfo.value.oneLotQuantity,isSuperaddition:1, editStatus: true,
-      productionPlanDetailId:detailInfo.value.id,technologicalProcessId:detailInfo.value.technologicalProcessId,
-      technologyVersion:detailInfo.value.technologyVersion,productId:detailInfo.value.productId})
+  data.forEach(item => {
+    lotList.value.unshift({
+      id: null, lotCode: item, productionQuantity: detailInfo.value.oneLotQuantity, isSuperaddition: 1, editStatus: true,
+      productionPlanDetailId: detailInfo.value.id, technologicalProcessId: detailInfo.value.technologicalProcessId,
+      technologyVersion: detailInfo.value.technologyVersion, productId: detailInfo.value.productId
+    })
   })
 }
 /** 打开批次详情页 */
@@ -380,20 +310,21 @@ defineExpose({
   width: 120px;
   display: inline-block;
 }
+
 .middleInfo {
   font-size: 16px;
   width: 120px;
   display: inline-block;
 }
+
 .rightInfo {
   font-size: 16px;
   padding-left: 20px;
 }
-:deep(
-    .column-container > .el-drawer__wrapper .el-drawer__body,
-    .column-container .el-drawer__body,
-    .row-container .el-drawer__body
-  ) {
+
+:deep(.column-container > .el-drawer__wrapper .el-drawer__body,
+  .column-container .el-drawer__body,
+  .row-container .el-drawer__body) {
   padding: 8px;
   margin-bottom: 20px;
 }