zhuo
2025-05-20 7eb190f13437b2e67788e9f4bdea725fdb165f01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<template>
  <div class="device-page">
    <div class="device-left">
      <el-input v-model="deviceName" class="div_left_input" clearable placeholder="输入设备名称" size="small"
        suffix-icon="el-icon-search" @blur="searchFilter" @clear="searchFilter"
        @keyup.enter.native="searchFilter"></el-input>
      <el-tree ref="tree" v-loading="loading" :data="list" :expand-on-click-node="false"
        :filter-node-method="filterNode" :props="{ children: 'children', label: 'label' }" highlight-current
        node-key="id" style="height:calc(100vh - 200px);
        overflow-y: scroll;
        scrollbar-width: none;" @node-click="handleNodeClick" @node-expand="nodeOpen" @node-collapse="nodeClose">
        <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%" :style="{
              color: isLeafNode(data) && shouldHighlight(data) ? 'red' : ''
            }">
                <i :class="`node_i ${data.children != undefined
                  ? data.code === '[1]'
                    ? 'el-icon-folder-opened'
                    : 'el-icon-folder'
                  : 'el-icon-tickets'
                  }`
                  "></i>
                {{ data.label }}
              </p>
              <p :style="{
              color: isLeafNode(data) && shouldHighlight(data) ? 'red' : ''
            }">
                {{ data.managementNumber === undefined ? '' : data.managementNumber }}
              </p>
            </el-col>
          </el-row>
        </div>
      </el-tree>
    </div>
    <div class="device-right">
      <div v-if="isShowAll" style="height: 100%;">
        <el-tabs v-model="menuListActiveName" class="main_right" type="border-card">
          <el-tab-pane label="设备总览" name="设备总览">
            <overview v-if="menuListActiveName == '设备总览'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备工具明细" name="设备工具明细">
            <management v-if="menuListActiveName == '设备工具明细'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备校准计划" name="设备校准计划">
            <equipment-calibration-plan v-if="menuListActiveName == '设备校准计划'"
              :clickNodeVal="clickNodeVal"></equipment-calibration-plan>
          </el-tab-pane>
          <el-tab-pane label="设备核查计划" name="设备核查计划">
            <equipment-verification-plan v-if="menuListActiveName == '设备核查计划'"
              :clickNodeVal="clickNodeVal"></equipment-verification-plan>
          </el-tab-pane>
          <el-tab-pane label="设备保养计划" name="设备保养计划">
            <equipment-maintenance-plan v-if="menuListActiveName == '设备保养计划'"
              :clickNodeVal="clickNodeVal"></equipment-maintenance-plan>
          </el-tab-pane>
          <el-tab-pane label="量值溯源计划" name="量值溯源计划">
            <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>
          <el-tab-pane label="使用记录" name="使用记录">
            <record v-if="menuListActiveName == '使用记录'" :isMenuList="1" />
          </el-tab-pane>
        </el-tabs>
      </div>
      <div v-if="!isShowAll" style="height: 100%;">
        <el-tabs v-model="tabListActiveName" class="main_right" type="border-card" @tab-click="handleClick">
          <el-tab-pane label="设备档案" name="设备档案">
            <files v-if="tabListActiveName == '设备档案'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备验收" name="设备验收">
            <equipment-acceptance v-if="tabListActiveName == '设备验收'" :clickNodeVal="clickNodeVal"></equipment-acceptance>
          </el-tab-pane>
          <el-tab-pane label="设备校准" name="设备校准">
            <calibration v-if="tabListActiveName == '设备校准'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <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" />
          </el-tab-pane>
          <el-tab-pane label="使用记录" name="使用记录">
            <record v-if="tabListActiveName == '使用记录'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备停用/启用" name="设备停用/启用">
            <state v-if="tabListActiveName == '设备停用/启用'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备报废" name="设备报废">
            <equipment-scrap v-if="tabListActiveName == '设备报废'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备故障与维修" name="设备故障与维修">
            <equipment-failure v-if="tabListActiveName == '设备故障与维修'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备点检" name="设备点检">
            <inspection-of-equipment v-if="tabListActiveName == '设备点检'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="设备事故" name="设备事故">
            <equipment-accident v-if="tabListActiveName == '设备事故'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
          <el-tab-pane label="作业指导书" name="作业指导书">
            <operationInstruction v-if="tabListActiveName == '作业指导书'" :clickNodeVal="clickNodeVal" />
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
  </div>
</template>
 
<script>
import operationOverview from "./component/operationOverview.vue";
import files from "./component/files.vue";
import calibration from "./component/calibration.vue";
import check from "./component/check.vue";
import borrow from "./component/borrow.vue";
import fault from "./component/fault.vue";
import record from "./component/record.vue";
import state from "./component/state.vue";
import management from "./component/management.vue";
import overview from "./component/deviceOverview.vue";
import resourceReservation from "./component/resourceReservation.vue";
import operationInstruction from "./component/operationInstruction.vue";
import EquipmentCalibrationPlan from "./component/equipmentCalibrationPlan.vue";
import EquipmentVerificationPlan from "./component/equipmentVerificationPlan.vue";
import UsingExternalInstruments from "./component/usingExternalInstruments.vue";
import EquipmentScrap from "./component/equipmentScrap.vue";
import EquipmentFailure from "./component/equipmentFailure.vue";
import InspectionOfEquipment from "./component/inspectionOfEquipment.vue";
import EquipmentAccident from "./component/equipmentAccident.vue";
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,
    EquipmentMaintenancePlan,
    EquipmentAccident,
    InspectionOfEquipment,
    EquipmentFailure,
    EquipmentScrap,
    UsingExternalInstruments,
    EquipmentVerificationPlan,
    EquipmentCalibrationPlan,
    operationOverview,
    files,
    calibration,
    check,
    borrow,
    fault,
    record,
    state,
    management,
    overview,
    resourceReservation,
    operationInstruction,
    equipmentMaintenance,
    usageAuthorization,
  },
  data() {
    return {
      isShowAll: true,
      deviceName: "", // 侧边栏搜索
      loading: false,
      tabListActiveName: '设备档案',
      menuListActiveName: '设备总览',
      list: [],
      clickNodeVal: {}
    };
  },
  mounted() {
    // 初始化调用
    this.geList();
  },
  methods: {
    handleClick(tab, event) {
    },
    searchFilter() {
      this.$refs.tree.filter(this.deviceName)
    },
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 父级
    geList() {
      this.loading = true;
      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) {
      // 点击临时缓存
      this.clickNodeVal = val;
      // 存储父级节点级数
      this.clickNodeVal.level = node.level
      this.clickNodeVal.parent = node.parent.data
      // 是否显示设备详情
      if (!val.value) {
        this.isShowAll = true
      } else {
        this.isShowAll = false
      }
    },
    nodeOpen(data, node, el) {
      // $($(el.$el).find(".node_i")[0]).attr(
      //   "class",
      //   "node_i el-icon-folder-opened"
      // );
    },
    nodeClose(data, node, el) {
      // $($(el.$el).find(".node_i")[0]).attr("class", "node_i el-icon-folder");
    },
  }
};
</script>
 
<style scoped>
.device-page {
  display: flex;
  padding-top: 10px;
  box-sizing: border-box;
  width: 100%;
}
 
.device-left {
  width: 250px;
  height: 100%;
  background: #fff;
  border-radius: 16px;
  box-sizing: border-box;
  padding: 10px 16px;
  flex-shrink: 0;
  padding-right: 0;
}
 
.device-right {
  background: #fff;
  width: calc(100% - 250px);
  height: calc(100vh - 100px);
  border-radius: 16px;
  box-sizing: border-box;
  padding: 10px;
}
 
.showLargeCategory {
  width: 100%;
  height: 100%;
}
 
.device-right-content {
  /* margin-top: 10px; */
  height: calc(100% - 42px);
  width: 100%;
}
 
.custom-tree-node {
  width: 100%;
  line-height: 32px;
  font-size: 14px;
}
 
.node_i {
  color: orange;
  font-size: 18px;
}
 
.main_right {
  height: calc(100% - 5px);
  overflow: hidden;
}
 
>>>.el-tabs__content {
  padding-top: 0;
  max-height: 95%; /* 根据需求调整高度 */
  overflow-y: auto; /* 垂直方向超出时显示滚动条 */
}
 
>>>.single-line-ellipsis {
  margin: 0 !important;
}
 
>>>.el-tree-node__content {
  text-align: left;
  align-items: start;
  margin: 4px;
  height: 100%;
}
</style>