gaoluyang
2025-03-29 01d5d762121c6fd6bf76108755b6ec715da16a31
添加-检验项偏差页面
已修改2个文件
已添加1个文件
296 ■■■■■ 文件已修改
src/api/statisticalCharts/dataAnalysis.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/materialOrder/customsInspection.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/statisticalCharts/inspectionItemWarning/index.vue 277 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/statisticalCharts/dataAnalysis.js
@@ -71,3 +71,19 @@
    data: query,
  });
}
//查询预警列表
export function selectDeviationWarningPage(query) {
  return request({
    url: "/insProductDeviationWarning/selectDeviationWarningPage",
    method: "get",
    params: query,
  });
}
//查询预警列表
export function selectDeviationWarning(query) {
  return request({
    url: "/insProductDeviationWarning/selectDeviationWarning",
    method: "get",
    params: query,
  });
}
src/views/business/materialOrder/customsInspection.vue
@@ -356,10 +356,9 @@
      </span>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false"
               :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
               :show-close="false" :visible.sync="bsm3Dia"
               title="区间值填写" width="800px">
      <el-table :data="editTable" height="80vh" style="width: 100%">
      <el-table :data="editTable" height="80vh" style="width: 100%" :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border>
        <!-- inspectionItemList -->
        <el-table-column label="检验项" prop="inspectionItemList" width="180">
        </el-table-column>
src/views/statisticalCharts/inspectionItemWarning/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,277 @@
<template>
  <div class="app-container">
    <div>
      <lims-table :tableData="tableData" :column="column"
                  :height="'calc(100vh - 500px)'" @pagination="pagination"
                  :rowClick="rowClick"
                  :page="page" :tableLoading="tableLoading"></lims-table>
    </div>
    <div>
      <el-row>
        <el-col :span="24">
          <div class="inspection-card">
            <div class="title">检验项偏差预警数据详情</div>
            <Echarts ref="chart"
                     :chartStyle="chartStyle"
                     :grid="grid"
                     :options="echartsOptions"
                     :series="echartsSeries"
                     :tooltip="tooltip"
                     :xAxis="xAxis"
                     :yAxis="yAxis"
                     style="height: 40vh;"></Echarts>
          </div>
        </el-col>
      </el-row>
    </div>
    <el-dialog :visible.sync="viewDia" title="查看详情" width="1100px">
      <lims-table :tableData="tableData1" :column="column1"
                  height="570"
                  :tableLoading="tableLoading1"></lims-table>
    </el-dialog>
  </div>
</template>
<script>
import limsTable from "@/components/Table/lims-table.vue";
import {selectDeviationWarning, selectDeviationWarningPage} from "@/api/statisticalCharts/dataAnalysis";
import Echarts from "@/components/echarts/echarts.vue";
export default {
  name: '',
  // import å¼•入的组件需要注入到对象中才能使用
  components: {Echarts, limsTable},
  data() {
    // è¿™é‡Œå­˜æ”¾æ•°æ®
    return {
      viewDia: false,
      queryParams: {},
      tableData: [],
      tableLoading: false,
      column: [
        { label: '样品编号', prop: 'sampleCode',width: 150 },
        { label: '样品名称', prop: 'sampleName',width: 150 },
        { label: '型号', prop: 'sampleModel' },
        { label: '供应商名称', prop: 'supplierName',width: 150 },
        { label: '检验项名称', prop: 'inspectionItemName',width: 150 },
        { label: '供应商名称', prop: 'supplierName',width: 150 },
        {
          label: "偏差值",
          prop: "deviationValue",
          width: 150,
          dataType: "tag",
          formatType: (params) => {
            return 'danger'
          },
        },
        { label: '检测时间', prop: 'detectionTime',width: 160 },
        {
          dataType: 'action',
          label: '操作',
          operation: [
            {
              name: '查看',
              type: 'text',
              clickFun: (row) => {
                this.openDia(row);
              },
            }
          ]
        }
      ],
      page: {
        total: 0,
        size: 20,
        current: 1
      },
      tableData1: [],
      tableLoading1: false,
      column1: [
        { label: '样品编号', prop: 'sampleCode'},
        { label: '供应商名称', prop: 'supplierName'},
        { label: '供应商名称', prop: 'supplierName'},
        {
          label: "检测值",
          prop: "testValue",
          width: 150,
          dataType: "tag",
          formatType: (params) => {
            return 'danger'
          },
        },
        { label: '检测时间', prop: 'detectionTime',width: 160 },
      ],
      chartStyle: {
        width: '100%',
        height: '96%' // è®¾ç½®å›¾è¡¨å®¹å™¨çš„高度
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      tooltip: {},
      echartsOptions: {},
      echartsSeries: [
        {
          name: '偏差值',
          type: 'line',
          smooth: true,
          tooltip: {
            valueFormatter: function (value) {
              return value;
            }
          },
          label: {
            show: true,
            position: 'top',
            formatter: function (value) {
              return value.value;
            },
            distance: 14
          },
          data: [],
          markArea: {},
          markPoint: {}
        },
      ],
      xAxis: [
        {
          type: 'category',
          data: [],
          boundaryGap: false,
          axisLabel: {
            interval: 0, // å¼ºåˆ¶æ˜¾ç¤ºæ‰€æœ‰æ ‡ç­¾
            rotate: 0,   // ä¸æ—‹è½¬ï¼ˆå¯ä»¥æ ¹æ®éœ€è¦è°ƒæ•´ï¼‰
            formatter: function (value) {
              // æ¯éš”一定长度添加换行符
              const maxLength = 9; // æ¯æ®µæœ€å¤§å­—符数
              let result = '';
              for (let i = 0; i < value.length; i += maxLength) {
                result += value.substring(i, i + maxLength) + '\n';
              }
              return result.trim(); // åŽ»æŽ‰æœ«å°¾å¤šä½™çš„æ¢è¡Œç¬¦
            },
            margin: 10, // æ ‡ç­¾ä¸Žè½´çº¿çš„距离
          },
        }
      ],
      yAxis: [{
        type: 'value',
        axisLabel: {
          formatter: '{value}'
        }
      }],
    };
  },
  mounted() {
    this.refreshTable()
  },
  // æ–¹æ³•集合
  methods: {
    // æŸ¥è¯¢åˆ—表信息
    refreshTable() {
      this.tableLoading = true
      selectDeviationWarningPage({ ...this.page}).then(res => {
        this.tableLoading = false
        this.tableData = res.data.records
        this.page.total = res.data.total
      }).catch(err => {
        this.tableLoading = false
      })
    },
    // æŸ¥è¯¢æŠ˜çº¿å›¾ä¿¡æ¯
    rowClick (row) {
      selectDeviationWarning({deviationWarningId: row.deviationWarningId}).then(res => {
        console.log('res---', res)
        if (res.data === null) {
          this.$message.warning('暂无数据')
          return
        }
        let lineData = []
        let xAxis = []
        let markAreas = []; // å­˜å‚¨ markArea çš„æ•°ç»„
        let markPoints = [];
        res.data.forEach((item, index) => {
          lineData.push(item.testValue)
          xAxis.push(item.sampleCode)
          // å¦‚æžœ isIssue ä¸º 1,则在此索引处添加一个 markArea
          if (item.isIssue == 1) {
            const startColumn = index > 0 ? xAxis[index - 1] : xAxis[index]; // èµ·ç‚¹ï¼šå‰ä¸€åˆ—或当前列
            const endColumn = xAxis[index]; // ç»ˆç‚¹ï¼šå½“前列
            markAreas.push([
              {
                xAxis: startColumn, // ä»Žå‰ä¸€åˆ—开始
              },
              {
                xAxis: endColumn, // åˆ°å½“前列结束
              }
            ]);
            markPoints.push({
              name: '问题点',
              coord: [item.sampleCode, item.testValue],
              value: item.testValue,
              itemStyle: {
                color: 'rgba(255, 173, 177, 0.8)'
              },
              label: {
                show: true,
                formatter: function(params) {
                  return params.value; // è‡ªå®šä¹‰æ ‡ç­¾å†…容
                },
                color: 'black', // æ ‡ç­¾æ–‡å­—颜色
                fontSize: 12,
                distance: 5, // è°ƒæ•´æ ‡ç­¾ä¸Žæ°”泡的距离
                padding: [0,0],
                backgroundColor: 'rgba(255, 173, 177, 0.8)', // æ ‡ç­¾èƒŒæ™¯è‰²åŠé€æ˜Žåº¦
                borderRadius: 4
              }
            });
          }
        })
        this.xAxis[0].data = xAxis
        this.echartsSeries[0].data = lineData
        // æ›´æ–° markArea é…ç½®
        this.echartsSeries[0].markArea = {
          itemStyle: {
            color: 'rgba(255, 173, 177, 0.4)' // è®¾ç½®èƒŒæ™¯é¢œè‰²
          },
          data: markAreas // åŠ¨æ€ç”Ÿæˆçš„ markArea æ•°æ®
        };
        this.echartsSeries[0].markPoint = {
          data: markPoints
        };
      })
    },
    // é‡ç½®
    refresh() {
      // this.resetForm('entity')
      this.refreshTable()
    },
    // åˆ†é¡µåˆ‡æ¢
    pagination(page) {
      this.page.size = page.limit
      this.refreshTable()
    },
    openDia (row) {
      this.viewDia = true
      this.tableLoading1 = true
      selectDeviationWarning({deviationWarningId: row.deviationWarningId}).then(res => {
        this.tableLoading1 = false
        this.tableData1 = res.data
      }).catch(() => {
        this.tableLoading1 = false
      })
    },
  }
};
</script>
<style scoped>
.inspection-card{
  width: 100%;
  margin-top: 10px;
}
</style>