张诺
16 小时以前 7db2391ce77797d79470a7e91aec1e78d0d7ec53
src/views/productionManagement/processRoute/processRouteItem/index.vue
@@ -3,7 +3,6 @@
    <PageHeader content="工艺路线项目" />
    
    <!-- 工艺路线信息展示 -->
    <div v-if="routeInfo.processRouteCode" class="section-title" style="margin-bottom: 12px;">工艺路线信息</div>
    <el-card v-if="routeInfo.processRouteCode" class="route-info-card" shadow="hover">
      <div class="route-info">
        <div class="info-item">
@@ -211,6 +210,7 @@
import { ref, computed, getCurrentInstance, onMounted, onUnmounted, nextTick } from "vue";
import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
import { findProcessRouteItemList, addOrUpdateProcessRouteItem, sortProcessRouteItem, batchDeleteProcessRouteItem } from "@/api/productionManagement/processRouteItem.js";
import { findProductProcessRouteItemList, deleteRouteItem, addRouteItem, addOrUpdateProductProcessRouteItem, sortRouteItem } from "@/api/productionManagement/productProcessRoute.js";
import { processList } from "@/api/productionManagement/productionProcess.js";
import { useRoute } from 'vue-router'
import { ElMessageBox } from 'element-plus'
@@ -220,6 +220,8 @@
const { proxy } = getCurrentInstance() || {};
const routeId = computed(() => route.query.id);
const orderId = computed(() => route.query.orderId);
const pageType = computed(() => route.query.type);
const tableLoading = ref(false);
const tableData = ref([]);
@@ -277,7 +279,12 @@
// 获取列表
const getList = () => {
  tableLoading.value = true;
  findProcessRouteItemList({ routeId: routeId.value })
  const listPromise =
    pageType.value === "order"
      ? findProductProcessRouteItemList({ orderId: orderId.value })
      : findProcessRouteItemList({ routeId: routeId.value });
  listPromise
    .then(res => {
      tableData.value = res.data || [];
      tableLoading.value = false;
@@ -345,8 +352,13 @@
    type: 'warning'
  })
    .then(() => {
      // 调用批量删除接口,传递id数组
      batchDeleteProcessRouteItem([row.id])
      // 生产订单下使用 productProcessRoute 的删除接口(路由后拼接 id),其它情况使用工艺路线项目批量删除接口
      const deletePromise =
        pageType.value === 'order'
          ? deleteRouteItem(row.id)
          : batchDeleteProcessRouteItem([row.id]);
      deletePromise
        .then(() => {
          proxy?.$modal?.msgSuccess('删除成功');
          getList();
@@ -378,21 +390,28 @@
    if (valid) {
      submitLoading.value = true;
      
      // 构建提交数据对象(单个对象形式)
      const submitData = {
        routeId: routeId.value,
        processId: form.value.processId,
        productModelId: form.value.productModelId,
      };
      if (operationType.value === 'add') {
        // 新增:传单个对象,包含dragSort字段
        // dragSort = 当前列表长度 + 1,表示新增记录排在最后
        const dragSort = tableData.value.length + 1;
        addOrUpdateProcessRouteItem({
          ...submitData,
          dragSort: dragSort
        })
        const isOrderPage = pageType.value === 'order';
        const addPromise = isOrderPage
          ? addRouteItem({
              productOrderId: orderId.value,
              productRouteId: routeId.value,
              processId: form.value.processId,
              productModelId: form.value.productModelId,
              dragSort,
            })
          : addOrUpdateProcessRouteItem({
              routeId: routeId.value,
              processId: form.value.processId,
              productModelId: form.value.productModelId,
              dragSort,
            });
        addPromise
          .then(() => {
            proxy?.$modal?.msgSuccess('新增成功');
            closeDialog();
@@ -405,11 +424,23 @@
            submitLoading.value = false;
          });
      } else {
        // 编辑:传单个对象,包含id
        addOrUpdateProcessRouteItem({
          ...submitData,
          id: form.value.id,
        })
        // 编辑:生产订单下使用 productProcessRoute/updateRouteItem,其它情况使用工艺路线项目更新接口
        const isOrderPage = pageType.value === 'order';
        const updatePromise = isOrderPage
          ? addOrUpdateProductProcessRouteItem({
              id: form.value.id,
              processId: form.value.processId,
              productModelId: form.value.productModelId,
            })
          : addOrUpdateProcessRouteItem({
              routeId: routeId.value,
              processId: form.value.processId,
              productModelId: form.value.productModelId,
              id: form.value.id,
            });
        updatePromise
          .then(() => {
            proxy?.$modal?.msgSuccess('修改成功');
            closeDialog();
@@ -477,10 +508,18 @@
        
        // 调用排序接口
        if (moveItem.id) {
          sortProcessRouteItem({
            id: moveItem.id,
            dragSort: dragSort
          })
          const isOrderPage = pageType.value === 'order';
          const sortPromise = isOrderPage
            ? sortRouteItem({
                id: moveItem.id,
                dragSort: dragSort
              })
            : sortProcessRouteItem({
                id: moveItem.id,
                dragSort: dragSort
              });
          sortPromise
            .then(() => {
              // 更新所有行的dragSort
              tableData.value.forEach((item, index) => {
@@ -522,10 +561,18 @@
        
        // 调用排序接口
        if (moveItem.id) {
          sortProcessRouteItem({
            id: moveItem.id,
            dragSort: dragSort
          })
          const isOrderPage = pageType.value === 'order';
          const sortPromise = isOrderPage
            ? sortRouteItem({
                id: moveItem.id,
                dragSort: dragSort
              })
            : sortProcessRouteItem({
                id: moveItem.id,
                dragSort: dragSort
              });
          sortPromise
            .then(() => {
              // 更新所有行的dragSort
              tableData.value.forEach((item, index) => {