<template>
|
<view class="parameter-page">
|
<!-- 获取参数按钮 -->
|
<button class="fetch-btn" @click="dialogToggle">获取当前参数</button>
|
|
<!-- 参数表格,分为两列 -->
|
<view class="parameter-table">
|
<!-- 左列参数 -->
|
<view class="parameter-column">
|
<view class="table-row header">
|
<text class="table-cell txt">参数名</text>
|
<text class="table-cell txt">参数值</text>
|
</view>
|
<view v-for="(param, index) in firstHalf" :key="index" class="table-row">
|
<view class="table-cell">
|
<input class="parameter-name" v-model="param.field" disabled="true" />
|
</view>
|
<view class="table-cell">
|
<input class="parameter-value" v-model="param.value" disabled="true" />
|
</view>
|
</view>
|
</view>
|
|
<!-- 右列参数 -->
|
<view class="parameter-column">
|
<view class="table-row header">
|
<text class="table-cell txt">参数名</text>
|
<text class="table-cell txt">参数值</text>
|
</view>
|
<view v-for="(param, index) in secondHalf" :key="index" class="table-row">
|
<view class="table-cell">
|
<input class="parameter-name" v-model="param.field" disabled="true" />
|
</view>
|
<view class="table-cell">
|
<input class="parameter-value" v-model="param.value" disabled="true" />
|
</view>
|
</view>
|
</view>
|
|
<view class="parameter-column">
|
<view class="table-row header">
|
<text class="table-cell txt">参数名</text>
|
<text class="table-cell txt">参数值</text>
|
</view>
|
<view v-for="(param, index) in secondHalf1" :key="index" class="table-row">
|
<view class="table-cell">
|
<input class="parameter-name" v-model="param.field" disabled="true" />
|
</view>
|
<view class="table-cell">
|
<input class="parameter-value" v-model="param.value" disabled="true" />
|
</view>
|
</view>
|
</view>
|
|
<view class="parameter-column">
|
<view class="table-row header">
|
<text class="table-cell txt">参数名</text>
|
<text class="table-cell txt">参数值</text>
|
</view>
|
<view v-for="(param, index) in secondHalf2" :key="index" class="table-row">
|
<view class="table-cell">
|
<input class="parameter-name" v-model="param.field" disabled="true" />
|
</view>
|
<view class="table-cell">
|
<input class="parameter-value" v-model="param.value" disabled="true" />
|
</view>
|
</view>
|
</view>
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
<script>
|
export default {
|
props: {
|
orderNo: String,
|
orderId: Number,
|
machineNo: String
|
},
|
data() {
|
return {
|
parameters: [], // 参数集合
|
firstHalf: [], // 第一半部分参数
|
secondHalf: [], // 第二半部分参数
|
secondHalf1: [], // 第三半部分参数
|
secondHalf2: [] // 第四半部分参数
|
};
|
},
|
created() {
|
|
// let machine = uni.getStorageSync('machine');
|
// let orderId = uni.getStorageSync('orderId');
|
// let orderNo = uni.getStorageSync('orderNo');
|
|
// if (orderId) {
|
// this.orderId = orderId;
|
// } else {
|
// if (!this.orderId) {
|
// this.orderId = uni.getStorageSync('id');
|
// }
|
|
// }
|
|
// if (orderNo) {
|
// this.orderNo = orderNo;
|
// } else {
|
// if (!this.orderNo) {
|
// this.orderNo = uni.getStorageSync('daa001');
|
// }
|
// }
|
|
// if (machine) {
|
// this.machineNo = machine;
|
// } else {
|
// if (!this.machineNo) {
|
// this.machineNo = uni.getStorageSync('machineNo');
|
// }
|
// }
|
|
if (!this.orderId && !this.orderNo) {
|
return;
|
}
|
|
this.fetchParameters();
|
},
|
methods: {
|
|
dialogToggle() {
|
let thit = this;
|
uni.showModal({
|
title: '提示',
|
content: '确认重新获取工艺参数吗?',
|
success: function(res) {
|
if (res.confirm) {
|
// 执行确认后的操作
|
thit.manualSynchronization();
|
}
|
else {
|
// 执行取消后的操作
|
}
|
}
|
})
|
|
},
|
|
fetchParameters() {
|
this.$post({
|
url: "/DeviceMetrics/GetListByOrderNo",
|
data: {
|
orderNo: this.orderNo,
|
orderId: this.orderId,
|
}
|
}).then(res => {
|
this.parameters = res.data.tbBillList;
|
this.splitParameters(); // 分割参数
|
}).catch(err => {
|
console.error("获取参数失败:", err);
|
});
|
},
|
manualSynchronization() {
|
console.log(111);
|
this.$sendPostRequest({
|
url: "http://192.168.0.94:9095/Numerical/manualSynchronizationBycl",
|
data: {
|
orderId: this.orderId,
|
machineNo: this.machineNo
|
},
|
contentType: "application/json"
|
}).then(res1 => {
|
if (res1.code == 200) {
|
this.fetchParameters();
|
this.$showMessage("更新成功");
|
} else {
|
this.$showMessage("同步失败");
|
}
|
});
|
|
|
},
|
// 将参数分成两部分
|
splitParameters() {
|
// const chunkSize = Math.ceil(this.parameters.length / 4);
|
// this.firstHalf = this.parameters.slice(0, chunkSize), // 第一列
|
// this.secondHalf = this.parameters.slice(chunkSize, chunkSize * 2), // 第二列
|
// this.secondHalf1 = this.parameters.slice(chunkSize * 2, chunkSize * 3), // 第三列
|
// this.secondHalf2 = this.parameters.slice(chunkSize * 3) // 第四列
|
let groupedData = this.groupByGroupSeq(this.parameters);
|
this.firstHalf = groupedData.get(1); // Group with groupSeq 1
|
this.secondHalf = groupedData.get(2); // Group with groupSeq 2
|
this.secondHalf1 = groupedData.get(3); // Group with groupSeq 3
|
this.secondHalf2 = groupedData.get(4); // Group with groupSeq 4
|
},
|
groupByGroupSeq(data) {
|
const acc = new Map(); // Initialize Map to store groups
|
|
// Loop through all items and assign them to the correct group
|
for (let i = 0; i < data.length; i++) {
|
const item = data[i];
|
if (!acc.has(item.groupSeq)) {
|
acc.set(item.groupSeq, []); // Initialize array for new groupSeq
|
}
|
acc.get(item.groupSeq).push(item); // Push item into the corresponding group
|
}
|
|
return acc;
|
}
|
}
|
};
|
</script>
|
|
<style scoped>
|
.parameter-page {
|
padding: 20px;
|
}
|
|
.fetch-btn {
|
display: block;
|
width: 100%;
|
margin-bottom: 20px;
|
background-color: #007bff;
|
color: white;
|
text-align: center;
|
font-size: 32px !important;
|
padding: 18px 0;
|
}
|
|
.parameter-table {
|
display: flex;
|
justify-content: space-between;
|
font-size: 28px !important;
|
}
|
|
.parameter-column {
|
flex: 1;
|
}
|
|
.table-row {
|
display: flex;
|
justify-content: space-between;
|
}
|
|
.header {
|
background-color: #f0f0f0;
|
font-weight: bold;
|
font-size: 32px !important;
|
}
|
|
.table-cell {
|
flex: 1;
|
padding: 5px;
|
border: 1px solid #ccc;
|
}
|
|
.txt {
|
text-align: center;
|
padding: 10px 0;
|
}
|
|
.parameter-name {
|
text-align: center;
|
background-color: transparent;
|
border: none;
|
}
|
|
.parameter-value {
|
text-align: center;
|
border: none;
|
padding: 5px;
|
background-color: transparent;
|
}
|
|
.table-row,
|
.table-cell,
|
.parameter-name,
|
.parameter-value,
|
.txt {
|
font-size: 28px !important;
|
}
|
|
</style>
|