<template>
|
<view class="nonconforming-management-page">
|
<PageHeader title="不合格品管理" @back="goBack" />
|
|
<!-- 搜索与筛选(样式参照仓储物流模块) -->
|
<view class="search-section">
|
<view class="search-row">
|
<view class="search-input-wrap">
|
<up-input v-model="searchForm.productName" placeholder="产品名称" clearable />
|
</view>
|
<view class="btn-search" @click="handleQuery">
|
<view class="btn-search-inner">
|
<up-icon name="search" size="22" color="#fff"></up-icon>
|
<text>搜索</text>
|
</view>
|
</view>
|
</view>
|
<view class="filter-row">
|
<view class="filter-item" @click="showTypeSelect = true">
|
<text>{{ typeLabel }}</text>
|
<up-icon name="arrow-down" size="14" color="#999"></up-icon>
|
</view>
|
<view class="filter-item" @click="openDateRange">
|
<text>{{ dateRangeLabel }}</text>
|
<up-icon name="calendar" size="14" color="#999"></up-icon>
|
</view>
|
</view>
|
</view>
|
|
<!-- 列表区域 -->
|
<view class="list-section">
|
<view v-if="tableData.length > 0">
|
<view v-for="(item, index) in tableData" :key="item.id || index" class="card-item">
|
<view class="card-click" @click="openForm('edit', item)">
|
<view class="card-header">
|
<view class="header-main">
|
<text class="product-name">{{ item.productName }}</text>
|
</view>
|
<view class="header-sub">
|
<text class="sub-title">{{ item.model || '-' }}</text>
|
<up-tag :text="getInspectTypeText(item.checkType ?? item.inspectType)" type="primary" size="mini" />
|
</view>
|
</view>
|
<up-divider />
|
<view class="card-body">
|
<view class="row"><text class="l">检测日期</text><text class="r">{{ item.checkTime || '-' }}</text></view>
|
<view class="row"><text class="l">批号</text><text class="r">{{ item.batchNo || '-' }}</text></view>
|
<view class="row"><text class="l">检验员</text><text class="r">{{ item.checkName || '-' }}</text></view>
|
<view class="row"><text class="l">不合格现象</text><text class="r text-error">{{ item.defectivePhenomena || '-' }}</text></view>
|
<view class="row" v-if="item.inspectState == 1"><text class="l">处理结果</text><text class="r text-success">{{ getDealResultLabel(item.dealResult) || item.dealResult || '-' }}</text></view>
|
<view class="row" v-if="item.inspectState == 1"><text class="l">处理人</text><text class="r">{{ item.dealName || '-' }}</text></view>
|
<view class="row" v-if="item.inspectState == 1"><text class="l">处理日期</text><text class="r">{{ item.dealTime || '-' }}</text></view>
|
</view>
|
</view>
|
<view class="card-actions">
|
<view class="btn-link btn-link-primary" v-if="item.inspectState == 0" @click.stop="openDealDialog(item)">处理</view>
|
<view class="btn-link btn-link-plain" v-if="item.inspectState == 0" @click.stop="openForm('edit', item)">编辑</view>
|
<view class="btn-link btn-link-warn" @click.stop="handleDelete(item)">删除</view>
|
</view>
|
</view>
|
<view class="load-more-wrap">
|
<u-loadmore :status="loadStatus" @loadmore="loadMore" />
|
</view>
|
</view>
|
<view v-else class="no-data">暂无数据</view>
|
</view>
|
|
<!-- 类型选择器 -->
|
<up-action-sheet
|
:actions="typeActions"
|
:show="showTypeSelect"
|
@close="showTypeSelect = false"
|
@select="selectType"
|
title="请选择类别"
|
></up-action-sheet>
|
|
<!-- 处理弹窗 -->
|
<up-popup v-model:show="dealDialogVisible" mode="center" round closeable @close="dealDialogVisible = false">
|
<view class="dialog-content">
|
<view class="dialog-header">
|
<text class="dialog-title">不合格品处理</text>
|
</view>
|
<up-form :model="dealForm" ref="dealFormRef" label-width="100" label-position="top">
|
<view class="info-summary">
|
<text class="summary-text">产品:{{ currentItem?.productName }}</text>
|
<text class="summary-text">检测日期:{{ currentItem?.checkTime || '-' }}</text>
|
</view>
|
<up-form-item label="不合格现象" prop="defectivePhenomena" required borderBottom>
|
<up-textarea v-model="dealForm.defectivePhenomena" placeholder="请输入不合格现象" count border="surround" />
|
</up-form-item>
|
<up-form-item label="处理结果" prop="dealResult" required borderBottom>
|
<view class="selector-trigger" @click="showDealResultSelect = true">
|
<text class="selector-text" :class="{ placeholder: !dealResultLabel }">{{ dealResultLabel || '请选择处理结果' }}</text>
|
<up-icon name="arrow-down" size="14" color="#999"></up-icon>
|
</view>
|
</up-form-item>
|
<up-form-item label="处理人" prop="dealName" required borderBottom>
|
<up-input v-model="dealForm.dealName" placeholder="请输入处理人" border="surround" />
|
</up-form-item>
|
<up-form-item label="处理日期" prop="dealTime" required borderBottom>
|
<up-input
|
v-model="dealForm.dealTime"
|
placeholder="请选择处理日期"
|
border="surround"
|
readonly
|
@click="showDatePicker = true"
|
/>
|
</up-form-item>
|
</up-form>
|
<view class="dialog-footer">
|
<up-button type="primary" text="提交处理" @click="submitDeal" :loading="submitLoading"></up-button>
|
<up-button text="取消" @click="dealDialogVisible = false" customStyle="margin-top: 20rpx"></up-button>
|
</view>
|
</view>
|
</up-popup>
|
|
<!-- 处理结果选择器 -->
|
<up-action-sheet
|
:actions="dealResultActions"
|
:show="showDealResultSelect"
|
@close="showDealResultSelect = false"
|
@select="selectDealResult"
|
title="请选择处理结果"
|
/>
|
|
<!-- 日期选择器 -->
|
<up-datetime-picker
|
:show="showDatePicker"
|
v-model="dateValue"
|
mode="date"
|
@confirm="confirmDate"
|
@cancel="showDatePicker = false"
|
></up-datetime-picker>
|
|
<!-- 录入日期范围选择:开始 -->
|
<up-datetime-picker
|
:show="showEntryStartPicker"
|
v-model="entryStartValue"
|
mode="date"
|
@confirm="confirmEntryStart"
|
@cancel="showEntryStartPicker = false"
|
/>
|
<!-- 录入日期范围选择:结束 -->
|
<up-datetime-picker
|
:show="showEntryEndPicker"
|
v-model="entryEndValue"
|
mode="date"
|
@confirm="confirmEntryEnd"
|
@cancel="showEntryEndPicker = false"
|
/>
|
|
<!-- 右下角新增按钮 -->
|
<view class="fab-button" @click="openForm('add')">
|
<up-icon name="plus" size="24" color="#ffffff"></up-icon>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, reactive, computed } from 'vue';
|
import {
|
qualityUnqualifiedListPage,
|
qualityUnqualifiedDeal,
|
qualityUnqualifiedDel
|
} from '@/api/qualityManagement/nonconformingManagement.js';
|
import { toast, showConfirm } from '@/utils/common';
|
import { useDict } from '@/utils/dict'
|
import dayjs from 'dayjs';
|
import PageHeader from '@/components/PageHeader.vue'
|
import { onReachBottom, onShow } from '@dcloudio/uni-app'
|
|
const searchForm = reactive({
|
productName: '',
|
checkType: '',
|
entryDateStart: undefined,
|
entryDateEnd: undefined
|
});
|
|
const tableData = ref([]);
|
const page = reactive({
|
current: 1,
|
size: 20,
|
total: 0
|
});
|
const loadStatus = ref('loadmore');
|
|
const showTypeSelect = ref(false);
|
const typeActions = [
|
{ name: '全部', value: '' },
|
{ name: '入厂检', value: '0' },
|
{ name: '车间检', value: '1' },
|
{ name: '出厂检', value: '2' }
|
];
|
const typeLabel = computed(() => {
|
const action = typeActions.find(a => a.value === String(searchForm.checkType ?? ''));
|
return action ? action.name : '全部类别';
|
});
|
|
const dateRangeLabel = computed(() => {
|
if (searchForm.entryDateStart && searchForm.entryDateEnd) return `${searchForm.entryDateStart}~${searchForm.entryDateEnd}`
|
if (searchForm.entryDateStart) return `${searchForm.entryDateStart}~`
|
if (searchForm.entryDateEnd) return `~${searchForm.entryDateEnd}`
|
return '检测日期'
|
})
|
|
const dealDialogVisible = ref(false);
|
const submitLoading = ref(false);
|
const currentItem = ref(null);
|
const dealForm = reactive({
|
id: null,
|
defectivePhenomena: '',
|
dealResult: '',
|
dealName: '',
|
dealTime: dayjs().format('YYYY-MM-DD')
|
});
|
|
const { rejection_handling } = useDict('rejection_handling')
|
const showDealResultSelect = ref(false)
|
const dealResultActions = computed(() => {
|
const list = rejection_handling?.value || []
|
return (list || []).map(it => ({ name: it.label, value: it.value }))
|
})
|
const dealResultLabel = computed(() => {
|
const list = rejection_handling?.value || []
|
const v = dealForm.dealResult
|
return (list || []).find(it => String(it.value) === String(v))?.label || ''
|
})
|
function getDealResultLabel(value) {
|
const list = rejection_handling?.value || []
|
return (list || []).find(it => String(it.value) === String(value))?.label || ''
|
}
|
|
const showDatePicker = ref(false);
|
const dateValue = ref(Number(new Date()));
|
|
const showEntryStartPicker = ref(false)
|
const showEntryEndPicker = ref(false)
|
const entryStartValue = ref(Date.now())
|
const entryEndValue = ref(Date.now())
|
|
const getInspectTypeText = (type) => {
|
const types = { '0': '入厂检', '1': '车间检', '2': '出厂检' };
|
return types[String(type ?? '')] || '-';
|
};
|
|
const getList = () => {
|
const isFirstPage = page.current === 1
|
if (loadStatus.value === 'loading' || (!isFirstPage && page.total > 0 && tableData.value.length >= page.total)) return
|
|
loadStatus.value = 'loading'
|
const params = {
|
productName: searchForm.productName || null,
|
checkType: searchForm.checkType === '' ? null : searchForm.checkType,
|
entryDateStart: searchForm.entryDateStart,
|
entryDateEnd: searchForm.entryDateEnd,
|
current: page.current,
|
size: page.size
|
};
|
|
qualityUnqualifiedListPage(params).then(res => {
|
const records = res?.data?.records || [];
|
if (page.current === 1) {
|
tableData.value = records;
|
} else {
|
tableData.value = [...tableData.value, ...records];
|
}
|
page.total = res?.data?.total || 0;
|
|
if (tableData.value.length >= page.total) {
|
loadStatus.value = 'nomore';
|
} else {
|
loadStatus.value = 'loadmore';
|
}
|
}).catch(() => {
|
loadStatus.value = 'error';
|
});
|
};
|
|
const loadMore = () => {
|
if (loadStatus.value === 'nomore' || loadStatus.value === 'loading') return
|
loadStatus.value = 'loading'
|
page.current++
|
getList()
|
}
|
|
const handleQuery = () => {
|
page.current = 1;
|
page.total = 0;
|
tableData.value = [];
|
loadStatus.value = 'loadmore';
|
getList();
|
};
|
|
const selectType = (e) => {
|
searchForm.checkType = e.value;
|
handleQuery();
|
};
|
|
const openDateRange = () => {
|
entryStartValue.value = searchForm.entryDateStart ? dayjs(searchForm.entryDateStart, 'YYYY-MM-DD').valueOf() : Date.now()
|
showEntryStartPicker.value = true
|
}
|
const confirmEntryStart = (e) => {
|
const ts = e?.value ?? entryStartValue.value
|
searchForm.entryDateStart = dayjs(ts).format('YYYY-MM-DD')
|
showEntryStartPicker.value = false
|
entryEndValue.value = searchForm.entryDateEnd ? dayjs(searchForm.entryDateEnd, 'YYYY-MM-DD').valueOf() : Date.now()
|
showEntryEndPicker.value = true
|
}
|
const confirmEntryEnd = (e) => {
|
const ts = e?.value ?? entryEndValue.value
|
searchForm.entryDateEnd = dayjs(ts).format('YYYY-MM-DD')
|
showEntryEndPicker.value = false
|
handleQuery()
|
}
|
|
const openDealDialog = (item) => {
|
currentItem.value = item;
|
dealForm.id = item.id;
|
dealForm.defectivePhenomena = item.defectivePhenomena || ''
|
dealForm.dealResult = item.dealResult || '';
|
dealForm.dealName = item.dealName || ''
|
dealForm.dealTime = dayjs().format('YYYY-MM-DD');
|
dealDialogVisible.value = true;
|
};
|
|
const selectDealResult = (e) => {
|
dealForm.dealResult = e.value
|
showDealResultSelect.value = false
|
}
|
|
const submitDeal = () => {
|
if (!dealForm.defectivePhenomena) {
|
toast('请输入不合格现象')
|
return;
|
}
|
if (!dealForm.dealResult) {
|
toast('请选择处理结果')
|
return
|
}
|
if (!dealForm.dealName) {
|
toast('请输入处理人')
|
return
|
}
|
submitLoading.value = true;
|
qualityUnqualifiedDeal(dealForm).then(() => {
|
toast('处理成功');
|
dealDialogVisible.value = false;
|
handleQuery();
|
}).finally(() => {
|
submitLoading.value = false;
|
});
|
};
|
|
const handleDelete = (row) => {
|
showConfirm('确认删除该不合格记录吗?').then(res => {
|
if (res.confirm) {
|
qualityUnqualifiedDel([row.id]).then(() => {
|
toast('删除成功');
|
handleQuery();
|
});
|
}
|
});
|
};
|
|
const confirmDate = (e) => {
|
dealForm.dealTime = dayjs(e.value).format('YYYY-MM-DD');
|
showDatePicker.value = false;
|
};
|
|
const openForm = (type, row) => {
|
if (type !== 'add' && row?.inspectState == 1) {
|
toast('已处理的数据不能再编辑')
|
return
|
}
|
const id = row?.id
|
uni.navigateTo({
|
url: `/pages/qualityManagement/nonconformingManagement/form?type=${type}${id ? `&id=${id}` : ''}`
|
})
|
}
|
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
|
onShow(() => {
|
handleQuery()
|
})
|
|
onReachBottom(() => {
|
loadMore()
|
})
|
</script>
|
|
<style lang="scss" scoped>
|
.nonconforming-management-page {
|
min-height: 100vh;
|
background: #f5f5f5;
|
padding-bottom: 120rpx;
|
}
|
|
.search-section {
|
background: #fff;
|
margin: 24rpx;
|
padding: 24rpx;
|
border-radius: 16rpx;
|
}
|
|
.search-row { display: flex; align-items: center; margin-bottom: 20rpx; }
|
.search-input-wrap { flex: 1; margin-right: 20rpx; min-width: 0; }
|
.btn-search {
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
width: 180rpx;
|
min-height: 72rpx;
|
flex-shrink: 0;
|
padding: 20rpx 24rpx;
|
background: #2979ff;
|
color: #fff;
|
border-radius: 12rpx;
|
font-size: 28rpx;
|
box-sizing: border-box;
|
text-align: center;
|
}
|
.btn-search-inner { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8rpx; }
|
|
.filter-row {
|
display: flex;
|
gap: 20rpx;
|
}
|
|
.filter-item {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
padding: 18rpx 20rpx;
|
background: #f5f5f5;
|
border-radius: 12rpx;
|
font-size: 26rpx;
|
color: #666;
|
}
|
|
.list-section { padding: 0 24rpx; }
|
.card-item {
|
background: #fff;
|
border-radius: 16rpx;
|
padding: 16rpx 20rpx;
|
margin-bottom: 20rpx;
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
|
}
|
.card-header { padding: 2rpx 0 6rpx; }
|
.header-main { display: flex; justify-content: space-between; align-items: center; gap: 16rpx; }
|
.product-name { font-size: 30rpx; font-weight: 500; color: #333; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.header-sub { display: flex; justify-content: space-between; gap: 16rpx; margin-top: 6rpx; }
|
.sub-title { font-size: 24rpx; color: #999; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.sub-right { font-size: 24rpx; color: #999; flex-shrink: 0; }
|
.card-body .row { display: flex; justify-content: space-between; padding: 6rpx 0; font-size: 26rpx; }
|
.card-body .l { color: #666; width: 180rpx; flex-shrink: 0; }
|
.card-body .r { color: #333; flex: 1; text-align: right; word-break: break-all; }
|
.card-actions {
|
display: flex;
|
gap: 16rpx;
|
justify-content: flex-end;
|
align-items: center;
|
margin-top: 12rpx;
|
padding-top: 14rpx;
|
border-top: 1rpx solid #eee;
|
}
|
.btn-link {
|
font-size: 28rpx;
|
padding: 10rpx 22rpx;
|
border-radius: 999rpx;
|
border: 1rpx solid transparent;
|
}
|
.btn-link-primary { color: #2979ff; border-color: rgba(41, 121, 255, 0.4); background: rgba(41, 121, 255, 0.08); }
|
.btn-link-plain { color: #606266; border-color: rgba(96, 98, 102, 0.35); background: rgba(96, 98, 102, 0.06); }
|
.btn-link-warn { color: #f56c6c; border-color: rgba(245, 108, 108, 0.55); background: rgba(245, 108, 108, 0.08); }
|
|
.text-error {
|
color: #f56c6c;
|
}
|
|
.text-success {
|
color: #67c23a;
|
}
|
|
.no-data { text-align: center; padding: 60rpx 0; color: #999; font-size: 28rpx; }
|
.load-more-wrap { padding: 24rpx 24rpx 8rpx; }
|
|
.dialog-content {
|
width: 650rpx;
|
padding: 40rpx;
|
background-color: #ffffff;
|
border-radius: 24rpx;
|
overflow: hidden;
|
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
|
}
|
|
.dialog-header {
|
margin-bottom: 30rpx;
|
text-align: center;
|
}
|
|
.dialog-title {
|
font-size: 32rpx;
|
font-weight: bold;
|
}
|
|
.info-summary {
|
background-color: #f5f7fa;
|
padding: 20rpx;
|
border-radius: 8rpx;
|
margin-bottom: 30rpx;
|
}
|
|
.summary-text {
|
display: block;
|
font-size: 26rpx;
|
color: #606266;
|
margin-bottom: 10rpx;
|
}
|
|
.dialog-footer {
|
margin-top: 40rpx;
|
}
|
|
.selector-trigger { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #f5f5f5; border-radius: 12rpx; }
|
.selector-text { font-size: 28rpx; color: #333; }
|
.selector-text.placeholder { color: #999; }
|
|
.fab-button {
|
position: fixed;
|
right: 36rpx;
|
bottom: 72rpx;
|
width: 104rpx;
|
height: 104rpx;
|
border-radius: 52rpx;
|
background: #2979ff;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
box-shadow: 0 10rpx 26rpx rgba(41, 121, 255, 0.35);
|
z-index: 20;
|
}
|
</style>
|