<template>
|
<view class="material-inspection-page">
|
<!-- 使用通用页面头部组件 -->
|
<PageHeader title="过程检验"
|
@back="goBack" />
|
<!-- 搜索区域 -->
|
<view class="search-section">
|
<view class="search-bar">
|
<view class="search-input">
|
<up-input class="search-text"
|
placeholder="请输入工序搜索"
|
v-model="searchForm.process"
|
@change="getList"
|
clearable />
|
</view>
|
<!-- <view class="filter-button"
|
@click="showDatePicker">
|
<up-icon name="calendar"
|
size="24"
|
color="#999"></up-icon>
|
</view> -->
|
<view class="filter-button"
|
@click="getList">
|
<up-icon name="search"
|
size="24"
|
color="#999"></up-icon>
|
</view>
|
</view>
|
<!-- 日期选择 -->
|
<!-- <view class="date-range"
|
v-if="searchForm.entryDate">
|
<text class="date-text">{{ searchForm.entryDate[0] }} 至 {{ searchForm.entryDate[1] }}</text>
|
<up-icon name="close"
|
size="16"
|
color="#999"
|
@click="clearDateRange"></up-icon>
|
</view> -->
|
</view>
|
<!-- 统计信息卡片 -->
|
<!-- <view class="stats-cards">
|
<view class="stat-card">
|
<text class="stat-number">{{ totalCount }}</text>
|
<text class="stat-label">总检验</text>
|
</view>
|
<view class="stat-card">
|
<text class="stat-number">{{ submittedCount }}</text>
|
<text class="stat-label">已提交</text>
|
</view>
|
<view class="stat-card">
|
<text class="stat-number">{{ pendingCount }}</text>
|
<text class="stat-label">待提交</text>
|
</view>
|
<view class="stat-card">
|
<text class="stat-number">{{ qualifiedCount }}</text>
|
<text class="stat-label">已合格</text>
|
</view>
|
</view> -->
|
<!-- 检验列表 -->
|
<view class="inspection-list"
|
v-if="inspectionList.length > 0">
|
<view v-for="(item, index) in inspectionList"
|
:key="index">
|
<view class="inspection-item"
|
@click="viewDetail(item)">
|
<view class="item-header">
|
<view class="item-left">
|
<!-- <view class="material-icon"
|
:class="getStateClass(item.inspectState)">
|
<up-icon :name="getStateIcon(item.inspectState)"
|
size="16"
|
color="#ffffff"></up-icon>
|
</view> -->
|
<view class="material-info">
|
<text class="material-name">{{ item.productName }}</text>
|
<text class="material-code">{{ item.model }}</text>
|
</view>
|
</view>
|
<view class="status-tags">
|
<u-tag :type="getTagType(item.checkResult)"
|
size="mini"
|
class="status-tag">
|
{{ item.checkResult }}
|
</u-tag>
|
<u-tag :type="getStateTagType(item.inspectState)"
|
size="mini"
|
class="status-tag">
|
{{ item.inspectState ? '已提交' : '未提交' }}
|
</u-tag>
|
</view>
|
</view>
|
<up-divider></up-divider>
|
<view class="item-details">
|
<view class="detail-row">
|
<text class="detail-label">检测日期</text>
|
<text class="detail-value">{{ formatDateTime(item.checkTime) || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">生产工单号</text>
|
<text class="detail-value">{{ item.workOrderNo || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">工序</text>
|
<text class="detail-value">{{ item.process || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">检验员</text>
|
<text class="detail-value">{{ item.checkName || '-' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">数量</text>
|
<text class="detail-value">{{ item.quantity || 0 }} {{ item.unit || '' }}</text>
|
</view>
|
<view class="detail-row">
|
<text class="detail-label">检测单位</text>
|
<text class="detail-value">{{ item.checkCompany || '-' }}</text>
|
</view>
|
</view>
|
<!-- 操作按钮 -->
|
<view class="action-buttons">
|
<!-- <u-button type="primary"
|
size="small"
|
class="action-btn"
|
:disabled="item.inspectState"
|
@click.stop="startInspection(item)">
|
编辑
|
</u-button> -->
|
<u-button type="info"
|
size="small"
|
class="action-btn"
|
@click.stop="viewDetail(item)">
|
详情
|
</u-button>
|
<!-- <u-button type="success"
|
size="small"
|
class="action-btn"
|
:disabled="item.inspectState"
|
@click.stop="submitInspection(item)">
|
提交
|
</u-button> -->
|
</view>
|
<view class="action-buttons">
|
<!-- <u-button type="info"
|
size="small"
|
class="action-btn"
|
@click.stop="viewFileList(item)">
|
附件
|
</u-button>
|
<u-button type="warning"
|
size="small"
|
class="action-btn"
|
:disabled="item.inspectState || item.checkName !== ''"
|
@click.stop="assignInspector(item)">
|
分配检验员
|
</u-button> -->
|
</view>
|
</view>
|
</view>
|
</view>
|
<view v-else
|
class="no-data">
|
<up-empty mode="data"
|
text="暂无检验任务"></up-empty>
|
</view>
|
<!-- 分页组件 -->
|
<!-- 浮动新增按钮 -->
|
<!-- <view class="fab-button"
|
@click="addInspection">
|
<up-icon name="plus"
|
size="24"
|
color="#ffffff"></up-icon>
|
</view> -->
|
<!-- 日期选择器 -->
|
<up-popup v-model:show="showDate"
|
mode="date"
|
:start-year="2020"
|
:end-year="2030"
|
:range="true"
|
@confirm="confirmDate" />
|
<!-- 分配检验员弹窗 -->
|
<up-popup v-model:show="showAssignDialog"
|
mode="center"
|
round
|
style="width: 80%">
|
<view class="assign-dialog">
|
<view class="dialog-header">
|
<text class="dialog-title">分配检验员</text>
|
<up-icon name="close"
|
size="20"
|
color="#999"
|
@click="showAssignDialog = false"></up-icon>
|
</view>
|
<view class="dialog-content">
|
<up-form-item label="检验员"
|
prop="checkName"
|
:label-width="60"
|
required>
|
<up-input v-model="assignForm.checkName"
|
placeholder="请选择检验员"
|
readonly />
|
<template #right>
|
<up-icon @click="showInspectorSheet = true"
|
name="arrow-right" />
|
</template>
|
</up-form-item>
|
</view>
|
<view class="dialog-footer">
|
<u-button type="default"
|
class="footer-btn"
|
@click="showAssignDialog = false">
|
取消
|
</u-button>
|
<u-button type="primary"
|
class="footer-btn"
|
@click="submitAssign">
|
确定
|
</u-button>
|
</view>
|
</view>
|
</up-popup>
|
<!-- 检验员选择 -->
|
<up-action-sheet :show="showInspectorSheet"
|
:actions="userSheetOptions"
|
@select="selectInspector"
|
title="选择检验员" />
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, computed, onMounted } from "vue";
|
import { onShow } from "@dcloudio/uni-app";
|
import PageHeader from "@/components/PageHeader.vue";
|
import dayjs from "dayjs";
|
import {
|
submitQualityInspect,
|
qualityInspectUpdate,
|
qualityInspectListPage,
|
} from "@/api/qualityManagement/materialInspection.js";
|
import { userListNoPage } from "@/api/system/user.js";
|
|
// 显示提示信息
|
const showToast = message => {
|
uni.showToast({
|
title: message,
|
icon: "none",
|
});
|
};
|
|
// 搜索表单
|
const searchForm = ref({
|
process: "",
|
entryDate: undefined,
|
entryDateStart: undefined,
|
entryDateEnd: undefined,
|
});
|
|
// 日期选择器
|
const showDate = ref(false);
|
|
// 分配检验员弹窗
|
const showAssignDialog = ref(false);
|
const showInspectorSheet = ref(false);
|
const assignForm = ref({
|
checkName: "",
|
});
|
const currentAssignRow = ref(null);
|
|
// 检验列表数据
|
const inspectionList = ref([]);
|
|
// 分页数据
|
const page = ref({
|
current: -1,
|
size: -1,
|
total: 0,
|
});
|
|
// 加载状态
|
const tableLoading = ref(false);
|
|
// 统计数据
|
const totalCount = ref(0);
|
const submittedCount = ref(0);
|
const pendingCount = ref(0);
|
const qualifiedCount = ref(0);
|
|
// 检验员列表
|
const userList = ref([]);
|
|
// ActionSheet选项
|
const userSheetOptions = computed(() => {
|
return userList.value.map(item => ({
|
name: item.nickName,
|
value: item.nickName,
|
}));
|
});
|
|
// 返回上一页
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
|
// 格式化日期时间
|
const formatDateTime = dateStr => {
|
if (!dateStr) return "";
|
return dayjs(dateStr).format("YYYY-MM-DD");
|
};
|
|
// 获取状态样式
|
const getStateClass = inspectState => {
|
return inspectState ? "state-submitted" : "state-pending";
|
};
|
|
// 获取状态图标
|
const getStateIcon = inspectState => {
|
return inspectState ? "checkmark-circle" : "time";
|
};
|
|
// 获取标签类型
|
const getTagType = checkResult => {
|
if (checkResult === "合格") return "success";
|
if (checkResult === "不合格") return "error";
|
return "default";
|
};
|
|
// 获取状态标签类型
|
const getStateTagType = inspectState => {
|
return inspectState ? "success" : "warning";
|
};
|
|
// 显示日期选择器
|
const showDatePicker = () => {
|
showDate.value = true;
|
};
|
|
// 确认日期选择
|
const confirmDate = e => {
|
searchForm.value.entryDate = e.value;
|
searchForm.value.entryDateStart = dayjs(e.value[0]).format("YYYY-MM-DD");
|
searchForm.value.entryDateEnd = dayjs(e.value[1]).format("YYYY-MM-DD");
|
getList();
|
};
|
const viewFileList = item => {
|
uni.setStorageSync("qualityInspectFileId", item.id);
|
uni.navigateTo({
|
url: "/pages/qualityManagement/processInspection/fileList",
|
});
|
};
|
|
// 清除日期范围
|
const clearDateRange = () => {
|
searchForm.value.entryDate = undefined;
|
searchForm.value.entryDateStart = undefined;
|
searchForm.value.entryDateEnd = undefined;
|
getList();
|
};
|
|
// 获取用户列表
|
const getUserList = async () => {
|
try {
|
const userRes = await userListNoPage();
|
userList.value = userRes.data || [];
|
} catch (e) {
|
console.error("加载检验员列表失败", e);
|
userList.value = [];
|
}
|
};
|
|
// 查询列表
|
const getList = () => {
|
tableLoading.value = true;
|
const params = { ...searchForm.value, ...page.value };
|
params.entryDate = undefined;
|
qualityInspectListPage({ ...params, inspectType: 1 })
|
.then(res => {
|
tableLoading.value = false;
|
inspectionList.value = res.data.records || [];
|
page.value.total = res.data.total || 0;
|
totalCount.value = res.data.total || 0;
|
submittedCount.value = inspectionList.value.filter(
|
item => item.inspectState
|
).length;
|
pendingCount.value = inspectionList.value.filter(
|
item => !item.inspectState
|
).length;
|
qualifiedCount.value = inspectionList.value.filter(
|
item => item.checkResult === "合格"
|
).length;
|
})
|
.catch(err => {
|
tableLoading.value = false;
|
console.error("获取列表失败:", err);
|
showToast("获取列表失败,请重试");
|
});
|
};
|
|
// 编辑检验
|
const startInspection = item => {
|
if (!item) {
|
showToast("参数错误");
|
return;
|
}
|
// 存储完整的检验数据
|
uni.setStorageSync("processInspectionEditData", item);
|
// 跳转到编辑页面
|
uni.navigateTo({
|
url: `/pages/qualityManagement/processInspection/add?id=${item.id}&isEdit=true`,
|
});
|
};
|
|
// 查看详情
|
const viewDetail = item => {
|
if (!item) {
|
showToast("参数错误");
|
return;
|
}
|
uni.setStorageSync("processInspectionEditData", item);
|
// 跳转到详情页面
|
uni.navigateTo({
|
url: `/pages/qualityManagement/processInspection/detail?id=${item.id}`,
|
});
|
};
|
|
// 新增检验
|
const addInspection = () => {
|
uni.navigateTo({
|
url: "/pages/qualityManagement/processInspection/add",
|
});
|
};
|
|
// 提交检验
|
const submitInspection = async item => {
|
if (!item) {
|
showToast("参数错误");
|
return;
|
}
|
try {
|
const res = await submitQualityInspect({ id: item.id });
|
if (res.code === 200) {
|
showToast("提交成功");
|
setTimeout(() => {
|
getList();
|
}, 1000);
|
} else {
|
showToast("提交失败:" + (res.msg || "未知错误"));
|
}
|
} catch (error) {
|
console.error("提交失败:", error);
|
showToast("提交失败,请重试");
|
}
|
};
|
|
// 分配检验员
|
const assignInspector = item => {
|
if (!item) {
|
showToast("参数错误");
|
return;
|
}
|
currentAssignRow.value = item;
|
getUserList();
|
showAssignDialog.value = true;
|
};
|
|
// 选择检验员
|
const selectInspector = e => {
|
assignForm.value.checkName = e.value;
|
showInspectorSheet.value = false;
|
};
|
|
// 提交分配
|
const submitAssign = async () => {
|
if (!currentAssignRow.value || !assignForm.value.checkName) {
|
showToast("请选择检验员");
|
return;
|
}
|
try {
|
const data = {
|
...assignForm.value,
|
id: currentAssignRow.value.id,
|
};
|
const res = await qualityInspectUpdate(data);
|
if (res.code === 200) {
|
showToast("分配成功");
|
showAssignDialog.value = false;
|
setTimeout(() => {
|
getList();
|
}, 1000);
|
} else {
|
showToast("分配失败:" + (res.msg || "未知错误"));
|
}
|
} catch (error) {
|
console.error("分配失败:", error);
|
showToast("分配失败,请重试");
|
}
|
};
|
|
// 处理分页
|
const handlePagination = obj => {
|
page.value.current = obj.current;
|
page.value.size = obj.size;
|
getList();
|
};
|
|
onMounted(() => {
|
getList();
|
getUserList();
|
});
|
|
onShow(() => {
|
getList();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "../../../styles/sales-common.scss";
|
|
.material-inspection-page {
|
min-height: 100vh;
|
background: #f8f9fa;
|
padding-bottom: 80px;
|
}
|
|
// 搜索区域
|
.search-section {
|
padding: 10px 15px;
|
background: #fff;
|
border-bottom: 1px solid #f0f0f0;
|
}
|
|
.search-bar {
|
display: flex;
|
align-items: center;
|
background: #f8f9fa;
|
border-radius: 20px;
|
padding: 0 15px;
|
height: 40px;
|
}
|
|
.search-input {
|
flex: 1;
|
}
|
|
.search-text {
|
background: transparent;
|
border: none;
|
}
|
|
.filter-button {
|
margin-left: 10px;
|
padding: 5px;
|
}
|
|
// 统计卡片
|
.stats-cards {
|
display: flex;
|
padding: 15px;
|
gap: 10px;
|
background: #fff;
|
margin-bottom: 10px;
|
}
|
|
.stat-card {
|
flex: 1;
|
background: #2979ff;
|
border-radius: 12px;
|
padding: 15px;
|
text-align: center;
|
color: #fff;
|
box-shadow: 0 2px 8px rgba(41, 121, 255, 0.2);
|
}
|
|
.stat-number {
|
display: block;
|
font-size: 20px;
|
font-weight: 600;
|
margin-bottom: 5px;
|
}
|
|
.stat-label {
|
font-size: 12px;
|
opacity: 0.9;
|
}
|
|
// 检验列表
|
.inspection-list {
|
padding: 20px;
|
}
|
|
.inspection-item {
|
background: #ffffff;
|
border-radius: 12px;
|
margin-bottom: 16px;
|
overflow: hidden;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
padding: 0 16px;
|
|
&:active {
|
transform: scale(0.98);
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
|
}
|
}
|
|
.item-header {
|
padding: 16px 0;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
}
|
|
.item-left {
|
display: flex;
|
align-items: center;
|
gap: 8px;
|
}
|
|
.material-icon {
|
width: 24px;
|
height: 24px;
|
background: #2979ff;
|
border-radius: 4px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.state-pending {
|
background: #ff9900;
|
}
|
|
.state-submitted {
|
background: #52c41a;
|
}
|
|
.material-info {
|
flex: 1;
|
}
|
|
.material-name {
|
font-size: 14px;
|
color: #333;
|
font-weight: 500;
|
}
|
|
.material-code {
|
font-size: 12px;
|
color: #999;
|
margin-left: 8px;
|
}
|
|
.status-tags {
|
display: flex;
|
gap: 8px;
|
}
|
|
.status-tag {
|
margin: 0;
|
}
|
|
.date-range {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-top: 10px;
|
padding: 8px 12px;
|
background: #f8f9fa;
|
border-radius: 8px;
|
}
|
|
.date-text {
|
font-size: 12px;
|
color: #666;
|
}
|
|
// 详情行
|
.item-details {
|
padding: 16px 0;
|
}
|
|
.detail-row {
|
display: flex;
|
align-items: flex-end;
|
justify-content: space-between;
|
margin-bottom: 8px;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
}
|
|
.detail-label {
|
font-size: 12px;
|
color: #777777;
|
min-width: 60px;
|
}
|
|
.detail-value {
|
font-size: 12px;
|
color: #000000;
|
text-align: right;
|
flex: 1;
|
margin-left: 16px;
|
}
|
|
// 操作按钮
|
.action-buttons {
|
display: flex;
|
gap: 12px;
|
padding: 0 0 16px 0;
|
justify-content: space-between;
|
}
|
|
.action-btn {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
gap: 8px;
|
}
|
|
// 空状态
|
.no-data {
|
padding: 60px 20px;
|
text-align: center;
|
}
|
|
// 浮动按钮
|
.fab-button {
|
position: fixed;
|
bottom: 20px;
|
right: 20px;
|
width: 56px;
|
height: 56px;
|
background: #2979ff;
|
border-radius: 50%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
box-shadow: 0 4px 16px rgba(41, 121, 255, 0.3);
|
z-index: 1000;
|
}
|
|
// 分配检验员弹窗
|
.assign-dialog {
|
padding: 24px;
|
background: #ffffff;
|
border-radius: 12px;
|
}
|
|
.dialog-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 24px;
|
padding-bottom: 16px;
|
border-bottom: 1px solid #f0f0f0;
|
}
|
|
.dialog-title {
|
font-size: 18px;
|
font-weight: 600;
|
color: #303133;
|
}
|
|
.dialog-content {
|
margin-bottom: 24px;
|
}
|
|
.dialog-footer {
|
display: flex;
|
gap: 16px;
|
padding-top: 16px;
|
border-top: 1px solid #f0f0f0;
|
}
|
|
.footer-btn {
|
flex: 1;
|
height: 44px;
|
font-size: 16px;
|
}
|
|
// 输入框样式
|
:deep(.up-input__inner) {
|
border-radius: 8px;
|
height: 44px;
|
font-size: 14px;
|
}
|
|
// 表单项样式
|
:deep(.up-form-item) {
|
margin-bottom: 0;
|
}
|
|
:deep(.up-form-item__label) {
|
font-size: 14px;
|
color: #606266;
|
margin-bottom: 8px;
|
}
|
|
// 按钮样式
|
:deep(.up-button--primary) {
|
border-radius: 8px;
|
}
|
|
:deep(.up-button--default) {
|
border-radius: 8px;
|
}
|
|
// 分页组件
|
.pagination {
|
padding: 20px;
|
background: #fff;
|
margin-top: 10px;
|
display: flex;
|
justify-content: center;
|
}
|
</style>
|