dev01 1 year ago
parent
commit
a26aa0e227

+ 4 - 4
src/client/reports.client.ts

@@ -16,20 +16,20 @@ export async function query(page: number, companyIds?: number[], field?: string,
 
   let param = ''
   if (companyIds && companyIds.length > 0) {
-    param = companyIds.map((id: number)=>`companyIds=${id}`).join('&');
+    param = companyIds.map((id: number) => `companyIds=${id}`).join('&');
   }
   if (field && keyword && keyword.length > 0 && field.length > 0) {
     param += `&field=${field}&keyword=${keyword}`
   }
   if (status || status == 0) {
-     param += `&status=${status}`
+    param += `&status=${status}`
   }
 
   const resp = await httpClient.get<Response<ReportsResponse>>(_url(`/srUserReport/all/?page=${page}&${param}`))
   return resp.data.data
 }
 
-export async function agg(): Promise<CompanyAgg[]> {
-  const resp = await httpClient.get<Response<CompanyAgg[]>>(_url("/company/agg"))
+export async function upper(id: number) {
+  const resp = await httpClient.get<Response<number>>(_url(`/srUserReport/seveText?id=${id}`))
   return resp.data.data;
 }

+ 2 - 2
src/services/reports.service.ts

@@ -4,6 +4,6 @@ export async function query(page?: number, companyIds?: number[], field?: string
   return reportsClient.query(page || 1, companyIds, field, keyword, status);
 }
 
-export async function agg() {
-  return reportsClient.agg();
+export async function upper(id: number) {
+  return reportsClient.upper(id);
 }

+ 21 - 75
src/views/report/ReportListView.vue

@@ -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">

+ 23 - 28
src/views/report/components/report-list/ReportItem.vue

@@ -22,40 +22,38 @@ defineProps({
 });
 
 const emits = defineEmits<{
-  (e: "delete", id: number): void;
+  (e: "upper", id: number): void;
 }>();
 
-function onDelete(id: number) {
-  emits("delete", id);
+function onUpper(id: number) {
+  emits("upper", id);
 }
 </script>
 
 <template>
   <a-card hoverable size="small">
-    <div class="title-link">
-      <span class="text-black"> {{ serialNumber }}. </span>
-      <span v-if="data.companyName" class="text-black"> {{ data.companyName }}</span>
-      <span v-else class="text-red">无关联企业</span>
-      <span class="text-black"> - </span>
-      <span v-if="data.name" class="text-black">{{ data.name }}</span>
-      <span v-else class="text-red">无报告类型</span>
-      <span v-if="data.status == 1" class="text-black">&nbsp;&nbsp; 已完成</span>
-      <span v-else class="text-black">&nbsp;&nbsp; 编写中</span>
-    </div>
+    <template #title>
+      <div class="title-link">
+        <span class="text-black"> {{ serialNumber }}. </span>
+        <span v-if="data.companyName" class="text-black"> {{ data.companyName }}</span>
+        <span v-else class="text-red">无关联企业</span>
+        <span class="text-black"> - </span>
+        <span v-if="data.name" class="text-black">{{ data.name }}</span>
+        <span v-else class="text-red">无报告类型</span>
+        <span v-if="data.status == 1" class="text-black">&nbsp;&nbsp; 已完成</span>
+        <span v-else class="text-black">&nbsp;&nbsp; 编写中</span>
+      </div>
+    </template>
 
-    <!-- <template #extra>
-      <RouterLink :to="{ name: 'ReportEditor', params: { id: data.id } }">编辑</RouterLink>
-      <a-button type="link" :href="reportExport.link(data.id, authStore.token)" target="_blank">下载</a-button>
-      <a-popconfirm
-        title="确定删除此报告?"
-        ok-text="确定"
-        cancel-text="取消"
-        @confirm="onDelete(data.id)"
-        placement="topRight"
+    <template #extra>
+      <a-button
+        v-if="!data.tianheCloudId"
+        type="link"
+        target="_blank"
+        @click="onUpper(data.id)"
+        >上链</a-button
       >
-        <a-button type="link">删除</a-button>
-      </a-popconfirm>
-    </template> -->
+    </template>
 
     <div class="report-metadata-wrap">
       <p>
@@ -77,14 +75,11 @@ function onDelete(id: number) {
 
 <style scoped lang="scss">
 .title-link {
-  margin-bottom: 0.6em;
   .text-black {
     color: rgba(0, 0, 0, 0.85);
   }
 }
 .report-metadata-wrap {
-  padding-top: 0.3em;
-  padding-bottom: 0.3em;
   p {
     margin-top: 0.3em;
     margin-bottom: 0.3em;