|
@@ -1,125 +1,175 @@
|
|
|
<template>
|
|
|
- <div class="centreLeft1">
|
|
|
- <!-- <div class="bg-color-black">
|
|
|
+ <div class="centerRight2">
|
|
|
+ <div class="bg-color-black">
|
|
|
<div class="d-flex pt-2 pl-2">
|
|
|
<span>
|
|
|
- <i class="iconfont icon-tongji4" />
|
|
|
+ <i class="iconfont icon-vector" />
|
|
|
</span>
|
|
|
<div class="d-flex">
|
|
|
- <span class="fs-xl text mx-2">任务通过率</span>
|
|
|
- <dv-decoration-3 class="dv-dec-3" />
|
|
|
+ <span class="fs-xl text mx-2">物料操作日志</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="d-flex jc-center">
|
|
|
- <chart />
|
|
|
+ <div class="d-flex mt-1 jc-center body-box">
|
|
|
+ <dv-scroll-board
|
|
|
+ ref="scrollBoard"
|
|
|
+ class="dv-scr-board"
|
|
|
+ :config="config"
|
|
|
+ />
|
|
|
</div>
|
|
|
-
|
|
|
- <div class="bottom-data">
|
|
|
- <div
|
|
|
- class="item-box mt-2"
|
|
|
- v-for="(item, index) in numberData"
|
|
|
- :key="index"
|
|
|
- >
|
|
|
- <div class="d-flex jc-end">
|
|
|
- <i class="iconfont" :class="[iconFont[index]]" />
|
|
|
- <dv-digital-flop class="dv-digital-flop" :config="item.config" />
|
|
|
- </div>
|
|
|
- <p>
|
|
|
- <span> {{ item.text }} </span>
|
|
|
- <span class="colorYellow">(件)</span>
|
|
|
- </p>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div> -->
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script lang="ts">
|
|
|
-import { defineComponent, onMounted, onUnmounted, reactive } from 'vue'
|
|
|
-import Chart from './chart/index'
|
|
|
-export default defineComponent({
|
|
|
- components: {
|
|
|
- Chart
|
|
|
- },
|
|
|
- setup() {
|
|
|
- // 下层数据
|
|
|
- const dataArr = [
|
|
|
- {
|
|
|
- number: 150,
|
|
|
- text: '今日构建总量'
|
|
|
- },
|
|
|
- {
|
|
|
- number: 144,
|
|
|
- text: '总共完成数量'
|
|
|
- },
|
|
|
- {
|
|
|
- number: 361,
|
|
|
- text: '正在编译数量'
|
|
|
+<script>
|
|
|
+
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ config: {
|
|
|
+ header: ["操作类型", "操作时间", "批号", "存货名称", "变更数目"],
|
|
|
+ data: [
|
|
|
+ ["数据加载中...", " ", " ", " ", " "],
|
|
|
+ [" ", " ", " ", " ", " "],
|
|
|
+ [" ", " ", " ", " ", " "],
|
|
|
+ [" ", " ", " ", " ", " "],
|
|
|
+ [" ", " ", " ", " ", " "],
|
|
|
+ [" ", " ", " ", " ", " "],
|
|
|
+ [" ", " ", " ", " ", " "],
|
|
|
+ ],
|
|
|
+ rowNum: 7,
|
|
|
+ headerHeight: 35,
|
|
|
+ headerBGC: "#0f1325",
|
|
|
+ oddRowBGC: "#0f1325",
|
|
|
+ evenRowBGC: "#171c33",
|
|
|
+ index: true,
|
|
|
+ columnWidth: [10, 80, 150, 140, 100],
|
|
|
+ align: ["center", "center", "center", "center", "center"],
|
|
|
},
|
|
|
- {
|
|
|
- number: 571,
|
|
|
- text: '未通过数量'
|
|
|
+ intervalId: null,
|
|
|
+ token: "PDA1",
|
|
|
+ typeMap: {
|
|
|
+ create: '批次入库',
|
|
|
+ out: '批次出库',
|
|
|
+ delete: '批次删除',
|
|
|
+ update: '批次更新',
|
|
|
+ cancel_out: '取消出库'
|
|
|
}
|
|
|
- ]
|
|
|
- // 对应图标
|
|
|
- const iconFont = [
|
|
|
- 'icon-diagnose',
|
|
|
- 'icon-monitoring',
|
|
|
- 'icon-cloudupload',
|
|
|
- 'icon-clouddownload'
|
|
|
- ]
|
|
|
- const numberData = reactive([])
|
|
|
- let intervalInstance = null
|
|
|
- onMounted(() => {
|
|
|
- setData()
|
|
|
- changeTiming()
|
|
|
- })
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.fetchData();
|
|
|
+ // 每分钟刷新一次数据
|
|
|
+ this.intervalId = setInterval(this.fetchData, 60000);
|
|
|
+ },
|
|
|
+ beforeUnmount() {
|
|
|
+ // 清除定时器
|
|
|
+ clearInterval(this.intervalId);
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async fetchData() {
|
|
|
+ try {
|
|
|
+ const headers = new Headers({
|
|
|
+ Accept: "application/json, text/plain, */*",
|
|
|
+ token: this.token,
|
|
|
+ });
|
|
|
|
|
|
- const setData = () => {
|
|
|
- dataArr.forEach(e => {
|
|
|
- numberData.push({
|
|
|
- config: {
|
|
|
- number: [e.number],
|
|
|
- toFixed: 1,
|
|
|
- content: '{nt}',
|
|
|
- style: {
|
|
|
- fontSize: 24
|
|
|
- }
|
|
|
- },
|
|
|
- text: e.text
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
+ const url = "http://192.168.31.105:8008/reportcenter/batchLog/";
|
|
|
+ const response = await fetch(url, {
|
|
|
+ method: "GET",
|
|
|
+ headers: headers,
|
|
|
+ });
|
|
|
|
|
|
- const changeTiming = () => {
|
|
|
- intervalInstance = setInterval(() => {
|
|
|
- changeNumber()
|
|
|
- }, 2000)
|
|
|
- }
|
|
|
- const changeNumber = () => {
|
|
|
- numberData.forEach((item, index) => {
|
|
|
- item.config.number[0] += ++index
|
|
|
- item.config = { ...item.config }
|
|
|
- })
|
|
|
- }
|
|
|
- onUnmounted(() => {
|
|
|
- clearInterval(intervalInstance)
|
|
|
- })
|
|
|
+ if (!response.ok) {
|
|
|
+ throw new Error(
|
|
|
+ `网络错误: ${response.status} ${response.statusText}`
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
- return { numberData, iconFont}
|
|
|
- }
|
|
|
-})
|
|
|
+ const jsonData = await response.json();
|
|
|
+ console.log("数据获取成功:", jsonData);
|
|
|
+
|
|
|
+ const tableData = jsonData.results.map((item) => {
|
|
|
+ // 确定变更数量和符号
|
|
|
+ let quantity = "0.000";
|
|
|
+ let sign = "";
|
|
|
+
|
|
|
+ if (item.log_type === 'create') {
|
|
|
+ quantity = `+${item.goods_in_qty}`;
|
|
|
+ } else if (item.log_type === 'out' || item.log_type === 'cancel_out') {
|
|
|
+ quantity = `-${item.goods_out_qty}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理取消出库的特殊情况
|
|
|
+ if (item.log_type === 'cancel_out') {
|
|
|
+ sign = "+";
|
|
|
+ quantity = `${Math.abs(parseFloat(item.goods_out_qty)).toFixed(3)}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ this.typeMap[item.log_type] || item.log_type,
|
|
|
+ item.create_time,
|
|
|
+ item.batch_code,
|
|
|
+ item.goods_desc,
|
|
|
+ quantity
|
|
|
+ ];
|
|
|
+ });
|
|
|
+
|
|
|
+ // 应用平台主题色
|
|
|
+ const typeColors = {
|
|
|
+ '批次入库': "#2ed47a", // 绿色
|
|
|
+ '批次出库': "#006b6b", // 红色
|
|
|
+ '取消出库': "#3c9aff", // 蓝色
|
|
|
+ '批次删除': "#ffb638", // 橘黄色
|
|
|
+ '批次更新': "#a3a1fb", // 紫色
|
|
|
+ };
|
|
|
+
|
|
|
+ while (tableData.length < 7) {
|
|
|
+ tableData.push(["-", "-", "-", "-", "-"]);
|
|
|
+ }
|
|
|
+
|
|
|
+ const formattedData = tableData.map((row) => {
|
|
|
+ const type = row[0];
|
|
|
+ const quantity = row[4];
|
|
|
+ const isPositive = quantity.startsWith('+');
|
|
|
+
|
|
|
+ return [
|
|
|
+ `<span style="color: ${typeColors[type] || "#fff"}">${type}</span>`,
|
|
|
+ `<span style="color: #c0e4ff">${row[1]}</span>`,
|
|
|
+ `<span style="color: #c0e4ff">${row[2]}</span>`,
|
|
|
+ `<span style="color: #c0e4ff">${row[3]}</span>`,
|
|
|
+ `<span style="color: ${isPositive ? '#2ed47a' : '#ff6b6b'}">${quantity}</span>`,
|
|
|
+ ];
|
|
|
+ });
|
|
|
+
|
|
|
+ this.config.data =
|
|
|
+ tableData.length > 0 ? formattedData : [["暂无数据", "", "", "", ""]];
|
|
|
+ console.log("数据处理成功:", this.config.data);
|
|
|
+
|
|
|
+ this.$refs["scrollBoard"].updateRows(this.config.data);
|
|
|
+ } catch (error) {
|
|
|
+ console.error("数据获取失败:", error);
|
|
|
+ const errorMessage = `加载失败: ${error.message}`;
|
|
|
+ this.config.data = [
|
|
|
+ [errorMessage, "", "", "", ""],
|
|
|
+ ["请检查网络连接", "", "", "", ""],
|
|
|
+ ["或服务地址是否正确", "", "", "", ""],
|
|
|
+ ["Token: " + this.token, "", "", "", ""],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-$box-width: 300px;
|
|
|
$box-height: 410px;
|
|
|
-
|
|
|
-.centreLeft1 {
|
|
|
+$box-width: 100%;
|
|
|
+.centerRight2 {
|
|
|
padding: 16px;
|
|
|
+ padding-top: 20px;
|
|
|
height: $box-height;
|
|
|
width: $box-width;
|
|
|
- border-radius: 10px;
|
|
|
+ border-radius: 5px;
|
|
|
.bg-color-black {
|
|
|
height: $box-height - 30px;
|
|
|
border-radius: 10px;
|
|
@@ -127,38 +177,12 @@ $box-height: 410px;
|
|
|
.text {
|
|
|
color: #c3cbde;
|
|
|
}
|
|
|
- .dv-dec-3 {
|
|
|
- position: relative;
|
|
|
- width: 100px;
|
|
|
- height: 20px;
|
|
|
- top: -3px;
|
|
|
- }
|
|
|
-
|
|
|
- .bottom-data {
|
|
|
- .item-box {
|
|
|
- & > div {
|
|
|
- padding-right: 5px;
|
|
|
- }
|
|
|
- font-size: 14px;
|
|
|
- float: right;
|
|
|
- position: relative;
|
|
|
- width: 50%;
|
|
|
- color: #d3d6dd;
|
|
|
- .dv-digital-flop {
|
|
|
- width: 120px;
|
|
|
- height: 30px;
|
|
|
- }
|
|
|
- i {
|
|
|
- font-size: 20px;
|
|
|
- line-height: 30px;
|
|
|
- margin-left: 20px;
|
|
|
- }
|
|
|
- .colorYellow {
|
|
|
- color: yellowgreen;
|
|
|
- }
|
|
|
- p {
|
|
|
- text-align: center;
|
|
|
- }
|
|
|
+ .body-box {
|
|
|
+ border-radius: 10px;
|
|
|
+ overflow: hidden;
|
|
|
+ .dv-scr-board {
|
|
|
+ width: 98%;
|
|
|
+ height: 340px;
|
|
|
}
|
|
|
}
|
|
|
}
|