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