<template>
|
<view class="container">
|
<!-- 刷新页面后的顶部提示框 -->
|
<view class="tips" :class="{ 'tips-ani': tipShow }">
|
<view class="tips-icon">✓</view>
|
<view class="tips-text">刷新成功</view>
|
</view>
|
|
<view class="newsTab">
|
<uni-segmented-control
|
:current="current"
|
:values="items"
|
@clickItem="onClickItem"
|
style-type="button"
|
active-color="#409EFF"
|
class="segmented-control fixed-tabs"
|
></uni-segmented-control>
|
|
<view class="content">
|
<view v-show="current===0">
|
<!-- 基于 uni-list 的页面布局 -->
|
<view v-if="data.length === 0" class="empty-state">
|
<view class="empty-icon">📝</view>
|
<view class="empty-text">暂无检验记录</view>
|
</view>
|
|
<uni-list v-else>
|
<!-- 列表项 -->
|
<uni-list-item
|
style="margin-top: 15px;"
|
class="list-item enhanced-list"
|
direction="column"
|
v-for="item in data"
|
:key="item.billNo"
|
:to="'Laboratory?id=' + (item.id || '')"
|
>
|
<!-- 通过header插槽定义列表的标题 -->
|
<template v-slot:header>
|
<view class="card-header pending-header">
|
<view class="form-group">
|
<label class="form-label">工单号:</label>
|
<input class="form-input order-no" disabled="true" type="text" v-model="item.billNo"/>
|
</view>
|
</view>
|
</template>
|
|
<!-- 通过body插槽定义列表内容显示 -->
|
<template v-slot:body>
|
<view class="card-body pending-body">
|
<view class="row">
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">创建时间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.createTime"/>
|
</view>
|
</view>
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">创建人:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.createUser"/>
|
</view>
|
</view>
|
</view>
|
|
<view class="row">
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">生产线:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.lineNo"/>
|
</view>
|
</view>
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">物料编码:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemNo"/>
|
</view>
|
</view>
|
</view>
|
|
<!-- 产品名称单独一行 -->
|
<view class="form-group">
|
<label class="form-label">产品名称:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemName"/>
|
</view>
|
|
<!-- 产品规格单独一行 -->
|
<view class="form-group">
|
<label class="form-label">产品规格:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemModel"/>
|
</view>
|
|
<view class="row">
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">生产车间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.departmentCode"/>
|
</view>
|
</view>
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">销售订单:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.saleOrderNoc"/>
|
</view>
|
</view>
|
</view>
|
|
<view class="row status-row">
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">检验时间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.inspectionTime"/>
|
</view>
|
</view>
|
<view class="col-50">
|
<view class="form-group status-group">
|
<label class="form-label lab">检验结果:</label>
|
<span class="status-tag" :class="item.inspectionResult === '合格' ? 'success' : 'danger'">
|
{{ item.inspectionResult || '待检验' }}
|
</span>
|
</view>
|
</view>
|
</view>
|
|
<view class="row">
|
<view class="col-100">
|
<view class="form-group">
|
<label class="form-label lab">检验人:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.inspectionUser"/>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
</uni-list-item>
|
</uni-list>
|
</view>
|
|
<view v-show="current===1">
|
<view v-if="data.length === 0" class="empty-state">
|
<view class="empty-icon">📁</view>
|
<view class="empty-text">暂无已完成的检验记录</view>
|
</view>
|
|
<uni-list v-else>
|
<!-- 已完成列表项样式 -->
|
<uni-list-item
|
style="margin-top: 15px;"
|
class="list-item enhanced-list"
|
direction="column"
|
v-for="item in data"
|
:key="item.billNo"
|
:to="'Laboratory?id=' + (item.id || '')"
|
>
|
<!-- 通过header插槽定义列表的标题 -->
|
<template v-slot:header>
|
<view class="card-header submitted-header">
|
<view class="form-group">
|
<label class="form-label">工单号:</label>
|
<input class="form-input order-no" disabled="true" type="text" v-model="item.billNo"/>
|
</view>
|
</view>
|
</template>
|
|
<!-- 通过body插槽定义列表内容显示 -->
|
<template v-slot:body>
|
<view class="card-body submitted-body">
|
<view class="row">
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">创建时间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.createTime"/>
|
</view>
|
</view>
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">创建人:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.createUser"/>
|
</view>
|
</view>
|
</view>
|
|
<view class="row">
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">生产线:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.lineNo"/>
|
</view>
|
</view>
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">物料编码:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemNo"/>
|
</view>
|
</view>
|
</view>
|
|
<!-- 产品名称单独一行 -->
|
<view class="form-group">
|
<label class="form-label">产品名称:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemName"/>
|
</view>
|
|
<!-- 产品规格单独一行 -->
|
<view class="form-group">
|
<label class="form-label">产品规格:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemModel"/>
|
</view>
|
|
<view class="row">
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">生产车间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.departmentCode"/>
|
</view>
|
</view>
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">销售订单:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.saleOrderNoc"/>
|
</view>
|
</view>
|
</view>
|
|
<view class="row status-row">
|
<view class="col-50">
|
<view class="form-group">
|
<label class="form-label lab">检验时间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.inspectionTime"/>
|
</view>
|
</view>
|
<view class="col-50">
|
<view class="form-group status-group">
|
<label class="form-label lab">检验结果:</label>
|
<span class="status-tag submitted-tag" :class="item.inspectionResult === '合格' ? 'success' : 'danger'">
|
{{ item.inspectionResult || '待检验' }}
|
</span>
|
</view>
|
</view>
|
</view>
|
|
<view class="row">
|
<view class="col-100">
|
<view class="form-group">
|
<label class="form-label lab">检验人:</label>
|
<input class="form-input" disabled="true" type="text" v-model="item.inspectionUser"/>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
</uni-list-item>
|
</uni-list>
|
</view>
|
</view>
|
</view>
|
|
<!-- 加载更多组件 -->
|
<view v-if="isLoading || noData" class="load-more-container">
|
<uni-load-more :status="options.status" />
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
components: {},
|
data() {
|
return {
|
items: ['检验记录'],
|
current: 0,
|
data: [],
|
tipShow: false,
|
|
// 分页参数
|
pageIndex: 1,
|
limit: 20,
|
totalPage: 0,
|
totalCount: 0,
|
noData: false,
|
isLoading: false,
|
|
// 加载更多组件状态
|
options: {
|
status: 'more'
|
}
|
};
|
},
|
onLoad() {
|
this.init();
|
},
|
methods: {
|
init() {
|
this.loadData();
|
},
|
|
loadData() {
|
if (this.isLoading) return;
|
|
this.isLoading = true;
|
let userName = this.$loginInfo.account;
|
|
// 构造请求参数
|
let requestData = {
|
pageIndex: this.pageIndex,
|
limit: this.limit
|
};
|
|
// 根据当前标签页添加筛选条件
|
if (this.current === 1) {
|
// 已完成 - 有检验结果的记录
|
requestData.hasInspectionResult = true;
|
}
|
|
this.$post({
|
url: "/MesLaboratory/GetPage",
|
data: requestData
|
}).then(res => {
|
if (this.pageIndex === 1) {
|
// 如果是第一页,直接覆盖原数据
|
this.data = res.data.tbBillList || [];
|
} else {
|
if (res.data.tbBillList && res.data.tbBillList.length > 0) {
|
// 如果是下一页,追加新数据
|
this.data = [...this.data, ...res.data.tbBillList];
|
}
|
}
|
|
this.totalCount = res.data.totalCount || 0;
|
this.totalPage = Math.ceil(this.totalCount / this.limit);
|
|
this.noData = this.pageIndex >= this.totalPage;
|
this.isLoading = false;
|
|
// 更新加载更多状态
|
this.options.status = this.noData ? 'noMore' : 'more';
|
}).catch(err => {
|
console.error('获取实验室数据失败:', err);
|
this.isLoading = false;
|
this.options.status = 'fail';
|
this.$showMessage('获取数据失败,请重试');
|
});
|
},
|
|
viewDetail(item) {
|
// 跳转到Laboratory.vue页面
|
uni.navigateTo({
|
url: `Laboratory?id=${item.id || ''}`
|
});
|
},
|
|
onClickItem(index) {
|
if (this.current !== index.currentIndex) {
|
this.current = index.currentIndex;
|
this.data = [];
|
this.pageIndex = 1;
|
this.init();
|
}
|
}
|
},
|
|
/**
|
* 下拉刷新回调函数
|
*/
|
onPullDownRefresh() {
|
this.pageIndex = 1;
|
this.init();
|
this.tipShow = true;
|
|
uni.stopPullDownRefresh();
|
|
setTimeout(() => {
|
this.tipShow = false;
|
}, 1000);
|
},
|
|
/**
|
* 上拉加载回调函数
|
*/
|
onReachBottom() {
|
if (this.noData || this.isLoading) return;
|
|
this.isLoading = true;
|
this.pageIndex++;
|
this.init();
|
},
|
|
onShow() {
|
// 每次进入页面都会执行的方法
|
// this.init();
|
}
|
};
|
</script>
|
|
<style lang="scss">
|
@import '@/common/uni-ui.scss';
|
|
/* 全局样式 */
|
page {
|
display: flex;
|
flex-direction: column;
|
box-sizing: border-box;
|
background-color: #f8f9fa;
|
min-height: 100%;
|
height: auto;
|
padding-bottom: 80px;
|
}
|
|
.container {
|
padding: 0;
|
background-color: #f8f9fa;
|
}
|
|
/* 顶部提示框 */
|
.tips {
|
position: fixed;
|
top: 0;
|
left: 0;
|
right: 0;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
color: #3a86ff;
|
font-size: 14px;
|
line-height: 40px;
|
background-color: #e6f7ff;
|
height: 0;
|
opacity: 0;
|
transform: translateY(-100%);
|
transition: all 0.3s ease;
|
z-index: 1000;
|
box-shadow: 0 2px 10px rgba(64, 158, 255, 0.2);
|
}
|
|
.tips-ani {
|
transform: translateY(0);
|
height: 40px;
|
opacity: 1;
|
}
|
|
.tips-icon {
|
margin-right: 8px;
|
font-size: 18px;
|
font-weight: bold;
|
}
|
|
/* 固定标签页样式 */
|
.fixed-tabs {
|
background-color: #fff;
|
border-bottom: 2px solid #409EFF;
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
position: sticky;
|
top: 0;
|
z-index: 999;
|
}
|
|
/* 分段控件按钮样式增强 */
|
.uni-segmented-control__button {
|
font-weight: 500;
|
font-size: 16px;
|
color: #606266;
|
transition: all 0.2s;
|
}
|
|
.uni-segmented-control__button--active {
|
color: #409EFF;
|
border-bottom: 2px solid #409EFF;
|
background-color: transparent;
|
font-weight: 600;
|
}
|
|
/* 内容区域 */
|
.content {
|
width: 100%;
|
padding: 15px;
|
box-sizing: border-box;
|
margin-top: 10px;
|
}
|
|
/* 卡片样式 */
|
.card-header, .card-body {
|
border-radius: 12px;
|
padding: 18px;
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
|
transition: all 0.3s ease;
|
}
|
|
.card-header {
|
margin-bottom: 10px;
|
display: flex;
|
align-items: center;
|
}
|
|
.card-body {
|
margin-bottom: 15px;
|
}
|
|
/* 未完成状态卡片样式 */
|
.pending-header {
|
background: linear-gradient(145deg, #f0f9ff, #e0f2fe);
|
border-left: 4px solid #409EFF;
|
}
|
|
.pending-body {
|
background-color: #f0f9ff;
|
}
|
|
/* 已完成状态卡片样式 */
|
.submitted-header {
|
background: linear-gradient(145deg, #f6f6f6, #e9e9e9);
|
border-left: 4px solid #909399;
|
}
|
|
.submitted-body {
|
background-color: #f6f6f6;
|
}
|
|
/* 表单样式 */
|
.form-group {
|
display: flex;
|
align-items: flex-start;
|
margin-bottom: 18px;
|
}
|
|
.form-label {
|
margin-bottom: 0;
|
padding: 6px 10px;
|
font-size: 14px;
|
width: 100px;
|
color: #606266;
|
flex-shrink: 0;
|
font-weight: 500;
|
}
|
|
.form-label.lab {
|
color: #303133;
|
font-weight: 600;
|
}
|
|
.form-input {
|
flex: 1;
|
margin-bottom: 0;
|
padding: 10px 14px;
|
font-size: 14px;
|
background-color: rgba(255, 255, 255, 0.7);
|
border: 1px solid #dcdfe6;
|
border-radius: 8px;
|
color: #303133;
|
transition: all 0.2s;
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
}
|
|
.form-input:active {
|
transform: scale(0.99);
|
}
|
|
/* 工单号底色 */
|
.order-no {
|
background-color: #e6f7ff;
|
border-color: #bfdbfe;
|
font-weight: 500;
|
}
|
|
/* 行和列布局 */
|
.row {
|
display: flex;
|
margin-bottom: 18px;
|
}
|
|
.status-row {
|
border-top: 1px dashed #dcdfe6;
|
padding-top: 12px;
|
margin-top: 12px;
|
}
|
|
.col-50 {
|
flex: 1;
|
margin-right: 18px;
|
}
|
|
.col-50:last-child {
|
margin-right: 0;
|
}
|
|
.col-100 {
|
flex: 1;
|
}
|
|
/* 状态标签 */
|
.status-group {
|
align-items: center;
|
}
|
|
.status-tag {
|
display: inline-block;
|
padding: 6px 12px;
|
font-size: 14px;
|
border-radius: 20px;
|
margin-left: 12px;
|
font-weight: 500;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
}
|
|
.status-tag.success {
|
background-color: #e6f7ed;
|
color: #36b37e;
|
border: 1px solid #d1fae5;
|
}
|
|
.status-tag.danger {
|
background-color: #ffefef;
|
color: #ff4d4f;
|
border: 1px solid #fee2e2;
|
}
|
|
.submitted-tag {
|
background-color: rgba(144, 147, 153, 0.1);
|
color: #909399;
|
}
|
|
/* 空状态 */
|
.empty-state {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
padding: 60px 0;
|
color: #909399;
|
}
|
|
.empty-icon {
|
font-size: 64px;
|
margin-bottom: 24px;
|
color: #c0c4cc;
|
}
|
|
.empty-text {
|
font-size: 16px;
|
font-weight: 500;
|
}
|
|
/* 加载更多容器 */
|
.load-more-container {
|
padding: 30px 0;
|
text-align: center;
|
}
|
|
/* 列表项动画 */
|
.enhanced-list {
|
transition: all 0.3s ease;
|
border-radius: 12px;
|
overflow: hidden;
|
}
|
|
.enhanced-list:active {
|
transform: translateY(2px);
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
}
|
|
.enhanced-list:hover {
|
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
|
transform: translateY(-2px);
|
}
|
</style>
|