index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div class="gasReport">
  3. <customHeader>瓦斯日报监测</customHeader>
  4. <div class="report-container">
  5. <div class="search-area">
  6. <a-row>
  7. <a-col :span="4">
  8. <div class="area-item">
  9. <div class="item-text">填报日期:</div>
  10. <a-date-picker style="width: 220px" :showTime="false" valueFormat="YYYY-MM-DD"
  11. v-model:value="searchData.reportTime" placeholder="请选择填报日期" @change="onChange" />
  12. </div>
  13. </a-col>
  14. <a-col :span="4">
  15. <div class="area-item">
  16. <div class="item-text">区队:</div>
  17. <a-select v-model:value="searchData.districtTeam" style="width: 220px" placeholder="请选择区队">
  18. <a-select-option v-for="item in qdList" :key="item" :value="item.value">{{ item.label
  19. }}</a-select-option>
  20. </a-select>
  21. </div>
  22. </a-col>
  23. <a-col :span="4">
  24. <div class="area-item">
  25. <div class="item-text">上报人:</div>
  26. <a-input style="width: 220px" v-model:value="searchData.sbr" placeholder="请输入上报人" />
  27. </div>
  28. </a-col>
  29. <a-col :span="4">
  30. <div class="area-item">
  31. <div class="item-text">上报地点:</div>
  32. <a-select v-model:value="searchData.strInstallPos" style="width: 220px" placeholder="请选择上报地点">
  33. <a-select-option v-for="item in addressList" :key="item" :value="item.value">{{ item.label
  34. }}</a-select-option>
  35. </a-select>
  36. </div>
  37. </a-col>
  38. <a-button type="primary" preIcon="ant-design:search-outlined" @click="getSearch">查询</a-button>
  39. <a-button preIcon="ant-design:sync-outlined" style="margin: 0px 15px" @click="onReset">重置</a-button>
  40. <a-button type="primary" preIcon="ant-design:download-outlined" @click="getExport">导出报表</a-button>
  41. <a-button type="primary" preIcon="ant-design:download-outlined" @click="getExport1" style="margin: 0px 15px">导出瓦斯三对照报表</a-button>
  42. </a-row>
  43. </div>
  44. <a-table :columns="columns" :data-source="tableData" :scroll="{ y: 500 }" class="tableW" :pagination="pagination"
  45. @change="pageChange">
  46. <template #bodyCell="{ column, text }"></template>
  47. </a-table>
  48. </div>
  49. </div>
  50. </template>
  51. <script setup lang="ts">
  52. import { ref, onMounted, computed, reactive } from 'vue';
  53. import { columns } from './gas-report.data';
  54. import { getGasAddressList, getList, expComReportByParam } from './gas-report.api';
  55. import customHeader from '/@/components/vent/customHeader.vue';
  56. import { message } from 'ant-design-vue';
  57. import dayjs from 'dayjs';
  58. let searchData = reactive({
  59. reportTime: dayjs().format('YYYY-MM-DD'),
  60. districtTeam: '',
  61. sbr: '',
  62. strInstallPos: '',
  63. });
  64. let qdList = reactive<any[]>([]); //区队下拉列表
  65. let addressList = reactive<any[]>([]); //上报地点下拉列表
  66. let pagination = reactive({
  67. current: 1, // 当前页码
  68. pageSize: 10, // 每页显示条数
  69. total: 0, // 总条目数,后端返回
  70. // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
  71. showSizeChanger: true, // 是否可改变每页显示条数
  72. pageSizeOptions: ['10', '20', '50'], // 可选的每页显示条数
  73. });
  74. let tableData = ref<any[]>([]);
  75. function onChange(val, time) {
  76. searchData.reportTime = time;
  77. }
  78. //获取日报列表数据
  79. async function getTableList() {
  80. let res = await getList({ pageNo: pagination.current, pageSize: pagination.pageSize, ...searchData });
  81. console.log(res, '瓦斯日报列表数据-----------');
  82. tableData.value = res.records;
  83. pagination.total = res.total;
  84. }
  85. //查询
  86. function getSearch() {
  87. pagination.current = 1;
  88. getTableList();
  89. }
  90. //重置
  91. function onReset() {
  92. pagination.current = 1;
  93. searchData.districtTeam = '';
  94. searchData.reportTime = '';
  95. searchData.strInstallPos = '';
  96. searchData.sbr = '';
  97. getTableList();
  98. }
  99. //分页切换
  100. function pageChange(val) {
  101. pagination.current = val.current;
  102. pagination.pageSize = val.pageSize;
  103. getTableList();
  104. }
  105. function uniqueObjectsArray(arr) {
  106. const map = new Map();
  107. return arr.filter((item) => {
  108. const key = JSON.stringify(item);
  109. const isNew = !map.has(key);
  110. map.set(key, item);
  111. return isNew;
  112. });
  113. }
  114. //获取安装位置下拉选项
  115. async function getSelectList() {
  116. let res = await getGasAddressList({ devicekind: 'gasDayReport' });
  117. console.log(res, '区队下拉选项--------');
  118. qdList.length = 0;
  119. addressList.length = 0;
  120. if (res.length != 0) {
  121. res.forEach((el) => {
  122. qdList.push({ label: el.devgroup_dictText, value: el.devgroup_dictText });
  123. addressList.push({ label: el.strinstallpos, value: el.strinstallpos });
  124. });
  125. qdList = uniqueObjectsArray(qdList);
  126. }
  127. }
  128. //导出报表
  129. async function getExport() {
  130. if (searchData.reportTime) {
  131. let res = await expComReportByParam({ tempName: 'wsrb', reportTime: searchData.reportTime });
  132. console.log(res, '导出------------');
  133. let filename = searchData.reportTime + '.xlsx';
  134. downFilePublic(res, filename);
  135. } else {
  136. message.warning('请选择需要导出数据的填报日期!');
  137. }
  138. }
  139. //导出三对照报表
  140. async function getExport1() {
  141. if (searchData.reportTime) {
  142. let res = await expComReportByParam({ tempName: 'wssdz', reportTime: searchData.reportTime });
  143. console.log(res, '导出------------');
  144. let filename = searchData.reportTime + '.xlsx';
  145. downFilePublic(res, filename);
  146. } else {
  147. message.warning('请选择需要导出数据的填报日期!');
  148. }
  149. }
  150. // 下载公用方法
  151. function downFilePublic(content, fileName) {
  152. const blob = new Blob([content], { type: 'application/xlsx;charset=UTF-8' }); // 构造一个blob对象来处理数据
  153. // 对于<a>标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
  154. // IE10以上支持blob但是依然不支持download
  155. if ('download' in document.createElement('a')) {
  156. // 支持a标签download的浏览器
  157. const link = document.createElement('a'); // 创建a标签
  158. link.download = fileName; // a标签添加属性
  159. link.style.display = 'none';
  160. link.href = URL.createObjectURL(blob);
  161. document.body.appendChild(link);
  162. link.click(); // 执行下载
  163. URL.revokeObjectURL(link.href); // 释放url
  164. document.body.removeChild(link); // 释放标签
  165. } else {
  166. // 其他浏览器
  167. navigator.msSaveBlob(blob, fileName);
  168. }
  169. }
  170. onMounted(() => {
  171. getSelectList();
  172. getTableList();
  173. });
  174. </script>
  175. <style lang="less" scoped>
  176. .gasReport {
  177. width: 100%;
  178. height: 100%;
  179. padding: 80px 10px 15px 10px;
  180. box-sizing: border-box;
  181. position: relative;
  182. .search-area {
  183. margin: 20px 0px;
  184. .area-item {
  185. display: flex;
  186. align-items: center;
  187. .item-text {
  188. color: #fff;
  189. }
  190. }
  191. }
  192. .zxm-picker,
  193. .zxm-input {
  194. border: 1px solid #3ad8ff77 !important;
  195. background-color: #ffffff00 !important;
  196. color: #fff !important;
  197. }
  198. }
  199. :deep(.zxm-table-thead > tr > th:last-child) {
  200. border-right: 1px solid #91e9fe !important;
  201. }
  202. :deep(.zxm-picker-input > input) {
  203. color: #fff;
  204. }
  205. :deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  206. border: 1px solid #3ad8ff77 !important;
  207. background-color: #ffffff00 !important;
  208. }
  209. :deep(.zxm-select-selection-item) {
  210. color: #fff !important;
  211. }
  212. </style>