spring
2025-04-08 fcbba75febaa36d23c6c49473ab5bcee0e1a2c04
src/views/structural/capabilityAndLaboratory/capabilityComponents/bindPartDialog.vue
@@ -1,22 +1,20 @@
<template>
  <div>
    <el-dialog title="零件绑定" :visible.sync="isShow" width="800px" @close="$emit('closeBindPartDialog')">
      <lims-table :tableData="tableData" :column="column" height="460"
                  :page="page" :tableLoading="tableLoading"></lims-table>
      <lims-table :tableData="tableData" :column="column" height="460" :page="page" :tableLoading="tableLoading"
        :key="1"></lims-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('closeBindPartDialog')">取 消</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"
               :close-on-click-modal="false" >
      :close-on-click-modal="false">
      <div class="body" v-if="addBindPartDialog">
        <el-form label-position="right" label-width="80px"
                 ref="bindPartData"
                 :rules="bindPartDataRules"
                 :model="bindPartData">
        <el-form label-position="right" label-width="80px" ref="bindPartData" :rules="bindPartDataRules"
          :model="bindPartData">
          <el-form-item label="零件号:" prop="partNo">
            <el-input v-model="bindPartData.partNo" size="small"></el-input>
            <el-input v-model="bindPartData.partNo" size="small" :disabled="dialogTitle == '修改零件绑定'"></el-input>
          </el-form-item>
          <el-form-item label="颜色:" prop="color">
            <el-input v-model="bindPartData.color" size="small"></el-input>
@@ -24,12 +22,31 @@
          <el-form-item label="色标:" prop="colorCode">
            <el-input v-model="bindPartData.colorCode" size="small"></el-input>
          </el-form-item>
          <el-form-item label="进厂检验项:" prop="inspectionItem"
            v-if="currentObj.objectType == '原辅材' || currentObj.objectType == '包材'" label-width="100px">
            <!-- <el-input v-model="bindPartData.inspectionItem" disabled placeholder="选择检验项" size="small">
              <template slot="append">
                <el-button slot="append" icon="el-icon-search" @click="openItems"></el-button>
              </template>
</el-input> -->
            <el-select v-model="bindPartData.inspectionItem" multiple collapse-tags placeholder="请选择" size="small">
              <el-option v-for="item in itemList" :key="item.inspectionItem" :label="item.inspectionItem"
                :value="item.inspectionItem">
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeBindPartDialog">取 消</el-button>
        <el-button type="primary" @click="submitBind" :loading="bindLoad">确 认</el-button>
        <el-button type="primary" @click="submitBind">确 认</el-button>
      </span>
    </el-dialog>
    <el-dialog title="修改记录" :visible.sync="editItem" width="900px">
      <div class="body" v-if="editItem">
        <lims-table :tableData="editList" :column="editColumn" height="460px" :tableLoading="tableLoading0" :key="2"
          :page="editPage" @pagination="editPagination"></lims-table>
      </div>
    </el-dialog>
  </div>
</template>
@@ -38,16 +55,22 @@
import limsTable from "@/components/Table/lims-table.vue";
import {
  addProductPart,
  addTestObjectPart, deleteProductPart, deleteTestObjectPart,
  addTestObjectPart,
  deleteProductPart,
  deleteTestObjectPart,
  selectByProductId,
  selectByTestObjectId, updateProductPart, updateTestObjectPart
  selectByTestObjectId,
  updateProductPart,
  updateTestObjectPart,
  inspectionItems,
  productPartReview,
  productPartLogList
} from "@/api/structural/structureTestObjectPart";
import {delProduct} from "@/api/structural/capability";
export default {
  name: "bindPartDialog",
  // import 引入的组件需要注入到对象中才能使用
  components: {limsTable},
  components: { limsTable },
  props: {
    bindPartDialog: {
      type: Boolean,
@@ -57,10 +80,14 @@
      type: Number,
      default: () => null
    },
    currentRow : { // 选择本条数据的信息
    currentRow: { // 选择本条数据的信息
      type: Object,
      default: () => {}
    }
      default: () => { }
    },
    currentObj: {//当前对象
      type: Object,
      default: () => { }
    },
  },
  data() {
    // 这里存放数据
@@ -71,9 +98,21 @@
      tableData: [],
      tableLoading: false,
      column: [
        {label: '零件号', prop: 'partNo'},
        {label: '颜色', prop: 'color'},
        {label: '色标', prop: 'colorCode'},
        { label: '零件号', prop: 'partNo' },
        { label: '颜色', prop: 'color' },
        { label: '色标', prop: 'colorCode' },
        { label: '进厂检验项', prop: 'inspectionItem' },
        {
          label: '状态', prop: 'review',
          dataType: "tag",
          formatType: (params) => {
            if (params == '待复核') {
              return 'danger'
            } else {
              return 'success'
            }
          },
        },
        {
          dataType: 'action',
          fixed: 'right',
@@ -93,13 +132,40 @@
                this.delete(row);
              },
            },
            {
              name: '复核',
              type: 'text',
              clickFun: (row) => {
                this.$confirm("是否复核通过?", "复核", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                })
                  .then(() => {
                    productPartReview({ id: row.id, type: this.type == 0 ? '对象' : '产品' }).then((res) => {
                      if (res.code == 200) {
                        this.$message.success("复核通过");
                        this.getList();
                      }
                    });
                  })
                  .catch(() => { });
              },
            },
            {
              name: '记录',
              type: 'text',
              clickFun: (row) => {
                this.lookList(row);
              },
            },
          ]
        }
      ],
      page: {
        total:0,
        size:10,
        current:1,
        total: 0,
        size: 10,
        current: 1,
        layout: 'total, prev, pager, next'
      },
      bindPartComponent: {
@@ -135,6 +201,7 @@
        partNo: '', // 零件号
        color: '', // 颜色
        colorCode: '', // 色标
        inspectionItem: [],//原辅材进厂检验对象列表
      },
      bindPartDataRules: {
        partNo: [
@@ -143,19 +210,82 @@
      },
      bindLoad: false,
      upIndex: 0,
      addBindLoad: false,
      itemList: [],//原辅材进厂检验对象列表
      editItem: false,
      editList: [],
      editColumn: [
        { label: '零件号', prop: 'partNo' },
        { label: '颜色', prop: 'color' },
        { label: '色标', prop: 'colorCode' },
        { label: '进厂检验项', prop: 'inspectionItem' },
        {
          label: '状态', prop: 'review',
          dataType: "tag",
          formatType: (params) => {
            if (params == '待复核') {
              return 'danger'
            } else {
              return 'success'
            }
          },
        },
        { label: '修改时间', prop: 'operTime' },
        { label: '修改人', prop: 'operName' },
      ],
      editPage: {
        total: 0,
        size: 10,
        current: 0,
      },
      tableLoading0: false,
      currentPart: {},//当前零件
      // mutilSelect: []
    }
  },
  mounted() {
    this.getList()
    this.getItemList()
  },
  // 方法集合
  methods: {
    getItemList() {
      // this.tableLoading0 = true;
      inspectionItems({
        sample: this.currentObj.specimenName,
        productName: this.type == 0 ? null : this.currentRow.name
      }).then(res => {
        this.itemList = res.data
        // this.tableLoading0 = false;
      })
    },
    // 修改记录
    lookList(row) {
      this.currentPart = row;
      this.editItem = true;
      this.getEditList()
    },
    getEditList() {
      this.tableLoading0 = true
      productPartLogList({ id: this.currentPart.id, type: this.type == 0 ? '对象' : '产品', ...this.editPage }).then(res => {
        this.tableLoading0 = false
        if (res.code == 200) {
          this.editList = res.data.records
          this.editPage.total = res.data.total
        }
      })
    },
    editPagination() {
      this.editPage.current = page;
      this.editPage.size = limit;
      this.getEditList();
    },
    getList() {
      this.tableLoading = true
      // 根据类型判断是检验对象零件绑定还是产品维护零件绑定
      if (this.type === 0) {
        selectByTestObjectId({testObjectId: this.currentRow.id}).then(res => {
        selectByTestObjectId({ testObjectId: this.currentRow.id }).then(res => {
          this.tableLoading = false
          if (res.code === 200) {
            this.tableData = res.data.records
@@ -165,7 +295,7 @@
          this.tableLoading = false
        })
      } else {
        selectByProductId({productId: this.currentRow.id}).then(res => {
        selectByProductId({ productId: this.currentRow.id }).then(res => {
          this.tableLoading = false
          if (res.code === 200) {
            this.tableData = res.data.records
@@ -176,16 +306,19 @@
        })
      }
    },
    addBindPart (type, row) {
    addBindPart(type, row) {
      this.addBindPartDialog = true
      this.dialogTitle = type === 'add' ? '新增零件绑定' : '修改零件绑定'
      this.operationType = type
      if (type === 'edit') {
        this.bindPartData = this.HaveJson(row)
        this.bindPartData.inspectionItem = this.bindPartData.inspectionItem ? this.bindPartData.inspectionItem.split(',') : []
      } else {
        this.bindPartData = {}
      }
    },
    // 提交零件绑定
    submitBind () {
    submitBind() {
      this.$refs['bindPartData'].validate((valid) => {
        if (valid) {
          // 根据类型判断是检验对象零件绑定还是产品维护零件绑定
@@ -194,16 +327,21 @@
            color: this.bindPartData.color,
            colorCode: this.bindPartData.colorCode,
            partNo: this.bindPartData.partNo,
            } : {
            id: this.bindPartData.id,
            inspectionItem: this.bindPartData.inspectionItem && this.bindPartData.inspectionItem.length > 0 ? this.bindPartData.inspectionItem.join(',') : ''
          } : {
            productId: this.currentRow.id,
            color: this.bindPartData.color,
            colorCode: this.bindPartData.colorCode,
            partNo: this.bindPartData.partNo,
            id: this.bindPartData.id,
            inspectionItem: this.bindPartData.inspectionItem && this.bindPartData.inspectionItem.length > 0 ? this.bindPartData.inspectionItem.join(',') : ''
          }
          this.bindLoad = true
          if (this.operationType === 'add') {
            if (this.type === 0) {
              addTestObjectPart(params).then(res => {
                this.bindLoad = false
                if (res.code === 200) {
                  this.resetForm('bindPartData')
                  this.addBindPartDialog = false
@@ -216,6 +354,7 @@
              })
            } else {
              addProductPart(params).then(res => {
                this.bindLoad = false
                if (res.code === 200) {
                  this.resetForm('bindPartData')
                  this.addBindPartDialog = false
@@ -260,21 +399,21 @@
        }
      })
    },
    delete (row) {
    delete(row) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (this.type === 0) {
          deleteTestObjectPart({id:row.id}).then(res => {
          deleteTestObjectPart({ id: row.id }).then(res => {
            if (res.code === 200) {
              this.$message.success('删除成功')
              this.getList();
            }
          })
        } else {
          deleteProductPart({id:row.id}).then(res => {
          deleteProductPart({ id: row.id }).then(res => {
            if (res.code === 200) {
              this.$message.success('删除成功')
              this.getList();
@@ -288,13 +427,23 @@
        });
      })
    },
    closeBindPartDialog () {
    closeBindPartDialog() {
      this.resetForm('bindPartData')
      this.addBindPartDialog = false
    },
    // openItems() {
    //   this.mutilSelect = this.bindPartData.inspectionItem ? this.bindPartData.inspectionItem.split(',') : []
    //   this.$refs.itemTable.toggleRowSelection(this.mutilSelect)
    //   this.addBindItem = true;
    // },
    // submitBindItem() {
    //   this.bindPartData.inspectionItem = this.mutilSelect.join(',')
    // },
    // handleSelectionChange(val) {
    //   this.mutilSelect = val
    // }
  },
}
</script>
<style scoped>
</style>
<style scoped></style>