huminmin
4 天以前 70bb972b03c0036c3699bbc561b32c5ec3cc8aef
src/views/productionManagement/workOrder/index.vue
@@ -5,86 +5,112 @@
      <div class="search-row">
        <div class="search-item">
          <span class="search_title">工单编号:</span>
          <el-input v-model="searchForm.workOrderNo"
                    style="width: 240px"
                    placeholder="请输入"
                    @change="handleQuery"
                    clearable
                    prefix-icon="Search"/>
          <el-input
            v-model="searchForm.workOrderNo"
            style="width: 240px"
            placeholder="请输入"
            @change="handleQuery"
            clearable
            prefix-icon="Search"
          />
        </div>
        <div class="search-item">
          <el-button type="primary"
                     @click="handleQuery">搜索
          </el-button>
          <span class="search_title">生产订单号:</span>
          <el-input
            v-model="searchForm.productOrderNpsNo"
            style="width: 240px"
            placeholder="请输入"
            @change="handleQuery"
            clearable
            prefix-icon="Search"
          />
        </div>
        <div class="search-item">
          <el-button type="primary" @click="handleQuery">搜索 </el-button>
        </div>
      </div>
    </div>
    <div class="table_list">
      <PIMTable rowKey="id"
                :column="tableColumn"
                :tableData="tableData"
                :page="page"
                :tableLoading="tableLoading"
                @pagination="pagination">
      <PIMTable
        rowKey="id"
        :column="tableColumn"
        :tableData="tableData"
        :page="page"
        :tableLoading="tableLoading"
        :rowClassName="rowClassName"
        @pagination="pagination"
      >
        <template #completionStatus="{ row }">
          <el-progress :percentage="toProgressPercentage(row?.completionStatus)"
                       :color="progressColor(toProgressPercentage(row?.completionStatus))"
                       :status="toProgressPercentage(row?.completionStatus) >= 100 ? 'success' : ''"/>
          <el-progress
            :percentage="toProgressPercentage(row?.completionStatus)"
            :color="progressColor(toProgressPercentage(row?.completionStatus))"
            :status="
              toProgressPercentage(row?.completionStatus) >= 100
                ? 'success'
                : ''
            "
          />
        </template>
      </PIMTable>
    </div>
    <el-dialog v-model="editDialogVisible"
               title="编辑时间"
               width="500px">
      <el-form :model="editrow"
               label-width="120px">
    <el-dialog v-model="editDialogVisible" title="编辑时间" width="500px">
      <el-form :model="editrow" label-width="120px">
        <el-form-item label="计划开始时间">
          <el-date-picker v-model="editrow.planStartTime"
                          type="date"
                          placeholder="请选择"
                          value-format="YYYY-MM-DD"
                          style="width: 300px"/>
          <el-date-picker
            v-model="editrow.planStartTime"
            type="date"
            placeholder="请选择"
            value-format="YYYY-MM-DD"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item label="计划结束时间">
          <el-date-picker v-model="editrow.planEndTime"
                          type="date"
                          placeholder="请选择"
                          value-format="YYYY-MM-DD"
                          style="width: 300px"/>
          <el-date-picker
            v-model="editrow.planEndTime"
            type="date"
            placeholder="请选择"
            value-format="YYYY-MM-DD"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item label="实际开始时间">
          <el-date-picker v-model="editrow.actualStartTime"
                          type="date"
                          placeholder="请选择"
                          value-format="YYYY-MM-DD"
                          style="width: 300px"/>
          <el-date-picker
            v-model="editrow.actualStartTime"
            type="date"
            placeholder="请选择"
            value-format="YYYY-MM-DD"
            style="width: 300px"
          />
        </el-form-item>
        <el-form-item label="实际结束时间">
          <el-date-picker v-model="editrow.actualEndTime"
                          type="date"
                          placeholder="请选择"
                          value-format="YYYY-MM-DD"
                          style="width: 300px"/>
          <el-date-picker
            v-model="editrow.actualEndTime"
            type="date"
            placeholder="请选择"
            value-format="YYYY-MM-DD"
            style="width: 300px"
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary"
                     @click="handleUpdate">确定</el-button>
          <el-button type="primary" @click="handleUpdate">确定</el-button>
          <el-button @click="editDialogVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog>
    <el-dialog v-model="transferCardVisible"
               title="流转卡"
               width="1000px">
    <el-dialog v-model="transferCardVisible" title="流转卡" width="1000px">
      <div class="transfer-card-title">工单流转卡</div>
      <div class="transfer-card-container">
        <div class="transfer-card-info">
          <div class="info-group">
            <div class="info-item">
              <span class="info-label">工单编号</span>
              <span class="info-value">{{ transferCardRowData.workOrderNo }}</span>
              <span class="info-value">{{
                transferCardRowData.workOrderNo
              }}</span>
            </div>
            <!-- <div class="info-item">
              <span class="info-label">产品编号</span>
@@ -92,11 +118,19 @@
            </div> -->
            <div class="info-item">
              <span class="info-label">产品名称</span>
              <span class="info-value">{{ transferCardRowData.productName }}</span>
              <span class="info-value">{{
                transferCardRowData.productName
              }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">产品规格</span>
              <span class="info-value">{{ transferCardRowData.model }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">料号</span>
              <span class="info-value">{{
                transferCardRowData.materialCode
              }}</span>
            </div>
            <!-- <div class="info-item">
              <span class="info-label">工单状态</span>
@@ -111,11 +145,15 @@
            <div class="info-item">
              <span class="info-label">计划开始时间</span>
              <span class="info-value">{{ transferCardRowData.planStartTime }}</span>
              <span class="info-value">{{
                transferCardRowData.planStartTime
              }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">计划结束时间</span>
              <span class="info-value">{{ transferCardRowData.planEndTime }}</span>
              <span class="info-value">{{
                transferCardRowData.planEndTime
              }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">备注</span>
@@ -125,11 +163,15 @@
          <div class="info-group">
            <div class="info-item">
              <span class="info-label">需求数量</span>
              <span class="info-value">{{ transferCardRowData.planQuantity }}</span>
              <span class="info-value">{{
                transferCardRowData.planQuantity
              }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">完成数量</span>
              <span class="info-value">{{ transferCardRowData.completeQuantity }}</span>
              <span class="info-value">{{
                transferCardRowData.completeQuantity
              }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">良品数量</span>
@@ -141,104 +183,145 @@
            </div>
            <div class="info-item">
              <span class="info-label">实际开始时间</span>
              <span class="info-value">{{ transferCardRowData.actualStartTime }}</span>
              <span class="info-value">{{
                transferCardRowData.actualStartTime
              }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">实际结束时间</span>
              <span class="info-value">{{ transferCardRowData.actualEndTime }}</span>
              <span class="info-value">{{
                transferCardRowData.actualEndTime
              }}</span>
            </div>
          </div>
        </div>
        <div class="transfer-card-qr">
          <div class="qr-container">
            <img :src="transferCardQrUrl"
                 alt="流转卡二维码"
                 style="width: 200px; height: 200px;"/>
            <img
              :src="transferCardQrUrl"
              alt="流转卡二维码"
              style="width: 200px; height: 200px"
            />
            <!-- <div class="qr-tip"
                 style="margin-top: 10px; text-align: center;">流转卡二维码</div> -->
          </div>
        </div>
      </div>
      <div class="print-button-container"
           style=" text-align: center;
      margin-bottom: 40px;">
        <el-button type="primary"
                   style="margin-top: 20px;"
                   @click="printTransferCard">打印流转卡
      <div
        class="print-button-container"
        style="text-align: center; margin-bottom: 40px"
      >
        <el-button
          type="primary"
          style="margin-top: 20px"
          @click="printTransferCard"
          >打印流转卡
        </el-button>
      </div>
    </el-dialog>
    <el-dialog v-model="reportDialogVisible"
               title="报工"
               width="500px">
      <el-form ref="reportFormRef"
               :model="reportForm"
               :rules="reportFormRules"
               label-width="120px">
        <el-form-item label="待生产数量">
          <el-input v-model="reportForm.planQuantity"
                    readonly
                    style="width: 300px"/>
        </el-form-item>
        <el-form-item label="本次生产数量" prop="quantity">
          <el-input v-model.number="reportForm.quantity"
                    type="number"
                    min="1"
                    step="1"
                    style="width: 300px"
                    placeholder="请输入本次生产数量"
                    @input="handleQuantityInput"/>
        </el-form-item>
        <el-form-item label="报废数量" prop="scrapQty">
          <el-input v-model.number="reportForm.scrapQty"
                    type="number"
                    min="0"
                    step="1"
                    style="width: 300px"
                    placeholder="请输入报废数量"
                    @input="handleScrapQtyInput"/>
        </el-form-item>
        <el-form-item label="班组信息">
          <el-select v-model="reportForm.userId"
                     style="width: 300px"
                     placeholder="请选择班组信息"
                     clearable
                     filterable
                     @change="handleUserChange">
            <el-option v-for="user in userOptions"
                       :key="user.userId"
                       :label="user.userName"
                       :value="user.userId"/>
          </el-select>
        </el-form-item>
    <el-dialog v-model="reportDialogVisible" title="报工" width="800px">
      <el-form
        ref="reportFormRef"
        :model="reportForm"
        :rules="reportFormRules"
        label-width="120px"
      >
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="待生产数量">
              <el-input
                v-model="reportForm.planQuantity"
                readonly
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="本次生产数量" prop="quantity">
              <el-input
                v-model.number="reportForm.quantity"
                type="number"
                min="1"
                step="1"
                style="width: 100%"
                placeholder="请输入本次生产数量"
                @input="handleQuantityInput"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报废数量" prop="scrapQty">
              <el-input
                v-model.number="reportForm.scrapQty"
                type="number"
                min="0"
                step="1"
                style="width: 100%"
                placeholder="请输入报废数量"
                @input="handleScrapQtyInput"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="班组信息">
              <el-select
                v-model="reportForm.userId"
                style="width: 100%"
                placeholder="请选择班组信息"
                clearable
                filterable
                @change="handleUserChange"
              >
                <el-option
                  v-for="user in userOptions"
                  :key="user.userId"
                  :label="user.userName"
                  :value="user.userId"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <ProductionRecordForm
          ref="productionRecordFormRef"
          :list="processParamList"
        />
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary"
                     @click="handleReport">确定</el-button>
          <el-button type="primary" @click="handleReport">确定</el-button>
          <el-button @click="reportDialogVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog>
    <FilesDia ref="workOrderFilesRef"/>
    <FilesDia ref="workOrderFilesRef" />
    <CopperPrintingForm
        v-if="copperPrintingFormVisible"
        v-model:isShow="copperPrintingFormVisible"
        :isEdit="true"
        :row="currentReportRowData"
        @refreshData="getList"/>
      v-if="copperPrintingFormVisible"
      v-model:isShow="copperPrintingFormVisible"
      :isEdit="true"
      :row="currentReportRowData"
      @refreshData="getList"
    />
    <VoltageSortingForm
        v-if="voltageSortingFormVisible"
        v-model:isShow="voltageSortingFormVisible"
        :isEdit="true"
        :row="currentReportRowData"
        @refreshData="getList"/>
      v-if="voltageSortingFormVisible"
      v-model:isShow="voltageSortingFormVisible"
      :isEdit="true"
      :row="currentReportRowData"
      @refreshData="getList"
    />
    <GranulationForm
      v-if="granulationFormVisible"
      v-model:isShow="granulationFormVisible"
      :isEdit="true"
      :row="currentReportRowData"
      @refreshData="getList"
    />
  </div>
</template>
<script setup>
import {onMounted, ref, nextTick} from "vue";
import {ElMessageBox} from "element-plus";
import { onMounted, ref, nextTick } from "vue";
import { ElMessageBox } from "element-plus";
import dayjs from "dayjs";
import {
  productWorkOrderPage,
@@ -246,28 +329,39 @@
  addProductMain,
  downProductWorkOrder,
} from "@/api/productionManagement/workOrder.js";
import {getUserProfile, userListNoPageByTenantId} from "@/api/system/user.js";
import { getUserProfile, userListNoPageByTenantId } from "@/api/system/user.js";
import QRCode from "qrcode";
import {getCurrentInstance, reactive, toRefs} from "vue";
import { getCurrentInstance, reactive, toRefs } from "vue";
import FilesDia from "./components/filesDia.vue";
import { listPage as listProcessParamPage } from "@/api/productionManagement/productProcessParameter.js";
const {proxy} = getCurrentInstance();
const {priority_type} = proxy.useDict("priority_type");
const { proxy } = getCurrentInstance();
const { priority_type } = proxy.useDict("priority_type");
const CopperPrintingForm = defineAsyncComponent(() => import("./components/CopperPrintingForm.vue"));
const VoltageSortingForm = defineAsyncComponent(() => import("./components/VoltageSortingForm.vue"));
const CopperPrintingForm = defineAsyncComponent(() =>
  import("./components/CopperPrintingForm.vue")
);
const VoltageSortingForm = defineAsyncComponent(() =>
  import("./components/VoltageSortingForm.vue")
);
const ProductionRecordForm = defineAsyncComponent(() =>
  import("./components/ProductionRecordForm.vue")
);
const GranulationForm = defineAsyncComponent(() =>
  import("./components/GranulationForm.vue")
);
const tableColumn = ref([
  {
    label: "优先级",
    prop: "priority",
    width: '100px',
    width: "100px",
    dataType: "tag",
    formatData: val => proxy.selectDictLabel(priority_type.value, val),
    formatType: val => {
    formatData: (val) => proxy.selectDictLabel(priority_type.value, val),
    formatType: (val) => {
      const v = Number(val);
      if (v === 0) return "danger";   // 红色
      if (v === 1) return "warning";  // 黄色
      if (v === 2) return "success";  // 绿色
      if (v === 0) return "danger"; // 红色
      if (v === 1) return "warning"; // 黄色
      if (v === 2) return "success"; // 绿色
      return "";
    },
  },
@@ -294,6 +388,10 @@
  {
    label: "规格",
    prop: "model",
  },
  {
    label: "料号",
    prop: "materialCode",
  },
  {
    label: "单位",
@@ -349,29 +447,29 @@
    operation: [
      {
        name: "编辑",
        clickFun: row => {
        clickFun: (row) => {
          handleEdit(row);
          handleEdit(row);
        },
      },
      {
        name: "流转卡",
        clickFun: row => {
        clickFun: (row) => {
          downloadAndPrintWorkOrder(row);
        },
      },
      {
        name: "附件",
        clickFun: row => {
        clickFun: (row) => {
          openWorkOrderFiles(row);
        },
      },
      {
        name: "报工",
        clickFun: row => {
        clickFun: (row) => {
          showReportDialog(row);
        },
        disabled: row => !row.isCanReport || row.planQuantity <= 0,
        disabled: (row) => !row.isCanReport || row.planQuantity <= 0,
      },
    ],
  },
@@ -383,6 +481,7 @@
const editDialogVisible = ref(false);
const copperPrintingFormVisible = ref(false);
const voltageSortingFormVisible = ref(false);
const granulationFormVisible = ref(false);
const transferCardVisible = ref(false);
const transferCardData = ref([]);
const transferCardQrUrl = ref("");
@@ -401,18 +500,23 @@
  productProcessRouteItemId: "",
  userId: "",
  productMainId: null,
  batchNo: "",
  otherData: {
    rows: [],
  },
});
const productionRecordFormRef = ref();
// 本次生产数量验证规则
const validateQuantity = (rule, value, callback) => {
  if (value === null || value === undefined || value === '') {
    callback(new Error('请输入本次生产数量'));
  if (value === null || value === undefined || value === "") {
    callback(new Error("请输入本次生产数量"));
    return;
  }
  const num = Number(value);
  // 整数且大于等于1
  if (isNaN(num) || !Number.isInteger(num) || num < 1) {
    callback(new Error('本次生产数量必须大于等于1'));
    callback(new Error("本次生产数量必须大于等于1"));
    return;
  }
  callback();
@@ -420,14 +524,14 @@
// 报废数量验证规则
const validateScrapQty = (rule, value, callback) => {
  if (value === null || value === undefined || value === '') {
  if (value === null || value === undefined || value === "") {
    callback();
    return;
  }
  const num = Number(value);
  // 整数且大于等于0
  if (isNaN(num) || !Number.isInteger(num) || num < 0) {
    callback(new Error('报废数量必须大于等于0'));
    callback(new Error("报废数量必须大于等于0"));
    return;
  }
  callback();
@@ -435,17 +539,23 @@
// 验证规则
const reportFormRules = {
  quantity: [
    {required: true, validator: validateQuantity, trigger: 'blur'}
  ],
  scrapQty: [
    {validator: validateScrapQty, trigger: 'blur'}
  ]
  quantity: [{ required: true, validator: validateQuantity, trigger: "blur" }],
  scrapQty: [{ validator: validateScrapQty, trigger: "blur" }],
};
const rowClassName = ({ row }) => {
  if (
    Number(row.completionStatus) > 0 &&
    Number(row.actualQualifiedRate) < Number(row.processQualifiedRate)
  ) {
    return "danger-row";
  }
  return "";
};
// 处理本次生产数量输入,限制必须大于等于1
const handleQuantityInput = (value) => {
  if (value === '' || value === null || value === undefined) {
  if (value === "" || value === null || value === undefined) {
    reportForm.quantity = null;
    return;
  }
@@ -474,7 +584,7 @@
// 处理报废数量
const handleScrapQtyInput = (value) => {
  if (value === '' || value === null || value === undefined) {
  if (value === "" || value === null || value === undefined) {
    reportForm.scrapQty = null;
    return;
  }
@@ -506,17 +616,18 @@
const data = reactive({
  searchForm: {
    workOrderNo: "",
    productOrderNpsNo: "",
  },
});
const {searchForm} = toRefs(data);
const toProgressPercentage = val => {
const { searchForm } = toRefs(data);
const toProgressPercentage = (val) => {
  const n = Number(val);
  if (!Number.isFinite(n)) return 0;
  if (n <= 0) return 0;
  if (n >= 100) return 100;
  return Math.round(n);
};
const progressColor = percentage => {
const progressColor = (percentage) => {
  const p = toProgressPercentage(percentage);
  if (p < 30) return "#f56c6c";
  if (p < 50) return "#e6a23c";
@@ -531,34 +642,34 @@
  page.current = 1;
  getList();
};
const pagination = obj => {
const pagination = (obj) => {
  page.current = obj.page;
  page.size = obj.limit;
  getList();
};
const getList = () => {
  tableLoading.value = true;
  const params = {...searchForm.value, ...page};
  const params = { ...searchForm.value, ...page };
  productWorkOrderPage(params)
      .then(res => {
        tableLoading.value = false;
        tableData.value = res.data.records;
        page.total = res.data.total;
      })
      .catch(() => {
        tableLoading.value = false;
      });
    .then((res) => {
      tableLoading.value = false;
      tableData.value = res.data.records;
      page.total = res.data.total;
    })
    .catch(() => {
      tableLoading.value = false;
    });
};
// 下载并打印工单流转卡(文件流)
const downloadAndPrintWorkOrder = async row => {
const downloadAndPrintWorkOrder = async (row) => {
  if (!row || !row.id) {
    proxy.$modal.msgError("缺少工单ID,无法下载流转卡");
    return;
  }
  const fileName = row.workOrderNo
      ? `工单流转卡_${row.workOrderNo}.xlsx`
      : "工单流转卡.xlsx";
    ? `工单流转卡_${row.workOrderNo}.xlsx`
    : "工单流转卡.xlsx";
  try {
    // 调用接口,以 responseType: 'blob' 获取文件流
    const blob = await downProductWorkOrder(row.id);
@@ -570,7 +681,9 @@
    // 创建 Blob URL
    const fileBlob =
        blob instanceof Blob ? blob : new Blob([blob], {type: blob.type || "application/octet-stream"});
      blob instanceof Blob
        ? blob
        : new Blob([blob], { type: blob.type || "application/octet-stream" });
    const url = window.URL.createObjectURL(fileBlob);
    // 创建隐藏 iframe,用于触发浏览器打印
@@ -600,7 +713,7 @@
  }
};
const showTransferCard = async row => {
const showTransferCard = async (row) => {
  transferCardRowData.value = row;
  const qrContent = String(row.id);
@@ -612,65 +725,93 @@
  window.print();
};
const handleEdit = row => {
const handleEdit = (row) => {
  editrow.value = JSON.parse(JSON.stringify(row));
  editDialogVisible.value = true;
};
const handleUpdate = () => {
  updateProductWorkOrder(editrow.value)
      .then(res => {
        proxy.$modal.msgSuccess("提交成功");
        editDialogVisible.value = false;
        getList();
      })
      .catch(() => {
        ElMessageBox.alert("修改失败", "提示", {
          confirmButtonText: "确定",
        });
    .then((res) => {
      proxy.$modal.msgSuccess("提交成功");
      editDialogVisible.value = false;
      getList();
    })
    .catch(() => {
      ElMessageBox.alert("修改失败", "提示", {
        confirmButtonText: "确定",
      });
    });
};
const showReportDialog = row => {
const processParamPage = reactive({
  current: 1,
  size: 9999,
  total: 0,
});
const getProcessParamList = async (row) => {
  const params = {
    processId: row.processId,
    ...processParamPage,
  };
  const res = await listProcessParamPage(params);
  return res.data.records;
};
const processParamList = ref([]);
const showReportDialog = async (row) => {
  currentReportRowData.value = row;
  if (row.processName === '印铜' || row.processName === '印银') {
    copperPrintingFormVisible.value = true
    return
  }
  if (row.processName === '电压分选') {
    voltageSortingFormVisible.value = true
  if (row.processName === "印铜" || row.processName === "印银") {
    copperPrintingFormVisible.value = true;
    return;
  }
  if (row.processName === "电压分选") {
    voltageSortingFormVisible.value = true;
    return;
  }
  if (row.processName === "造粒") {
    granulationFormVisible.value = true;
    return;
  }
  processParamList.value = await getProcessParamList(row);
  reportForm.planQuantity = row.planQuantity;
  reportForm.quantity = row.quantity !== undefined && row.quantity !== null ? row.quantity : null;
  reportForm.quantity =
    row.quantity !== undefined && row.quantity !== null ? row.quantity : null;
  reportForm.productProcessRouteItemId = row.productProcessRouteItemId;
  reportForm.batchNo = row.batchNo;
  reportForm.workOrderId = row.id;
  reportForm.reportWork = row.reportWork;
  reportForm.productMainId = row.productMainId;
  reportForm.scrapQty = row.scrapQty !== undefined && row.scrapQty !== null ? row.scrapQty : null;
  reportForm.scrapQty =
    row.scrapQty !== undefined && row.scrapQty !== null ? row.scrapQty : null;
  nextTick(() => {
    reportFormRef.value?.clearValidate();
  });
  // 获取当前登录用户信息,设置为默认选中
  getUserProfile()
      .then(res => {
        if (res.code === 200) {
          reportForm.userId = res.data.userId;
          reportForm.userName = res.data.userName;
        }
      })
      .catch(err => {
        console.error("获取用户信息失败", err);
      });
    .then((res) => {
      if (res.code === 200) {
        reportForm.userId = res.data.userId;
        reportForm.userName = res.data.userName;
      }
    })
    .catch((err) => {
      console.error("获取用户信息失败", err);
    });
  reportDialogVisible.value = true;
};
const openWorkOrderFiles = row => {
const openWorkOrderFiles = (row) => {
  workOrderFilesRef.value?.openDialog(row);
};
const handleReport = () => {
const handleReport = async () => {
  const data = await productionRecordFormRef.value.submitData();
  if (!data) {
    return;
  }
  reportForm.otherData.rows = data || [];
  reportFormRef.value?.validate((valid) => {
    if (!valid) {
      return false;
@@ -684,7 +825,11 @@
    }
    // 验证本次生产数量
    if (reportForm.quantity === null || reportForm.quantity === undefined || reportForm.quantity === '') {
    if (
      reportForm.quantity === null ||
      reportForm.quantity === undefined ||
      reportForm.quantity === ""
    ) {
      ElMessageBox.alert("请输入本次生产数量", "提示", {
        confirmButtonText: "确定",
      });
@@ -692,7 +837,10 @@
    }
    const quantity = Number(reportForm.quantity);
    const scrapQty = reportForm.scrapQty === null || reportForm.scrapQty === undefined || reportForm.scrapQty === ''
    const scrapQty =
      reportForm.scrapQty === null ||
      reportForm.scrapQty === undefined ||
      reportForm.scrapQty === ""
        ? 0
        : Number(reportForm.scrapQty);
@@ -722,11 +870,12 @@
    const submitData = {
      ...reportForm,
      quantity: quantity,
      scrapQty: scrapQty
      scrapQty: scrapQty,
      otherData: JSON.stringify(reportForm.otherData),
    };
    // console.log(submitData);
    addProductMain(submitData).then(res => {
    addProductMain(submitData).then((res) => {
      if (res.code === 200) {
        proxy.$modal.msgSuccess("报工成功");
        reportDialogVisible.value = false;
@@ -743,20 +892,22 @@
// 获取用户列表
const getUserList = () => {
  userListNoPageByTenantId()
      .then(res => {
        if (res.code === 200) {
          userOptions.value = res.data || [];
        }
      })
      .catch(err => {
        console.error("获取用户列表失败", err);
      });
    .then((res) => {
      if (res.code === 200) {
        userOptions.value = res.data || [];
      }
    })
    .catch((err) => {
      console.error("获取用户列表失败", err);
    });
};
// 用户选择变化时更新 userName
const handleUserChange = (userId) => {
  if (userId) {
    const selectedUser = userOptions.value.find(user => user.userId === userId);
    const selectedUser = userOptions.value.find(
      (user) => user.userId === userId
    );
    if (selectedUser) {
      reportForm.userName = selectedUser.userName;
    }
@@ -835,7 +986,11 @@
}
</style>
<style lang="scss">
<style lang="scss" scoped>
:deep(.danger-row td) {
  color: #e95a66 !important;
}
@media print {
  @page {
    size: landscape;