张诺
8 小时以前 5cfebd7e46c0c53f79b5fb4a917e926194ab4398
src/views/productionManagement/productionOrder/index.vue
@@ -11,7 +11,7 @@
                    style="width: 160px;"
                    @change="handleQuery" />
        </el-form-item>
        <el-form-item label="合同号:">
        <el-form-item label="订单编号:">
          <el-input v-model="searchForm.salesContractNo"
                    placeholder="请输入"
                    clearable
@@ -41,6 +41,8 @@
        </el-form-item>
      </el-form>
      <div>
<!--        <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,6 +53,8 @@
                :page="page"
                :tableLoading="tableLoading"
                :row-class-name="tableRowClassName"
                :isSelection="true"
                @selection-change="handleSelectionChange"
                @pagination="pagination">
        <template #completionStatus="{ row }">
          <el-progress
@@ -61,49 +65,60 @@
        </template>
      </PIMTable>
    </div>
    <el-dialog v-model="bindRouteDialogVisible"
               title="绑定工艺路线"
               width="500px">
      <el-form label-width="90px">
        <el-form-item label="工艺路线">
          <el-select v-model="bindForm.routeId"
                     placeholder="请选择工艺路线"
                     style="width: 100%;"
                     :loading="bindRouteLoading">
            <el-option v-for="item in routeOptions"
                       :key="item.id"
                       :label="`${item.processRouteCode || ''}`"
                       :value="item.id" />
          </el-select>
        </el-form-item>
      </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>
        </span>
      </template>
    </el-dialog>
    <BindRouteDialog
        ref="BindRouteDialogRef"
        v-model="bindRouteDialogVisible"
        :type="bindDialogType"
        :rowData="rowData"
        @confirm="handleBindRouteSubmit"
    />
    <new-product-order v-if="isShowNewModal"
                         v-model:visible="isShowNewModal"
                         @completed="handleQuery" />
  </div>
</template>
<script setup>
  import { onMounted, ref } from "vue";
  import { defineAsyncComponent, getCurrentInstance, onMounted, reactive, ref, toRefs } from "vue";
  import { ElMessageBox } from "element-plus";
  import dayjs from "dayjs";
  import { useRouter } from "vue-router";
  import {
    productOrderListPage,
    listProcessRoute,
    bindingRoute,
    listProcessBom,
    delProductOrder,
    saveProductionProductInput,
    viewGetByProductWordId
  } from "@/api/productionManagement/productionOrder.js";
  import { listMain as getOrderProcessRouteMain } from "@/api/productionManagement/productProcessRoute.js";
  import PIMTable from "@/components/PIMTable/PIMTable.vue";
  import BindRouteDialog from "./BindRouteDialog.vue";
  import {getDeviceLedger} from "@/api/equipmentManagement/ledger.js";
  const NewProductOrder = defineAsyncComponent(() => import("@/views/productionManagement/productionOrder/New.vue"));
  const { proxy } = getCurrentInstance();
  const router = useRouter();
  const isShowNewModal = ref(false);
  const MOCK_MODE = true;
  const loading = ref(false)
  const dialogVisible = ref(false)
  const bindDialogType = ref('add')
  const BindRouteDialogRef = ref(null)
  const handleBindRouteSubmit =async (data)=>{
    const res = await saveProductionProductInput(data)
    if(res.code === 200){
      proxy.$modal.msgSuccess("绑定成功");
      bindRouteDialogVisible.value = false
      handleQuery()
    }else{
      proxy.$modal.msgError(res.msg || "绑定失败")
    }
  }
  const tableColumn = ref([
    {
@@ -112,7 +127,7 @@
      width: '120px',
    },
    {
      label: "销售合同号",
      label: "订单编号",
      prop: "salesContractNo",
      width: '150px',
    },
@@ -174,21 +189,22 @@
      label: "操作",
      align: "center",
      fixed: "right",
      width: 200,
      width: 300,
      operation: [
        {
          name: "工艺路线",
          type: "text",
          clickFun: row => {
            showRouteItemModal(row);
          },
        },
        {
          name: "绑定工艺路线",
          type: "text",
          showHide: row => !row.processRouteCode,
          clickFun: row => {
            openBindRouteDialog(row);
          },
        },
        {
          name: "查看工艺路线",
          type: "text",
          showHide: row => row.processRouteCode,
          clickFun: row => {
            openBindRouteDialog(row,"view");
          },
        },
        {
@@ -208,6 +224,7 @@
    size: 100,
    total: 0,
  });
  const selectedRows = ref([]);
  const data = reactive({
    searchForm: {
@@ -239,13 +256,18 @@
  // 添加表行类名方法
  const tableRowClassName = ({ row }) => {
    switch (row.deliveryDaysDiff) {
      case 15:
        return 'yellow'
      case 10:
        return 'red'
      case 2:
        return 'purple'
    if (!row.deliveryDate) 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';
    }
  };
@@ -254,25 +276,29 @@
  const bindRouteLoading = ref(false);
  const bindRouteSaving = ref(false);
  const routeOptions = ref([]);
  const rowData = ref(null)
  const bindForm = reactive({
    orderId: null,
    routeId: null,
  });
  const openBindRouteDialog = async row => {
  const openBindRouteDialog = async (row,type) => {
    bindForm.orderId = row.id;
    bindForm.routeId = null;
    bindRouteDialogVisible.value = true;
    routeOptions.value = [];
    if (!row.productModelId) {
      proxy.$modal.msgWarning("当前订单缺少产品型号,无法查询工艺路线");
      bindRouteDialogVisible.value = false;
      return;
    }
    bindRouteLoading.value = true;
    try {
      const res = await listProcessRoute({ productModelId: row.productModelId });
      routeOptions.value = res.data || [];
      BindRouteDialogRef.value?.resetForm?.()
      if (type === "view") {
        bindDialogType.value = "detail"
        const res = await viewGetByProductWordId(row.id)
        rowData.value = res?.data || res
      } else {
        bindDialogType.value = "add"
        rowData.value = row
        rowData.value.finishedSize = row.specificationModel
      }
      bindRouteDialogVisible.value = true;
    } catch (e) {
      console.error("获取工艺路线列表失败:", e);
      proxy.$modal.msgError("获取工艺路线列表失败");
@@ -382,6 +408,33 @@
    });
  };
  // 表格选择数据
  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("选中的内容将被导出,是否确认导出?", "导出", {
@@ -397,8 +450,6 @@
      });
  };
  const handleConfirmRoute = () => {};
  onMounted(() => {
    getList();
  });
@@ -410,14 +461,28 @@
}
::v-deep .yellow {
  background-color: #e8b183;
  background-color: #FAF0DE;
}
::v-deep .pink {
  background-color: #FAE1DE;
}
::v-deep .red {
  background-color: #e35050;
  background-color: #ffe5e5;
}
::v-deep .purple{
  background-color: #c484dd;
  background-color: #F4DEFA;
}
:deep(.fixed-desc .el-descriptions__table) {
  table-layout: fixed;
  width: 100%;
}
:deep(.fixed-desc .el-descriptions__cell) {
  width: 25%;
  word-break: break-word;
}
</style>