spring
2026-03-30 f6427b5dea54bbb8761fade351e9f86404b2fb61
src/pages/qualityManagement/rawMaterial/index.vue
@@ -1,6 +1,6 @@
<template>
  <view class="raw-material-page">
    <PageHeader title="原材料" @back="goBack" />
    <PageHeader title="检测化验" @back="goBack" />
    
    <!-- 搜索与筛选 -->
    <view class="search-section">
@@ -31,7 +31,17 @@
      <view v-for="(item, index) in tableData" :key="index" class="list-item">
        <view class="item-header">
          <text class="product-name">{{ item.productName }}</text>
          <up-tag :text="item.inspectState ? '已提交' : '未提交'" :type="item.inspectState ? 'success' : 'warning'" size="mini"></up-tag>
          <view class="item-header-right">
            <up-tag
              :text="item.inspectState == 1 ? '已提交' : '未提交'"
              :type="item.inspectState == 1 ? 'success' : 'warning'"
              size="mini"
            ></up-tag>
            <view class="file-entry" @click.stop="openFiles(item)">
              <up-icon name="file-text" size="16" color="#606266"></up-icon>
              <text class="file-entry-text">附件</text>
            </view>
          </view>
        </view>
        <view class="item-content">
          <view class="item-row">
@@ -56,9 +66,10 @@
          </view>
        </view>
        <view class="item-actions">
          <up-button v-if="!item.inspectState" type="primary" size="mini" @click.stop="openForm('edit', item)">编辑</up-button>
          <up-button v-if="!item.inspectState" type="success" size="mini" @click.stop="handleConfirmSubmit(item)">提交</up-button>
          <up-button type="error" size="mini" @click.stop="handleDelete(item)">删除</up-button>
          <up-button v-if="item.inspectState != 1||hasRawCancel" type="primary" size="mini" @click.stop="openForm('edit', item)">编辑</up-button>
          <up-button type="warning" size="mini" @click.stop="openDetail(item)">详情</up-button>
          <up-button v-if="item.inspectState != 1" type="success" size="mini" @click.stop="handleConfirmSubmit(item)">提交</up-button>
          <up-button v-if="hasRawCancel" type="error" size="mini" @click.stop="handleDelete(item)">删除</up-button>
        </view>
      </view>
      <view class="pagination-container">
@@ -96,7 +107,8 @@
</template>
<script setup>
import { ref, reactive, onMounted, computed } from 'vue';
import { ref, reactive, computed } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import {
  findRawMaterialListPage,
  submitRawMaterial,
@@ -104,8 +116,10 @@
} from '@/api/qualityManagement/rawMaterial.js';
import { toast, showConfirm } from '@/utils/common';
import useUserStore from '@/store/modules/user';
import { checkPermi } from '@/utils/permission';
const userStore = useUserStore();
const hasRawCancel = computed(() => checkPermi(['raw_cancel']));
const searchForm = reactive({
  batchNo: '',
@@ -195,10 +209,20 @@
};
const openForm = (type, item) => {
  // Mobile usually navigates to a new page for add/edit if complex
  // Here we'll just show a toast for now as the actual form components are many
  toast('功能开发中,请在PC端操作');
  // if (type === 'edit' && !hasRawEdit.value) return
  const id = item?.id
  uni.navigateTo({
    url: `/pages/qualityManagement/rawMaterial/form?type=${type}${id ? `&id=${id}` : ''}`
  })
};
const openDetail = (item) => {
  const id = item?.id
  if (!id) return
  uni.navigateTo({
    url: `/pages/qualityManagement/rawMaterial/form?type=detail&id=${id}`
  })
}
const handleConfirmSubmit = (row) => {
  showConfirm('确认提交该检验记录吗?').then(res => {
@@ -212,9 +236,11 @@
};
const handleDelete = (row) => {
  if (!hasRawCancel.value) return
  showConfirm('确认删除该记录吗?').then(res => {
    if (res.confirm) {
      deleteRawMaterial({ id: row.id }).then(() => {
      // 对齐 PC 端:删除接口接收 id 数组
      deleteRawMaterial([row.id]).then(() => {
        toast('删除成功');
        handleQuery();
      });
@@ -222,11 +248,24 @@
  });
};
const openFiles = (row) => {
  if (!row?.id) {
    toast('请先保存后再上传附件')
    return
  }
  try {
    uni.setStorageSync('rawMaterialFilesCtx', JSON.stringify({ id: row.id }))
  } catch (e) {}
  uni.navigateTo({
    url: `/pages/qualityManagement/rawMaterial/files?id=${row.id}`
  })
}
const goBack = () => {
  uni.navigateBack();
};
onMounted(() => {
onShow(() => {
  handleQuery();
});
</script>
@@ -279,6 +318,28 @@
  margin-bottom: 20rpx;
}
.item-header-right {
  display: flex;
  align-items: center;
  gap: 16rpx;
}
.file-entry {
  display: inline-flex;
  align-items: center;
  gap: 8rpx;
  padding: 8rpx 16rpx;
  border-radius: 999rpx;
  background: #f2f6fc;
  border: 1rpx solid #ebeef5;
}
.file-entry-text {
  font-size: 24rpx;
  color: #606266;
  line-height: 1;
}
.product-name {
  font-size: 30rpx;
  font-weight: bold;
@@ -309,10 +370,19 @@
.item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 20rpx;
  gap: 16rpx;
  border-top: 1rpx solid #ebeef5;
  padding-top: 20rpx;
}
.item-actions :deep(.u-button),
.item-actions :deep(.up-button) {
  min-width: 140rpx;
  height: 64rpx;
  line-height: 64rpx;
  font-size: 26rpx;
  border-radius: 999rpx;
  padding: 0 24rpx;
}
.no-data {
  padding-top: 200rpx;