yanghao 3 zile în urmă
părinte
comite
b26d1956b1

+ 3 - 12
src/views/pms/iotrddailyreport/FillDailyReportForm.vue

@@ -469,16 +469,7 @@ const formDisabled = computed(() => (key?: string) => {
       return data.value.auditStatus !== 10
     }
 
-    if (
-      formType.value === 'time' &&
-      (NON_PROD_FIELDS.some((field) => field.key === key) ||
-        key === 'constructionBrief' ||
-        key === 'otherNptReason')
-    ) {
-      return false
-    }
-
-    if (formType.value === 'time' && key === 'button') {
+    if (formType.value === 'time') {
       return false
     }
 
@@ -1141,7 +1132,7 @@ const inContent = async (attachment) => {
             placeholder="请输入下步工作计划"
           />
         </el-form-item>
-        <el-form-item class="col-span-2" label="外设备" prop="externalRental">
+        <el-form-item class="col-span-2" label="外设备" prop="externalRental">
           <el-input
             v-model="form.externalRental"
             type="textarea"
@@ -1149,7 +1140,7 @@ const inContent = async (attachment) => {
             resize="none"
             show-word-limit
             :maxlength="1000"
-            placeholder="请输入外设备"
+            placeholder="请输入外设备"
           />
         </el-form-item>
         <el-form-item class="col-span-2" label="故障情况" prop="malfunction">

+ 72 - 7
src/views/pms/iotrydailyreport/ry-xj-form.vue

@@ -7,6 +7,10 @@ import { FormInstance, FormRules } from 'element-plus'
 import { computed, reactive, ref, watch, nextTick } from 'vue'
 import { Delete, Plus } from '@element-plus/icons-vue'
 import dayjs from 'dayjs'
+import { useDebounceFn } from '@vueuse/core'
+import { useUserStore } from '@/store/modules/user'
+
+const userStore = useUserStore()
 
 interface Props {
   visible: boolean
@@ -45,6 +49,8 @@ interface ReportDetail {
   duration: number
   currentOperation: string
   constructionDetail: string
+  allocatedTime: number
+  allocatedEfficiency: number
 }
 
 interface FormOriginal {
@@ -159,7 +165,8 @@ const { t } = useI18n()
 const initFormData = (): Form => {
   const base: any = {
     ratedProductionTime: 0,
-    productionTime: 0
+    productionTime: 0,
+    reportDetails: []
   }
   // 初始化所有非生产时间字段为 0
   NON_PROD_FIELDS.forEach((field) => {
@@ -206,7 +213,9 @@ async function loadDetail(id: number) {
         endTime: formatT(item.endTime),
         duration: item.duration,
         currentOperation: item.currentOperation,
-        constructionDetail: item.constructionDetail
+        constructionDetail: item.constructionDetail,
+        allocatedTime: item.allocatedTime,
+        allocatedEfficiency: item.allocatedEfficiency
       })
     )
 
@@ -233,7 +242,9 @@ const addProductionStatusRow = () => {
     endTime: '',
     duration: 0,
     currentOperation: '',
-    constructionDetail: ''
+    constructionDetail: '',
+    allocatedTime: 0,
+    allocatedEfficiency: 0
   })
 }
 
@@ -431,6 +442,28 @@ const orange = computed(() => {
   if (Math.abs(total - rateTime) > 0.01) return true
   return false
 })
+
+const computedAllocatedEfficiency = useDebounceFn(function (row: ReportDetail) {
+  console.log('row', row)
+  if (!row) return
+
+  if (!row.allocatedTime || !row.duration) return
+
+  console.log('row', row)
+
+  row.allocatedEfficiency = Number(
+    (1 - (row.duration - row.allocatedTime) / row.allocatedTime).toFixed(2)
+  )
+}, 100)
+
+const calculate = (row: ReportDetail) => {
+  calculateDuration(row)
+  computedAllocatedEfficiency(row)
+}
+
+const allocatedTimeDisabled = computed(() => {
+  return userStore.getRoles.includes('RY定额时效')
+})
 </script>
 
 <template>
@@ -713,7 +746,7 @@ const orange = computed(() => {
                 </template>
               </ZmTableColumn>
 
-              <ZmTableColumn :width="130" label="开始时间" prop="startTime">
+              <ZmTableColumn :width="160" label="开始时间" prop="startTime">
                 <template #default="{ row, $index }">
                   <el-form-item
                     v-if="$index >= 0"
@@ -732,13 +765,13 @@ const orange = computed(() => {
                       format="HH:mm"
                       value-format="HH:mm"
                       class="w-full!"
-                      @change="calculateDuration(row)"
+                      @change="calculate(row)"
                       :disabled="isMainFieldDisabled"
                     />
                   </el-form-item>
                 </template>
               </ZmTableColumn>
-              <ZmTableColumn :width="130" label="结束时间" prop="endTime">
+              <ZmTableColumn :width="160" label="结束时间" prop="endTime">
                 <template #default="{ row, $index }">
                   <el-form-item
                     v-if="$index >= 0"
@@ -757,7 +790,7 @@ const orange = computed(() => {
                       format="HH:mm"
                       value-format="HH:mm"
                       class="w-full!"
-                      @change="calculateDuration(row)"
+                      @change="calculate(row)"
                       :disabled="isMainFieldDisabled"
                     />
                   </el-form-item>
@@ -809,6 +842,38 @@ const orange = computed(() => {
                 </template>
               </ZmTableColumn>
 
+              <ZmTableColumn label="定额时长" :width="160" align="center">
+                <template #default="{ row, $index }">
+                  <el-form-item
+                    v-if="$index >= 0"
+                    class="mb-0!"
+                    :prop="`reportDetails.${$index}.allocatedTime`"
+                  >
+                    <el-input-number
+                      v-model="row.allocatedTime"
+                      :disabled="isMainFieldDisabled && allocatedTimeDisabled"
+                      :controls="false"
+                      align="left"
+                      :min="0"
+                      placeholder="请输入定额时长"
+                      class="!w-full"
+                      :precision="2"
+                      @input="computedAllocatedEfficiency(row)"
+                    />
+                  </el-form-item>
+                </template>
+              </ZmTableColumn>
+
+              <ZmTableColumn
+                label="定额时效"
+                :width="120"
+                align="center"
+                prop="allocatedEfficiency"
+                :formatter="
+                  (row) => (row.allocatedEfficiency ? `${row.allocatedEfficiency * 100}%` : '')
+                "
+              />
+
               <ZmTableColumn label="操作" width="80" fixed="right" align="center">
                 <template #default="{ $index }">
                   <el-button