Преглед на файлове

Merge branch 'master' of http://120.46.159.163:7400/ezhizao/ezhizao_dms_vue

ezhizao_zx преди 10 месеца
родител
ревизия
c53dbdb5e6

+ 1 - 1
src/api/business/dayworkItemReject.js

@@ -42,7 +42,7 @@ export function printSortReject(data) {
 		{
 			...data,
 		},
-		`分选标准报表_${new Date().getTime()}.xlsx` 
+		`德迈仕质量检查不良原因数据查询报表_${new Date().getTime()}.xlsx` 
 	)
 }
 export function getSortRejectList(query) {

+ 45 - 0
src/api/business/takeStockPeriod.js

@@ -0,0 +1,45 @@
+import request from '@/utils/request'
+const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API
+
+// 查询盘点时间列表
+export function listTakeStockPeriod(query) {
+  return request({
+    url:baseUrl + '/business/takeStockPeriod/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询盘点时间详细
+export function getTakeStockPeriod(id) {
+  return request({
+    url:baseUrl + '/business/takeStockPeriod/' + id,
+    method: 'get'
+  })
+}
+
+// 新增盘点时间
+export function addTakeStockPeriod(data) {
+  return request({
+    url:baseUrl + '/business/takeStockPeriod',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改盘点时间
+export function updateTakeStockPeriod(data) {
+  return request({
+    url: baseUrl +'/business/takeStockPeriod',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除盘点时间
+export function delTakeStockPeriod(id) {
+  return request({
+    url:baseUrl + '/business/takeStockPeriod/' + id,
+    method: 'delete'
+  })
+}

+ 45 - 0
src/api/business/taksStockLot.js

@@ -0,0 +1,45 @@
+import request from '@/utils/request'
+const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API
+
+// 查询盘点批次信息列表
+export function listTaksStockLot(query) {
+  return request({
+    url:baseUrl + '/business/taksStockLot/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询盘点批次信息详细
+export function getTaksStockLot(id) {
+  return request({
+    url:baseUrl + '/business/taksStockLot/' + id,
+    method: 'get'
+  })
+}
+
+// 新增盘点批次信息
+export function addTaksStockLot(data) {
+  return request({
+    url:baseUrl + '/business/taksStockLot',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改盘点批次信息
+export function updateTaksStockLot(data) {
+  return request({
+    url:baseUrl + '/business/taksStockLot',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除盘点批次信息
+export function delTaksStockLot(id) {
+  return request({
+    url: baseUrl +'/business/taksStockLot/' + id,
+    method: 'delete'
+  })
+}

+ 658 - 0
src/views/business/dayworkSelect/form.vue

@@ -0,0 +1,658 @@
+<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 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"
+                :disabled="true"
+                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="true"
+                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="true"
+                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"
+                readonly
+                :clearable="true"
+                style="width: 220px; margin-left: 8px"
+              >
+                <template #append>
+                  <el-button
+                    icon="Search"
+                    @click="handleSelectUserSingle"
+                  /> </template
+              ></el-input>
+            </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"
+                :disabled="true"
+                :precision="0"
+                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="true"
+                :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="true"
+                :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>
+      <!-- 列表区 -->
+      <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="200px"
+            prop="rejectNum"
+            align="center"
+          >
+            <template #default="scope">
+              <el-input-number
+                v-model.trim="scope.row.rejectNum"
+                placeholder="废品数量"
+                :disabled="!editStatus"
+                :precision="0"
+                :min="0"
+                controls-position="right"
+              />
+            </template>
+          </el-table-column>
+          <el-table-column prop="reason" label="废品原因" align="center">
+            <template #default="scope">
+              <el-select
+                v-model="scope.row.reason"
+                :disabled="!editStatus"
+                placeholder="请选择废品原因"
+              >
+                <el-option
+                  v-for="cause in waste_causes"
+                  :key="cause.value"
+                  :label="cause.label"
+                  :value="cause.value"
+                ></el-option>
+              </el-select>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+    </div>
+  </el-drawer>
+</template>
+<script setup>
+import {
+  getProcessList,
+  getDayworkItemRejectList,
+  updateDayworkItemInfoForNum,
+  getEquipmentInfo,
+  getIsFirstOrder,
+} from "@/api/business/daywork.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 { waste_causes } = proxy.useDict("waste_causes");
+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(false);
+const currentDept = ref(false);
+const rejectAmount = ref(0);
+const dynamicOptions = ref([]);
+const workingHoursTime = ref("");
+const maxQuailifiedNum = ref(0);
+const detailsRow = {
+  id: null,
+  rejectNum: "",
+  reason: "",
+};
+// 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);
+    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.productDescription = row.productDescription;
+    form.value.lotCode = row.lotCode;
+    form.value.technologyVersion = row.technologyVersion;
+    form.value.productionPlanNo = row.productionPlanNo;
+    form.value.status = row.status;
+    editStatus.value = row.status < 2 ? false : true;
+    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;
+        }
+      }
+    });
+    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);
+          }
+          form.value.groupRejectList = response.data;
+        }
+      }
+    );
+    //查询能够选择的设备信息
+    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 handleSelectUserSingle() {}
+/**
+ * 对话框关闭 事件
+ */
+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) {
+      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) => {
+            item.deptId = detailInfo.value.deptId;
+            item.processId = detailInfo.value.processId;
+          });
+        }
+        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() {
+  updateDayworkItemInfoForNum(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 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;
+  }
+}
+
+/** 取消按钮 */
+const handleCancel = () => {
+  visible.value = false;
+  reset();
+};
+
+/** 暴露给父组件的方法 */
+defineExpose({
+  open,
+});
+</script>
+<style scoped>
+.el-select-v2__placeholder {
+  display: flex !important;
+}
+</style>

+ 622 - 0
src/views/business/dayworkSelect/index.vue

@@ -0,0 +1,622 @@
+<template>
+  <div class="page-container row-container">
+    <!-- 左侧区域 -->
+    <section class="list-part-container" style="flex: 3">
+      <!-- 搜索区 -->
+      <el-form
+        class="list-search-container"
+        :model="queryDayworkParams"
+        ref="queryRef"
+        :inline="true"
+        style="margin-right: 0px"
+      >
+        <el-form-item class="section-title" label="生产批次" />
+        <el-form-item label="生产计划单号:">
+          <el-input
+            placeholder="请输入生产计划单号/批次号"
+            v-model.trim="queryDayworkParams.productionPlanNo"
+            @keydown.enter.prevent
+            clearable
+            style="width: 200px"
+          />
+        </el-form-item>
+        <el-form-item label="产品描述:">
+          <el-input
+            placeholder="请输入产品描述"
+            v-model.trim="queryDayworkParams.productDescription"
+            @keydown.enter.prevent
+            clearable
+            style="width: 130px"
+          />
+        </el-form-item>
+        <el-form-item style="margin-left: 0">
+          <el-button type="info" icon="Search" @click="handleQuery"
+            >搜索
+          </el-button>
+        </el-form-item>
+      </el-form>
+      <div class="el-table-container">
+        <div class="el-table-inner-container">
+          <el-table
+            ref="dayworkTable"
+            :data="dayworkList"
+            v-loading="dayworkLoading"
+            highlight-current-row
+            height="100%"
+            @current-change="handleDayworkCurrentChange"
+          >
+            <el-table-column
+              label="客户简称"
+              prop="companyAlias"
+              width="120"
+              align="center"
+            />
+            <el-table-column
+              label="生产计划单号"
+              prop="productionPlanNo"
+              width="100"
+              align="center"
+            />
+            <el-table-column
+              label="批次号"
+              min-width="120"
+              prop="lotCode"
+              align="center"
+            >
+              <template #default="scope">
+                <el-button
+                  v-if="permissionFlag || useUserStore().user.userId == 1"
+                  link
+                  type="primary"
+                  @click="handleColumnClick(scope.row)"
+                  ><span>{{ scope.row.lotCode }}</span></el-button
+                >
+                <span v-else>{{ scope.row.lotCode }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column
+              label="产品描述"
+              prop="productDescription"
+              align="center"
+            />
+            <el-table-column
+              label="图纸版本"
+              prop="technologyVersion"
+              width="60"
+              align="center"
+            />
+            <el-table-column
+              label="投产量"
+              prop="productionQuantity"
+              width="60"
+              align="center"
+            />
+            <el-table-column
+              label="下达日期"
+              prop="createTime"
+              width="100"
+              align="center"
+            >
+              <template #default="scope">
+                <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"
+            />
+          </el-table>
+        </div>
+      </div>
+      <!-- 分页 -->
+      <pagination
+        v-show="total > 0"
+        :total="total"
+        v-model:page="queryDayworkParams.pageNum"
+        v-model:limit="queryDayworkParams.pageSize"
+        @pagination="getDayworks"
+      />
+    </section>
+    <!-- 右侧区域 -->
+    <section class="list-part-container" style="flex: 2">
+      <el-form class="list-search-container" :inline="true">
+        <el-form-item class="section-title" label="报工信息" />
+        <el-form-item
+          class="section-title"
+          label="请选择工序:"
+          prop="processId"
+        >
+          <el-select-v2
+            v-model="queryItemParams.processId"
+            clearable
+            :options="processList"
+            placeholder="请选择工序"
+            style="width: 100%"
+            @change="handleProcessChange"
+          />
+        </el-form-item>
+      </el-form>
+
+      <div class="el-table-container">
+        <div class="el-table-inner-container">
+          <el-table
+            :data="dayworkItemList"
+            v-loading="dayworkItemLoading"
+            height="100%"
+          >
+            <el-table-column
+              label="操作者"
+              prop="nickName"
+              width="60"
+              align="center"
+            />
+            <el-table-column
+              label="工序名称"
+              prop="processAlias"
+              align="center"
+            />
+            <el-table-column
+              label="投产量"
+              prop="prodNum"
+              width="60"
+              align="center"
+            />
+            <el-table-column
+              label="合格数"
+              prop="qualifiedNum"
+              width="60"
+              align="center"
+            />
+            <el-table-column
+              label="废品数"
+              prop="rejectNum"
+              width="60"
+              align="center"
+            />
+            <el-table-column
+              label="开始时间"
+              prop="startTime"
+              width="160"
+              align="center"
+            />
+            <el-table-column
+              label="结束时间"
+              prop="endTime"
+              width="160"
+              align="center"
+            />
+            <el-table-column
+              label="总工时"
+              prop="workingHours"
+              width="160"
+              align="center"
+            />
+            <el-table-column
+              label="生产状态"
+              prop="status"
+              width="100"
+              align="center"
+            >
+              <template #default="scope">
+                <dict-tag :options="daywork_status" :value="scope.row.status" />
+              </template>
+            </el-table-column>
+            <el-table-column
+              fixed="right"
+              label="操作"
+              align="center"
+              width="200px"
+            >
+              <template #default="scope">
+                <el-button
+                  link
+                  type="primary"
+                  icon="View"
+                  @click="handleSelectDayworkItem(scope.row)"
+                  >查看
+                </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>
+    <!-- 报工信息表单 -->
+    <daywork-item-form
+      ref="dayworkItemRef"
+      @handleSaveSuccess="handleGetDayworkItems"
+    />
+    <!-- 分选报工信息表单 -->
+    <sort-item-form
+      ref="sortItemRef"
+      @handleSaveSuccess="handleGetDayworkItems"
+    />
+    <!-- 报工历史修改表单 -->
+    <dialog-daywork-item-history ref="dialogDayworkItemHistoryRef" />
+  </div>
+</template>
+
+<script setup>
+import {
+  listDaywork,
+  listDayworkItem,
+  getProcessList,
+  delDayworkItem,
+} from "@/api/business/daywork.js";
+import { listDeptProcess } from "@/api/business/deptProcess";
+import { selectUserPermissionList } from "@/api/system/user.js";
+import router from "@/router";
+import dayworkItemForm from "./form";
+import sortItemForm from "./sortForm";
+import useUserStore from "@/store/modules/user";
+
+const { proxy } = getCurrentInstance();
+
+/** 字典 */
+const { daywork_status } = proxy.useDict("daywork_status");
+
+/** 生产批次 */
+const dayworkList = ref([]);
+const dayworkTable = ref(null);
+const currentDaywork = ref({});
+const dayworkLoading = ref(false);
+const total = ref(0);
+/**工段 */
+const permissionFlag = ref(false);
+const loading = ref(false);
+/** 报工信息 */
+const dayworkItemList = ref([]);
+const dayworkItemLoading = ref(false);
+const itemTotal = ref(0);
+const lastStatus = ref(null);
+const latestProcessId = ref(null);
+const latestDeptId = ref(null);
+const permissionList = ref(null);
+const deptProcessList = ref([]);
+/**工序 */
+const processList = ref([]);
+/** 查询对象 */
+const queryDayworkParams = ref({
+  productDescription: "",
+  deptId: "",
+  lotCode: "",
+  pageNum: 1,
+  pageSize: 10,
+});
+const queryItemParams = ref({
+  dayworkId: "0",
+  isAmend: 0,
+  isWasteRecycling: 0,
+  pageNum: 1,
+  pageSize: 10,
+  technologicalProcessDetailId: null,
+});
+
+/***********************  工段相关事件  ****************************/
+function getList() {
+  loading.value = true;
+  getPremission();
+  getDayworks();
+}
+
+//切换工段
+function handleDeptChange() {
+  getDayworks();
+}
+
+/***********************  生产批次相关事件  ****************************/
+
+/** 查询计划明细 */
+function getDayworks() {
+  dayworkLoading.value = true;
+  listDaywork(queryDayworkParams.value).then((res) => {
+    dayworkList.value = res.rows;
+    for (var i = 0; i < dayworkList.value.length; i++) {
+      let timeStamp = dayworkList.value[i].totalWorkingHours;
+      let seconds = Math.floor((timeStamp / 1000) % 60);
+      let minutes = Math.floor((timeStamp / (1000 * 60)) % 60);
+      let hours = Math.floor(timeStamp / (1000 * 60 * 60));
+      let time = `${hours}小时${minutes}分钟${seconds}秒`;
+      dayworkList.value[i].totalWorkingHours = time;
+    }
+    total.value = res.total;
+    dayworkLoading.value = false;
+    // 批次
+    if (dayworkList.value.length > 0) {
+      proxy.$refs.dayworkTable.setCurrentRow(dayworkList.value[0]);
+      console.log(dayworkList.value[0]);
+    } else {
+      dayworkItemList.value = [];
+      itemTotal.value = 0;
+    }
+  });
+}
+function getPremission() {
+  console.log("888");
+  selectUserPermissionList({ userId: useUserStore().user.userId }).then(
+    (res) => {
+      permissionList.value = res.data;
+      console.log(permissionList.value);
+      if (permissionList.value.indexOf("business:productionPlan:query") != -1) {
+        permissionFlag.value = true;
+      } else {
+        permissionFlag.value = false;
+      }
+    }
+  );
+}
+
+/** 打开批次详情页 */
+function handleColumnClick(row) {
+  router.push({ path: "/reviseBath/lotFormParticulars/" + row.lotCode });
+}
+// 打开历史修改弹窗
+function handleOpenHistory() {
+  proxy.$refs.dialogDayworkItemHistoryRef.open(currentDaywork.value.id);
+}
+
+/** 生产计划明细 current-change 事件 */
+function handleDayworkCurrentChange(row) {
+  if (row) {
+    queryItemParams.value.processId = null;
+    currentDaywork.value = row;
+    queryItemParams.value.dayworkId = currentDaywork.value.id;
+    queryItemParams.value.isAmend = row.isAmend;
+    queryItemParams.value.isWasteRecycling = row.isWasteRecycling;
+    queryItemParams.value.technologicalProcessDetailId = null;
+    queryItemParams.value.technologicalProcessId = row.technologicalProcessId;
+    getDayworkItems();
+    getProcess();
+  } else {
+    dayworkItemList.value = [];
+    itemTotal.value = 0;
+  }
+}
+
+/***********************  报工信息相关事件  ****************************/
+//查询报工信息数据
+function handleGetDayworkItems() {
+  dayworkLoading.value = true;
+  listDaywork(queryDayworkParams.value).then((res) => {
+    dayworkList.value = res.rows;
+    for (var i = 0; i < dayworkList.value.length; i++) {
+      let timeStamp = dayworkList.value[i].totalWorkingHours;
+      let seconds = Math.floor((timeStamp / 1000) % 60);
+      let minutes = Math.floor((timeStamp / (1000 * 60)) % 60);
+      let hours = Math.floor(timeStamp / (1000 * 60 * 60));
+      let time = `${hours}小时${minutes}分钟${seconds}秒`;
+      dayworkList.value[i].totalWorkingHours = time;
+    }
+    total.value = res.total;
+    dayworkLoading.value = false;
+    if (dayworkList.value.length > 0) {
+      for (var i = 0; i < dayworkList.value.length; i++) {
+        if (dayworkList.value[i].id == currentDaywork.value.id) {
+          var index = i;
+          break;
+        }
+      }
+    }
+    proxy.$refs.dayworkTable.setCurrentRow(dayworkList.value[index]);
+  });
+}
+//删除报工信息
+function handleDeletedItem(id) {
+  proxy.$modal.confirm("是否确认删除选中的数据项?").then(function () {
+    delDayworkItem(id).then((res) => {
+      if (res.code == 200) {
+        proxy.$modal.msgSuccess("删除成功");
+        listDaywork(queryDayworkParams.value).then((res) => {
+          dayworkList.value = res.rows;
+          for (var i = 0; i < dayworkList.value.length; i++) {
+            let timeStamp = dayworkList.value[i].totalWorkingHours;
+            let seconds = Math.floor((timeStamp / 1000) % 60);
+            let minutes = Math.floor((timeStamp / (1000 * 60)) % 60);
+            let hours = Math.floor(timeStamp / (1000 * 60 * 60));
+            let time = `${hours}小时${minutes}分钟${seconds}秒`;
+            dayworkList.value[i].totalWorkingHours = time;
+          }
+          total.value = res.total;
+          // 批次
+          proxy.$refs.dayworkTable.setCurrentRow(
+            dayworkList.value[
+              dayworkList.value.findIndex(
+                (daywork) => daywork.id == currentDaywork.value.id
+              )
+            ]
+          );
+        });
+      }
+    });
+  });
+}
+//修改报工信息
+function handleSelectDayworkItem(row) {
+  //同工序下状态是否有工序已完成
+  let processFinish = false;
+  //除了编辑此条以外的同工序合格数
+  let totalQuailifiedNum = 0;
+  for (let i = 0; i < dayworkItemList.value.length; i++) {
+    if (
+      row.processId == dayworkItemList.value[i].processId &&
+      (dayworkItemList.value[i].status == 2 ||
+        dayworkItemList.value[i].status == 3) &&
+      row.id != dayworkItemList.value[i].id
+    ) {
+      totalQuailifiedNum += dayworkItemList.value[i].qualifiedNum;
+    }
+    if (
+      row.processId == dayworkItemList.value[i].processId &&
+      dayworkItemList.value[i].status == 3 &&
+      row.id != dayworkItemList.value[i].id
+    ) {
+      processFinish = true;
+    }
+  }
+  let maxQuailifiedNum =
+    Math.floor(row.prodNum * 1.03 - totalQuailifiedNum) > 0
+      ? Math.floor(row.prodNum * 1.03 - totalQuailifiedNum)
+      : 0;
+  //该daywork合格数总数不能超过投产数的103%
+  row.technologicalProcessId = queryItemParams.value.technologicalProcessId;
+  row.deptId = queryDayworkParams.value.deptId;
+  row.productionPlanNo = currentDaywork.value.productionPlanNo;
+  row.productDescription = currentDaywork.value.productDescription;
+  row.productionPlanDetailId = currentDaywork.value.productionPlanDetailId;
+  row.dayworkId = currentDaywork.value.id;
+  row.lotId = currentDaywork.value.lotId;
+  row.isAmend = currentDaywork.value.isAmend;
+  row.isWasteRecycling = currentDaywork.value.isWasteRecycling;
+  row.maxQuailifiedNum = maxQuailifiedNum;
+  row.technologyVersion = currentDaywork.value.technologyVersion;
+  row.lotCode = currentDaywork.value.lotCode;
+  row.totalQuailifiedNum = totalQuailifiedNum;
+  // console.log(row, currentDaywork)
+  row.productId = currentDaywork.value.productId;
+  //判断是否是当前工段
+  if (row.deptId == currentDaywork.value.deptId) {
+    row.currentDept = true;
+  } else {
+    row.currentDept = false;
+  }
+  //如果为true,则同工序已有工序已完成
+  row.processFinish = processFinish;
+  if (row.isSort == 0) {
+    proxy.$refs.dayworkItemRef.open(row);
+  } else {
+    proxy.$refs.sortItemRef.open(row);
+  }
+}
+
+//查看报工信息
+function handleCheckDayworkItem(row) {
+  row.technologicalProcessId = queryItemParams.value.technologicalProcessId;
+  row.deptId = queryDayworkParams.value.deptId;
+  row.productionPlanDetailId = currentDaywork.value.productionPlanDetailId;
+  row.isAmend = currentDaywork.value.isAmend;
+  row.isWasteRecycling = currentDaywork.value.isWasteRecycling;
+  row.dayworkId = currentDaywork.value.id;
+  row.lotId = currentDaywork.value.lotId;
+  //判断是否是当前工段
+  if (row.deptId == currentDaywork.value.deptId) {
+    row.currentDept = true;
+  } else {
+    row.currentDept = false;
+  }
+  //修改向form表单传一个状态值
+  row.editStatus = false;
+  // row.returnFlag = false;
+  // //如果是最新工序的已接收,则传一个状态值,给form表单一个退回按钮
+  // if (row.processId == latestProcessId.value && row.status == 7) {
+  //   row.returnFlag = true;
+  // }
+  if (row.isSort == 0) {
+    proxy.$refs.dayworkItemRef.open(row);
+  } else {
+    proxy.$refs.sortItemRef.open(row);
+  }
+}
+
+/**切换工序 */
+function handleProcessChange() {
+  getDayworkItems();
+}
+
+/** 报工详情列表 */
+function getDayworkItems() {
+  dayworkItemLoading.value = true;
+  //查询该工段在工段资源分配时绑定的工序,传一个flag,如果flag有值则后端查询不分页
+  listDeptProcess({ deptId: queryDayworkParams.value.deptId, flag: 1 }).then(
+    (res) => {
+      deptProcessList.value = res.rows;
+      listDayworkItem(queryItemParams.value).then((res) => {
+        console.log(currentDaywork.value);
+        for (let i = 0; i < res.rows.length; i++) {
+          //如果时首序,投产数是单批数
+          if (
+            res.rows[i].processStepNumber === res.others.isFirst &&
+            res.rows[i].prodNum == 0
+          ) {
+            if (currentDaywork.value.isLast == 1) {
+              res.rows[i].prodNum = currentDaywork.value.lastLotQuantity;
+            } else {
+              res.rows[i].prodNum = currentDaywork.value.oneLotQuantity;
+            }
+          }
+          //拿到最新一条报工信息的工序id,只能编辑当前序
+          // if (res.rows[i] == res.rows[res.rows.length - 1]) {
+          //   latestProcessId.value = res.rows[i].processId;
+          // }
+        }
+        if (res.others != null && res.others.latestProcessId != null) {
+          latestProcessId.value = res.others.latestProcessId;
+        }
+        if (res.others != null && res.others.lastItem != null) {
+          latestDeptId.value = res.others.lastItem.deptId;
+          lastStatus.value = res.others.lastItem.status;
+        }
+        for (var i = 0; i < res.rows.length; i++) {
+          let timeStamp = res.rows[i].workingHours;
+          let seconds = Math.floor((timeStamp / 1000) % 60);
+          let minutes = Math.floor((timeStamp / (1000 * 60)) % 60);
+          let hours = Math.floor(timeStamp / (1000 * 60 * 60));
+          let time = `${hours}小时${minutes}分钟${seconds}秒`;
+          res.rows[i].workingHours = time;
+          res.rows[i].deptProcessStatus = false;
+          //报工记录的工序id是该工段绑定的工序时,允许编辑
+          for (var item = 0; item < deptProcessList.value.length; item++) {
+            if (
+              res.rows[i].processId == deptProcessList.value[item].processId
+            ) {
+              res.rows[i].deptProcessStatus = true;
+            }
+          }
+          console.log(res.rows[i].deptProcessStatus);
+        }
+        dayworkItemList.value = res.rows;
+        getProcess();
+        itemTotal.value = res.total;
+        dayworkItemLoading.value = false;
+      });
+    }
+  );
+}
+//工序信息
+function getProcess() {
+  //工序下拉框
+  getProcessList({
+    technologicalProcessId: queryItemParams.value.technologicalProcessId,
+    isWasteRecycling: currentDaywork.value.isWasteRecycling,
+    isAmend: currentDaywork.value.isAmend,
+    lotId: currentDaywork.value.lotId,
+  }).then((res) => {
+    processList.value = res.data;
+  });
+}
+
+/** 搜索按钮操作 */
+function handleQuery() {
+  getDayworks();
+}
+
+onMounted(() => {
+  getList();
+});
+</script>
+<style scoped>
+.el-form--inline .el-form-item {
+  margin-right: 20px;
+}
+</style>

+ 779 - 0
src/views/business/dayworkSelect/sortForm.vue

@@ -0,0 +1,779 @@
+<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 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"
+                :disabled="true"
+                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="true"
+                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="true"
+                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"
+                readonly
+                :clearable="true"
+                style="width: 220px; margin-left: 8px"
+              >
+                <template #append>
+                  <el-button icon="Search" @click="handleSelectUserSingle" />
+                </template>
+              </el-input>
+            </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"
+                :disabled="true"
+                :precision="0"
+                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="true"
+                :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="true"
+                :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>
+      <!-- 列表区 -->
+      <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="150px"
+          >
+            <template #default="scope">
+              <el-select
+                v-model="scope.row.type"
+                :disabled="true"
+                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="true"
+                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">
+            <template #default="scope">
+              <el-input
+                v-model.trim="scope.row.reason"
+                placeholder="请输入检查结果"
+                :disabled="true"
+                :clearable="true"
+                style="margin-left: 8px"
+              />
+            </template>
+          </el-table-column>
+          <el-table-column
+            label="废品数量"
+            width="200px"
+            prop="rejectNum"
+            align="center"
+          >
+            <template #default="scope">
+              <el-input-number
+                v-model.trim="scope.row.rejectNum"
+                placeholder="废品数量"
+                :disabled="true"
+                :precision="0"
+                :min="0"
+                controls-position="right"
+              />
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+    </div>
+  </el-drawer>
+</template>
+<script setup>
+import {
+  getProcessList,
+  getDayworkItemRejectList,
+  updateDayworkItemInfoForNum,
+  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 isFirst = ref(true); //是否为首序
+const visible = ref(false);
+const editStatus = ref(false);
+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);
+    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;
+    editStatus.value = row.status < 2 ? false : true;
+    form.value.processId = row.processId;
+    form.value.productId = row.productId;
+    form.value.technologyVersion = row.technologyVersion;
+    form.value.productionPlanNo = row.productionPlanNo;
+    form.value.productDescription = row.productDescription;
+    form.value.lotCode = row.lotCode;
+    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({
+      productId: form.value.productId,
+      processId: form.value.processId,
+      technologyVersion: form.value.technologyVersion,
+    }).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 handleSelectUserSingle() {}
+
+/** 表单重置 */
+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.rejectNum = 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;
+            //计算废品总数
+            form.value.rejectNum += item.rejectNum;
+          });
+        }
+        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() {
+  updateDayworkItemInfoForNum(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>

+ 284 - 0
src/views/business/inventoryCheck/form.vue

@@ -0,0 +1,284 @@
+<template>
+  <el-drawer title="外协单信息" :with-header="false" v-model="visible" direction="rtl" size="100%">
+    <div class="form-container column-container">
+      <div class="form-btns-container">
+        <span class="title-label">
+          <el-icon>
+            <Document />
+          </el-icon>
+          <span>盘点批次</span>
+        </span>
+
+        <div class="close-btn" @click="cancel">
+          <i class="fa fa-times" aria-hidden="true" />
+          <!-- <span>关闭</span> -->
+        </div>
+      </div>
+      <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true"
+                style="margin-right: 0px">
+                <el-form-item class="section-title" label="盘点批次列表" />
+                <el-form-item label="批次号:">
+                    <el-input placeholder="请输入批次号" v-model.trim="queryParams.lotCode" @keydown.enter.prevent clearable
+                        style="width: 130px" />
+                </el-form-item>
+                <el-form-item label="产品描述:">
+                    <el-input placeholder="请输入产品描述" v-model.trim="queryParams.productDescription" @keydown.enter.prevent
+                        clearable style="width: 130px" />
+                </el-form-item>
+                <el-form-item label="生产状态:">
+					<el-select v-model="queryParams.isProductStatus" clearable placeholder="请选择生产状态" style="width: 145px">
+						<el-option v-for="dict in inventory_production_status" :key="dict.value" :label="dict.label"
+							:value="dict.value"></el-option>
+					</el-select>
+				</el-form-item>
+                <el-form-item label="标识:">
+                  <el-select
+                    style="width: 160px"
+                    multiple
+                    v-model="queryParams.flags"
+                    collapse-tags
+                    collapse-tags-tooltip
+                    clearable
+                    placeholder="请选择标识"
+                  >
+                    <el-option
+                      v-for="item in is_identification"
+                      :key="item.value"
+                      :label="item.label"
+                      :value="item.value"
+                    ></el-option>
+                  </el-select>
+                </el-form-item>
+                <el-form-item class="section-title" label="请选择当前工段:">
+                    <el-select-v2 v-model="queryParams.deptId" :options="deptList" placeholder="请选择工段"
+                        style="width: 120px" />
+                </el-form-item>
+                <el-form-item label="盘点状态:">
+					<el-select v-model="queryParams.isTaksStock" clearable placeholder="请选择盘点状态" style="width: 145px">
+						<el-option v-for="dict in is_taks_stock" :key="dict.value" :label="dict.label"
+							:value="dict.value"></el-option>
+					</el-select>
+				</el-form-item>
+                <el-form-item style="margin-left: 0">
+                    <el-button type="info" icon="Search" @click="handleQuery">搜索
+                    </el-button>
+                </el-form-item>
+            </el-form>
+      <div class="el-table-container">
+        <div class="el-table-inner-container">
+          <el-table v-loading="loading" :data="dataList" size="small" border height="100%">
+            <el-table-column label="行号" type="index" align="center" width="48" />
+            <el-table-column label="计划单号" align="center" prop="productionPlanNo" width="104" />
+            <el-table-column label="批次号" align="center" prop="lotCode" width="104" />
+            <el-table-column label="产品描述" align="center" prop="productDescription"  />
+            <el-table-column label="生产状态" prop="isProductStatus" width="90" align="center" >
+                            <template #default="scope">
+                                <dict-tag :options="inventory_production_status" :value="scope.row.isProductStatus" />
+                            </template>
+                        </el-table-column>
+            <el-table-column label="工段" align="center" prop="deptName" width="100" />
+            <el-table-column label="投入数" align="center" prop="prodNum" width="96" />
+            <el-table-column label="盘点数量" align="center" prop="taksStockNum" width="96" >
+              <template #default="scope">
+                <el-input-number
+                  v-if="scope.row.editStatus"
+                  v-model="scope.row.taksStockNum"
+                  controls-position="right"
+                  style="width: 100px"
+                  :min="0"
+                  @input="(val) => {handleChangeTaksStockNum(val, scope.row,scope.$index)}"
+                />
+                <div v-else>{{ scope.row.taksStockNum }}</div>
+              </template>
+            </el-table-column>
+            <el-table-column label="标识" width="300" align="center">
+            <template #default="scope">
+              <el-tag
+                v-if="scope.row.isWaste == 1"
+                class="spacing"
+                type="danger"
+                >{{ "批废" }}</el-tag
+              >
+              <el-tag
+                v-if="scope.row.isAmend == 1"
+                class="spacing"
+                type="danger"
+                >{{ "工艺修改" }}</el-tag
+              >
+              <el-tag
+                v-if="scope.row.isWasteRecycling == 1"
+                class="spacing"
+                type="primary"
+                >{{ "废品回用" }}</el-tag
+              >
+            </template>
+          </el-table-column>
+          <el-table-column label="盘点状态" prop="isTaksStock" width="200" align="center" >
+            <template #default="scope">
+                <el-select
+                  v-model="scope.row.isTaksStock"
+                  placeholder="请选择盘点状态"
+                  style="width: 160px"
+                  v-if="scope.row.editStatus"
+                  @change="(val) => {handleChangeTaksStock(val, scope.row,scope.$index)}"
+                >
+                  <el-option
+                    v-for="dict in is_taks_stock"
+                    :key="dict.value"
+                    :label="dict.label"
+                    :value="dict.value"
+                  ></el-option>
+                </el-select>
+                <div v-else>
+                  <dict-tag :options="is_taks_stock" :value="scope.row.isTaksStock" />
+                </div>
+              </template>
+                        </el-table-column>
+                        <el-table-column label="操作" width="160" align="center" v-if="detailInfo.status !=2">
+              <template #default="scope">
+                <el-button
+                link
+                icon="Check"
+                  v-if="scope.row.editStatus"
+                  type="success"
+                  @click="handleSave(scope.row)"
+                  >保存</el-button
+                >
+                <el-button
+                link
+                icon="Edit"
+                  v-else
+                  type="warning"
+                  @click="() => (scope.row.editStatus = true)"
+                  v-hasPermi="['business:inventoryCheck:editDetail']"
+                  >编辑</el-button
+                >
+                <el-button
+                link
+                icon="Close"
+                  v-if="scope.row.editStatus"
+                  type="danger"
+                  @click="handleCancel(scope.row, scope.$index)"
+                  >取消</el-button
+                >
+              </template>
+            </el-table-column>
+          </el-table>
+        </div>
+      
+      </div>
+             <!-- 分页 -->
+             <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
+                v-model:limit="queryParams.pageSize" @pagination="getList" />
+    </div>
+  </el-drawer>
+</template>
+<script setup>
+import {
+  listTaksStockLot,updateTaksStockLot
+} from "@/api/business/taksStockLot";
+import { getDeptList } from "@/api/business/planDetailSubDetail.js";
+import { ref } from "vue";
+const { proxy } = getCurrentInstance();
+/** 字典 */
+const { is_identification } = proxy.useDict("is_identification");
+const { is_taks_stock } = proxy.useDict("is_taks_stock");
+const { inventory_production_status } = proxy.useDict("inventory_production_status");
+
+/** 表单抽屉 页变量 */
+const loading = ref(false);
+const visible = ref(false);
+const detailInfo = ref({});
+const total = ref(0)
+const isDispatch = ref(false)
+const deptList = ref([])
+const dataList = ref([])
+/** 查询对象 */
+const queryParams = ref({
+  pageNum: 1,
+  pageSize: 10,
+  productDescription: "",
+  lotCode: "",
+  deptId: null,
+  flags: null,
+  isTaksStock:null
+});
+
+/****************************  方法区  ****************************/
+/** 打开抽屉 */
+const open = (row) => {
+  visible.value = true;
+  reset();
+  detailInfo.value = proxy.deepClone(row);
+  getDeptList().then((response) => {
+        deptList.value = response.data.rows;
+        isDispatch.value = response.data.others.isDispatch;
+        loading.value = false;
+        if (isDispatch.value) {
+            deptList.value.unshift({ label: "全部", value: "0" });
+        } 
+        queryParams.value.deptId = deptList.value[0].value;
+        queryParams.value.takeStockPeriodId = row.id
+        getList();
+    });
+}
+function getList() {
+  listTaksStockLot(queryParams.value).then(res =>{
+    res.rows.forEach(element => {
+      element.isTaksStock = element.isTaksStock +""
+      element.taksStockNum = Number(element.taksStockNum)
+    });
+    dataList.value = res.rows;
+    total.value = res.total;
+  })
+}
+function handleSave(row) {
+  updateTaksStockLot(row).then(res =>{
+    if(res.code == 200){
+      proxy.$modal.msgSuccess("保存成功");
+      getList()
+    }
+  })
+}
+function handleChangeTaksStock(value,row,index) {
+if(value == 0) {
+  dataList.value[index].taksStockNum = 0
+}
+}
+function handleChangeTaksStockNum(value,row,index) {
+  if(value != 0) {
+    dataList.value[index].isTaksStock = "1"
+  }
+}
+function handleCancel(row,index) {
+  dataList.value[index].editStatus = false
+  getList()
+}
+function handleQuery() {
+  getList();
+}
+/** 取消按钮 */
+const cancel = () => {
+  visible.value = false;
+  reset();
+};
+
+/** 表单重置 */
+const reset = () => {
+  queryParams.value = {
+  pageNum: 1,
+  pageSize: 10,
+  productDescription: "",
+  lotCode: "",
+  deptId: null,
+  flags: null,
+  isTaksStock:null
+  };
+  dataList.value = [];
+};
+
+/** 暴露给父组件的方法 */
+defineExpose({
+  open,
+});
+</script>

+ 240 - 0
src/views/business/inventoryCheck/index.vue

@@ -0,0 +1,240 @@
+<template>
+    <div class="page-container row-container">
+        <!-- 左侧区域 -->
+        <section class="list-part-container" style="flex: 3">
+            <!-- 搜索区 -->
+            <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true"
+                style="margin-right: 0px">
+                <el-form-item class="section-title" label="盘点" />
+                <el-form-item label="创建时间:">
+                    <el-date-picker v-model="queryParams.createStartTime" type="date" value-format="YYYY-MM-DD"
+                        :editable="false" clearable placeholder="请选择" style="width: 130px"  />
+                    <span>~</span>
+                    <el-date-picker v-model="queryParams.createEndTime" type="date" value-format="YYYY-MM-DD"
+                        :editable="false" clearable placeholder="请选择" style="width: 130px"  />
+                </el-form-item>
+                <el-form-item label="开始时间:">
+                    <el-date-picker v-model="queryParams.startStartTime" type="date" value-format="YYYY-MM-DD"
+                        :editable="false" clearable placeholder="请选择" style="width: 130px"  />
+                    <span>~</span>
+                    <el-date-picker v-model="queryParams.startEndTime" type="date" value-format="YYYY-MM-DD"
+                        :editable="false" clearable placeholder="请选择" style="width: 130px" />
+                </el-form-item>
+                <el-form-item label="结束时间:">
+                    <el-date-picker v-model="queryParams.endStartTime" type="date" value-format="YYYY-MM-DD"
+                        :editable="false" clearable placeholder="请选择" style="width: 130px"  />
+                    <span>~</span>
+                    <el-date-picker v-model="queryParams.endEndTime" type="date" value-format="YYYY-MM-DD"
+                        :editable="false" clearable placeholder="请选择" style="width: 130px"  />
+                </el-form-item>
+                <el-form-item label="状态:">
+					<el-select v-model="queryParams.status" clearable placeholder="请选择盘点状态" style="width: 145px">
+						<el-option v-for="dict in take_stock_status" :key="dict.value" :label="dict.label"
+							:value="dict.value"></el-option>
+					</el-select>
+				</el-form-item>
+                <el-form-item label="备注:">
+                    <el-input placeholder="请输入备注" v-model.trim="queryParams.remark" @keydown.enter.prevent clearable
+                        style="width: 120px" />
+                </el-form-item>
+                <el-form-item style="margin-left: 0">
+                    <el-button type="info" icon="Search" @click="handleQuery">搜索
+                    </el-button>
+                    <el-button v-show=" !hasAlreadyAddTakeStock && !hasAlreadyTakeStock" v-hasPermi="['business:inventoryCheck:add']"
+                     type="primary" icon="Plus" @click="handleAdd">新增</el-button>
+                </el-form-item>
+            </el-form>
+            <div class="el-table-container">
+                <div class="el-table-inner-container">
+                    <el-table ref="takeStockPeriodTable" :data="takeStockPeriodList" v-loading="loading"
+                        highlight-current-row height="100%">
+                        <el-table-column type="index" label="行号" width="50" align="center" />
+                        <el-table-column label="创建时间" prop="createTime" width="200" align="center" />
+                        <el-table-column label="开始时间" prop="startTime" width="200" align="center" />
+                        <el-table-column label="结束时间" prop="endTime" width="200" align="center" />
+                        <el-table-column label="盘点状态" prop="status" width="80" align="center" >
+                            <template #default="scope">
+                                <dict-tag :options="take_stock_status" :value="scope.row.status" />
+                            </template>
+                        </el-table-column>
+                        <el-table-column label="备注" prop="remark"  align="center" >
+                            <template #default="scope">
+									<div v-if="scope.row.editStatus">
+										<el-input v-model.trim="scope.row.remark" size="small"
+											placeholder="请输入备注" />
+									</div>
+									<div v-else>{{ scope.row.remark }}</div>
+                            </template>
+                            </el-table-column>
+                            <el-table-column label="操作" align="center"  width="250">
+                                    <template #default="scope">
+                                    <el-button v-show="!scope.row.editStatus" v-hasPermi="['business:inventoryCheck:edit']"
+                                      link type="warning" icon="Edit" @click="handleUpdate(scope.row)"
+                                      >
+                                        编辑
+                                    </el-button>
+                                    <el-button v-show="!scope.row.editStatus" v-hasPermi="['business:inventoryCheck:view']"
+                                     link type="primary" icon="View" @click="handleView(scope.row)"
+                                      >
+                                        查看
+                                    </el-button>
+                                    <el-button v-show="!scope.row.editStatus && scope.row.status == 0" v-hasPermi="['business:inventoryCheck:start']" 
+                                    link type="success" icon="Open" @click="handleStartTakeStock(scope.row)"
+                                       >
+                                        开始盘点
+                                    </el-button>
+                                    <el-button v-show="!scope.row.editStatus && scope.row.status ==1" link v-hasPermi="['business:inventoryCheck:end']"
+                                     type="danger" icon="TurnOff" @click="handleEndTakeStock(scope.row)"
+                                       >
+                                        结束盘点
+                                    </el-button>
+                                    <el-button
+                                    link
+                                        v-if="scope.row.editStatus"
+                                        icon="Close"
+                                        type="danger"
+                                        @click="handleCancel(scope.row, scope.$index)"
+                                        >取消</el-button
+                                        >
+                                    <el-button
+                                    link
+                                    icon="Check"
+                                    v-if="scope.row.editStatus"
+                                    type="success"
+                                    @click="handleSave(scope.row)"
+                                    >保存</el-button
+                                    >
+                                    </template>
+          </el-table-column>
+                    </el-table>
+                </div>
+            </div>
+            <!-- 分页 -->
+            <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
+                v-model:limit="queryParams.pageSize" @pagination="getTakeStockPeriodList" />
+        </section>
+        <!-- 盘点详情 -->
+        <inventory-check-form ref="inventoryCheckFormRef" />
+
+    </div>
+</template>
+
+<script setup name="inventoryCheck">
+import { listTakeStockPeriod ,addTakeStockPeriod ,updateTakeStockPeriod} from "@/api/business/takeStockPeriod";
+
+import inventoryCheckForm from "./form.vue";
+import { ref } from "vue";
+const { proxy } = getCurrentInstance();
+/** 字典 */
+const { take_stock_status } = proxy.useDict("take_stock_status");
+
+/** 盘点 */
+const takeStockPeriodTable = ref(null);
+const takeStockPeriodList = ref([])
+//列表中是否已经存在开始盘点的数据
+const hasAlreadyTakeStock = ref(false);
+//列表中已经存在新增的盘点
+const hasAlreadyAddTakeStock = ref(false);
+const loading = ref(false);
+const total = ref(0);
+
+const queryParams = ref({
+   status:null,
+   createStartTime:null,
+   createEndTime:null,
+   startTimeStr:null,
+   startTimeEnd:null,
+   endTimeStr:null,
+   endTimeEnd:null,
+   remark:null,
+   pageNum: 1,
+   pageSize: 10,
+});
+
+/***********************  工段相关事件  ****************************/
+
+function getTakeStockPeriodList() {
+    loading.value = true;
+    listTakeStockPeriod(queryParams.value).then(res =>{
+        takeStockPeriodList.value = res.rows;
+        hasAlreadyTakeStock.value = res.others.hasAddTakeStockStatus
+        hasAlreadyAddTakeStock.value = res.others.hasTakeStockStatus
+        total.value = res.total;
+    })
+    loading.value = false
+}
+//新增
+function handleAdd() {
+    takeStockPeriodList.value.unshift({createTime:proxy.moment().format("YYYY-MM-DD HH:mm:ss"),startTime:null,endTime:null,status:"0",remark:null, editStatus: true })
+    hasAlreadyAddTakeStock.value = true
+}
+//保存按钮
+function handleSave(row) {
+    console.log(row)
+    addTakeStockPeriod(row).then(res => {
+        if(res.code === 200) {
+            getTakeStockPeriodList()
+        }
+    })
+}
+//查看按钮
+function handleView(row) {
+    proxy.$refs.inventoryCheckFormRef.open(row);
+}
+//结束盘点
+function handleEndTakeStock(row) {
+    proxy.$modal
+    .confirm("是否确认结束盘点?")
+    .then(function () {
+    row.endTime = proxy.moment().format("YYYY-MM-DD HH:mm:ss")
+    row.status = 2
+    updateTakeStockPeriod(row).then(res => {
+        if(res.code === 200) {
+            proxy.$modal.msgSuccess("已成功结束盘点");
+            getTakeStockPeriodList()
+        }
+    })
+    })
+}
+//编辑按钮
+function handleUpdate(row) {
+    row.editStatus = true
+}
+//开始盘点
+function handleStartTakeStock(row) {
+    proxy.$modal
+    .confirm("是否确认开始盘点?")
+    .then(function () {
+    row.startTime = proxy.moment().format("YYYY-MM-DD HH:mm:ss")
+    row.status = 1
+    updateTakeStockPeriod(row).then(res => {
+        if(res.code === 200) {
+            proxy.$modal.msgSuccess("已成功开始盘点");
+            getTakeStockPeriodList()
+        }
+    })
+    })
+ 
+}
+/** 搜索按钮操作 */
+function handleQuery() {
+    getTakeStockPeriodList();
+}
+function handleCancel(row,index) {
+    if(row.id) {
+        takeStockPeriodList.value[index].editStatus = false    
+    }else {
+        getTakeStockPeriodList()
+    }
+  
+ 
+}
+onMounted(() => {
+    getTakeStockPeriodList();
+});
+</script>
+<style scoped>
+.el-form--inline .el-form-item {
+    margin-right: 20px;
+}
+</style>