| | |
| | | <TaskControlModal v-model="showTaskControlModal" :task="task" @produce-start="onProduceStart"></TaskControlModal> |
| | | <ReportProductionModal |
| | | v-model="showReportModal" |
| | | :amount="plcInfo?.finishNumber ?? 0" |
| | | @close="showReportModal = false" |
| | | @submit="showReportModal = false" |
| | | @submit="onReportProduction" |
| | | ></ReportProductionModal> |
| | | </template> |
| | | <script setup lang="ts"> |
| | | import type { Task } from '@/api/task' |
| | | import type { Task, Worker } from '@/api/task' |
| | | import { ref, toRefs } from 'vue' |
| | | import BigButton from '@/views/dashboard/components/BigButton.vue' |
| | | import { useDateFormat } from '@vueuse/core' |
| | | import TaskControlModal from '@/views/dashboard/components/TaskControlModal.vue' |
| | | import { CircleCloseFilled } from '@element-plus/icons-vue' |
| | | import { finishTask } from '@/api' |
| | | import { apiReportWork, finishTask } from '@/api' |
| | | import { ElMessage } from 'element-plus' |
| | | import ReportProductionModal from '@/views/dashboard/components/ReportProductionModal.vue' |
| | | import { usePLCStore } from '@/stores/plc' |
| | | import { storeToRefs } from 'pinia' |
| | | |
| | | const props = defineProps<{ |
| | | task?: Task |
| | | workers: Worker[] |
| | | }>() |
| | | const { task } = toRefs(props) |
| | | const { task, workers } = toRefs(props) |
| | | |
| | | const emit = defineEmits<{ |
| | | shouldReload: [task: Task] |
| | |
| | | const time = useDateFormat(timestamp * 1000, 'YYYY-MM-DD HH:mm:ss', { locales: 'zh-cn' }) |
| | | return time.value |
| | | } |
| | | |
| | | const plcStore = usePLCStore() |
| | | const { plcInfo } = storeToRefs(plcStore) |
| | | // 报工 |
| | | const showReportModal = ref(false) |
| | | function openReportModal() { |
| | | showReportModal.value = true |
| | | } |
| | | |
| | | /** |
| | | * 上报加工数 |
| | | * @param amount 加工数 |
| | | */ |
| | | function onReportProduction(amount: number) { |
| | | if (!task?.value) { |
| | | return |
| | | } |
| | | apiReportWork({ |
| | | procedureId: task.value?.Procedure.ID, |
| | | reportAmount: amount, |
| | | workerID: workers.value[0].workerId |
| | | }) |
| | | .then((res) => { |
| | | if (res.code === 200) { |
| | | ElMessage({ |
| | | message: '报工成功', |
| | | type: 'success', |
| | | duration: 2000 |
| | | }) |
| | | showReportModal.value = false |
| | | } else { |
| | | ElMessage({ |
| | | message: '报工失败', |
| | | type: 'error', |
| | | duration: 3000 |
| | | }) |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | console.error(err) |
| | | }) |
| | | } |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | $title-text-color: #9599af; |