|
|
@@ -6,16 +6,20 @@ import { useUserStore } from '@/store/modules/user'
|
|
|
import { getStrDictOptions } from '@/utils/dict'
|
|
|
import * as DeptApi from '@/api/system/dept'
|
|
|
import { IotRdDailyReportApi } from '@/api/pms/iotrddailyreport'
|
|
|
+import { formatT } from '@/utils/formatTime'
|
|
|
|
|
|
const deptId = useUserStore().getUser.deptId
|
|
|
|
|
|
interface Props {
|
|
|
visible: boolean
|
|
|
loadList: () => void
|
|
|
+ isview: 'detail' | 'create' | 'time'
|
|
|
+ id?: number
|
|
|
}
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
- visible: false
|
|
|
+ visible: false,
|
|
|
+ isview: 'create'
|
|
|
})
|
|
|
|
|
|
const emits = defineEmits(['update:visible'])
|
|
|
@@ -134,8 +138,30 @@ const loading = ref(false)
|
|
|
|
|
|
async function load() {
|
|
|
loading.value = true
|
|
|
- await loadDept()
|
|
|
+
|
|
|
await loadUserOptions()
|
|
|
+
|
|
|
+ if (props.isview && props.id) {
|
|
|
+ const res = await IotRdDailyReportApi.getIotRdDailyReport(props.id)
|
|
|
+ deptName.value = res.deptName
|
|
|
+ form.value = {
|
|
|
+ deptId: res.deptId,
|
|
|
+ location: res.location,
|
|
|
+ responsiblePerson: res.responsiblePerson,
|
|
|
+ timeRange: [formatT(res.startTime), formatT(res.endTime)],
|
|
|
+ rdStatus: res.rdStatus,
|
|
|
+ dailyFuel: res.dailyFuel,
|
|
|
+ productionStatus: res.productionStatus,
|
|
|
+ nextPlan: res.nextPlan,
|
|
|
+ externalRental: res.externalRental,
|
|
|
+ malfunction: res.malfunction,
|
|
|
+ otherNptReason: res.otherNptReason,
|
|
|
+ ...NON_PROD_FIELDS.reduce((acc, field) => ({ ...acc, [field.key]: res[field.key] }), {})
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ await loadDept()
|
|
|
+ }
|
|
|
+
|
|
|
loading.value = false
|
|
|
}
|
|
|
|
|
|
@@ -164,11 +190,15 @@ async function submitForm() {
|
|
|
formLoading.value = true
|
|
|
await formRef.value.validate()
|
|
|
const { timeRange, ...rest } = form.value
|
|
|
- const data = { ...rest, startTime: timeRange?.[0], endTime: timeRange?.[1] }
|
|
|
+ const data: any = { ...rest, startTime: timeRange?.[0], endTime: timeRange?.[1] }
|
|
|
|
|
|
+ if (props.id) {
|
|
|
+ data.id = props.id
|
|
|
+ }
|
|
|
await IotRdDailyReportApi.createIotRdDailyReport(data)
|
|
|
|
|
|
- message.success('新增成功')
|
|
|
+ if (props.id) message.success('更新成功')
|
|
|
+ else message.success('新增成功')
|
|
|
handleCloseForm()
|
|
|
props.loadList()
|
|
|
} catch (error) {
|
|
|
@@ -205,6 +235,7 @@ async function submitForm() {
|
|
|
class="flex flex-col"
|
|
|
:rules="rules"
|
|
|
:loading="loading"
|
|
|
+ :disabled="props.isview !== 'create'"
|
|
|
>
|
|
|
<div class="grid grid-cols-2 gap-x-8">
|
|
|
<el-form-item label="施工队伍">{{ deptName }}</el-form-item>
|
|
|
@@ -326,6 +357,7 @@ async function submitForm() {
|
|
|
class="w-full!"
|
|
|
align="left"
|
|
|
@blur="handleRowValidate(field.key)"
|
|
|
+ :disabled="isview === 'detail'"
|
|
|
>
|
|
|
<template #suffix>小时(H)</template>
|
|
|
</el-input-number>
|
|
|
@@ -349,13 +381,20 @@ async function submitForm() {
|
|
|
show-word-limit
|
|
|
:maxlength="1000"
|
|
|
placeholder="当'其他非生产时间'大于0时必填"
|
|
|
+ :disabled="isview === 'detail'"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
<template #footer>
|
|
|
- <el-button size="default" type="primary" @click="submitForm" :loading="formLoading">
|
|
|
+ <el-button
|
|
|
+ :disabled="isview === 'detail'"
|
|
|
+ size="default"
|
|
|
+ type="primary"
|
|
|
+ @click="submitForm"
|
|
|
+ :loading="formLoading"
|
|
|
+ >
|
|
|
确 定
|
|
|
</el-button>
|
|
|
<el-button size="default" @click="emits('update:visible', false)">取 消</el-button>
|