소스 검색

Merge branch 'workordering' into test

zhangcl 5 일 전
부모
커밋
33fba90228
5개의 변경된 파일146개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 0
      src/api/pms/iotmainworkorder/index.ts
  2. 3 1
      src/locales/en.ts
  3. 3 1
      src/locales/ru.ts
  4. 3 1
      src/locales/zh-CN.ts
  5. 136 2
      src/views/pms/iotmainworkorder/index.vue

+ 1 - 0
src/api/pms/iotmainworkorder/index.ts

@@ -20,6 +20,7 @@ export interface IotMainWorkOrderVO {
   actualStartTime: Date // 实际保养开始时间
   actualEndTime: Date // 实际保养结束时间
   remark: string // 备注
+  delayReason: string // 延时原因
   status: number // 状态 0启用  1停用
   processInstanceId: string // 流程实例id
   auditStatus: number // 审批状态 未提交、审批中、审批通过、审批不通过、已取消

+ 3 - 1
src/locales/en.ts

@@ -945,7 +945,9 @@ export default {
     source:'Source',
     ConsumptionQuantity:'ConsumptionQuantity',
     materialGroup:'MaterialGroup',
-    groupHolder:'Please select material group'
+    groupHolder:'Please select material group',
+    delayReason: 'Delay Reason',
+    inputDelayReason: 'Please input reason'
   },
   chooseMaintain:{
     selectRepairItem:'SelectRepairItem',

+ 3 - 1
src/locales/ru.ts

@@ -850,7 +850,9 @@ export default {
     source:'来源',
     ConsumptionQuantity:'消耗数量',
     materialGroup:'物料组',
-    groupHolder:'请选择所属物料组'
+    groupHolder:'请选择所属物料组',
+    delayReason: '延保原因',
+    inputDelayReason: '请输入延保原因'
   },
   chooseMaintain:{
     selectRepairItem:'选择维修项',

+ 3 - 1
src/locales/zh-CN.ts

@@ -941,7 +941,9 @@ export default {
     source:'来源',
     ConsumptionQuantity:'消耗数量',
     materialGroup:'物料组',
-    groupHolder:'请选择所属物料组'
+    groupHolder:'请选择所属物料组',
+    delayReason: '延时原因',
+    inputDelayReason: '请输入延时原因'
   },
   chooseMaintain:{
     selectRepairItem:'选择维修项',

+ 136 - 2
src/views/pms/iotmainworkorder/index.vue

@@ -136,6 +136,15 @@
           </el-table-column>
           <el-table-column :label="t('iotMaintain.operation')" align="center" :width="columnWidths.operation" fixed="right">
             <template #default="scope">
+              <el-button
+                v-if="isNegativeMainDistance(scope.row.mainDistance)"
+                link
+                :type="getDelayReasonButtonType(scope.row.delayReason)"
+                @click="openDelayReasonDialog(scope.row)"
+                v-hasPermi="['pms:iot-main-work-order:update']"
+              >
+                {{ t('mainPlan.delayed') || '延时' }}
+              </el-button>
               <el-button
                 link
                 type="primary"
@@ -168,6 +177,37 @@
   </el-row>
   <!-- 表单弹窗:添加/修改 -->
   <IotMainWorkOrderForm ref="formRef" @success="getList" />
+
+  <!-- 延保原因弹窗 -->
+  <el-dialog
+    v-model="delayReasonDialogVisible"
+    :title="t('workOrderMaterial.delayReason') || '延时原因'"
+    width="500px"
+    :close-on-click-modal="false"
+  >
+    <el-form :model="delayReasonForm" label-width="0px" :rules="delayReasonRules"
+             ref="delayReasonFormRef">
+      <el-form-item label=" " prop="delayReason" class="required-item" label-width="16px">
+        <el-input
+          v-model="delayReasonForm.delayReason"
+          type="textarea"
+          :rows="4"
+          :placeholder="t('workOrderMaterial.inputDelayReason') || '请输入延时原因'"
+          maxlength="500"
+          show-word-limit
+        />
+      </el-form-item>
+    </el-form>
+    <template #footer>
+      <el-button @click="delayReasonDialogVisible = false">
+        {{ t('common.cancel') || '取消' }}
+      </el-button>
+      <el-button type="primary" @click="saveDelayReason" :loading="saveDelayReasonLoading">
+        {{ t('common.save') || '保存' }}
+      </el-button>
+    </template>
+  </el-dialog>
+
 </template>
 
 <script setup lang="ts">
@@ -182,6 +222,9 @@ const { push } = useRouter() // 路由跳转
 /** 保养工单 列表 */
 defineOptions({ name: 'IotMainWorkOrder' })
 
+// 表单引用
+const delayReasonFormRef = ref<InstanceType<typeof ElForm>>()
+
 const message = useMessage() // 消息弹窗
 const { t } = useI18n() // 国际化
 const tableRef = ref() // 表格引用
@@ -219,6 +262,13 @@ const queryFormRef = ref() // 搜索的表单
 const exportLoading = ref(false) // 导出的加载中
 const hoverText = ref('');
 
+// 定义表单验证规则
+const delayReasonRules = {
+  delayReason: [
+    { required: true, message: t('workOrderMaterial.inputDelayReason') || '请输入延时原因', trigger: 'blur' }
+  ]
+}
+
 // 列宽度配置
 const columnWidths = ref({
   serial: '80px',
@@ -250,6 +300,75 @@ const getTextWidth = (text: string, fontSize = 14) => {
   return width;
 };
 
+/** 延保原因相关状态 */
+const delayReasonDialogVisible = ref(false)
+const saveDelayReasonLoading = ref(false)
+const delayReasonForm = reactive({
+  id: undefined as number | undefined,
+  delayReason: ''
+})
+
+/** 判断mainDistance是否为负值 */
+const isNegativeMainDistance = (mainDistance: string | null): boolean => {
+  if (!mainDistance) return false
+
+  // 使用正则提取数字部分(包括负号、小数点和科学计数法)
+  const numericPart = mainDistance.match(/[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/)?.[0]
+
+  if (numericPart) {
+    const num = parseFloat(numericPart)
+    return num < 0
+  }
+
+  return false
+}
+
+/** 打开延保原因弹窗 */
+const openDelayReasonDialog = (row: IotMainWorkOrderVO) => {
+  delayReasonForm.id = row.id
+  delayReasonForm.delayReason = row.delayReason || ''
+  delayReasonDialogVisible.value = true
+}
+
+/** 保存延保原因 */
+const saveDelayReason = async () => {
+  // 表单验证
+  if (!delayReasonFormRef.value) return
+  const valid = await delayReasonFormRef.value.validate()
+  if (!valid) return
+
+  if (!delayReasonForm.id) {
+    message.error('ID不能为空')
+    return
+  }
+
+  try {
+    saveDelayReasonLoading.value = true
+    // 调用更新接口,只传递id和delayReason字段
+    await IotMainWorkOrderApi.updateIotMainWorkOrder({
+      id: delayReasonForm.id,
+      delayReason: delayReasonForm.delayReason
+    })
+
+    message.success(t('common.success') || '保存成功')
+    delayReasonDialogVisible.value = false
+
+    // 刷新列表数据
+    await getList()
+  } catch (error) {
+    console.error('保存延保原因失败:', error)
+    message.error(t('sys.api.operationFailed') || '保存失败')
+  } finally {
+    saveDelayReasonLoading.value = false
+  }
+}
+
+/** 根据delayReason是否有值返回按钮类型 */
+const getDelayReasonButtonType = (delayReason: string | null | undefined): string => {
+  // 如果delayReason有值(不为null、undefined且不是空字符串),返回success,否则返回warning
+  return delayReason ? 'success' : 'warning'
+}
+
 /** 处理部门被点击 */
 const handleDeptNodeClick = async (row) => {
   queryParams.deptId = row.id
@@ -310,8 +429,8 @@ const calculateColumnWidths = () => {
   calculateColumnMinWidth('updateTime', t('dict.fillTime'), (row: any) => row.result == 2 ? formatCellDate(row.updateTime) : '');
 
   // 操作列固定宽度
-  minWidths.operation = 150;
-  totalMinWidth += 150;
+  minWidths.operation = 160;
+  totalMinWidth += 160;
 
   // 2. 计算可伸缩列最终宽度
   const newWidths: Record<string, string> = {};
@@ -382,6 +501,10 @@ const resultOptions = computed(() => [
     label: t('operationFill.all'),
     value: '0' // 空值会触发 clearable 效果
   },
+  {
+    label: t('mainPlan.delayed'),
+    value: '3' // 空值会触发 clearable 效果
+  },
   ...getStrDictOptions(DICT_TYPE.PMS_MAIN_WORK_ORDER_RESULT)
 ])
 
@@ -620,4 +743,15 @@ watch(isLeftContentCollapsed, () => {
   transform: rotate(180deg);
 }
 
+/* 延时原因 必填星号样式 */
+:deep(.required-item .el-form-item__label:before) {
+  content: '*';
+  color: #ff4d4f;
+  margin-right: 2px;
+}
+
+/* 调整标签区域样式 */
+:deep(.required-item .el-form-item__label) {
+  padding-right: 0 !important;
+}
 </style>