From 13f102240d9c0c9d5a133fb093551f2e08d7c55c Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期五, 19 一月 2024 16:47:41 +0800
Subject: [PATCH] ie不支持es6的问题,安装插件,配置
---
src/views/dashboard/components/TaskControl.vue | 96 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 91 insertions(+), 5 deletions(-)
diff --git a/src/views/dashboard/components/TaskControl.vue b/src/views/dashboard/components/TaskControl.vue
index 03c17b4..cb9d2e2 100644
--- a/src/views/dashboard/components/TaskControl.vue
+++ b/src/views/dashboard/components/TaskControl.vue
@@ -47,25 +47,29 @@
<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]
@@ -85,6 +89,20 @@
*/
function finishTaskProduce() {
if (task?.value && task.value?.Procedure?.ID) {
+ //鐐瑰嚮鐨勬椂鍊欎笉鑳芥瘮瀹為檯寮�濮嬫椂闂村ぇ浜�1鍒嗛挓
+ let realStartTime = task.value?.Procedure?.realStartTime
+ if (realStartTime) {
+ realStartTime = realStartTime * 1000
+ let time = Date.now()
+ let differ = Math.abs(time - realStartTime) / 1000
+ if (differ < 60) {
+ ElMessage({
+ message: '宸ュ簭鍒堕�犳椂闂村お鐭紝璇锋鏌ワ紒',
+ type: 'warning'
+ })
+ return true
+ }
+ }
finishTask({ id: task!.value.Procedure.ID }).then(
(res) => {
ElMessage({
@@ -124,10 +142,78 @@
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
+ // 鏈変汉鍛樻墠鍙互鎶ュ伐
+ if (!workers.value || workers.value.length == 0) {
+ ElMessage({
+ message: '娌℃湁浜哄憳淇℃伅涓嶅厑璁告墜鍔ㄦ姤宸ワ紒',
+ type: 'error',
+ duration: 3000
+ })
+ return true
+ }
+ // 浠庡紑濮嬬敓浜у埌鎶ュ伐鐨勭偣鍑绘椂闂翠笉鑳藉皬浜�1鍒嗛挓
+ if (task?.value && task.value?.Procedure?.realStartTime) {
+ let realStartTime = task.value?.Procedure?.realStartTime
+ if (realStartTime) {
+ realStartTime = realStartTime * 1000
+ let time = Date.now()
+ let differ = Math.abs(time - realStartTime) / 1000
+ if (differ < 60) {
+ ElMessage({
+ message: '宸ュ簭鍒堕�犳椂闂村お鐭紝璇锋鏌ワ紒',
+ type: 'warning'
+ })
+ return true
+ }
+ }
+ }
+
+ if (workers.value[0].workerId) {
+ showReportModal.value = true
+ }
+}
+
+/**
+ * 涓婃姤鍔犲伐鏁�
+ * @param amount 鍔犲伐鏁�
+ */
+function onReportProduction(amount: number) {
+ if (!task?.value) {
+ return
+ }
+ // 鏈変汉鍛樻墠鍙互鎶ュ伐
+ if (workers.value[0].workerId) {
+ 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">
--
Gitblit v1.8.0