zhangwencui
2026-04-24 759f41097324fa1ade4060fc838d700d8c8fa55f
src/views/productionManagement/productionOrder/index.vue
@@ -3,6 +3,14 @@
    <div class="search_form">
      <el-form :model="searchForm"
               :inline="true">
        <el-form-item label="生产订单号:">
          <el-input v-model="searchForm.npsNo"
                    placeholder="请输入"
                    clearable
                    prefix-icon="Search"
                    style="width: 160px;"
                    @change="handleQuery" />
        </el-form-item>
        <el-form-item label="客户名称:">
          <el-input v-model="searchForm.customerName"
                    placeholder="请输入"
@@ -40,7 +48,11 @@
                     @click="handleQuery">搜索</el-button>
        </el-form-item>
      </el-form>
      <div>
      <div class="action-buttons">
        <el-button type="primary"
                   @click="isShowNewModal = true">新增</el-button>
        <el-button type="danger"
                   @click="handleDelete">删除</el-button>
        <el-button @click="handleOut">导出</el-button>
      </div>
    </div>
@@ -51,13 +63,13 @@
                :page="page"
                :tableLoading="tableLoading"
                :row-class-name="tableRowClassName"
                :isSelection="true"
                @selection-change="handleSelectionChange"
                @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>
@@ -79,18 +91,35 @@
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="bindRouteDialogVisible = false">取 消</el-button>
          <el-button type="primary"
                     :loading="bindRouteSaving"
                     @click="handleBindRouteConfirm">确 认</el-button>
          <el-button @click="bindRouteDialogVisible = false">取 消</el-button>
        </span>
      </template>
    </el-dialog>
    <MaterialLedgerDialog v-model="materialDialogVisible"
                          :order-row="currentMaterialOrder"
                          @saved="getList" />
    <MaterialDetailDialog v-model="materialDetailDialogVisible"
                          :order-row="currentMaterialDetailOrder"
                          @confirmed="getList" />
    <new-product-order v-if="isShowNewModal"
                       v-model:visible="isShowNewModal"
                       @completed="handleQuery" />
  </div>
</template>
<script setup>
  import { onMounted, ref } from "vue";
  import {
    computed,
    defineAsyncComponent,
    getCurrentInstance,
    onMounted,
    reactive,
    ref,
    toRefs,
  } from "vue";
  import { ElMessageBox } from "element-plus";
  import dayjs from "dayjs";
  import { useRouter } from "vue-router";
@@ -99,42 +128,52 @@
    listProcessRoute,
    bindingRoute,
    listProcessBom,
    delProductOrder,
  } from "@/api/productionManagement/productionOrder.js";
  import { listMain as getOrderProcessRouteMain } from "@/api/productionManagement/productProcessRoute.js";
  import MaterialLedgerDialog from "@/views/productionManagement/productionOrder/components/MaterialLedgerDialog.vue";
  import MaterialDetailDialog from "@/views/productionManagement/productionOrder/components/MaterialDetailDialog.vue";
  import PIMTable from "@/components/PIMTable/PIMTable.vue";
  import { listPage } from "@/api/productionManagement/processRoute.js";
  const NewProductOrder = defineAsyncComponent(() =>
    import("@/views/productionManagement/productionOrder/New.vue")
  );
  const { proxy } = getCurrentInstance();
  const router = useRouter();
  const isShowNewModal = ref(false);
  const tableColumn = ref([
    {
      label: "生产订单号",
      prop: "npsNo",
      width: '120px',
      width: "150px",
    },
    {
      label: "销售合同号",
      prop: "salesContractNo",
      width: '150px',
      width: "150px",
    },
    {
      label: "客户名称",
      prop: "customerName",
      width: '200px',
      width: "200px",
    },
    {
      label: "产品名称",
      prop: "productCategory",
      width: '120px',
      prop: "productName",
      width: "120px",
    },
    {
      label: "规格",
      prop: "specificationModel",
      width: '120px',
      prop: "model",
      width: "120px",
    },
    {
      label: "工艺路线编号",
      prop: "processRouteCode",
      width: '200px',
      width: "200px",
    },
    {
      label: "需求数量",
@@ -164,8 +203,8 @@
      width: 120,
    },
    {
      label: "交付日期",
      prop: "deliveryDate",
      label: "计划完成时间",
      prop: "planCompleteTime",
      formatData: val => (val ? dayjs(val).format("YYYY-MM-DD") : ""),
      width: 120,
    },
@@ -174,7 +213,7 @@
      label: "操作",
      align: "center",
      fixed: "right",
      width: 200,
      width: 340,
      operation: [
        {
          name: "工艺路线",
@@ -191,11 +230,25 @@
            openBindRouteDialog(row);
          },
        },
        // {
        //   name: "产品结构",
        //   type: "text",
        //   clickFun: row => {
        //     showProductStructure(row);
        //   },
        // },
        {
          name: "产品结构",
          name: "领料",
          type: "text",
          clickFun: row => {
            showProductStructure(row);
            openMaterialDialog(row);
          },
        },
        {
          name: "领料详情",
          type: "text",
          clickFun: row => {
            openMaterialDetailDialog(row);
          },
        },
      ],
@@ -208,9 +261,11 @@
    size: 100,
    total: 0,
  });
  const selectedRows = ref([]);
  const data = reactive({
    searchForm: {
      npsNo: "",
      customerName: "",
      salesContractNo: "",
      projectName: "",
@@ -239,13 +294,18 @@
  // 添加表行类名方法
  const tableRowClassName = ({ row }) => {
    switch (row.deliveryDaysDiff) {
      case 15:
        return 'yellow'
      case 10:
        return 'red'
      case 2:
        return 'purple'
    if (!row.planCompleteTime) return "";
    if (row.isFh) return "";
    const diff = row.deliveryDaysDiff;
    if (diff === 15) {
      return "yellow";
    } else if (diff === 10) {
      return "pink";
    } else if (diff === 2) {
      return "purple";
    } else if (diff < 2) {
      return "red";
    }
  };
@@ -258,6 +318,10 @@
    orderId: null,
    routeId: null,
  });
  const materialDialogVisible = ref(false);
  const currentMaterialOrder = ref(null);
  const materialDetailDialogVisible = ref(false);
  const currentMaterialDetailOrder = ref(null);
  const openBindRouteDialog = async row => {
    bindForm.orderId = row.id;
@@ -271,8 +335,8 @@
    }
    bindRouteLoading.value = true;
    try {
      const res = await listProcessRoute({ productModelId: row.productModelId });
      routeOptions.value = res.data || [];
      const res = await listPage({ productModelId: row.productModelId });
      routeOptions.value = res.data.records || [];
    } catch (e) {
      console.error("获取工艺路线列表失败:", e);
      proxy.$modal.msgError("获取工艺路线列表失败");
@@ -301,6 +365,16 @@
    } finally {
      bindRouteSaving.value = false;
    }
  };
  const openMaterialDialog = row => {
    currentMaterialOrder.value = row;
    materialDialogVisible.value = true;
  };
  const openMaterialDetailDialog = async row => {
    currentMaterialDetailOrder.value = row;
    materialDetailDialogVisible.value = true;
  };
  // 查询列表
@@ -353,6 +427,7 @@
        path: "/productionManagement/processRouteItem",
        query: {
          id: data.id,
          bomId: data.bomId,
          processRouteCode: data.processRouteCode || "",
          productName: data.productName || "",
          model: data.model || "",
@@ -382,6 +457,35 @@
    });
  };
  // 表格选择数据
  const handleSelectionChange = selection => {
    selectedRows.value = selection;
  };
  const handleDelete = () => {
    let ids = [];
    if (selectedRows.value.length > 0) {
      ids = selectedRows.value.map(item => item.id);
    } else {
      proxy.$modal.msgWarning("请选择数据");
      return;
    }
    ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "导出", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
    })
      .then(() => {
        delProductOrder(ids).then(res => {
          proxy.$modal.msgSuccess("删除成功");
          getList();
        });
      })
      .catch(() => {
        proxy.$modal.msg("已取消");
      });
  };
  // 导出
  const handleOut = () => {
    ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
@@ -390,7 +494,11 @@
      type: "warning",
    })
      .then(() => {
        proxy.download("/productOrder/export", {...searchForm.value}, "生产订单.xlsx");
        proxy.download(
          "/productOrder/export",
          { ...searchForm.value },
          "生产订单.xlsx"
        );
      })
      .catch(() => {
        proxy.$modal.msg("已取消");
@@ -405,19 +513,32 @@
</script>
<style scoped lang="scss">
.search_form{
  align-items: start;
}
  .search_form {
    align-items: start;
  }
::v-deep .yellow {
  background-color: #e8b183;
}
  .action-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
  }
::v-deep .red {
  background-color: #e35050;
}
  :deep(.yellow) {
    background-color: #faf0de;
  }
::v-deep .purple{
  background-color: #c484dd;
}
  :deep(.pink) {
    background-color: #fae1de;
  }
  :deep(.red) {
    background-color: #f80202;
  }
  :deep(.purple) {
    background-color: #f4defa;
  }
  .table_list {
    margin-top: unset;
  }
</style>