|
@@ -0,0 +1,784 @@
|
|
|
+<template>
|
|
|
+ <!-- 添加或修改项目信息对话框 -->
|
|
|
+ <el-drawer
|
|
|
+ v-model="visible"
|
|
|
+ size="80%"
|
|
|
+ direction="rtl"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ >
|
|
|
+ <div class="page-container form-container">
|
|
|
+ <div class="form-btns-container">
|
|
|
+ <span class="title-label"
|
|
|
+ ><el-icon>
|
|
|
+ <Document />
|
|
|
+ </el-icon>
|
|
|
+ 报工详情</span
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-if="editStatus"
|
|
|
+ type="primary"
|
|
|
+ icon="Check"
|
|
|
+ style="margin-right: 10px"
|
|
|
+ :disabled="form.status > 3 || !currentDept"
|
|
|
+ @click="handleSave"
|
|
|
+ >保 存
|
|
|
+ </el-button>
|
|
|
+ <el-button v-if="editStatus" icon="Close" @click="handleCancel"
|
|
|
+ >取 消
|
|
|
+ </el-button>
|
|
|
+ <el-button v-else type="primary" icon="Check" @click="handleCancel"
|
|
|
+ >确定
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <!-- 主表 -->
|
|
|
+ <el-form
|
|
|
+ ref="dayworkItemRef"
|
|
|
+ class="master-container"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ :show-message="true"
|
|
|
+ >
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="7">
|
|
|
+ <el-form-item label="开始时间:" prop="startTime">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="form.startTime"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ type="datetime"
|
|
|
+ value-format="YYYY-MM-DD HH:mm:ss "
|
|
|
+ :clearable="false"
|
|
|
+ :editable="false"
|
|
|
+ placeholder="请选择开始时间"
|
|
|
+ @change="handleTotalTime"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="9">
|
|
|
+ <el-form-item
|
|
|
+ label="工序名称:"
|
|
|
+ prop="processId"
|
|
|
+ label-width="90px"
|
|
|
+ >
|
|
|
+ <el-select-v2
|
|
|
+ v-model="form.processId"
|
|
|
+ clearable
|
|
|
+ :disabled="true"
|
|
|
+ :options="processList"
|
|
|
+ placeholder="请选择工序"
|
|
|
+ style="width: 220px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="生产状态:" prop="status" align="center">
|
|
|
+ <el-select
|
|
|
+ v-model="form.status"
|
|
|
+ placeholder="请选择生产状态"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ style="width: 220px"
|
|
|
+ @change="handleChangeStatus"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="dict in dynamicOptions"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="7">
|
|
|
+ <el-form-item label="结束时间:" prop="endTime">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="form.endTime"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ type="datetime"
|
|
|
+ value-format="YYYY-MM-DD HH:mm:ss "
|
|
|
+ :editable="false"
|
|
|
+ :clearable="false"
|
|
|
+ placeholder="请选择结束时间"
|
|
|
+ @change="handleTotalTime"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="9">
|
|
|
+ <el-form-item label="操作者:" prop="nickName" label-width="82px">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="form.nickName"
|
|
|
+ placeholder="请输入操作者"
|
|
|
+ :disabled="true"
|
|
|
+ :clearable="true"
|
|
|
+ style="width: 220px; margin-left: 8px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="投产量:" prop="prodNum" label-width="82px">
|
|
|
+ <el-input-number
|
|
|
+ v-model.trim="form.prodNum"
|
|
|
+ :precision="0"
|
|
|
+ :disabled="true"
|
|
|
+ controls-position="right"
|
|
|
+ style="width: 220px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="7">
|
|
|
+ <el-form-item
|
|
|
+ label="总工时:"
|
|
|
+ prop="workingHoursTime"
|
|
|
+ label-width="82px"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model.trim="workingHoursTime"
|
|
|
+ :disabled="true"
|
|
|
+ style="width: 220px; margin-left: 0px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="9">
|
|
|
+ <el-form-item
|
|
|
+ label="合格数:"
|
|
|
+ prop="qualifiedNum"
|
|
|
+ label-width="90px"
|
|
|
+ style="padding-right: 0px"
|
|
|
+ >
|
|
|
+ <el-input-number
|
|
|
+ v-model.trim="form.qualifiedNum"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ :precision="0"
|
|
|
+ controls-position="right"
|
|
|
+ style="width: 220px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item
|
|
|
+ label="设备:"
|
|
|
+ prop="equipmentDetailId"
|
|
|
+ label-width="82px"
|
|
|
+ >
|
|
|
+ <el-select-v2
|
|
|
+ v-model="form.equipmentDetailId"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ :options="equipmentList"
|
|
|
+ placeholder="请选择设备"
|
|
|
+ style="width: 220px"
|
|
|
+ >
|
|
|
+ </el-select-v2>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <!-- 搜索区域 -->
|
|
|
+ <el-form class="list-search-container" :inline="true">
|
|
|
+ <el-form-item class="section-title" label="废品信息" />
|
|
|
+ <el-form-item>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="Plus"
|
|
|
+ v-if="editStatus && currentDept"
|
|
|
+ @click="handleAddReject"
|
|
|
+ >新增
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <!-- 列表区 -->
|
|
|
+ <div class="el-table-container">
|
|
|
+ <el-table
|
|
|
+ ref="dayworkItemRejectTable"
|
|
|
+ v-loading="loading"
|
|
|
+ row-key="id"
|
|
|
+ :data="form.groupRejectList"
|
|
|
+ height="100%"
|
|
|
+ >
|
|
|
+ <el-table-column type="index" label="行号" width="60" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.$index + 1 }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="type"
|
|
|
+ label="分选检查类型"
|
|
|
+ align="center"
|
|
|
+ width="300px"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.type"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ placeholder="请选择分选检查类型"
|
|
|
+ @change="(arg) => handleChangeType(scope.row, arg)"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="cause in sort_standard_type"
|
|
|
+ :key="cause.value"
|
|
|
+ :label="cause.label"
|
|
|
+ :value="cause.value"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="sortStandard"
|
|
|
+ label="分选检查标准"
|
|
|
+ align="center"
|
|
|
+ width="300px"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.sortStandard"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ placeholder="请选择分选检查标准"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="cause in scope.row.standardList"
|
|
|
+ :key="cause.value"
|
|
|
+ :label="cause.label"
|
|
|
+ :value="cause.value"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="reason"
|
|
|
+ label="检查结果"
|
|
|
+ align="center"
|
|
|
+ width="300px"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="scope.row.reason"
|
|
|
+ placeholder="请输入检查结果"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ :clearable="true"
|
|
|
+ style="width: 220px; margin-left: 8px"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="废品数量"
|
|
|
+ width="160px"
|
|
|
+ prop="rejectNum"
|
|
|
+ align="center"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input-number
|
|
|
+ v-model.trim="scope.row.rejectNum"
|
|
|
+ placeholder="废品数量"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ :precision="0"
|
|
|
+ :min="0"
|
|
|
+ controls-position="right"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column fixed="right" label="操作" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="danger"
|
|
|
+ icon="Delete"
|
|
|
+ :disabled="!editStatus || !currentDept"
|
|
|
+ @click="handleDeleteReject(scope.row)"
|
|
|
+ >删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-drawer>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import {
|
|
|
+ getProcessList,
|
|
|
+ getDayworkItemRejectList,
|
|
|
+ updateDayworkItemInfo,
|
|
|
+ getEquipmentInfo,
|
|
|
+ getIsFirstOrder,
|
|
|
+} from "@/api/business/daywork.js";
|
|
|
+import { listInspectionInstruction } from "@/api/business/productInspectionInstruction.js";
|
|
|
+import { ref } from "vue";
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+const emit = defineEmits(["handleSaveSuccess"]);
|
|
|
+/** 字典 */
|
|
|
+const { daywork_status_edit } = proxy.useDict("daywork_status_edit");
|
|
|
+const { daywork_status_first } = proxy.useDict("daywork_status_first");
|
|
|
+const { daywork_status_second } = proxy.useDict("daywork_status_second");
|
|
|
+const { sort_standard_type } = proxy.useDict("sort_standard_type");
|
|
|
+const detailInfo = ref({});
|
|
|
+const loading = ref(false);
|
|
|
+const processList = ref([]);
|
|
|
+const lotId = ref(null);
|
|
|
+const equipmentList = ref([]);
|
|
|
+const visible = ref(false);
|
|
|
+const isFirst = ref(true); //是否为首序
|
|
|
+const editStatus = ref(true);
|
|
|
+const currentDept = ref(false);
|
|
|
+const rejectAmount = ref(0);
|
|
|
+const dynamicOptions = ref([]);
|
|
|
+const workingHoursTime = ref("");
|
|
|
+const maxQuailifiedNum = ref(0);
|
|
|
+const sortProductInspection = ref([])
|
|
|
+const detailsRow = {
|
|
|
+ id: null,
|
|
|
+ type:null,
|
|
|
+ rejectNum: "",
|
|
|
+ checkResult: "",
|
|
|
+ checkStandard:""
|
|
|
+};
|
|
|
+// const validateprodNum = (rule, value, callback) => {
|
|
|
+// if (value <= 0) {
|
|
|
+// callback(new Error("投产量应大于0"));
|
|
|
+// } else {
|
|
|
+// callback();
|
|
|
+// }
|
|
|
+// };
|
|
|
+const validateWorkingHours = (rule, value, callback) => {
|
|
|
+ if (form.value.workHoursTimestamp < 0) {
|
|
|
+ callback(new Error("结束时间应晚于开始时间"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+};
|
|
|
+const validateQualifiedNum = (rule, value, callback) => {
|
|
|
+ const max = maxQuailifiedNum.value;
|
|
|
+ if (value < 0) {
|
|
|
+ callback(new Error("合格数量应大于/等于0"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+
|
|
|
+ // else if (
|
|
|
+ // value > max &&
|
|
|
+ // detailInfo.value.firstProcessId != form.value.processId
|
|
|
+ // ) {
|
|
|
+ // callback(new Error("合格数量不应大于投产量的103%,即" + max));
|
|
|
+ // }
|
|
|
+};
|
|
|
+const validateEndTime = (rule, value, callback) => {
|
|
|
+ if (form.value.status > 1) {
|
|
|
+ if (form.value.endTime == null) {
|
|
|
+ callback(new Error("结束时间不能为空"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (form.value.endTime != null) {
|
|
|
+ callback(new Error("该状态结束时间应为空"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+const validateStartTime = (rule, value, callback) => {
|
|
|
+ if (form.value.status > 1) {
|
|
|
+ if (form.value.startTime == null) {
|
|
|
+ callback(new Error("开始时间不能为空"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+};
|
|
|
+const data = reactive({
|
|
|
+ form: {
|
|
|
+ groupRejectList: [],
|
|
|
+ nickName: "",
|
|
|
+ processId: "",
|
|
|
+ processAlias: "",
|
|
|
+ prodNum: 0,
|
|
|
+ qualifiedNum: 0,
|
|
|
+ rejectNum: 0,
|
|
|
+ startTime: "",
|
|
|
+ endTime: "",
|
|
|
+ workingHours: 0,
|
|
|
+ status: "",
|
|
|
+ workHoursTimestamp: 0,
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ // prodNum: [
|
|
|
+ // { required: true, message: "投产量不能为空", trigger: "blur" },
|
|
|
+ // { validator: validateprodNum, trigger: "blur" },
|
|
|
+ // ],
|
|
|
+ startTime: [{ validator: validateStartTime, trigger: "blur" }],
|
|
|
+ endTime: [{ validator: validateEndTime, trigger: "blur" }],
|
|
|
+ workingHoursTime: [{ validator: validateWorkingHours, trigger: "change" }],
|
|
|
+ qualifiedNum: [
|
|
|
+ { required: true, message: "合格数量不能为空", trigger: "blur" },
|
|
|
+ { validator: validateQualifiedNum, trigger: "blur" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+const { form, rules } = toRefs(data);
|
|
|
+
|
|
|
+/*********************** 方法区 ****************************/
|
|
|
+/** 打开抽屉 */
|
|
|
+const open = (row) => {
|
|
|
+ reset();
|
|
|
+ loading.value = true;
|
|
|
+ if (row.id) {
|
|
|
+ //查询是否为首序
|
|
|
+ getIsFirstOrder(row.dayworkId).then((res) => {
|
|
|
+ isFirst.value = res.data.isFirstOrder;
|
|
|
+ });
|
|
|
+ lotId.value = row.lotId;
|
|
|
+ //页面操作是编辑还是删除
|
|
|
+ console.log("row", row);
|
|
|
+ editStatus.value = row.editStatus;
|
|
|
+ detailInfo.value = proxy.deepClone(row);
|
|
|
+ console.log(detailInfo.value);
|
|
|
+ //是否是当前工序
|
|
|
+ currentDept.value = row.currentDept;
|
|
|
+ form.value.id = row.id;
|
|
|
+ form.value.startTime = row.startTime;
|
|
|
+ form.value.endTime = row.endTime;
|
|
|
+ workingHoursTime.value = row.workingHours;
|
|
|
+ form.value.nickName = row.nickName;
|
|
|
+ form.value.status = row.status;
|
|
|
+ form.value.processId = row.processId;
|
|
|
+ form.value.productionPlanDetailId = row.productionPlanDetailId;
|
|
|
+ if (form.value.status == 0 || form.value.status == 1) {
|
|
|
+ dynamicOptions.value = daywork_status_first.value;
|
|
|
+ } else if (form.value.status == 2 || form.value.status == 3) {
|
|
|
+ dynamicOptions.value = daywork_status_edit.value;
|
|
|
+ } else {
|
|
|
+ dynamicOptions.value = daywork_status_second.value;
|
|
|
+ }
|
|
|
+ form.value.qualifiedNum = row.qualifiedNum;
|
|
|
+ //合格数最大能修改数值
|
|
|
+ maxQuailifiedNum.value = row.maxQuailifiedNum;
|
|
|
+ form.value.workHoursTimestamp = 0;
|
|
|
+ form.value.prodNum = row.prodNum;
|
|
|
+ // technologicalProcessId: row.technologicalProcessId
|
|
|
+ getProcessList({
|
|
|
+ technologicalProcessId: row.technologicalProcessId,
|
|
|
+ isAmend: row.isAmend,
|
|
|
+ isWasteRecycling: row.isWasteRecycling,
|
|
|
+ lotId: row.lotId,
|
|
|
+ }).then((res) => {
|
|
|
+ processList.value = res.data;
|
|
|
+ for (let i = 0; i < processList.value.length; i++) {
|
|
|
+ if (processList.value[i].label === row.processAlias.trim()) {
|
|
|
+ form.value.processId = processList.value[i].value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //查询该工序的分选标准
|
|
|
+ listInspectionInstruction({technologicalProcessDetailId:detailInfo.value.technologicalProcessDetailId}).then(res=>{
|
|
|
+ if(res.code == 200){
|
|
|
+ sortProductInspection.value = res.rows;
|
|
|
+ //查询废品原因
|
|
|
+ handleQueryReject()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //查询能够选择的设备信息
|
|
|
+ let productionPlanDetailId = parseInt(row.productionPlanDetailId);
|
|
|
+ getEquipmentInfo({
|
|
|
+ commonCode: row.userName,
|
|
|
+ productionPlanDetailId: productionPlanDetailId,
|
|
|
+ dayworkItemId: row.id,
|
|
|
+ deptId: row.deptId,
|
|
|
+ }).then((equipmentRef) => {
|
|
|
+ if (equipmentRef.code == 200) {
|
|
|
+ if (equipmentRef.rows.length > 0) {
|
|
|
+ equipmentList.value = equipmentRef.rows;
|
|
|
+ for (let i = 0; i < equipmentList.value.length; i++) {
|
|
|
+ if (row.equipmentDetailCode == equipmentList.value[i].label) {
|
|
|
+ form.value.equipmentDetailId = equipmentList.value[i].value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ equipmentList.value = [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ loading.value = false;
|
|
|
+ visible.value = true;
|
|
|
+ }
|
|
|
+};
|
|
|
+/**
|
|
|
+ * 对话框关闭 事件
|
|
|
+ */
|
|
|
+function close() {
|
|
|
+ reset();
|
|
|
+ visible.value = false;
|
|
|
+}
|
|
|
+
|
|
|
+/** 表单重置 */
|
|
|
+function reset() {
|
|
|
+ form.value = {
|
|
|
+ groupRejectList: [],
|
|
|
+ nickName: "",
|
|
|
+ processId: null,
|
|
|
+ processAlias: "",
|
|
|
+ prodNum: 0,
|
|
|
+ qualifiedNum: 0,
|
|
|
+ rejectNum: 0,
|
|
|
+ startTime: "",
|
|
|
+ endTime: "",
|
|
|
+ workingHours: 0,
|
|
|
+ };
|
|
|
+ proxy.resetForm("dayworkItemRef");
|
|
|
+}
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+const handleSave = () => {
|
|
|
+ proxy.$refs["dayworkItemRef"].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ console.log(form.value.groupRejectList)
|
|
|
+ rejectAmount.value = 0;
|
|
|
+ var reasonList = [];
|
|
|
+ var flag = true;
|
|
|
+ //判断工序是否是尾序
|
|
|
+ var lastProcess = false;
|
|
|
+ if (
|
|
|
+ form.value.processId ==
|
|
|
+ processList.value[processList.value.length - 1].value
|
|
|
+ ) {
|
|
|
+ lastProcess = true;
|
|
|
+ }
|
|
|
+ if (lastProcess) {
|
|
|
+ if (form.value.status > 3) {
|
|
|
+ flag = false;
|
|
|
+ proxy.$modal.msgError("尾序不能选择该状态");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //判断这个item是否能选择工序已完成
|
|
|
+ if (detailInfo.value.processFinish && form.value.status == 3) {
|
|
|
+ flag = false;
|
|
|
+ proxy.$modal.msgError("该道序状态已有工序已完成");
|
|
|
+ }
|
|
|
+ for (let i = 0; i < form.value.groupRejectList.length; i++) {
|
|
|
+ rejectAmount.value += form.value.groupRejectList[i].rejectNum;
|
|
|
+ if (form.value.groupRejectList[i].rejectNum <= 0) {
|
|
|
+ flag = false;
|
|
|
+ proxy.$modal.msgError("第" + (i + 1) + "废品数应大于0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!form.value.groupRejectList[i].sortStandard) {
|
|
|
+ flag = false;
|
|
|
+ proxy.$modal.msgError("第" + (i + 1) + "行分选检查标准不能为空");
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (reasonList.indexOf(form.value.groupRejectList[i].sortStandard) >= 0) {
|
|
|
+ flag = false;
|
|
|
+ proxy.$modal.msgError(
|
|
|
+ "第" +
|
|
|
+ (i + 1) +
|
|
|
+ "行分选检查标准与" +
|
|
|
+ (reasonList.indexOf(form.value.groupRejectList[i].sortStandard) + 1) +
|
|
|
+ "行相同"
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ reasonList.push(form.value.groupRejectList[i].sortStandard);
|
|
|
+ }
|
|
|
+ if (rejectAmount.value > form.value.prodNum) {
|
|
|
+ flag = false;
|
|
|
+ proxy.$modal.msgError(
|
|
|
+ "废品总数不能超过投产数,当前废品总数为" + rejectAmount.value
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ form.value.workingHours = form.value.workHoursTimestamp;
|
|
|
+ //设备id和code
|
|
|
+ for (let i = 0; i < equipmentList.value.length; i++) {
|
|
|
+ if (form.value.equipmentDetailId == equipmentList.value[i].value) {
|
|
|
+ form.value.equipmentDetailCode = equipmentList.value[i].label;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ if(form.value.groupRejectList.length > 0){
|
|
|
+ form.value.groupRejectList.forEach(item => {
|
|
|
+ item.deptId = detailInfo.value.deptId
|
|
|
+ item.inspectionInstructionId = item.sortStandard
|
|
|
+ let checkStandard = item.standardList.filter(info => info.value == item.sortStandard)[0]
|
|
|
+ console.log(checkStandard)
|
|
|
+ item.checkStandard = checkStandard.label
|
|
|
+ item.processId = detailInfo.value.processId
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log("rejectList",form.value.groupRejectList)
|
|
|
+ form.value.dayworkId = detailInfo.value.dayworkId;
|
|
|
+ //同工序的所有合格数
|
|
|
+ form.value.temporaryProcessQualifiedNum =
|
|
|
+ detailInfo.value.totalQuailifiedNum + form.value.qualifiedNum;
|
|
|
+ //如果状态从工序已完成改成结束报工,传给后端一个标记,如果为true,则删除中间表对应的数据
|
|
|
+ if (detailInfo.value.status == 3 && form.value.status == 2) {
|
|
|
+ form.value.dayworkId = detailInfo.value.dayworkId;
|
|
|
+ form.value.flag = true;
|
|
|
+ }
|
|
|
+ let data = form.value;
|
|
|
+ data.lotId = lotId.value;
|
|
|
+
|
|
|
+ const max = maxQuailifiedNum.value;
|
|
|
+ let sunm =
|
|
|
+ detailInfo.value.totalQuailifiedNum + form.value.qualifiedNum; //计算总合格数
|
|
|
+ let num = sunm - form.value.prodNum; //多出来的数量
|
|
|
+ let percent = (sunm / form.value.prodNum) * 100; //合格率
|
|
|
+ percent = Math.ceil(percent * 100) / 100; //只入不舍
|
|
|
+ //判断是否超过投产量
|
|
|
+ if (sunm > form.value.prodNum) {
|
|
|
+ //判断是否为首序
|
|
|
+ if (isFirst.value) {
|
|
|
+ // 弹出确认对话框
|
|
|
+ proxy.$modal
|
|
|
+ .confirm(
|
|
|
+ "合格数为投产量" +
|
|
|
+ percent +
|
|
|
+ "%,超出投产量" +
|
|
|
+ num +
|
|
|
+ "。 是否继续保存!"
|
|
|
+ )
|
|
|
+ .then(function () {
|
|
|
+ updateDayworkItem();
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ return;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (form.value.qualifiedNum <= max) {
|
|
|
+ updateDayworkItem();
|
|
|
+ } else {
|
|
|
+ proxy.$modal.msgError(
|
|
|
+ "合格数不能超过投产量的103%,最大合格数为" + max
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ updateDayworkItem();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+//页面提交方法
|
|
|
+function updateDayworkItem() {
|
|
|
+ updateDayworkItemInfo(form.value).then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ proxy.$modal.msgSuccess("保存成功!");
|
|
|
+ visible.value = false;
|
|
|
+ emit("handleSaveSuccess");
|
|
|
+ } else {
|
|
|
+ proxy.$modal.msgError("保存失败!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+//删除废弃信息
|
|
|
+function handleDeleteReject(row) {
|
|
|
+ form.value.groupRejectList.splice(form.value.groupRejectList.indexOf(row), 1);
|
|
|
+}
|
|
|
+//查询废品信息
|
|
|
+function handleQueryReject() {
|
|
|
+ getDayworkItemRejectList({ dayworkItemId: detailInfo.value.id }).then(
|
|
|
+ (response) => {
|
|
|
+ if (response.code == 200) {
|
|
|
+ for (let i = 0; i < response.data.length; i++) {
|
|
|
+ response.data[i].rejectNum = parseInt(response.data[i].rejectNum);
|
|
|
+ response.data[i].type = response.data[i].type+'';
|
|
|
+ if(sortProductInspection.value.length > 0) {
|
|
|
+ response.data[i].standardList = sortProductInspection.value.filter(item =>response.data[i].type == item.type).map(item => {
|
|
|
+ return { value :item.inspectionInstructionId , label : item.standard }
|
|
|
+ })
|
|
|
+ response.data[i].sortStandard = response.data[i].standardList.filter(item => response.data[i].checkStandard == item.label)[0].value
|
|
|
+ console.log( response.data[i].sortStandard)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ form.value.groupRejectList = response.data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+//添加废弃信息
|
|
|
+function handleAddReject() {
|
|
|
+ const newDetail = JSON.parse(JSON.stringify(detailsRow));
|
|
|
+ newDetail.rejectNum = 0;
|
|
|
+ newDetail.dayworkId = detailInfo.value.dayworkId;
|
|
|
+ newDetail.dayworkItemId = detailInfo.value.id;
|
|
|
+ newDetail.lotId = detailInfo.value.lotId;
|
|
|
+ form.value.groupRejectList.push(newDetail);
|
|
|
+}
|
|
|
+
|
|
|
+//计算总工时
|
|
|
+function handleTotalTime() {
|
|
|
+ if (form.value.endTime == null) {
|
|
|
+ workingHoursTime.value = "0小时0分钟0秒";
|
|
|
+ form.value.workHoursTimestamp = 0;
|
|
|
+ } else {
|
|
|
+ form.value.workHoursTimestamp =
|
|
|
+ new Date(form.value.endTime) - new Date(form.value.startTime);
|
|
|
+ let seconds = Math.floor((form.value.workHoursTimestamp / 1000) % 60);
|
|
|
+ let minutes = Math.floor(
|
|
|
+ (form.value.workHoursTimestamp / (1000 * 60)) % 60
|
|
|
+ );
|
|
|
+ let hours = Math.floor(form.value.workHoursTimestamp / (1000 * 60 * 60));
|
|
|
+ let time = `${hours}小时${minutes}分钟${seconds}秒`;
|
|
|
+ workingHoursTime.value = time;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//当生产状态为未开始、生产中时,结束时间为空,合格数为0,废弃信息为空
|
|
|
+function handleChangeStatus() {
|
|
|
+ if (form.value.status == 1) {
|
|
|
+ form.value.endTime = null;
|
|
|
+ workingHoursTime.value = "0小时0分钟0秒";
|
|
|
+ form.value.workingHours = 0;
|
|
|
+ form.value.groupRejectList = [];
|
|
|
+ form.value.qualifiedNum = 0;
|
|
|
+ }
|
|
|
+ if (form.value.status == 0) {
|
|
|
+ form.value.endTime = null;
|
|
|
+ form.value.startTime = null;
|
|
|
+ workingHoursTime.value = "0小时0分钟0秒";
|
|
|
+ form.value.workingHours = 0;
|
|
|
+ form.value.groupRejectList = [];
|
|
|
+ form.value.qualifiedNum = 0;
|
|
|
+ form.value.equipmentDetailId = null;
|
|
|
+ form.value.equipmentDetailCode = null;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function handleChangeType(row, arg) {
|
|
|
+ row.checkStandard = null
|
|
|
+ if(sortProductInspection.value.length > 0) {
|
|
|
+ row.standardList = sortProductInspection.value.filter(item =>row.type == item.type).map(item => {
|
|
|
+ return { value :item.inspectionInstructionId , label : item.standard }
|
|
|
+ })
|
|
|
+ row.sortStandard = row.standardList.filter(item => row.checkStandard == item.label)[0]
|
|
|
+}
|
|
|
+}
|
|
|
+
|
|
|
+/** 取消按钮 */
|
|
|
+const handleCancel = () => {
|
|
|
+ visible.value = false;
|
|
|
+ reset();
|
|
|
+};
|
|
|
+
|
|
|
+/** 暴露给父组件的方法 */
|
|
|
+defineExpose({
|
|
|
+ open,
|
|
|
+});
|
|
|
+</script>
|
|
|
+<style scoped>
|
|
|
+.el-select-v2__placeholder {
|
|
|
+ display: flex !important;
|
|
|
+}
|
|
|
+</style>
|