zhangwencui
7 小时以前 8d48fa86c9096f6bac90e83ed779e5a5b62b0fc7
src/views/productionManagement/productionReporting/index.vue
@@ -4,18 +4,26 @@
      <el-form :model="searchForm"
               :inline="true">
        <el-form-item label="生产订单号:">
          <el-input v-model="searchForm.orderNo"
          <el-input v-model="searchForm.npsNo"
                    placeholder="请输入"
                    clearable
                    style="width: 160px;"
                    @keyup.enter="handleQuery" />
        </el-form-item>
        <el-form-item label="班组:">
          <el-input v-model="searchForm.teamName"
                    placeholder="请输入"
                    clearable
                    style="width: 160px;"
                    @keyup.enter="handleQuery" />
          <el-select v-model="searchForm.schedule"
                     placeholder="请选择"
                     clearable
                     style="width: 160px;"
                     @keyup.enter="handleQuery">
            <el-option label="白班"
                       value="白班" />
            <el-option label="夜班"
                       value="夜班" />
          </el-select>
          <!-- <el-input v-model="searchForm.schedule"
                    placeholder="请输入""
                    @keyup.enter="handleQuery" /> -->
        </el-form-item>
        <el-form-item label="产品名称:">
          <el-input v-model="searchForm.productName"
@@ -46,49 +54,53 @@
                :isSelection="false"
                @selection-change="handleSelectionChange"
                @pagination="pagination">
        <template #outputVolume="{ row }">
          <span style="font-weight: bold;color: #409eff;">{{ row.outputVolume }}</span><span style="margin-left: 5px;color: #909399;">方</span>
        <template #totalQuantity="{ row }">
          <span style="font-weight: bold;color: #409eff;">{{ row.totalQuantity }}</span><span style="margin-left: 5px;color: #909399;">方</span>
        </template>
        <template #unqualifiedVolume="{ row }">
          <span style="font-weight: bold;color: #b43434;">{{ row.unqualifiedVolume }}</span><span style="margin-left: 5px;color: #909399;">方</span>
        <template #scrapQty="{ row }">
          <span style="font-weight: bold;color: #b43434;">{{ row.scrapQty }}</span><span style="margin-left: 5px;color: #909399;">方</span>
        </template>
        <template #completedVolume="{ row }">
          <span style="font-weight: bold;color: #28e431;">{{ row.completedVolume }}</span><span style="margin-left: 5px;color: #909399;">方</span>
        <template #quantity="{ row }">
          <span style="font-weight: bold;color: #28e431;">{{ row.quantity }}</span><span style="margin-left: 5px;color: #909399;">方</span>
        </template>
      </PIMTable>
    </div>
    <ReportingDialog v-model:visible="dialogVisible"
                     :data="form"
                     @completed="handleQuery" />
    <!-- 详情弹窗 -->
    <detail-dialog v-model:visible="detailDialogVisible"
                   :data="detailData" />
  </div>
</template>
<script setup>
  import { onMounted, ref, reactive, getCurrentInstance } from "vue";
  import { useRouter } from "vue-router";
  import { ElMessage, ElMessageBox } from "element-plus";
  import dayjs from "dayjs";
  import {
    workListPage,
    productionReport,
    productionReportUpdate,
    productionReportDelete,
    productionReportDetail,
    productionReportListPage,
  } from "@/api/productionManagement/productionReporting.js";
  import PIMTable from "@/components/PIMTable/PIMTable.vue";
  import ReportingDialog from "./components/ReportingDialog.vue";
  import DetailDialog from "./detailDialog.vue";
  const router = useRouter();
  const { proxy } = getCurrentInstance();
  const tableColumn = ref([
    {
      label: "生产订单号",
      prop: "orderNo",
      prop: "npsNo",
      width: "150px",
    },
    {
      label: "班组",
      prop: "teamName",
      prop: "schedule",
      width: "120px",
      dataType: "tag",
      formatType: params => {
        return params === "白班" ? "primary" : "warning";
      },
    },
    {
      label: "产品编码",
@@ -102,37 +114,37 @@
    },
    {
      label: "规格",
      prop: "specification",
      width: "120px",
      className: "specification-cell",
      prop: "productModelName",
      width: "150px",
      className: "productModelName-cell",
    },
    {
      label: "产出方量",
      prop: "outputVolume",
      width: "120px",
      prop: "totalQuantity",
      width: "100px",
      align: "right",
      dataType: "slot",
      slot: "outputVolume",
      slot: "totalQuantity",
    },
    {
      label: "不合格方量",
      prop: "unqualifiedVolume",
      width: "120px",
      prop: "scrapQty",
      width: "100px",
      align: "right",
      dataType: "slot",
      slot: "unqualifiedVolume",
      slot: "scrapQty",
    },
    {
      label: "完成方量",
      prop: "completedVolume",
      width: "120px",
      prop: "quantity",
      width: "100px",
      align: "right",
      dataType: "slot",
      slot: "completedVolume",
      slot: "quantity",
    },
    {
      label: "创建人",
      prop: "createBy",
      prop: "postName",
      width: "120px",
      dataType: "tag",
    },
@@ -182,171 +194,41 @@
  });
  const searchForm = reactive({
    orderNo: "",
    teamName: "",
    npsNo: "",
    schedule: "",
    productName: "",
  });
  const mockData = [
    {
      id: 1,
      orderNo: "PO202401001",
      teamName: "生产一组",
      materialCode: "PC001",
      productName: "标准砌块",
      specification: "600×240×200",
      outputVolume: 120.5,
      unqualifiedVolume: 2.3,
      completedVolume: 118.2,
      createBy: "张三",
      createTime: "2024-01-15 08:30:00",
    },
    {
      id: 2,
      orderNo: "PO202401002",
      teamName: "生产二组",
      materialCode: "PC002",
      productName: "标准砌块",
      specification: "600×240×200",
      outputVolume: 150.8,
      unqualifiedVolume: 1.5,
      completedVolume: 149.3,
      createBy: "李四",
      createTime: "2024-01-15 09:15:00",
    },
    {
      id: 3,
      orderNo: "PO202401003",
      teamName: "生产三组",
      materialCode: "PC003",
      productName: "加气砌块",
      specification: "600×240×250",
      outputVolume: 95.2,
      unqualifiedVolume: 0.8,
      completedVolume: 94.4,
      createBy: "王五",
      createTime: "2024-01-15 10:00:00",
    },
    {
      id: 4,
      orderNo: "PO202401004",
      teamName: "生产一组",
      materialCode: "PC004",
      productName: "标准砌块",
      specification: "600×240×200",
      outputVolume: 180.6,
      unqualifiedVolume: 3.2,
      completedVolume: 177.4,
      createBy: "赵六",
      createTime: "2024-01-15 14:20:00",
    },
    {
      id: 5,
      orderNo: "PO202401005",
      teamName: "生产二组",
      materialCode: "PC005",
      productName: "加气砌块",
      specification: "600×240×250",
      outputVolume: 110.3,
      unqualifiedVolume: 1.1,
      completedVolume: 109.2,
      createBy: "孙七",
      createTime: "2024-01-15 15:45:00",
    },
    {
      id: 6,
      orderNo: "PO202401006",
      teamName: "生产三组",
      materialCode: "PC006",
      productName: "标准砌块",
      specification: "600×240×200",
      outputVolume: 135.7,
      unqualifiedVolume: 2.5,
      completedVolume: 133.2,
      createBy: "周八",
      createTime: "2024-01-16 08:00:00",
    },
    {
      id: 7,
      orderNo: "PO202401007",
      teamName: "生产一组",
      materialCode: "PC007",
      productName: "加气砌块",
      specification: "600×240×250",
      outputVolume: 88.4,
      unqualifiedVolume: 0.6,
      completedVolume: 87.8,
      createBy: "吴九",
      createTime: "2024-01-16 09:30:00",
    },
    {
      id: 8,
      orderNo: "PO202401008",
      teamName: "生产二组",
      materialCode: "PC008",
      productName: "标准砌块",
      specification: "600×240×200",
      outputVolume: 165.2,
      unqualifiedVolume: 2.8,
      completedVolume: 162.4,
      createBy: "郑十",
      createTime: "2024-01-16 11:00:00",
    },
    {
      id: 9,
      orderNo: "PO202401009",
      teamName: "生产三组",
      materialCode: "PC009",
      productName: "加气砌块",
      specification: "600×240×250",
      outputVolume: 102.5,
      unqualifiedVolume: 1.3,
      completedVolume: 101.2,
      createBy: "钱十一",
      createTime: "2024-01-16 13:15:00",
    },
    {
      id: 10,
      orderNo: "PO202401010",
      teamName: "生产一组",
      materialCode: "PC010",
      productName: "标准砌块",
      specification: "600×240×200",
      outputVolume: 142.8,
      unqualifiedVolume: 2.1,
      completedVolume: 140.7,
      createBy: "刘十二",
      createTime: "2024-01-16 15:00:00",
    },
  ];
  const dialogVisible = ref(false);
  const form = reactive({
    id: undefined,
    orderId: "",
    orderNo: "",
    teamName: "",
    npsNo: "",
    schedule: "",
    materialCode: "",
    productName: "",
    specification: "",
    outputVolume: 0,
    unqualifiedVolume: 0,
    completedVolume: 0,
    productModelName: "",
    totalQuantity: 0,
    scrapQty: 0,
    quantity: 0,
    processId: "",
    params: {},
  });
  const selectedRows = ref([]);
  const detailDialogVisible = ref(false);
  const detailData = ref({});
  const getList = () => {
    tableLoading.value = true;
    setTimeout(() => {
    productionReportListPage({
      current: page.current,
      size: page.size,
      ...searchForm,
    }).then(res => {
      tableData.value = res.data.records;
      page.total = res.data.total;
      tableLoading.value = false;
      const start = (page.current - 1) * page.size;
      const end = start + page.size;
      tableData.value = mockData.slice(start, end);
      page.total = mockData.length;
    }, 500);
    });
  };
  const handleQuery = () => {
@@ -355,8 +237,8 @@
  };
  const handleReset = () => {
    searchForm.orderNo = "";
    searchForm.teamName = "";
    searchForm.npsNo = "";
    searchForm.schedule = "";
    searchForm.productName = "";
    page.current = 1;
    getList();
@@ -374,44 +256,79 @@
  const handleAdd = () => {
    Object.assign(form, {
      type: "add",
      id: undefined,
      orderId: "",
      orderNo: "",
      teamName: "",
      npsNo: "",
      schedule: "",
      materialCode: "",
      productName: "",
      specification: "",
      outputVolume: 0,
      unqualifiedVolume: 0,
      completedVolume: 0,
      productModelName: "",
      totalQuantity: 0,
      scrapQty: 0,
      quantity: 0,
      processId: "",
      params: {},
    });
    dialogVisible.value = true;
    router.push({
      path: "/productionManagement/ReportingDialog",
      // query: { data: JSON.stringify(form) },
    });
  };
  const handleEdit = row => {
    Object.assign(form, {
      id: row.id,
      orderId: row.orderId || "",
      orderNo: row.orderNo,
      teamName: row.teamName,
      materialCode: row.materialCode,
      productName: row.productName,
      specification: row.specification,
      outputVolume: row.outputVolume,
      unqualifiedVolume: row.unqualifiedVolume,
      completedVolume: row.completedVolume,
      createBy: row.createBy || "",
      createTime: row.createTime || new Date(),
      processId: row.processId || "",
      params: row.params || {},
    });
    dialogVisible.value = true;
    // 调用详情接口获取完整数据
    productionReportDetail(row.id)
      .then(res => {
        if (res.code === 200) {
          const detailData = res.data;
          // 构建编辑表单数据
          const editForm = {
            id: row.id,
            type: "edit",
            orderId: detailData.productOrderId || "",
            npsNo: detailData.npsNo || "",
            schedule: detailData.schedule || "",
            materialCode: detailData.materialCode || "",
            productName: detailData.productName || "",
            productModelName: detailData.model || "",
            totalQuantity: detailData.quantity || 0,
            scrapQty: detailData.unqualifiedQuantity || 0,
            quantity: detailData.qualifiedQuantity || 0,
            createBy: detailData.postName || "",
            createTime: detailData.createTime || new Date(),
            processId: "",
            params: {},
            // 传递工序信息
            productionProductRouteItemDtoList:
              detailData.productionProductRouteItemDtoList || [],
          };
          router.push({
            path: "/productionManagement/ReportingDialog",
            query: { data: JSON.stringify(editForm) },
          });
        } else {
          ElMessage.error("获取详情失败");
        }
      })
      .catch(() => {
        ElMessage.error("获取详情失败");
      });
  };
  const handleDetail = row => {
    ElMessage.info("详情功能待实现");
    productionReportDetail(row.id)
      .then(res => {
        if (res.code === 200) {
          detailData.value = res.data;
          detailDialogVisible.value = true;
        } else {
          ElMessage.error("获取详情失败");
        }
      })
      .catch(() => {
        ElMessage.error("获取详情失败");
      });
  };
  const handleDelete = row => {
@@ -421,7 +338,7 @@
      type: "warning",
    })
      .then(() => {
        productionReportDelete({ id: row.id })
        productionReportDelete(row.id)
          .then(() => {
            ElMessage.success("删除成功");
            getList();
@@ -539,7 +456,7 @@
  }
</style>
<style lang="scss">
  .specification-cell {
  .productModelName-cell {
    color: #7a7d81;
    font-style: italic;
  }