index.vue 8.8 KB

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