|
@@ -81,69 +81,71 @@
|
|
|
</ContentWrap>
|
|
|
|
|
|
<!-- 列表 -->
|
|
|
- <ContentWrap>
|
|
|
- <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
|
- <el-table-column :label="t('iotDevice.serial')" width="70" align="center">
|
|
|
- <template #default="scope">
|
|
|
- {{ scope.$index + 1 }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="客户名称" align="center" prop="manufactureName" />
|
|
|
- <el-table-column label="合同名称" align="center" prop="contractName" />
|
|
|
- <el-table-column label="合同编号" align="center" prop="contractCode" />
|
|
|
- <el-table-column label="井号" align="center" prop="wellName" />
|
|
|
- <!-- <el-table-column label="井型/井别" align="center" prop="wellType" /> -->
|
|
|
- <el-table-column :label="t('project.wellType')" align="center" prop="wellType" min-width="90">
|
|
|
- <template #default="scope">
|
|
|
- <dict-tag :type="DICT_TYPE.PMS_PROJECT_WELL_TYPE" :value="scope.row.wellType" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="施工地点" align="center" prop="location" />
|
|
|
- <!-- <el-table-column label="施工工艺" align="center" prop="technique" /> -->
|
|
|
- <el-table-column :label="t('project.technology')" align="center" prop="technique" min-width="90">
|
|
|
- <template #default="scope">
|
|
|
- <dict-tag :type="DICT_TYPE.PMS_PROJECT_TECHNOLOGY" :value="scope.row.technique" />
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="设计工作量" align="center" prop="workloadDesign" />
|
|
|
- <el-table-column
|
|
|
- label="创建时间"
|
|
|
- align="center"
|
|
|
- prop="createTime"
|
|
|
- :formatter="dateFormatter"
|
|
|
- width="180px"
|
|
|
- />
|
|
|
- <!--
|
|
|
- <el-table-column label="备注" align="center" prop="remark" /> -->
|
|
|
- <el-table-column label="操作" align="center" min-width="120px">
|
|
|
- <template #default="scope">
|
|
|
- <el-button
|
|
|
- link
|
|
|
- type="primary"
|
|
|
- @click="openPlanDialog(scope.row)"
|
|
|
- v-hasPermi="['rq:iot-project-task:update']"
|
|
|
- >
|
|
|
- 计划
|
|
|
- </el-button>
|
|
|
- <el-button
|
|
|
- link
|
|
|
- type="primary"
|
|
|
- @click="openForm('update', scope.row.id,scope.row.projectId)"
|
|
|
- v-hasPermi="['rq:iot-project-task:update']"
|
|
|
- >
|
|
|
- 编辑
|
|
|
- </el-button>
|
|
|
- <el-button
|
|
|
- link
|
|
|
- type="danger"
|
|
|
- @click="handleDelete(scope.row.id)"
|
|
|
- v-hasPermi="['rq:iot-project-task:delete']"
|
|
|
- >
|
|
|
- 删除
|
|
|
- </el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
+ <ContentWrap ref="tableContainerRef">
|
|
|
+ <div class="table-container">
|
|
|
+ <el-table ref="tableRef" v-loading="loading" :data="list" :stripe="true" style="width: 100%" :cell-style="{padding: '5px'}">
|
|
|
+ <el-table-column :label="t('iotDevice.serial')" :width="columnWidths.serial" align="center" v-if="false">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.$index + 1 }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="客户名称" align="center" prop="manufactureName" :width="columnWidths.manufactureName" />
|
|
|
+ <el-table-column label="合同名称" align="center" prop="contractName" :width="columnWidths.contractName" />
|
|
|
+ <el-table-column label="合同编号" align="center" prop="contractCode" :width="columnWidths.contractCode" />
|
|
|
+ <el-table-column label="井号" align="center" prop="wellName" :width="columnWidths.wellName" />
|
|
|
+ <!-- <el-table-column label="井型/井别" align="center" prop="wellType" /> -->
|
|
|
+ <el-table-column :label="t('project.wellType')" align="center" prop="wellType" :width="columnWidths.wellType">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :type="DICT_TYPE.PMS_PROJECT_WELL_TYPE" :value="scope.row.wellType" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="施工地点" align="center" prop="location" :width="columnWidths.location" />
|
|
|
+ <!-- <el-table-column label="施工工艺" align="center" prop="technique" /> -->
|
|
|
+ <el-table-column :label="t('project.technology')" align="center" prop="technique" :width="columnWidths.technique">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :type="DICT_TYPE.PMS_PROJECT_TECHNOLOGY" :value="scope.row.technique" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="设计工作量" align="center" prop="workloadDesign" :width="columnWidths.workloadDesign"/>
|
|
|
+ <el-table-column
|
|
|
+ label="创建时间"
|
|
|
+ align="center"
|
|
|
+ prop="createTime"
|
|
|
+ :formatter="dateFormatter"
|
|
|
+ :width="columnWidths.createTime"
|
|
|
+ />
|
|
|
+ <!--
|
|
|
+ <el-table-column label="备注" align="center" prop="remark" /> -->
|
|
|
+ <el-table-column label="操作" align="center" :width="columnWidths.operation" fixed="right">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ @click="openPlanDialog(scope.row)"
|
|
|
+ v-hasPermi="['rq:iot-project-task:update']"
|
|
|
+ >
|
|
|
+ 计划
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ @click="openForm('update', scope.row.id,scope.row.projectId)"
|
|
|
+ v-hasPermi="['rq:iot-project-task:update']"
|
|
|
+ >
|
|
|
+ 编辑
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="danger"
|
|
|
+ @click="handleDelete(scope.row.id)"
|
|
|
+ v-hasPermi="['rq:iot-project-task:delete']"
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
<!-- 分页 -->
|
|
|
<Pagination
|
|
|
:total="total"
|
|
@@ -243,7 +245,7 @@ import * as DictDataApi from '@/api/system/dict/dict.data'
|
|
|
import { DictDataVO } from '@/api/system/dict/dict.data'
|
|
|
import dayjs from 'dayjs'
|
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
-import { ref, reactive, onMounted, computed } from 'vue'
|
|
|
+import { ref, reactive, onMounted, computed, nextTick, watch, onUnmounted } from 'vue'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
|
/** 项目信息任务拆分 列表 */
|
|
@@ -284,6 +286,43 @@ const { push } = useRouter() // 路由跳转
|
|
|
|
|
|
const COMPLETED_STATUS = 6;
|
|
|
|
|
|
+// 表格引用
|
|
|
+const tableRef = ref()
|
|
|
+// 表格容器引用
|
|
|
+const tableContainerRef = ref()
|
|
|
+
|
|
|
+// 列宽度配置
|
|
|
+const columnWidths = ref({
|
|
|
+ serial: '50px',
|
|
|
+ manufactureName: '120px',
|
|
|
+ contractName: '150px',
|
|
|
+ contractCode: '120px',
|
|
|
+ wellName: '100px',
|
|
|
+ wellType: '100px',
|
|
|
+ location: '120px',
|
|
|
+ technique: '100px',
|
|
|
+ workloadDesign: '100px',
|
|
|
+ createTime: '150px',
|
|
|
+ operation: '200px'
|
|
|
+})
|
|
|
+
|
|
|
+// 计算文本宽度
|
|
|
+const getTextWidth = (text: string, fontSize = 14) => {
|
|
|
+ const span = document.createElement('span');
|
|
|
+ span.style.visibility = 'hidden';
|
|
|
+ span.style.position = 'absolute';
|
|
|
+ span.style.whiteSpace = 'nowrap';
|
|
|
+ span.style.fontSize = `${fontSize}px`;
|
|
|
+ span.style.fontFamily = 'inherit';
|
|
|
+ span.innerText = text;
|
|
|
+
|
|
|
+ document.body.appendChild(span);
|
|
|
+ const width = span.offsetWidth;
|
|
|
+ document.body.removeChild(span);
|
|
|
+
|
|
|
+ return width;
|
|
|
+};
|
|
|
+
|
|
|
// 计划相关状态
|
|
|
const planDialogVisible = ref(false)
|
|
|
// const planList = ref<Array<{name: string, value: string, startTime: string, endTime: string}>>([])
|
|
@@ -292,6 +331,29 @@ const saveLoading = ref(false)
|
|
|
const currentRow = ref<IotProjectTaskVO | null>(null)
|
|
|
const workProgressDictOptions = ref<any[]>([]) // 施工进度字典选项
|
|
|
|
|
|
+const wellTypeDictOptions = ref<any[]>([]) // 井型字典选项
|
|
|
+const technologyDictOptions = ref<any[]>([]) // 施工工艺字典选项
|
|
|
+
|
|
|
+/** 获取井型字典数据 */
|
|
|
+const getWellTypeDictOptions = async () => {
|
|
|
+ try {
|
|
|
+ wellTypeDictOptions.value = getIntDictOptions(DICT_TYPE.PMS_PROJECT_WELL_TYPE)
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取井型字典失败:', error)
|
|
|
+ wellTypeDictOptions.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 获取施工工艺字典数据 */
|
|
|
+const getTechnologyDictOptions = async () => {
|
|
|
+ try {
|
|
|
+ technologyDictOptions.value = getIntDictOptions(DICT_TYPE.PMS_PROJECT_TECHNOLOGY)
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取施工工艺字典失败:', error)
|
|
|
+ technologyDictOptions.value = []
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/** 时间戳转换为日期时间字符串(使用dayjs处理) */
|
|
|
const timestampToDateTime = (timestamp: number | null): string => {
|
|
|
if (!timestamp) return ''
|
|
@@ -433,11 +495,102 @@ const getList = async () => {
|
|
|
const data = await IotProjectTaskApi.getIotProjectTaskList(queryParams)
|
|
|
list.value = data.list
|
|
|
total.value = data.total
|
|
|
+
|
|
|
+ // 获取数据后计算列宽
|
|
|
+ nextTick(() => {
|
|
|
+ calculateColumnWidths();
|
|
|
+ });
|
|
|
} finally {
|
|
|
loading.value = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 计算列宽度
|
|
|
+const calculateColumnWidths = () => {
|
|
|
+ const MIN_WIDTH = 80; // 最小列宽
|
|
|
+ const PADDING = 25; // 列内边距
|
|
|
+ const FLEXIBLE_COLUMNS = ['manufactureName', 'contractName', 'contractCode', 'wellName', 'location']; // 可伸缩列
|
|
|
+
|
|
|
+ // 确保表格容器存在
|
|
|
+ if (!tableContainerRef.value?.$el) return;
|
|
|
+
|
|
|
+ const container = tableContainerRef.value.$el;
|
|
|
+ const containerWidth = container.clientWidth;
|
|
|
+
|
|
|
+ // 1. 计算所有列的最小宽度
|
|
|
+ const minWidths: Record<string, number> = {};
|
|
|
+ let totalMinWidth = 0;
|
|
|
+
|
|
|
+ // 计算列最小宽度的函数
|
|
|
+ const calculateColumnMinWidth = (key: string, label: string, getValue: Function) => {
|
|
|
+ const headerWidth = getTextWidth(label) * 1.2;
|
|
|
+ let contentMaxWidth = 0;
|
|
|
+
|
|
|
+ // 计算内容最大宽度
|
|
|
+ list.value.forEach((row, index) => {
|
|
|
+ const text = String(getValue ? getValue(row, index) : (row[key] || ''));
|
|
|
+ const textWidth = getTextWidth(text);
|
|
|
+ if (textWidth > contentMaxWidth) contentMaxWidth = textWidth;
|
|
|
+ });
|
|
|
+
|
|
|
+ const minWidth = Math.max(headerWidth, contentMaxWidth, MIN_WIDTH) + PADDING;
|
|
|
+ minWidths[key] = minWidth;
|
|
|
+ totalMinWidth += minWidth;
|
|
|
+ return minWidth;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 计算各列最小宽度
|
|
|
+ calculateColumnMinWidth('serial', t('iotDevice.serial'), (row: any, index: number) => `${index + 1}`);
|
|
|
+ calculateColumnMinWidth('manufactureName', '客户名称', (row: any) => row.manufactureName);
|
|
|
+ calculateColumnMinWidth('contractName', '合同名称', (row: any) => row.contractName);
|
|
|
+ calculateColumnMinWidth('contractCode', '合同编号', (row: any) => row.contractCode);
|
|
|
+ calculateColumnMinWidth('wellName', '井号', (row: any) => row.wellName);
|
|
|
+ calculateColumnMinWidth('wellType', t('project.wellType'), (row: any) => {
|
|
|
+ const dict = wellTypeDictOptions.value.find(d => d.value === row.wellType);
|
|
|
+ return dict ? dict.label : '';
|
|
|
+ });
|
|
|
+ calculateColumnMinWidth('location', '施工地点', (row: any) => row.location);
|
|
|
+ calculateColumnMinWidth('technique', t('project.technology'), (row: any) => {
|
|
|
+ const dict = technologyDictOptions.value.find(d => d.value === row.technique);
|
|
|
+ return dict ? dict.label : '';
|
|
|
+ });
|
|
|
+ calculateColumnMinWidth('workloadDesign', '设计工作量', (row: any) => row.workloadDesign);
|
|
|
+ calculateColumnMinWidth('createTime', '创建时间', (row: any) => dateFormatter(null, null, row.createTime));
|
|
|
+
|
|
|
+ // 操作列固定宽度
|
|
|
+ minWidths.operation = 200;
|
|
|
+ totalMinWidth += 200;
|
|
|
+
|
|
|
+ // 2. 计算可伸缩列最终宽度
|
|
|
+ const newWidths: Record<string, string> = {};
|
|
|
+ const availableWidth = containerWidth - 17; // 减去滚动条宽度
|
|
|
+
|
|
|
+ // 应用最小宽度到所有列
|
|
|
+ Object.keys(minWidths).forEach(key => {
|
|
|
+ newWidths[key] = `${minWidths[key]}px`;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 计算可伸缩列需要的宽度
|
|
|
+ if (totalMinWidth < availableWidth) {
|
|
|
+ // 有剩余空间:按比例分配给可伸缩列
|
|
|
+ const extraSpace = availableWidth - totalMinWidth;
|
|
|
+ const flexibleColumnCount = FLEXIBLE_COLUMNS.length;
|
|
|
+ const spacePerColumn = Math.floor(extraSpace / flexibleColumnCount);
|
|
|
+
|
|
|
+ FLEXIBLE_COLUMNS.forEach(key => {
|
|
|
+ newWidths[key] = `${minWidths[key] + spacePerColumn}px`;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 更新列宽配置
|
|
|
+ columnWidths.value = newWidths;
|
|
|
+
|
|
|
+ // 4. 触发表格重新布局
|
|
|
+ nextTick(() => {
|
|
|
+ tableRef.value?.doLayout();
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
/** 搜索按钮操作 */
|
|
|
const handleQuery = () => {
|
|
|
queryParams.pageNo = 1
|
|
@@ -488,10 +641,80 @@ const handleExport = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 声明 ResizeObserver 实例
|
|
|
+let resizeObserver: ResizeObserver | null = null;
|
|
|
+
|
|
|
/** 初始化 **/
|
|
|
onMounted(() => {
|
|
|
getList()
|
|
|
// 预加载字典数据
|
|
|
getWorkProgressDictOptions()
|
|
|
+ getWellTypeDictOptions()
|
|
|
+ getTechnologyDictOptions()
|
|
|
+
|
|
|
+ // 创建 ResizeObserver 监听表格容器尺寸变化
|
|
|
+ if (tableContainerRef.value?.$el) {
|
|
|
+ resizeObserver = new ResizeObserver(() => {
|
|
|
+ // 使用防抖避免频繁触发
|
|
|
+ clearTimeout((window as any).resizeTimer);
|
|
|
+ (window as any).resizeTimer = setTimeout(() => {
|
|
|
+ calculateColumnWidths();
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
+ resizeObserver.observe(tableContainerRef.value.$el);
|
|
|
+ }
|
|
|
})
|
|
|
+
|
|
|
+onUnmounted(() => {
|
|
|
+ // 清除 ResizeObserver
|
|
|
+ if (resizeObserver && tableContainerRef.value?.$el) {
|
|
|
+ resizeObserver.unobserve(tableContainerRef.value.$el);
|
|
|
+ resizeObserver = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清除定时器
|
|
|
+ if ((window as any).resizeTimer) {
|
|
|
+ clearTimeout((window as any).resizeTimer);
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+// 监听列表数据变化重新计算列宽
|
|
|
+watch(list, () => {
|
|
|
+ nextTick(calculateColumnWidths)
|
|
|
+}, { deep: true })
|
|
|
+
|
|
|
</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+/* 表格容器样式,确保水平滚动 */
|
|
|
+.table-container {
|
|
|
+ width: 100%;
|
|
|
+ overflow-x: auto;
|
|
|
+}
|
|
|
+
|
|
|
+/* 确保表格单元格内容不换行 */
|
|
|
+:deep(.el-table .cell) {
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+/* 确保表格列标题不换行 */
|
|
|
+:deep(.el-table th > .cell) {
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+/* 调整表格最小宽度,确保内容完全显示 */
|
|
|
+:deep(.el-table) {
|
|
|
+ min-width: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+/* 强制显示所有内容,防止省略号 */
|
|
|
+:deep(.el-table td.el-table__cell),
|
|
|
+:deep(.el-table th.el-table__cell) {
|
|
|
+ overflow: visible !important;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.el-table .cell) {
|
|
|
+ overflow: visible !important;
|
|
|
+ text-overflow: clip !important;
|
|
|
+}
|
|
|
+</style>
|