MonthSystemApplyCount.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="card-search">
  3. <!-- 查询表单 -->
  4. <a-form
  5. ref="formRef"
  6. name="advanced_search"
  7. class="ant-advanced-search-form"
  8. :model="searchParams"
  9. >
  10. <a-row :gutter="24">
  11. <a-col :span="6">
  12. <a-form-item label="查询月份" :label-col="{span:6}" name="reportDate">
  13. <a-date-picker format="YYYY-MM" picker="month" v-model:value="pickerDate" :allow-clear="false"
  14. @change="pickerDateChange"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :span="6" style="text-align: left">
  18. <a-button type="primary" html-type="submit" @click="loadData">查询</a-button>
  19. <a-button style="margin: 0 8px" @click="onReset">重置</a-button>
  20. </a-col>
  21. </a-row>
  22. </a-form>
  23. <!-- 操作按钮 -->
  24. <a-row class="edit-operation" style="margin-bottom: 20px">
  25. <a-col :span="24" class="flex-space-between">
  26. <div>
  27. <a-radio-group v-model:value="dataType" button-style="solid">
  28. <a-radio-button value="table">表格</a-radio-button>
  29. <a-radio-button value="imageTable">图表</a-radio-button>
  30. </a-radio-group>
  31. </div>
  32. <div>
  33. <BExportExcel :filename="'系统使用情况统计'"
  34. :params="{...exportSearchParams}"
  35. :title="'导出'"
  36. :url="'statistics/export/systemApplyCount'"></BExportExcel>
  37. </div>
  38. </a-col>
  39. </a-row>
  40. <!-- 数据展示 -->
  41. <div v-show="dataType == 'table'">
  42. <a-table :columns="originalColumns" :data-source="systemApplyCount" :scroll="{ x:'1300' }"
  43. :loading="tableLoading"
  44. :pagination="false"
  45. bordered>
  46. </a-table>
  47. </div>
  48. <div v-show="dataType == 'imageTable'">
  49. </div>
  50. </div>
  51. </template>
  52. <script setup lang="ts">
  53. import {computed, onMounted, reactive, ref} from "vue";
  54. import {getMonthSystemDataCount} from "@/api/statistics";
  55. import dayjs from "dayjs";
  56. import BExportExcel from "@/components/basic/excel/exportExcel/exportExcel.vue";
  57. // 查询条件
  58. const searchParams = reactive({
  59. dateStr: "",
  60. })
  61. // 导出Excel查询参数
  62. const exportSearchParams = computed(() => {
  63. return JSON.parse(JSON.stringify(searchParams));
  64. })
  65. const pickerDate = ref<any>(dayjs());
  66. // 表格加载
  67. const tableLoading = ref(false);
  68. // 展示类型切换
  69. const dataType = ref("table");
  70. // 统计数据
  71. const systemApplyCount = ref<Array<any>>([]);
  72. // 表格定义
  73. const originalColumns = ref<Array<any>>([
  74. {
  75. title: '项目', dataIndex: 'regionName', key: 'regionName', align: "center", width: 200, fixed: 'left'
  76. },
  77. {
  78. title: '第一周',
  79. children: [
  80. {title: '驿站人员数量', dataIndex: 'siteUserCount', key: 'siteUserCount', width: 120, align: "center"},
  81. {title: '录入企业数量', dataIndex: 'companyCount', key: 'companyCount', width: 120, align: "center"},
  82. {title: '收集岗位数量', dataIndex: 'postCount', key: 'postCount', width: 120, align: "center"},
  83. {title: '登记求职人数', dataIndex: 'jobUserCount', key: 'jobUserCount', width: 120, align: "center"},
  84. ]
  85. }
  86. ])
  87. // 数据加载
  88. function loadData() {
  89. tableLoading.value = true;
  90. getMonthSystemDataCount(searchParams).then((result: any) => {
  91. console.log(result);
  92. // 初始化数据,获取到区县名称
  93. let arr = new Array<any>();
  94. if (result && Object.keys(result).length > 0) {
  95. // 获取到查询结果Map中的第一个键值对,解析获取到县区信息,填充进初始数组中
  96. result[Object.keys(result)[0]].forEach((item: any) => {
  97. arr.push({
  98. regionCode: item.regionCode,
  99. regionName: item.regionName
  100. });
  101. });
  102. }
  103. // 初始化表结构
  104. originalColumns.value = [{
  105. title: '项目', dataIndex: 'regionName', key: 'regionName', align: "center", width: 200, fixed: 'left'
  106. }]
  107. // 解析第一周到第五周的统计数据
  108. for (let i = 1; i <= 5; i++) {
  109. // 填充数据
  110. initTableData(result, '第' + i + '周', arr, i + 'z');
  111. }
  112. // 解析汇总数据
  113. initTableData(result, '汇总', arr, 'hz');
  114. systemApplyCount.value = arr;
  115. }).finally(() => {
  116. tableLoading.value = false;
  117. })
  118. }
  119. // 查询表单
  120. function onReset() {
  121. searchParams.dateStr = dayjs(new Date().getDate()).format("YYYY-MM");
  122. loadData()
  123. }
  124. // 日期变更事件
  125. function pickerDateChange(date: any, dateStr: string) {
  126. console.log(date);
  127. searchParams.dateStr = dateStr;
  128. loadData();
  129. }
  130. // 表格数据与结构定义初始化
  131. function initTableData(result: any, resultKey: any, arr: any, arrNewKey: any) {
  132. if (!result[resultKey]) {
  133. return;
  134. }
  135. // 填充数据
  136. result[resultKey].forEach((item: any) => {
  137. let arrItem = arr.find((arrElement: any) => arrElement.regionCode === item.regionCode);
  138. if (arrItem) {
  139. // 将item的其他字段重命名,然后将其赋值给arr中对应的元素
  140. Object.keys(item).forEach(key => {
  141. if (key !== 'regionCode' && key !== 'regionName') {
  142. arrItem[key + arrNewKey] = item[key];
  143. }
  144. });
  145. }
  146. })
  147. // 填充表结构
  148. originalColumns.value.push({
  149. title: resultKey,
  150. children: [
  151. {
  152. title: '驿站人员数量',
  153. dataIndex: 'siteUserCount' + arrNewKey,
  154. key: 'siteUserCount' + arrNewKey,
  155. width: 120,
  156. align: "center"
  157. },
  158. {
  159. title: '录入企业数量',
  160. dataIndex: 'companyCount' + arrNewKey,
  161. key: 'companyCount' + arrNewKey,
  162. width: 120,
  163. align: "center"
  164. },
  165. {
  166. title: '收集岗位数量',
  167. dataIndex: 'postCount' + arrNewKey,
  168. key: 'postCount' + arrNewKey,
  169. width: 120,
  170. align: "center"
  171. },
  172. {
  173. title: '登记求职人数',
  174. dataIndex: 'jobUserCount' + arrNewKey,
  175. key: 'jobUserCount' + arrNewKey,
  176. width: 120,
  177. align: "center"
  178. },
  179. ]
  180. })
  181. }
  182. onMounted(() => {
  183. searchParams.dateStr = dayjs().format("YYYY-MM");
  184. loadData();
  185. })
  186. </script>
  187. <script lang="ts">
  188. // 设置页面名称进行组件缓存
  189. export default {
  190. name: "MonthSystemApplyDataCount",
  191. }
  192. </script>
  193. <style scoped>
  194. </style>