ke_junjie
2025-06-04 bb6e2230bb8ded3c5546bc4e4c282ee343754475
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
<template>
  <div id="Didproject" class="global-content">
    <div class="width height overflowy-auto">
      <div class="height250 overflow">
        <div class="flex justify-end align-centent">
          <el-date-picker
            v-model="daterange"
            size="mini"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="至"
            :clearable="false"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
          <el-button class="margin-left margin-right" type="primary" size="mini" @click="derive">导出</el-button>
        </div>
        <did-nav />
        <classify />
      </div>
      <!-- height-calc280  -->
      <div class="width margin-top10px overflowy-auto">
        <div class="margintopbot paddingtopbottom width overflow">
          <p class="fontsize2rem text-center">货位使用实时图</p>
          <div class="flex flex-wrap">
            <div
              class="did-echarts margin-top10px margin-right width30"
              v-for="(item, index) in chartData"
              :key="index + 'pieechart'"
            >
              <pie-echarts class="width height" :chartData="item" />
            </div>
          </div>
        </div>
        <div class="margintopbot width overflow">
          <p class="fontsize2rem text-center">零件出入库统计</p>
          <div class="width margintopbot flex justify-end">
            <el-date-picker
              v-model="datatime"
              size="mini"
              type="datetimerange"
              value-format="yyyy-MM-dd HH:mm:ss"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
            <el-button class="margin-left margin-right" type="primary" size="mini" @click="goodsinquer">查询</el-button>
            <el-button class="margin-left margin-right" type="primary" size="mini" @click="linkTo">跳转</el-button>
          </div>
          <div class="width98 margintopbot echart-height">
            <line-echart
              titleechart="零件数量统计"
              :linelist="BarItemlinelist"
              :colorList="barcolorList"
              class="width height"
            />
          </div>
          <div class="width98 margintopbot echart-height">
            <line-echart
              titleechart="器具出入库统计"
              :linelist="Containerlinelist"
              :colorList="concolorList"
              class="width height"
            />
          </div>
        </div>
      </div>
    </div>
 
    <top-notice :visible.sync="noticeVisible" :notices="noticeData"></top-notice>
  </div>
</template>
 
<script>
import DidInquer from './components/didinquer';
import DidNav from './components/didnav';
import Classify from './components/classify.vue';
import PieEcharts from './components/pieEcharts';
import LineEchart from './components/lineEcharts';
import {
  GetHomePieData,
  GetHomeBarItemData,
  GetHomeBarContainerData,
  GetHomeNumDataByDate,
  GetWarnings
} from '@/api/Didproject';
import { getDate, GetDateStr, GetTimeStr, getimestampDate, getymdhms } from '@/utils/date';
const { Didproject } = require('@/components/tableContainer/tableHead');
import { exportTableList } from '@/utils/excel';
import TopNotice from './components/notice.vue';
// import { SearchPermission, AddOrUpdateRoleVsPermission, GetUserRoleAllPermission } from '@/api/role-auth';
export default {
  components: { DidInquer, DidNav, PieEcharts, LineEchart, Classify, TopNotice },
  data() {
    return {
      daterange: [GetDateStr(0), GetDateStr(0)],
      datatime: [GetDateStr(-15) + ' 00:00:00', getDate() + ' ' + GetTimeStr(0)],
      chartData: [],
      BarItemlinelist: {}, //零件出入数量
      Containerlinelist: {}, //出入库数量
      clearIntervaltime: null,
      BarItemlineshow: false,
      Containerline: false,
      barcolorList: ['#ffc637', '#fc7293', '#8477e9', '#2599f0', '#31c3ea', '#17d8b9', '#e8bdf3'],
      concolorList: ['#31c3ea', '#17d8b9', '#2599f0', '#e8bdf3', '#ffc637', '#fc7293', '#8477e9'],
      noticeVisible: false,
      noticeData: []
    };
  },
  mounted() {
    this.getWarnings(() => {
      this.GetHomePieData();
      this.GetHomeBarItemData();
      this.GetHomeBarContainerData();
      this.clearIntervaltime = setInterval(() => {
        this.GetHomePieData();
      }, 60000);
    });
  },
  methods: {
    //时间查询
    goodsinquer() {
      this.GetHomeBarItemData();
      this.GetHomeBarContainerData();
    },
    //各类型库位使用统计
    GetHomePieData() {
      //placeType 库位类型;placeTotalNum 总库位数;placeFullNum 已用库位数;placeRate 使用率;
      GetHomePieData().then(res => {
        if (res.code == 0) {
          let data = res.data;
          let pielist = [];
          data.forEach((element, index) => {
            pielist.push({ titel: '', placeRate: '', list: [] });
 
            for (let i in element) {
              if (i == 'placeVal' || i == 'placeOtherVal') {
                pielist[index].list.push({
                  name:
                    i == 'placeOtherVal'
                      ? '未用库位数'
                      : i == 'placeVal'
                      ? '已用库位数'
                      : i == 'placeRate'
                      ? '使用率'
                      : i,
                  value: element[i]
                });
              } else if (i == 'placeType') {
                pielist[index].titel = element[i];
              } else if (i == 'placeRate') {
                pielist[index].placeRate = element[i];
              }
            }
          });
          this.chartData = pielist;
          console.log(this.chartData);
        }
      });
    },
    //获取零件的出入库数量
    GetHomeBarItemData() {
      let time = {
        startTime: this.datatime ? this.datatime[0] : '',
        endTime: this.datatime ? this.datatime[1] : ''
      };
      this.BarItemlineshow = false;
      GetHomeBarItemData(time).then(res => {
        this.BarItemlinelist = res.data;
        this.BarItemlineshow = true;
      });
    },
    //获取器具的出入库数量
    GetHomeBarContainerData() {
      let time = {
        startTime: this.datatime ? this.datatime[0] : '',
        endTime: this.datatime ? this.datatime[1] : ''
      };
      this.$Loading(true);
      this.Containerline = false;
      GetHomeBarContainerData(time).then(res => {
        this.Containerlinelist = res.data;
        this.Containerline = true;
        this.$Loading();
      });
    },
    //跳转大屏
    linkTo() {
      const { href } = this.$router.resolve({
        path: '/output'
      });
      window.open(href, '_blank');
    },
    //导出
    derive() {
      let tabledata = [];
      let tHeader = [];
      let filterVal = [];
      Didproject.forEach(item => {
        tHeader.push(item.columnDescription);
        filterVal.push(item.columnName);
      });
      this.$Loading(true);
      GetHomeNumDataByDate({ stDate: this.daterange[0], edDate: this.daterange[1] }).then(res => {
        if (res.code == 0) {
          let data = res.data;
          data.forEach((element, index) => {
            tabledata.push({
              time: getimestampDate(element.time)
            });
            element.homeNumDataEntityList.forEach(item => {
              Didproject.forEach(vl => {
                if (item.titel == vl.columnDescription) {
                  tabledata[index][vl.columnName] = item.value;
                }
              });
            });
          });
          exportTableList(tHeader, filterVal, tabledata, '库存数据' + getymdhms());
          this.$Loading(false);
        }
      });
    },
    getWarnings(callback) {
      GetWarnings()
        .then(d => {
          if (d.code === 0) {
            this.noticeData = d.data || [];
            this.noticeVisible = true;
            callback(true);
          } else {
            callback(false);
          }
          console.log('kklkljj', d);
        })
        .catch(() => {
          callback(false);
        });
    }
  },
  beforeDestroy() {
    if (this.clearIntervaltime) {
      clearInterval(this.clearIntervaltime);
      this.clearIntervaltime = null;
    }
  }
};
</script>
<style lang="scss" scoped>
#Didproject {
  position: relative;
  .did-echarts {
    height: 200px;
  }
  .echart-height {
    height: 300px;
    margin: 1% auto 2%;
    overflow: hidden;
  }
}
</style>