Prechádzať zdrojové kódy

pms 保养 物料领用 站内信 钉钉消息

zhangcl 2 mesiacov pred
rodič
commit
a757428dc3

+ 10 - 0
src/layout/components/Message/src/Message.vue

@@ -51,6 +51,16 @@ const routerDetail = (item) =>{
         id: id
       }
     })
+  } else if (item.businessType === 'material-requisition') {
+    push({
+      name: 'IotMaterialReqDetail',
+      params: { id }
+    })
+  } else if (item.businessType === 'generateMaintenance') {
+    push({
+      name: 'IotMainWorkOrderBom',
+      params: { id }
+    })
   }
 }
 // ========== 初始化 =========

+ 2 - 2
src/views/pms/iotmaterialrequisition/IotMaterialReqDetail.vue

@@ -121,8 +121,8 @@ import SelectLocalStock from "@/views/pms/iotmaterialrequisition/SelectLocalStoc
 import * as DeptApi from "@/api/system/dept";
 import {erpPriceTableColumnFormatter} from "@/utils";
 
-/** 物料领用 表单 */
-defineOptions({ name: 'IotMaterialRequisitionAdd' })
+/** 物料领用 详情 */
+defineOptions({ name: 'IotMaterialReqDetail' })
 
 const { t } = useI18n() // 国际化
 const message = useMessage() // 消息弹窗

+ 38 - 0
src/views/pms/iotmaterialrequisition/SelectLocalStock.vue

@@ -86,9 +86,12 @@
           <el-table-column :label="t('stock.requQuantity')" align="center" prop="requisitionQuantity">
             <template #default="scope">
               <el-input
+                type="number"
+                :controls="false"
                 v-model="scope.row.requisitionQuantity"
                 @click.stop=""
                 @focus="handleInputFocus(scope.row)"
+                @blur="(event) => handleQuantityBlur(event, scope.row)"
               />
             </template>
           </el-table-column>
@@ -167,6 +170,17 @@ const selectRow = (row) => {
 
 // 确认选择
 const handleConfirm = () => {
+  // 检查是否有未通过校验的行
+  const invalidRows = selectedRows.value.filter(row => {
+    const quantity = parseFloat(row.requisitionQuantity);
+    return isNaN(quantity) || quantity <= 0 || quantity > row.quantity;
+  });
+
+  if (invalidRows.length > 0) {
+    ElMessage.error('存在无效的领用数量,请检查');
+    return;
+  }
+
   if (selectedRows.value.length === 0) {
     ElMessage.warning('请至少选择一个物料')
     return
@@ -206,6 +220,30 @@ const getList = async () => {
   }
 }
 
+// 处理领用数量输入框失焦事件
+const handleQuantityBlur = (event: Event, row: any) => {
+  const inputValue = (event.target as HTMLInputElement).value;
+  let num = parseFloat(inputValue);
+  // 处理无效值
+  if (isNaN(num)) {
+    row.requisitionQuantity = 0;
+    return;
+  }
+  // 处理小于等于0的情况
+  if (num <= 0) {
+    row.requisitionQuantity = 0;
+    return;
+  }
+  // 处理超过库存数量的情况
+  if (num > row.quantity) {
+    row.requisitionQuantity = row.quantity;
+    ElMessage.warning('领用数量不能超过库存数量');
+    return;
+  }
+  // 保留两位小数
+  row.requisitionQuantity = parseFloat(num.toFixed(2));
+};
+
 // 处理输入框焦点事件(自动选中当前行)
 const handleInputFocus = (row: MaterialApi.MaterialVO) => {
   // 如果未选中则添加到选中列表