reportTableWork.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <div class="reportTable-work">
  3. <div class="report-query">
  4. <ReportQuery
  5. :show="['time']"
  6. :query-data.sync="queryData"
  7. :search="search"
  8. >
  9. </ReportQuery>
  10. </div>
  11. <div class="report-table-view">
  12. <Card title="报告预览">
  13. <template #title-extra>
  14. <div style="padding-right: 20px">
  15. <span style="color: #b2b2b2; font-size: 12px"
  16. >支持 pdf,word,excel</span
  17. >
  18. <a-button type="link" size="small" @click="exportFunc"
  19. >导出</a-button
  20. >
  21. <a-button type="link" size="small">打印</a-button>
  22. </div>
  23. </template>
  24. <a-table
  25. :columns="tableColumns"
  26. :data-source="tableData"
  27. :pagination="true"
  28. :scroll="{ y: tableContainerHeight }"
  29. bordered
  30. ></a-table>
  31. </Card>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import ReportQuery from "@/components/report/common/reportQuery.vue";
  37. import Card from "@/components/common/card.vue";
  38. import * as XLSX from "xlsx";
  39. export default {
  40. components: {
  41. Card,
  42. ReportQuery,
  43. },
  44. data() {
  45. let timeRange = this.$util.dateUtil.getNearlyMonthRange();
  46. return {
  47. timeRange: "",
  48. queryData: {
  49. timeRange: timeRange,
  50. },
  51. oriTableData: [],
  52. tableContainerHeight: 500,
  53. tableColumns: [
  54. {
  55. title: "序号",
  56. dataIndex: "index",
  57. key: "index",
  58. align: "center",
  59. width: 80,
  60. customRender: (text, record, index) => `${index + 1}`,
  61. },
  62. {
  63. title: "姓名",
  64. dataIndex: "name",
  65. key: "name",
  66. align: "center",
  67. },
  68. {
  69. title: "人员类型",
  70. dataIndex: "people_type",
  71. key: "people_type",
  72. align: "center",
  73. },
  74. {
  75. title: "部门",
  76. dataIndex: "department",
  77. key: "department",
  78. align: "center",
  79. },
  80. {
  81. title: "通行时间",
  82. dataIndex: "time",
  83. key: "time",
  84. },
  85. {
  86. title: "通行设备",
  87. dataIndex: "equipment",
  88. key: "equipment",
  89. align: "center",
  90. },
  91. {
  92. title: "通行方向",
  93. dataIndex: "direction",
  94. key: "direction",
  95. align: "center",
  96. },
  97. {
  98. title: "行为感知",
  99. key: "operation",
  100. fixed: "right",
  101. width: 100,
  102. scopedSlots: { customRender: "action" },
  103. },
  104. ],
  105. originalData: [
  106. {
  107. key: "1",
  108. name: "潘夏彤",
  109. people_type: "自有员工",
  110. department: "业务一部",
  111. time: "2023-03-11 12:00:00",
  112. equipment: "ZX010012",
  113. direction: "进入B3",
  114. behavior: "",
  115. directionStatus: "进",
  116. },
  117. {
  118. key: "2",
  119. name: "庞慧",
  120. people_type: "协作员工",
  121. department: "业务二部",
  122. time: "2023-03-15 12:00:00",
  123. equipment: "ZX010012",
  124. direction: "进入1F",
  125. behavior: "",
  126. directionStatus: "进",
  127. },
  128. {
  129. key: "3",
  130. name: "李天泽",
  131. people_type: "访客",
  132. department: "业务二部",
  133. time: "2023-03-24 12:00:00",
  134. equipment: "ZX010012",
  135. direction: "出去B2",
  136. behavior: "",
  137. directionStatus: "出",
  138. },
  139. {
  140. key: "4",
  141. name: "李天泽",
  142. people_type: "访客",
  143. department: "业务二部",
  144. time: "2022-09-11 12:00:00",
  145. equipment: "ZX010012",
  146. direction: "出去B2",
  147. behavior: "",
  148. directionStatus: "出",
  149. },
  150. {
  151. key: "5",
  152. name: "李天泽",
  153. people_type: "访客",
  154. department: "业务二部",
  155. time: "2022-09-11 12:00:00",
  156. equipment: "ZX010012",
  157. direction: "出去B2",
  158. behavior: "",
  159. directionStatus: "出",
  160. },
  161. {
  162. key: "6",
  163. name: "李天泽",
  164. people_type: "访客",
  165. department: "业务二部",
  166. time: "2022-09-11 12:00:00",
  167. equipment: "ZX010017",
  168. direction: "进入B2",
  169. behavior: "",
  170. directionStatus: "进",
  171. },
  172. {
  173. key: "7",
  174. name: "李天泽",
  175. people_type: "访客",
  176. department: "业务三部",
  177. time: "2022-08-26 12:00:00",
  178. equipment: "ZX010017",
  179. direction: "进入B2",
  180. behavior: "",
  181. directionStatus: "进",
  182. },
  183. {
  184. key: "8",
  185. name: "李天泽",
  186. people_type: "访客",
  187. department: "业务三部",
  188. time: "2022-08-26 12:00:00",
  189. equipment: "ZX010017",
  190. direction: "进入B2",
  191. behavior: "",
  192. directionStatus: "进",
  193. },
  194. {
  195. key: "9",
  196. name: "李天泽",
  197. people_type: "访客",
  198. department: "业务三部",
  199. time: "2022-08-26 12:00:00",
  200. equipment: "ZY010012",
  201. direction: "进入B2",
  202. behavior: "",
  203. directionStatus: "进",
  204. },
  205. {
  206. key: "10",
  207. name: "李天泽",
  208. people_type: "访客",
  209. department: "业务三部",
  210. time: "2022-08-26 12:00:00",
  211. equipment: "ZY010012",
  212. direction: "进入B2",
  213. behavior: "",
  214. directionStatus: "进",
  215. },
  216. {
  217. key: "11",
  218. name: "李天泽",
  219. people_type: "访客",
  220. department: "业务一部",
  221. time: "2022-08-26 12:00:00",
  222. equipment: "ZY010012",
  223. direction: "进入B2",
  224. behavior: "",
  225. directionStatus: "进",
  226. },
  227. {
  228. key: "12",
  229. name: "李天泽",
  230. people_type: "访客",
  231. department: "业务一部",
  232. time: "2022-08-26 12:00:00",
  233. equipment: "ZY010012",
  234. direction: "进入B2",
  235. behavior: "",
  236. directionStatus: "进",
  237. },
  238. {
  239. key: "13",
  240. name: "李天泽",
  241. people_type: "访客",
  242. department: "业务一部",
  243. time: "2022-08-26 12:00:00",
  244. equipment: "ZY010012",
  245. direction: "进入B2",
  246. behavior: "",
  247. directionStatus: "进",
  248. },
  249. {
  250. key: "14",
  251. name: "李天泽",
  252. people_type: "访客",
  253. department: "业务一部",
  254. time: "2022-08-26 12:00:00",
  255. equipment: "ZY010012",
  256. direction: "进入B2",
  257. behavior: "",
  258. directionStatus: "进",
  259. },
  260. {
  261. key: "15",
  262. name: "李天泽",
  263. people_type: "访客",
  264. department: "业务一部",
  265. time: "2022-08-26 12:00:00",
  266. equipment: "ZY010012",
  267. direction: "进入B2",
  268. behavior: "",
  269. directionStatus: "进",
  270. },
  271. {
  272. key: "16",
  273. name: "李天泽",
  274. people_type: "访客",
  275. department: "业务一部",
  276. time: "2022-08-26 12:00:00",
  277. equipment: "ZY010012",
  278. direction: "进入B2",
  279. behavior: "",
  280. directionStatus: "进",
  281. },
  282. {
  283. key: "17",
  284. name: "李天泽",
  285. people_type: "访客",
  286. department: "业务一部",
  287. time: "2022-08-26 12:00:00",
  288. equipment: "ZY010012",
  289. direction: "进入B2",
  290. behavior: "",
  291. directionStatus: "进",
  292. },
  293. {
  294. key: "18",
  295. name: "李天泽",
  296. people_type: "访客",
  297. department: "业务一部",
  298. time: "2022-08-26 12:00:00",
  299. equipment: "ZY010012",
  300. direction: "出去B2",
  301. behavior: "",
  302. directionStatus: "出",
  303. },
  304. {
  305. key: "19",
  306. name: "李天泽",
  307. people_type: "访客",
  308. department: "业务三部",
  309. time: "2022-08-26 12:00:00",
  310. equipment: "ZY010012",
  311. direction: "出去B2",
  312. behavior: "",
  313. directionStatus: "出",
  314. },
  315. {
  316. key: "20",
  317. name: "李天泽",
  318. people_type: "访客",
  319. department: "业务三部",
  320. time: "2022-08-26 12:00:00",
  321. equipment: "ZY010012",
  322. direction: "出去B2",
  323. behavior: "",
  324. directionStatus: "出",
  325. },
  326. {
  327. key: "21",
  328. name: "李天泽",
  329. people_type: "访客",
  330. department: "业务三部",
  331. time: "2022-08-26 12:00:00",
  332. equipment: "ZY010012",
  333. direction: "出去B2",
  334. behavior: "",
  335. directionStatus: "出",
  336. },
  337. ],
  338. tableData: [],
  339. };
  340. },
  341. mounted() {},
  342. methods: {
  343. exportFunc() {
  344. console.log("打印报表");
  345. const data = [
  346. ["姓名", "年龄", "性别", "毕业院校"],
  347. ["张三", 18, "男", "清华大学"],
  348. ["李四", 22, "女", "北京大学"],
  349. ["王五", 20, "男", "上海交通大学"],
  350. ];
  351. const worksheet = XLSX.utils.aoa_to_sheet(data);
  352. const workbook = XLSX.utils.book_new();
  353. XLSX.utils.book_append_sheet(workbook, worksheet, "表格名字");
  354. XLSX.writeFile(workbook, "智慧办公-会议管理.xlsx");
  355. },
  356. search() {},
  357. },
  358. };
  359. </script>
  360. <style lang="less" scoped>
  361. .reportTable-work {
  362. width: 100%;
  363. height: 100%;
  364. .report-query {
  365. background-color: #ffffff;
  366. padding: 12px;
  367. margin-bottom: 12px;
  368. }
  369. .report-table-view {
  370. width: 100%;
  371. height: 690px;
  372. background-color: #ffffff;
  373. }
  374. }
  375. </style>