gaoluyang
2026-06-16 e65bfa1d46d255f307eaa057665f01c8bde0e122
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
263
264
265
266
267
268
<template>
  <div class="app-container">
    <div class="search_form">
      <el-form :model="queryParams" inline style="margin-bottom: 0;">
        <el-form-item label="处理单编号">
          <el-input v-model="queryParams.orderNo" style="width: 200px" placeholder="输入编号" clearable
            :prefix-icon="Search" @change="handleQuery" />
        </el-form-item>
        <el-form-item label="项目名称">
          <el-input v-model="queryParams.projectName" style="width: 200px" placeholder="输入项目" clearable
            :prefix-icon="Search" @change="handleQuery" />
        </el-form-item>
<!--        <el-form-item label="状态">&ndash;&gt;-->
<!--          <el-select v-model="queryParams.status" clearable style="width: 150px" @change="handleQuery" placeholder="全部">&ndash;&gt;-->
<!--            <el-option label="草稿" :value="0" />&ndash;&gt;-->
<!--            <el-option label="待审批" :value="1" />&ndash;&gt;-->
<!--            <el-option label="审批中" :value="2" />&ndash;&gt;-->
<!--            <el-option label="已完成" :value="3" />&ndash;&gt;-->
<!--            <el-option label="已驳回" :value="4" />&ndash;&gt;-->
<!--          </el-select>&ndash;&gt;-->
<!--        </el-form-item>&ndash;&gt;-->
        <el-form-item label="创建时间">
          <el-date-picker v-model="dateRange" value-format="YYYY-MM-DD" type="daterange"
            style="width: 260px" placeholder="请选择" clearable @change="changeDaterange" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleQuery">搜索</el-button>
          <el-button @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="mb20" style="text-align: right;">
      <el-button type="primary" @click="handleAdd">新增处理单</el-button>
      <el-button type="danger" plain :disabled="!selectedRows.length" @click="handleDelete">删除</el-button>
    </div>
    <div class="table_list">
      <PIMTable rowKey="id" :column="tableColumn" :tableData="tableData" :page="page"
        :isSelection="true" @selection-change="handleSelectionChange"
        :tableLoading="tableLoading" @pagination="pagination" :total="page.total" />
    </div>
    <OrderFormDia ref="orderFormDia" @close="handleQuery" />
  </div>
</template>
 
<script setup>
import { Search } from "@element-plus/icons-vue";
import { onMounted, ref, reactive, nextTick, getCurrentInstance } from "vue";
import { ElMessageBox } from "element-plus";
import {
  qualityUnqualifiedOrderListPage,
  deleteQualityUnqualifiedOrder,
} from "@/api/qualityManagement/nonconformingManagement.js";
import OrderFormDia from "@/views/qualityManagement/nonconformingManagement/components/orderFormDia.vue";
import dayjs from "dayjs";
 
const { proxy } = getCurrentInstance();
 
const disposalMethodMap = { 1: "让步接收", 2: "厂内维修", 3: "返厂维修", 4: "换货", 5: "退货", 6: "报废" };
const statusMap = { 0: "草稿", 1: "待审批", 2: "审批中", 3: "已完成", 4: "已驳回" };
 
const queryParams = reactive({
  orderNo: "",
  projectName: "",
  status: null,
  entryDateStart: undefined,
  entryDateEnd: undefined,
});
 
const dateRange = ref(undefined);
const tableData = ref([]);
const selectedRows = ref([]);
const tableLoading = ref(false);
const page = reactive({
  current: 1,
  size: 100,
  total: 0,
});
const orderFormDia = ref();
 
const tableColumn = ref([
  {
    label: "处理单编号",
    prop: "orderNo",
    width: 160,
  },
  {
    label: "项目名称",
    prop: "projectName",
  },
  {
    label: "型号规格",
    prop: "specificationModel",
    width: 120,
  },
  {
    label: "不合格数量",
    prop: "unqualifiedQuantity",
    width: 100,
  },
  {
    label: "处置方式",
    prop: "disposalMethod",
    width: 110,
    dataType: "tag",
    formatData: (val) => disposalMethodMap[val] || "",
  },
  // {
  //   label: "状态",
  //   prop: "status",
  //   width: 80,
  //   dataType: "tag",
  //   formatData: (val) => statusMap[val] || "",
  //   formatType: (val) => {
  //     const map = { 0: "info", 1: "warning", 2: "", 3: "success", 4: "danger" };
  //     return map[val] || "info";
  //   },
  // },
  {
    label: "检验员",
    prop: "inspectorName",
    width: 100,
  },
  {
    label: "检验日期",
    prop: "inspectDate",
    width: 110,
  },
  {
    label: "创建时间",
    prop: "createTime",
    width: 160,
  },
  {
    dataType: "action",
    label: "操作",
    align: "center",
    fixed: "right",
    width: 160,
    operation: [
      {
        name: "导出",
        type: "text",
        clickFun: (row) => {
          handleExport(row);
        },
      },
      {
        name: "处置",
        type: "text",
        showHide: (row) => row.status === 0,
        clickFun: (row) => {
          nextTick(() => {
            orderFormDia.value?.openDialog("dispose", row);
          });
        },
      },
      {
        name: "编辑",
        type: "text",
        clickFun: (row) => {
          nextTick(() => {
            orderFormDia.value?.openDialog("edit", row);
          });
        },
      },
      {
        name: "详情",
        type: "text",
        clickFun: (row) => {
          nextTick(() => {
            orderFormDia.value?.openDialog("view", row);
          });
        },
      },
    ],
  },
]);
 
const changeDaterange = (value) => {
  queryParams.entryDateStart = undefined;
  queryParams.entryDateEnd = undefined;
  if (value) {
    queryParams.entryDateStart = dayjs(value[0]).format("YYYY-MM-DD");
    queryParams.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD");
  }
  getList();
};
 
const handleQuery = () => {
  page.current = 1;
  getList();
};
 
const resetQuery = () => {
  queryParams.orderNo = "";
  queryParams.projectName = "";
  queryParams.status = null;
  dateRange.value = undefined;
  queryParams.entryDateStart = undefined;
  queryParams.entryDateEnd = undefined;
  handleQuery();
};
 
const pagination = (obj) => {
  page.current = obj.page;
  page.size = obj.limit;
  getList();
};
 
const getList = () => {
  tableLoading.value = true;
  const params = { ...queryParams, page: page.current, size: page.size };
  qualityUnqualifiedOrderListPage(params)
    .then((res) => {
      tableLoading.value = false;
      tableData.value = res.data?.records || [];
      page.total = res.data?.total || 0;
    })
    .catch(() => {
      tableLoading.value = false;
    });
};
 
const handleSelectionChange = (selection) => {
  selectedRows.value = selection;
};
 
const handleAdd = () => {
  nextTick(() => {
    orderFormDia.value?.openDialog("add", null);
  });
};
 
const handleDelete = () => {
  if (selectedRows.value.length === 0) {
    proxy.$modal.msgWarning("请选择数据");
    return;
  }
  const ids = selectedRows.value.map((item) => item.id);
  ElMessageBox.confirm("选中的处理单将被删除,是否确认?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      deleteQualityUnqualifiedOrder(ids).then(() => {
        proxy.$modal.msgSuccess("删除成功");
        getList();
      });
    })
    .catch(() => {
      proxy.$modal.msg("已取消");
    });
};
 
const handleExport = (row) => {
  proxy.$download.zip(
    `/qualityUnqualifiedOrder/export/${row.id}`,
    `不合格品处理单_${row.orderNo || row.id}.xlsx`
  );
};
 
onMounted(() => {
  getList();
});
</script>
 
<style scoped></style>