gongchunyi
8 小时以前 f372a30a711a1f7d7bc764d2060d5719a47c7c4c
fix: 最外层应当不能被编辑修改
已修改1个文件
32 ■■■■ 文件已修改
src/views/productionManagement/productStructure/Detail/index.vue 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productionManagement/productStructure/Detail/index.vue
@@ -57,14 +57,14 @@
                               label="消耗工序">
                <template #default="{ row, $index }">
                  <el-form-item v-if="dataValue.isEdit"
                                :rules="[{ required: true, message: '请选择消耗工序', trigger: 'change' }]"
                                :rules="dataValue.dataList.some(item => (item as any).tempId === row.tempId) ? [] : [{ required: true, message: '请选择消耗工序', trigger: 'change' }]"
                                style="margin: 0">
                    <el-select v-model="row.processId"
                               placeholder="请选择"
                               filterable
                               clearable
                               style="width: 100%"
                               :disabled="!dataValue.isEdit">
                               :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)">
                      <el-option v-for="item in dataValue.processOptions"
                                 :key="item.id"
                                 :label="item.name"
@@ -85,7 +85,7 @@
                                     :step="1"
                                     controls-position="right"
                                     style="width: 100%"
                                     :disabled="!dataValue.isEdit" />
                                     :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
                  </el-form-item>
                </template>
              </el-table-column>
@@ -102,7 +102,7 @@
                                     :step="1"
                                     controls-position="right"
                                     style="width: 100%"
                                     :disabled="!dataValue.isEdit" />
                                     :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
                  </el-form-item>
                </template>
              </el-table-column>
@@ -115,7 +115,7 @@
                    <el-input v-model="row.unit"
                              placeholder="请输入单位"
                              clearable
                              :disabled="!dataValue.isEdit" />
                               :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
                  </el-form-item>
                </template>
              </el-table-column>
@@ -220,7 +220,7 @@
    },
  ]);
  const openDialog = tempId => {
  const openDialog = (tempId: any) => {
    console.log(tempId, "tempId");
    dataValue.currentRowName = tempId;
    dataValue.showProductDialog = true;
@@ -236,8 +236,8 @@
      const { data } = await queryList(routeId.value);
      dataValue.dataList = (data as any) || [];
      // 为所有项及其子项设置name属性
      const setNameRecursively = items => {
        items.forEach(item => {
      const setNameRecursively = (items: any[]) => {
        items.forEach((item: any) => {
          item.tempId = item.id;
          item.processName =
            dataValue.processOptions.find(option => option.id === item.processId)
@@ -257,7 +257,7 @@
    dataValue.processOptions = data as any;
  };
  const handleProduct = row => {
  const handleProduct = (row: any) => {
    if (row?.length > 1) {
      ElMessage.error("只能选择一个产品");
    }
@@ -297,7 +297,7 @@
    });
    dataValue.showProductDialog = false;
  };
  const childItem = (item, tempId, productData) => {
  const childItem = (item: any, tempId: any, productData: any) => {
    if (item.tempId === tempId) {
      item.productName = productData.productName;
      item.model = productData.model;
@@ -320,14 +320,14 @@
    let isValid = true;
    // 校验函数
    const validateItem = item => {
    const validateItem = (item: any, isTopLevel = false) => {
      // 校验当前项的必填字段
      if (!item.model) {
        ElMessage.error("请选择规格");
        isValid = false;
        return;
      }
      if (!item.processId) {
      if (!isTopLevel && !item.processId) {
        ElMessage.error("请选择消耗工序");
        isValid = false;
        return;
@@ -351,14 +351,14 @@
      // 递归校验子项
      if (item.children && item.children.length > 0) {
        item.children.forEach(child => {
          validateItem(child);
          validateItem(child, false);
        });
      }
    };
    // 遍历所有顶层项
    dataValue.dataList.forEach(item => {
      validateItem(item);
      validateItem(item, true);
    });
    return isValid;
@@ -399,7 +399,7 @@
    }
    // 递归删除子项
    const delchildItem = (items, tempId) => {
    const delchildItem = (items: any[], tempId: any) => {
      for (let i = 0; i < items.length; i++) {
        const item = items[i];
        if (item.tempId === tempId) {
@@ -448,7 +448,7 @@
      addchildItem(item, tempId);
    });
  };
  const addchildItem = (item, tempId) => {
  const addchildItem = (item: any, tempId: any) => {
    if (item.tempId === tempId) {
      console.log(item, "item");
      if (!item.children) {