Browse Source

优化历史记录

master
LiLongLong 5 months ago
parent
commit
632749f44e
  1. 20
      src/services/matrix/craft.ts
  2. 27
      src/utils/index.ts
  3. 117
      src/views/History.vue
  4. 8
      src/views/debug/index.vue
  5. 5
      src/views/matrixCraft/index.vue

20
src/services/matrix/craft.ts

@ -1,6 +1,7 @@
import type { WorkType } from "../globalCmd/cmdTypes";
import httpRequest, { type BaseResponse } from "../httpRequest";
import type { CraftItem } from "@/services/matrix/type";
import { getHistoryInfo } from '../../../../A8000/src/services/Index/history';
export function getList(params: { pageSize: number; pageNum: number }) {
return httpRequest<BaseResponse>({
@ -38,6 +39,23 @@ export function delCraft(params:CraftItem){
return httpRequest<BaseResponse<CraftItem[]>>({
url: `/api/matrixCraft/${params.id}`,
params: { ...params },
method: "PUT",
method: "DELETE",
});
}
export function getHistoryList(params:{pageSize:number, pageNum:number}){
return httpRequest<BaseResponse>({
url: `/api/log/list`,
params: { ...params },
method: "GET",
});
}
export function delHistoryLog(params:CraftItem){
return httpRequest<BaseResponse>({
url: `/api/log/${params.id}`,
params,
method: "DELETE",
});
}

27
src/utils/index.ts

@ -7,3 +7,30 @@ export function formatRemainTime(seconds: number) {
const sec = (seconds % 60).toFixed();
return min.padStart(2, "0") + ":" + sec.padStart(2, "0");
}
export function timestampToDate(timestamp:number, format = 'YYYY-MM-DD HH:mm:ss') {
// 创建 Date 对象
const date = new Date(timestamp);
// 如果时间戳无效,返回错误信息
if (isNaN(date.getTime())) {
return '时间戳无效';
}
// 提取日期和时间部分
const year = String(date.getFullYear())
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需要加 1
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
// 根据传入的格式返回日期字符串
return format
.replace('YYYY', year)
.replace('MM', month)
.replace('DD', day)
.replace('HH', hours)
.replace('mm', minutes)
.replace('ss', seconds);
}

117
src/views/History.vue

@ -1,5 +1,116 @@
<template>
<div class="p-6 text-primary text-lg">历史喷涂</div>
<main class="spurt_print">
<div class="spurt_print_btn ml-[3rem]">
<el-button @click="onDel">删除</el-button>
</div>
<div class="w-[90vw] ml-[3rem] mt-[2rem] h-[70vh]">
<el-table :data="tableData" stripe style="width: 100%" ref="historyTableRef">
<el-table-column type="selection" width="55" />
<el-table-column prop="createTime" label="时间" width="100" />
<el-table-column prop="matrixName" label="基质名称" width="100" />
<el-table-column prop="name" label="工艺名称"/>
<el-table-column prop="routeType" label="喷涂路线" width="100">
<template v-slot="scope">
{{scope.row.routeType == 1 ? '横向' : '竖向'}}
</template>
</el-table-column>
<el-table-column prop="height" label="喷涂高度" width="100" />
<el-table-column prop="nitrogenFlowVelocity" label="氮气流速" width="100" />
<el-table-column prop="nitrogenAirPressure" label="氮气气压" width="100" />
<el-table-column prop="matrixFlowVelocity" label="基质流速" width="100" />
<el-table-column prop="voltage" label="电压" width="100" />
<el-table-column prop="movementSpeed" label="移速" width="100" />
<el-table-column prop="space" label="行间距" width="100" />
</el-table>
</div>
</main>
<footer class="footer" v-if="total">
<el-pagination class="pagination" layout="prev, pager, next" :total="total" />
</footer>
</template>
<script setup lang="ts"></script>
<style lang="scss" scoped></style>
<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { getHistoryList, delHistoryLog} from '@/services/matrix/craft'
import { useSettingStore } from '@/stores/setting'
import type { CraftItem } from "@/services/matrix/type";
import { ElMessage, ElMessageBox } from "element-plus";
let total = ref()
const settingStore = useSettingStore()
let tableData = ref<any>([])
const defaultCraft: CraftItem = {
id: 1,
name: '',
matrixId: 0,
routeType: 1,
space: 0,
nitrogenFlowVelocity: 0,
nitrogenAirPressure: 0,
matrixFlowVelocity: 0,
voltage: 0,
needPower: false,
height: 0,
movementSpeed: 0,
position: [],
};
onMounted(()=>{
tableData.value = settingStore.matrixList
getLogList()
})
//
const getLogList = () => {
const params = {
pageNum:1,
pageSize:10,
}
getHistoryList(params).then((res:any)=>{
tableData.value = res.data.list
total.value = res.data.total
})
}
const historyTableRef = ref()
const onDel = () => {
const selectRows = historyTableRef.value.getSelectionRows()
if(selectRows.length !== 1){
ElMessage.error('请选择一条数据进行编辑')
return;
}
const sel = selectRows[0]
ElMessageBox.confirm('确认删除此条数据吗?','提示',{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}).then(()=>{
delHistoryLog(sel).then(res => {
ElMessage.success("删除成功")
getLogList()
})
})
}
</script>
<style lang="scss" scoped>
.el-button--primary{
background: linear-gradient(90deg, #0657c0 24%, #096ae0 101%);;
}
.spurt_print{
.spurt_print_btn{
margin-top: 2rem;
}
}
.footer{
display: flex;
justify-content: end;
position: relative;
.pagination{
position: absolute;
bottom: 0;
right: 3rem;
}
}
</style>

8
src/views/debug/index.vue

@ -168,9 +168,9 @@
</el-col>
<el-col :span="12" class="ml-[20px]">
<div>喷涂方向</div>
<div>喷涂路线</div>
<div>
<el-radio-group v-model="workForm.direction">
<el-radio-group v-model="workForm.routeType">
<el-radio :value="1">横向</el-radio>
<el-radio :value="2">纵向</el-radio>
</el-radio-group>
@ -252,7 +252,7 @@
SyringeParams,
VoltageType,
ControlValueType
} from '@/services/globalCmd/cmdTypes'
} from '@/services/globalCmd/cmdTypes'
import {
moveMotorToPosition,
switchThreeWayValve,
@ -273,7 +273,7 @@ import {
direction:'1'
})
const workForm = ref<Record<string, any>>({
direction: 1,
routeType: 1,
})
const axis = ref<any>({
index: 0

5
src/views/matrixCraft/index.vue

@ -12,7 +12,8 @@
<el-table-column prop="name" label="工艺名称"/>
<el-table-column prop="routeType" label="喷涂路线" width="100">
<template v-slot="scope">
{{scope.row.routeType == 1 ? '横向' : '竖向'}}
<img v-if="scope.row.routeType === 1" :src="route_h" width="20px" height="20px" alt="icon"/>
<img v-else :src="route_h" width="20px" height="20px" alt="icon"/>
</template>
</el-table-column>
<el-table-column prop="height" label="喷涂高度" width="100" />
@ -67,6 +68,8 @@
import type { CraftItem } from "@/services/matrix/type";
import type { WorkType } from "@/services/globalCmd/cmdTypes";
import { ElMessage, ElMessageBox } from "element-plus";
import route_v from "@/assets/route_vertical.png";
import route_h from "@/assets/route_horizontal.png";
let total = ref()
const settingStore = useSettingStore()
let sprayVisible = ref(false)

Loading…
Cancel
Save