|
@@ -44,10 +44,17 @@ interface PlanRow {
|
|
|
startTime: string
|
|
startTime: string
|
|
|
endTime: string
|
|
endTime: string
|
|
|
showEndTime: boolean
|
|
showEndTime: boolean
|
|
|
- planWellTrips?: string
|
|
|
|
|
- planLayers?: string
|
|
|
|
|
- planGasInjection?: string
|
|
|
|
|
- planFootage?: string
|
|
|
|
|
|
|
+ [key: string]: any
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+interface PlanExtColumn {
|
|
|
|
|
+ name: string
|
|
|
|
|
+ identifier: string
|
|
|
|
|
+ dataType?: string
|
|
|
|
|
+ required?: number
|
|
|
|
|
+ unit?: string
|
|
|
|
|
+ defaultValue?: string | number | null
|
|
|
|
|
+ sort?: number
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const message = useMessage()
|
|
const message = useMessage()
|
|
@@ -111,14 +118,50 @@ const timestampToDateTime = (timestamp: number | string | null | undefined): str
|
|
|
return dayjs(value).format('YYYY-MM-DD HH:mm')
|
|
return dayjs(value).format('YYYY-MM-DD HH:mm')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-let currentTableCol = ref<any[]>([])
|
|
|
|
|
|
|
+const currentTableColumns = ref<PlanExtColumn[]>([])
|
|
|
|
|
+
|
|
|
|
|
+const normalizeWorkloadColumns = (res: any): PlanExtColumn[] => {
|
|
|
|
|
+ const columns = Array.isArray(res?.data) ? res.data : Array.isArray(res) ? res : []
|
|
|
|
|
+ return columns
|
|
|
|
|
+ .filter((item: PlanExtColumn) => item?.identifier)
|
|
|
|
|
+ .sort((a: PlanExtColumn, b: PlanExtColumn) => (a?.sort ?? 0) - (b?.sort ?? 0))
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const isRequiredColumn = (column: PlanExtColumn) => Number(column.required) === 1
|
|
|
|
|
+
|
|
|
|
|
+const isEmptyValue = (value: unknown) =>
|
|
|
|
|
+ value === undefined || value === null || (typeof value === 'string' && value.trim() === '')
|
|
|
|
|
+
|
|
|
|
|
+const getPlanDynamicValues = (row: PlanRow) =>
|
|
|
|
|
+ currentTableColumns.value.reduce<Record<string, any>>((values, column) => {
|
|
|
|
|
+ values[column.identifier] = row[column.identifier] ?? ''
|
|
|
|
|
+ return values
|
|
|
|
|
+ }, {})
|
|
|
|
|
+
|
|
|
|
|
+const createPlanRow = (plan?: any): PlanRow => {
|
|
|
|
|
+ const row: PlanRow = {
|
|
|
|
|
+ id: plan?.id,
|
|
|
|
|
+ status: plan?.status || '',
|
|
|
|
|
+ startTime: timestampToDateTime(plan?.startTime),
|
|
|
|
|
+ endTime: timestampToDateTime(plan?.endTime),
|
|
|
|
|
+ showEndTime: plan?.status !== COMPLETED_STATUS
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ currentTableColumns.value.forEach((column) => {
|
|
|
|
|
+ row[column.identifier] = plan?.[column.identifier] ?? column.defaultValue ?? ''
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ return row
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const openPlanDialog = async (row: ProjectTaskRow) => {
|
|
const openPlanDialog = async (row: ProjectTaskRow) => {
|
|
|
currentRow.value = row
|
|
currentRow.value = row
|
|
|
planList.value = []
|
|
planList.value = []
|
|
|
|
|
+ currentTableColumns.value = []
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const res = await IotProjectTaskScheduleApi.getWorkload(row.id)
|
|
const res = await IotProjectTaskScheduleApi.getWorkload(row.id)
|
|
|
- currentTableCol.value = res
|
|
|
|
|
|
|
+ currentTableColumns.value = normalizeWorkloadColumns(res)
|
|
|
} catch {
|
|
} catch {
|
|
|
message.error('获取部门数据失败')
|
|
message.error('获取部门数据失败')
|
|
|
}
|
|
}
|
|
@@ -130,21 +173,7 @@ const openPlanDialog = async (row: ProjectTaskRow) => {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
if (taskSchedules?.length) {
|
|
if (taskSchedules?.length) {
|
|
|
- planList.value = taskSchedules.map((plan: any) => {
|
|
|
|
|
- const status = plan.status
|
|
|
|
|
-
|
|
|
|
|
- return {
|
|
|
|
|
- id: plan.id,
|
|
|
|
|
- status,
|
|
|
|
|
- startTime: timestampToDateTime(plan.startTime),
|
|
|
|
|
- endTime: timestampToDateTime(plan.endTime),
|
|
|
|
|
- showEndTime: status !== COMPLETED_STATUS,
|
|
|
|
|
- planWellTrips: plan.planWellTrips,
|
|
|
|
|
- planLayers: plan.planLayers,
|
|
|
|
|
- planGasInjection: plan.planGasInjection,
|
|
|
|
|
- planFootage: plan.planFootage
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ planList.value = taskSchedules.map((plan: any) => createPlanRow(plan))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
planDialogVisible.value = true
|
|
planDialogVisible.value = true
|
|
@@ -166,12 +195,7 @@ const onStatusChange = (row: PlanRow) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const addNewRow = () => {
|
|
const addNewRow = () => {
|
|
|
- planList.value.push({
|
|
|
|
|
- status: '',
|
|
|
|
|
- startTime: '',
|
|
|
|
|
- endTime: '',
|
|
|
|
|
- showEndTime: true
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ planList.value.push(createPlanRow())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const removeRow = (index: number) => {
|
|
const removeRow = (index: number) => {
|
|
@@ -179,42 +203,22 @@ const removeRow = (index: number) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const savePlan = async () => {
|
|
const savePlan = async () => {
|
|
|
- console.log('ssssssssssssssss', currentTableCol.value[0])
|
|
|
|
|
try {
|
|
try {
|
|
|
saveLoading.value = true
|
|
saveLoading.value = true
|
|
|
|
|
|
|
|
for (let index = 0; index < planList.value.length; index++) {
|
|
for (let index = 0; index < planList.value.length; index++) {
|
|
|
- // if (!planList.value[index].status) {
|
|
|
|
|
- // message.error(`第${index + 1}行请选择施工状态`)
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ const row = planList.value[index]
|
|
|
|
|
|
|
|
- if (!planList.value[index].startTime) {
|
|
|
|
|
|
|
+ if (!row.startTime) {
|
|
|
message.error(`第${index + 1}行请选择开始时间`)
|
|
message.error(`第${index + 1}行请选择开始时间`)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (
|
|
|
|
|
- currentTableCol.value[0].identifier === 'planLayers' &&
|
|
|
|
|
- !planList.value[index].planLayers
|
|
|
|
|
- ) {
|
|
|
|
|
- message.error(`第${index + 1}行请选择计划层数`)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (
|
|
|
|
|
- currentTableCol.value[0].identifier === 'planWellTrips' &&
|
|
|
|
|
- !planList.value[index].planWellTrips
|
|
|
|
|
- ) {
|
|
|
|
|
- message.error(`第${index + 1}行请选择计划井次`)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (
|
|
|
|
|
- currentTableCol.value[0].identifier === 'planGasInjection' &&
|
|
|
|
|
- !planList.value[index].planGasInjection
|
|
|
|
|
- ) {
|
|
|
|
|
- message.error(`第${index + 1}行请选择计划注气量`)
|
|
|
|
|
|
|
+ const emptyRequiredColumn = currentTableColumns.value.find(
|
|
|
|
|
+ (column) => isRequiredColumn(column) && isEmptyValue(row[column.identifier])
|
|
|
|
|
+ )
|
|
|
|
|
+ if (emptyRequiredColumn) {
|
|
|
|
|
+ message.error(`第${index + 1}行请填写${emptyRequiredColumn.name}`)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -226,10 +230,7 @@ const savePlan = async () => {
|
|
|
startTime: item.startTime ? new Date(item.startTime).getTime() : null,
|
|
startTime: item.startTime ? new Date(item.startTime).getTime() : null,
|
|
|
endTime:
|
|
endTime:
|
|
|
item.status !== COMPLETED_STATUS && item.endTime ? new Date(item.endTime).getTime() : null,
|
|
item.status !== COMPLETED_STATUS && item.endTime ? new Date(item.endTime).getTime() : null,
|
|
|
- planWellTrips: item.planWellTrips,
|
|
|
|
|
- planLayers: item.planLayers,
|
|
|
|
|
- planGasInjection: item.planGasInjection,
|
|
|
|
|
- planFootage: item.planFootage
|
|
|
|
|
|
|
+ ...getPlanDynamicValues(item)
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
await IotProjectTaskScheduleApi.saveTaskSchedule(submitData)
|
|
await IotProjectTaskScheduleApi.saveTaskSchedule(submitData)
|
|
@@ -581,10 +582,15 @@ onMounted(async () => {
|
|
|
|
|
|
|
|
<el-table-column
|
|
<el-table-column
|
|
|
min-width="120"
|
|
min-width="120"
|
|
|
- v-for="item in currentTableCol"
|
|
|
|
|
|
|
+ v-for="item in currentTableColumns"
|
|
|
:key="item.identifier"
|
|
:key="item.identifier"
|
|
|
- :label="item.name"
|
|
|
|
|
:prop="item.identifier">
|
|
:prop="item.identifier">
|
|
|
|
|
+ <template #header>
|
|
|
|
|
+ <span>
|
|
|
|
|
+ <span v-if="isRequiredColumn(item)" class="required-mark">*</span>
|
|
|
|
|
+ {{ item.unit ? `${item.name}(${item.unit})` : item.name }}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </template>
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
|
<el-input type="number" v-model="scope.row[item.identifier]" placeholder="请输入" />
|
|
<el-input type="number" v-model="scope.row[item.identifier]" placeholder="请输入" />
|
|
|
</template>
|
|
</template>
|
|
@@ -693,6 +699,11 @@ onMounted(async () => {
|
|
|
margin-bottom: 0;
|
|
margin-bottom: 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.required-mark {
|
|
|
|
|
+ margin-right: 2px;
|
|
|
|
|
+ color: var(--el-color-danger);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
@media (width >= 2200px) {
|
|
@media (width >= 2200px) {
|
|
|
.query-actions {
|
|
.query-actions {
|
|
|
grid-column: 4;
|
|
grid-column: 4;
|