董国庆
9 天以前 527efb36f35b471710e445972673abff45bacdac
laboratory/src/views/dataManagement/sampleManage/addSample.vue
@@ -174,7 +174,7 @@
          <el-input v-model="form.sampleCode" :disabled="true" placeholder="自动生成" />
        </el-form-item>
      </el-form>
      <div>取样单编号:{{ form.sampleCode }}</div>
      <div v-if=" pageType == 'detail'">取样单编号:{{ form.sampleCode }}</div>
      <div class="header-title-left" style="margin-top: 38px">
        <img src="@/assets/public/headercard.png" />
        <span>取样操作记录</span>
@@ -213,8 +213,8 @@
                <el-image
                  v-for="(url, index) in scope.row.pictures.split(',')" 
                  :key="index"
                  :src="url"
                  :preview-src-list="[url]"
                  :src="getFullUrl(url)"
                  :preview-src-list="[getFullUrl(url)]"
                  style="width: 50px; height: 50px;"
                />
              </template>
@@ -254,6 +254,7 @@
import ReceiveConfirmDialog from "./components/receiveConfirmDialog.vue";
import { add, getDetail, update, batchCollectSamples } from "./service";
import {getFullUrl} from '@/utils/utils.js'
import { mapState } from "vuex";
export default {
  name: "AddSample",
@@ -320,8 +321,9 @@
    }
  },
  computed: {
    ...mapState(["tagList", "isFold"]),
    isEngineer() {
      return this.userRole == '3'; // 工艺工程师
      return this.userRole != '4'  ; // 工艺工程师
    },
    isAssayer() {
      return this.userRole == '4'; // 化验师
@@ -350,24 +352,18 @@
          // 设置取样操作记录
          if (detail.samplingRecordOperations && detail.samplingRecordOperations.length > 0) {
            console.log('原始取样操作记录:', detail.samplingRecordOperations);
            // 如果是化验师角色,需要将数据分为待接收和已接收
            if (this.isAssayer) {
              // 确保status是字符串类型
              this.pendingSamples = detail.samplingRecordOperations
                .filter(item => {
                  const status = String(item.status);
                  console.log('过滤待接收样品:', item.id, status);
                  return status == '2';
                })
                .map(item => ({
                  ...item,
                  status: String(item.status)
                }));
              console.log('处理后的待接收样品:', this.pendingSamples);
              this.pendingSamplesTotal = this.pendingSamples.length;
              this.receivedSamples = detail.samplingRecordOperations
                .filter(item => String(item.status) == '3')
                .map(item => ({
@@ -384,20 +380,10 @@
              }));
            }
          }
          // 如果是详情模式,禁用所有输入
          // if (this.pageType == 'detail') {
          //   this.$nextTick(() => {
          //     const inputs = document.querySelectorAll('input, textarea, select');
          //     inputs.forEach(input => {
          //       input.disabled = true;
          //     });
          //   });
          // }
        }
      } catch (error) {
        console.error('获取详情失败:', error);
        this.$message.error('获取详情失败,请重试');
        // console.error('获取详情失败:', error);
        // this.$message.error('获取详情失败,请重试');
      }
    },
    handleAddTime(processTime) {
@@ -460,10 +446,6 @@
          samplingCode: this.form.sampleCode,
          id: this.form.id,
            };
            // 打印提交数据
            console.log('保存提交数据:',submitData);
            let res;
            if (this.pageType == 'edit') {
              // 编辑模式调用update接口
@@ -475,7 +457,7 @@
            if (res.code == 200) {
              this.$message.success(this.pageType == 'edit' ? '编辑成功' : '保存成功');
              this.$router.go(-1);
              this.back();
            } else {
              this.$message.error(res.msg || (this.pageType == 'edit' ? '编辑失败' : '保存失败'));
            }
@@ -485,6 +467,13 @@
          }
        }
      });
    },
    back() {
      this.$router.back();
      this.$store.commit(
        "SET_TAGLIST",
        this.tagList.filter((item) => item.path !== this.$route.path)
      );
    },
    // 添加存草稿方法
    async handleSaveDraft() {
@@ -518,7 +507,7 @@
        if (res.code == 200) {
          this.$message.success(this.pageType == 'edit' ? '草稿保存成功' : '存草稿成功');
          this.$router.go(-1);
          this.back()
        } else {
          this.$message.error(res.msg || (this.pageType == 'edit' ? '草稿保存失败' : '存草稿失败'));
        }
@@ -528,9 +517,7 @@
      }
    },
    handlePendingSelectionChange(selection) {
      console.log("pending samples data:", this.pendingSamples);
      this.selectedSamples = selection;
      // 强制更新视图
      this.$nextTick(() => {
        this.$forceUpdate();
      });