PC养护站页面 新增设备和物资管理跳转功能
This commit is contained in:
parent
a416e86ca5
commit
090979fb07
@ -18,12 +18,12 @@ const routes = [
|
|||||||
component: () => import('../views/ServiceStationManagePage/index.vue')
|
component: () => import('../views/ServiceStationManagePage/index.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/yhzsb',
|
path: '/yhzsb/:data',
|
||||||
name: 'yhzsb',
|
name: 'yhzsb',
|
||||||
component: () => import('../views/EquipmentManagement/index.vue')
|
component: () => import('../views/EquipmentManagement/index.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/yhzwz',
|
path: '/yhzwz/:data',
|
||||||
name: 'yhzwz',
|
name: 'yhzwz',
|
||||||
component: () => import('../views/MaterialManagement/index.vue')
|
component: () => import('../views/MaterialManagement/index.vue')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import { h, ref, onMounted, reactive, watch, toRaw } from "vue";
|
import { h, ref, onMounted, reactive, watch, toRaw, nextTick } from "vue";
|
||||||
import { request } from "@/utils/request";
|
import { request } from "@/utils/request";
|
||||||
import { Search } from "@element-plus/icons-vue";
|
import { Search } from "@element-plus/icons-vue";
|
||||||
import DetailDialog from "./detailDialog.vue";
|
import DetailDialog from "./detailDialog.vue";
|
||||||
import EditDialog from "./editDialog.vue";
|
import EditDialog from "./editDialog.vue";
|
||||||
import AddDialog from "./addDialog.vue";
|
import AddDialog from "./addDialog.vue";
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
const treeData = ref([]);
|
const treeData = ref([]);
|
||||||
const treeProps = {
|
const treeProps = {
|
||||||
@ -122,6 +123,7 @@ const getTreeData = async () => {
|
|||||||
};
|
};
|
||||||
// 处理节点点击事件
|
// 处理节点点击事件
|
||||||
const handleNodeClick = (data, node) => {
|
const handleNodeClick = (data, node) => {
|
||||||
|
if (!data || !data.type) return;
|
||||||
if (data.type === 'area' && node.expanded === false) {
|
if (data.type === 'area' && node.expanded === false) {
|
||||||
console.log('树节点关闭', node.expanded)
|
console.log('树节点关闭', node.expanded)
|
||||||
yhzid.value = ''; // 重置养护站id
|
yhzid.value = ''; // 重置养护站id
|
||||||
@ -395,13 +397,49 @@ const openAddEquipmentModel = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
|
||||||
const treeRef = ref(null);
|
const treeRef = ref(null);
|
||||||
watch(() => filterText.value, (val) => {
|
watch(() => filterText.value, (val) => {
|
||||||
treeRef.value.filter(val || '')
|
treeRef.value.filter(val || '')
|
||||||
|
|
||||||
|
// 添加自动点击逻辑
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const visibleNodes = getFilteredVisibleNodes()
|
||||||
|
if (visibleNodes.length === 2) {
|
||||||
|
handleAutoClickNode(visibleNodes[1])
|
||||||
|
}
|
||||||
|
}, 100) // 增加 100ms 延迟确保过滤完成
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 获取过滤后的可见节点
|
||||||
|
const getFilteredVisibleNodes = () => {
|
||||||
|
return Object.values(treeRef.value?.store?.nodesMap || {})
|
||||||
|
.filter(node => node.visible && !node.isHidden)
|
||||||
|
}
|
||||||
|
const handleAutoClickNode = (node) => {
|
||||||
|
// 展开父节点
|
||||||
|
if (node.parent) {
|
||||||
|
node.parent.expanded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行点击逻辑
|
||||||
|
handleNodeClick(
|
||||||
|
node.data,
|
||||||
|
{
|
||||||
|
data: node.data,
|
||||||
|
expanded: false,
|
||||||
|
isCurrent: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => filterData, qxmc, yhzid],
|
[() => filterData, qxmc, yhzid],
|
||||||
([newFilterData, newQxmc, newYhzid]) => {
|
([newFilterData, newQxmc, newYhzid]) => {
|
||||||
@ -410,10 +448,16 @@ export default () => {
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
getTreeData();
|
onMounted(async () => {
|
||||||
getyhzsbList();
|
await getTreeData();
|
||||||
|
await getyhzsbList();
|
||||||
|
const rowData = JSON.parse(decodeURIComponent(route.params.data));
|
||||||
|
if (rowData) {
|
||||||
|
filterText.value = rowData.mc;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
treeRef,
|
treeRef,
|
||||||
|
|||||||
@ -92,7 +92,7 @@ import MyDialog from "../../component/MyDialog";
|
|||||||
const script = scriptFn();
|
const script = scriptFn();
|
||||||
const { treeRef, dialogRef } = script;
|
const { treeRef, dialogRef } = script;
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style scoped>
|
||||||
/* * {
|
/* * {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
} */
|
} */
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { h, ref, onMounted, reactive, watch, toRaw } from "vue";
|
import { h, ref, onMounted, reactive, watch, toRaw, nextTick } from "vue";
|
||||||
import { request } from "@/utils/request";
|
import { request } from "@/utils/request";
|
||||||
import { Search } from "@element-plus/icons-vue";
|
import { Search } from "@element-plus/icons-vue";
|
||||||
import DetailDialog from "./detailDialog.vue";
|
import DetailDialog from "./detailDialog.vue";
|
||||||
import EditDialog from "./editDialog.vue";
|
import EditDialog from "./editDialog.vue";
|
||||||
import AddDialog from "./addDialog.vue";
|
import AddDialog from "./addDialog.vue";
|
||||||
import { th } from "element-plus/es/locales.mjs";
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
const treeData = ref([]);
|
const treeData = ref([]);
|
||||||
const treeProps = {
|
const treeProps = {
|
||||||
@ -110,6 +110,7 @@ const getTreeData = async () => {
|
|||||||
};
|
};
|
||||||
// 处理节点点击事件
|
// 处理节点点击事件
|
||||||
const handleNodeClick = (data, node) => {
|
const handleNodeClick = (data, node) => {
|
||||||
|
if (!data || !data.type) return;
|
||||||
if (data.type === 'area' && node.expanded === false) {
|
if (data.type === 'area' && node.expanded === false) {
|
||||||
console.log('树节点关闭', node.expanded)
|
console.log('树节点关闭', node.expanded)
|
||||||
yhzid.value = ''; // 重置养护站id
|
yhzid.value = ''; // 重置养护站id
|
||||||
@ -388,8 +389,41 @@ export default () => {
|
|||||||
const treeRef = ref(null);
|
const treeRef = ref(null);
|
||||||
watch(() => filterText.value, (val) => {
|
watch(() => filterText.value, (val) => {
|
||||||
treeRef.value.filter(val || '')
|
treeRef.value.filter(val || '')
|
||||||
|
|
||||||
|
// 添加自动点击逻辑
|
||||||
|
nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const visibleNodes = getFilteredVisibleNodes()
|
||||||
|
if (visibleNodes.length === 2) {
|
||||||
|
handleAutoClickNode(visibleNodes[1])
|
||||||
|
}
|
||||||
|
}, 100) // 增加 100ms 延迟确保过滤完成
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 获取过滤后的可见节点
|
||||||
|
const getFilteredVisibleNodes = () => {
|
||||||
|
return Object.values(treeRef.value?.store?.nodesMap || {})
|
||||||
|
.filter(node => node.visible && !node.isHidden)
|
||||||
|
}
|
||||||
|
const handleAutoClickNode = (node) => {
|
||||||
|
// 展开父节点
|
||||||
|
if (node.parent) {
|
||||||
|
node.parent.expanded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行点击逻辑
|
||||||
|
handleNodeClick(
|
||||||
|
node.data,
|
||||||
|
{
|
||||||
|
data: node.data,
|
||||||
|
expanded: false,
|
||||||
|
isCurrent: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => filterData, qxmc, yhzid],
|
[() => filterData, qxmc, yhzid],
|
||||||
([newFilterData, newQxmc, newYhzid]) => {
|
([newFilterData, newQxmc, newYhzid]) => {
|
||||||
@ -399,9 +433,15 @@ export default () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
const route = useRoute()
|
||||||
getTreeData();
|
|
||||||
getyhzwzList();
|
onMounted(async () => {
|
||||||
|
await getTreeData();
|
||||||
|
await getyhzwzList();
|
||||||
|
const rowData = JSON.parse(decodeURIComponent(route.params.data));
|
||||||
|
if (rowData) {
|
||||||
|
filterText.value = rowData.mc;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
treeRef,
|
treeRef,
|
||||||
|
|||||||
@ -28,10 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-box">
|
<div class="form-box">
|
||||||
<div class="event-box">
|
<div class="event-box">
|
||||||
<el-button
|
<el-button type="primary" size="large" @click="script.openAddModel"
|
||||||
type="primary"
|
|
||||||
size="large"
|
|
||||||
@click="script.openAddModel"
|
|
||||||
>新增物资</el-button
|
>新增物资</el-button
|
||||||
>
|
>
|
||||||
<el-button type="info" size="large" @click="script.handelExport"
|
<el-button type="info" size="large" @click="script.handelExport"
|
||||||
@ -72,7 +69,7 @@ import MyDialog from "../../component/MyDialog";
|
|||||||
const script = scriptFn();
|
const script = scriptFn();
|
||||||
const { treeRef, dialogRef } = script;
|
const { treeRef, dialogRef } = script;
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style scoped>
|
||||||
/* * {
|
/* * {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
} */
|
} */
|
||||||
|
|||||||
@ -183,6 +183,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import DynamicTable from "../../component/DynamicTable";
|
import DynamicTable from "../../component/DynamicTable";
|
||||||
import { h, ref, onMounted, reactive, watch, toRaw } from "vue";
|
import { h, ref, onMounted, reactive, watch, toRaw } from "vue";
|
||||||
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { request } from "@/utils/request";
|
import { request } from "@/utils/request";
|
||||||
import { Search } from "@element-plus/icons-vue";
|
import { Search } from "@element-plus/icons-vue";
|
||||||
import MyDialog from "../../component/MyDialog";
|
import MyDialog from "../../component/MyDialog";
|
||||||
@ -408,10 +409,30 @@ const columns = [
|
|||||||
{
|
{
|
||||||
prop: "sbsl",
|
prop: "sbsl",
|
||||||
label: "设备数量",
|
label: "设备数量",
|
||||||
|
render: (row) => () =>
|
||||||
|
h(
|
||||||
|
ElButton,
|
||||||
|
{
|
||||||
|
link: true,
|
||||||
|
type: "primary",
|
||||||
|
onClick: () => handleClickSb(row),
|
||||||
|
},
|
||||||
|
() => row.sbsl
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: "wzsl",
|
prop: "wzsl",
|
||||||
label: "物资数量",
|
label: "物资数量",
|
||||||
|
render: (row) => () =>
|
||||||
|
h(
|
||||||
|
ElButton,
|
||||||
|
{
|
||||||
|
link: true,
|
||||||
|
type: "primary",
|
||||||
|
onClick: () => handleClickWz(row),
|
||||||
|
},
|
||||||
|
() => row.wzsl
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: "rysl",
|
prop: "rysl",
|
||||||
@ -475,7 +496,7 @@ const columns = [
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
if (res.code === "00000") {
|
if (res.code === "00000") {
|
||||||
ElMessage.success("删除成功");
|
ElMessage.success("删除成功");
|
||||||
@ -506,12 +527,25 @@ const pagination = reactive({
|
|||||||
getTableData();
|
getTableData();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
const handleClickSb = (row) => {
|
||||||
|
router.push({
|
||||||
|
path: `/yhzsb/${encodeURIComponent(JSON.stringify(row))}`,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClickWz = (row) => {
|
||||||
|
router.push({
|
||||||
|
path: `/yhzwz/${encodeURIComponent(JSON.stringify(row))}`,
|
||||||
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style scoped>
|
||||||
.root {
|
.root {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
// padding: 5px;
|
|
||||||
}
|
}
|
||||||
.event-box {
|
.event-box {
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
|
|||||||
463
packages/screen/src/views/SnowEventManagement/index.js
Normal file
463
packages/screen/src/views/SnowEventManagement/index.js
Normal file
@ -0,0 +1,463 @@
|
|||||||
|
import { h, ref, onMounted, reactive, watch, toRaw, nextTick } from "vue";
|
||||||
|
import { request } from "@/utils/request";
|
||||||
|
import { Search } from "@element-plus/icons-vue";
|
||||||
|
import DetailDialog from "./detailDialog.vue";
|
||||||
|
import EditDialog from "./editDialog.vue";
|
||||||
|
import AddDialog from "./addDialog.vue";
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
const treeData = ref([]);
|
||||||
|
const treeProps = {
|
||||||
|
children: "children",
|
||||||
|
label: "name",
|
||||||
|
key: "id",
|
||||||
|
}
|
||||||
|
const filterText = ref(''); // 树节点过滤条件
|
||||||
|
const tableData = ref([]);
|
||||||
|
const qxmc = ref(''); // 区县名称
|
||||||
|
const yhzid = ref(''); // 养护站id
|
||||||
|
const filterData = reactive({
|
||||||
|
wzmc: '',
|
||||||
|
}); // 表格过滤条件
|
||||||
|
const pagination = reactive({
|
||||||
|
current: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 0,
|
||||||
|
pageSizes: [10, 20, 50],
|
||||||
|
layout: "prev, pager, next, jumper",
|
||||||
|
onChange: (page, pageSize) => {
|
||||||
|
pagination.current = page;
|
||||||
|
pagination.pageSize = pageSize;
|
||||||
|
getyhzwzList(qxmc.value, yhzid.value, filterData);
|
||||||
|
},
|
||||||
|
}); // 表格分页
|
||||||
|
const modelVisible = ref(false); // 弹窗显示状态
|
||||||
|
const model = reactive({
|
||||||
|
title: '',
|
||||||
|
content: null,
|
||||||
|
props: {},
|
||||||
|
onCancel: null,
|
||||||
|
onConfirm: null,
|
||||||
|
}); // 弹窗内容
|
||||||
|
const dialogType = ref(''); // 弹窗类型
|
||||||
|
const dialogRef = ref(null); // 弹窗实例
|
||||||
|
|
||||||
|
const INIT_FORM = {
|
||||||
|
rkrq: "",
|
||||||
|
rkdw: "",
|
||||||
|
sl: "",
|
||||||
|
dw: "",
|
||||||
|
cfdd: "",
|
||||||
|
fzr: "",
|
||||||
|
lxdh: "",
|
||||||
|
ye: "",
|
||||||
|
qxmc: "",
|
||||||
|
wzmc: "",
|
||||||
|
fzrid: "",
|
||||||
|
yhzid: "",
|
||||||
|
}; // 表单初始值
|
||||||
|
const form = reactive({ ...INIT_FORM }); // 表单
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 节点过滤函数
|
||||||
|
const filterNode = (value, node) => {
|
||||||
|
const keyword = (value || '').toLowerCase();
|
||||||
|
|
||||||
|
const nodeData = node || {}
|
||||||
|
|
||||||
|
// 处理区域节点匹配
|
||||||
|
if (nodeData.type === 'area') {
|
||||||
|
return (nodeData.rawName || '').toLowerCase().includes(keyword)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理站点节点匹配
|
||||||
|
if (nodeData.type === 'site') {
|
||||||
|
const parentData = node.parent?.data?.type === 'area' ? node.parent.data : {}
|
||||||
|
const parentMatch = (parentData.rawName || '').toLowerCase().includes(keyword)
|
||||||
|
return parentMatch || (nodeData.name || '').toLowerCase().includes(keyword)
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// 获取养护站列表分组
|
||||||
|
const getTreeData = async () => {
|
||||||
|
try {
|
||||||
|
const res = await request({
|
||||||
|
url: '/snow-ops-platform/yhz/listAreaGroup',
|
||||||
|
method: 'GET'
|
||||||
|
})
|
||||||
|
if (res.code === '00000') {
|
||||||
|
treeData.value = Object.entries(res.data).map(([areaName, sites]) => ({
|
||||||
|
id: areaName,
|
||||||
|
name: `${areaName}(${sites.length})`,
|
||||||
|
type: 'area',
|
||||||
|
children: sites.map(site => ({
|
||||||
|
id: site.id,
|
||||||
|
name: `${site.mc}(${site.wzsl})`,
|
||||||
|
type: 'site'
|
||||||
|
})),
|
||||||
|
rawName: areaName // 原始名称
|
||||||
|
}));
|
||||||
|
console.log('treeData', toRaw(treeData.value))
|
||||||
|
} else {
|
||||||
|
throw new Error(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(error.message);
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 处理节点点击事件
|
||||||
|
const handleNodeClick = (data, node) => {
|
||||||
|
if (!data || !data.type) return;
|
||||||
|
if (data.type === 'area' && node.expanded === false) {
|
||||||
|
console.log('树节点关闭', node.expanded)
|
||||||
|
yhzid.value = ''; // 重置养护站id
|
||||||
|
qxmc.value = ''; // 重置区县名称
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.type === 'area') {
|
||||||
|
console.log('你点击的是区县', data.id)
|
||||||
|
yhzid.value = ''; // 重置养护站id
|
||||||
|
qxmc.value = data.id; // 保存区县名称
|
||||||
|
|
||||||
|
}
|
||||||
|
if (data.type === 'site') {
|
||||||
|
console.log('你点击的是站点', data.name)
|
||||||
|
yhzid.value = data.id; // 保存养护站id
|
||||||
|
qxmc.value = ''; // 重置区县名称
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取养护站物资列表
|
||||||
|
const getyhzwzList = async (qxmc, yhzid, filterData) => {
|
||||||
|
try {
|
||||||
|
const data = {
|
||||||
|
qxmc: qxmc,
|
||||||
|
yhzid: yhzid,
|
||||||
|
wzmc: filterData?.wzmc || '',
|
||||||
|
pageNum: pagination.current,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
}
|
||||||
|
const res = await request({
|
||||||
|
url: '/snow-ops-platform/yjwz/list',
|
||||||
|
method: 'GET',
|
||||||
|
params: data,
|
||||||
|
})
|
||||||
|
if (res.code === '00000') {
|
||||||
|
tableData.value = res.data.records;
|
||||||
|
pagination.total = res.data.total;
|
||||||
|
} else {
|
||||||
|
tableData.value = [];
|
||||||
|
pagination.total = 0;
|
||||||
|
throw new Error(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(error.message);
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
prop: 'wzmc',
|
||||||
|
label: '物资名称',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'ye',
|
||||||
|
label: '余量',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'rkdw',
|
||||||
|
label: '入库单位',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'rkrq',
|
||||||
|
label: '入库日期',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'sl',
|
||||||
|
label: '数量',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'dw',
|
||||||
|
label: '单位',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'cfdd',
|
||||||
|
label: '存放地点',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'fzr',
|
||||||
|
label: '负责人',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'lxdh',
|
||||||
|
label: '联系电话',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'qxmc',
|
||||||
|
label: '所属区县',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "操作",
|
||||||
|
fixed: "right",
|
||||||
|
width: 150,
|
||||||
|
render: (row) => () =>
|
||||||
|
h("div", { class: "action-btns" }, [
|
||||||
|
h(
|
||||||
|
ElButton,
|
||||||
|
{
|
||||||
|
type: "primary",
|
||||||
|
link: true,
|
||||||
|
onClick: async () => {
|
||||||
|
dialogType.value = 'detail'
|
||||||
|
await getDetailData(row);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
() => "详情"
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
ElButton,
|
||||||
|
{
|
||||||
|
type: "primary",
|
||||||
|
link: true,
|
||||||
|
onClick: async () => {
|
||||||
|
dialogType.value = 'edit'
|
||||||
|
await getDetailData(row);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
() => "编辑"
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
ElButton,
|
||||||
|
{
|
||||||
|
type: "danger",
|
||||||
|
link: true,
|
||||||
|
onClick: async () => {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm("确定要删除该设备吗?", "删除确认", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning",
|
||||||
|
});
|
||||||
|
const res = await request({
|
||||||
|
url: `/snow-ops-platform/yjwz/delete`,
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
rid: row.rid,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (res.code === '00000') {
|
||||||
|
ElMessage.success('删除成功');
|
||||||
|
getyhzwzList(qxmc.value, yhzid.value, filterData);
|
||||||
|
} else {
|
||||||
|
throw new Error(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(error.message);
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
() => "删除"
|
||||||
|
),
|
||||||
|
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const handleEdit = async () => {
|
||||||
|
try {
|
||||||
|
await dialogRef?.value?.dynamicComponentRef?.formRef.validate();
|
||||||
|
console.log('form', toRaw(form))
|
||||||
|
const res = await request({
|
||||||
|
url: '/snow-ops-platform/yjwz/update',
|
||||||
|
method: 'POST',
|
||||||
|
data: toRaw(form),
|
||||||
|
});
|
||||||
|
if (res.code === '00000') {
|
||||||
|
ElMessage.success('编辑成功');
|
||||||
|
dialogType.value = '';
|
||||||
|
modelVisible.value = false;
|
||||||
|
getyhzwzList(qxmc.value, yhzid.value, filterData);
|
||||||
|
} else {
|
||||||
|
throw new Error(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(error.message);
|
||||||
|
console.log('error', error)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取养护站物资详情
|
||||||
|
const getDetailData = async (row) => {
|
||||||
|
try {
|
||||||
|
const res = await request({
|
||||||
|
url: `/snow-ops-platform/yjwz/getById?rid=${row.rid}`,
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
if (!res || res.code !== '00000') {
|
||||||
|
throw new Error('获取物资详情失败')
|
||||||
|
}
|
||||||
|
if (res.code === '00000') {
|
||||||
|
if (dialogType.value === 'detail') {
|
||||||
|
model.title = `物资详情`;
|
||||||
|
model.content = DetailDialog;
|
||||||
|
model.props = {
|
||||||
|
detailData: res.data,
|
||||||
|
};
|
||||||
|
model.onCancel = () => {
|
||||||
|
dialogType.value = '';
|
||||||
|
modelVisible.value = false;
|
||||||
|
};
|
||||||
|
model.onConfirm = () => {
|
||||||
|
dialogType.value = '';
|
||||||
|
modelVisible.value = false;
|
||||||
|
};
|
||||||
|
modelVisible.value = true;
|
||||||
|
}
|
||||||
|
if (dialogType.value === 'edit') {
|
||||||
|
model.title = `编辑物资`;
|
||||||
|
model.content = EditDialog;
|
||||||
|
Object.assign(form, res.data);
|
||||||
|
model.props = {
|
||||||
|
detailData: res.data,
|
||||||
|
form: form,
|
||||||
|
};
|
||||||
|
model.onCancel = () => {
|
||||||
|
dialogType.value = '';
|
||||||
|
modelVisible.value = false;
|
||||||
|
};
|
||||||
|
model.onConfirm = async () => {
|
||||||
|
await handleEdit();
|
||||||
|
};
|
||||||
|
modelVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(error.message);
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 打开新增物资弹窗
|
||||||
|
const openAddModel = () => {
|
||||||
|
model.title = `新增物资`;
|
||||||
|
model.content = AddDialog;
|
||||||
|
Object.assign(form, INIT_FORM);
|
||||||
|
model.props = {
|
||||||
|
detailData: {},
|
||||||
|
form: form,
|
||||||
|
};
|
||||||
|
model.onCancel = () => {
|
||||||
|
dialogType.value = '';
|
||||||
|
modelVisible.value = false;
|
||||||
|
};
|
||||||
|
model.onConfirm = async () => {
|
||||||
|
try {
|
||||||
|
console.log('form', toRaw(form))
|
||||||
|
const res = await request({
|
||||||
|
url: '/snow-ops-platform/yjwz/add',
|
||||||
|
method: 'POST',
|
||||||
|
data: toRaw(form),
|
||||||
|
});
|
||||||
|
if (res.code === '00000') {
|
||||||
|
ElMessage.success('新增成功');
|
||||||
|
dialogType.value = '';
|
||||||
|
modelVisible.value = false;
|
||||||
|
getyhzwzList(qxmc.value, yhzid.value, filterData);
|
||||||
|
} else {
|
||||||
|
throw new Error(res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(error.message);
|
||||||
|
console.log('error', error)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
modelVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default () => {
|
||||||
|
|
||||||
|
const treeRef = ref(null);
|
||||||
|
watch(() => filterText.value, (val) => {
|
||||||
|
treeRef.value.filter(val || '')
|
||||||
|
|
||||||
|
// 添加自动点击逻辑
|
||||||
|
nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const visibleNodes = getFilteredVisibleNodes()
|
||||||
|
if (visibleNodes.length === 2) {
|
||||||
|
handleAutoClickNode(visibleNodes[1])
|
||||||
|
}
|
||||||
|
}, 100) // 增加 100ms 延迟确保过滤完成
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
// 获取过滤后的可见节点
|
||||||
|
const getFilteredVisibleNodes = () => {
|
||||||
|
return Object.values(treeRef.value?.store?.nodesMap || {})
|
||||||
|
.filter(node => node.visible && !node.isHidden)
|
||||||
|
}
|
||||||
|
const handleAutoClickNode = (node) => {
|
||||||
|
// 展开父节点
|
||||||
|
if (node.parent) {
|
||||||
|
node.parent.expanded = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行点击逻辑
|
||||||
|
handleNodeClick(
|
||||||
|
node.data,
|
||||||
|
{
|
||||||
|
data: node.data,
|
||||||
|
expanded: false,
|
||||||
|
isCurrent: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[() => filterData, qxmc, yhzid],
|
||||||
|
([newFilterData, newQxmc, newYhzid]) => {
|
||||||
|
getyhzwzList(newQxmc, newYhzid, newFilterData)
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await getTreeData();
|
||||||
|
await getyhzwzList();
|
||||||
|
const rowData = JSON.parse(decodeURIComponent(route.params.data));
|
||||||
|
if (rowData) {
|
||||||
|
filterText.value = rowData.mc;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
treeRef,
|
||||||
|
treeData,
|
||||||
|
treeProps,
|
||||||
|
filterText,
|
||||||
|
filterNode,
|
||||||
|
handleNodeClick,
|
||||||
|
|
||||||
|
tableData,
|
||||||
|
filterData,
|
||||||
|
pagination,
|
||||||
|
columns,
|
||||||
|
modelVisible,
|
||||||
|
dialogRef,
|
||||||
|
model,
|
||||||
|
openAddModel,
|
||||||
|
}
|
||||||
|
}
|
||||||
149
packages/screen/src/views/SnowEventManagement/index.vue
Normal file
149
packages/screen/src/views/SnowEventManagement/index.vue
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
<template>
|
||||||
|
<div class="root">
|
||||||
|
<div class="left-tree">
|
||||||
|
<div class="fillter-box">
|
||||||
|
<el-input
|
||||||
|
v-model="script.filterText.value"
|
||||||
|
placeholder="请输入搜索内容"
|
||||||
|
clearable
|
||||||
|
></el-input>
|
||||||
|
</div>
|
||||||
|
<div class="tree-box">
|
||||||
|
<el-tree
|
||||||
|
ref="treeRef"
|
||||||
|
:data="script.treeData.value"
|
||||||
|
:props="script.treeProps"
|
||||||
|
@node-click="script.handleNodeClick"
|
||||||
|
accordion
|
||||||
|
:filter-node-method="script.filterNode"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="right-form">
|
||||||
|
<div class="select-box">
|
||||||
|
<div class="inline-flex">
|
||||||
|
<label>物资名称:</label>
|
||||||
|
<el-input v-model="script.filterData.wzmc"></el-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-box">
|
||||||
|
<div class="event-box">
|
||||||
|
<el-button type="primary" size="large" @click="script.openAddModel"
|
||||||
|
>新增物资</el-button
|
||||||
|
>
|
||||||
|
<el-button type="info" size="large" @click="script.handelExport"
|
||||||
|
>导出</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-content">
|
||||||
|
<DynamicTable
|
||||||
|
:dataSource="script.tableData.value"
|
||||||
|
:columns="script.columns"
|
||||||
|
:autoHeight="true"
|
||||||
|
:pagination="script.pagination"
|
||||||
|
></DynamicTable>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="model-box">
|
||||||
|
<MyDialog
|
||||||
|
v-model="script.modelVisible.value"
|
||||||
|
:title="script.model?.title"
|
||||||
|
:dynamicComponent="script.model?.content"
|
||||||
|
:component-props="script.model?.props"
|
||||||
|
:onConfirm="script.model?.onConfirm"
|
||||||
|
:onCancel="script.model?.onCancel"
|
||||||
|
ref="dialogRef"
|
||||||
|
width="60%"
|
||||||
|
>
|
||||||
|
</MyDialog>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import scriptFn from "./index.js";
|
||||||
|
import DynamicTable from "../../component/DynamicTable";
|
||||||
|
import MyDialog from "../../component/MyDialog";
|
||||||
|
|
||||||
|
const script = scriptFn();
|
||||||
|
const { treeRef, dialogRef } = script;
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
/* * {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
} */
|
||||||
|
.root {
|
||||||
|
height: 100%;
|
||||||
|
/* padding: 45px; */
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 左侧树形结构区域 */
|
||||||
|
.left-tree {
|
||||||
|
width: 20vw;
|
||||||
|
height: 100%;
|
||||||
|
padding: 25px 25px 0 25px;
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.fillter-box {
|
||||||
|
width: 100%;
|
||||||
|
height: 60px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.tree-box {
|
||||||
|
width: 100%;
|
||||||
|
height: calc(100% - 60px);
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 右侧表单区域 */
|
||||||
|
.right-form {
|
||||||
|
width: 80vw;
|
||||||
|
height: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.select-box {
|
||||||
|
width: 100%;
|
||||||
|
height: 60px;
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
.inline-flex {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.inline-flex label {
|
||||||
|
white-space: nowrap; /* 禁止换行 */
|
||||||
|
}
|
||||||
|
.form-box {
|
||||||
|
width: 100%;
|
||||||
|
height: calc(100% - 60px);
|
||||||
|
overflow: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.event-box {
|
||||||
|
width: 100%;
|
||||||
|
height: 60px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
.form-content {
|
||||||
|
width: 100%;
|
||||||
|
height: calc(100% - 60px);
|
||||||
|
}
|
||||||
|
.model-box {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
x
Reference in New Issue
Block a user