Selaa lähdekoodia

Merge branch 'master' of http://120.46.159.163:7400/ezhizao/ezhizao_dms_vue

wangxin 1 vuosi sitten
vanhempi
commit
ed5243c562
2 muutettua tiedostoa jossa 134 lisäystä ja 30 poistoa
  1. 30 14
      src/api/business/lot.js
  2. 104 16
      src/views/business/lot/InBatchesDialog.vue

+ 30 - 14
src/api/business/lot.js

@@ -4,7 +4,7 @@ const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API
 // 查询计划查询列表
 export function listLot(query) {
   return request({
-    url: baseUrl +'/business/lot/list',
+    url: baseUrl + '/business/lot/list',
     method: 'get',
     params: query
   })
@@ -12,7 +12,7 @@ export function listLot(query) {
 // 根据生产计划查询批次
 export function getLotInfo(query) {
   return request({
-    url: baseUrl +'/business/lot/getLotInfo',
+    url: baseUrl + '/business/lot/getLotInfo',
     method: 'get',
     params: query
   })
@@ -21,7 +21,7 @@ export function getLotInfo(query) {
 //通过批次号查批次信息
 export function getLotInfoByLotCode(data) {
   return request({
-    url: baseUrl +'/business/lot/getLotInfoByLotCode',
+    url: baseUrl + '/business/lot/getLotInfoByLotCode',
     method: 'post',
     data: data
   })
@@ -30,7 +30,7 @@ export function getLotInfoByLotCode(data) {
 // 查询计划查询详细
 export function getLot(id) {
   return request({
-    url: baseUrl +'/business/lot/' + id,
+    url: baseUrl + '/business/lot/' + id,
     method: 'get'
   })
 }
@@ -38,17 +38,17 @@ export function getLot(id) {
 // 查询批次查询详细
 export function getLotList(query) {
   return request({
-    url:baseUrl + '/business/lot/getLotList',
+    url: baseUrl + '/business/lot/getLotList',
     method: 'get',
-    params:query
+    params: query
   })
 }
 //保存废品回用
 export function addWasteRecycling(data) {
   return request({
-    url:baseUrl + '/business/lot/addWasteRecycling',
+    url: baseUrl + '/business/lot/addWasteRecycling',
     method: 'post',
-    data:data
+    data: data
   })
 }
 
@@ -56,7 +56,7 @@ export function addWasteRecycling(data) {
 // 新增计划查询
 export function addLot(data) {
   return request({
-    url: baseUrl +'/business/lot',
+    url: baseUrl + '/business/lot',
     method: 'post',
     data: data
   })
@@ -64,7 +64,7 @@ export function addLot(data) {
 // 新增计划查询
 export function getProcess(data) {
   return request({
-    url: baseUrl +'/business/lot/getProcess',
+    url: baseUrl + '/business/lot/getProcess',
     method: 'post',
     data: data
   })
@@ -73,7 +73,7 @@ export function getProcess(data) {
 //查找对应计划单下最后一批
 export function getLastLot(query) {
   return request({
-    url: baseUrl +'/business/lot/getLastLot',
+    url: baseUrl + '/business/lot/getLastLot',
     method: 'get',
     params: query
   })
@@ -81,7 +81,7 @@ export function getLastLot(query) {
 // 修改计划查询
 export function updateLot(data) {
   return request({
-    url: baseUrl +'/business/lot',
+    url: baseUrl + '/business/lot',
     method: 'put',
     data: data
   })
@@ -90,14 +90,30 @@ export function updateLot(data) {
 // 删除计划查询
 export function delLot(id) {
   return request({
-    url: baseUrl +'/business/lot/' + id,
+    url: baseUrl + '/business/lot/' + id,
     method: 'delete'
   })
 }
 
 export function getLotInfoForInBatches(data) {
   return request({
-    url: baseUrl +'/business/lot/getLotInfoForInBatches',
+    url: baseUrl + '/business/lot/getLotInfoForInBatches',
+    method: 'post',
+    data: data
+  })
+}
+
+export function listCarriers(params) {
+  return request({
+    url: baseUrl + '/business/carrier/list',
+    method: 'get',
+    params
+  })
+}
+
+export function saveInBatches(data) {
+  return request({
+    url: baseUrl + '/business/lot/saveIsBatches',
     method: 'post',
     data: data
   })

+ 104 - 16
src/views/business/lot/InBatchesDialog.vue

@@ -54,25 +54,48 @@
               <div>{{ baseLot.prodNum }}</div>
             </el-form-item>
           </el-col>
+          <el-col :span="8">
+            <el-form-item label="工序合格数量:">
+              <div>{{ baseLot.qualifiedNum }}</div>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="当前载具:">
+              <div>{{ baseLot.carriers.map(v => v.code).join(',') }}</div>
+            </el-form-item>
+          </el-col>
           <el-col :span="24">
             <div style="display: flex; flex-direction: row;">
               <div style="line-height: 32px;">分批信息</div>
               <el-form-item label="分批数量" style="margin-bottom: 0px;">
-                <el-input-number v-model="baseLot.sparateNum" :controls="false" @blur="handleNumBlur" :max="10" />
+                <el-input-number v-model="baseLot.sparateNum" :controls="false" @blur="handleNumBlur" />
               </el-form-item>
             </div>
             <el-divider />
             <el-row v-for="(e, i) in baseLot.sparateList" :key="i">
-              <el-col :span="8">
+              <el-col :span="6">
                 <el-form-item label="分批批次号:">
                   <el-input disabled v-model="e.lotCode" />
                 </el-form-item>
               </el-col>
-              <el-col :span="8">
+              <el-col :span="5">
                 <el-form-item label="分批数量:">
                   <el-input-number v-model="e.lotNumber" :controls="false" />
                 </el-form-item>
               </el-col>
+              <el-col :span="5">
+                <el-form-item label="合格数量:">
+                  <el-input-number v-model="e.qualifiedNum" :controls="false" />
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item label="分批载具:">
+                  <el-select-v2 v-model="e.carrierSelection"
+                    :disabled="e.id === baseLot.id || baseLot.currentDept == null" multiple filterable
+                    collapse-tags-tooltip collapse-tags clearable :options="carriers" placeholder="请选择载具"
+                    style="width: 100%" />
+                </el-form-item>
+              </el-col>
             </el-row>
           </el-col>
         </el-row>
@@ -85,15 +108,20 @@
   </el-dialog>
 </template>
 <script setup>
-import { getLotInfoForInBatches } from '@/api/business/lot'
+import { getLotInfoForInBatches, listCarriers, saveInBatches } from '@/api/business/lot'
+// import {}
 const { proxy } = getCurrentInstance();
 /**工段弹窗变量 */
 const total = ref(0);
-const baseLot = ref({})
+const baseLot = ref({
+  carriers: []
+})
 const selections = ref([]);
 const visible = ref(false);
 const deptIds = ref([])
 const loading = ref(false);
+const carriers = ref([])
+const loadingCarrier = ref(true)
 /**查询对象 */
 const data = reactive({
   queryParams: {
@@ -109,18 +137,44 @@ const { queryParams } = toRefs(data);
  * 对话框打开 事件
  */
 function open(data) {
-  baseLot.value = { ...data, id: data.lotId }
+  baseLot.value = { ...data, id: data.lotId, carriers: [] }
   visible.value = true;
   loadLot();
+  getCarriers()
+}
+
+function getCarriers() {
+  listCarriers({ isAbandoned: 0 }).then(res => {
+    if (res.code === 200) {
+      carriers.value = res.rows.map(v => ({ value: v.id, label: v.code }))
+    }
+  })
 }
 
+// function remoteCarriers(queryString) {
+//   loadingCarrier.value = true
+//   listCarriers({ isAbandoned: 0, pageSize: 200, code: queryString != '' ? queryString : null }).then(res => {
+//     if (res.code === 200) {
+//       carriers.value = res.rows.map(v => ({ value: v.id, label: v.code }))
+//     } else {
+//       carriers.value = []
+//     }
+//     loadingCarrier.value = false
+//   })
+// }
+
 function loadLot() {
   getLotInfoForInBatches({ id: baseLot.value.id }).then(res => {
-    baseLot.value.issueDate = res.data.issueDate
-    baseLot.value.prodNum = res.data.prodNum
-    baseLot.value.currentDept = res.data.currentDept
-    baseLot.value.sparateList = []
-    baseLot.value.sparateNum = 0
+    if (res.code === 200) {
+      baseLot.value.issueDate = res.data.issueDate
+      baseLot.value.prodNum = res.data.prodNum
+      baseLot.value.currentDept = res.data.currentDept
+      baseLot.value.sparateList = []
+      baseLot.value.qualifiedNum = res.data.qualifiedNum
+      baseLot.value.carriers = res.data.carriers
+      baseLot.value.sparateNum = 0
+      baseLot.value.latestLotCode = res.data.latestLotCode
+    }
   })
 }
 
@@ -148,13 +202,16 @@ function handleMultipleSelected() {
 }
 
 function handleSave() {
-  console.log(baseLot.value)
+  // console.log(baseLot.value)
   // 保存时判断下分批数量和是否等于投产数量。不等要提示一下
   let num = 0
+  let qualified = 0
   baseLot.value.sparateList.forEach(e => {
     num += e.prodNum
+    qualified += e.qualifiedNum
   })
   const prodNum = !!baseLot.value.prodNum ? baseLot.value.prodNum : baseLot.value.productionQuantity
+  const qualifiedNum = !!baseLot.value.qualifiedNum ? baseLot.value.qualifiedNum : 0
   if (num != prodNum) {
     proxy.$message({
       type: 'warning',
@@ -162,34 +219,65 @@ function handleSave() {
     })
     return
   }
+  if (qualified != qualifiedNum) {
+    proxy.$message({
+      type: 'warning',
+      message: '分批合格数量需等于总合格数量'
+    })
+    return
+  }
+  const saveDate = { ...baseLot.value, sparateList: baseLot.value.sparateList.map(v => ({ ...v, carriers: v.id === baseLot.id ? v.carriers : carrierSelection.map(e => ({ id: e })) })) }
   // 提交分批结果
-
+  saveInBatches(saveDate).then(res => {
+    if (res.code === 200) {
+      proxy.$message({
+        type: 'success',
+        message: '分批成功'
+      })
+      close()
+    } else {
+      proxy.$message({
+        type: 'error',
+        message: res.message
+      })
+    }
+  })
 }
 
 function handleNumBlur() {
-  // console.log('blur number')
   // 分批数量修改
   baseLot.value.sparateList = []
   const prodNum = !!baseLot.value.prodNum ? baseLot.value.prodNum : baseLot.value.productionQuantity
   const arg = baseLot.value.sparateNum
+  const latestLotCode = baseLot.value.latestLotCode
+  if ((latestLotCode.charAt(latestLotCode.length - 1) + arg - 1) > 9) {
+    proxy.$message({
+      type: 'warning',
+      message: '总分批书里不能大于9'
+    })
+    return
+  }
   for (let i = 0; i < arg; i++) {
     const item = { ...baseLot.value }
     if (i === 0) {
       // 第一条
       item.lotNumber = Math.ceil(prodNum / arg)
+      item.carrierSelection = baseLot.value.carriers.map(v => v.id)
     } else if ((i + 1) === arg) {
       item.lotNumber = prodNum - (Math.ceil(prodNum / arg) * (arg - 1))
-      item.lotCode = baseLot.value.lotCode.slice(0, -1) + i
+      item.lotCode = baseLot.value.latestLotCode.slice(0, -1) + (Number(latestLotCode.charAt(latestLotCode.length - 1)) + i)
       item.id = null
       item.lotId = null
       item.last = 0
+      item.carrierSelection = []
     } else {
       item.id = null
       item.lotId = null
-      item.lotCode = baseLot.value.lotCode.slice(0, -1) + i
+      item.lotCode = baseLot.value.latestLotCode.slice(0, -1) + (Number(latestLotCode.charAt(latestLotCode.length - 1)) + i)
       item.lotNumber = Math.ceil(prodNum / arg)
       item.fromId = baseLot.value.id
       item.last = 0
+      item.carrierSelection = []
     }
     baseLot.value.sparateList.push(item)
   }