2
lkk
2025-04-09 7db11f1ecbe7df37eb1a8adfdfadc8b654d46522
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1080px"
      append-to-body
    >
      <h3 v-if="fList.proResult">检测项目 :{{ fList.project.proName }}</h3>
      <h3 v-if="fList.proResult">
        检测结果 :{{ fList.proResult }}{{ fList.project.proMetering }}
      </h3>
      <!-- <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        label-width="68px"
      > -->
        <!-- <el-form-item label="病种名称" prop="bingzhong">
          <el-input
            v-model="queryParams.bingzhong"
            placeholder="请输入简称"
            clearable
            @keyup.enter.native="handleQuery"
            style="width: 120px"
          />
        </el-form-item>
        <el-form-item label="拼音码" prop="bzPinyin">
          <el-input
            v-model="queryParams.bzPinyin"
            placeholder="请输入拼音码"
            clearable
            @keyup.enter.native="handleQuery"
            style="width: 130px"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
        </el-form-item> -->
        <!-- <el-form-item>
          <h3 >{{ queryParams.proName  || '暂无项目名称'  }}</h3>
        </el-form-item> -->
        <!-- <el-form-item>
          <h3 style="margin-left: 160px">已选项目</h3>
        </el-form-item> -->
      <!-- </el-form> -->
      <h2 style="text-align: center;margin-top: -30px;">{{ queryParams.proName  || '暂无项目名称'  }}</h2>
      <div style="display: flex; width: 100%">
        <div style="width: 50%; margin-right: 40px">
          <el-table
            :data="dataList"
            ref="multipleTable"
            v-loading="loading"
            @selection-change="handleSelectionChange"
            border
            height="420px"
          >
            <el-table-column type="selection" width="40" align="center" />
            <el-table-column
              label="序号"
              type="index"
              align="center"
              width="50px"
            />
            <!-- <el-table-column label="规则" align="center" prop="ruleStr" /> -->
            <el-table-column label="检查所见" align="center" prop="yxbx" />
            <el-table-column label="检查结论" align="center" prop="ruleStr" />
          </el-table>
          <div class="pag">
            <div class="pag1" style="margin-left: 630px">
              <pagination
                small
                v-show="total > 0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getList"
              />
            </div>
          </div>
        </div>
 
        <div style="width: 100%; height: 600px">
          <!-- <h3 style="margin-top: -30px;">已选项目</h3> -->
          <el-form
            :model="form"
            ref="queryForm"
            size="small"
            label-width="68px"
            :inline="true"
          >
            <!--  :inline="true" -->
            <!-- <el-form-item>
              <el-input
                type="textarea"
                v-model="form.desc"
                style="width: 560px"
              ></el-input>
            </el-form-item> -->
            <el-form-item label="检查所见" prop="jcsj">
              <el-input
                v-model="form.jcsj"
                clearable
                type="textarea"
                :autosize="{ minRows: 8 }"
                style="width: 380px"
              />
            </el-form-item>
            <el-form-item label="检查结论" prop="conclusion">
              <el-input
                v-model="form.desc"
                clearable
                type="textarea"
                :autosize="{ minRows: 8 }"
                style="width: 380px"
              />
            </el-form-item>
          </el-form>
        </div>
      </div>
 
      <span slot="footer" class="dialog-footer" style="margin-top: -120px">
        <el-button @click="open = false">取 消</el-button>
        <el-button type="primary" @click="handleOk">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
  
<script>
import { getlist, getlistByRuleStr } from "@/api/doctor/check";
import { getYxJcXxJg } from "@/api/picture/picture";
export default {
  name: "Public",
  props: {
    checkStatus: {
      type: String,
      default: "0",
      validator: (value) => ["0", "1"].includes(value),
    },
    proResult: {
      type: String,
      default: "",
    },
    conclusion: {
      type: String,
      default: "",
    },
    projectList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      open: false,
      // 弹出层标题
      title: "",
      yxbx: "",
      proName:'',
      //   lastDesc: "",
      total: 0,
      dataList: [],
      // 遮罩层
      loading: false,
      form: {
        desc: "",
        jcsj: "",
      },
      queryParams: {
        bingzhong: "",
        bzPinyin: "",
        proId:"",
        proName:"",
        pageNum: 1,
        pageSize: 10,
      },
      list: [],
      fList: {},
      selectedItems: [],
      searchDebounce: null,
    };
  },
  watch: {
    checkStatus(newValue) {
      if (newValue === "1") {
        this.updateData(this.proResult, this.conclusion);
      }
    },
    projectList: {
      immediate: true,
      deep: true,
      handler(newVal) {
        console.log("收到的项目数据:", newVal);
        // 你可以在这里处理数据,比如保存到 data 或做逻辑判断
        if (newVal && newVal.length > 0) {
          const firstProject = newVal[0]; // 你也可以遍历所有项目,看你业务需求
          this.queryParams.proId = firstProject.proId; // 假设项目中叫 id
          this.queryParams.proName = firstProject.proName; // 假设叫 proName
          this.proName = firstProject.proName
        }
      },
    },
  },
  mounted() {},
 
  created() {},
  methods: {
    async getList() {
      try {
        this.loading = true; // 添加加载状态
 
        const res = await getlist(this.queryParams);
        this.dataList = res.rows;
        this.total = res.total;
 
        // 如果需要选中操作,将其封装为独立方法
        await this.handleAutoSelection();
      } catch (error) {
        console.error("获取数据失败:", error);
        this.$message.error("获取数据失败");
      } finally {
        this.loading = false;
      }
    },
 
    // 封装选中逻辑
    async handleAutoSelection() {
      if (!this.fList?.rulesList?.length) return;
 
      await this.$nextTick();
      this.dataList.forEach((item) => {
        const shouldSelect = this.fList.rulesList.some(
          (rule) => rule.aid === item.aid
        );
        if (shouldSelect) {
          this.$refs.multipleTable?.toggleRowSelection(item, true);
        }
      });
    },
 
    handleQuery() {
      if (this.searchDebounce) clearTimeout(this.searchDebounce);
 
      this.searchDebounce = setTimeout(() => {
        this.queryParams.pageNum = 1; // 重置页码
        this.getList();
      }, 300);
    },
 
    updateData(proResult, conclusion) {
      if (this.checkStatus === "1") {
        this.form.jcsj = proResult; // 更新检查所见
        this.form.desc = conclusion; // 更新检查结论
        // console.log(proResult, conclusion);
      }
    },
 
    handleSelectionChange(selection) {
      this.list = selection;
      this.updateFormContent(selection);
    },
 
    updateFormContent(selection) {
      if (!selection.length) return;
 
      // 如果处于检查状态,使用传入的值
      if (this.checkStatus === "1") {
        this.updateData(this.proResult, this.conclusion);
        return;
      }
 
      // 重置表单内容
      this.form.desc = "";
      this.form.jcsj = "";
 
      // 使用map和join替代forEach和字符串拼接
      this.form.desc = selection
        .map((item) => item.bingzhong || item.ruleStr)
        .filter(Boolean)
        .join(",");
 
      this.form.jcsj = selection
        .map((item) => item.yxbx)
        .filter(Boolean)
        .join(",");
    },
 
    handleOk() {
      if (!this.form.desc && !this.form.jcsj) {
        this.$message.warning("请选择数据");
        return;
      }
 
      try {
        this.$emit("add", this.form.desc, this.form.jcsj);
        this.resetForm();
        this.open = false;
      } catch (error) {
        console.error("处理数据失败:", error);
        this.$message.error("操作失败");
      }
    },
 
    resetForm() {
      this.form.desc = "";
      this.form.jcsj = "";
      this.list = [];
      if (this.$refs.multipleTable) {
        this.$refs.multipleTable.clearSelection();
      }
    },
  },
  computed: {
    isCheckMode() {
      return this.checkStatus === "1";
    },
 
    hasSelectedItems() {
      return this.list.length > 0;
    },
  },
};
</script>
  
<style scoped>
.el-dialog__body {
  padding: 10px 20px;
}
::v-deep .el-dialog__footer {
  padding: 0 !important;
  padding-bottom: 40px !important;
}
</style>