gaoluyang
2025-02-15 b1187d1141a17fea3a7c184db73f232ca9877a85
src/components/capability/bindPartDialog.vue
@@ -7,7 +7,7 @@
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('closeBindPartDialog')">取 消</el-button>
        <el-button type="primary" @click="addBindPart" :loading="addBindLoad">新 增</el-button>
        <el-button type="primary" @click="addBindPart('add')" :loading="addBindLoad">新 增</el-button>
      </span>
    </el-dialog>
    <el-dialog :title="dialogTitle" :visible.sync="addBindPartDialog" width="400px" @close="closeBindPartDialog"
@@ -20,10 +20,10 @@
          <el-form-item label="零件号:" prop="partNo">
            <el-input v-model="bindPartData.partNo" size="small"></el-input>
          </el-form-item>
          <el-form-item label="颜色:">
          <el-form-item label="颜色:" prop="color">
            <el-input v-model="bindPartData.color" size="small"></el-input>
          </el-form-item>
          <el-form-item label="色标:">
          <el-form-item label="色标:" prop="colorCode">
            <el-input v-model="bindPartData.colorCode" size="small"></el-input>
          </el-form-item>
        </el-form>
@@ -38,7 +38,13 @@
<script>
import limsTable from "@/components/Table/lims-table.vue";
import {selectByProductId, selectByTestObjectId} from "@/api/structural/structureTestObjectPart";
import {
  addProductPart,
  addTestObjectPart, deleteProductPart, deleteTestObjectPart,
  selectByProductId,
  selectByTestObjectId, updateProductPart, updateTestObjectPart
} from "@/api/structural/structureTestObjectPart";
import {delProduct} from "@/api/structural/capability";
export default {
  name: "bindPartDialog",
@@ -63,6 +69,7 @@
    return {
      isShow: this.bindPartDialog,
      dialogTitle: '新增零件绑定',
      operationType: '',
      tableData: [],
      tableLoading: false,
      column: [
@@ -78,7 +85,7 @@
              name: '编辑',
              type: 'text',
              clickFun: (row) => {
                this.editForm(row);
                this.addBindPart('edit', row);
              },
            },
            {
@@ -149,29 +156,34 @@
      this.tableLoading = true
      // 根据类型判断是检验对象零件绑定还是产品维护零件绑定
      if (this.type === 0) {
        selectByTestObjectId(this.currentRow.id).then(res => {
        selectByTestObjectId({id: this.currentRow.id}).then(res => {
          this.tableLoading = false
          if (res.code === 200) {
            this.tableData = res.data
            this.page.total = res.total
            this.tableData = res.data.records
            this.page.total = res.data.total
          }
        }).catch(err => {
          this.tableLoading = false
        })
      } else {
        selectByProductId(this.currentRow.id).then(res => {
        selectByProductId({id: this.currentRow.id}).then(res => {
          this.tableLoading = false
          if (res.code === 200) {
            this.tableData = res.data
            this.page.total = res.total
            this.tableData = res.data.records
            this.page.total = res.data.total
          }
        }).catch(err => {
          this.tableLoading = false
        })
      }
    },
    addBindPart () {
    addBindPart (type, row) {
      this.addBindPartDialog = true
      this.dialogTitle = type === 'add' ? '新增零件绑定' : '修改零件绑定'
      this.operationType = type
      if (type === 'edit') {
        this.bindPartData = row
      }
    },
    // 提交零件绑定
    submitBind () {
@@ -190,33 +202,95 @@
            partNo: this.bindPartData.partNo,
          }
          this.bindLoad = true
          if (this.type === 0) {
          if (this.operationType === 'add') {
            if (this.type === 0) {
              addTestObjectPart(params).then(res => {
                if (res.code === 200) {
                  this.resetForm('bindPartData')
                  this.addBindPartDialog = false
                  this.$message.success('新增成功')
                  this.getList()
                }
              }).catch(err => {
                this.bindLoad = false
                console.log(err)
              })
            } else {
              addProductPart(params).then(res => {
                if (res.code === 200) {
                  this.resetForm('bindPartData')
                  this.addBindPartDialog = false
                  this.$message.success('新增成功')
                  this.getList()
                }
              }).catch(err => {
                this.bindLoad = false
                console.log(err)
              })
            }
          } else {
            if (this.type === 0) {
              updateTestObjectPart(params).then(res => {
                if (res.code === 200) {
                  this.resetForm('bindPartData')
                  this.addBindPartDialog = false
                  this.$message.success('修改成功')
                  this.getList()
                }
              }).catch(err => {
                this.bindLoad = false
                console.log(err)
              })
            } else {
              updateProductPart(params).then(res => {
                if (res.code === 200) {
                  this.resetForm('bindPartData')
                  this.addBindPartDialog = false
                  this.$message.success('修改成功')
                  this.getList()
                }
              }).catch(err => {
                this.bindLoad = false
                console.log(err)
              })
            }
          }
          this.$axios.post(url, params, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
            this.bindLoad = false
            if (res.code === 200) {
              this.$refs['bindPartData'].resetFields();
              this.addBindPartDialog = false
              this.$message.success('操作成功')
              this.getList()
            }
          }).catch(err => {
            this.bindLoad = false
            console.log(err)
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      })
    },
    delete (row) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (this.type === 0) {
          deleteTestObjectPart({id:row.id}).then(res => {
            if (res.code === 200) {
              this.$message.success('删除成功')
              this.getList();
            }
          })
        } else {
          deleteProductPart({id:row.id}).then(res => {
            if (res.code === 200) {
              this.$message.success('删除成功')
              this.getList();
            }
          })
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      })
    },
    closeBindPartDialog () {
      this.$refs['bindPartData'].resetFields();
      this.resetForm('bindPartData')
      this.addBindPartDialog = false
    },
  },