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