liding
2026-06-09 76302992e7bcb60682ee6d3ae9de6619b477b968
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<template>
  <div class="app-container">
    <!-- 查询区域 -->
    <div class="search-form">
      <el-form :model="searchForm" inline size="small">
        <el-form-item label="报告编号">
          <el-input v-model="searchForm.reportNo" placeholder="请输入报告编号" clearable></el-input>
        </el-form-item>
        <el-form-item label="审核状态">
          <el-select v-model="searchForm.status" placeholder="请选择审核状态" clearable>
            <el-option label="待审核" value="0"></el-option>
            <el-option label="已通过" value="1"></el-option>
            <el-option label="已驳回" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="searchList">查询</el-button>
          <el-button @click="resetSearch">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
 
    <!-- 数据表格 -->
    <el-table v-loading="tableLoading" :data="tableData" border>
      <el-table-column label="报告编号" prop="reportNo" show-overflow-tooltip></el-table-column>
      <el-table-column label="产品名称" prop="productName" show-overflow-tooltip></el-table-column>
      <el-table-column label="规格型号" prop="specModel" show-overflow-tooltip></el-table-column>
      <el-table-column label="不合格描述" prop="unqualifiedDesc" show-overflow-tooltip></el-table-column>
      <el-table-column label="检验人员" prop="inspector" show-overflow-tooltip></el-table-column>
      <el-table-column label="登记时间" prop="registerDate" show-overflow-tooltip></el-table-column>
      <el-table-column label="审核状态" prop="status">
        <template slot-scope="scope">
          <el-tag :type="getStatusType(scope.row.status)">
            {{ getStatusText(scope.row.status) }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="审核意见" prop="auditOpinion" show-overflow-tooltip></el-table-column>
      <el-table-column label="审核人员" prop="auditor" show-overflow-tooltip></el-table-column>
      <el-table-column label="审核时间" prop="auditDate" show-overflow-tooltip></el-table-column>
      <el-table-column label="操作" width="200">
        <template slot-scope="scope">
          <el-button type="text" @click="viewDetail(scope.row)">查看</el-button>
          <el-button type="text" v-if="scope.row.status === '0'" @click="openAuditDia(scope.row)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <!-- 分页 -->
    <el-pagination
      :current-page="page.current"
      :page-size="page.size"
      :total="page.total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
 
    <!-- 审核弹窗 -->
    <el-dialog title="不良品审核" :visible.sync="auditVisible" width="500px">
      <el-form :model="auditForm" label-width="100px" size="small">
        <el-form-item label="审核状态">
          <el-radio-group v-model="auditForm.status">
            <el-radio label="1">通过</el-radio>
            <el-radio label="2">驳回</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核意见">
          <el-textarea v-model="auditForm.opinion" :rows="3" placeholder="请输入审核意见"></el-textarea>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="auditVisible = false">取消</el-button>
        <el-button type="primary" @click="submitAudit" :loading="submitLoading">确定审核</el-button>
      </div>
    </el-dialog>
 
    <!-- 详情弹窗 -->
    <el-dialog title="不良品审核详情" :visible.sync="detailVisible" width="600px">
      <el-form :model="detailData" label-width="120px" size="small" disabled>
        <el-form-item label="报告编号">
          <span>{{ detailData.reportNo }}</span>
        </el-form-item>
        <el-form-item label="产品名称">
          <span>{{ detailData.productName }}</span>
        </el-form-item>
        <el-form-item label="规格型号">
          <span>{{ detailData.specModel }}</span>
        </el-form-item>
        <el-form-item label="生产厂家">
          <span>{{ detailData.manufacturer }}</span>
        </el-form-item>
        <el-form-item label="原材料信息">
          <span>{{ detailData.materialInfo }}</span>
        </el-form-item>
        <el-form-item label="不合格描述">
          <span>{{ detailData.unqualifiedDesc }}</span>
        </el-form-item>
        <el-form-item label="检验人员">
          <span>{{ detailData.inspector }}</span>
        </el-form-item>
        <el-form-item label="登记时间">
          <span>{{ detailData.registerDate }}</span>
        </el-form-item>
        <el-form-item label="审核状态">
          <el-tag :type="getStatusType(detailData.status)">
            {{ getStatusText(detailData.status) }}
          </el-tag>
        </el-form-item>
        <el-form-item label="审核意见">
          <span>{{ detailData.auditOpinion || "-" }}</span>
        </el-form-item>
        <el-form-item label="审核人员">
          <span>{{ detailData.auditor || "-" }}</span>
        </el-form-item>
        <el-form-item label="审核时间">
          <span>{{ detailData.auditDate || "-" }}</span>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="detailVisible = false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  pageDefectiveProductAudit,
  auditDefectiveProduct,
  getDefectiveProduct,
} from "@/api/quality/defectiveProduct";
 
export default {
  name: "DefectiveProductAudit",
  data() {
    return {
      searchForm: {
        reportNo: "",
        status: "",
      },
      tableData: [],
      tableLoading: false,
      page: {
        current: 1,
        size: 20,
        total: 0,
      },
      auditVisible: false,
      auditForm: {
        id: null,
        status: "1",
        opinion: "",
      },
      submitLoading: false,
      detailVisible: false,
      detailData: {},
    };
  },
  mounted() {
    this.searchList();
  },
  methods: {
    searchList() {
      this.tableLoading = true;
      pageDefectiveProductAudit({
        ...this.searchForm,
        page: this.page.current,
        size: this.page.size,
      }).then((res) => {
        this.tableData = res.data.records;
        this.page.total = res.data.total;
        this.tableLoading = false;
      }).catch((err) => {
        this.tableLoading = false;
        console.error(err);
      });
    },
    resetSearch() {
      this.searchForm = {
        reportNo: "",
        status: "",
      };
      this.searchList();
    },
    handleSizeChange(val) {
      this.page.size = val;
      this.searchList();
    },
    handleCurrentChange(val) {
      this.page.current = val;
      this.searchList();
    },
    getStatusType(status) {
      switch (status) {
        case "0":
          return "warning";
        case "1":
          return "success";
        case "2":
          return "danger";
        default:
          return "info";
      }
    },
    getStatusText(status) {
      switch (status) {
        case "0":
          return "待审核";
        case "1":
          return "已通过";
        case "2":
          return "已驳回";
        default:
          return "未知";
      }
    },
    openAuditDia(row) {
      this.auditForm = {
        id: row.id,
        status: "1",
        opinion: "",
      };
      this.auditVisible = true;
    },
    submitAudit() {
      this.submitLoading = true;
      auditDefectiveProduct(this.auditForm).then((res) => {
        if (res.code === 200) {
          this.$message.success("审核成功");
          this.auditVisible = false;
          this.searchList();
        } else {
          this.$message.error(res.msg || "审核失败");
        }
        this.submitLoading = false;
      }).catch((err) => {
        this.submitLoading = false;
        console.error(err);
      });
    },
    viewDetail(row) {
      getDefectiveProduct({ id: row.id }).then((res) => {
        this.detailData = res.data;
        this.detailVisible = true;
      }).catch((err) => {
        console.error(err);
      });
    },
  },
};
</script>
 
<style scoped>
.search-form {
  margin-bottom: 15px;
}
 
.dialog-footer {
  text-align: right;
}
</style>