|
@@ -1,18 +1,13 @@
|
|
|
<script setup lang="ts">
|
|
|
import { onMounted, ref } from "vue";
|
|
|
-import { PlusOutlined } from "@ant-design/icons-vue";
|
|
|
import PageHeader from "@/components/PageHeader.vue";
|
|
|
import QueryBox from "./components/report-list/QueryBox.vue";
|
|
|
import type { FieldType } from "./components/report-list/QueryBox.vue";
|
|
|
-import CompanySelect from "./components/report-list/CompanySelect.vue";
|
|
|
import ReportItem from "./components/report-list/ReportItem.vue";
|
|
|
-import * as reportService from "@/services/report.service";
|
|
|
import * as reportsService from "@/services/reports.service";
|
|
|
import { CompLog } from "@/libs/log.lib";
|
|
|
import type { ReportBasic } from "@/types/report.types";
|
|
|
-import { routeToReportEditor } from "@/router";
|
|
|
import SpinComponent from "@/components/SpinComponent.vue";
|
|
|
-import TemplateSelect from "./components/TemplateSelect.vue";
|
|
|
import { message } from "ant-design-vue";
|
|
|
|
|
|
const _componentName = "ReportListView";
|
|
@@ -57,9 +52,8 @@ const field = ref<FieldType>("title");
|
|
|
const keyword = ref("");
|
|
|
// 过滤栏选择的企业id
|
|
|
const companyIdSelected = ref<Array<number>>([]);
|
|
|
-// 模板选择器ref
|
|
|
-const templateSelect = ref<InstanceType<typeof TemplateSelect> | null>(null);
|
|
|
|
|
|
+// 列表数据
|
|
|
function fetchReports(
|
|
|
companyIds?: Array<number>,
|
|
|
page?: number,
|
|
@@ -75,33 +69,12 @@ function fetchReports(
|
|
|
spinning.value = false;
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- // logError(err);
|
|
|
+ logError(err);
|
|
|
spinning.value = false;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-// function onCompanySelectChange(event: {index: number, checked: boolean}) {
|
|
|
-// console.log('company select change', event);
|
|
|
-// const company = companies.value[event.index];
|
|
|
-// company.checked = event.checked;
|
|
|
-
|
|
|
-// if (company.id || company.id == 0) {
|
|
|
-// if (!event.checked) {
|
|
|
-// companyIdSelected.value.splice(companyIdSelected.value.indexOf(company.id), 1);
|
|
|
-// } else {
|
|
|
-// companyIdSelected.value.push(company.id);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// if (companyIdSelected.value) {
|
|
|
-// if (companyIdSelected.value.length > 0) {
|
|
|
-// fetchReports(companyIdSelected.value)
|
|
|
-// } else {
|
|
|
-// fetchReports()
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
+// 搜索
|
|
|
function onQuery(queryData: { field: string; keyword: string }) {
|
|
|
currentPage.value = 1;
|
|
|
fetchReports(
|
|
@@ -112,31 +85,26 @@ function onQuery(queryData: { field: string; keyword: string }) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+// 分页
|
|
|
function onPaginationChange(page: number) {
|
|
|
- fetchReports(companyIdSelected.value, page, field.value, keyword.value)
|
|
|
+ fetchReports(companyIdSelected.value, page, field.value, keyword.value);
|
|
|
}
|
|
|
|
|
|
-function onCreateReport() {
|
|
|
- templateSelect.value?.show();
|
|
|
-}
|
|
|
-
|
|
|
-// function onTemplateSelected(templateId: number | null) {
|
|
|
-// reportService.create({templateId}).then((id) => {
|
|
|
-// // routeToReportEditor(id);
|
|
|
-// }).catch(logError);
|
|
|
-// }
|
|
|
-
|
|
|
+// 状态筛选
|
|
|
function onFilterChange() {
|
|
|
currentPage.value = 1;
|
|
|
fetchReports(companyIdSelected.value, currentPage.value);
|
|
|
}
|
|
|
|
|
|
-function onReportDelete(id: number) {
|
|
|
- reportService
|
|
|
- .remove(id)
|
|
|
+// 上链
|
|
|
+function onReportUpper(id: number) {
|
|
|
+ spinning.value = true;
|
|
|
+ reportsService
|
|
|
+ .upper(id)
|
|
|
.then((ok) => {
|
|
|
if (ok) {
|
|
|
- message.success("删除报告成功");
|
|
|
+ spinning.value = false;
|
|
|
+ message.success("上链成功");
|
|
|
currentPage.value =
|
|
|
reports.value.length === 1 ? currentPage.value - 1 : currentPage.value;
|
|
|
fetchReports(
|
|
@@ -146,14 +114,17 @@ function onReportDelete(id: number) {
|
|
|
keyword.value
|
|
|
);
|
|
|
} else {
|
|
|
- message.success("删除报告失败");
|
|
|
+ spinning.value = false;
|
|
|
+ message.error("操作失败");
|
|
|
}
|
|
|
})
|
|
|
.catch(() => {
|
|
|
- message.success("删除报告失败");
|
|
|
+ spinning.value = false;
|
|
|
+ message.error("操作失败");
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+// 编号计算
|
|
|
function serialNumber(index: number) {
|
|
|
index += 1;
|
|
|
return (currentPage.value - 1) * 10 + index;
|
|
@@ -161,32 +132,13 @@ function serialNumber(index: number) {
|
|
|
|
|
|
onMounted(() => {
|
|
|
fetchReports();
|
|
|
- // 左侧企业名录统计;
|
|
|
- // reportsService
|
|
|
- // .agg()
|
|
|
- // .then((aggs) => {
|
|
|
- // companies.value = aggs
|
|
|
- // .filter((agg) => agg.count > 0)
|
|
|
- // .map((agg) => {
|
|
|
- // return {
|
|
|
- // id: agg.companyId,
|
|
|
- // label: agg.name,
|
|
|
- // tail: agg.count,
|
|
|
- // checked: false,
|
|
|
- // };
|
|
|
- // });
|
|
|
- // })
|
|
|
- // .catch(logError);
|
|
|
});
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="reports-wrap">
|
|
|
- <PageHeader title="全部报告">
|
|
|
- <a-button type="primary" @click="onCreateReport"
|
|
|
- ><plus-outlined />新建报告</a-button
|
|
|
- >
|
|
|
- </PageHeader>
|
|
|
+ <PageHeader title="全部报告"></PageHeader>
|
|
|
|
|
|
<div class="query-box-wrap">
|
|
|
<QueryBox v-model:field="field" v-model:keyword="keyword" @search="onQuery" />
|
|
@@ -201,11 +153,6 @@ onMounted(() => {
|
|
|
</div>
|
|
|
|
|
|
<a-row class="main-content" :gutter="24">
|
|
|
- <!-- <a-col :xxl="5" :xl="6" :lg="7" :span="8" class="company-filter-wrap">
|
|
|
- <h3>我所服务的企业 <span>【{{ companies.length }}】</span></h3>
|
|
|
- <CompanySelect :data="companies" @change="onCompanySelectChange" />
|
|
|
- </a-col> -->
|
|
|
-
|
|
|
<a-col :xxl="24" :xl="24" :lg="24" :span="24">
|
|
|
<SpinComponent :spinning="spinning">
|
|
|
<ReportItem
|
|
@@ -214,7 +161,7 @@ onMounted(() => {
|
|
|
:key="index"
|
|
|
:serialNumber="serialNumber(index)"
|
|
|
class="report-item"
|
|
|
- @delete="onReportDelete"
|
|
|
+ @upper="onReportUpper"
|
|
|
/>
|
|
|
</SpinComponent>
|
|
|
</a-col>
|
|
@@ -227,7 +174,6 @@ onMounted(() => {
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <!-- <TemplateSelect ref="templateSelect" @ok="onTemplateSelected" /> -->
|
|
|
</template>
|
|
|
|
|
|
<style scoped lang="scss">
|