张诺
9 小时以前 ea324e1975ffec307758e00b5736b4399c36e6f6
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,7 +41,8 @@
        </el-form-item>
      </el-form>
      <div>
        <el-button type="primary" @click="isShowNewModal = true">新增</el-button>
<!--        <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>
@@ -52,6 +53,8 @@
                :page="page"
                :tableLoading="tableLoading"
                :row-class-name="tableRowClassName"
                :isSelection="true"
                @selection-change="handleSelectionChange"
                @pagination="pagination">
        <template #completionStatus="{ row }">
          <el-progress
@@ -62,32 +65,14 @@
        </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" />
@@ -95,23 +80,39 @@
</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)
    console.log(res)
  }
  const tableColumn = ref([
    {
@@ -120,7 +121,7 @@
      width: '120px',
    },
    {
      label: "销售合同号",
      label: "订单编号",
      prop: "salesContractNo",
      width: '150px',
    },
@@ -182,21 +183,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");
          },
        },
        {
@@ -216,6 +218,7 @@
    size: 100,
    total: 0,
  });
  const selectedRows = ref([]);
  const data = reactive({
    searchForm: {
@@ -247,6 +250,7 @@
  // 添加表行类名方法
  const tableRowClassName = ({ row }) => {
    if (!row.deliveryDate) return '';
    if (row.isFh) return '';
    const diff = row.deliveryDaysDiff;
@@ -266,25 +270,27 @@
  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;
    if(type === "view") {
      bindDialogType.value = "view"
      let res = await viewGetByProductWordId(row.id)
      console.log(res)
    }
    BindRouteDialogRef.value?.getProductOrder()
    try {
      const res = await listProcessRoute({ productModelId: row.productModelId });
      routeOptions.value = res.data || [];
      rowData.value = row;
    } catch (e) {
      console.error("获取工艺路线列表失败:", e);
      proxy.$modal.msgError("获取工艺路线列表失败");
@@ -394,6 +400,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("选中的内容将被导出,是否确认导出?", "导出", {
@@ -408,8 +441,6 @@
        proxy.$modal.msg("已取消");
      });
  };
  const handleConfirmRoute = () => {};
  onMounted(() => {
    getList();
@@ -430,10 +461,20 @@
}
::v-deep .red {
  background-color: #f80202;
  background-color: #ffe5e5;
}
::v-deep .purple{
  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>