zhangwencui
3 天以前 00fc3e3b4523dd6266fe98e9b0a7dac64c7e819a
test commit
已修改1个文件
704 ■■■■■ 文件已修改
src/views/index.vue 704 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/index.vue
@@ -9,14 +9,15 @@
          <div class="welcome-banner">
            <div class="welcome-title">
              <span class="welcome-user">{{ userStore.roleName || '系统管理员' }}</span>
              <span> 您好!祝您开心每一天</span>
              <span> 您好!!祝您开心每一天</span>
            </div>
            <div class="welcome-time">登录于: {{ userStore.currentLoginTime }}</div>
          </div>
          <!-- 用户信息卡片 -->
          <div class="user-card">
            <img :src="userStore.avatar" class="avatar" alt="" />
            <img :src="userStore.avatar"
                 class="avatar"
                 alt="" />
            <div class="user-card-main">
              <div class="user-name">{{ userStore.name }}</div>
              <div class="user-role">{{ userStore.roleName }}</div>
@@ -44,7 +45,6 @@
              <div class="data-value">{{ businessInfo.monthSaleHaveMoney }}</div>
            </div>
          </div>
        </div>
        <div class="data-card purchase">
          <div class="data-title">采购数据</div>
@@ -76,8 +76,10 @@
      <!-- 右:待办事项 -->
      <div class="todo-panel">
        <div class="section-title">待办事项</div>
        <ul class="todo-list" v-if="todoList.length > 0">
          <li v-for="item in todoList" :key="item.id">
        <ul class="todo-list"
            v-if="todoList.length > 0">
          <li v-for="item in todoList"
              :key="item.id">
            <div style="display: flex;flex-direction: column;justify-content: space-between;width: 100%;gap: 20px">
              <div style="display: flex;justify-content: space-between;align-items: center;">
                <div class="todo-title">待办编号:{{ item.approveId }}</div>
@@ -88,7 +90,8 @@
            </div>
          </li>
        </ul>
        <div v-else style="text-align: center">
        <div v-else
             style="text-align: center">
          暂无数据
        </div>
      </div>
@@ -98,23 +101,36 @@
        <div class="process-panel__header">
          <div class="section-title">工序数据生产统计明细</div>
          <div style="display: flex; gap: 10px; align-items: center;">
            <el-button type="primary" size="small" plain icon="Filter" @click="openProcessDialog">选择工序</el-button>
            <el-button type="info" size="small" plain icon="Refresh" @click="resetProcessFilter">重置</el-button>
            <el-radio-group v-model="processRange" size="small" @change="refreshProcessStats">
            <el-button type="primary"
                       size="small"
                       plain
                       icon="Filter"
                       @click="openProcessDialog">选择工序</el-button>
            <el-button type="info"
                       size="small"
                       plain
                       icon="Refresh"
                       @click="resetProcessFilter">重置</el-button>
            <el-radio-group v-model="processRange"
                            size="small"
                            @change="refreshProcessStats">
              <el-radio-button :value="1">日</el-radio-button>
              <el-radio-button :value="2">周</el-radio-button>
              <el-radio-button :value="3">月</el-radio-button>
            </el-radio-group>
          </div>
        </div>
        <div class="process-panel__body">
          <div class="process-panel__chart">
            <Echarts :chartStyle="{ width: '100%', height: '100%' }" :grid="processGrid" :series="processSeries"
              :tooltip="processTooltip" :xAxis="processXAxis" :yAxis="processYAxis" style="height: 100%"
            <Echarts :chartStyle="{ width: '100%', height: '100%' }"
                     :grid="processGrid"
                     :series="processSeries"
                     :tooltip="processTooltip"
                     :xAxis="processXAxis"
                     :yAxis="processYAxis"
                     style="height: 100%"
              @click="handleChartClick" />
          </div>
          <div class="process-panel__aside">
            <div class="process-legend">
              <div class="process-legend__item">
@@ -127,9 +143,7 @@
                <span class="dot dot-teal"></span><span>产出量</span>
              </div>
            </div>
            <div class="process-card process-card--name">{{ processAside.processName }}</div>
            <div class="process-card">
              <div class="process-card__label">累计总投入</div>
              <div class="process-card__value">{{ formatAmount(processAside.totalInput) }}
@@ -149,13 +163,18 @@
        </div>
      </div>
    </div>
    <!-- 工序选择弹窗 -->
    <el-dialog v-model="processDialogVisible" title="选择工序" width="500px" append-to-body>
    <el-dialog v-model="processDialogVisible"
               title="选择工序"
               width="500px"
               append-to-body>
      <div class="process-selection-wrapper">
        <el-checkbox-group v-model="tempProcessIds">
          <div class="process-grid">
            <el-checkbox v-for="item in processOptions" :key="item.id" :label="item.id" border>
            <el-checkbox v-for="item in processOptions"
                         :key="item.id"
                         :label="item.id"
                         border>
              {{ item.name }}
            </el-checkbox>
          </div>
@@ -164,7 +183,8 @@
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="processDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="handleProcessDialogConfirm">确认</el-button>
          <el-button type="primary"
                     @click="handleProcessDialogConfirm">确认</el-button>
        </span>
      </template>
    </el-dialog>
@@ -174,7 +194,9 @@
        <div class="section-title">客户合同金额分析</div>
        <div class="contract-summary">
          <div class="contract-info">
            <img src="../assets/images/khtitle.png" alt="" style="width: 42px" />
            <img src="../assets/images/khtitle.png"
                 alt=""
                 style="width: 42px" />
            <div class="contract-card">
              <div class="contract-name">总合同金额(元)</div>
              <div class="contract-meta">
@@ -184,16 +206,20 @@
            </div>
          </div>
        </div>
        <div
          style="display: flex;align-items: center;gap: 20px;justify-content: space-evenly;height: 180px;margin-top: 20px">
        <div style="display: flex;align-items: center;gap: 20px;justify-content: space-evenly;height: 180px;margin-top: 20px">
          <div>
            <Echarts ref="chart" :legend="pieLegend" :chartStyle="chartStylePie" :series="materialPieSeries"
            <Echarts ref="chart"
                     :legend="pieLegend"
                     :chartStyle="chartStylePie"
                     :series="materialPieSeries"
              :tooltip="pieTooltip"></Echarts>
          </div>
          <ul class="contract-list">
            <li v-for="item in materialPieSeries[0].data" :key="item.name">
            <li v-for="item in materialPieSeries[0].data"
                :key="item.name">
              <div style="display: flex;align-items: center;justify-content: space-between;width: 100%">
                <div class="line" :style="{ color: item.itemStyle.color }">●{{ item.name }}</div>
                <div class="line"
                     :style="{ color: item.itemStyle.color }">●{{ item.name }}</div>
                <div style="width: 70px">{{ item.rate }}%</div>
                <div>¥{{ item.value }}</div>
              </div>
@@ -210,17 +236,26 @@
          <!--                        <el-radio-button label="按季度" :value="3" />-->
          <!--                    </el-radio-group>-->
        </div>
        <Echarts ref="chart" :color="barColors2" :chartStyle="chartStyle" :grid="grid" :series="barSeries"
          :tooltip="tooltip" :xAxis="xAxis" :yAxis="yAxis" style="height: 260px"></Echarts>
        <Echarts ref="chart"
                 :color="barColors2"
                 :chartStyle="chartStyle"
                 :grid="grid"
                 :series="barSeries"
                 :tooltip="tooltip"
                 :xAxis="xAxis"
                 :yAxis="yAxis"
                 style="height: 260px"></Echarts>
      </div>
    </div>
    <!-- 底部横向两栏 -->
    <div class="dashboard-row">
      <div class="main-panel">
        <div style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 10px;">
          <div class="section-title" style="margin-bottom: 0;">质量统计</div>
          <el-radio-group v-model="qualityRange" size="small" @change="qualityStatisticsInfo">
          <div class="section-title"
               style="margin-bottom: 0;">质量统计</div>
          <el-radio-group v-model="qualityRange"
                          size="small"
                          @change="qualityStatisticsInfo">
            <el-radio-button :value="1">周</el-radio-button>
            <el-radio-button :value="2">月</el-radio-button>
            <el-radio-button :value="3">季度</el-radio-button>
@@ -231,42 +266,55 @@
          <div class="quality-card two">过程检验数量 <span>{{ qualityStatisticsObject.processNum }}件</span></div>
          <div class="quality-card three">出厂已检数量 <span>{{ qualityStatisticsObject.factoryNum }}件</span></div>
        </div>
        <Echarts ref="chart" :chartStyle="chartStyle" :grid="grid" :legend="barLegend" :series="barSeries1"
          :tooltip="tooltip" :xAxis="xAxis1" :yAxis="yAxis1" style="height: 260px"></Echarts>
        <Echarts ref="chart"
                 :chartStyle="chartStyle"
                 :grid="grid"
                 :legend="barLegend"
                 :series="barSeries1"
                 :tooltip="tooltip"
                 :xAxis="xAxis1"
                 :yAxis="yAxis1"
                 style="height: 260px"></Echarts>
      </div>
      <div class="main-panel">
        <div class="section-title">回款与开票分析</div>
        <Echarts ref="invoiceChart" :chartStyle="chartStyle" :grid="grid" :legend="lineLegend" :series="lineSeries"
          :tooltip="tooltipLine" :xAxis="xAxis2" :yAxis="yAxis2" style="height: 270px;" />
        <Echarts ref="invoiceChart"
                 :chartStyle="chartStyle"
                 :grid="grid"
                 :legend="lineLegend"
                 :series="lineSeries"
                 :tooltip="tooltipLine"
                 :xAxis="xAxis2"
                 :yAxis="yAxis2"
                 style="height: 270px;" />
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted, computed, reactive } from 'vue'
  import { ref, onMounted, computed, reactive } from "vue";
import Echarts from "@/components/Echarts/echarts.vue";
import * as echarts from 'echarts';
  import * as echarts from "echarts";
import useUserStore from "@/store/modules/user.js";
import {
  analysisCustomerContractAmounts, getAmountHalfYear,
    analysisCustomerContractAmounts,
    getAmountHalfYear,
  getBusiness,
  homeTodos,
  processDataProductionStatistics,
  statisticsReceivablePayable,
  qualityInspectionStatistics
    qualityInspectionStatistics,
} from "@/api/viewIndex.js";
import { list } from '@/api/productionManagement/productionProcess';
  import { list } from "@/api/productionManagement/productionProcess";
  const userStore = useUserStore();
const userStore = useUserStore()
const processOptions = ref([])
const selectedProcessIds = ref([])
const tempProcessIds = ref([])
const processDialogVisible = ref(false)
const activeProcessIndex = ref(0)
  const processOptions = ref([]);
  const selectedProcessIds = ref([]);
  const tempProcessIds = ref([]);
  const processDialogVisible = ref(false);
  const activeProcessIndex = ref(0);
const businessInfo = ref({
  inventoryNum: 0,
@@ -275,455 +323,483 @@
  monthSaleHaveMoney: 0,
  monthSaleMoney: 0,
  todayInventoryNum: 0,
})
  });
const qualityStatisticsObject = ref({
  supplierNum: 0,
  processNum: 0,
  factoryNum: 0,
})
const sum = ref(0)
const yny = ref(0)
const chain = ref(0)
  });
  const sum = ref(0);
  const yny = ref(0);
  const chain = ref(0);
const pieLegend = reactive({
  show: false,
})
  });
const barSeries = ref([
  {
    type: 'bar',
      type: "bar",
    data: [],
    label: {
      show: true,
    }
  },
])
    },
  ]);
const barSeries1 = ref([
  {
    name: '原材料不合格数',
    type: 'bar',
      name: "原材料不合格数",
      type: "bar",
    barGap: 0,
    emphasis: {
      focus: 'series'
        focus: "series",
    },
    data: []
      data: [],
  },
  {
    name: '过程不合格数',
    type: 'bar',
      name: "过程不合格数",
      type: "bar",
    emphasis: {
      focus: 'series'
        focus: "series",
    },
    data: []
      data: [],
  },
  {
    name: '出厂不合格数',
    type: 'bar',
      name: "出厂不合格数",
      type: "bar",
    emphasis: {
      focus: 'series'
        focus: "series",
    },
    data: []
      data: [],
  },
])
  ]);
const chartStyle = {
  width: '100%',
  height: '100%' // 设置图表容器的高度
}
    width: "100%",
    height: "100%", // 设置图表容器的高度
  };
const chartStylePie = {
  width: '140%',
  height: '140%' // 设置图表容器的高度
}
    width: "140%",
    height: "140%", // 设置图表容器的高度
  };
const grid = {
  left: '3%',
  right: '4%',
  bottom: '3%',
  containLabel: true
}
    left: "3%",
    right: "4%",
    bottom: "3%",
    containLabel: true,
  };
const barLegend = {
  show: true,
  data: ['原材料不合格数', '过程不合格数', '出厂不合格数']
}
    data: ["原材料不合格数", "过程不合格数", "出厂不合格数"],
  };
const barLegend1 = {
  show: true,
  data: ['预付账款', '应付账款', '预收账款', '应收账款']
}
    data: ["预付账款", "应付账款", "预收账款", "应收账款"],
  };
const lineLegend = {
  show: true,
  data: ['开票', '回款']
}
    data: ["开票", "回款"],
  };
const tooltip = {
  trigger: 'axis',
    trigger: "axis",
  axisPointer: {
    type: 'shadow'
  }
}
const xAxis = [{
  type: 'value',
}]
const xAxis1 = ref([{
  type: 'category',
      type: "shadow",
    },
  };
  const xAxis = [
    {
      type: "value",
    },
  ];
  const xAxis1 = ref([
    {
      type: "category",
  axisTick: { show: false },
  data: []
}])
const yAxis = [{
  type: 'category',
  data: ['应付账款', '应收账款',]
}]
const yAxis1 = [{
  type: 'value'
}]
      data: [],
    },
  ]);
  const yAxis = [
    {
      type: "category",
      data: ["应付账款", "应收账款"],
    },
  ];
  const yAxis1 = [
    {
      type: "value",
    },
  ];
const pieTooltip = reactive({
  trigger: 'item',
    trigger: "item",
  formatter: function (params) {
    // 动态生成提示信息,基于数据项的 name 属性
    const description = params.name === '本月回款金额' ? '本月回款金额' : '应收款金额';
      const description =
        params.name === "本月回款金额" ? "本月回款金额" : "应收款金额";
    return `${description} ${formatNumber(params.value)}元 ${params.percent}%`;
  },
  position: 'right'
})
    position: "right",
  });
const materialPieSeries = ref([
  {
    type: 'pie',
    radius: ['66%', '90%'],
      type: "pie",
      radius: ["66%", "90%"],
    avoidLabelOverlap: false,
    itemStyle: {
      borderColor: '#fff',
      borderWidth: 2
        borderColor: "#fff",
        borderWidth: 2,
    },
    label: {
      show: false
        show: false,
    },
    data: []
  }
])
      data: [],
    },
  ]);
const lineSeries = ref([
  {
    type: 'line',
      type: "line",
    data: [],
    label: {
      show: true
        show: true,
    },
    showSymbol: true, // 显示圆点
  },
])
  ]);
const tooltipLine = {
  trigger: 'axis',
}
    trigger: "axis",
  };
const yAxis2 = ref([
  {
    type: 'value',
  }
])
      type: "value",
    },
  ]);
const xAxis2 = ref([
  {
    type: 'category',
      type: "category",
    data: [],
    axisLabel: {
      interval: 0,
      formatter: function (value) {
        return value.replace(/~/g, '\n');
          return value.replace(/~/g, "\n");
      },
    }
  }
])
      },
    },
  ]);
// 待办事项
const todoList = ref([])
const radio1 = ref(1)
const qualityRange = ref(1)
  const todoList = ref([]);
  const radio1 = ref(1);
  const qualityRange = ref(1);
// 图表引用
const barChart = ref(null)
const lineChart = ref(null)
const barColors2 = ['#5181DB', '#D369E0', '#F2CA6D', '#60CCA8']
  const barChart = ref(null);
  const lineChart = ref(null);
  const barColors2 = ["#5181DB", "#D369E0", "#F2CA6D", "#60CCA8"];
// 随机颜色生成函数
const getRandomColor = () => {
  return '#' + Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0');
}
    return (
      "#" +
      Math.floor(Math.random() * 0xffffff)
        .toString(16)
        .padStart(6, "0")
    );
  };
onMounted(() => {
  getBusinessData()
  analysisCustomer()
  todoInfoS()
  statisticsReceivable()
  qualityStatisticsInfo()
  getAmountHalfYearNum()
  getProcessList()
})
    getBusinessData();
    analysisCustomer();
    todoInfoS();
    statisticsReceivable();
    qualityStatisticsInfo();
    getAmountHalfYearNum();
    getProcessList();
  });
// 数据统计
const getBusinessData = () => {
  getBusiness().then((res) => {
    businessInfo.value = { ...res.data }
  })
}
    getBusiness().then(res => {
      businessInfo.value = { ...res.data };
    });
  };
// 合同金额
const analysisCustomer = () => {
  analysisCustomerContractAmounts().then((res) => {
    sum.value = res.data.sum
    yny.value = res.data.yny
    chain.value = res.data.chain
    analysisCustomerContractAmounts().then(res => {
      sum.value = res.data.sum;
      yny.value = res.data.yny;
      chain.value = res.data.chain;
    // 为每个数据项分配随机颜色
    materialPieSeries.value[0].data = res.data.item.map(item => ({
      ...item,
      itemStyle: { color: getRandomColor() }
    }))
  })
}
        itemStyle: { color: getRandomColor() },
      }));
    });
  };
// 待办事项
const todoInfoS = () => {
  homeTodos().then((res) => {
    todoList.value = res.data
  })
}
    homeTodos().then(res => {
      todoList.value = res.data;
    });
  };
// 获取工序列表
const getProcessList = () => {
  list().then(res => {
    processOptions.value = res.data
  })
}
      processOptions.value = res.data;
    });
  };
const openProcessDialog = () => {
  tempProcessIds.value = [...selectedProcessIds.value]
  processDialogVisible.value = true
}
    tempProcessIds.value = [...selectedProcessIds.value];
    processDialogVisible.value = true;
  };
const handleProcessDialogConfirm = () => {
  selectedProcessIds.value = [...tempProcessIds.value]
  processDialogVisible.value = false
  refreshProcessStats()
}
    selectedProcessIds.value = [...tempProcessIds.value];
    processDialogVisible.value = false;
    refreshProcessStats();
  };
const resetProcessFilter = () => {
  selectedProcessIds.value = []
  tempProcessIds.value = []
  refreshProcessStats()
}
    selectedProcessIds.value = [];
    tempProcessIds.value = [];
    refreshProcessStats();
  };
const handleChartClick = (params) => {
  const handleChartClick = params => {
  if (params && params.dataIndex !== undefined) {
    activeProcessIndex.value = params.dataIndex
      activeProcessIndex.value = params.dataIndex;
  }
}
  };
// 应付应收统计
const statisticsReceivable = () => {
  statisticsReceivablePayable({ type: radio1.value }).then((res) => {
    statisticsReceivablePayable({ type: radio1.value }).then(res => {
    barSeries.value[0].data = [
      // { value: res.data.prepayMoney, itemStyle: { color: barColors2[0] } },
      { value: res.data.payableMoney, itemStyle: { color: barColors2[0] } },
      // { value: res.data.advanceMoney, itemStyle: { color: barColors2[2] } },
      { value: res.data.receivableMoney, itemStyle: { color: barColors2[1] } }
    ]
  })
}
        { value: res.data.receivableMoney, itemStyle: { color: barColors2[1] } },
      ];
    });
  };
// 质检统计
const qualityStatisticsInfo = () => {
  qualityInspectionStatistics({ type: qualityRange.value }).then((res) => {
    xAxis1.value[0].data = []
    barSeries1.value[0].data = []
    barSeries1.value[1].data = []
    barSeries1.value[2].data = []
    qualityInspectionStatistics({ type: qualityRange.value }).then(res => {
      xAxis1.value[0].data = [];
      barSeries1.value[0].data = [];
      barSeries1.value[1].data = [];
      barSeries1.value[2].data = [];
    res.data.item.forEach(item => {
      xAxis1.value[0].data.push(item.date)
      barSeries1.value[0].data.push(item.supplierNum)
      barSeries1.value[1].data.push(item.processNum)
      barSeries1.value[2].data.push(item.factoryNum)
    })
    qualityStatisticsObject.value.supplierNum = res.data.supplierNum
    qualityStatisticsObject.value.processNum = res.data.processNum
    qualityStatisticsObject.value.factoryNum = res.data.factoryNum
  })
}
        xAxis1.value[0].data.push(item.date);
        barSeries1.value[0].data.push(item.supplierNum);
        barSeries1.value[1].data.push(item.processNum);
        barSeries1.value[2].data.push(item.factoryNum);
      });
      qualityStatisticsObject.value.supplierNum = res.data.supplierNum;
      qualityStatisticsObject.value.processNum = res.data.processNum;
      qualityStatisticsObject.value.factoryNum = res.data.factoryNum;
    });
  };
const getAmountHalfYearNum = async () => {
  const res = await getAmountHalfYear()
  console.log(res)
  const monthName = []
  const receiptAmount = []
  const invoiceAmount = []
    const res = await getAmountHalfYear();
    console.log(res);
    const monthName = [];
    const receiptAmount = [];
    const invoiceAmount = [];
  res.data.forEach(item => {
    monthName.push(item.month)
    receiptAmount.push(item.receiptAmount)
    invoiceAmount.push(item.invoiceAmount)
  })
      monthName.push(item.month);
      receiptAmount.push(item.receiptAmount);
      invoiceAmount.push(item.invoiceAmount);
    });
  // 正确响应式赋值:创建新的 xAxis 和 series 对象
  xAxis2.value[0].data = monthName
  xAxis2.value[0].data = monthName.map(item => item.replace(/~/g, '\n~'));
    xAxis2.value[0].data = monthName;
    xAxis2.value[0].data = monthName.map(item => item.replace(/~/g, "\n~"));
  lineSeries.value = [
    {
      name: '开票',
      type: 'line',
        name: "开票",
        type: "line",
      data: invoiceAmount,
      stack: 'Total',
        stack: "Total",
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(131, 207, 255, 1)'
              color: "rgba(131, 207, 255, 1)",
          },
          {
            offset: 1,
            color: 'rgba(186, 228, 255, 1)'
          }
        ])
              color: "rgba(186, 228, 255, 1)",
            },
          ]),
      },
      itemStyle: {
        color: '#2D99FF',
        borderColor: '#2D99FF'
          color: "#2D99FF",
          borderColor: "#2D99FF",
      },
      emphasis: {
        focus: 'series'
          focus: "series",
      },
      lineStyle: {
        width: 0
          width: 0,
      },
      showSymbol: true,
    },
    {
      name: '回款',
      type: 'line',
        name: "回款",
        type: "line",
      data: receiptAmount,
      stack: 'Total',
        stack: "Total",
      lineStyle: {
        width: 0
          width: 0,
      },
      itemStyle: {
        color: '#83CFFF',
        borderColor: '#83CFFF'
          color: "#83CFFF",
          borderColor: "#83CFFF",
      },
      showSymbol: true,
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(54, 153, 255, 1)'
              color: "rgba(54, 153, 255, 1)",
          },
          {
            offset: 1,
            color: 'rgba(89, 169, 254, 1)'
          }
        ])
              color: "rgba(89, 169, 254, 1)",
            },
          ]),
      },
      emphasis: {
        focus: 'series'
          focus: "series",
      },
    }
  ]
}
      },
    ];
  };
// 工序数据生产统计明细(假数据 + 图表)
const processRange = ref(1)
const processChartData = ref([])
  const processRange = ref(1);
  const processChartData = ref([]);
const processXAxis = ref([
  {
    nameTextStyle: { color: 'rgba(0,0,0,0.35)', fontSize: 12 },
    axisLabel: { color: 'rgba(0,0,0,0.35)' },
    splitLine: { lineStyle: { color: 'rgba(0,0,0,0.06)', type: 'dashed' } },
      nameTextStyle: { color: "rgba(0,0,0,0.35)", fontSize: 12 },
      axisLabel: { color: "rgba(0,0,0,0.35)" },
      splitLine: { lineStyle: { color: "rgba(0,0,0,0.06)", type: "dashed" } },
  },
])
  ]);
const processYAxis = ref([
  {
    type: 'category',
      type: "category",
    axisTick: { show: false },
    axisLine: { show: false },
    axisLabel: { color: 'rgba(0,0,0,0.45)' },
      axisLabel: { color: "rgba(0,0,0,0.45)" },
    data: [],
  },
])
  ]);
const processGrid = reactive({ left: 0, right: 100, top: 30, bottom: 20, containLabel: true })
  const processGrid = reactive({
    left: 0,
    right: 100,
    top: 30,
    bottom: 20,
    containLabel: true,
  });
const processTooltip = reactive({
  trigger: 'axis',
  axisPointer: { type: 'shadow' },
  formatter: (params) => {
    const name = params?.[0]?.name ?? ''
    const list = Array.isArray(params) ? params : []
    trigger: "axis",
    axisPointer: { type: "shadow" },
    formatter: params => {
      const name = params?.[0]?.name ?? "";
      const list = Array.isArray(params) ? params : [];
    const lines = list
      .map((p) => {
        const colorBox = `<span style="display:inline-block;margin-right:6px;border-radius:2px;width:10px;height:10px;background:${p.color}"></span>`
        return `${colorBox}${p.seriesName} <b style="float:right;">${Number(p.value || 0).toFixed(2)}</b>`
        .map(p => {
          const colorBox = `<span style="display:inline-block;margin-right:6px;border-radius:2px;width:10px;height:10px;background:${p.color}"></span>`;
          return `${colorBox}${p.seriesName} <b style="float:right;">${Number(
            p.value || 0
          ).toFixed(2)}</b>`;
      })
      .join('<br/>')
    return `<div style="min-width:140px;"><div style="font-weight:700;margin-bottom:6px;">${name}</div>${lines}</div>`
        .join("<br/>");
      return `<div style="min-width:140px;"><div style="font-weight:700;margin-bottom:6px;">${name}</div>${lines}</div>`;
  },
})
  });
const processSeries = computed(() => {
  const input = processChartData.value.map((i) => i.input)
  const scrap = processChartData.value.map((i) => i.scrap)
  const output = processChartData.value.map((i) => i.output)
    const input = processChartData.value.map(i => i.input);
    const scrap = processChartData.value.map(i => i.scrap);
    const output = processChartData.value.map(i => i.output);
  return [
    {
      name: '投入量',
      type: 'bar',
      stack: 'total',
        name: "投入量",
        type: "bar",
        stack: "total",
      barWidth: 22,
      itemStyle: { color: '#1E5BFF', borderRadius: [6, 0, 0, 6] },
        itemStyle: { color: "#1E5BFF", borderRadius: [6, 0, 0, 6] },
      data: input,
    },
    {
      name: '报废量',
      type: 'bar',
      stack: 'total',
        name: "报废量",
        type: "bar",
        stack: "total",
      barWidth: 22,
      itemStyle: { color: '#F7B500' },
        itemStyle: { color: "#F7B500" },
      data: scrap,
    },
    {
      name: '产出量',
      type: 'bar',
      stack: 'total',
        name: "产出量",
        type: "bar",
        stack: "total",
      barWidth: 22,
      itemStyle: { color: '#19C6C6', borderRadius: [0, 6, 6, 0] },
        itemStyle: { color: "#19C6C6", borderRadius: [0, 6, 6, 0] },
      data: output,
    },
  ]
})
    ];
  });
const processAside = computed(() => {
  const list = processChartData.value
  const item = list[activeProcessIndex.value] || {}
    const list = processChartData.value;
    const item = list[activeProcessIndex.value] || {};
  return {
    processName: item.name || '暂无数据',
      processName: item.name || "暂无数据",
    totalInput: item.input || 0,
    totalScrap: item.scrap || 0,
    totalOutput: item.output || 0,
  }
})
    };
  });
const formatAmount = (n) => {
  const num = Number(n || 0)
  return num.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
}
  const formatAmount = n => {
    const num = Number(n || 0);
    return num.toLocaleString(undefined, {
      minimumFractionDigits: 2,
      maximumFractionDigits: 2,
    });
  };
const refreshProcessStats = () => {
  processDataProductionStatistics({
    type: processRange.value,
    processIds: selectedProcessIds.value.length > 0 ? selectedProcessIds.value.join(',') : null
      processIds:
        selectedProcessIds.value.length > 0
          ? selectedProcessIds.value.join(",")
          : null,
  }).then(res => {
    processChartData.value = res.data.map(item => ({
      name: item.processName,
      input: item.totalInput,
      scrap: item.totalScrap,
      output: item.totalOutput
    }))
    processYAxis.value[0].data = processChartData.value.map((i) => i.name)
    activeProcessIndex.value = 0
  })
}
        output: item.totalOutput,
      }));
      processYAxis.value[0].data = processChartData.value.map(i => i.name);
      activeProcessIndex.value = 0;
    });
  };
onMounted(() => {
  getBusinessData()
  analysisCustomer()
  todoInfoS()
  statisticsReceivable()
  qualityStatisticsInfo()
  getAmountHalfYearNum()
  refreshProcessStats()
})
    getBusinessData();
    analysisCustomer();
    todoInfoS();
    statisticsReceivable();
    qualityStatisticsInfo();
    getAmountHalfYearNum();
    refreshProcessStats();
  });
</script>
<style scoped>
@@ -752,7 +828,12 @@
.welcome-banner {
  padding: 10px 10px;
  background: linear-gradient(135deg, rgba(229, 240, 255, 0.9), rgba(214, 232, 255, 0.7), rgba(207, 236, 255, 0.9));
    background: linear-gradient(
      135deg,
      rgba(229, 240, 255, 0.9),
      rgba(214, 232, 255, 0.7),
      rgba(207, 236, 255, 0.9)
    );
}
.welcome-title {
@@ -839,7 +920,7 @@
.data-title {
  font-weight: 700;
  font-size: 26px;
  color: #FFFFFF;
    color: #ffffff;
}
.data-num {
@@ -885,14 +966,14 @@
.data-desc {
  font-weight: 500;
  font-size: 13px;
  color: #FFFFFF;
    color: #ffffff;
}
.data-value {
  font-size: 18px;
  font-weight: 500;
  margin: 10px 0;
  color: #FFFFFF;
    color: #ffffff;
}
.top-left {
@@ -939,7 +1020,7 @@
}
.todo-title::before {
  content: '';
    content: "";
  /* 必需,表示这里有一个内容 */
  position: absolute;
  left: -10px;
@@ -952,7 +1033,7 @@
  /* 圆的直径 */
  height: 6px;
  /* 圆的直径 */
  background: #498CEB;
    background: #498ceb;
  border-radius: 50%;
  /* 让其变成圆形 */
}
@@ -1003,10 +1084,10 @@
  position: absolute;
  left: 0;
  top: 4px;
  content: '';
    content: "";
  width: 4px;
  height: 18px;
  background-color: #002FA7;
    background-color: #002fa7;
  border-radius: 2px;
}
@@ -1072,13 +1153,13 @@
}
.line::after {
  content: '';
    content: "";
  position: absolute;
  right: 2px;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: #C9C5C5;
    background-color: #c9c5c5;
  border-radius: 2px;
}
@@ -1115,7 +1196,6 @@
.quality-card.three {
  background-image: url("../assets/images/chuchang.png");
}
.quality-card span {
@@ -1184,15 +1264,15 @@
}
.dot-blue {
  background: #1E5BFF;
    background: #1e5bff;
}
.dot-yellow {
  background: #F7B500;
    background: #f7b500;
}
.dot-teal {
  background: #19C6C6;
    background: #19c6c6;
}
.process-card {
@@ -1203,7 +1283,7 @@
.process-card--name {
  background: rgba(235, 242, 255, 1);
  color: #1E5BFF;
    color: #1e5bff;
  font-weight: 800;
  font-size: 14px;
}