董国庆
8 天以前 527efb36f35b471710e445972673abff45bacdac
laboratory/src/views/dataManagement/sampleManage/addSample.vue
@@ -82,7 +82,7 @@
              <el-table-column prop="addAuxiliaryTen" label="加辅10" width="150"></el-table-column>
            </template>
            <el-table-column prop="sampleAmount" label="取样量" width="150"></el-table-column>
            <el-table-column prop="pictures" label="拍照" width="150">
            <!-- <el-table-column prop="pictures" label="拍照" width="150">
              <template slot-scope="scope">
                <template v-if="scope.row.pictures">
                  <el-image
@@ -95,8 +95,9 @@
                </template>
                <span v-else>-</span>
              </template>
            </el-table-column>
            <el-table-column prop="handlePersonName" label="操作人员" width="150"></el-table-column>
            </el-table-column> -->
            <el-table-column prop="sendTime" label="送样时间" width="150"></el-table-column>
            <el-table-column prop="sendPersonName" label="送样人" width="150"></el-table-column>
            <el-table-column label="状态" prop="status" width="100" fixed="right">
              <template slot-scope="scope">
                <span>{{ scope.row.status == '2' ? '待接收' : '已接收' }}</span>
@@ -140,17 +141,18 @@
                  <el-image
                    v-for="(url, index) in scope.row.pictures.split(',')" 
                    :key="index"
                    src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
                    :preview-src-list="[url]"
                    :src="getFullUrl(url)"
                    :preview-src-list="[getFullUrl(url)]"
                    style="width: 50px; height: 50px;"
                  />
                </template>
                <span v-else>-</span>
              </template>
            </el-table-column>
            <el-table-column prop="handlePersonName" label="操作人员" width="150"></el-table-column>
            <el-table-column prop="receiveTime" label="收样时间" width="150"></el-table-column>
            <el-table-column prop="receiver" label="收样人" width="150"></el-table-column>
            <el-table-column prop="sendTime" label="送样时间" width="150"></el-table-column>
            <el-table-column prop="sendPersonName" label="送样人" width="150"></el-table-column>
            <el-table-column prop="receiptsTime" label="收样时间" width="150"></el-table-column>
            <el-table-column prop="receiptsPersonName" label="收样人" width="150"></el-table-column>
            <el-table-column label="状态" prop="status" width="100" fixed="right">
              <template slot-scope="scope">
                <span>{{ scope.row.status == '3' ? '已接收' : '待接收' }}</span>
@@ -172,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>
@@ -211,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>
@@ -234,7 +236,7 @@
      />
      <div class="add-project-footer" v-if="isEngineer && pageType !== 'detail'">
        <el-button type="primary" class="save-btn" @click="handleSave">保存</el-button>
        <el-button type="primary" class="save-btn" @click="handleSave">{{'发送'}}</el-button>
        <el-button @click="handleSaveDraft">存草稿</el-button>
      </div>
    </div>
@@ -251,6 +253,8 @@
import addTime from "./components/addTime.vue";
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",
@@ -317,22 +321,22 @@
    }
  },
  computed: {
    ...mapState(["tagList", "isFold"]),
    isEngineer() {
      return this.userRole == '3'; // 工艺工程师
      return this.userRole != '4'  ; // 工艺工程师
    },
    isAssayer() {
      return this.userRole == '4'; // 化验师
    },
  },
  methods: {
    getFullUrl,
    // 获取详情数据
    async getDetailData(id) {
      try {
        const res = await getDetail({ id });
        if (res) {
          const detail = res;
          console.log('获取到的详情数据:', detail);
          // 设置表单数据
          this.form = {
            ...this.form,
@@ -348,26 +352,20 @@
          // 设置取样操作记录
          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';
                  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')
                .filter(item => String(item.status) == '3')
                .map(item => ({
                  ...item,
                  status: String(item.status)
@@ -382,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) {
@@ -458,10 +446,6 @@
          samplingCode: this.form.sampleCode,
          id: this.form.id,
            };
            // 打印提交数据
            console.log('保存提交数据:',submitData);
            let res;
            if (this.pageType == 'edit') {
              // 编辑模式调用update接口
@@ -473,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' ? '编辑失败' : '保存失败'));
            }
@@ -483,6 +467,13 @@
          }
        }
      });
    },
    back() {
      this.$router.back();
      this.$store.commit(
        "SET_TAGLIST",
        this.tagList.filter((item) => item.path !== this.$route.path)
      );
    },
    // 添加存草稿方法
    async handleSaveDraft() {
@@ -505,8 +496,6 @@
        };
        // 打印提交数据
        console.log('草稿提交数据:', submitData);
        let res;
        if (this.pageType == 'edit') {
          // 编辑模式调用update接口
@@ -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,10 +517,7 @@
      }
    },
    handlePendingSelectionChange(selection) {
      console.log("pending selection change:", selection);
      console.log("pending samples data:", this.pendingSamples);
      this.selectedSamples = selection;
      // 强制更新视图
      this.$nextTick(() => {
        this.$forceUpdate();
      });
@@ -552,7 +538,7 @@
    },
    confirmReceive(signature) {
      // 获取选中样品的ID并拼接
      const recordOperationIds = this.selectedSamples.map(item => item.id).join(',');
      const recordOperationIds = this.selectedSamples.map(item => item.id);
      
      // 调用批量收样接口
      batchCollectSamples({
@@ -589,10 +575,7 @@
      
    },
    isSelectable(row) {
      console.log('isSelectable row:', row);
      console.log('row status:', row.status, typeof row.status);
      const result = String(row.status) === '2';
      console.log('isSelectable result:', result);
      const result = String(row.status) == '2';
      return result;
    },
  },