<template>
|
<view class="metric-detail-page">
|
<PageHeader :title="'标准参数: ' + standardNo" @back="goBack" />
|
|
<!-- 信息头部 -->
|
<view class="detail-info-header">
|
<view class="info-row">
|
<text class="info-label">标准编号:</text>
|
<text class="info-value">{{ standardNo }}</text>
|
</view>
|
<view class="info-row">
|
<text class="info-label">状态:</text>
|
<up-tag :text="getStatusText(state)" :type="getStatusType(state)" size="mini"></up-tag>
|
</view>
|
</view>
|
|
<!-- 参数列表 -->
|
<view class="list-container" v-if="paramList.length > 0">
|
<view v-for="(item, index) in paramList" :key="index" class="list-item">
|
<view class="item-content">
|
<view class="item-header">
|
<text class="param-name">{{ item.parameterItem }}</text>
|
<text class="param-unit">{{ item.unit || '-' }}</text>
|
</view>
|
<view class="item-row">
|
<text class="item-label">标准值:</text>
|
<text class="item-value">{{ item.standardValue || '-' }}</text>
|
</view>
|
<view class="item-row">
|
<text class="item-label">内控值:</text>
|
<text class="item-value">{{ item.controlValue || '-' }}</text>
|
</view>
|
<view class="item-row">
|
<text class="item-label">默认值:</text>
|
<text class="item-value">{{ item.defaultValue || '-' }}</text>
|
</view>
|
</view>
|
<view class="item-actions" v-if="!isReadonly">
|
<up-button type="primary" size="mini" @click.stop="openParamDialog('edit', item)">编辑</up-button>
|
<up-button type="error" size="mini" @click.stop="handleDelete(item)">删除</up-button>
|
</view>
|
</view>
|
</view>
|
|
<view v-else class="no-data">
|
<up-empty mode="data" text="暂无参数"></up-empty>
|
</view>
|
|
<!-- 浮动新增按钮 -->
|
<view class="fab-button" v-if="!isReadonly" @click="openParamDialog('add')">
|
<up-icon name="plus" size="24" color="#ffffff"></up-icon>
|
</view>
|
|
<!-- 参数编辑弹窗 -->
|
<up-popup v-model:show="paramDialogVisible" mode="center" round closeable @close="closeParamDialog">
|
<view class="dialog-content">
|
<view class="dialog-header">
|
<text class="dialog-title">{{ operationType === 'add' ? '新增参数' : '修改参数' }}</text>
|
</view>
|
<up-form :model="form" ref="formRef" label-width="80">
|
<up-form-item label="参数项" prop="parameterItem" required>
|
<up-input v-model="form.parameterItem" placeholder="请输入参数项" border="bottom" />
|
</up-form-item>
|
<up-form-item label="单位" prop="unit">
|
<up-input v-model="form.unit" placeholder="请输入单位" border="bottom" />
|
</up-form-item>
|
<up-form-item label="标准值" prop="standardValue">
|
<up-input v-model="form.standardValue" placeholder="请输入标准值" border="bottom" />
|
</up-form-item>
|
<up-form-item label="内控值" prop="controlValue">
|
<up-input v-model="form.controlValue" placeholder="请输入内控值" border="bottom" />
|
</up-form-item>
|
<up-form-item label="默认值" prop="defaultValue">
|
<up-input v-model="form.defaultValue" placeholder="请输入默认值" border="bottom" />
|
</up-form-item>
|
</up-form>
|
<view class="dialog-footer">
|
<up-button type="primary" text="确认" @click="submitForm" :loading="submitLoading"></up-button>
|
<up-button text="取消" @click="closeParamDialog" customStyle="margin-top: 20rpx"></up-button>
|
</view>
|
</view>
|
</up-popup>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, reactive, onMounted, computed } from 'vue';
|
import { onLoad } from '@dcloudio/uni-app';
|
import {
|
qualityTestStandardParamList,
|
qualityTestStandardParamAdd,
|
qualityTestStandardParamUpdate,
|
qualityTestStandardParamDel
|
} from '@/api/qualityManagement/metricMaintenance.js';
|
import { toast, showConfirm } from '@/utils/common';
|
|
const standardId = ref(null);
|
const standardNo = ref('');
|
const state = ref('0');
|
|
const paramList = ref([]);
|
const loading = ref(false);
|
|
const isReadonly = computed(() => state.value === '1' || state.value === 1);
|
|
const paramDialogVisible = ref(false);
|
const operationType = ref('add');
|
const submitLoading = ref(false);
|
const form = reactive({
|
id: null,
|
standardId: null,
|
parameterItem: '',
|
unit: '',
|
standardValue: '',
|
controlValue: '',
|
defaultValue: ''
|
});
|
|
const getStatusText = (s) => {
|
const states = { '0': '草稿', '1': '通过', '2': '撤销' };
|
return states[s] || '未知';
|
};
|
|
const getStatusType = (s) => {
|
const types = { '0': 'info', '1': 'success', '2': 'warning' };
|
return types[s] || 'info';
|
};
|
|
const getList = () => {
|
loading.value = true;
|
qualityTestStandardParamList({ standardId: standardId.value }).then(res => {
|
paramList.value = res.data || [];
|
}).finally(() => {
|
loading.value = false;
|
});
|
};
|
|
const openParamDialog = (type, row) => {
|
operationType.value = type;
|
if (type === 'edit' && row) {
|
Object.assign(form, {
|
id: row.id,
|
standardId: standardId.value,
|
parameterItem: row.parameterItem,
|
unit: row.unit,
|
standardValue: row.standardValue,
|
controlValue: row.controlValue,
|
defaultValue: row.defaultValue
|
});
|
} else {
|
Object.assign(form, {
|
id: null,
|
standardId: standardId.value,
|
parameterItem: '',
|
unit: '',
|
standardValue: '',
|
controlValue: '',
|
defaultValue: ''
|
});
|
}
|
paramDialogVisible.value = true;
|
};
|
|
const closeParamDialog = () => {
|
paramDialogVisible.value = false;
|
};
|
|
const submitForm = () => {
|
submitLoading.value = true;
|
const api = operationType.value === 'add' ? qualityTestStandardParamAdd : qualityTestStandardParamUpdate;
|
api(form).then(() => {
|
toast('保存成功');
|
paramDialogVisible.value = false;
|
getList();
|
}).finally(() => {
|
submitLoading.value = false;
|
});
|
};
|
|
const handleDelete = (row) => {
|
showConfirm('确认删除该参数项吗?').then(res => {
|
if (res.confirm) {
|
qualityTestStandardParamDel([row.id]).then(() => {
|
toast('删除成功');
|
getList();
|
});
|
}
|
});
|
};
|
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
|
onLoad((options) => {
|
standardId.value = options.id;
|
standardNo.value = options.standardNo;
|
state.value = options.state;
|
getList();
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.metric-detail-page {
|
padding-bottom: 120rpx;
|
background-color: #f5f7fa;
|
min-height: 100vh;
|
}
|
|
.detail-info-header {
|
padding: 30rpx;
|
background-color: #ffffff;
|
margin-bottom: 20rpx;
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
|
}
|
|
.info-row {
|
display: flex;
|
align-items: center;
|
margin-bottom: 10rpx;
|
}
|
|
.info-label {
|
color: #909399;
|
font-size: 28rpx;
|
width: 160rpx;
|
}
|
|
.info-value {
|
color: #303133;
|
font-size: 28rpx;
|
font-weight: bold;
|
}
|
|
.list-container {
|
padding: 20rpx;
|
}
|
|
.list-item {
|
background-color: #ffffff;
|
border-radius: 16rpx;
|
padding: 30rpx;
|
margin-bottom: 20rpx;
|
}
|
|
.item-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 20rpx;
|
}
|
|
.param-name {
|
font-size: 30rpx;
|
font-weight: bold;
|
color: #303133;
|
}
|
|
.param-unit {
|
font-size: 26rpx;
|
color: #909399;
|
background-color: #f0f2f5;
|
padding: 4rpx 12rpx;
|
border-radius: 4rpx;
|
}
|
|
.item-row {
|
display: flex;
|
margin-bottom: 10rpx;
|
}
|
|
.item-label {
|
color: #909399;
|
width: 160rpx;
|
font-size: 26rpx;
|
}
|
|
.item-value {
|
flex: 1;
|
color: #303133;
|
font-size: 26rpx;
|
}
|
|
.item-actions {
|
display: flex;
|
justify-content: flex-end;
|
gap: 20rpx;
|
border-top: 1rpx solid #ebeef5;
|
padding-top: 20rpx;
|
margin-top: 20rpx;
|
}
|
|
.no-data {
|
padding-top: 200rpx;
|
}
|
|
.fab-button {
|
position: fixed;
|
right: 40rpx;
|
bottom: 60rpx;
|
width: 100rpx;
|
height: 100rpx;
|
background-color: #3c9cff;
|
border-radius: 50%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
box-shadow: 0 4rpx 16rpx rgba(60, 156, 255, 0.4);
|
z-index: 99;
|
}
|
|
.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;
|
color: #303133;
|
}
|
|
.dialog-footer {
|
margin-top: 40rpx;
|
}
|
</style>
|