index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="sensitive-words flex">
  3. <div class="table-box">
  4. <pageSearch ref="searchTableRef" :searchConfig="searchConfig" />
  5. <statisticsItem></statisticsItem>
  6. <statisticalChart class="mt20"></statisticalChart>
  7. <majorStatisticalChart class="mt20"></majorStatisticalChart>
  8. <pageContent ref="tableListRef" :total="total" v-loading="loading" :contentConfig="contentConfig">
  9. <!-- 单位 -->
  10. <template #unitNameStr="scope">
  11. <el-link @click="handleUnitdetail(scope.row.unitName)" type="primary">{{
  12. scope.row.unitNameStr
  13. }}</el-link>
  14. </template>
  15. <template #belongsDeptStr1="scope">
  16. <el-link @click="handleUnitdetail(scope.row.unitName)" type="primary">{{
  17. scope.row.unitNameStr
  18. }}</el-link>
  19. </template>
  20. <template #contactName1="scope">
  21. <el-link @click="handleUnitdetail(scope.row.unitName)" type="primary">{{
  22. scope.row.unitNameStr
  23. }}</el-link>
  24. </template>
  25. <template #contactName2="scope">
  26. <el-link @click="handleUnitdetail(scope.row.unitName)" type="primary">{{
  27. scope.row.unitNameStr
  28. }}</el-link>
  29. </template>
  30. </pageContent>
  31. </div>
  32. </div>
  33. </template>
  34. <script setup lang="ts">
  35. import contentConfig from './config/content.config';
  36. import pageContent from './components/pageContent.vue';
  37. import searchConfig from './config/search.config';
  38. import pageSearch from './components/pageSearch.vue';
  39. import statisticsItem from './components/statisticsItem.vue';
  40. import statisticalChart from './components/statisticalChart.vue';
  41. import majorStatisticalChart from './components/majorStatisticalChart.vue';
  42. import { useRouter } from 'vue-router';
  43. import useSystemStore from '@/store/main';
  44. import {
  45. bj_notification_type,
  46. overdueStatus,
  47. notificationStatus,
  48. bj_lssuing_unit,
  49. categoryOnm,
  50. isFeedback,
  51. takeMeasures,
  52. } from '@/plugins/dictData';
  53. const router = useRouter();
  54. // 使用pinia数据
  55. const systemStore = useSystemStore();
  56. const { pageList, resDate, searchObj } = storeToRefs(systemStore);
  57. const statisticsItemData = ref<any>();
  58. watch(
  59. [() => pageList, () => searchObj.value],
  60. ([newPageList, newSearchObj], [oldPageList, oldSearchObj]) => {
  61. console.log(newSearchObj);
  62. statisticsItemData.value = resDate.value;
  63. },
  64. { deep: true }
  65. );
  66. const total = ref(0);
  67. const tableListRef: any = ref<InstanceType<typeof pageContent>>();
  68. const searchTableRef: any = ref<InstanceType<typeof pageSearch>>();
  69. // 操作弹框
  70. import usePageModal from '@/components/components/hooks/usePageDetails';
  71. const { modalRef, handleNewDataClick, handleEditDataClick, handleCheckDataClick, handlePageDetail } =
  72. usePageModal();
  73. const loading = ref(false);
  74. const handleUnitdetail = async (id?: string) => {
  75. router.push({
  76. path: '/notificationAnalysis/notificationMattersDetail',
  77. query: { id: id },
  78. });
  79. };
  80. const handleDownload = async () => {
  81. ElMessageBox.confirm(`确定要导出所选数据信息?`, '提示', {
  82. confirmButtonText: '确定',
  83. cancelButtonText: '取消',
  84. distinguishCancelAndClose: true,
  85. })
  86. .then(async () => {
  87. const isLoading = ElLoading.service({
  88. lock: true,
  89. text: 'Loading',
  90. background: 'rgba(0, 0, 0, 0.7)',
  91. });
  92. let data: any = {};
  93. // 获取表格数据
  94. // data = cfgSelection.value;
  95. try {
  96. // 创建 Blob 对象
  97. const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
  98. // 获取列名
  99. const headers = [
  100. { key: 'uuid', label: '目标设备码' },
  101. { key: 'client_ip', label: '目标设备IP' },
  102. { key: 'type', label: '适用平台' },
  103. { key: 'remark', label: '目标设备名称' },
  104. ];
  105. const headerRow = headers.map(header => header.label).join(',');
  106. // 构造 CSV 内容
  107. const csvContent = [
  108. headerRow,
  109. ...data.map((row: any) => headers.map(header => row[header.key]).join(',')),
  110. ].join('\n');
  111. // 构造文件名
  112. const filename = `${timestamp}.csv`; // 指定下载文件的名称;
  113. // 创建 Blob 对象
  114. const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8' });
  115. // 创建下载链接
  116. const url = URL.createObjectURL(blob);
  117. const a = document.createElement('a');
  118. a.href = url;
  119. a.download = filename;
  120. a.click();
  121. URL.revokeObjectURL(url); // 释放 URL 对象
  122. } finally {
  123. isLoading.close();
  124. }
  125. })
  126. .catch(() => {});
  127. };
  128. // 筛选-状态赋值 bj_notification_status
  129. async function searchItem() {
  130. searchConfig.formItems.forEach(item => {
  131. if (item.prop === 'deliveryUnit') {
  132. item.options = bj_lssuing_unit;
  133. }
  134. if (item.prop === 'releasedUnit') {
  135. item.options = bj_lssuing_unit;
  136. }
  137. if (item.prop === 'notificationStatus') {
  138. item.options = notificationStatus;
  139. }
  140. if (item.prop === 'overdueStatus') {
  141. item.options = overdueStatus;
  142. }
  143. if (item.prop === 'notificationType') {
  144. item.options = bj_notification_type;
  145. }
  146. if (item.prop === 'conm') {
  147. item.options = categoryOnm;
  148. }
  149. if (item.prop === 'wfir') {
  150. item.options = isFeedback;
  151. }
  152. if (item.prop === 'takeMeasures') {
  153. item.options = takeMeasures;
  154. }
  155. });
  156. }
  157. searchItem();
  158. </script>
  159. <style scoped lang="scss">
  160. .sensitive-words {
  161. height: calc(100vh - 95px);
  162. margin-top: 0;
  163. overflow-y: auto;
  164. overflow-x: hidden;
  165. scrollbar-width: none; /* 可选:隐藏滚动条 */
  166. &::-webkit-scrollbar {
  167. display: none;
  168. }
  169. }
  170. .status {
  171. cursor: pointer;
  172. position: relative;
  173. .status-tip {
  174. position: absolute;
  175. top: 2px;
  176. left: 60px;
  177. }
  178. }
  179. .dialog-tip {
  180. text-align: center;
  181. }
  182. .table-box {
  183. width: 55%;
  184. display: flex;
  185. flex-direction: column;
  186. flex: 3;
  187. }
  188. :deep .el-tabs__item.is-active {
  189. color: #fff;
  190. background-color: #409eff;
  191. }
  192. :deep .el-tabs__header {
  193. padding-left: 20px;
  194. background-color: #fff;
  195. }
  196. </style>