diff --git a/package.json b/package.json
index 69e6f62..fe2260f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
- "name": "calibration-pc",
- "version": "1.0.6",
+ "name": "gy-calibration",
+ "version": "1.0.7",
"description": "谷云开发部开发的断路器标定软件",
"main": "./out/main/index.js",
"author": "example.com",
diff --git a/src/renderer/index.html b/src/renderer/index.html
index 8b3708c..70ce626 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -2,7 +2,7 @@
@@ -56,30 +66,35 @@
v-if="device.connectStatus === 1"
:class="[
'iconfont',
- 'icon-icon_duanluqi',
+ 'icon-icon_duanluqi2',
'circuit-breaker',
+ device.switch === 0 ? 'upsideDown' : '',
device.result === 1 ? 'color-green' : device.result === -1 ? 'color-red' : device.result === 2 ? 'color-orange' : ''
]"
>
-
+
芯片ID:
-
{{ device.cpuId || '无' }}
+ {{ device.cpuId || '无' }}
设备端口: {{ device.devicePort || '无' }}
标定结果:
- {{
- device.result === 1 ? '成功' : device.result === -1 ? '失败' : device.result === 2 ? '标定中' : '未标定' || '无'
+ {{
+ device.result === 1 ? '成功' : device.result === -1 ? '失败' : device.result === 2 ? '标定中' : '无' || '无'
}}
结果描述:
-
{{ device.resultTxt || '无' }}
-
+
+
+ 复制
修改
删除
@@ -222,7 +244,7 @@
-
+
@@ -243,10 +265,10 @@
-
-
-
-
+
+
+
+
@@ -264,7 +286,7 @@
断路器校准参数
-
+
@@ -450,10 +472,49 @@
- 错误日志
+
+
+
+
+
+
+ {{ scope.row.errorCode }}
+
+
+
+
+
+
+ {{ scope.row.logMsg }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 导出
+
+
@@ -571,7 +632,7 @@ const shortcutKeyList = ref([
const currentScheme = ref({
schemeName: '',
- schemeType: '1p',
+ schemeType: '1P',
series: 'B7',
framework: '100ZS',
middleDetect: true,
@@ -603,6 +664,7 @@ const currentScheme = ref({
// 1. 新增:设备日志参数集合和step分组数据
const logParamColumns = ref([]); // [{ valueKey, valueName, valueUnit }]
const stepLogRows = ref([]); // [{ step, paramMap: { valueKey: item }, result: 0/1 }]
+const errorLogList = ref([]);
const logTabChange = (tab, event) => {
console.log(tab, event);
@@ -626,6 +688,7 @@ const fetchDeviceLogs = async deviceId => {
if (response.data.code === 0) {
processLogData(response.data.data.result);
+ errorLogList.value = response.data.data.log || [];
} else {
ElMessage.error(response.data.message || '获取设备日志失败');
}
@@ -801,7 +864,6 @@ const socketStatus = computed(() => {
return webSocketStore.socket_open;
});
-
onMounted(() => {
logBoxRef.value = document.querySelector('#log-box-main');
initSocket();
@@ -899,8 +961,39 @@ const stopExecution = async () => {
};
const openSettings = () => {
- schemeDrawerVisible.value = true;
- loadSchemes();
+ ElMessageBox.prompt('请输入管理员密码', '密码验证', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ inputType: 'password',
+ inputValue: 'gy999',
+ inputPlaceholder: '请输入密码',
+ closeOnClickModal: false
+ // inputValidator: (value) => {
+ // if (!value) return '请输入密码';
+ // if (value !== 'gy999') return '密码错误';
+ // return true;
+ // }
+ })
+ .then(async ({ value }) => {
+ try {
+ const response = await axios.post(config.url + '/master/scheme/auth?secret=' + value);
+ if (response.data.code === 0) {
+ if (response.data.data.result) {
+ schemeDrawerVisible.value = true;
+ loadSchemes();
+ } else {
+ ElMessage.error(response.data.message || '密码错误');
+ }
+ } else {
+ ElMessage.error(response.data.message || '密码验证失败');
+ }
+ } catch (error) {
+ ElMessage.error('密码验证失败');
+ }
+ })
+ .catch(() => {
+ // 用户取消,无需处理
+ });
};
// 获取默认标定参数
@@ -1042,7 +1135,7 @@ const deleteScheme = scheme => {
const addScheme = () => {
currentScheme.value = {
schemeName: `方案${schemeList.value.length + 1}`,
- schemeType: '1p',
+ schemeType: '1P',
series: 'B7',
framework: '100ZS',
middleDetect: true,
@@ -1070,12 +1163,14 @@ const addScheme = () => {
steps: [],
iLeakDetectObj: defaultiLeakDetectObj
};
+ isEditMode.value = false;
schemeDetailVisible.value = true;
};
-// 查看方案
+// 修改方案
const viewScheme = scheme => {
currentScheme.value = JSON.parse(JSON.stringify(scheme));
+ isEditMode.value = true;
schemeDetailVisible.value = true;
};
@@ -1243,6 +1338,165 @@ const playCalibration = async () => {
// ElMessage.error('开始执行失败');
}
};
+
+const copyScheme = scheme => {
+ const newScheme = JSON.parse(JSON.stringify(scheme));
+ delete newScheme.id;
+ if (typeof newScheme.schemeName === 'string') {
+ newScheme.schemeName = newScheme.schemeName + '_1';
+ }
+ currentScheme.value = newScheme;
+ isEditMode.value = false;
+ schemeDetailVisible.value = true;
+};
+
+const importInputRef = ref(null);
+
+const exportAllSchemes = () => {
+ if (!schemeList.value.length) {
+ ElMessage.warning('暂无可导出的方案');
+ return;
+ }
+ const exportArr = schemeList.value.map(sch => {
+ const obj = JSON.parse(JSON.stringify(sch));
+ obj.id = '';
+ return obj;
+ });
+ const blob = new Blob([JSON.stringify(exportArr, null, 2)], { type: 'application/json' });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = '谷云校表方案' + dayjs().format('YYYY-MM-DD HH:mm:ss') + '.json';
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ ElMessage.success('导出成功');
+};
+
+const importSchemes = () => {
+ if (importInputRef.value) {
+ importInputRef.value.value = '';
+ importInputRef.value.click();
+ }
+};
+
+const handleImportFile = async e => {
+ const file = e.target.files[0];
+ if (!file) return;
+ const reader = new FileReader();
+ reader.onload = async evt => {
+ try {
+ const arr = JSON.parse(evt.target.result);
+ if (!Array.isArray(arr)) {
+ ElMessage.error('导入文件格式错误,应为方案数组');
+ return;
+ }
+ let successCount = 0,
+ failCount = 0;
+ const duplicateNames = [];
+ for (const sch of arr) {
+ const newSch = JSON.parse(JSON.stringify(sch));
+ delete newSch.id;
+ try {
+ const res = await axios.post(config.url + '/master/scheme/add', newSch);
+ if (res.data.code === 0) successCount++;
+ else {
+ failCount++;
+ if (res.data.code === 50 && res.data.message && res.data.message.includes('方案名称重复')) {
+ duplicateNames.push(newSch.schemeName);
+ }
+ }
+ } catch (err) {
+ failCount++;
+ }
+ }
+ let msg = `导入完成,成功${successCount}条,失败${failCount}条`;
+ if (duplicateNames.length) {
+ msg += `\n名称重复:${duplicateNames.join(',')}`;
+ }
+ ElMessage({ message: msg, type: duplicateNames.length ? 'error' : 'success', duration: 8000 });
+ loadSchemes();
+ } catch {
+ ElMessage.error('导入文件解析失败');
+ }
+ };
+ reader.readAsText(file);
+};
+
+const schemeTableRef = ref(null);
+const selectedSchemes = ref([]);
+const isEditMode = ref(false);
+
+const handleSelectionChange = val => {
+ selectedSchemes.value = val;
+};
+
+const exportSelectedSchemes = () => {
+ const exportArr = selectedSchemes.value.length ? selectedSchemes.value : [];
+ if (!exportArr.length) {
+ ElMessage.warning('请先选择要导出的方案');
+ return;
+ }
+ const arr = exportArr.map(sch => {
+ const obj = JSON.parse(JSON.stringify(sch));
+ obj.id = '';
+ return obj;
+ });
+ const blob = new Blob([JSON.stringify(arr, null, 2)], { type: 'application/json' });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = '谷云校表方案' + dayjs().format('YYYY-MM-DD HH:mm:ss') + '.json';
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ ElMessage.success('导出成功');
+};
+
+const showExportProdDialog = ref(false);
+const exportProdRange = ref([]);
+const exportProdPickerOptions = [
+ {
+ text: '最近一周',
+ value: () => {
+ const end = new Date();
+ const start = new Date();
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
+ return [start, end];
+ }
+ },
+ {
+ text: '最近一个月',
+ value: () => {
+ const end = new Date();
+ const start = new Date();
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
+ return [start, end];
+ }
+ },
+ {
+ text: '最近三个月',
+ value: () => {
+ const end = new Date();
+ const start = new Date();
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
+ return [start, end];
+ }
+ }
+];
+
+const handleExportProd = () => {
+ if (!exportProdRange.value || exportProdRange.value.length !== 2) {
+ ElMessage.warning('请选择导出时间范围');
+ return;
+ }
+ // TODO: 调用实际导出生产数据接口
+ // exportProdRange.value[0]、exportProdRange.value[1] 为起止时间
+ showExportProdDialog.value = false;
+ ElMessage.success('导出请求已发起(请补充实际导出逻辑)');
+};