You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/drawer-htmlroot/pages/smartWellRecommend.vue

183 lines
4.8 KiB
Vue

1 month ago
<template>
1 month ago
<div class="container">
<div class="data-tree">
1 month ago
<div class="oper">
<el-button type="primary" :icon="Refresh" @click="loadData"></el-button>
<el-button type="danger" :icon="Delete" @click="handleDelete"></el-button>
</div>
1 month ago
<el-table :data="fileDatas" style="width: 100%; height: 100%; border: 1px solid #dcdfe6"
@selection-change="handleSelectionChange" row-key="Id">
<el-table-column type="selection" width="28" />
<el-table-column prop="Fracture_FileName" label="文件名" width="230px">
<template #default="scope">
<el-link @click="handleOpenFile(scope.row)">{{ scope.row.Fracture_FileName }}</el-link>
</template>
</el-table-column>
<el-table-column label="操作" width="80" style="margin: 0;padding: 0;">
<template #default="scope">
<el-tooltip content="删除" placement="top">
<el-button :icon="Delete" type="danger" size="small" circle @click="handelDeleteRow(scope.row)"
style="margin-right: 5px;padding: 0;" />
</el-tooltip>
<el-tooltip content="二次布井" placement="top">
<el-button :icon="Switch" type="primary" size="small" circle @click="reCalc(scope.row)"
style="margin: 0;padding: 0;" />
</el-tooltip>
</template>
</el-table-column>
</el-table>
</div>
<div class="main">
<WellRecommend />
</div>
</div>
1 month ago
</template>
<script setup>
definePageMeta({
requiresAuth: true
});
import { ref, onMounted } from 'vue'
1 month ago
import { Refresh, Delete, Switch } from "@element-plus/icons-vue";
1 month ago
import { getWellRecommendList, deleteWellRecommendRecords } from '~/services/wellRecommandService'
import { emitter } from "~/utils/eventBus";
import { ElMessageBox } from 'element-plus';
const { $toastMessage } = useNuxtApp();
import { generateGUID } from "~/utils/common";
const selectedRows = ref([]);
const fileDatas = ref(null);
1 month ago
const loadData = async () => {
1 month ago
try {
selectedRows.value = [];
const response = await getWellRecommendList();
if (!response) {
$toastMessage.error("获取井推荐列表失败");
return;
}
1 month ago
console.log("得到图件列表:", response);
1 month ago
fileDatas.value = response;
} catch (error) {
console.error('获取井推荐列表异常:', error);
$toastMessage.error('获取井推荐列表失败!');
}
};
// 获取选中项
const handleSelectionChange = (selection) => {
selectedRows.value = selection;
1 month ago
console.log(selection);
1 month ago
}
// 单行删除
const handelDeleteRow = async (item) => {
selectedRows.value.push(item);
await handleDelete();
}
1 month ago
// 二次布井
const reCalc = (item) => {
// console.log("二次布井", item);
// 先打开文件
handleOpenFile(item);
emitter.emit("reCalc", item);
}
1 month ago
// 删除数据
const handleDelete = async () => {
if (selectedRows.value.length === 0) {
$toastMessage.warning("请选择要删除的文件!");
return;
}
ElMessageBox.confirm(`您确定要删除选中的数据吗?`, "删除确认", {
confirmButtonText: "确认删除",
cancelButtonText: "取消",
type: "warning"
})
.then(async () => {
const selectKeys = selectedRows.value.map(item => item.Id);
try {
const response = await deleteWellRecommendRecords(generateGUID(), selectKeys.join(','));
1 month ago
console.log("删除结果:", response);
1 month ago
if (response > 0) {
await loadData();
1 month ago
$toastMessage.info("删除数据成功!");
1 month ago
selectedRows.value = [];
} else {
$toastMessage.error("删除失败!");
}
} catch (error) {
$toastMessage.error("删除异常!");
console.error("删除异常:", error);
}
})
.catch(() => {
1 month ago
console.log("已取消删除!");
1 month ago
});
};
// 打开文件操作(点击操作)
const handleOpenFile = (item) => {
1 month ago
console.log("打开文件:", item);
emitter.emit("evtType", { type: 'openFile', data: JSON.stringify({ fileName: item.Fracture_FileName }) });
emitter.emit("calcPropery", item);
1 month ago
};
onMounted(async () => {
await nextTick();
await loadData();
});
</script>
<style scoped>
.data-tree {
1 month ago
width: 340px;
1 month ago
/* height: calc(100vh - 55px); */
height: 100%;
border: none;
}
.main {
width: 100%;
}
.file-links {
display: flex;
list-style: none;
gap: 0.1rem;
flex-direction: column;
overflow-y: auto;
height: 100%;
width: 100%;
margin-top: 10px;
padding-left: 10px;
}
.file-links a {
text-decoration: none;
color: #333;
padding: 0.5rem;
transition: color 0.3s;
}
.file-links a:hover {
color: #42b983;
cursor: pointer;
}
.file-links a.active {
color: #42b983;
border-bottom: 2px solid #42b983;
font-weight: bold;
}
.oper {
width: 100%;
height: 40px;
margin: 0;
padding-left: 10px;
}
</style>