liding
2025-04-30 4ae5681e4a92c1cc98e811135098c71958c48a02
src/views/business/reliabilityPlan/index.vue
@@ -97,12 +97,16 @@
          <el-cascader v-model="materialForm.materialName" :options="itemParameterData.cascaderField.sample.tree"
            :props="{ value: 'name', label: 'name', checkStrictly: false, multiple: false, emitPath: false }"
            :show-all-levels="false" clearable filterable placeholder="请选择原辅材名称" size="small" style="width: 100%;"
            :disabled="operationType === 'review' || operationType === 'submit'">
            :disabled="operationType === 'review' || operationType === 'submit'" @change="handleMaterialNameChange">
          </el-cascader>
        </el-form-item>
        <el-form-item label="零件号" prop="partNo">
          <el-input v-model="materialForm.partNo" placeholder="请填写零件号"
            :disabled="operationType === 'review' || operationType === 'submit'"></el-input>
          <el-select v-model="materialForm.partNo" placeholder="请选择" clearable filterable
            :disabled="operationType === 'review' || !materialForm.materialName || operationType === 'submit'"
            style="width: 100%;">
            <el-option v-for="item in materialPartNoOption" :key="item.id" :label="item.partNo" :value="item.partNo">
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="审核人" prop="reviewerId">
          <el-select v-model="proPlanForm.reviewerId" clearable filterable size="small" style="width: 50%;"
@@ -159,6 +163,7 @@
      tableData: [],
      typeOption: [],
      partNoOption: [], // 添加产品型号选项数据
      materialPartNoOption:[],
      tableLoading: false,
      itemParameterData: {
        cascaderField: {
@@ -470,19 +475,56 @@
        }
      } else {
        this.materialDia = true
        if (this.operationType === 'add') {
          this.materialForm = {
            id: '',
            materialName: '',
            partNo: '',
            state: '',
            reviewerId: ''
          if (this.operationType === 'add') {
            this.materialForm = {
              id: '',
              materialName: '',
              partNo: '',
              state: '',
              reviewerId: ''
            }
          } else {
            this.materialForm = { ...row }
            // 编辑时获取选中节点的ID并加载相关数据
            const selectedNode = this.findNodeById(this.itemParameterData.cascaderField.sample.tree, row.materialName)
            if (selectedNode) {
              this.getMaterialPartNoOptions(selectedNode.id)
            }
          }
        } else {
          this.materialForm = { ...row }
        }
      }
    },
    //原辅材零件号选择
    handleMaterialNameChange(value) {
        if (value) {
          const selectedNode = this.findNodeById(this.itemParameterData.cascaderField.sample.tree, value)
          if (selectedNode) {
            this.getMaterialPartNoOptions(selectedNode.id)
          }
        } else {
          this.materialPartNoOption = []
          this.materialForm.partNo = ''
        }
      },
      // 获取原辅材零件号列表
      getMaterialPartNoOptions(materialId) {
        if (!materialId) {
          this.materialPartNoOption = []
          return
        }
        getPartNoList({ productId: materialId }).then(res => {
          if (res.code === 200) {
            this.materialPartNoOption = res.data || []
            if (this.materialPartNoOption.length === 0) {
              this.materialForm.partNo = ''
            }
          }
        }).catch(() => {
          this.materialPartNoOption = []
          this.materialForm.partNo = ''
        })
      },
    // 成品信息提交
    submitProForm(state) {
      this.submitProLoading = true
@@ -491,7 +533,8 @@
      const params = {
        ...this.proPlanForm,
        state: state === undefined ? null : parseInt(state),
        productId: selectedNode?.id
        productId: selectedNode?.id,
        itemType: ['成品', '原辅材'][this.tabIndex] // 0成品1原辅材
      }
      addOrUpdateProduct(params).then(res => {