|
|
@@ -462,14 +462,61 @@
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="工作量单位" width="150">
|
|
|
+ <template #default="{ $index }">
|
|
|
+ <el-select
|
|
|
+ v-model="currentTask.platformWellDetails[$index].workloadUnit"
|
|
|
+ placeholder="请选择工作量单位"
|
|
|
+ clearable
|
|
|
+ :disabled="getPlatformWellWorkloadUnits($index).includes(currentTask.platformWellDetails[$index].workloadUnit)
|
|
|
+ && currentTask.platformWellDetails[$index].workloadUnit !== currentTask.workloadUnit"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="dict in getStrDictOptions(DICT_TYPE.PMS_PROJECT_WORKLOAD_UNIT)"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ :disabled="getPlatformWellWorkloadUnits($index).includes(dict.value)
|
|
|
+ && dict.value !== currentTask.platformWellDetails[$index].workloadUnit"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
<el-table-column prop="workloadDesign" label="设计工作量">
|
|
|
<template #default="{ $index }">
|
|
|
- <el-input
|
|
|
- v-model="currentTask.platformWellDetails[$index].workloadDesign"
|
|
|
- placeholder="请输入设计工作量"
|
|
|
- />
|
|
|
+ <el-tooltip
|
|
|
+ :disabled="!currentTask.platformWellDetails[$index].workloadDesignError"
|
|
|
+ :content="currentTask.platformWellDetails[$index].workloadDesignError"
|
|
|
+ placement="top"
|
|
|
+ effect="light"
|
|
|
+ popper-class="workload-design-tooltip"
|
|
|
+ :show-after="0"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="currentTask.platformWellDetails[$index].workloadDesign"
|
|
|
+ placeholder="请输入设计工作量"
|
|
|
+ class="workload-input-with-button"
|
|
|
+ :class="{ 'error-input': currentTask.platformWellDetails[$index].workloadDesignError }"
|
|
|
+ @blur="validatePlatformWellWorkloadDesign($index)"
|
|
|
+ >
|
|
|
+ <template #append>
|
|
|
+ <el-tooltip content="添加多个设计工作量" placement="top">
|
|
|
+ <el-button
|
|
|
+ class="workload-add-btn"
|
|
|
+ @click="openPlatformWellWorkloadDialog($index)"
|
|
|
+ :disabled="getPlatformWellWorkloadAddBtnDisabled($index)"
|
|
|
+ >
|
|
|
+ <span class="btn-text">+</span>
|
|
|
+ </el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </el-tooltip>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+
|
|
|
<el-table-column label="操作" width="100">
|
|
|
<template #default="{ $index }">
|
|
|
<el-button
|
|
|
@@ -641,15 +688,28 @@
|
|
|
</el-select>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+
|
|
|
<el-table-column prop="workloadDesign" label="工作量">
|
|
|
<template #default="{ $index }">
|
|
|
- <el-input
|
|
|
- v-model="workloadList[$index].workloadDesign"
|
|
|
- placeholder="请输入工作量"
|
|
|
- :disabled="$index === 0 && hasInitialWorkload"
|
|
|
- />
|
|
|
+ <el-tooltip
|
|
|
+ :disabled="!workloadList[$index].workloadDesignError"
|
|
|
+ :content="workloadList[$index].workloadDesignError"
|
|
|
+ placement="top"
|
|
|
+ effect="light"
|
|
|
+ popper-class="workload-design-tooltip"
|
|
|
+ :show-after="0"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="workloadList[$index].workloadDesign"
|
|
|
+ placeholder="请输入工作量"
|
|
|
+ :disabled="$index === 0 && hasInitialWorkload"
|
|
|
+ :class="{ 'error-input': workloadList[$index].workloadDesignError }"
|
|
|
+ @blur="validateWorkloadDialogDesign($index)"
|
|
|
+ />
|
|
|
+ </el-tooltip>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+
|
|
|
<el-table-column label="操作" width="80">
|
|
|
<template #default="{ $index }">
|
|
|
<el-button
|
|
|
@@ -761,6 +821,9 @@ const workAreaAutocomplete = ref() // 添加对el-autocomplete的引用
|
|
|
// currentDictLabel 响应式变量
|
|
|
const currentDictLabel = ref(''); // 存储当前项目对应的施工区域字典类型
|
|
|
|
|
|
+// 当前正在操作的平台井索引
|
|
|
+const currentPlatformWellIndex = ref(-1);
|
|
|
+
|
|
|
// 施工工艺相关变量
|
|
|
const technologyOptions = ref<any[]>([])
|
|
|
const loadingTechnologyOptions = ref(false)
|
|
|
@@ -935,23 +998,6 @@ const getDeviceNames = (deviceIds: number[]) => {
|
|
|
return deviceNames.join(', ');
|
|
|
};
|
|
|
|
|
|
-// 初始化动态属性到当前任务
|
|
|
-/* const initDynamicAttrsToCurrentTask = () => {
|
|
|
- dynamicAttrs.value.forEach(attr => {
|
|
|
- // 如果当前任务中还没有这个属性,则初始化
|
|
|
- if (!currentTask.value.hasOwnProperty(attr.identifier)) {
|
|
|
- // 如果是编辑模式且有已有值,使用已有值,否则使用默认值
|
|
|
- if (formType.value === 'update' && tableData.value[0] && tableData.value[0][attr.identifier] !== undefined) {
|
|
|
- currentTask.value[attr.identifier] = tableData.value[0][attr.identifier];
|
|
|
- } else {
|
|
|
- currentTask.value[attr.identifier] = attr.defaultValue || '';
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-}; */
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
const initDynamicAttrsToCurrentTask = () => {
|
|
|
dynamicAttrs.value.forEach(attr => {
|
|
|
if (!currentTask.value.hasOwnProperty(attr.identifier)) {
|
|
|
@@ -1181,6 +1227,8 @@ const openDeviceDialogForForm = async () => {
|
|
|
|
|
|
// 打开工作量维护对话框
|
|
|
const openWorkloadDialog = () => {
|
|
|
+ currentPlatformWellIndex.value = -1; // 设置为-1表示普通井模式
|
|
|
+
|
|
|
// 前置校验:设计工作量不合法则直接返回
|
|
|
if (!validateWorkloadDesign()) {
|
|
|
ElMessage.error(workloadDesignError.value);
|
|
|
@@ -1241,13 +1289,17 @@ const removeWorkloadItem = (index: number) => {
|
|
|
|
|
|
// 确认工作量选择
|
|
|
const confirmWorkloadSelection = () => {
|
|
|
- // 验证数据
|
|
|
- const invalidItems = workloadList.value.some(item =>
|
|
|
- !item.workloadUnit || !item.workloadDesign
|
|
|
- );
|
|
|
+ // 验证工作量对话框中的所有数据
|
|
|
+ let allValid = true;
|
|
|
|
|
|
- if (invalidItems) {
|
|
|
- ElMessage.error('请完善所有工作量单位和工作量信息');
|
|
|
+ workloadList.value.forEach((item, index) => {
|
|
|
+ if (!validateWorkloadDialogDesign(index)) {
|
|
|
+ allValid = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!allValid) {
|
|
|
+ ElMessage.error('请完善所有工作量信息');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -1261,20 +1313,27 @@ const confirmWorkloadSelection = () => {
|
|
|
|
|
|
// 获取当前井号并存储到Map
|
|
|
let currentWellName = '';
|
|
|
- if (currentTask.value.platformWell === '1') {
|
|
|
- currentWellName = currentTask.value.wellName || (currentTask.value.platformWellDetails.length > 0
|
|
|
- ? currentTask.value.platformWellDetails[0].wellName : '');
|
|
|
+
|
|
|
+ if (currentPlatformWellIndex.value >= 0) {
|
|
|
+ // 平台井模式
|
|
|
+ const wellDetail = currentTask.value.platformWellDetails[currentPlatformWellIndex.value];
|
|
|
+ currentWellName = wellDetail.wellName;
|
|
|
+
|
|
|
+ // 同步更新平台井表格中的工作量单位
|
|
|
+ if (workloadList.value.length > 0) {
|
|
|
+ const firstItem = workloadList.value[0];
|
|
|
+ if (wellDetail.workloadUnit !== firstItem.workloadUnit) {
|
|
|
+ wellDetail.workloadUnit = firstItem.workloadUnit;
|
|
|
+ }
|
|
|
+ wellDetail.workloadDesign = firstItem.workloadDesign;
|
|
|
+ }
|
|
|
} else {
|
|
|
+ // 普通井模式
|
|
|
currentWellName = currentTask.value.wellName;
|
|
|
- }
|
|
|
- // 深拷贝存储,避免后续修改影响Map数据
|
|
|
- if (currentWellName) {
|
|
|
- workloadMap.value.set(currentWellName, JSON.parse(JSON.stringify(workloadList.value)));
|
|
|
|
|
|
- // 同步更新表单中的workloadUnit为第一项的值(确保一致性)
|
|
|
+ // 同步更新表单中的工作量单位
|
|
|
if (workloadList.value.length > 0) {
|
|
|
const firstItem = workloadList.value[0];
|
|
|
- // 只有当当前值不同时才更新,避免触发watch循环
|
|
|
if (currentTask.value.workloadUnit !== firstItem.workloadUnit) {
|
|
|
currentTask.value.workloadUnit = firstItem.workloadUnit;
|
|
|
}
|
|
|
@@ -1282,17 +1341,13 @@ const confirmWorkloadSelection = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 如果有数据,设置第一个项到表单中(保持原有逻辑)
|
|
|
- /* if (workloadList.value.length > 0) {
|
|
|
- const firstItem = workloadList.value[0];
|
|
|
- currentTask.value.workloadUnit = firstItem.workloadUnit;
|
|
|
- currentTask.value.workloadDesign = firstItem.workloadDesign;
|
|
|
- } */
|
|
|
-
|
|
|
- // 这里可以根据需要将整个workloadList存储到currentTask中
|
|
|
- // 例如:currentTask.value.workloadDesignList = [...workloadList.value];
|
|
|
+ // 存储到Map
|
|
|
+ if (currentWellName) {
|
|
|
+ workloadMap.value.set(currentWellName, JSON.parse(JSON.stringify(workloadList.value)));
|
|
|
+ }
|
|
|
|
|
|
workloadDialogVisible.value = false;
|
|
|
+ currentPlatformWellIndex.value = -1; // 重置索引
|
|
|
ElMessage.success('工作量信息已更新');
|
|
|
};
|
|
|
|
|
|
@@ -1364,6 +1419,64 @@ const getWorkloadUnitLabel = (value) => {
|
|
|
return option ? option.label : value
|
|
|
}
|
|
|
|
|
|
+// 打开平台井工作量对话框
|
|
|
+const openPlatformWellWorkloadDialog = (index) => {
|
|
|
+ currentPlatformWellIndex.value = index;
|
|
|
+ const wellDetail = currentTask.value.platformWellDetails[index];
|
|
|
+
|
|
|
+ // 前置校验
|
|
|
+ if (!validatePlatformWellWorkloadDesign(index)) {
|
|
|
+ ElMessage.error(wellDetail.workloadDesignError);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重置列表
|
|
|
+ workloadList.value = [];
|
|
|
+ hasInitialWorkload.value = false;
|
|
|
+
|
|
|
+ if (!wellDetail.wellName) {
|
|
|
+ ElMessage.warning('请先填写井号');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从Map中回显工作量数据
|
|
|
+ if (workloadMap.value.has(wellDetail.wellName)) {
|
|
|
+ workloadList.value = JSON.parse(JSON.stringify(workloadMap.value.get(wellDetail.wellName)));
|
|
|
+ hasInitialWorkload.value = workloadList.value.length > 0;
|
|
|
+ } else {
|
|
|
+ // 无历史数据时,使用当前行的值初始化
|
|
|
+ if (wellDetail.workloadUnit && wellDetail.workloadDesign) {
|
|
|
+ workloadList.value.push({
|
|
|
+ workloadUnit: wellDetail.workloadUnit,
|
|
|
+ workloadDesign: wellDetail.workloadDesign
|
|
|
+ });
|
|
|
+ hasInitialWorkload.value = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ workloadDialogVisible.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+// 校验平台井设计工作量
|
|
|
+const validatePlatformWellWorkloadDesign = (index) => {
|
|
|
+ const wellDetail = currentTask.value.platformWellDetails[index];
|
|
|
+ wellDetail.workloadDesignError = '';
|
|
|
+
|
|
|
+ const value = wellDetail.workloadDesign;
|
|
|
+ if (value === '' || value === null || value === undefined) {
|
|
|
+ wellDetail.workloadDesignError = '设计工作量不能为空';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ const numValue = Number(value);
|
|
|
+ if (isNaN(numValue) || numValue < 0) {
|
|
|
+ wellDetail.workloadDesignError = '请填写大于0的数字';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+};
|
|
|
+
|
|
|
/** 同步当前任务表单数据到表格数据 */
|
|
|
const syncCurrentTaskToTable = () => {
|
|
|
// 平台井模式特殊处理
|
|
|
@@ -1532,45 +1645,6 @@ const resetTaskForm = () => {
|
|
|
taskFormRef.value?.resetFields();
|
|
|
};
|
|
|
|
|
|
-// 添加新任务
|
|
|
-const addNewTask = () => {
|
|
|
- resetTaskForm();
|
|
|
- isNewTask.value = true;
|
|
|
-};
|
|
|
-
|
|
|
-// 保存任务
|
|
|
-const saveTask = async () => {
|
|
|
- // 验证表单
|
|
|
- try {
|
|
|
- await taskFormRef.value.validate();
|
|
|
- } catch (error) {
|
|
|
- ElMessage.error('请完善任务信息');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 设置项目ID
|
|
|
- currentTask.value.projectId = formData.value.id;
|
|
|
-
|
|
|
- if (isNewTask.value) {
|
|
|
- // 新增任务
|
|
|
- const newId = tableData.value.length > 0
|
|
|
- ? Math.max(...tableData.value.map(item => item.id)) + 1
|
|
|
- : 1;
|
|
|
-
|
|
|
- currentTask.value.id = newId;
|
|
|
- tableData.value.unshift({...currentTask.value});
|
|
|
- ElMessage.success('任务添加成功');
|
|
|
- resetTaskForm();
|
|
|
- } else {
|
|
|
- // 更新任务
|
|
|
- const index = tableData.value.findIndex(item => item.id === currentTask.value.id);
|
|
|
- if (index !== -1) {
|
|
|
- tableData.value.splice(index, 1, {...currentTask.value});
|
|
|
- ElMessage.success('任务更新成功');
|
|
|
- }
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
// 获取已选的工作量单位(排除当前行) ==========
|
|
|
const getSelectedWorkloadUnits = (currentIndex) => {
|
|
|
if (!workloadList.value || workloadList.value.length === 0) {
|
|
|
@@ -1583,26 +1657,6 @@ const getSelectedWorkloadUnits = (currentIndex) => {
|
|
|
.filter(unit => unit && unit.trim() !== '');
|
|
|
};
|
|
|
|
|
|
-// 删除当前任务
|
|
|
-const deleteCurrentTask = () => {
|
|
|
- if (!currentTask.value.id) return;
|
|
|
-
|
|
|
- ElMessageBox.confirm('确定要删除这个任务吗?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- const index = tableData.value.findIndex(item => item.id === currentTask.value.id);
|
|
|
- if (index !== -1) {
|
|
|
- tableData.value.splice(index, 1);
|
|
|
- resetTaskForm();
|
|
|
- ElMessage.success('任务删除成功');
|
|
|
- }
|
|
|
- }).catch(() => {
|
|
|
- // 取消删除
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
// 处理行点击事件
|
|
|
const handleRowClick = (row, index) => {
|
|
|
if (row) {
|
|
|
@@ -1796,6 +1850,27 @@ const open = async () => {
|
|
|
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
|
+// 获取平台井已选的工作量单位(排除当前行)
|
|
|
+const getPlatformWellWorkloadUnits = (currentIndex) => {
|
|
|
+ if (!currentTask.value.platformWellDetails || currentTask.value.platformWellDetails.length === 0) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前井号的井名
|
|
|
+ const currentWellName = currentTask.value.platformWellDetails[currentIndex]?.wellName;
|
|
|
+ if (!currentWellName) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从workloadMap中获取当前井号的工作量列表
|
|
|
+ const currentWellWorkloadList = workloadMap.value.get(currentWellName) || [];
|
|
|
+
|
|
|
+ return currentWellWorkloadList
|
|
|
+ .filter((_, index) => index !== 0)
|
|
|
+ .map(item => item.workloadUnit)
|
|
|
+ .filter(unit => unit && unit.trim() !== '');
|
|
|
+};
|
|
|
+
|
|
|
/** 自动选择合同 */
|
|
|
const autoSelectContract = async (projectId: string) => {
|
|
|
console.log('项目id:' + projectId);
|
|
|
@@ -1913,6 +1988,12 @@ const formatResponsiblePersonsForForm = (responsiblePersonIds: number[]) => {
|
|
|
return personNames.join(', ');
|
|
|
};
|
|
|
|
|
|
+// 平台井工作量加号按钮禁用状态
|
|
|
+const getPlatformWellWorkloadAddBtnDisabled = (index) => {
|
|
|
+ const wellDetail = currentTask.value.platformWellDetails[index];
|
|
|
+ return !wellDetail.workloadUnit || !!wellDetail.workloadDesignError;
|
|
|
+};
|
|
|
+
|
|
|
// 格式化填报人显示(用于表单)
|
|
|
const formatSubmittersForForm = (submitterIds: number[]) => {
|
|
|
if (!submitterIds || submitterIds.length === 0) return '';
|
|
|
@@ -2072,9 +2153,20 @@ const handlePlatformWellChange = (value) => {
|
|
|
const mainDetail = {
|
|
|
taskId: currentTask.value.id, // 关联当前任务ID
|
|
|
wellName: currentTask.value.wellName,
|
|
|
- workloadDesign: currentTask.value.workloadDesign
|
|
|
+ workloadUnit: currentTask.value.workloadUnit, // 同步工作量单位
|
|
|
+ workloadDesign: currentTask.value.workloadDesign,
|
|
|
+ workloadDesignError: ''
|
|
|
};
|
|
|
|
|
|
+ // 如果workloadMap中有主井数据,同步到平台井表格
|
|
|
+ if (workloadMap.value.has(currentTask.value.wellName)) {
|
|
|
+ const workloadData = workloadMap.value.get(currentTask.value.wellName);
|
|
|
+ if (workloadData && workloadData.length > 0) {
|
|
|
+ mainDetail.workloadUnit = workloadData[0].workloadUnit;
|
|
|
+ mainDetail.workloadDesign = workloadData[0].workloadDesign;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 清空现有详情,添加主记录
|
|
|
currentTask.value.platformWellDetails = [mainDetail];
|
|
|
} else {
|
|
|
@@ -2089,12 +2181,6 @@ const handlePlatformWellChange = (value) => {
|
|
|
// 更新备份数据
|
|
|
platformWellDetailsBackup.value = [...currentTask.value.platformWellDetails];
|
|
|
} else {
|
|
|
- // 关闭平台井时,清理所有平台井详情对应的Map数据
|
|
|
- /* currentTask.value.platformWellDetails.forEach(detail => {
|
|
|
- if (detail.wellName && workloadMap.value.has(detail.wellName)) {
|
|
|
- workloadMap.value.delete(detail.wellName);
|
|
|
- }
|
|
|
- }); */
|
|
|
|
|
|
// 如果有平台井详情,将第一个详情的数据设置回主任务
|
|
|
if (currentTask.value.platformWellDetails.length > 0) {
|
|
|
@@ -2122,6 +2208,26 @@ const handlePlatformWellChange = (value) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+// 校验工作量对话框中的设计工作量
|
|
|
+const validateWorkloadDialogDesign = (index) => {
|
|
|
+ const workloadItem = workloadList.value[index];
|
|
|
+ workloadItem.workloadDesignError = '';
|
|
|
+
|
|
|
+ const value = workloadItem.workloadDesign;
|
|
|
+ if (value === '' || value === null || value === undefined) {
|
|
|
+ workloadItem.workloadDesignError = '设计工作量不能为空';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ const numValue = Number(value);
|
|
|
+ if (isNaN(numValue) || numValue < 0) {
|
|
|
+ workloadItem.workloadDesignError = '请填写大于0的数字';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+};
|
|
|
+
|
|
|
// 获取表单中已选的工作量单位(来自workloadMap)
|
|
|
const getFormSelectedWorkloadUnits = () => {
|
|
|
// 兼容普通井/平台井的井号获取逻辑(与工作量弹窗逻辑一致)
|
|
|
@@ -2147,16 +2253,11 @@ const addPlatformWellDetail = () => {
|
|
|
const newDetail = {
|
|
|
taskId: '',
|
|
|
wellName: '',
|
|
|
- workloadDesign: ''
|
|
|
+ workloadUnit: '', // 新增工作量单位字段
|
|
|
+ workloadDesign: '',
|
|
|
+ workloadDesignError: '' // 新增错误信息字段
|
|
|
};
|
|
|
|
|
|
- // 如果是当前任务对应的平台井详情,插入到第一位
|
|
|
- /* if (currentTask.value.platformWell === '1') {
|
|
|
- currentTask.value.platformWellDetails.unshift(newDetail);
|
|
|
- } else {
|
|
|
- currentTask.value.platformWellDetails.push(newDetail);
|
|
|
- } */
|
|
|
-
|
|
|
// 将新记录添加到数组末尾,而不是开头
|
|
|
currentTask.value.platformWellDetails.push(newDetail);
|
|
|
// 添加后重新排序,确保当前任务对应的记录始终在第一行
|