ソースを参照

pms 物料消耗 保养工单 不消耗物料 或保养完成时 选择物料 设置 新增物料按钮 为失效状态

zhangcl 1 週間 前
コミット
9ec59e82ed
1 ファイル変更32 行追加6 行削除
  1. 32 6
      src/views/pms/iotmainworkorder/IotMainWorkOrderOptimize.vue

+ 32 - 6
src/views/pms/iotmainworkorder/IotMainWorkOrderOptimize.vue

@@ -415,7 +415,7 @@
           type="primary"
           :icon="Box"
           @click="handleSelectMaterial"
-          :disabled="!currentBomItem"
+          :disabled="!currentBomItem || isButtonsDisabled"
         >
           {{ t('stock.selectMaterial') }}
         </el-button>
@@ -432,7 +432,7 @@
           type="primary"
           :icon="Plus"
           @click="handleAddMaterial"
-          :disabled="!currentBomItem"
+          :disabled="!currentBomItem || isButtonsDisabled"
         >
           新增物料
         </el-button>
@@ -480,7 +480,7 @@
               placeholder="请输入物料名称(必填)"
               style="width: 100%"
               :class="{ 'is-required-input': row.isNew && !row.materialName?.trim() }"
-            :disabled="isMaterialDisabled(row)"
+              :disabled="isMaterialDisabled(row)"
             />
             </el-tooltip>
             <!-- 非新增行:正常显示 -->
@@ -916,8 +916,13 @@ const displayedMaterialList = computed(() => {
 const isMaterialDisabled = (material) => {
   // 根据物料的bomNodeId找到对应的保养项
   const bomItem = list.value.find(item => item.bomNodeId === material.bomNodeId);
-  // 如果保养项存在且rule=1(不消耗物料),则禁用
-  return bomItem && bomItem.rule === 1;
+  // 如果保养项不存在,默认不禁用
+  if (!bomItem) return false;
+  // 如果保养项状态为已完成(status=1),则禁用该物料
+  if (bomItem.status === 1) return true;
+  // 如果保养项rule=1(不消耗物料),则禁用
+  if (bomItem.rule === 1) return true;
+  return false;
 };
 
 // 物料表格行类名 - 用于设置灰色背景
@@ -931,6 +936,19 @@ const getMaterialRowClassName = ({ row }) => {
   return '';
 };
 
+// 计算属性:判断按钮是否应该禁用
+const isButtonsDisabled = computed(() => {
+  if (!currentBomItem.value) return true;
+
+  // 条件1:保养状态为已完成(status=1)
+  if (currentBomItem.value.status === 1) return true;
+
+  // 条件2:消耗物料字段为不消耗物料(rule=1)
+  if (currentBomItem.value.rule === 1) return true;
+
+  return false;
+});
+
 // 切换显示所有物料/当前保养项物料
 const toggleShowAllMaterials = () => {
   showAllMaterials.value = !showAllMaterials.value;
@@ -2592,19 +2610,27 @@ const handleRowClick = (row) => {
 :deep(.disabled-material-row) {
   background-color: #f5f7fa !important;
   color: #c0c4cc !important;
+  cursor: not-allowed !important;
 }
 
 :deep(.disabled-material-row:hover>td) {
   background-color: #f5f7fa !important;
 }
 
+:deep(.disabled-material-row .el-input.is-disabled .el-input__inner) {
+  background-color: #f5f7fa !important;
+  color: #c0c4cc !important;
+  cursor: not-allowed !important;
+}
+
 :deep(.disabled-material-row .el-input-number.is-disabled) {
   opacity: 0.6;
+  cursor: not-allowed !important;
 }
 
 :deep(.disabled-material-row .el-button.is-disabled) {
   opacity: 0.6;
-  cursor: not-allowed;
+  cursor: not-allowed !important;
 }
 
 /* 新增物料行的样式 */