gaoluyang
2025-04-16 1ea1ad2c56e95e71e1756cfca73e7183f9795ac9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<template>
  <div>
    <el-dialog title="新增不合格复测" :visible.sync="isShow" width="70%" :show-close="false" :close-on-click-modal="false"
      :close-on-press-escape="false">
      <div class="table">
        <el-table class="el-table" ref="productTable" :data="productList" max-height="800px" tooltip-effect="dark"
                  v-loading="tableLoading" @selection-change="selectProduct" style="margin-bottom: 10px;"
                  :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border @select-all="handleAll">
          <el-table-column type="selection" width="65"></el-table-column>
          <el-table-column prop="isBinding" label="类型" min-width="140" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-select v-model="scope.row.isBinding" clearable size="small">
                <el-option :value="1" label="绑定值"></el-option>
                <el-option :value="0" label="不合格值"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column prop="inspectionItemClass" label="检验项分类" min-width="140" show-overflow-tooltip></el-table-column>
          <el-table-column prop="inspectionItem" label="检验项" min-width="140" show-overflow-tooltip></el-table-column>
          <el-table-column prop="inspectionItemSubclass" label="检验项子项" min-width="140"
            show-overflow-tooltip></el-table-column>
          <el-table-column prop="tell" label="要求描述" min-width="220px"></el-table-column>
          <el-table-column prop="ask" label="要求值" min-width="220px"></el-table-column>
          <el-table-column prop="lastValue" label="检验结果" min-width="140" show-overflow-tooltip></el-table-column>
          <el-table-column prop="insResult" label="结果判定" min-width="140" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-tag type="success" v-if="scope.row.insResult === 1">合格</el-tag>
              <el-tag type="danger" v-if="scope.row.insResult === 0">不合格</el-tag>
              <el-tag type="info" v-if="scope.row.insResult === 3">不判定</el-tag>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('resetAddUnPass')">取 消</el-button>
        <el-button type="primary" @click="submitHandle" :loading="handlePassLoading">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import {addUnqualifiedRetest, getInsProductUnqualified} from '@/api/business/unpass.js'
import {getInsProduct} from "@/api/business/inspectionTask";
export default {
  name: "addUnPass",
  // import 引入的组件需要注入到对象中才能使用
  components: {},
  props: {
    addUnPassDialog: {
      type: Boolean,
      default: () => false
    },
  },
  data() {
    // 这里存放数据
    return {
      type: '',
      isShow: this.addUnPassDialog,
      handlePassLoading: false,
      productList: [],
      productListSelected: [],
      productIds: [],
      tableLoading: false
    }
  },
  mounted() {
  },
  // 方法集合
  methods: {
    getInsOrder(info) {
      this.tableLoading = true
      try {
        getInsProduct({ id: info.id, type: info.type, laboratory: info.laboratory, rawMaterialTag: info.rawMaterialTag,repetitionTag: info.repetitionTag,cableTag: info.cableTag }).then(res => {
          if (res.code === 200) {
            this.productList = res.data
          }
          this.tableLoading = false
        })
      } catch (err) {
        this.tableLoading = false
      }
    },
    // 提交不合格处理
    submitHandle() {
      if (this.productListSelected.length === 0) {
        this.$message.warning('请选择需要复测的检验项')
        return
      }
      // 检查是否所有选中的行都选择了 isBinding
      const hasUnselectedBinding = this.productListSelected.some(
        (row) => row.isBinding === null || row.isBinding === undefined
      );
 
      if (hasUnselectedBinding) {
        this.$message.error("请确保选中的数据都选择了类型!");
        return;
      }
      this.$confirm('确认提交不合格复测?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.handlePass()
      }).catch(() => {
 
      });
    },
    handlePass() {
      const ids = this.productListSelected.map(item => ({
        id: item.id,
        isBinding: item.isBinding
      }));
      this.handlePassLoading = true
      try {
        addUnqualifiedRetest(ids).then(res => {
          if (res.code === 200) {
            this.$message.success('提交成功')
            this.$emit('resetAddUnPass')
          }
          this.handlePassLoading = false
        }).catch(e => {
          this.handlePassLoading = false
        })
      } catch (e) {
        this.handlePassLoading = false
      }
    },
    selectProduct(val) {
      this.productListSelected = val
      this.productIds = []
      val.forEach(a => {
        this.productIds.push(a.id)
      })
    },
    handleAll(val) {
      this.productListSelected = val
      this.productIds = []
      val.forEach(a => {
        this.productIds.push(a.id)
      })
    },
  },
}
</script>
 
<style scoped></style>