ezhizao_zx 6 сар өмнө
parent
commit
cae5fe2409

+ 22 - 0
src/api/business/daywork.js

@@ -150,6 +150,16 @@ export function getDeptList(query) {
 	})
 }
 
+/**
+ * 获取用户工段
+ */
+export function getDeptListForUser() {
+	return request({
+		url: baseUrl + '/business/productionDaywork/getDeptListForUser',
+		method: 'get'
+	})
+}
+
 /** 查询批次信息 */
 export function getDayworkItemProcess(id) {
 	return request({
@@ -324,6 +334,18 @@ export function updateDayworkItemInfoForNum(data) {
 		data: data
 	})
 }
+/**
+ * 修改生产批次报工列表中周转报工的信息
+ * @param {*} data 
+ */
+export function updateDayworkItemInfoForTurnover(data) {
+	return request({
+		url: baseUrl + '/business/productionDaywork/updateDayworkItemInfoForTurnover',
+		method: 'post',
+		data: data
+	})
+}
+
 export function updateDayworkItemInfoMax(data) {
 	return request({
 		url: baseUrl + '/business/productionDaywork/updateDayworkItemInfoMax',

+ 30 - 18
src/views/business/daywork/index.vue

@@ -45,8 +45,8 @@
             <el-table-column label="下达日期" prop="createTime" width="100" align="center">
               <template #default="scope">
                 <span>{{
-        proxy.moment(scope.row.createTime).format("YYYY-MM-DD")
-      }}</span>
+                  proxy.moment(scope.row.createTime).format("YYYY-MM-DD")
+                }}</span>
               </template>
             </el-table-column>
             <el-table-column label="报工总时长" prop="totalWorkingHours" width="150" align="center" />
@@ -86,17 +86,14 @@
             <el-table-column fixed="right" label="操作" align="center" width="200px">
               <template #default="scope">
                 <el-button v-show="scope.row.deptProcessStatus &&
-        (scope.row.status == 2 || scope.row.status == 3) &&
-        scope.row.id == latestProcessId && scope.row.deptId == latestDeptId && !(lastStatus == 4 || lastStatus == 5 || lastStatus == 7)
-        " link type="warning" icon="Edit" @click="handleUpdateDayworkItem(scope.row)">编辑
+                  (scope.row.status == 2 || scope.row.status == 3) &&
+                  scope.row.id == latestProcessId && scope.row.deptId == latestDeptId && !(lastStatus == 4 || lastStatus == 5 || lastStatus == 7)
+                  " link type="warning" icon="Edit" @click="handleUpdateDayworkItem(scope.row)">编辑
                 </el-button>
                 <el-button link type="primary" icon="View" @click="handleCheckDayworkItem(scope.row)">查看
                 </el-button>
-                <el-button v-show="scope.row.deptProcessStatus &&
-        (scope.row.status == 2 || scope.row.status == 3) &&
-        scope.row.id == latestProcessId && scope.row.deptId == latestDeptId && !(lastStatus == 4 || lastStatus == 5 || lastStatus == 7) &&
-        (scope.row.processStepNumber != lastProcessStepNumber) && currentDaywork.status != 2
-        " v-hasPermi="['business:daywork:remove']" link type="danger" icon="Delete"
+                <el-button v-show="showItemDel(scope.row)
+                  " v-hasPermi="['business:daywork:remove']" link type="danger" icon="Delete"
                   @click="handleDeletedItem(scope.row.id)">删除
                 </el-button>
               </template>
@@ -151,14 +148,15 @@ const lastStatus = ref(null)
 const latestProcessId = ref(null);
 const latestDeptId = ref(null)
 const lastProcessStepNumber = ref(null)
+const latestItem = ref(null)
 const deptProcessList = ref([]);
 /**工序 */
 const processList = ref([]);
 /** 查询对象 */
 const queryDayworkParams = ref({
   productDescription: null,
-  equipmentDetailCode:null,
-  productionPlanNo:null,
+  equipmentDetailCode: null,
+  productionPlanNo: null,
   deptId: "",
   lotCode: "",
   pageNum: 1,
@@ -181,10 +179,10 @@ function getList() {
     deptList.value = response.data.rows;
     loading.value = false;
     if (deptList.value.length > 0) {
-      if(dayworkStore().deptId != null){
+      if (dayworkStore().deptId != null) {
         queryDayworkParams.value.deptId = dayworkStore().deptId
-      }else{
-         queryDayworkParams.value.deptId = deptList.value[0].value;
+      } else {
+        queryDayworkParams.value.deptId = deptList.value[0].value;
       }
       getDayworks();
     } else {
@@ -204,13 +202,13 @@ function handleDeptChange() {
 /** 查询计划明细 */
 function getDayworks() {
   dayworkLoading.value = true;
-  if(dayworkStore().productionPlanNo != null) {
+  if (dayworkStore().productionPlanNo != null) {
     queryDayworkParams.value.productionPlanNo = dayworkStore().productionPlanNo
   }
-  if(dayworkStore().productDescription != null) {
+  if (dayworkStore().productDescription != null) {
     queryDayworkParams.value.productDescription = dayworkStore().productDescription
   }
-  if(dayworkStore().equipmentDetailCode != null) {
+  if (dayworkStore().equipmentDetailCode != null) {
     queryDayworkParams.value.equipmentDetailCode = dayworkStore().equipmentDetailCode
   }
   listDaywork(queryDayworkParams.value).then((res) => {
@@ -435,6 +433,7 @@ function getDayworkItems() {
         if (res.others != null && res.others.lastItem != null) {
           latestDeptId.value = res.others.lastItem.deptId
           lastStatus.value = res.others.lastItem.status
+          latestItem.value = res.others.lastItem
         }
         for (var i = 0; i < res.rows.length; i++) {
           let timeStamp = res.rows[i].workingHours;
@@ -481,6 +480,19 @@ function handleQuery() {
   getDayworks();
 }
 
+function showItemDel(row) {
+  // 判断是最新一条且是当前工段加工则可删除
+  if (row.id == latestItem.value.id) {
+    if (row.status >= 4) {
+      // 周转则判断fromDeptId
+      return row.fromDeptId == queryDayworkParams.value.deptId
+    } else {
+      return row.deptId == queryDayworkParams.value.deptId
+    }
+  }
+  return false
+}
+
 onMounted(() => {
   getList();
 });

+ 34 - 1
src/views/business/dayworkUpdate/index.vue

@@ -82,7 +82,8 @@
             </el-table-column>
             <el-table-column fixed="right" label="操作" align="center" width="200px">
               <template #default="scope">
-                <el-button link type="warning" icon="Edit" @click="handleUpdateDayworkItem(scope.row)">编辑
+                <el-button v-if="checkDept(scope.row)" link type="warning" icon="Edit"
+                  @click="handleUpdateDayworkItem(scope.row)">编辑
                 </el-button>
               </template>
             </el-table-column>
@@ -112,6 +113,7 @@ import {
   delDayworkItem
 } from "@/api/business/daywork.js";
 import { listDeptProcess } from "@/api/business/deptProcess";
+import { getDeptListForUser } from "@/api/business/daywork.js";
 import { selectUserPermissionList } from "@/api/system/user.js";
 import router from "@/router";
 import dayworkItemForm from "./form";
@@ -127,6 +129,8 @@ const { daywork_status } = proxy.useDict("daywork_status");
 
 /** 生产批次 */
 const dayworkList = ref([]);
+const deptList = ref([])
+const latestItem = ref(null)
 const dayworkTable = ref(null);
 const currentDaywork = ref({});
 const dayworkLoading = ref(false);
@@ -343,6 +347,7 @@ function handleUpdateDayworkItem(row) {
   } else {
     row.currentDept = false;
   }
+  row.isLatest = latestItem.value.id == row.id
   console.log(row)
   //如果为true,则同工序已有工序已完成
   row.processFinish = processFinish;
@@ -419,6 +424,7 @@ function getDayworkItems() {
         if (res.others != null && res.others.lastItem != null) {
           latestDeptId.value = res.others.lastItem.deptId
           lastStatus.value = res.others.lastItem.status
+          latestItem.value = res.others.lastItem
         }
         for (var i = 0; i < res.rows.length; i++) {
           let timeStamp = res.rows[i].workingHours;
@@ -457,14 +463,41 @@ function getProcess() {
   });
 }
 
+function checkPermi(arg) {
+  const permissions = useUserStore().permissions
+  const all_permission = "*:*:*";
+  const hasPermission = permissions.some(permission => {
+    return all_permission === permission || permission === arg
+  })
+  return hasPermission;
+}
+function checkDept(row) {
+  // 判断是否有权限 business:dayworkUpdate:deptUpdate
+  if (checkPermi('business:dayworkUpdate:deptUpdate')) {
+    // 有权限的情况下判断此人是否是该工段的
+    return deptList.value.some(e => e.value == row.deptId)
+  }
+  return true
+}
+
 /** 搜索按钮操作 */
 function handleQuery() {
   getDayworks();
 }
 
+function getDepts() {
+  getDeptListForUser().then((response) => {
+    console.log(response)
+    deptList.value = response.data.rows;
+    loading.value = false;
+  });
+}
+
 onMounted(() => {
   getList();
 });
+
+getDepts()
 </script>
 <style scoped>
 .el-form--inline .el-form-item {

+ 63 - 104
src/views/business/dayworkUpdate/turnoverForm.vue

@@ -73,42 +73,42 @@
                 controls-position="right" style="width: 220px" />
             </el-form-item>
           </el-col>
-          <el-col :span="8">
+          <!-- <el-col :span="8">
             <el-form-item label="设备:" prop="equipmentDetailId" label-width="82px">
               <el-select-v2 v-model="form.equipmentDetailId" :disabled="true" :options="equipmentList"
                 placeholder="请选择设备" style="width: 220px">
               </el-select-v2>
             </el-form-item>
-          </el-col>
-          <el-col :span="7">
-            <el-form-item label="周转类型" label-width="82px">
-              <el-select v-model="form.turnoverType" :disabled="!editStatus" placeholder="请选择周转类型" style="width: 220px;"
-                @change="turnoverTypeChangeHandler">
+          </el-col> -->
+          <el-col :span="8">
+            <el-form-item label="周转类型" label-width="82px">
+              <el-select v-model="form.turnoverType" :disabled="!editStatus || !isLatest" placeholder="请选择周转类型"
+                style="width: 220px;" @change="turnoverTypeChangeHandler">
                 <el-option v-for="dict in daywork_turnover_type" :key="dict.value" :label="dict.label"
                   :value="dict.value" />
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="9">
-            <el-form-item label="周转工段" label-width="90px">
-              <el-select v-model="form.deptId" :disabled="!editStatus" placeholder="请选择周转工段" style="width: 220px;"
-                @change="deptChangeHandler">
+          <el-col :span="7">
+            <el-form-item label="周转工段:" label-width="82px">
+              <el-select v-model="form.deptId" :disabled="!editStatus || !isLatest" placeholder="请选择周转工段"
+                style="width: 220px;" @change="deptChangeHandler">
                 <el-option v-for="dict in deptList" :key="dict.detpId" :label="dict.deptName" :value="dict.deptId" />
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="8" v-if="form.turnoverType == '1'">
-            <el-form-item label="周转区" label-width="82px">
-              <el-select v-model="placeIds" :disabled="!editStatus" multiple placeholder="请选择周转区" style="width: 220px;"
-                @change="turnoverChangeHandler">
+          <el-col :span="9" v-if="form.turnoverType == '1'">
+            <el-form-item label="周转区:" label-width="90px">
+              <el-select v-model="placeIds" :disabled="!editStatus || !isLatest" multiple placeholder="请选择周转区"
+                style="width: 220px;" @change="turnoverChangeHandler">
                 <el-option v-for="dict in turnoverList" :key="dict.id" :label="dict.code" :value="dict.id" />
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="8" v-else>
-            <el-form-item label="周转区" label-width="82px">
-              <el-select v-model="form.turnoverId" :disabled="!editStatus" placeholder="请选择周转区" style="width: 220px;"
-                @change="workshopTurnoverChangeHandler">
+          <el-col :span="9" v-else>
+            <el-form-item label="周转区:" label-width="90px">
+              <el-select v-model="form.turnoverId" :disabled="!editStatus || !isLatest" placeholder="请选择周转区"
+                style="width: 220px;" @change="workshopTurnoverChangeHandler">
                 <el-option v-for="dict in workShopTurnoverList" :key="dict.id" :label="dict.code" :value="dict.id" />
               </el-select>
             </el-form-item>
@@ -125,7 +125,7 @@ import {
   getProcessList,
   getDayworkItemRejectList,
   getDayworkItemOriginalRejectList,
-  updateDayworkItemInfoForNum,
+  updateDayworkItemInfoForTurnover,
   getEquipmentInfo,
   getIsFirstOrder,
   getAllWorkShop
@@ -146,6 +146,7 @@ const loading = ref(false);
 const processList = ref([]);
 const lotId = ref(null);
 const equipmentList = ref([]);
+const isLatest = ref(false)
 const visible = ref(false);
 const isFirst = ref(true); //是否为首序
 const editStatus = ref(false);
@@ -195,19 +196,20 @@ const validateQualifiedNum = (rule, value, callback) => {
   // }
 };
 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();
-    }
-  }
+  // 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();
+  //   }
+  // }
+  callback()
 };
 const validateStartTime = (rule, value, callback) => {
   if (form.value.status > 1) {
@@ -232,8 +234,9 @@ const getWorkShopInfo = () => {
 const setTurnoverList = () => {
   const fromDept = allDepts.some(e => e.deptId == form.value.fromDeptId) ? allDepts.filter(e => e.deptId == form.value.fromDeptId)[0] : null
   form.value.workshopId = fromDept != null ? fromDept.workshopId : null
+  // console.log(form.value.deptId, allDepts.filter(e => e.deptId == form.value.deptId))
   const targetDept = allDepts.some(e => e.deptId == form.value.deptId) ? allDepts.filter(e => e.deptId == form.value.deptId)[0] : null
-  console.log(form.value.workshopId)
+
   const fromWorkshop = allWorkshop.some(e => e.id == form.value.workshopId) ? allWorkshop.filter(e => e.id == form.value.workshopId)[0] : null
   // 根据form信息放置周转区等数据
   if (form.value.turnoverType == '1') {
@@ -334,6 +337,7 @@ const open = (row) => {
     maxQuailifiedNum.value = row.maxQuailifiedNum;
     form.value.workHoursTimestamp = 0;
     form.value.prodNum = row.prodNum;
+    isLatest.value = row.isLatest
     // technologicalProcessId: row.technologicalProcessId
     getProcessList({
       technologicalProcessId: row.technologicalProcessId,
@@ -359,26 +363,26 @@ const open = (row) => {
       }
     );
     //查询能够选择的设备信息
-    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 = [];
-        }
-      }
-    });
+    // 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;
     getWorkShopInfo()
@@ -431,46 +435,8 @@ const handleSave = () => {
       rejectAmount.value = 0;
       var reasonList = [];
       var flag = true;
-      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].reason) {
-          flag = false;
-          proxy.$modal.msgError("第" + (i + 1) + "行废品原因不能为空");
-
-          return;
-        }
-        if (reasonList.indexOf(form.value.groupRejectList[i].reason) >= 0) {
-          flag = false;
-          proxy.$modal.msgError(
-            "第" +
-            (i + 1) +
-            "行废品原因与" +
-            (reasonList.indexOf(form.value.groupRejectList[i].reason) + 1) +
-            "行相同"
-          );
-          return;
-        }
-        reasonList.push(form.value.groupRejectList[i].reason);
-      }
-      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 => {
@@ -480,19 +446,9 @@ const handleSave = () => {
         }
         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 sunm = form.value.qualifiedNum
         let num = sunm - form.value.prodNum; //多出来的数量
         let percent = (sunm / form.value.prodNum) * 100; //合格率
         percent = Math.ceil(percent * 100) / 100; //只入不舍
@@ -537,7 +493,8 @@ const handleSave = () => {
 
 //页面提交方法
 function updateDayworkItem() {
-  updateDayworkItemInfoForNum(form.value).then((res) => {
+  console.log(form.value)
+  updateDayworkItemInfoForTurnover(form.value).then((res) => {
     if (res.code == 200) {
       proxy.$modal.msgSuccess("保存成功!");
       visible.value = false;
@@ -642,11 +599,13 @@ function deptChangeHandler() {
 
 function workshopTurnoverChangeHandler() {
   // 区间外周转周转区变更
+  const turnovers = workShopTurnoverList.value.filter(t => t.id == form.value.turnoverId)
+  form.value.turnoverArea = turnovers.map(e => e.code).join("、")
 }
 
 function turnoverChangeHandler() {
   // 区间内周转周转区变更
-  const places = turnoverList.filter(t => placeIds.value.some(e => e == t.id))
+  const places = turnoverList.value.filter(t => placeIds.value.some(e => e == t.id))
   form.value.placeId = places.map(e => e.id).join('、')
   form.value.place = places.map(e => e.code).join('、')
 }