gaoluyang
昨天 46d5fc2f692b19538f2f7224f04096faececd38b
军泰伟业
1.生产订单新增时展示工序和物料清单并可以修改
已修改3个文件
272 ■■■■■ 文件已修改
src/views/productionManagement/productionOrder/New.vue 187 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/productionOrder/index.vue 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/productionProcess/Edit.vue 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/productionOrder/New.vue
@@ -40,18 +40,6 @@
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="销售合同号" prop="salesContractNo">
                <el-input v-model="formState.salesContractNo" placeholder="请输入销售合同号" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="客户名称" prop="customerName">
                <el-input v-model="formState.customerName" placeholder="请输入客户名称" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="需求数量" prop="quantity">
                <el-input-number v-model="formState.quantity" :step="1" :min="1" style="width: 100%" />
              </el-form-item>
@@ -116,7 +104,7 @@
          </el-button>
        </div>
        <div class="table-container">
          <el-table :data="productionTaskList" border size="small" class="compact-table">
          <el-table :data="processRouteItems" border size="small" class="compact-table">
        <el-table-column type="index" label="序号" width="60" />
        <el-table-column label="工序名称" min-width="150">
          <template #default="{ row }">
@@ -135,25 +123,44 @@
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="计划数" min-width="120">
        <el-table-column label="报工权限" min-width="180">
          <template #default="{ row }">
            <el-input-number v-model="row.planQuantity" :min="0" style="width: 100%" />
            <el-select
              v-model="row.userPower"
              multiple
              collapse-tags
              collapse-tags-tooltip
              placeholder="请选择报工权限"
              style="width: 100%"
            >
              <el-option
                v-for="item in userOptions"
                :key="item.userId"
                :label="item.nickName"
                :value="item.nickName"
              />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column label="报工权限" min-width="150">
        <el-table-column label="计划数" min-width="100">
          <template #default="{ row }">
            <el-input v-model="row.reportPermission" placeholder="请输入报工权限" />
            <el-input-number v-model="row.planNum" :min="1" size="small" style="width: 100%" />
          </template>
        </el-table-column>
        <el-table-column label="是否质检" min-width="100">
          <template #default="{ row }">
            <el-switch v-model="row.isQuality" :active-value="true" :inactive-value="false" size="small" />
          </template>
        </el-table-column>
        <el-table-column label="计划开始时间" min-width="180">
          <template #default="{ row }">
            <el-date-picker
                v-model="row.planStartTime"
                type="datetime"
                type="date"
                placeholder="选择开始时间"
                style="width: 100%"
                format="YYYY-MM-DD HH:mm"
                value-format="YYYY-MM-DD HH:mm:ss"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
            />
          </template>
        </el-table-column>
@@ -161,23 +168,23 @@
          <template #default="{ row }">
            <el-date-picker
                v-model="row.planEndTime"
                type="datetime"
                type="date"
                placeholder="选择结束时间"
                style="width: 100%"
                format="YYYY-MM-DD HH:mm"
                value-format="YYYY-MM-DD HH:mm:ss"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
            />
          </template>
        </el-table-column>
        <el-table-column label="操作" width="80" fixed="right" align="center">
          <template #default="{ $index }">
            <el-button type="danger" link size="small" @click="removeProductionTask($index)">
            <el-button type="danger" link size="small" @click="removeProcessRouteItem($index)">
              <el-icon><Delete /></el-icon>
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div v-if="productionTaskList.length === 0" class="empty-tip">
      <div v-if="processRouteItems.length === 0" class="empty-tip">
        <el-empty description="暂无生产任务,点击上方按钮添加" :image-size="60" />
      </div>
        </div>
@@ -193,37 +200,37 @@
          </el-button>
        </div>
        <div class="table-container">
          <el-table :data="materialList" border size="small" class="compact-table">
          <el-table :data="productStructureRecords" border size="small" class="compact-table">
            <el-table-column type="index" label="序号" width="50" align="center" />
            <el-table-column label="图纸编号" min-width="140">
              <template #default="{ row }">
                <el-input v-model="row.drawingNumber" placeholder="请输入图纸编号" size="small" />
              </template>
            </el-table-column>
            <el-table-column label="产品名称" min-width="140">
              <template #default="{ row }">
                <el-input v-model="row.productName" placeholder="请输入产品名称" size="small" />
              </template>
            </el-table-column>
            <el-table-column label="单位用量" min-width="100">
            <el-table-column label="单位产出需要数量" min-width="140">
              <template #default="{ row }">
                <el-input-number v-model="row.unitQuantity" :min="0" :precision="2" size="small" style="width: 100%" />
              </template>
            </el-table-column>
            <el-table-column label="库存数量" min-width="100">
            <el-table-column label="需求数量" min-width="120">
              <template #default="{ row }">
                <el-input-number v-model="row.inventoryQuantity" :min="0" size="small" style="width: 100%" />
                <el-input-number v-model="row.demandedQuantity" :min="0" :precision="2" size="small" style="width: 100%" />
              </template>
            </el-table-column>
            <el-table-column label="单位" min-width="80">
              <template #default="{ row }">
                <el-input v-model="row.unit" placeholder="请输入" size="small" />
              </template>
            </el-table-column>
            <el-table-column label="bomId" min-width="100">
              <template #default="{ row }">
                <el-input-number v-model="row.bomId" :min="0" size="small" style="width: 100%" />
              </template>
            </el-table-column>
            <el-table-column label="操作" width="80" fixed="right" align="center">
              <template #default="{ $index }">
                <el-button type="danger" link size="small" @click="removeMaterialItem($index)">
                <el-button type="danger" link size="small" @click="removeProductStructureRecord($index)">
                  <el-icon><Delete /></el-icon>
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <div v-if="materialList.length === 0" class="empty-tip">
          <div v-if="productStructureRecords.length === 0" class="empty-tip">
            <el-empty description="暂无用料清单,点击上方按钮添加" :image-size="60" />
          </div>
        </div>
@@ -245,6 +252,7 @@
import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
import {addProductOrder, listProcessRoute} from "@/api/productionManagement/productionOrder.js";
import {list as listProcess} from "@/api/productionManagement/productionProcess.js";
import {listDeptUserTree} from "@/api/basicData/productProcess.js";
const props = defineProps({
  visible: {
@@ -271,19 +279,20 @@
  unit: "",
  drawingNumber: "",
  quantity: 0,
  salesContractNo: "",
  customerName: "",
  deliveryDate: "",
});
// 生产任务列表
const productionTaskList = ref([]);
// 工序路线明细列表
 const processRouteItems = ref([]);
// 用料清单列表
const materialList = ref([]);
 // 物料清单列表
 const productStructureRecords = ref([]);
// 工序列表
const processOptions = ref([]);
// 用户列表
const userOptions = ref([]);
// 文件列表
const fileList = ref([]);
@@ -307,8 +316,33 @@
  });
};
// 组件挂载时获取工序列表
// 获取用户列表
const fetchUserOptions = () => {
  listDeptUserTree().then(res => {
    const users = [];
    const extractUsers = (nodes) => {
      nodes.forEach(node => {
        if (node.userList && node.userList.length > 0) {
          node.userList.forEach(user => {
            users.push({
              userId: user.userId,
              nickName: user.nickName || user.userName
            });
          });
        }
        if (node.childrenList && node.childrenList.length > 0) {
          extractUsers(node.childrenList);
        }
      });
    };
    extractUsers(res.data || []);
    userOptions.value = users;
  });
};
// 组件挂载时获取数据
fetchProcessOptions();
fetchUserOptions();
let { proxy } = getCurrentInstance()
@@ -323,13 +357,11 @@
    productModelName: "",
    unit: "",
    quantity: 0,
    salesContractNo: "",
    customerName: "",
    deliveryDate: "",
  };
  // 重置生产任务和用料清单
  productionTaskList.value = [];
  materialList.value = [];
  // 重置工序路线明细和物料清单
  processRouteItems.value = [];
  productStructureRecords.value = [];
  fileList.value = [];
  isShow.value = false;
};
@@ -370,25 +402,34 @@
  if (selectedProcess) {
    row.processName = selectedProcess.name;
    row.processNo = selectedProcess.no;
    row.isQuality = selectedProcess.isQuality || false;
    // userPower是逗号分隔的用户名,转换为数组
    if (selectedProcess.userPower) {
      row.userPower = selectedProcess.userPower.split(',');
    } else {
      row.userPower = [];
    }
  }
};
// 添加生产任务
const addProductionTask = () => {
  productionTaskList.value.push({
  processRouteItems.value.push({
    processId: undefined,
    processName: "",
    processNo: "",
    planQuantity: 1,
    reportPermission: "",
    productModelId: undefined,
    userPower: [],
    planStartTime: "",
    planEndTime: "",
    planNum: 1,
    isQuality: false,
  });
};
// 删除生产任务
const removeProductionTask = (index) => {
  productionTaskList.value.splice(index, 1);
// 删除工序路线明细
const removeProcessRouteItem = (index) => {
  processRouteItems.value.splice(index, 1);
};
// 添加用料 - 弹出产品选择框
@@ -400,22 +441,24 @@
const handleMaterialProductSelect = (products) => {
  if (products && products.length > 0) {
    products.forEach(product => {
      materialList.value.push({
      productStructureRecords.value.push({
        productModelId: product.id,
        drawingNumber: product.model,
        productName: product.productName,
        unit: product.unit,
        parentId: undefined,
        productOrderId: undefined,
        processId: undefined,
        unitQuantity: 1,
        inventoryQuantity: 0,
        demandedQuantity: 1,
        unit: product.unit,
        bomId: undefined,
      });
    });
  }
  showMaterialProductDialog.value = false;
};
// 删除用料
const removeMaterialItem = (index) => {
  materialList.value.splice(index, 1);
// 删除物料清单
const removeProductStructureRecord = (index) => {
  productStructureRecords.value.splice(index, 1);
};
// 文件上传变更
@@ -436,11 +479,17 @@
        return;
      }
      // 处理提交数据 - 将userPower数组转换为逗号分隔的字符串
      const processedProcessRouteItems = processRouteItems.value.map(item => ({
        ...item,
        userPower: Array.isArray(item.userPower) ? item.userPower.join(',') : item.userPower
      }));
      // 组装提交数据
      const submitData = {
        ...formState.value,
        productionTasks: productionTaskList.value,
        materials: materialList.value,
        processRouteItems: processedProcessRouteItems,
        productStructureRecords: productStructureRecords.value,
        files: fileList.value,
      };
src/views/productionManagement/productionOrder/index.vue
@@ -3,32 +3,8 @@
    <div class="search_form">
      <el-form :model="searchForm"
               :inline="true">
        <el-form-item label="客户名称:">
          <el-input v-model="searchForm.customerName"
                    placeholder="请输入"
                    clearable
                    prefix-icon="Search"
                    style="width: 160px;"
                    @change="handleQuery" />
        </el-form-item>
        <el-form-item label="合同号:">
          <el-input v-model="searchForm.salesContractNo"
                    placeholder="请输入"
                    clearable
                    prefix-icon="Search"
                    style="width: 160px;"
                    @change="handleQuery" />
        </el-form-item>
        <el-form-item label="产品名称:">
          <el-input v-model="searchForm.productCategory"
                    placeholder="请输入"
                    clearable
                    prefix-icon="Search"
                    style="width: 160px;"
                    @change="handleQuery" />
        </el-form-item>
        <el-form-item label="规格:">
          <el-input v-model="searchForm.specificationModel"
                    placeholder="请输入"
                    clearable
                    prefix-icon="Search"
@@ -126,16 +102,6 @@
      width: '120px',
    },
    {
      label: "销售合同号",
      prop: "salesContractNo",
      width: '150px',
    },
    {
      label: "客户名称",
      prop: "customerName",
      width: '200px',
    },
    {
      label: "产品名称",
      prop: "productCategory",
      width: '120px',
@@ -144,11 +110,6 @@
      label: "图纸编号",
      prop: "specificationModel",
      width: '160px',
    },
    {
      label: "规格型号",
      prop: "drawingNumber",
      width: '120px',
    },
    {
      label: "工艺路线编号",
@@ -235,11 +196,8 @@
  const data = reactive({
    searchForm: {
      customerName: "",
      salesContractNo: "",
      projectName: "",
      productCategory: "",
      specificationModel: "",
    },
  });
  const { searchForm } = toRefs(data);
src/views/productionManagement/productionProcess/Edit.vue
@@ -109,12 +109,6 @@
// 监听 record 变化,更新表单数据
watch(() => props.record, (newRecord) => {
  if (newRecord && isShow.value) {
    const userPowerNames = newRecord.userPower ? newRecord.userPower.split(',') : [];
    const userPowerIds = userPowerNames.map(name => {
      const user = findUserByName(name);
      return user ? user.id : null;
    }).filter(id => id !== null);
    formState.value = {
      id: newRecord.id,
      name: newRecord.name || '',
@@ -122,11 +116,46 @@
      remark: newRecord.remark || '',
      salaryQuota: newRecord.salaryQuota || '',
      isQuality: newRecord.isQuality,
      userPower: userPowerIds,
      userPower: [],
    };
    // 等待 staffList 加载完成后,再查找用户ID
    if (staffList.value.length > 0) {
      setUserPowerIds(newRecord.userPower);
    } else {
      // staffList 还没加载,等待一下再查找
      const checkStaffList = () => {
        if (staffList.value.length > 0) {
          setUserPowerIds(newRecord.userPower);
        } else {
          setTimeout(checkStaffList, 100);
        }
      };
      checkStaffList();
    }
  }
}, { immediate: true, deep: true });
// 根据用户名查找用户ID
const setUserPowerIds = (userPowerStr) => {
  const userPowerNames = userPowerStr ? userPowerStr.split(',') : [];
  const userPowerIds = [];
  const findUserIds = (nodes, targetName) => {
    nodes.forEach(node => {
      if (node.isUser && node.label === targetName) {
        userPowerIds.push(node.id);
      }
      if (node.children && node.children.length > 0) {
        findUserIds(node.children, targetName);
      }
    });
  };
  userPowerNames.forEach(name => {
    findUserIds(staffList.value, name);
  });
  formState.value.userPower = userPowerIds;
};
let { proxy } = getCurrentInstance()
const closeModal = () => {