1
wwl
2 天以前 137bbf301680d8fa637dfad7662b006bf1c43641
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="68px"
      @submit.native.prevent
    >
      <el-form-item label="体检号" prop="reportDoctorCode">
        <el-input
          ref="inputName"
          v-model="queryParams.tjNum"
          placeholder="请输入体检号"
          clearable
          @keyup.enter.native="handleQuery"
          style="width: 170px"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          style="margin-right: 15px"
        >
          查询
        </el-button>
        <el-button
          icon="el-icon-refresh"
          type="primary"
          size="mini"
          @click="resetQuery"
        >
          重置
        </el-button>
        <el-button
          icon="el-icon-check"
          type="primary"
          size="mini"
          style="margin-right: 15px"
          @click="tongbu"
        >
          同步
        </el-button>
      </el-form-item>
    </el-form>
 
    <div class="box">
      <div class="table-header">检验记录</div>
      <div>
        <el-table
          :data="exaLists"
          border
          style="width: 100%"
          @selection-change="handleSelectionChange"
          :header-cell-style="{ background: '#aad8df', fontSize: '14px', color: '#333' }"
          height="350"
          ref="firstTable"
        >
          <el-table-column fixed type="selection" align="center" label="选择" width="50" />
          <el-table-column label="姓名" align="center" prop="name" width="80" />
          <el-table-column label="性别" align="center" prop="gender" width="80" />
          <el-table-column label="年龄" align="center" prop="patientAge" width="80" />
          <el-table-column label="送检科室" align="center" prop="deptName" width="100" />
          <el-table-column
            label="检验项目"
            align="center"
            prop="checkParts"
            width="350"
            :show-overflow-tooltip="true"
          />
          <el-table-column label="项目编号" align="center" prop="jcxmid" width="150" />
          <el-table-column label="审核医师" align="center" prop="shys" width="150" />
          <el-table-column label="报告时间" align="center" prop="examinationDate" width="150" />
          <el-table-column label="门诊号" align="center" prop="mzh" width="140" />
          <el-table-column label="申请单号" align="center" prop="brid" width="145" />
          <el-table-column label="报告医师" align="center" prop="reportDoctorName" width="120" />
          <el-table-column label="检验医师名" align="center" prop="checkDoctorName" width="120" />
          <el-table-column align="center" label="检测项目" width="100">
            <template slot-scope="scope">
              <div>{{ scope.row.proName }}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="proResult" label="检测结果" width="180" />
          <el-table-column align="center" prop="company" label="单位" width="80" />
          <el-table-column align="center" prop="conclusion" label="异常" width="180" />
          <el-table-column align="center" prop="tjStandardGtValue" label="参考范围" width="120" />
        </el-table>
      </div>
    </div>
 
    <div class="table-title">
      <h3>
        体检记录:
        <span class="highlight">姓名:{{ infoList.tjCustomerName || "暂无" }}</span>
        <span class="highlight">
          性别:
          {{
            infoList.tjCustomerSex == 0
              ? "男"
              : infoList.tjCustomerSex == 1
              ? "女"
              : "暂无"
          }}
        </span>
        <span class="highlight">年龄:{{ infoList.tjCustomerAge || "暂无" }}</span>
        <span class="highlight">门诊号:{{ infoList.cardId || "暂无" }}</span>
      </h3>
    </div>
 
    <el-table
      border
      height="350"
      ref="tab1"
      :data="checkList"
      v-loading="loading"
      style="width: 100%"
      @selection-change="handleSelectionChangeSecond"
      :header-cell-style="{ background: '#aad8df', fontSize: '14px', color: '#333' }"
    >
      <el-table-column type="selection" width="60" />
      <el-table-column
        label="状态"
        align="center"
        prop="type"
        :show-overflow-tooltip="true"
        min-width="60"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.type == '0'">未检</span>
          <span v-if="scope.row.type == '1'">已检</span>
          <span v-if="scope.row.type == '2'">弃检</span>
          <span v-if="scope.row.type == '3'">延期</span>
        </template>
      </el-table-column>
      <el-table-column label="科室" align="center" prop="deptName" min-width="115" />
      <el-table-column label="项目" align="center" prop="proName" min-width="160" />
      <el-table-column label="收费方式" align="center" prop="sffs" min-width="80" />
      <el-table-column label="是否收费" align="center" prop="isPay" min-width="80" />
      <el-table-column label="检验时间" align="center" prop="bcupdateTime" min-width="160" />
      <el-table-column label="最后修改时间" align="center" prop="zhupdateTime" min-width="160" />
    </el-table>
  </div>
</template>
 
<script>
import { getlisList, getJyTjList, asyncPacs } from "@/api/doctor/pacsCheck";
import { getOrderList } from "@/api/hosp/order";
 
export default {
  data() {
    return {
      queryParams: {
        tjNum: null,
      },
      exaLists: [],
      checkList: [],
      infoList: {},
      selectedFirstTable: [],
      selectedSecondTable: [],
      loading: false,
      isProcessingSelection: false,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.$refs.inputName.focus();
    });
  },
  methods: {
    async handleQuery() {
      if (!this.queryParams.tjNum) {
        this.$message.error("体检号不能为空");
        return;
      }
      this.loading = true;
      try {
        const [orderResponse, lisResponse] = await Promise.all([
          getOrderList(this.queryParams).catch(() => ({ data: { list: [] } })),
          getlisList(this.queryParams),
        ]);
        this.infoList = orderResponse.data.list?.[0] || {};
        this.exaLists = lisResponse.data.map((item, index) => ({
          ...item,
          brid: item.brid?.trim(),
          tempId: index,
        }));
        await this.fetchRightTableData();
      } catch (e) {
        console.error(e);
      } finally {
        this.loading = false;
      }
    },
 
    resetQuery() {
      this.queryParams.tjNum = null;
      this.exaLists = [];
      this.checkList = [];
      this.infoList = {};
    },
handleSelectionChange(selected) {
  if (this.isProcessingSelection) return;
  this.isProcessingSelection = true;
 
  // 找到用户刚操作的那一条(对比之前和现在的差异)
  const old = this.selectedFirstTable;
  let changedRow = null;
 
  if (selected.length > old.length) {
    // 新增:找出新增的
    changedRow = selected.find(row => !old.includes(row));
  } else {
    // 删除:找出删除的
    changedRow = old.find(row => !selected.includes(row));
  }
 
  if (changedRow) {
    const group = this.exaLists.filter(r => r.brid === changedRow.brid);
    const isAdding = selected.length > old.length;
 
    this.$refs.firstTable.clearSelection();
    if (isAdding) {
      // 添加,整个组选上 + 原有选的 brid 也选上
      const allBrids = new Set();
      selected.forEach(row => allBrids.add(row.brid));
      allBrids.add(changedRow.brid);
      const newSelection = this.exaLists.filter(row => allBrids.has(row.brid));
      newSelection.forEach(row => {
        this.$refs.firstTable.toggleRowSelection(row, true);
      });
      this.selectedFirstTable = newSelection;
    } else {
      // 删除,整个组取消,再把剩下 brid 分组补回去
      const remaining = old.filter(row => row.brid !== changedRow.brid);
      const remainBrids = [...new Set(remaining.map(r => r.brid))];
      const newSelection = this.exaLists.filter(row => remainBrids.includes(row.brid));
      newSelection.forEach(row => {
        this.$refs.firstTable.toggleRowSelection(row, true);
      });
      this.selectedFirstTable = newSelection;
    }
  } else {
    this.selectedFirstTable = selected;
  }
 
  this.fetchRightTableData();
  this.isProcessingSelection = false;
},
 
 
    handleSelectionChangeSecond(selected) {
      this.selectedSecondTable = selected.slice(0, 1);
    },
 
    fetchRightTableData() {
      if (!this.queryParams.tjNum) return;
      this.loading = true;
      return getJyTjList(this.queryParams.tjNum)
        .then(res => {
          this.checkList = res.data || [];
        })
        .finally(() => {
          this.loading = false;
        });
    },
 
    tongbu() {
      const requestData = {
        lis: this.selectedFirstTable,
        tj: this.selectedSecondTable[0],
      };
      asyncPacs(requestData).then(res => {
        if (res.code === 200) {
          this.$message.success("同步成功!");
          this.fetchRightTableData();
        } else {
          this.$message.error(res.message || "同步失败");
        }
      });
    },
  },
};
</script>
 
<style lang="scss" scoped>
.app-container {
  padding: 20px;
  background: #f5f7fa;
}
.table-header {
  text-align: center;
  background-color: #aad8df;
  padding: 10px;
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-top: 10px;
  border-radius: 4px 4px 0 0;
}
.table-title {
  text-align: left;
  margin: 20px 0;
  padding: 10px 0;
}
.table-title h3 {
  font-size: 16px;
  color: #333;
  margin: 0;
  line-height: 1.5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.table-title .highlight {
  font-weight: bold;
  color: #2c3e50;
}
.el-table {
  border-radius: 4px;
  font-size: 14px;
}
</style>