gaoluyang
2026-05-18 89166f04030795cd8d91ea0b18e0d3ad2f8b43c3
src/views/index.vue
@@ -1,606 +1,616 @@
<template>
  <div class="app-container home">
    <div style="display: flex;">
      <div>
        <div class="card-top-left">
          <div class="title">
            <span style="font-weight: bold">本月销售、采购情况计划</span>
          </div>
          <div class="card-group">
            <div class="info-card">
              <div class="info-message">
                <div class="info-number">{{contractAmount}}</div>
                <div class="info-title">合同金额(元)</div>
              </div>
              <img src="@/assets/images/icon1.png" alt="" style="width: 63px;height: 63px">
            </div>
            <div class="info-card1">
              <div class="info-message">
                <div class="info-number">{{invoiceAmount}}</div>
                <div class="info-title">开票金额(元)</div>
              </div>
              <img src="@/assets/images/icon2.png" alt="" style="width: 63px;height: 63px">
            </div>
            <div class="info-card2">
              <div class="info-message">
                <div class="info-number">{{receiptAmount}}</div>
                <div class="info-title">回款金额(元)</div>
              </div>
              <img src="@/assets/images/icon%203.png" alt="" style="width: 63px;height: 63px">
            </div>
          </div>
        </div>
        <div class="card-top-left">
          <div class="title">
            <span style="font-weight: bold">本月应收、应付情况计划</span>
          </div>
          <div class="pie">
            <div class="card-group">
              <div class="pie-group">
                <div style="margin-right: 80px">
                  <Echarts ref="chart"
                           :legend="pieLegend"
                           :chartStyle="chartStyle"
                           :series="materialPieSeries"
                           :tooltip="pieTooltip"></Echarts>
                </div>
                <div class="info-message2">
                  <div class="info-message1">
                    <div class="pie-title">本月回款金额</div>
                    <div class="pie-info"><span class="pie-number">{{receiveAmount}}</span>元   <span class="pie-number">{{receiveAmountPercentage}}</span>%</div>
                  </div>
                  <div class="info-message1">
                    <div class="pie-title">应收款金额</div>
                    <div class="pie-info"><span class="pie-number">{{contractAmountMonth}}</span>元</div>
                  </div>
                </div>
              </div>
            </div>
            <div class="card-group">
              <div class="pie-group">
                <div style="margin-right: 80px">
                  <Echarts ref="chart"
                           :options="options"
                           :legend="pieLegend"
                           :chartStyle="chartStyle"
                           :series="materialPieSeries1"
                           :tooltip="pieTooltip1"></Echarts>
                </div>
                <div class="info-message2">
                  <div class="info-message1">
                    <div class="pie-title1">本月付款金额</div>
                    <div class="pie-info"><span class="pie-number1">{{paymentAmount}}</span>元   <span class="pie-number1">{{payableAmountPercentage}}</span>%</div>
                  </div>
                  <div class="info-message1">
                    <div class="pie-title1">应付款金额</div>
                    <div class="pie-info"><span class="pie-number1">{{payableAmount}}</span>元</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div>
        <div class="card-top-right">
          <div class="title">
            <span style="font-weight: bold">客户合同金额TOP5统计</span>
          </div>
          <div>
            <Echarts ref="chart"
                     :chartStyle="chartStyle1"
                     :grid="grid"
                     :legend="barLegend"
                     :series="barSeries"
                     :tooltip="tooltip"
                     :xAxis="xAxis1"
                     :yAxis="yAxis1"
                     style="height: 42vh;"></Echarts>
          </div>
        </div>
      </div>
    </div>
    <div>
      <div>
        <div class="card-bottom">
          <div class="title">
            <span style="font-weight: bold">回款、开票近半年走势图</span>
          </div>
          <div>
            <Echarts ref="chart"
                     :chartStyle="chartStyle1"
                     :grid="grid"
                     :legend="barLegend"
                     :series="lineSeries"
                     :tooltip="tooltipLine"
                     :xAxis="xAxis2"
                     :yAxis="yAxis2"
                     style="height: 27vh;"></Echarts>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup name="Index">
const { proxy } = getCurrentInstance()
import * as echarts from 'echarts';
import Echarts from "@/components/Echarts/echarts.vue";
import {
  getAmountHalfYear,
  getAmountMouth,
  getContractAmount,
  getInvoiceAmount,
  getReceiptAmount,
  getTopFiveList, paymentMonthList
} from "@/api/viewIndex.js";
const pieLegend = reactive({
  show: false,
})
const contractAmount = ref(0)
const invoiceAmount = ref(0)
const receiptAmount = ref(0)
const receiveAmount = ref(0)
const contractAmountMonth = ref(0)
const receiveAmountPercentage = ref(0)
const paymentAmount = ref(0)
const payableAmount = ref(0)
const payableAmountPercentage = ref(0)
const options = reactive({
  graphic: {
    type: 'circle',
    left: 'center',
    top: 'middle',
    shape: {
      r: '70%' // 圆形半径与饼图外圈相同
    },
  }
})
const pieTooltip = reactive({
  trigger: 'item',
  formatter: function (params) {
    // 动态生成提示信息,基于数据项的 name 属性
    const description = params.name === '本月回款金额' ? '本月回款金额' : '应收款金额';
    return `${description} ${formatNumber(params.value)}元 ${params.percent}%`;
  },
  position: 'right'
})
const pieTooltip1 = reactive({
  trigger: 'item',
  formatter: function (params) {
    // 动态生成提示信息,基于数据项的 name 属性
    const description = params.name === '本月付款金额' ? '本月付款金额' : '应付款金额';
    return `${description} ${formatNumber(params.value)}元 ${params.percent}%`;
  },
  position: 'right'
})
// 数字格式化函数,添加逗号作为千位分隔符
function formatNumber(num) {
  return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
const materialPieSeries = ref([
  {
    type: 'pie',
    radius: '92%',
    avoidLabelOverlap: false,
    itemStyle: {
      borderColor: '#fff',
      borderWidth: 2
    },
    label: {
     show:false
    },
    data: [
      { value: 0, name: '本月回款金额', itemStyle: { color: '#2D99FF' }  },
      { value: 0, name: '应收款金额', itemStyle: { color: '#D4DDFF' } },
    ]
  }
])
const materialPieSeries1 = ref([
  {
    type: 'pie',
    radius: '92%',
    avoidLabelOverlap: false,
    itemStyle: {
      borderColor: '#fff',
      borderWidth: 2
    },
    label: {
     show:false
    },
    data: [
      { value: 0, name: '本月付款金额', itemStyle: { color: '#1EBFAC' }  },
      { value: 0, name: '应付款金额', itemStyle: { color: '#D0EFE1' } },
    ]
  }
])
const chartStyle = {
  width: '150%',
  height: '120%' // 设置图表容器的高度
}
const chartStyle1 = {
  width: '100%',
  height: '100%' // 设置图表容器的高度
}
const grid = {
  show: false
}
const tooltip = {
  trigger: 'axis',
  axisPointer: {
    type: 'shadow'
  }
}
const tooltipLine = {
  trigger: 'axis',
}
const yAxis1 = ref([
  {
    type: 'value',
  }
])
const xAxis1 = ref([
  {
    type: 'category',
    data: []
  }
])
const yAxis2 = ref([
  {
    type: 'value',
  }
])
const xAxis2 = ref([
  {
    type: 'category',
    data: []
  }
])
const barLegend = reactive({})
const barSeries = ref([
    {
      type: 'bar',
      data: [],
      label: {
        show: true
      },
    },
])
const lineSeries = ref([
    {
      type: 'line',
      data: [],
      label: {
        show: true
      },
    },
])
// 合同金额
const getContractAmountNum = () => {
  getContractAmount().then((res) => {
    contractAmount.value = res.data
  })
}
// 开票金额
const getInvoiceAmountNum = () => {
  getInvoiceAmount().then((res) => {
    invoiceAmount.value = res.data
  })
}
// 回款金额
const getReceiptAmountNum = () => {
  getReceiptAmount().then((res) => {
    receiptAmount.value = res.data
  })
}
// 月回款金额饼图
const getAmountMouthNum = () => {
  getAmountMouth().then((res) => {
    receiveAmount.value = res.data.receiveAmount
    contractAmountMonth.value = res.data.contractAmount
    const percentage = (receiveAmount.value / contractAmountMonth.value) * 100;
    receiveAmountPercentage.value = percentage.toFixed(2)
    materialPieSeries.value[0].data[0].value = receiveAmount.value
    materialPieSeries.value[0].data[1].value = contractAmountMonth.value
  })
}
// 月付款金额饼图
const paymentMonthListNum = () => {
  paymentMonthList().then((res) => {
    paymentAmount.value = res.data.paymentAmount
    payableAmount.value = res.data.payableAmount
    const percentage = (paymentAmount.value / payableAmount.value) * 100;
    payableAmountPercentage.value = percentage.toFixed(2)
    materialPieSeries1.value[0].data[0].value = paymentAmount.value
    materialPieSeries1.value[0].data[1].value = payableAmount.value
  })
}
// 客户top5
const getTopFiveListNum = async () => {
  const res = await getTopFiveList()
  const customerName = []
  const totalAmount = []
  res.data.forEach(item => {
    customerName.push(item.customerName)
    totalAmount.push(item.totalAmount)
  })
// 正确响应式赋值:创建新的 xAxis 和 series 对象
  xAxis1.value = [
    {
      type: 'category',
      data: customerName
    }
  ]
  barSeries.value = [
    {
      type: 'bar',
      data: totalAmount,
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          { offset: 0, color: '#F7D2FF' },
          { offset: 1, color: '#826AF9' }
        ])
      },
      emphasis: {
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 1, color: '#826AF9' }
          ])
        }
      },
    }
  ]
}
// 线形图
const getAmountHalfYearNum = async () => {
  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)
  })
// 正确响应式赋值:创建新的 xAxis 和 series 对象
  xAxis2.value = [
    {
      type: 'category',
      data: monthName
    }
  ]
  lineSeries.value = [
    {
      name: '开票',
      type: 'line',
      data: receiptAmount,
      smooth: true,
      stack: 'Total',
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(131, 207, 255, 1)'
          },
          {
            offset: 1,
            color: 'rgba(186, 228, 255, 1)'
          }
        ])
      },
      // 设置小圆点的颜色
      itemStyle: {
        color: '#2D99FF', // 小圆点颜色设置为#2D99FF
        borderColor: '#2D99FF' // 如果需要的话,可以设置边框颜色
      },
      emphasis: {
        focus: 'series'
      },
      lineStyle: {
        width: 0
      },
      showSymbol: false,
    },
    {
      name: '回款',
      type: 'line',
      data: invoiceAmount,
      smooth: true,
      stack: 'Total',
      lineStyle: {
        width: 0
      },
      // 设置小圆点的颜色
      itemStyle: {
        color: '#83CFFF', // 小圆点颜色设置为#83CFFF
        borderColor: '#83CFFF' // 如果需要的话,可以设置边框颜色
      },
      showSymbol: false,
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(54, 153, 255, 1)'
          },
          {
            offset: 1,
            color: 'rgba(89, 169, 254, 1)'
          }
        ])
      },
      emphasis: {
        focus: 'series'
      },
    }
  ]
}
getContractAmountNum()
getInvoiceAmountNum()
getReceiptAmountNum()
getTopFiveListNum()
getAmountMouthNum()
paymentMonthListNum()
getAmountHalfYearNum()
</script>
<style scoped>
.card-top-left {
  padding: 16px;
  background: #fff;
  height: 24vh;
  width: 56vw;
  margin-bottom: 20px;
}
.card-top-right {
  padding: 16px;
  background: #fff;
  height: 50.6vh;
  width: 28vw;
  margin-bottom: 20px;
  margin-left: 20px;
}
.card-bottom {
  padding: 16px;
  background: #fff;
  height: 34vh;
  width: 85.2vw;
  margin-bottom: 20px;
}
.title {
  position: relative;
  font-size: 18px;
  color: #333;
  font-weight: 400;
  padding-left: 10px;
  margin-bottom: 26px;
}
.title::before {
  position: absolute;
  left: 0;
  top: 4px;
  content: '';
  width: 4px;
  height: 18px;
  background-color: #3A7BFA;
  border-radius: 2px;
}
.card-group {
  display: flex;
}
.info-card {
  width: 300px;
  height: 126px;
  background-image: url("../assets/images/Rectangle 76@2x.png");
  background-size: 100% 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.info-card1 {
  width: 300px;
  height: 126px;
  background-image: url("../assets/images/Rectangle 77@2x.png");
  background-size: 100% 100%;
  margin: 0 40px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.info-card2 {
  width: 300px;
  height: 126px;
  background-image: url("../assets/images/Rectangle 77@2x(1).png");
  background-size: 100% 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.info-message {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.info-message1 {
  font-weight: bold;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}
.info-message2 {
  font-weight: bold;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
}
.info-number {
  font-weight: bold;
  font-size: 32px;
  color: #FFFFFF;
  margin-bottom: 10px;
}
.info-title {
  font-weight: bold;
  font-size: 18px;
  color: #FFFFFF;
}
.pie {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
}
.pie-group {
  display: flex;
}
.pie-title {
  font-size: 14px;
  line-height: 24px;
  color: #2853FD;
  padding-left: 16px;
  position: relative;
}
.pie-title::before {
  content: '';
  width: 6px; /* 蓝点的宽度 */
  height: 6px; /* 蓝点的高度 */
  background-color: #2853FD; /* 蓝点的颜色 */
  border-radius: 50%; /* 将正方形变为圆形 */
  position: absolute;
  left: 0; /* 定位到左边 */
  top: 9px; /* 垂直居中对齐,根据行高调整 */
}
.pie-title1 {
  font-size: 14px;
  line-height: 24px;
  color: #1EBFAC;
  padding-left: 16px;
  position: relative;
}
.pie-title1::before {
  content: '';
  width: 6px; /* 蓝点的宽度 */
  height: 6px; /* 蓝点的高度 */
  background-color: #1EBFAC; /* 蓝点的颜色 */
  border-radius: 50%; /* 将正方形变为圆形 */
  position: absolute;
  left: 0; /* 定位到左边 */
  top: 9px; /* 垂直居中对齐,根据行高调整 */
}
.pie-info {
  padding-left: 16px;
  font-size: 14px;
  line-height: 24px;
}
.pie-number {
  color: #2853FD;
}
.pie-number1 {
  color: #1EBFAC;
}
</style>
<template>
  <div class="dashboard">
    <!-- 顶部横向两栏 -->
    <div class="dashboard-top">
      <!-- 左:企业信息 -->
      <div class="top-left">
        <div class="company-info">
          <!-- 顶部问候条 -->
          <div class="welcome-banner">
            <div class="welcome-title">
              <span class="welcome-user">{{ userStore.nickName || '系统管理员' }}</span>
              <span> 您好!祝您开心每一天</span>
            </div>
            <div class="welcome-time">登录于: {{ userStore.currentLoginTime }}</div>
          </div>
          <!-- 用户信息卡片 -->
          <div class="user-card">
            <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>
              <div class="user-meta">
                <span>{{ userStore.phonenumber || '123456789' }}</span>
                <span class="sep">|</span>
                <span>{{ userStore.currentFactoryName || '组织架构' }}</span>
                <span class="sep">|</span>
                <span>{{ userStore.remark || '岗位名' }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 销售/采购/库存数据卡片 - 注释掉 -->
      <!--
      <div class="data-cards">
        <div class="data-card sales">
          <div class="data-title">销售数据</div>
          <div class="data-num">
            <div>
              <div class="data-desc">本月销售额/元</div>
              <div class="data-value">{{ businessInfo.monthSaleMoney }}</div>
            </div>
            <div>
              <div class="data-desc">未开票金额/元</div>
              <div class="data-value">{{ businessInfo.monthSaleHaveMoney }}</div>
            </div>
          </div>
        </div>
        <div class="data-card purchase">
          <div class="data-title">采购数据</div>
          <div class="data-num">
            <div>
              <div class="data-desc">本月采购额/元</div>
              <div class="data-value">{{ businessInfo.monthPurchaseMoney }}</div>
            </div>
            <div>
              <div class="data-desc">待付款金额/元</div>
              <div class="data-value">{{ businessInfo.monthPurchaseHaveMoney }}</div>
            </div>
          </div>
        </div>
        <div class="data-card inventory">
          <div class="data-title">库存数据</div>
          <div class="data-num">
            <div>
              <div class="data-desc">当前库存总量/件</div>
              <div class="data-value">{{ businessInfo.inventoryNum }}</div>
            </div>
            <div>
              <div class="data-desc">今日入库/件</div>
              <div class="data-value">{{ businessInfo.todayInventoryNum }}</div>
            </div>
          </div>
        </div>
      </div>
      -->
      <!-- 待办事项 - 注释掉 -->
      <!--
      <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">
            <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>
                <div class="todo-division">部门:{{ item.approveDeptName }}</div>
                <div class="todo-time">{{ item.approveTime }}</div>
              </div>
              <div class="todo-division">待办事由:{{ item.approveReason }}</div>
            </div>
          </li>
        </ul>
        <div v-else style="text-align: center">
          暂无数据
        </div>
      </div>
      -->
    </div>
    <!-- 工序数据生产统计明细 - 生产相关,保留 -->
    <div class="dashboard-row">
      <div class="main-panel process-panel">
        <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-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%"
              @click="handleChartClick" />
          </div>
          <div class="process-panel__aside">
            <div class="process-legend">
              <div class="process-legend__item">
                <span class="dot dot-blue"></span><span>投入量</span>
              </div>
              <div class="process-legend__item">
                <span class="dot dot-yellow"></span><span>报废量</span>
              </div>
              <div class="process-legend__item">
                <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) }}</div>
            </div>
            <div class="process-card">
              <div class="process-card__label">累计总报废</div>
              <div class="process-card__value">{{ formatAmount(processAside.totalScrap) }}</div>
            </div>
            <div class="process-card">
              <div class="process-card__label">累计总产出</div>
              <div class="process-card__value">{{ formatAmount(processAside.totalOutput) }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 选择工序对话框 -->
    <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>
              {{ item.name }}
            </el-checkbox>
          </div>
        </el-checkbox-group>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="processDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="handleProcessDialogConfirm">确认</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 客户合同金额分析 - 注释掉 -->
    <!--
    <div class="dashboard-row">
      <div class="main-panel contract-panel">
        <div class="section-title">客户合同金额分析</div>
        <div class="contract-summary">
          <div class="contract-info">
            <img src="../assets/images/khtitle.png" alt="" style="width: 42px" />
            <div class="contract-card">
              <div class="contract-name">总合同金额(元)</div>
              <div class="contract-meta">
                <div class="main-amount">{{ sum }}</div>
                <div>周同比: <span class="up">{{ yny }}% </span> 日环比: <span class="up">{{ chain }}% </span></div>
              </div>
            </div>
          </div>
        </div>
        <div class="contract-chart-wrapper">
          <div class="chart-container">
            <Echarts ref="chart" :legend="pieLegend" :chartStyle="{ width: '100%', height: '280px' }" :series="materialPieSeries"
              :tooltip="pieTooltip"></Echarts>
          </div>
          <ul class="contract-list">
            <li v-for="item in materialPieSeries[0].data" :key="item.name">
              <div class="contract-item">
                <span class="contract-dot" :style="{ background: item.itemStyle?.color || '#999' }"></span>
                <span class="contract-name">{{ item.name }}</span>
                <span class="contract-rate">{{ item.rate }}%</span>
                <span class="contract-value">¥{{ item.value }}</span>
              </div>
            </li>
          </ul>
        </div>
      </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">
            <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 class="quality-cards">
          <div class="quality-card one">原材料已检测数 <span>{{ qualityStatisticsObject.supplierNum }}件</span></div>
          <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>
      </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;" />
      </div>
    </div>
    -->
  </div>
</template>
<script setup>
import { ref, onMounted, computed, reactive } from 'vue'
import Echarts from "@/components/Echarts/echarts.vue";
import useUserStore from "@/store/modules/user.js";
import { list } from '@/api/productionManagement/productionProcess';
const userStore = useUserStore()
const processOptions = ref([])
const selectedProcessIds = ref([])
const tempProcessIds = ref([])
const processDialogVisible = ref(false)
const activeProcessIndex = ref(0)
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' } },
  },
])
const processYAxis = ref([
  {
    type: 'category',
    axisLabel: { color: 'rgba(0,0,0,0.35)', fontSize: 12 },
    axisLine: { show: false },
    axisTick: { show: false },
    data: [],
  },
])
const processTooltip = ref({
  trigger: 'axis',
  axisPointer: { type: 'shadow' },
})
const processSeries = ref([
  {
    name: '投入量',
    type: 'bar',
    stack: 'total',
    barWidth: 16,
    itemStyle: { color: '#2D99FF', borderRadius: [0, 4, 4, 0] },
    data: [],
  },
  {
    name: '报废量',
    type: 'bar',
    stack: 'total',
    barWidth: 16,
    itemStyle: { color: '#F2CA6D', borderRadius: [0, 4, 4, 0] },
    data: [],
  },
  {
    name: '产出量',
    type: 'bar',
    stack: 'total',
    barWidth: 16,
    itemStyle: { color: '#5EE9C0', borderRadius: [0, 4, 4, 0] },
    data: [],
  },
])
const processGrid = ref({
  left: '3%',
  right: '4%',
  bottom: '3%',
  top: '3%',
  containLabel: true,
})
const processAside = computed(() => {
  const idx = activeProcessIndex.value
  const item = processChartData.value[idx] || {}
  return {
    processName: item.processName || '-',
    totalInput: item.inputNum || 0,
    totalScrap: item.scrapNum || 0,
    totalOutput: item.outputNum || 0,
  }
})
const formatAmount = (num) => {
  if (!num) return '0'
  return num.toLocaleString()
}
const getProcessList = () => {
  list().then(res => {
    processOptions.value = res.data.records
  })
}
const openProcessDialog = () => {
  tempProcessIds.value = [...selectedProcessIds.value]
  processDialogVisible.value = true
}
const handleProcessDialogConfirm = () => {
  selectedProcessIds.value = [...tempProcessIds.value]
  processDialogVisible.value = false
  refreshProcessStats()
}
const resetProcessFilter = () => {
  selectedProcessIds.value = []
  tempProcessIds.value = []
  refreshProcessStats()
}
const handleChartClick = (params) => {
  if (params && params.dataIndex !== undefined) {
    activeProcessIndex.value = params.dataIndex
  }
}
const refreshProcessStats = async () => {
  // 这里调用工序数据统计API
  console.log('刷新工序数据', selectedProcessIds.value, processRange.value)
}
onMounted(() => {
  getProcessList()
})
</script>
<style lang="scss" scoped>
.dashboard {
  padding: 20px;
  background: #f5f7fa;
  min-height: calc(100vh - 84px);
}
.dashboard-top {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.top-left {
  .company-info {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  }
}
.welcome-banner {
  background: linear-gradient(135deg, var(--el-color-primary) 0%, var(--el-color-primary-light-3) 100%);
  padding: 20px;
  color: #fff;
  .welcome-title {
    font-size: 16px;
    margin-bottom: 8px;
    .welcome-user {
      font-size: 20px;
      font-weight: 600;
    }
  }
  .welcome-time {
    font-size: 13px;
    opacity: 0.9;
  }
}
.user-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  .avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--el-color-primary-light-8);
  }
  .user-card-main {
    flex: 1;
    .user-name {
      font-size: 18px;
      font-weight: 600;
      color: #303133;
      margin-bottom: 4px;
    }
    .user-role {
      font-size: 13px;
      color: var(--el-color-primary);
      background: var(--el-color-primary-light-9);
      display: inline-block;
      padding: 2px 10px;
      border-radius: 12px;
      margin-bottom: 8px;
    }
    .user-meta {
      font-size: 13px;
      color: #909399;
      .sep {
        margin: 0 8px;
        color: #dcdfe6;
      }
    }
  }
}
.dashboard-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.main-panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
}
.process-panel {
  &__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
  }
  &__body {
    display: flex;
    gap: 20px;
    height: 400px;
  }
  &__chart {
    flex: 1;
    min-width: 0;
  }
  &__aside {
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
}
.process-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
  &__item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #606266;
    .dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      &.dot-blue {
        background: #2D99FF;
      }
      &.dot-yellow {
        background: #F2CA6D;
      }
      &.dot-teal {
        background: #5EE9C0;
      }
    }
  }
}
.process-card {
  background: #f5f7fa;
  border-radius: 8px;
  padding: 16px;
  &--name {
    font-size: 16px;
    font-weight: 600;
    color: #303133;
    text-align: center;
    background: var(--el-color-primary-light-9);
    color: var(--el-color-primary);
  }
  &__label {
    font-size: 12px;
    color: #909399;
    margin-bottom: 4px;
  }
  &__value {
    font-size: 20px;
    font-weight: 600;
    color: #303133;
  }
}
.process-selection-wrapper {
  max-height: 400px;
  overflow-y: auto;
}
.process-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (max-width: 1200px) {
  .dashboard-top {
    grid-template-columns: 1fr;
  }
  .process-panel__body {
    flex-direction: column;
    height: auto;
  }
  .process-panel__aside {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    .process-card {
      flex: 1;
      min-width: 150px;
    }
  }
}
@media (max-width: 768px) {
  .process-panel__header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .process-grid {
    grid-template-columns: 1fr;
  }
}
</style>