¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- |
| | | * @Author: lzhe lzhe@example.com |
| | | * @Date: 2024-04-16 15:22:46 |
| | | * @LastEditors: lzhe lzhe@example.com |
| | | * @LastEditTime: 2024-06-21 01:45:18 |
| | | * @FilePath: /CPSnew/smart-web/src/views/home/widgets/components/mdcDeviceStatus.vue |
| | | * @Description: è¿æ¯é»è®¤è®¾ç½®,请设置`customMade`, æå¼koroFileHeaderæ¥çé
ç½® è¿è¡è®¾ç½®: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
| | | --> |
| | | <template> |
| | | <el-card shadow="hover" header="设å¤ç¨¼å¨çæå" style="height: 100%;" class="running"> |
| | | <div class="running-icon"> |
| | | <el-icon><RefreshLeft /></el-icon> |
| | | <el-icon @click="showSearch"><Filter /></el-icon> |
| | | </div> |
| | | <div class="no-list">{{oeeTitle}}</div> |
| | | <div :id="'equipment'" style="height:160px;"></div> |
| | | |
| | | <div class="advance-box" v-show="isSearch"> |
| | | <div class="advance-header">çé |
| | | <el-icon @click="isSearch = false"><Close /></el-icon> |
| | | </div> |
| | | <div class="advance-content"> |
| | | <div> |
| | | <div> |
| | | <div class="advance-title">鿩工ä½</div> |
| | | <el-tree-select |
| | | multiple |
| | | show-checkbox |
| | | default-expand-all |
| | | size="small" |
| | | @change = "parentIdChange" |
| | | v-model="search.workStationIdList" |
| | | clearable |
| | | node-key="id" |
| | | placeholder="ä¸çº§èå" |
| | | ref="parentTree" |
| | | :data="parentData" |
| | | :props="{ label: 'title' }" |
| | | style="width:80%;" |
| | | :render-after-expand="false" /> |
| | | </div> |
| | | <div> |
| | | <div class="advance-title">éæ©éè¦æåçæ¶é´</div> |
| | | <el-select v-model="search.timeLevel" size="small" style="width:80%;"> |
| | | <template #prefix><span style="margin-right: 6px;color: #409eff;">è¿Nå°æ¶</span></template> |
| | | <el-option v-for="item in timeLevelList" :key="item.value" :label="item.label" :value="item.value"/> |
| | | </el-select> |
| | | </div> |
| | | <div> |
| | | <div class="advance-title">éæ©è®¾å¤æå</div> |
| | | <el-select v-model="search.top" size="small" style="width:80%;"> |
| | | <template #prefix><span style="margin-right: 6px;color: #409eff;" placeholder="ææ">设å¤TOP</span></template> |
| | | <el-option v-for="item in topList" :key="item.value" :label="item.label" :value="item.value"/> |
| | | </el-select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="width: 100%;text-align: right;margin-right: 12px;margin-top: 12px;"> |
| | | <el-button type="primary" @click="serchSubmit">çé</el-button> |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | | |
| | | </template> |
| | | |
| | | <script> |
| | | import * as echarts from 'echarts'; |
| | | import * as ElementPlusIconsVue from '@element-plus/icons-vue' |
| | | let icons = [] |
| | | for (const [key, component] of Object.entries(ElementPlusIconsVue)) { |
| | | icons.push(key) |
| | | } |
| | | export default { |
| | | title: "设å¤ç¨¼å¨çæå", |
| | | icon: "el-icon-data-line", |
| | | description: "å¿«éæ¥ç设å¤ç¨¼å¨ç", |
| | | data() { |
| | | return { |
| | | oeeTitle: "", |
| | | parentData: {}, |
| | | list: [], |
| | | timeLevelList: [], |
| | | topList: [], |
| | | search: { |
| | | workStationIdList: [], |
| | | timeLevel: "", |
| | | top: "" |
| | | }, |
| | | isSearch: false, |
| | | timeLevel: "", |
| | | top: "", |
| | | apiResource: { |
| | | workStationIdList: [] |
| | | }, |
| | | cardData: {}, |
| | | option: { |
| | | grid: { |
| | | top: '0', |
| | | bottom: '0', |
| | | containLabel: true |
| | | }, |
| | | yAxis: { |
| | | type: 'category', |
| | | data: [], |
| | | axisLine: { |
| | | show: false // éèy轴轴线 |
| | | }, |
| | | axisTick: { |
| | | show: false // éèyè½´å»åº¦çº¿ |
| | | }, |
| | | splitLine: { |
| | | show: false // éèyè½´ç½æ ¼çº¿ |
| | | } |
| | | }, |
| | | xAxis: { |
| | | type: 'value', |
| | | axisLabel: { |
| | | show: false // éèxè½´æ°æ®æ ç¾ |
| | | } |
| | | }, |
| | | series: [ |
| | | { |
| | | data: [3.96, 3.95, 3.93, 3.91, 3.91, 3.9, 3.85], |
| | | type: 'bar', |
| | | label: { |
| | | show: true, // æ¾ç¤ºæ ç¾ |
| | | position: 'right', // æ ç¾ä½ç½®è®¾ç½®ä¸ºæ±åçå³ä¾§ |
| | | formatter: function(params) { |
| | | // è¿åæ°æ®å¼åæ¨æ³è¦æ·»å çå符串çç»å |
| | | return params.value + '%'; // ä¾å¦ï¼è¿å '3.96 æå' |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | }, |
| | | } |
| | | }, |
| | | components: {...ElementPlusIconsVue}, |
| | | mounted() { |
| | | this.getParentData(); |
| | | var arr = []; |
| | | for(var i=1;i<=30;i++) { |
| | | this.timeLevelList.push({value:i,label:i}); |
| | | this.topList.push({value:i,label:i}); |
| | | } |
| | | }, |
| | | methods: { |
| | | showSearch() { |
| | | this.search.timeLevel = this.timeLevel; |
| | | this.search.top = this.top; |
| | | this.isSearch = true; |
| | | }, |
| | | serchSubmit() { |
| | | this.apiResource = this.search; |
| | | this.getRunData(); |
| | | }, |
| | | setCurrentKey(v) { |
| | | if (this.firstWorkKey) return |
| | | if (v.isWorkstation) { |
| | | this.firstWorkKey = v.id |
| | | } |
| | | }, |
| | | formatData(data, current) { |
| | | let newData = [] |
| | | if (!current) { |
| | | newData = data.filter(item => item.parentId == 0).map(v => { |
| | | //if (!v.isWorkstation) v.disabled = true |
| | | v.children = this.formatData(data, v).sort((a, b) => { |
| | | return b.sort - a.sort |
| | | }) |
| | | this.setCurrentKey(v) |
| | | return v |
| | | }) |
| | | } else { |
| | | let res = data.filter(v => v.parentId == current.id) |
| | | res = res.map(item => { |
| | | //if (!item.isWorkstation) item.disabled = true |
| | | item.children = this.formatData(data, item).sort((a, b) => { |
| | | return b.sort - a.sort |
| | | }) |
| | | this.setCurrentKey(item) |
| | | return item |
| | | }) |
| | | return res |
| | | } |
| | | return newData |
| | | }, |
| | | getParentData() { |
| | | this.$HTTP.post('/api/blade-cps/group/groupWorkstation/type', { |
| | | groupCategory: 1, |
| | | groupType: "group_workstation" |
| | | }).then(({ code, data }) => { |
| | | if (code === 200) { |
| | | this.data = this.formatData(data) |
| | | this.$nextTick(() => { |
| | | this.parentData = this.data; |
| | | this.getList(); |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | parentIdChange(val) { |
| | | // var $parentId = this.$refs.parentTree.getCurrentNode().title; |
| | | // this.formAddMenu.$parentId = $parentId; |
| | | }, |
| | | getList() { |
| | | this.cardData = this.$CONFIG.DEFAULT_GRID.data; |
| | | this.cardData.forEach(item=> { |
| | | if(item.cardKey == "mdcEquipmentRun") { |
| | | this.getRunData(); |
| | | } |
| | | }) |
| | | }, |
| | | getRunData() { |
| | | var ids = this.extractLastLevelIds(this.parentData); |
| | | var obj = { |
| | | timeLevel: 24, |
| | | top: 7, |
| | | workStationIdList: ids |
| | | } |
| | | this.$HTTP.post(`/api/blade-visual/status/oee-top`,obj).then(res=> { |
| | | if(res.code == 200) { |
| | | this.isSearch = false; |
| | | var recordDom = document.getElementById('equipment'); |
| | | if(res.data.categories.length == 0) return; |
| | | this.option.yAxis.data = res.data.categories; |
| | | this.option.series[0].data = res.data.series[0].data; |
| | | this.oeeTitle = res.data.series[0].name; |
| | | var myChart = echarts.init(recordDom); |
| | | myChart.setOption(this.option); |
| | | } |
| | | }) |
| | | }, |
| | | goPage(item) { |
| | | |
| | | }, |
| | | extractLastLevelIds(items, result = []) { //éå½è·åchildrenæåä¸çº§çidçæ°ç» |
| | | items.forEach(item => { |
| | | // 妿å½å项æid屿§ä¸æ²¡æchildrenæchildren为空æ°ç» |
| | | if (item.id && (!item.children || item.children.length === 0)) { |
| | | result.push(item.id); |
| | | } |
| | | |
| | | // 妿å½å项æchildren屿§ä¸æ¯æ°ç»ï¼åéå½è°ç¨collectIds |
| | | if (Array.isArray(item.children)) { |
| | | this.extractLastLevelIds(item.children, result); |
| | | } |
| | | }); |
| | | |
| | | // è¿åæ¶éå°çidæ°ç» |
| | | return result; |
| | | }, |
| | | }, |
| | | } |
| | | </script> |
| | | <style scoped> |
| | | .running /deep/ .el-card__body { |
| | | padding: 12px 12px 12px; |
| | | } |
| | | .running { |
| | | position: relative; |
| | | } |
| | | .running-icon { |
| | | position: absolute; |
| | | right: 0; |
| | | top: 15px; |
| | | } |
| | | .running-icon i { |
| | | font-size: 16px; |
| | | cursor: pointer; |
| | | margin-right: 15px; |
| | | } |
| | | .no-list { |
| | | display: flex; |
| | | justify-content: center; |
| | | font-weight: 500; |
| | | font-size: 14px; |
| | | color: #666; |
| | | align-items: center; |
| | | } |
| | | .advance-box{ |
| | | width: 330px; |
| | | height: 100%; |
| | | padding: 15px 16px; |
| | | border-radius: 2px; |
| | | box-sizing: border-box; |
| | | border: 1px solid #ebeef5; |
| | | position: absolute; |
| | | right: 0; |
| | | top: 0; |
| | | background-color: #fff; |
| | | } |
| | | .advance-header { |
| | | width: 100%; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | font-weight: 700; |
| | | font-size: 16px; |
| | | color: #333; |
| | | } |
| | | .advance-header i { |
| | | cursor: pointer; |
| | | } |
| | | .advance-content { |
| | | height: calc(100% - 54px); |
| | | overflow: auto; |
| | | } |
| | | .advance-title { |
| | | margin: 20px 0 12px; |
| | | font-weight: 400; |
| | | font-size: 14px; |
| | | color: #666; |
| | | } |
| | | </style> |