<template>
|
<view class="metric-binding-page">
|
<PageHeader title="指标绑定" @back="goBack" />
|
|
<!-- 搜索与筛选 -->
|
<view class="search-section">
|
<up-search
|
placeholder="标准编号/标准名称"
|
v-model="searchForm.keyword"
|
@search="handleQuery"
|
@custom="handleQuery"
|
@clear="handleQuery"
|
:show-action="true"
|
action-text="搜索"
|
:animation="true"
|
customStyle="margin-bottom: 20rpx"
|
></up-search>
|
<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="showStatusSelect = true">
|
<text>{{ statusLabel }}</text>
|
<up-icon name="arrow-down" size="14" color="#999"></up-icon>
|
</view>
|
</view>
|
</view>
|
|
<!-- 列表区域 -->
|
<view class="list-container" v-if="tableData.length > 0">
|
<view v-for="(item, index) in tableData" :key="index" class="list-item" @click="viewDetail(item)">
|
<view class="item-header">
|
<text class="standard-no">{{ item.standardNo }}</text>
|
<up-tag :text="getStatusText(item.state)" :type="getStatusType(item.state)" size="mini"></up-tag>
|
</view>
|
<view class="item-content">
|
<view class="item-row">
|
<text class="item-label">标准名称:</text>
|
<text class="item-value">{{ item.standardName }}</text>
|
</view>
|
<view class="item-row">
|
<text class="item-label">类别:</text>
|
<text class="item-value">{{ getInspectTypeText(item.inspectType) }}</text>
|
</view>
|
</view>
|
</view>
|
<view class="pagination-container">
|
<up-loadmore :status="loadStatus" @loadmore="getList" />
|
</view>
|
</view>
|
|
<view v-else class="no-data">
|
<up-empty mode="data" text="暂无数据"></up-empty>
|
</view>
|
|
<!-- 类别选择器 -->
|
<up-action-sheet
|
:actions="typeActions"
|
:show="showTypeSelect"
|
@close="showTypeSelect = false"
|
@select="selectType"
|
title="请选择类别"
|
></up-action-sheet>
|
|
<!-- 状态选择器 -->
|
<up-action-sheet
|
:actions="statusActions"
|
:show="showStatusSelect"
|
@close="showStatusSelect = false"
|
@select="selectStatus"
|
title="请选择状态"
|
></up-action-sheet>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, reactive, onMounted, computed } from 'vue';
|
import {
|
qualityTestStandardListPage
|
} from '@/api/qualityManagement/metricMaintenance.js';
|
|
const searchForm = reactive({
|
keyword: '',
|
inspectType: '',
|
state: ''
|
});
|
|
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 === searchForm.inspectType);
|
return action ? action.name : '全部类别';
|
});
|
|
const showStatusSelect = ref(false);
|
const statusActions = [
|
{ name: '全部', value: '' },
|
{ name: '草稿', value: '0' },
|
{ name: '通过', value: '1' },
|
{ name: '撤销', value: '2' }
|
];
|
const statusLabel = computed(() => {
|
const action = statusActions.find(a => a.value === searchForm.state);
|
return action ? action.name : '全部状态';
|
});
|
|
const getInspectTypeText = (type) => {
|
const types = { '0': '原材料检验', '1': '过程检验', '2': '出厂检验' };
|
return types[type] || '-';
|
};
|
|
const getStatusText = (state) => {
|
const states = { '0': '草稿', '1': '通过', '2': '撤销' };
|
return states[state] || '未知';
|
};
|
|
const getStatusType = (state) => {
|
const types = { '0': 'info', '1': 'success', '2': 'warning' };
|
return types[state] || 'info';
|
};
|
|
const getList = () => {
|
if (loadStatus.value === 'loading' || (page.total > 0 && tableData.value.length >= page.total)) return;
|
|
loadStatus.value = 'loading';
|
const params = {
|
standardNo: searchForm.keyword || null,
|
inspectType: searchForm.inspectType || null,
|
state: searchForm.state || null,
|
current: page.current,
|
size: page.size
|
};
|
|
qualityTestStandardListPage(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';
|
page.current++;
|
}
|
}).catch(() => {
|
loadStatus.value = 'loadmore';
|
});
|
};
|
|
const handleQuery = () => {
|
page.current = 1;
|
page.total = 0;
|
tableData.value = [];
|
loadStatus.value = 'loadmore';
|
getList();
|
};
|
|
const selectType = (e) => {
|
searchForm.inspectType = e.value;
|
handleQuery();
|
};
|
|
const selectStatus = (e) => {
|
searchForm.state = e.value;
|
handleQuery();
|
};
|
|
const viewDetail = (item) => {
|
uni.navigateTo({
|
url: `/pages/qualityManagement/metricBinding/detail?id=${item.id}&standardNo=${item.standardNo}`
|
});
|
};
|
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
|
onMounted(() => {
|
handleQuery();
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.metric-binding-page {
|
padding-bottom: 20rpx;
|
background-color: #f5f7fa;
|
min-height: 100vh;
|
}
|
|
.search-section {
|
padding: 20rpx 30rpx;
|
background-color: #ffffff;
|
position: sticky;
|
top: 0;
|
z-index: 10;
|
}
|
|
.filter-row {
|
display: flex;
|
justify-content: space-around;
|
padding: 10rpx 0;
|
}
|
|
.filter-item {
|
display: flex;
|
align-items: center;
|
gap: 10rpx;
|
font-size: 28rpx;
|
color: #606266;
|
}
|
|
.list-container {
|
padding: 20rpx;
|
}
|
|
.list-item {
|
background-color: #ffffff;
|
border-radius: 16rpx;
|
padding: 30rpx;
|
margin-bottom: 20rpx;
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
|
}
|
|
.item-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 20rpx;
|
}
|
|
.standard-no {
|
font-size: 30rpx;
|
font-weight: bold;
|
color: #303133;
|
}
|
|
.item-content {
|
margin-bottom: 10rpx;
|
}
|
|
.item-row {
|
display: flex;
|
margin-bottom: 10rpx;
|
}
|
|
.item-label {
|
color: #909399;
|
width: 160rpx;
|
font-size: 28rpx;
|
}
|
|
.item-value {
|
flex: 1;
|
color: #303133;
|
font-size: 28rpx;
|
}
|
|
.pagination-container {
|
padding: 20rpx 0;
|
}
|
|
.no-data {
|
padding-top: 200rpx;
|
}
|
</style>
|