zhanghl
2025-04-25 b0ec7df2059a1d23942e71b6fb1ff3575904db81
Merge remote-tracking branch 'origin/dev' into dev
已添加1个文件
已修改2个文件
315 ■■■■ 文件已修改
src/api/mainPlan/gasProduceStatics.js 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mainPlan/gasPlanning/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mainPlan/gasProduceStatics/index.vue 295 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/mainPlan/gasProduceStatics.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
import request from '@/utils/request'
// æŸ¥è¯¢é’£é‡‘车间统计列表
export function listUpdateGasProduceStatics(data) {
  return request({
    url: '/aps/apsGasPipingRouteStat/computeCapacity',
    method: 'post',
    data: data
  })
}
// æ›´æ–°
export function listGasProduceStatics(data) {
  return request({
    url: '/aps/apsGasPipingRouteStat/getCapacityPlanData',
    method: 'post',
    data: data
  })
}
src/views/mainPlan/gasPlanning/index.vue
@@ -157,7 +157,7 @@
      </div>
    </div>
    <div class="box_container">
      <div class="title_text">气体规划产能</div>
      <div class="title_text">气柜规划产能</div>
      <div class="tabel_container">
        <!-- <HxlhTable
          style="width: 100%"
src/views/mainPlan/gasProduceStatics/index.vue
@@ -1,5 +1,56 @@
<template>
  <div class="app-container">
    <el-form
      class="responsive-form"
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-row type="flex" justify="left">
        <el-form-item label="统计方式">
          <el-select
            v-model="queryParams.type"
            style="width: 200px"
            placeholder="Select"
            @change="handleChangeSelectType"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="选择区间">
          <div v-if="!dayCom">
            <el-date-picker
              v-model="queryParams.monthRange"
              type="monthrange"
              range-separator="To"
              start-placeholder="选择开始月份"
              end-placeholder="选择结束月份"
            />
          </div>
          <div v-else>
            <el-date-picker
              v-model="value2"
              type="month"
              placeholder="选择月份"
            />
          </div>
        </el-form-item>
        <el-form-item class="column-with-margin">
          <el-button type="primary" icon="Search" @click="handleQuery"
            >查询</el-button
          >
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-row>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
@@ -8,7 +59,8 @@
          icon="Download"
          @click="handleExport"
          v-hasPermi="['apsPartRouteStat:export']"
        >导出</el-button>
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
@@ -17,27 +69,68 @@
          icon="Refresh"
          @click="handleRefresh"
          v-hasPermi="['apsPartRouteStat:edit']"
        >更新</el-button>
          >更新</el-button
        >
      </el-col>
      <right-toolbar @queryTable="getList" :search="false"></right-toolbar>
    </el-row>
    <vxe-grid ref="gridRef" v-bind="gridOptions" :loading="loading"></vxe-grid>
    <div class="box_container">
      <div class="title_text">管路规划产能负载统计</div>
      <div class="tabel_container">
        <vxe-grid
          ref="gridRef"
          v-bind="gridOptions"
          :loading="loading"
        ></vxe-grid>
      </div>
    </div>
    <div class="box_container">
      <div class="title_text">气柜规划产能负载统计</div>
      <div class="tabel_container">
        <vxe-grid
          ref="gridRef2"
          v-bind="gridOptions"
          :loading="loading"
        ></vxe-grid>
      </div>
    </div>
  </div>
</template>
<script setup name="apsPartRouteStat">
import { query,updateStat } from "@/api/mainPlan/partRouteStat.js";
<script setup name="gasProduceStatics">
import {
  listUpdateGasProduceStatics,
  listGasProduceStatics,
} from "@/api/mainPlan/gasProduceStatics.js";
import { ref } from "vue";
import * as XLSX from 'xlsx';
import * as XLSX from "xlsx";
const { proxy } = getCurrentInstance();
const loading = ref(true);
const gridRef = ref();
const height = ref(document.documentElement.clientHeight - 130 + "px;")
const gridRef2 = ref();
const height = ref(document.documentElement.clientHeight - 130 + "px;");
const headers = ref([]);
const exportData = ref([]);
const showSearch = ref(true);
const data = reactive({
  queryParams: {
    monthRange: "",
    type: "按月统计",
  },
});
const options = [
  {
    value: "month",
    label: "按月统计",
  },
  {
    value: "day",
    label: "按日统计",
  },
];
const { queryParams } = toRefs(data);
const gridOptions = reactive({
  border: true,
  stripe: true,
@@ -47,122 +140,141 @@
  showFooterOverflow: true,
  height: height,
  columnConfig: {
    resizable: true
    resizable: true,
  },
  scrollX: {
    enabled: true,
    gt: 0,
    threshold: 50
    threshold: 50,
  },
  scrollY: {
    enabled: true,
    gt: 0,
    threshold: 50
  }
    threshold: 50,
  },
});
let tableColumn = []
let tableData = []
const dayCom = ref(false);
let tableColumn = [];
let tableData = [];
let merges = [];
function handleChangeSelectType(e) {
  console.log(e, "sjcsuhcushc");
  if (e === "day") {
    dayCom.value = true;
  } else {
    dayCom.value = false;
  }
}
/** æŸ¥è¯¢é›¶ä»¶ç»Ÿè®¡è¡¨åˆ—表 */
function getList() {
  let rowKey = 0
  let colKey = 0
  headers.value = []
  exportData.value = []
  tableColumn = []
  tableData = []
  let rowKey = 0;
  let colKey = 0;
  headers.value = [];
  exportData.value = [];
  tableColumn = [];
  tableData = [];
  loading.value = true;
  query().then(response => {
    const colList = []
    let headersOne = []
    let headersTwo = []
    if(response.code == '200'){
  listGasProduceStatics().then((response) => {
    const colList = [];
    let headersOne = [];
    let headersTwo = [];
    if (response.code == "200") {
      if (!response.planTitle) {
        loading.value = false;
        return;
      }
      headersOne.push('日期');
      headersTwo.push('资源组');
      headersOne.push("日期");
      headersTwo.push("资源组");
      colList.push({
          field: 'dateCol',
          title: '日期',
          fixed: 'left',
          children: [
            { field: `resourceName`, title: '资源组', width: 250, type: 'html'},
          ],
          width: 160
        })
      response.planTitle.forEach(item => {
        field: "dateCol",
        title: "日期",
        fixed: "left",
        children: [
          { field: `resourceName`, title: "资源组", width: 250, type: "html" },
        ],
        width: 160,
      });
      response.planTitle.forEach((item) => {
        headersOne.push(item);
        headersOne.push('');
        headersOne.push('');
        headersTwo.push('设计工时');
        headersTwo.push('需求工时');
        headersTwo.push('产能负荷');
        colKey++
        headersOne.push("");
        headersOne.push("");
        headersTwo.push("设计工时");
        headersTwo.push("需求工时");
        headersTwo.push("产能负荷");
        colKey++;
        colList.push({
          field: `dateColTime${colKey}`,
          title: item,
          children: [
          { field: `designTimes${colKey}`, title: '设计工时', width: 80},
          { field: `requireTimes${colKey}`, title: '需求工时', width: 80},
          { field: `capacityLoad${colKey}`, title: '产能负荷', width: 80, type: 'html'},
            { field: `designTimes${colKey}`, title: "设计工时", width: 80 },
            { field: `requireTimes${colKey}`, title: "需求工时", width: 80 },
            {
              field: `capacityLoad${colKey}`,
              title: "产能负荷",
              width: 80,
              type: "html",
            },
          ],
          width: 160
        })
          width: 160,
        });
      });
      headers.value.push(headersOne);
      headers.value.push(headersTwo);
      const columnList = [...tableColumn, ...colList]
      const dataList = []
      const columnList = [...tableColumn, ...colList];
      const dataList = [];
      let startCol = 1;
      //获取map
      response.planTable.forEach(mapItem => {
        rowKey++
      response.planTable.forEach((mapItem) => {
        rowKey++;
        let lastCol = startCol + 2;
        merges.push({ s: { r: 0, c: startCol }, e: { r: 0, c:  lastCol} });
        merges.push({ s: { r: 0, c: startCol }, e: { r: 0, c: lastCol } });
        startCol = lastCol + 1;
        let data = [];
        const item = {
          id: `${rowKey}`
        }
          id: `${rowKey}`,
        };
        for (const [key, listValue] of Object.entries(mapItem)) {
          data.push(key);
          let tableKey = 0;
          let flag = false;
          listValue.forEach(listItem => {
            tableKey++
          listValue.forEach((listItem) => {
            tableKey++;
            item[`designTimes${tableKey}`] = listItem.designTimes;
            item[`requireTimes${tableKey}`] = listItem.requireTimes;
            item[`capacityLoad${tableKey}`] = listItem.capacityLoad > 100 ? `<font color="red">${listItem.capacityLoad}%</font>` :listItem.capacityLoad+'%';
            item[`capacityLoad${tableKey}`] =
              listItem.capacityLoad > 100
                ? `<font color="red">${listItem.capacityLoad}%</font>`
                : listItem.capacityLoad + "%";
            data.push(listItem.designTimes);
            data.push(listItem.requireTimes);
            data.push(listItem.capacityLoad+'%');
            data.push(listItem.capacityLoad + "%");
            if (listItem.capacityLoad > 100) {
              flag = true;
            }
          });
          item[`resourceName`] = flag ? `<div class='el-badge'><sup class="el-badge__content is-fixed is-dot"></sup>${key}</div>` : key;
          item[`resourceName`] = flag
            ? `<div class='el-badge'><sup class="el-badge__content is-fixed is-dot"></sup>${key}</div>`
            : key;
        }
        exportData.value.push(data);
        dataList.push(item);
      });
      const $grid = gridRef.value
      if ($grid) {
        tableColumn = columnList
        tableData = [...tableData, ...dataList]
        $grid.loadColumn(tableColumn)
        $grid.loadData(tableData)
        gridOptions.loading = false
      const $grid = gridRef.value;
      const $grid2 = gridRef.value;
      if ($grid || $grid2) {
        tableColumn = columnList;
        tableData = [...tableData, ...dataList];
        $grid.loadColumn(tableColumn);
        $grid.loadData(tableData);
        $grid2.loadColumn(tableColumn);
        $grid2.loadData(tableData);
        gridOptions.loading = false;
      }
      loading.value = false;
@@ -172,7 +284,6 @@
/** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
function handleExport() {
  // åˆå¹¶è¡¨å¤´å’Œæ•°æ®
  const finalData = [...headers.value, ...exportData.value];
@@ -185,21 +296,30 @@
    { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } }
  ]; */
  ws['!merges'] = merges;
  ws["!merges"] = merges;
  // åˆ›å»º workbook
  const wb = XLSX.utils.book_new();
  // å°† worksheet æ·»åŠ åˆ° workbook ä¸­
  XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
  XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
  // å¯¼å‡ºæ–‡ä»¶
  XLSX.writeFile(wb, `apsPartRouteStat_${new Date().getTime()}.xlsx`);
}
/** æœç´¢æŒ‰é’®æ“ä½œ */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}
/** é‡ç½®æŒ‰é’®æ“ä½œ */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}
/** åˆ·æ–°æŒ‰é’®æ“ä½œ */
function handleRefresh(){
  updateStat().then(response => {
    if(response.code == '200'){
function handleRefresh() {
  updateStat().then((response) => {
    if (response.code == "200") {
      getList();
    }
  });
@@ -207,3 +327,20 @@
getList();
</script>
<style lang="scss" scoped>
.box_container {
  width: 100%;
  margin: 20px auto;
  background: #fff;
  border-radius: 5px;
  box-shadow: 1px 1px 1px 4px#f1f1f1;
  .title_text {
    padding-top: 20px;
    margin-left: 20px;
  }
  .tabel_container {
    width: 98%;
    margin: 20px auto;
  }
}
</style>