✨ feat(mes): 新增当前用户工作站绑定状态 VO 和相关接口
parent
6c276d6ae3
commit
00ff024328
|
|
@ -13,6 +13,18 @@ export interface ProWorkRecordLogVO {
|
|||
createTime: Date
|
||||
}
|
||||
|
||||
// MES 当前工作站绑定状态 VO
|
||||
export interface ProWorkRecordVO {
|
||||
userId: number
|
||||
userNickname: string
|
||||
workstationId: number
|
||||
workstationCode: string
|
||||
workstationName: string
|
||||
type: number // 1=上工 2=下工
|
||||
clockInTime: Date
|
||||
clockOutTime: Date
|
||||
}
|
||||
|
||||
// MES 工作记录 API
|
||||
export const ProWorkRecordApi = {
|
||||
// 查询工作记录分页
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
<!-- 我的工作站 - 上下工状态栏 -->
|
||||
<template>
|
||||
<div
|
||||
class="flex items-center justify-between p-12px mb-16px rounded-8px border border-solid border-[var(--el-border-color-lighter)] bg-[var(--el-fill-color-light)]"
|
||||
>
|
||||
<div class="flex items-center gap-8px">
|
||||
<span class="font-600 text-14px text-[var(--el-text-color-primary)]">我的工作站</span>
|
||||
<el-divider direction="vertical" />
|
||||
<template v-if="isClockIn">
|
||||
<el-tag type="success" effect="plain" round class="!inline-flex !items-center">
|
||||
<Icon icon="ep:check" class="mr-4px" />
|
||||
{{ myWorkstation!.workstationCode }} - {{ myWorkstation!.workstationName }}
|
||||
</el-tag>
|
||||
<span class="ml-4px text-13px text-[var(--el-text-color-secondary)]">
|
||||
上工时间:{{ formatDate(myWorkstation!.clockInTime) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-tag type="info" effect="plain" round>当前未上工</el-tag>
|
||||
</template>
|
||||
</div>
|
||||
<div class="flex-shrink-0">
|
||||
<el-popover
|
||||
v-if="!isClockIn"
|
||||
:visible="clockInPopoverVisible"
|
||||
placement="bottom-end"
|
||||
:width="320"
|
||||
trigger="click"
|
||||
>
|
||||
<template #reference>
|
||||
<el-button type="success" plain @click="clockInPopoverVisible = true">
|
||||
<Icon icon="ep:video-play" class="mr-5px" /> 上工
|
||||
</el-button>
|
||||
</template>
|
||||
<div>
|
||||
<p class="mb-8px font-bold">选择工作站</p>
|
||||
<MdWorkstationSelect
|
||||
v-model="selectedWorkstationId"
|
||||
placeholder="请选择工作站"
|
||||
class="w-full"
|
||||
/>
|
||||
<div class="mt-12px text-right">
|
||||
<el-button size="small" @click="clockInPopoverVisible = false">取消</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="success"
|
||||
:disabled="!selectedWorkstationId"
|
||||
@click="handleClockIn"
|
||||
>
|
||||
确认上工
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
<el-button v-if="isClockIn" type="danger" plain @click="handleClockOut">
|
||||
<Icon icon="ep:video-pause" class="mr-5px" /> 下工
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { formatDate } from '@/utils/formatTime'
|
||||
import { ProWorkRecordApi, type ProWorkRecordVO } from '@/api/mes/pro/workrecord'
|
||||
import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorkstationSelect.vue'
|
||||
import { MesProWorkRecordTypeEnum } from '@/views/mes/utils/constants'
|
||||
|
||||
defineOptions({ name: 'WorkRecordStatusBar' })
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'change'): void // 上工/下工操作完成后触发,通知父组件刷新列表
|
||||
}>()
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const myWorkstation = ref<ProWorkRecordVO | null>(null) // 当前工作站绑定状态
|
||||
const clockInPopoverVisible = ref(false) // 上工弹窗是否可见
|
||||
const selectedWorkstationId = ref<number>() // 选中的工作站编号
|
||||
const isClockIn = computed(
|
||||
() => myWorkstation.value?.type === MesProWorkRecordTypeEnum.CLOCK_IN
|
||||
) // 是否处于上工状态
|
||||
|
||||
/** 查询当前用户工作站 */
|
||||
const loadMyWorkstation = async () => {
|
||||
myWorkstation.value = await ProWorkRecordApi.getMyWorkRecord()
|
||||
}
|
||||
|
||||
/** 上工 */
|
||||
const handleClockIn = async () => {
|
||||
if (!selectedWorkstationId.value) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await ProWorkRecordApi.clockInWorkRecord(selectedWorkstationId.value)
|
||||
message.success('上工成功')
|
||||
clockInPopoverVisible.value = false
|
||||
selectedWorkstationId.value = undefined
|
||||
await loadMyWorkstation()
|
||||
emit('change')
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 下工 */
|
||||
const handleClockOut = async () => {
|
||||
try {
|
||||
await message.confirm('确认下工当前工作站?')
|
||||
await ProWorkRecordApi.clockOutWorkRecord()
|
||||
message.success('下工成功')
|
||||
await loadMyWorkstation()
|
||||
emit('change')
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => loadMyWorkstation())
|
||||
</script>
|
||||
|
|
@ -1,68 +1,7 @@
|
|||
<!-- MES 工作记录列表 -->
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 当前工作站绑定状态 -->
|
||||
<el-card shadow="never" class="mb-16px">
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="font-bold">我的工作站</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="flex items-center justify-between">
|
||||
<div v-if="myWorkstation">
|
||||
<el-tag type="success" size="large" effect="dark">
|
||||
<Icon icon="ep:monitor" class="mr-4px" />
|
||||
已上工:{{ myWorkstation.workstationCode }} - {{ myWorkstation.workstationName }}
|
||||
</el-tag>
|
||||
<span class="ml-8px text-gray-400 text-sm">
|
||||
上工时间:{{ formatDate(myWorkstation.createTime) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-tag type="info" size="large">
|
||||
<Icon icon="ep:warning" class="mr-4px" />
|
||||
当前未绑定工作站
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="flex gap-8px">
|
||||
<el-popover
|
||||
v-if="!myWorkstation"
|
||||
:visible="clockInPopoverVisible"
|
||||
placement="bottom"
|
||||
:width="320"
|
||||
trigger="click"
|
||||
>
|
||||
<template #reference>
|
||||
<el-button type="success" @click="clockInPopoverVisible = true">
|
||||
<Icon icon="ep:video-play" class="mr-5px" /> 上工
|
||||
</el-button>
|
||||
</template>
|
||||
<div>
|
||||
<p class="mb-8px font-bold">选择工作站</p>
|
||||
<MdWorkstationSelect
|
||||
v-model="selectedWorkstationId"
|
||||
placeholder="请选择工作站"
|
||||
class="w-full"
|
||||
/>
|
||||
<div class="mt-12px text-right">
|
||||
<el-button size="small" @click="clockInPopoverVisible = false">取消</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="success"
|
||||
:disabled="!selectedWorkstationId"
|
||||
@click="handleClockIn"
|
||||
>
|
||||
确认上工
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
<el-button v-if="myWorkstation" type="danger" @click="handleClockOut">
|
||||
<Icon icon="ep:video-pause" class="mr-5px" /> 下工
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
<WorkRecordStatusBar @change="getList" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
|
|
@ -134,18 +73,14 @@
|
|||
row-key="id"
|
||||
>
|
||||
<el-table-column label="编号" align="center" prop="id" width="80" />
|
||||
<el-table-column label="用户" align="center" prop="userNickname" width="120" />
|
||||
<el-table-column label="工作站编码" align="center" prop="workstationCode" width="140" />
|
||||
<el-table-column label="工作站名称" align="center" prop="workstationName" width="160" />
|
||||
<el-table-column label="用户" align="center" prop="userNickname" />
|
||||
<el-table-column label="工作站编码" align="center" prop="workstationCode" />
|
||||
<el-table-column label="工作站名称" align="center" prop="workstationName" />
|
||||
<el-table-column label="操作类型" align="center" prop="type" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag
|
||||
:type="DICT_TYPE.MES_PRO_WORK_RECORD_TYPE"
|
||||
:value="scope.row.type"
|
||||
/>
|
||||
<dict-tag :type="DICT_TYPE.MES_PRO_WORK_RECORD_TYPE" :value="scope.row.type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" min-width="200" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
|
|
@ -165,21 +100,22 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter, formatDate } from '@/utils/formatTime'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import download from '@/utils/download'
|
||||
import { ProWorkRecordApi, ProWorkRecordLogVO } from '@/api/mes/pro/workrecord'
|
||||
import { ProWorkRecordApi, type ProWorkRecordLogVO } from '@/api/mes/pro/workrecord'
|
||||
import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorkstationSelect.vue'
|
||||
import UserSelect from '@/views/system/user/components/UserSelect.vue'
|
||||
import WorkRecordStatusBar from './WorkRecordStatusBar.vue'
|
||||
|
||||
defineOptions({ name: 'MesProWorkRecordLog' })
|
||||
|
||||
const message = useMessage()
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const loading = ref(true)
|
||||
const list = ref<ProWorkRecordLogVO[]>([])
|
||||
const total = ref(0)
|
||||
const exportLoading = ref(false)
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref<ProWorkRecordLogVO[]>([]) // 列表的数据
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
|
|
@ -188,43 +124,7 @@ const queryParams = reactive({
|
|||
type: undefined,
|
||||
createTime: undefined
|
||||
})
|
||||
const queryFormRef = ref()
|
||||
|
||||
// ========== 我的工作站 ==========
|
||||
const myWorkstation = ref<ProWorkRecordLogVO | null>(null)
|
||||
const clockInPopoverVisible = ref(false)
|
||||
const selectedWorkstationId = ref<number>()
|
||||
|
||||
/** 查询当前用户工作站 */
|
||||
const loadMyWorkstation = async () => {
|
||||
myWorkstation.value = await ProWorkRecordApi.getMyWorkRecord()
|
||||
}
|
||||
|
||||
/** 上线 */
|
||||
const handleClockIn = async () => {
|
||||
if (!selectedWorkstationId.value) return
|
||||
try {
|
||||
await ProWorkRecordApi.clockInWorkRecord(selectedWorkstationId.value)
|
||||
message.success('上线成功')
|
||||
clockInPopoverVisible.value = false
|
||||
selectedWorkstationId.value = undefined
|
||||
await loadMyWorkstation()
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 下线 */
|
||||
const handleClockOut = async () => {
|
||||
try {
|
||||
await message.confirm('确认下线当前工作站?')
|
||||
await ProWorkRecordApi.clockOutWorkRecord()
|
||||
message.success('下线成功')
|
||||
await loadMyWorkstation()
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// ========== 列表查询 ==========
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
|
|
@ -246,7 +146,7 @@ const handleQuery = () => {
|
|||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
queryFormRef.value?.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
|
|
@ -264,8 +164,5 @@ const handleExport = async () => {
|
|||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await loadMyWorkstation()
|
||||
await getList()
|
||||
})
|
||||
onMounted(() => getList())
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -222,6 +222,12 @@ export const MesProAndonLevelEnum = {
|
|||
LEVEL3: 3 // 三级
|
||||
}
|
||||
|
||||
/** MES 上下工操作类型枚举 */
|
||||
export const MesProWorkRecordTypeEnum = {
|
||||
CLOCK_IN: 1, // 上工
|
||||
CLOCK_OUT: 2 // 下工
|
||||
}
|
||||
|
||||
/** MES 生产报工类型枚举 */
|
||||
export const MesProFeedbackTypeEnum = {
|
||||
SELF: 1, // 自行报工
|
||||
|
|
|
|||
Loading…
Reference in New Issue