13404089107
昨天 bfc611fedef3df0e21d0034614fac90896dcdc44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<template>
  <Card>
    <div class="header-title-left">
      <img src="@/assets/public/headercard.png" />
      <div>所属实验调度</div>
    </div>
    <Table :data="schedulingData" :total="0" :height="null" >
      <template>
        <el-table-column prop="projectName" label="所属项目课题方案" width="200"></el-table-column>
        <el-table-column prop="experimentCode" label="实验编号" width="200"></el-table-column>
        <el-table-column prop="experimentName" label="实验名称" width="200"></el-table-column>
        <el-table-column prop="experimentDate" label="通知时间" width="200"></el-table-column>
        <el-table-column prop="experimentStartTime" label="实验开始时间" width="200"></el-table-column>
        <el-table-column prop="experimentEndTime" label="实验结束时间" width="200"></el-table-column>
        <el-table-column prop="participantsName" label="参加人员" width="200"></el-table-column>
        <el-table-column prop="status" label="状态" width="150">
          <template slot-scope="scope">
            <el-tag :type="getStatusType(scope.row.status)">
              {{ getStatusText(scope.row.status) }}
            </el-tag>
          </template>
        </el-table-column>
      </template>
    </Table>
 
    <!-- 送样-收样记录部分 -->
    <div class="sample-record-section">
      <div class="header-title-left" style="margin-top: 38px">
        <img src="@/assets/public/headercard.png" />
        <span>送样-收样记录</span>
        <el-button
          type="primary"
          class="el-icon-plus"
          @click="showAdditives = !showAdditives"
        >
          {{ showAdditives ? "收起辅料详情" : "展开辅料详情" }}
        </el-button>
      </div>
      <div class="sample-code">取样单编号:{{ form.sampleCode || 'DD-25010BS01' }}</div>
      
      <div class="sample-table">
        <div class="table-header">
          <el-button type="primary" class="batch-send" @click="handleBatchSend">批量发送</el-button>
        </div>
        <Table :data="sampleList" :total="sampleTotal" :height="null"
         @selection-change="handleSelectionChange">
          <template>
            <el-table-column type="selection" width="55" :selectable="isSelectable"></el-table-column>
            <el-table-column type="index"  label="序号" width="80"></el-table-column>
            <el-table-column prop="processTime" label="工艺时间" width="120"></el-table-column>
            <el-table-column prop="samplingName" label="取样名称" width="150"></el-table-column>
            <el-table-column prop="sampleCode" label="取样样品编号" width="150"></el-table-column>
            <el-table-column prop="temperature" label="温度" width="100"></el-table-column>
            <el-table-column prop="samplePh" label="PH" width="100"></el-table-column>
            <el-table-column prop="waterAddition" label="加水量" width="100"></el-table-column>
            <template v-if="showAdditives">
              <el-table-column prop="addAuxiliaryOne" label="加辅1" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryTwo" label="加辅2" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryThree" label="加辅3" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryFour" label="加辅4" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryFive" label="加辅5" width="150"></el-table-column>
              <el-table-column prop="addAuxiliarySix" label="加辅6" width="150"></el-table-column>
              <el-table-column prop="addAuxiliarySeven" label="加辅7" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryEight" label="加辅8" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryNine" label="加辅9" width="150"></el-table-column>
              <el-table-column prop="addAuxiliaryTen" label="加辅10" width="150"></el-table-column>
            </template>
            <el-table-column prop="sampleAmount" label="取样量" width="100"></el-table-column>
            <el-table-column prop="pictures" label="拍照" width="100">
              <template slot-scope="scope">
                <el-image
                  v-for="(url, index) in scope.row.pictures.split(',')" 
                  :key="index"
                  :src="url"
                  :preview-src-list="[url]"
                  style="width: 50px; height: 50px;"
                />
              </template>
            </el-table-column>
            <el-table-column prop="handlePersonName" label="操作人员" width="100"></el-table-column>
            <el-table-column prop="status" label="状态" width="100" fixed="right">
              <template slot-scope="scope">
                <el-tag :type="getSampleStatusType(scope.row.status)">
                  {{ getSampleStatusText(scope.row.status) }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column label="操作" width="100" fixed="right">
              <template slot-scope="scope">
                <el-button type="text" @click="handleSend(scope.row)" v-if="scope.row.status == '1'">发送</el-button>
              </template>
            </el-table-column>
          </template>
        </Table>
      </div>
    </div>
 
    <receive-confirm-dialog
      :visible.sync="showReceiveConfirm"
      :sample-count="selectedSamples.length"
      @confirm="confirmSend"
    />
  </Card>
</template>
 
<script>
import ReceiveConfirmDialog from './components/receiveConfirmDialog.vue'
import { getDetail, commitRecord, batchSendSamples, sendSample } from './service'
 
export default {
  name: "SampleSubmission",
  components: {
    ReceiveConfirmDialog
  },
  data() {
    return {
      id: null,
      showReceiveConfirm: false,
      showAdditives: true,
      schedulingData: [],
      schedulingTotal: 0,
      form: {
        sampleCode: "",
      },
      sampleList: [],
      sampleTotal: 0,
      selectedSamples: [],
      statusTypeMap: {
        '-1': 'info',
        '1': 'warning',
        '2': 'success',
        '3': 'info'
      },
      statusTextMap: {
        '-1': '草稿箱',
        '1': '待提交',
        '2': '已提交',
        '3': '已封存'
      },
      sampleStatusTypeMap: {
        '1': 'warning',
        '2': 'info',
        '3': 'success'
      },
      sampleStatusTextMap: {
        '1': '待发送',
        '2': '待接收',
        '3': '已接收'
      }
    };
  },
  created() {
    this.id = this.$route.query.id;
    if (this.id) {
      this.getDetailData();
    }
  },
  methods: {
    async getDetailData() {
      try {
        const res = await getDetail({ id: this.id });
        if (res) {
          this.schedulingData = [res.experimentDispatch] || [];
          this.schedulingTotal = this.schedulingData.length;
          this.form.sampleCode = res.samplingCode || '';
          this.sampleList = res.samplingRecordOperations || [];
          this.sampleTotal = this.sampleList.length;
        }
      } catch (error) {
        console.error('获取详情失败:', error);
        this.$message.error('获取详情失败');
      }
    },
    handleSelectionChange(selection) {
      this.selectedSamples = selection;
    },
    async handleSend(row) {
      this.selectedSamples = [row];
      this.showReceiveConfirm = true;
    },
    async handleBatchSend() {
      if (this.selectedSamples.length == 0) {
        this.$message.warning('请先选择要发送的样品');
        return;
      }
      this.showReceiveConfirm = true;
    },
    async confirmSend(signature) {
      try {
        const recordOperationIds = this.selectedSamples.map(item => item.id).join(',');
        const res = await batchSendSamples({ 
          recordOperationId: recordOperationIds,
          sendSign: signature
        });
 
        if (res.code == 200) {
          this.$message.success(`成功发送 ${this.selectedSamples.length} 个样品`);
          this.selectedSamples = [];
          this.showReceiveConfirm = false;
          // 刷新数据
          this.getDetailData();
        } else {
          this.$message.error(res.msg || '发送失败');
        }
      } catch (error) {
        console.error('发送失败:', error);
        this.$message.error('发送失败');
      }
    },
    getStatusType(status) {
      return this.statusTypeMap[status] || 'info';
    },
    getStatusText(status) {
      return this.statusTextMap[status] || '未知状态';
    },
    isSelectable(row) {
      return row.status == '1';
    },
    getSampleStatusType(status) {
      return this.sampleStatusTypeMap[status] || 'info';
    },
    getSampleStatusText(status) {
      return this.sampleStatusTextMap[status] || '未知状态';
    },
  }
};
</script>
 
<style lang="less" scoped>
.header-title-left {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 20px;
 
  img {
    width: 12px;
    height: 19px;
  }
 
  div, span {
    flex-shrink: 0;
    font-weight: bold;
    font-size: 18px;
    color: #222222;
    line-height: 27px;
    font-family: "Source Han Sans CN Bold Bold";
  }
 
  div:before {
    content: "*";
    color: #f56c6c;
    margin-right: 4px;
  }
 
  .el-button {
    margin-left: 16px;
  }
}
 
.sample-record-section {
  .sample-code {
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 14px;
    color: rgba(0,0,0,0.88);
    margin: 20px 0;
  }
 
  .table-header {
    margin-bottom: 16px;
    text-align: left;
  }
 
  .sample-photo {
    width: 60px;
    height: 60px;
    object-fit: cover;
  }
}
</style>