董国庆
2025-12-09 332e2e6cd982c2d71028798f535a94d7b9c55b91
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
282
283
284
285
286
287
<template>
  <el-dialog
    title="发送签字确认"
    :visible.sync="visible"
    width="500px"
    :close-on-click-modal="false"
    @open='open'
    @close="handleClose"
  >
    <div class="receive-dialog">
      <!-- 人员选择区域 -->
      <div class="personnel-selection" v-if="personnelList.length > 0">
        <div class="personnel-table">
          <el-table
            ref="personnelTable"
            :data="personnelList"
            style="width: 100%"
            border
            size="small"
            @row-click="handlePersonnelRowClick"
            :row-class-name="getPersonnelRowClassName"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="index" width="55" align="center" label="编号"></el-table-column>
            <el-table-column prop="nickName" label="化验师姓名" min-width="120" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.nickName }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="id" label="操作" min-width="120" align="center">
              <template slot-scope="scope">
                <!-- <el-radio v-model="selectedPersonnelId" :label="scope.row.nickName"></el-radio> -->
                <el-checkbox :value="selectedPersonnelId ==scope.row.id"></el-checkbox>
              </template>
            </el-table-column>
            <!-- <el-table-column prop="id" label="人员ID" min-width="120" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.id }}</span>
              </template>
            </el-table-column> -->
          </el-table>
        </div>
      </div>
 
      <div class="receive-tip">
        您已选中 <span class="sample-count">{{ sampleCount }}</span> 条样品发送,请签字确认
      </div>
 
      <div class="approval-dialog-approve">
        <div class="add-group">
          <div>*</div>
          <span>签字确认</span>
          <el-button type="primary" class="el-icon-plus" @click="openSignature">签名</el-button>
        </div>
        <img
          v-if="imgSrc"
          style="width: 200px; height: 100px; margin-left: 25px"
          :src="getFullUrl(imgSrc)"
          fit="fit"
        />
      </div>
    </div>
 
    <div slot="footer" class="dialog-footer select-member-footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="handleConfirm" :disabled="!selectedPersonnelId || !imgSrc">
        确认发送
      </el-button>
    </div>
 
    <SignatureCanvas
      :visible="signatureDialogVisible"
      @confirm="handleSignatureConfirm"
      @close="signatureDialogVisible = false"
    />
  </el-dialog>
</template>
 
<script>
import SignatureCanvas from "@/components/SignatureCanvas.vue";
import {getFullUrl} from '@/utils/utils.js'
import {queryDetail} from '@/components/service.js'
 
export default {
  name: "ReceiveConfirmDialog",
  components: {
    SignatureCanvas,
  },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    sampleCount: {
      type: Number,
      default: 1,
    },
    personnelList: {
      type: Array,
      default: () => [],
      validator: (value) => {
        return value.every(item => item.id && item.nickName)
      }
    },
  },
  data() {
    return {
      signatureDialogVisible: false,
      imgSrc: "",
      selectedPersonnelId: null,
    };
  },
  methods: {
    getFullUrl,
    open(){
      queryDetail().then(res=>{
        if(res){
          this.imgSrc=res.signPicture
        }
      })
    },
    handleClose() {
      this.$emit("update:visible", false);
      this.imgSrc = "";
    },
    openSignature() {
      this.signatureDialogVisible = true;
    },
    handleSignatureConfirm(imageData) {
      this.signatureDialogVisible = false;
      this.imgSrc = ""; // 先清空
      this.$nextTick(() => {
        this.imgSrc = imageData;
      });
    },
    handlePersonnelRowClick(row, column, event) {
      // 当点击表格行时,设置为选中状态
      this.$refs.personnelTable.clearSelection();
      this.$refs.personnelTable.toggleRowSelection(row);
      this.selectedPersonnelId = row.id;
    },
    getPersonnelRowClassName({ row }) {
      // 根据是否选中来设置行样式
      return row.id === this.selectedPersonnelId ? 'selected-personnel' : '';
    },
    handleSelectionChange(selection) {
      // 当radio选择改变时,更新选中的人员
      if (selection && selection.id) {
        this.selectedPersonnelId = selection.id;
      } else {
        this.selectedPersonnelId = null;
      }
    },
    handleConfirm() {
      if (!this.selectedPersonnelId) {
        this.$message.warning("请先选择接收人员");
        return;
      }
      if (!this.imgSrc) {
        this.$message.warning("请先完成签名确认");
        return;
      }
      
      this.$emit("confirm", {
        personnelId: this.selectedPersonnelId,
        personnelName: this.personnelList.find(p => p.id === this.selectedPersonnelId)?.name || '',
        imgSrc: this.imgSrc
      });
      this.handleClose();
    },
    handleClose() {
      this.$emit("update:visible", false);
      this.imgSrc = "";
      this.selectedPersonnelId = null; // 清空选中的人员
    },
  },
};
</script>
 
<style lang="less" scoped>
::v-deep .el-dialog__header {
  border-bottom: 1px solid #e4e7ed;
}
 
.receive-dialog {
  padding: 20px;
 
  .receive-tip {
    font-size: 14px;
    color: #333;
    margin-bottom: 20px;
 
    .sample-count {
      color: #409EFF;
      font-weight: bold;
    }
  }
}
 
.approval-dialog-approve {
  margin-top: 26px;
 
  img {
    border: 2px dashed #049c9a;
  }
}
 
.add-group {
  padding-left: 25px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  margin-bottom: 19px;
 
  div {
    color: #f56c6c;
  }
 
  span {
    font-weight: 500;
    font-size: 14px;
    color: #222222;
    line-height: 21px;
    margin: 0 32px 0 8px;
  }
}
 
.personnel-selection {
  margin-bottom: 20px;
}
 
.personnel-table {
  padding-left: 25px;
  margin-bottom: 19px;
 
  ::v-deep .el-table {
    border-radius: 4px;
 
    .el-table__header-wrapper {
      thead {
        th {
          background-color: #f5f7fa;
          color: #606266;
          font-weight: 500;
          font-size: 13px;
          border-color: #ebeef5;
        }
      }
    }
 
    .el-table__body-wrapper {
      tbody {
        td {
          border-color: #ebeef5;
          font-size: 13px;
 
          &.cell {
            padding: 8px 0;
          }
        }
 
        .selected-personnel {
          background-color: #ecf5ff;
        }
 
        tr:hover {
          background-color: #f5f7fa;
        }
 
        tr.selected-personnel:hover {
          background-color: #ecf5ff;
        }
      }
    }
  }
}
 
.dialog-footer {
  align-items: center;
  display: flex;
  justify-content: center;
 
  button {
    width: 150px;
  }
}
</style>