zhuo
2025-05-20 7eb190f13437b2e67788e9f4bdea725fdb165f01
src/views/CNAS/resourceDemand/device/index.vue
@@ -12,7 +12,9 @@
        <div slot-scope="{ node, data }" class="custom-tree-node">
          <el-row style="width: 100%;">
            <el-col :span="24">
              <p class="single-line-ellipsis" style="width: 100%">
              <p class="single-line-ellipsis" style="width: 100%" :style="{
              color: isLeafNode(data) && shouldHighlight(data) ? 'red' : ''
            }">
                <i :class="`node_i ${data.children != undefined
                  ? data.code === '[1]'
                    ? 'el-icon-folder-opened'
@@ -22,7 +24,9 @@
                  "></i>
                {{ data.label }}
              </p>
              <p>
              <p :style="{
              color: isLeafNode(data) && shouldHighlight(data) ? 'red' : ''
            }">
                {{ data.managementNumber === undefined ? '' : data.managementNumber }}
              </p>
            </el-col>
@@ -55,6 +59,10 @@
            <quantity-value-traceability-plan v-if="menuListActiveName == '量值溯源计划'"
              :clickNodeVal="clickNodeVal"></quantity-value-traceability-plan>
          </el-tab-pane>
          <el-tab-pane label="设备使用授权" name="设备使用授权">
            <usage-authorization v-if="menuListActiveName == '设备使用授权'"
              :clickNodeVal="clickNodeVal"></usage-authorization>
          </el-tab-pane>
          <el-tab-pane label="利用外部仪器设备" name="利用外部仪器设备">
            <using-external-instruments v-if="menuListActiveName == '利用外部仪器设备'" :clickNodeVal="clickNodeVal"></using-external-instruments>
          </el-tab-pane>
@@ -74,8 +82,8 @@
          <el-tab-pane label="设备校准" name="设备校准">
            <calibration v-if="tabListActiveName == '设备校准'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备维护" name="设备维护">
            <maintenance v-if="tabListActiveName == '设备维护'" :clickNodeVal="clickNodeVal" />
          <el-tab-pane label="设备维护保养" name="设备维护保养">
            <equipmentMaintenance v-if="tabListActiveName == '设备维护保养'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备借用" name="设备借用">
            <borrow v-if="tabListActiveName == '设备借用'" :clickNodeVal="clickNodeVal" />
@@ -112,7 +120,6 @@
import files from "./component/files.vue";
import calibration from "./component/calibration.vue";
import check from "./component/check.vue";
import maintenance from "./component/maintenance.vue";
import borrow from "./component/borrow.vue";
import fault from "./component/fault.vue";
import record from "./component/record.vue";
@@ -131,10 +138,13 @@
import EquipmentMaintenancePlan from "./component/equipmentMaintenancePlan.vue";
import EquipmentAcceptance from "./component/equipmentAcceptance.vue";
import QuantityValueTraceabilityPlan from "./component/quantityValueTraceabilityPlan.vue";
import equipmentMaintenance from "./component/equipmentMaintenance.vue";
import usageAuthorization from "./component/usageAuthorization.vue";
import {
  treeDevice,
} from '@/api/cnas/resourceDemand/device.js'
export default {
  name: 'Device',
  components: {
    QuantityValueTraceabilityPlan,
    EquipmentAcceptance,
@@ -150,7 +160,6 @@
    files,
    calibration,
    check,
    maintenance,
    borrow,
    fault,
    record,
@@ -158,7 +167,9 @@
    management,
    overview,
    resourceReservation,
    operationInstruction
    operationInstruction,
    equipmentMaintenance,
    usageAuthorization,
  },
  data() {
    return {
@@ -191,8 +202,24 @@
      treeDevice().then(res => {
        let data = res.data;
        this.list = data;
        console.log('this.list--', this.list)
        this.loading = false
      });
    },
    // 判断是否是叶子节点
    isLeafNode(data) {
      return !data.children || data.children.length === 0;
    },
    // 判断是否需要标红
    shouldHighlight(data) {
      if (!data.activationDate) return false;
      const today = new Date();
      const targetDate = new Date(data.activationDate);
      const fiveDaysBeforeTarget = new Date(targetDate);
      // 计算前五天的日期
      fiveDaysBeforeTarget.setDate(targetDate.getDate() - 5);
      return today > fiveDaysBeforeTarget;
    },
    handleNodeClick(val, node, el) {
      // 点击临时缓存
@@ -277,6 +304,8 @@
>>>.el-tabs__content {
  padding-top: 0;
  max-height: 95%; /* 根据需求调整高度 */
  overflow-y: auto; /* 垂直方向超出时显示滚动条 */
}
>>>.single-line-ellipsis {