| | |
| | | <el-row type="flex" justify="left"> |
| | | <el-form-item label="统计方式"> |
| | | <el-select |
| | | v-model="queryParams.type" |
| | | v-model="queryParams.searchType" |
| | | style="width: 200px" |
| | | placeholder="Select" |
| | | @change="handleChangeSelectType" |
| | |
| | | } from "@/api/mainPlan/gasProduceStatics.js"; |
| | | import { ref } from "vue"; |
| | | import * as XLSX from "xlsx"; |
| | | |
| | | import { ElMessage } from "element-plus"; |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const loading = ref(true); |
| | | const loading = ref(false); |
| | | const gridRef = ref(); |
| | | const gridRef2 = ref(); |
| | | const height = ref(document.documentElement.clientHeight - 130 + "px;"); |
| | |
| | | const data = reactive({ |
| | | queryParams: { |
| | | monthRange: "", |
| | | type: "按月统计", |
| | | searchType: "按月统计", |
| | | }, |
| | | }); |
| | | const options = [ |
| | |
| | | } |
| | | /** 查询零件统计表列表 */ |
| | | function getList() { |
| | | let type = "" |
| | | options.map(item=>{ |
| | | if(queryParams.value.searchType === item.label){ |
| | | type = item.value |
| | | } |
| | | }) |
| | | // 创建一个Date对象 |
| | | let sDate = new Date(queryParams.value.monthRange[0]); |
| | | let eDate = new Date(queryParams.value.monthRange[1]); |
| | | // 获取年份和月份 |
| | | let sYear = sDate.getFullYear(); |
| | | let sMonth = sDate.getMonth() + 1; // 月份是从0开始的,所以要加1 |
| | | let eYear = eDate.getFullYear(); |
| | | let eMonth = eDate.getMonth() + 1; // 月份是从0开始的,所以要加1 |
| | | // 格式化为"YYYY-MM"的形式 |
| | | let sYearMonth = `${sYear}-${sMonth.toString().padStart(2, "0")}`; |
| | | let eYearMonth = `${eYear}-${eMonth.toString().padStart(2, "0")}`; |
| | | console.log(sYearMonth, eYearMonth, "yearMonth"); |
| | | |
| | | let rowKey = 0; |
| | | let colKey = 0; |
| | | headers.value = []; |
| | |
| | | tableColumn = []; |
| | | tableData = []; |
| | | loading.value = true; |
| | | listGasProduceStatics().then((response) => { |
| | | listGasProduceStatics({ |
| | | searchStartDate: sYearMonth, |
| | | searchEndDate: eYearMonth, |
| | | searchType: type, |
| | | }).then((response) => { |
| | | const colList = []; |
| | | let headersOne = []; |
| | | let headersTwo = []; |
| | |
| | | title: "日期", |
| | | fixed: "left", |
| | | children: [ |
| | | { field: `resourceName`, title: "资源组", width: 250, type: "html" }, |
| | | { |
| | | field: `resourceName`, |
| | | title: "资源组", |
| | | width: 250, |
| | | type: "html", |
| | | }, |
| | | ], |
| | | width: 160, |
| | | }); |
| | |
| | | |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | // 合并表头和数据 |
| | | const finalData = [...headers.value, ...exportData.value]; |
| | | |
| | | // 将数据转换为 worksheet |
| | | const ws = XLSX.utils.aoa_to_sheet(finalData); |
| | | |
| | | // 合并单元格(如果需要) |
| | | /* ws['!merges'] = [ |
| | | { s: { r: 0, c: 1 }, e: { r: 0, c: 3 } }, |
| | | { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } } |
| | | ]; */ |
| | | |
| | | ws["!merges"] = merges; |
| | | |
| | | // 创建 workbook |
| | | const wb = XLSX.utils.book_new(); |
| | | // 将 worksheet 添加到 workbook 中 |
| | | XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); |
| | | // 导出文件 |
| | | XLSX.writeFile(wb, `apsPartRouteStat_${new Date().getTime()}.xlsx`); |
| | | proxy.download( |
| | | "/aps/apsGasPipingRouteStat/exportExcel", {}, |
| | | `aps_gas_produce_statics_${new Date().getTime()}.xlsx` |
| | | ); |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | if (!queryParams.value.monthRange) { |
| | | ElMessage({ |
| | | message: "请选择年月", |
| | | type: "error", |
| | | }); |
| | | return; |
| | | } |
| | | // queryParams.value.pageNum = 1; |
| | | getList(); |
| | | } |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | getList(); |
| | | // getList(); |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | .box_container { |