guoyujia 1 سال پیش
والد
کامیت
a41285e4d9

+ 40 - 1
src/api/business/daywork.js

@@ -20,7 +20,6 @@ export function listDaywork(query) {
  * @returns
  */
 export function listDayworkItem(data) {
-  console.log(data)
   return request({
     url: baseUrl + '/business/productionDaywork/listItem',
     method: 'post',
@@ -28,6 +27,19 @@ export function listDayworkItem(data) {
   })
 }
 
+/**
+ * 修改 生产批次报工 列表
+ * @param {*} data
+ * @returns
+ */
+export function updateItem(data) {
+  return request({
+    url: baseUrl + '/business/productionDaywork/updateItem',
+    method: 'post',
+    data: data
+  })
+}
+
 /**
  * 获取报工批次工序列表
  * @param {*} data
@@ -40,3 +52,30 @@ export function getProcessList(query) {
     params: query
   })
 }
+
+/**
+ * 获取报工批次废弃信息
+ * @param {*} data
+ * @returns
+ */
+export function getDayworkItemRejectList(query) {
+  return request({
+    url: baseUrl + '/business/productionDaywork/getDayworkItemRejectList',
+    method: 'get',
+    params: query
+  })
+}
+/**
+ * 修改 生产批次报工 列表
+ * @param {*} data
+ * @returns
+ */
+export function updateDayworkItemInfo(data) {
+  return request({
+    url: baseUrl + '/business/productionDaywork/updateDayworkItemInfo',
+    method: 'post',
+    data: data
+  })
+}
+
+

+ 5 - 5
src/components/Time/time.js

@@ -6,10 +6,10 @@
 // listData.value[i].taskTime = (timeStamp / 3600000).toFixed(2) === 'NaN' ? 0 : (timeStamp / 3600000)
 // 	.toFixed(2);
 export function toHHmmss(data, flag = true) {
-	var time;
-	var hours = parseInt((data % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
-	var minutes = parseInt((data % (1000 * 60 * 60)) / (1000 * 60));
-	var seconds = (data % (1000 * 60)) / 1000;
+	let time;
+	let hours = parseInt((data % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
+	let minutes = parseInt((data % (1000 * 60 * 60)) / (1000 * 60));
+	let seconds = (data % (1000 * 60)) / 1000;
 	if (flag) {
 		time = `${hours}小时${minutes}分钟${seconds}秒`;
 	} else {
@@ -18,4 +18,4 @@ export function toHHmmss(data, flag = true) {
 			10 ? ('0' + seconds) : seconds);
 	}
 	return time;
-}
+}

+ 500 - 0
src/views/business/daywork/form.vue

@@ -0,0 +1,500 @@
+<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"
+          @click="handleSave"
+          >保 存</el-button
+        >
+        <el-button icon="Close" @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"
+                type="datetime"
+                value-format="YYYY-MM-DD hh:mm:ss "
+                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="请选择生产状态"
+                style="width: 220px"
+              >
+                <el-option
+                  v-for="dict in daywork_status"
+                  :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"
+                type="datetime"
+                value-format="YYYY-MM-DD hh:mm:ss "
+                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"
+                controls-position="right"
+                style="width: 220px"
+                @input="editStatus = true"
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="20">
+          <el-col :span="7">
+            <el-form-item
+              label="总工时:"
+              prop="workingHours"
+              label-width="92px"
+            >
+              <el-input
+                v-model.trim="form.workingHours"
+                :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"
+                :precision="0"
+                controls-position="right"
+                style="width: 220px"
+                @input="editStatus = true"
+              />
+            </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
+            v-if="editStatus"
+            type="primary"
+            icon="Plus"
+            @click="handleAddReject"
+            >新增</el-button
+          >
+          <el-button
+            v-if="editStatus"
+            type="primary"
+            icon="Check"
+            @click="handleCheckRejectInfo"
+            >确定</el-button
+          >
+          <el-button
+            v-if="!editStatus"
+            type="warning"
+            icon="Edit"
+            @click="handleUpdateRejectInfo"
+            >编辑</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
+            label="废弃数量"
+            width="160px"
+            prop="rejectNum"
+            align="center"
+          >
+            <template #default="scope">
+              <div v-if="editStatus">
+                <el-input-number
+                  v-model.trim="scope.row.rejectNum"
+                  placeholder="废弃数量"
+                  :precision="0"
+                  controls-position="right"
+                />
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="reason"
+            label="废弃原因"
+            align="center"
+            width="300px"
+          >
+            <template #default="scope">
+              <div v-if="!editStatus">
+                <dict-tag :options="waste_causes" :value="scope.row.reason" />
+              </div>
+              <div v-if="editStatus">
+                <el-select
+                  v-model="scope.row.reason"
+                  placeholder="请选择废弃原因"
+                >
+                  <el-option
+                    v-for="cause in waste_causes"
+                    :key="cause.value"
+                    :label="cause.label"
+                    :value="cause.value"
+                  ></el-option>
+                </el-select>
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column fixed="right" label="操作" align="center">
+            <template #default="scope">
+              <el-button
+                link
+                type="danger"
+                icon="Delete"
+                @click="handleDeleteReject(scope.row)"
+                >删除</el-button
+              >
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+    </div>
+  </el-drawer>
+</template>
+<script setup>
+import {
+  getProcessList,
+  getDayworkItemRejectList,
+  updateDayworkItemInfo,
+} from "@/api/business/daywork.js";
+const { proxy } = getCurrentInstance();
+const emit = defineEmits(["handleSaveSuccess"]);
+/** 字典 */
+const { daywork_status } = proxy.useDict("daywork_status");
+const { waste_causes } = proxy.useDict("waste_causes");
+const queryParams = ref({
+  pageNum: 1,
+  pageSize: 10,
+});
+const detailInfo = ref({});
+const loading = ref(false);
+const processList = ref([]);
+const visible = ref(false);
+const editStatus = ref(true);
+const rejectAmount = ref(0);
+const workHoursTimestamp = ref(0);
+const detailsRow = {
+  id: null,
+  rejectNum: "",
+  reason: "",
+};
+const validateprodNum = (rule, value, callback) => {
+  const max = detailInfo.value.maxProdNum;
+  if (value <= 0) {
+    callback(new Error("投产量应大于0"));
+  } else if (value > max) {
+    callback(new Error(`投产量不能超过` + max));
+  } else {
+    callback();
+  }
+};
+const validateWorkingHours = (rule, value, callback) => {
+  if (workHoursTimestamp.value < 0) {
+    callback(new Error("结束时间应晚于开始时间"));
+  } else {
+    callback();
+  }
+};
+const validateQualifiedNum = (rule, value, callback) => {
+  if (value < 0) {
+    callback(new Error("合格数量应大于/等于0"));
+  } else {
+    callback();
+  }
+};
+const data = reactive({
+  form: {
+    groupRejectList: [],
+    nickName: "",
+    processId: null,
+    processAlias: "",
+    prodNum: 0,
+    qualifiedNum: 0,
+    rejectNum: 0,
+    startTime: "",
+    endTime: "",
+    workingHours: "",
+    status: "",
+  },
+  rules: {
+    prodNum: [
+      { required: true, message: "投产量不能为空", trigger: "blur" },
+      { validator: validateprodNum, trigger: "blur" },
+    ],
+    startTime: [
+      { required: true, message: "下达日期不能为空", trigger: "blur" },
+    ],
+    endTime: [{ required: true, message: "下达日期不能为空", trigger: "blur" }],
+    workingHours: [
+      { required: true, message: "工作时间不能为空", trigger: "blur" },
+      { 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) {
+    editStatus.value = true;
+    detailInfo.value = proxy.deepClone(row);
+    form.value.id = row.id;
+    form.value.startTime = row.startTime;
+    form.value.endTime = row.endTime;
+    form.value.workingHours = row.workingHours;
+    form.value.nickName = row.nickName;
+    form.value.status = row.status;
+    form.value.qualifiedNum = row.qualifiedNum;
+    form.value.prodNum = row.prodNum;
+    getProcessList({ technologicalProcessId: row.technologicalProcessId }).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;
+          }
+        }
+      }
+    );
+    getDayworkItemRejectList({ dayworkId: detailInfo.value.dayworkId }).then(
+      (response) => {
+        if (response.code == 200) {
+          for (let i = 0; i < response.data.length; i++) {
+            response.data[i].rejectNum = parseInt(response.data[i].rejectNum);
+          }
+          form.value.groupRejectList = response.data;
+        }
+      }
+    );
+  }
+  loading.value = false;
+  visible.value = true;
+};
+
+/** 多选事件 */
+function handleMultipleSelected() {
+  if (multipleSelected.value) {
+    multipleSelected.value(selections.value);
+  }
+  close();
+}
+function handleCheckRejectInfo() {
+  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
+    );
+    return;
+  } else {
+    if (parseInt(form.value.prodNum) - rejectAmount.value >= 0) {
+      form.value.qualifiedNum =
+        parseInt(form.value.prodNum) - rejectAmount.value;
+    } else {
+      proxy.$modal.msgError("废品总数加合格数不能超过投产数");
+      flag = false;
+      form.value.qualifiedNum = 0;
+    }
+  }
+  if (flag) {
+    editStatus.value = false;
+  }
+}
+
+function handleUpdateRejectInfo() {
+  editStatus.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: "",
+  };
+  proxy.resetForm("dayworkItemRef");
+}
+
+/** 提交按钮 */
+const handleSave = () => {
+  proxy.$refs["dayworkItemRef"].validate((valid) => {
+    if (valid) {
+      form.value.workingHours = workHoursTimestamp.value;
+      updateDayworkItemInfo(form.value).then((res) => {
+        if (res.code == 200) {
+          proxy.$modal.msgSuccess("保存成功!");
+          visible.value = false;
+          emit("handleSaveSuccess");
+        }
+      });
+    }
+  });
+};
+function handleDeleteReject(row) {
+  form.value.groupRejectList.splice(form.value.groupRejectList.indexOf(row), 1);
+  editStatus.value = true;
+}
+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() {
+  workHoursTimestamp.value =
+    new Date(form.value.endTime) - new Date(form.value.startTime);
+  let seconds = Math.floor((workHoursTimestamp.value / 1000) % 60);
+  let minutes = Math.floor((workHoursTimestamp.value / (1000 * 60)) % 60);
+  let hours = Math.floor(workHoursTimestamp.value / (1000 * 60 * 60));
+  let time = `${hours}小时${minutes}分钟${seconds}秒`;
+  form.value.workingHours = time;
+}
+
+/** 取消按钮 */
+const handleCancel = () => {
+  visible.value = false;
+  reset();
+};
+
+/** 暴露给父组件的方法 */
+defineExpose({
+  open,
+});
+</script>

+ 24 - 0
src/views/business/daywork/index.vue

@@ -68,12 +68,18 @@
                 <dict-tag :options="daywork_status" :value="scope.row.status" />
               </template>
             </el-table-column>
+            <el-table-column fixed="right" label="操作" align="center" width="70px">
+              <template #default="scope">
+                <el-button  link type="warning" icon="Edit" @click="handleUpdateDayworkItem(scope.row,scope.$index)" >编辑</el-button>
+              </template>
+            </el-table-column>
           </el-table>
         </div>
       </div>
       <!-- 分页 -->
       <pagination v-show="itemTotal > 0" :total="itemTotal" v-model:page="queryItemParams.pageNum" v-model:limit="queryItemParams.pageSize" @pagination="getDayworkItems" />
     </section>
+    <dayworkItem-form ref="dayworkItemRef" @handleSaveSuccess = "handleGetDayworkItems" />
   </div>
 </template>
 
@@ -81,6 +87,7 @@
 import { listDaywork, listDayworkItem, getProcessList } from '@/api/business/daywork.js'
 import { getDept } from '@/api/business/planDetailSubDetail.js'
 import { toHHmmss } from '@/components/Time/time.js'
+import dayworkItemForm from './form'
 import { get } from '@vueuse/core'
 const { proxy } = getCurrentInstance()
 
@@ -153,10 +160,27 @@ function getDayworks() {
     }
   })
 }
+function handleGetDayworkItems() {
+  handleDayworkCurrentChange(currentDaywork.value)
+}
 function handleDeptChange() {
   getDayworks()
 }
 
+function handleUpdateDayworkItem(row,index) {
+  row.technologicalProcessId = queryItemParams.value.technologicalProcessId
+  row.deptId =  queryDayworkParams.value.deptId
+  row.dayworkId = currentDaywork.value.id
+  row.lotId = currentDaywork.value.lotId
+  if(index == 0) {
+    row.maxProdNum = currentDaywork.value.oneLotQuantity
+  }
+  else {
+    row.maxProdNum = dayworkItemList.value[index-1].qualifiedNum
+  }
+  proxy.$refs.dayworkItemRef.open(row)
+}
+
 function handleProcessChange() {
   getDayworkItems()
 }

+ 9 - 6
src/views/business/equipment/index.vue

@@ -37,7 +37,7 @@
       </el-form>
       <!-- 设备类别列表区域 -->
       <div class="el-table-container">
-        <div class="el-table-inner-container">
+        <div class="el-table-inner-container" >
           <!-- <el-table v-loading="equipmentCategoryLoading" ref="categoryTable" :data="equipmentCategoryList" height="100%" row-key="id" :indent="20" highlight-current-row default-expand-all @current-change="handleCurrentCategoryChange">
             <el-table-column type="index" label="序号" width="50" align="center" />
             <el-table-column prop="name" label="设备类别名称" width="100" header-align="center" />
@@ -63,6 +63,7 @@
             default-expand-all
             node-key="id"
             highlight-current
+            style="max-height: 100%; overflow-y: auto;margin-bottom: 20px;"
             @node-click="handleCurrentCategoryChange"
           >
             <template #default="{ node, data }">
@@ -76,7 +77,7 @@
                 <span>
                   <span
                     v-if="data.parentId == 0"
-                    style="display: inline-block; width: 20px"
+                    style="display: inline-block; width: 30px"
                     >{{ getNodeIndex(data) }}.
                   </span>
                   <span>{{ node.label }}</span>
@@ -104,13 +105,14 @@
           </el-tree>
         </div>
       </div>
-      <pagination
+      <!-- <pagination
         v-show="equipmentCategoryTotal > 0"
         :total="equipmentCategoryTotal"
+        :pager-count="4"
         v-model:page="queryEquipmentCategoryParams.pageNum"
         v-model:limit="queryEquipmentCategoryParams.pageSize"
         @pagination="getCategoryList"
-      />
+      /> -->
     </section>
 
     <!-- 右侧区域 -->
@@ -290,6 +292,7 @@ const categoryTable = ref(null);
 const currentCategory = ref({});
 const equipmentCategoryList = ref([]);
 const name = ref("");
+const pagerCount = ref(4)
 const equipmentCategoryTotal = ref(0);
 const equipmentTable = ref(null);
 const equipmentList = ref([]);
@@ -301,8 +304,8 @@ const equipmentCategoryLoading = ref(true);
 /** 设备类别 查询对象 */
 const queryEquipmentCategoryParams = ref({
   name: "",
-  pageNum: 1,
-  pageSize: 10,
+  // pageNum: 1,
+  // pageSize: 10,
 });
 
 /** 设备档案 查询对象 */