微调
This commit is contained in:
@@ -92,7 +92,7 @@
|
||||
<script lang="tsx" setup name="FactorTest">
|
||||
import {type Device} from '@/api/device/interface/device';
|
||||
import {Failed} from '@element-plus/icons-vue'
|
||||
import {type Ref, ref, toRef, watch} from 'vue'
|
||||
import {onBeforeMount, type Ref, ref, toRef, watch} from 'vue'
|
||||
import {dialogBig} from '@/utils/elementBind'
|
||||
import {ElMessageBox} from 'element-plus';
|
||||
import {getCoefficientCheck} from '@/api/home/channelsTest/index'
|
||||
@@ -134,28 +134,34 @@ const big_I_Adjust = ref('')
|
||||
const small_V_Adjust = ref('')
|
||||
const small_I_Adjust = ref('')
|
||||
const props = defineProps({
|
||||
testStatus: {
|
||||
type: String,
|
||||
default: 'wait'
|
||||
},
|
||||
webMsgSend: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const testStatus = toRef(props, 'testStatus');
|
||||
const tableDataMap = new Map<number, Ref<ChannelsTest.CoefficientVO[]>>([]);
|
||||
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
|
||||
const webMsgSend = toRef(props, 'webMsgSend');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
onBeforeMount(() => {
|
||||
// 初始化
|
||||
initData()
|
||||
})
|
||||
const initData = () => {
|
||||
checkStore.devices[0]
|
||||
|
||||
|
||||
|
||||
CurV.value = checkStore.devices[0]?.devVolt || 57.74;
|
||||
isButtonDisabled.value = false; // 恢复按钮
|
||||
select_Plan.value = plan
|
||||
select_Plan.value = checkStore.plan
|
||||
planId.value = checkStore.devices[0]?.planId || '';
|
||||
devIdArray.value = checkStore.devices.map(item => item.deviceId);
|
||||
name.value = checkStore.devices.map(item => item.deviceName)
|
||||
@@ -166,7 +172,7 @@ const initData = () => {
|
||||
|
||||
// 初始化 loadingStates 为 false
|
||||
// loadingStates.value = new Array(selection.length).fill(false);
|
||||
errorStates.value = new Array(selection.length).fill(false);
|
||||
errorStates.value = new Array(checkStore.devices.length).fill(false);
|
||||
|
||||
for (let i = 0; i < channel.value.length; i++) {
|
||||
const currentTableData = initializeTableData(dataTemplates, i);
|
||||
@@ -176,6 +182,13 @@ const initData = () => {
|
||||
}
|
||||
|
||||
|
||||
watch(testStatus, function (newValue, oldValue) {
|
||||
if (newValue === 'start') {
|
||||
// 开始系数校准操作
|
||||
handleSubmit()
|
||||
}
|
||||
})
|
||||
|
||||
watch(webMsgSend, function (newValue, oldValue) {
|
||||
if (newValue.code == 10520) {
|
||||
ElMessageBox.alert('报文解析异常!', '初始化失败', {
|
||||
@@ -381,6 +394,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
|
||||
//editableTabsValue.value = (tabNumber.value).toString();//显示下一个tab
|
||||
isButtonDisabled.value = false; // 恢复按钮
|
||||
emit('update:testStatus', 'success')
|
||||
break;
|
||||
}
|
||||
switch (newValue.operateCode) {
|
||||
@@ -501,23 +515,16 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
|
||||
//出错系数检测初始化
|
||||
const TableInit = () => {
|
||||
console.log("TableInitactive", active.value);
|
||||
isButtonDisabled.value = false; // 恢复按钮
|
||||
for (let i = 0; i < channel.value.length; i++) {
|
||||
const currentTableData = initializeTableData(dataTemplates, i);
|
||||
tableDataMap.set(i, currentTableData)
|
||||
|
||||
// const targetArrayRef = tableDataMap.get(i);
|
||||
// if (targetArrayRef) {
|
||||
// const targetArray = targetArrayRef.value;
|
||||
// if (targetArray.length > 0) {
|
||||
// targetArray.forEach(item => item.loading =false)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
activeIndex.value = 0
|
||||
qualified.value = 0
|
||||
active.value = 0
|
||||
emit('update:testStatus', 'test_init_fail')
|
||||
|
||||
// isButtonDisabled.value = false; // 恢复按钮
|
||||
// for (let i = 0; i < channel.value.length; i++) {
|
||||
// const currentTableData = initializeTableData(dataTemplates, i);
|
||||
// tableDataMap.set(i, currentTableData)
|
||||
// }
|
||||
// activeIndex.value = 0
|
||||
// qualified.value = 0
|
||||
// active.value = 0
|
||||
|
||||
}
|
||||
|
||||
@@ -646,133 +653,19 @@ const dataTemplates: ChannelsTest.CoefficientVO[] = [
|
||||
|
||||
];
|
||||
|
||||
const dataTemplates2: ChannelsTest.CoefficientVO[] = [
|
||||
{
|
||||
monitorNum: '1',
|
||||
desc: '系数下装',
|
||||
type: 'big',
|
||||
aVuData: '—',
|
||||
aVuXi: '—',
|
||||
bVuData: '—',
|
||||
bVuXi: '—',
|
||||
cVuData: '—',
|
||||
cVuXi: '—',
|
||||
aIeData: '—',
|
||||
aIeXi: '—',
|
||||
bIeData: '—',
|
||||
bIeXi: '—',
|
||||
cIeData: '—',
|
||||
cIeXi: '—',
|
||||
loading: false,
|
||||
devName: ''
|
||||
},
|
||||
{
|
||||
monitorNum: '2',
|
||||
desc: '系数下装',
|
||||
type: 'small',
|
||||
aVuData: '—',
|
||||
aVuXi: '—',
|
||||
bVuData: '—',
|
||||
bVuXi: '—',
|
||||
cVuData: '—',
|
||||
cVuXi: '—',
|
||||
aIeData: '—',
|
||||
aIeXi: '—',
|
||||
bIeData: '—',
|
||||
bIeXi: '—',
|
||||
cIeData: '—',
|
||||
cIeXi: '—',
|
||||
loading: false,
|
||||
devName: ''
|
||||
},
|
||||
{
|
||||
monitorNum: '3',
|
||||
desc: '系数校准',
|
||||
type: 'big',
|
||||
aVuData: '—',
|
||||
aVuXi: '不合格',
|
||||
bVuData: '—',
|
||||
bVuXi: '—',
|
||||
cVuData: '—',
|
||||
cVuXi: '—',
|
||||
aIeData: '—',
|
||||
aIeXi: '—',
|
||||
bIeData: '—',
|
||||
bIeXi: '—',
|
||||
cIeData: '—',
|
||||
cIeXi: '—',
|
||||
loading: false,
|
||||
devName: ''
|
||||
},
|
||||
{
|
||||
monitorNum: '4',
|
||||
desc: '系数校准',
|
||||
type: 'small',
|
||||
aVuData: '—',
|
||||
aVuXi: '—',
|
||||
bVuData: '—',
|
||||
bVuXi: '—',
|
||||
cVuData: '—',
|
||||
cVuXi: '—',
|
||||
aIeData: '—',
|
||||
aIeXi: '—',
|
||||
bIeData: '—',
|
||||
bIeXi: '—',
|
||||
cIeData: '—',
|
||||
cIeXi: '—',
|
||||
loading: false,
|
||||
devName: ''
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
// 更新错误状态的方法
|
||||
const updateErrorState = (index: number, hasError: boolean) => {
|
||||
errorStates.value[index] = hasError;
|
||||
};
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = (selection: Device.ResPqDev[], plan: Plan.ReqPlan) => {
|
||||
CurV.value = selection[0]?.devVolt || 57.74;
|
||||
isButtonDisabled.value = false; // 恢复按钮
|
||||
select_Plan.value = plan
|
||||
planId.value = selection[0]?.planId || '';
|
||||
devIdArray.value = selection.map(item => item.id);
|
||||
name.value = selection.map(item => item.name)
|
||||
channel.value = selection.map(item => item.devChns)
|
||||
dialogVisible.value = true;
|
||||
total.value = name.value.length
|
||||
|
||||
// const emit = defineEmits<{
|
||||
|
||||
// (e: 'submitClicked', callback: (resolve: (value: boolean) => void) => void): void;
|
||||
// }>();
|
||||
|
||||
// 初始化 loadingStates 为 false
|
||||
// loadingStates.value = new Array(selection.length).fill(false);
|
||||
errorStates.value = new Array(selection.length).fill(false);
|
||||
|
||||
for (let i = 0; i < channel.value.length; i++) {
|
||||
const currentTableData = initializeTableData(dataTemplates, i);
|
||||
tableDataMap.set(i, currentTableData)
|
||||
}
|
||||
//console.log('tableDataMap',tableDataMap);
|
||||
}
|
||||
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'quitClicked'): void;
|
||||
(e: 'submitClicked', callback: (resolve: (value: boolean) => void) => void): void;
|
||||
}>();
|
||||
|
||||
const handleCancel = () => {
|
||||
// 清空 name, channel, total
|
||||
name.value = [];
|
||||
channel.value = [];
|
||||
total.value = 0;
|
||||
activeIndex.value = 0
|
||||
qualified.value = 0
|
||||
active.value = 0
|
||||
dialogVisible.value = false
|
||||
editableTabsValue.value = '0'
|
||||
emit('quitClicked'); // 触发事件
|
||||
}
|
||||
const emit = defineEmits(['update:testStatus']);
|
||||
|
||||
const getTableDataForChannel = (index: number): any[] => {
|
||||
const data = tableDataMap.get(index);
|
||||
@@ -802,13 +695,13 @@ const checkForErrors = (data: ChannelsTest.CoefficientVO[]): boolean => {
|
||||
|
||||
const handleSubmit = async () => {
|
||||
// 创建一个 Promise 来等待父组件的回调
|
||||
const response = await new Promise<boolean>((resolve) => {
|
||||
emit('submitClicked', resolve);
|
||||
});
|
||||
// const response = await new Promise<boolean>((resolve) => {
|
||||
// emit('submitClicked', resolve);
|
||||
// });
|
||||
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
// if (!response) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
isButtonDisabled.value = true; // 禁用按钮
|
||||
tableLoading('big', '系数下装')
|
||||
@@ -820,72 +713,7 @@ const handleSubmit = async () => {
|
||||
scriptId: select_Plan.value?.scriptId,
|
||||
operateType: '0' // '0'为预检测、‘1‘为正式检测
|
||||
})
|
||||
active.value++;
|
||||
|
||||
// 初始化 loadingStates 为 true
|
||||
// loadingStates.value = new Array(name.value.length).fill(true);
|
||||
|
||||
return;
|
||||
// 初始化 currentTableData
|
||||
let isTimer2Completed = false;
|
||||
|
||||
|
||||
//"80b4b4f52a4c4064a18319525f8ac13c",
|
||||
for (let i = 0; i < channel.value.length; i++) {
|
||||
// 重置状态变量
|
||||
active.value = 0;
|
||||
//activeIndex.value = 0;
|
||||
editableTabsValue.value = i.toString();
|
||||
// 初始化并填充 currentTableData
|
||||
const currentTableData = initializeTableData(dataTemplates2, i);
|
||||
tableDataMap.set(i, currentTableData);
|
||||
//activeIndex.value++;
|
||||
|
||||
// 清除之前的 timer1
|
||||
clearInterval(timer1);
|
||||
// 启动 timer1
|
||||
timer1 = setInterval(() => {
|
||||
active.value++;
|
||||
if (active.value > 5) {
|
||||
clearInterval(timer1);
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
// 清除之前的 timer2
|
||||
clearInterval(timer2);
|
||||
// 启动 timer2
|
||||
timer2 = setInterval(() => {
|
||||
// 初始化并填充 currentTableData
|
||||
const currentTableData = initializeTableData(i > 0 ? dataTemplates2 : dataTemplates2, i);
|
||||
tableDataMap.set(i, currentTableData);
|
||||
activeIndex.value++;
|
||||
|
||||
clearInterval(timer2);
|
||||
const currentDataRef = tableDataMap.get(i);
|
||||
if (currentDataRef) {
|
||||
const currentData = currentDataRef.value;
|
||||
// 检查当前数据中有无不合格字段
|
||||
const hasError = checkForErrors(currentData);
|
||||
if (hasError) {
|
||||
} else {
|
||||
qualified.value++;
|
||||
}
|
||||
updateErrorState(i, hasError);
|
||||
}
|
||||
|
||||
// 设置标志变量为 true,表示 timer2 已经完成
|
||||
isTimer2Completed = true;
|
||||
}, 3000);
|
||||
|
||||
// 等待 timer2 完成
|
||||
while (!isTimer2Completed) {
|
||||
// 这里可以添加一个短暂的等待,避免死循环
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
|
||||
// 重置标志变量
|
||||
isTimer2Completed = false;
|
||||
}
|
||||
active.value++;
|
||||
};
|
||||
|
||||
// 提取初始化并填充 currentTableData 的函数
|
||||
@@ -905,9 +733,6 @@ const initializeTableData = (templates: ChannelsTest.CoefficientVO[], index: num
|
||||
return currentTableData;
|
||||
};
|
||||
|
||||
|
||||
// 对外映射
|
||||
defineExpose({open})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user