运维管理平台前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
5.3 KiB

4 months ago
<template>
<PageWrapper dense>
<a-row>
<a-col :span="4" style="margin-top: 1%">
<a-tree
:show-icon="true"
:tree-data="treeData"
3 months ago
v-model:selectedKeys="checkedTree"
4 months ago
@select="onSelect"
3 months ago
:fieldNames="{
children: 'children',
title: 'projectName',
key: 'projectId',
disabled: 'disabled',
}"
/>
4 months ago
</a-col>
<a-col :span="20">
<BasicTable @register="registerTable">
<template #toolbar>
2 months ago
<a-button type="primary" @click="handleAdd" v-if="checkedTree[0]">新增</a-button>
<a-upload
name="file"
:before-upload="beforeUpload"
@change="importChange"
:showUploadList="false"
v-if="checkedTree.length > 0"
>
<a-button type="primary"> 导入 </a-button>
</a-upload>
2 weeks ago
<a-upload
name="file"
:before-upload="reportUpload"
@change="reportChange"
:showUploadList="false"
v-if="checkedTree.length > 0"
>
<a-button type="primary"> 批量点位上报 </a-button>
</a-upload>
<a-button @click="downloadExcel(exportExcel, '点位信息', getForm().getFieldsValue())"
>导出</a-button
>
4 months ago
</template>
<template #bodyCell="{ column, record }">
<template v-if="column && record && column.key === 'action'">
3 months ago
<a-button type="link" @click="showpointModal(record.id)">点位上报</a-button>
4 months ago
<a-button type="link" @click="handleEdit(record.id)">编辑</a-button>
2 months ago
<a-popconfirm
title="确定要删除吗?"
ok-text="是"
cancel-text="否"
@confirm="handleDelete(record.id)"
>
<a-button type="link">删除</a-button>
</a-popconfirm>
3 months ago
<a-button type="link" @click="handleDetail(record.id)">详情</a-button>
4 months ago
</template>
</template>
</BasicTable>
<detailDrawer ref="detailDrawerRef" />
<addModal ref="addModalRef" @success="reload()" />
4 months ago
<pointModal ref="pointModalRef" />
</a-col>
</a-row>
</PageWrapper>
</template>
<script setup lang="ts">
import { PageWrapper } from '@/components/Page';
import { BasicTable, useTable } from '@/components/Table';
2 weeks ago
import { list, tree, removeByIds, listUpload, exportExcel,uploadWorkOrderInfo} from './api';
4 months ago
import { formSchemas, columns } from './data';
import detailDrawer from './detailDrawer.vue';
import addModal from './addModal.vue';
3 months ago
import { ref, onMounted } from 'vue';
4 months ago
import pointModal from './pointModal.vue';
import { downloadExcel } from '@/utils/file/download';
2 weeks ago
import { message } from 'ant-design-vue';
4 months ago
defineOptions({ name: 'Point' });
2 weeks ago
const [registerTable, { getForm, reload }] = useTable({
4 months ago
title: '点位信息',
api: list,
showIndexColumn: true,
rowKey: 'id',
useSearchForm: true,
formConfig: {
schemas: formSchemas,
name: 'point',
baseColProps: {
xs: 24,
sm: 24,
md: 24,
lg: 6,
},
},
3 months ago
beforeFetch(params: any) {
if (checkedTree.value.length === 1) {
params.projectId = checkedTree.value[0];
}
return params;
},
immediate: false,
4 months ago
columns: columns,
actionColumn: {
3 months ago
width: 300,
4 months ago
title: '操作',
key: 'action',
fixed: 'right',
},
});
//新增编辑弹窗
const addModalRef = ref();
const handleAdd = () => {
addModalRef.value.showModal(1, null, checkedTree.value[0], selectInfo.value);
4 months ago
};
const handleEdit = (id: any) => {
addModalRef.value.showModal(2, id, checkedTree.value[0], selectInfo.value);
4 months ago
};
2 months ago
const handleDelete = async (id: any) => {
await removeByIds([id]);
reload();
4 months ago
};
//点位上报
//弹窗内容
const pointModalRef = ref();
3 months ago
const showpointModal = (id: any) => {
pointModalRef.value.showModal(id);
4 months ago
};
//tree
3 months ago
const checkedTree = ref([]);
const treeData = ref([]);
const getTree = async () => {
const res = await tree();
treeData.value = res;
treeData.value.forEach((i: any) => {
i.disabled = true;
});
console.log(res);
};
const selectInfo = ref({});
4 months ago
const onSelect = (selectedKeys: any, info: any) => {
console.log('selected', selectedKeys, info);
selectInfo.value = info;
3 months ago
console.log(checkedTree.value);
4 months ago
reload();
};
//导入
const beforeUpload = async (file: any) => {
console.log(file);
const params = {
file: file,
};
await listUpload(params);
return false;
};
const importChange = () => {
2 weeks ago
message.success('导入成功');
reload();
};
const reportUpload = async (file: any) => {
console.log(file);
const params = {
file: file,
};
await uploadWorkOrderInfo(params);
return false;
};
const reportChange = () => {
message.success('导入成功');
reload();
};
3 months ago
onMounted(() => {
getTree();
});
4 months ago
//抽屉
const detailDrawerRef = ref();
3 months ago
const handleDetail = (id: any) => {
detailDrawerRef.value.showDrawer(id);
4 months ago
};
</script>
<style scoped></style>