he wei
2024-11-12 a6f96b0ff302e4ddedb6a2c5ccf3d2956959abaa
src/views/datas/dataHis.vue
@@ -21,6 +21,10 @@
const monChart = ref();
const groupChart = ref();
const slideValue = ref(0);
const testDataFormated = reactive({
  labels: [],
  datas: [],
});
const testRecordList = ref([]);
const testDatas = ref([]);
@@ -32,11 +36,17 @@
const testObj = computed(() => {
  if (testRecordList.value) {
    let [type, record] = testRecordCode.value || [];
    let [type, record, record2] = testRecordCode.value || [];
    if (!type) return {};
    let list = testRecordList.value.filter((v) => v.value == type)[0].children;
    return list.filter((v) => record == v.value)[0];
    if (record2 !== undefined) {
      return list
        .filter((v) => record == v.value)[0].children
        .filter((vv) => vv.value == record2)[0];
    } else {
      return list.filter((v) => record == v.value)[0];
    }
  } else {
    return {};
  }
@@ -45,6 +55,8 @@
function chooseDev(params) {
  currentDevId.value = params.devId;
  testRecordCode.value = undefined;
  testDatas.value = [];
  updateChart([]);
  getList();
}
@@ -70,20 +82,52 @@
          let type = "";
          switch (v) {
            case "chr":
              type = "充电测试";
              type = devType.value == 1 ? "充电测试" : "充电";
              break;
            case "dis":
              type = "放电测试";
              type = devType.value == 1 ? "放电测试" : "放电";
              break;
            case "jun":
              type = "均衡";
              break;
          }
          let label = type;
          let value = v;
          let children = arr.map((vv) => ({
            ...vv,
            label: vv.testStarttime,
            value: vv.testRecordCount,
          }));
          return { label, value, disabled: !arr.length, children };
          let children = [];
          let count = arr.length;
          if (devType.value == 1) {
            children = arr.map((vv) => ({
              ...vv,
              label: vv.testStarttime,
              value: vv.testRecordCount,
            }));
          } else {
            // 添加一级 区分是组1还是组2
            let _obj = {};
            for (let i = 0, len = arr.length; i < len; i++) {
              let item = arr[i];
              let idx = item.battIdx;
              _obj[idx] = _obj[idx] || [];
              _obj[idx].push(item);
            }
            Object.keys(_obj).forEach((vv) => {
              let item = _obj[vv];
              let idx = `组${vv * 1 + 1}`;
              let _count = item.length;
              children.push({
                label: idx,
                count: _count,
                value: `group_${vv}`,
                children: item.map((vvv) => ({
                  ...vvv,
                  label: vvv.testStarttime,
                  value: vvv.testRecordCount,
                })),
              });
            });
          }
          return { label, value, count, disabled: !arr.length, children };
        });
      }
      testRecordList.value = _list;
@@ -94,14 +138,6 @@
}
const canSlide = computed(() => !!testDatas.value.length);
const testInf = computed(() => {
  if (testDatas.value.length) {
    return testDatas.value[0];
  } else {
    return {};
  }
});
function updateChart(data) {
  let labels = [],
@@ -131,8 +167,9 @@
    monBarVol.labels.push(monNum_text);
    monBarVol.datas.push(item.monVol);
  });
  groupChart.value.updateChart(labels, groupVols);
  testDataFormated.datas = monVols;
  testDataFormated.labels = labels;
  setBarChart(monVols);
}
// 根据百分比获取显示的数据的笔数
@@ -144,14 +181,15 @@
}
function handleSlider(params) {
  updateChart(testDatas.value);
  // updateChart(testDatas.value);
  setBarChart(testDataFormated.datas);
}
// 设置柱状图
function setBarChart(dataList) {
  if (!dataList.length) {
    return false;
  }
  // if (!dataList.length) {
  //   return false;
  // }
  let unit = "V";
  let fixed = 3;
@@ -160,7 +198,7 @@
  let index = getDataIndex(dataList.length, slideValue.value);
  let labels = [],
    datas = [];
  if (index != -1) {
  if (dataList.length && index != -1) {
    let data = dataList[index];
    let batNum = getBarNum(data);
    title =
@@ -180,8 +218,8 @@
}
function selectRecord() {
  let res = testRecordCode.value[1];
  console.log("res", res, "=============");
  let res = testRecordCode.value[testRecordCode.value.length - 1];
  // console.log("res", res, "=============");
  getRecordInf(currentDevId.value, res)
    .then((res) => {
@@ -205,7 +243,10 @@
    $message.error("请选择要导出的测试记录");
    return false;
  }
  exportRecord(currentDevId.value, testRecordCode.value[1])
  exportRecord(
    currentDevId.value,
    testRecordCode.value[testRecordCode.value.length - 1]
  )
    .then((res) => {
      let { data, status, headers } = res;
      const matchRes = /filename=(.*)/.exec(headers["content-disposition"]);
@@ -228,6 +269,17 @@
    .catch((err) => {
      console.log(err);
    });
}
function formatTooltip(params) {
  let testTimeLong = testDataFormated.labels;
  let index = getDataIndex(testTimeLong.length, params);
  let test_long = formatSeconds(0);
  if (index != -1) {
    // test_long = formatSeconds(testTimeLong[index]);
    test_long = testTimeLong[index];
  }
  return test_long;
}
onMounted(() => {
@@ -258,7 +310,7 @@
          size="default"
          is-button
        >
          <el-radio-button :value="1">充放电一体机</el-radio-button>
          <el-radio-button :value="1">充放电测试仪</el-radio-button>
          <el-radio-button :value="2">均衡测试仪</el-radio-button>
        </el-radio-group>
      </div>
@@ -284,7 +336,7 @@
          @change="selectRecord"
          ><template #default="{ node, data }">
            <span>{{ data.label }}</span>
            <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
            <span v-if="!node.isLeaf"> ({{ data.count }}) </span>
          </template></el-cascader
        >
        <div class="info-title">
@@ -298,13 +350,17 @@
        </div>
        <div class="info">
          <div class="label">测试时间</div>
          <div class="content">{{ testInf.testStarttime }}</div>
          <div class="content">{{ testObj.testStarttime }}</div>
          <div class="label">测试时长</div>
          <div class="content">{{ formatSeconds(testObj.testTimelong) }}</div>
          <div class="label">数据类型</div>
          <div class="content">
            {{ { 2: "放电数据", 3: "充电数据" }[testInf.testType] }}
            {{
              { 2: "充电数据", 3: "放电数据", 4: "均衡数据" }[testObj.testType]
            }}
          </div>
          <div class="label">停止原因</div>
          <div class="content">{{ testObj.stopTypeReason }}</div>
          <!-- <div class="label">标称容量</div>
          <div class="content">4444444</div>
          <div class="label">单体数量</div>
@@ -332,7 +388,7 @@
          <el-slider
            class="slider"
            v-model="slideValue"
            :show-tooltip="false"
            :format-tooltip="formatTooltip"
            :disabled="!canSlide"
            @input="handleSlider"
          />
@@ -350,7 +406,7 @@
  .p-left {
    width: 340px;
    background: #1a585d;
    background: radial-gradient(#1a585d10, #1a585d80);
    display: flex;
    flex-direction: column;
    .filter {
@@ -472,7 +528,7 @@
    }
    .item {
      // background: #000;
      background: #1a585d;
      background: radial-gradient(#1a585d10, #1a585d80);
    }
    .card-content {
      height: 100%;