WXL (wul)
6 天以前 a5cba9ab040f6f97558046885dce3017f9bab7e9
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<template>
  <el-dialog
    :title="dialogTitle"
    :visible.sync="dialogVisible"
    width="750px"
    :close-on-click-modal="false"
    append-to-body
    @close="handleClose"
    top="3vh"
  >
    <!-- 已选患者预览(关联建档模式) -->
    <div class="archive-section" v-if="selectedPatients.length > 0">
      <div class="section-title">已选患者({{ selectedPatients.length }}人)</div>
      <el-table :data="selectedPatients" border size="small" max-height="180">
        <el-table-column prop="patname" label="姓名" width="80" align="center" />
        <el-table-column label="性别" width="60" align="center">
          <template slot-scope="scope">{{ scope.row.sex == 1 ? "男" : "女" }}</template>
        </el-table-column>
        <el-table-column prop="age" label="年龄" width="60" align="center" />
        <el-table-column prop="deptname" label="科室" align="center" />
        <el-table-column prop="diagname" label="诊断" align="center" show-overflow-tooltip />
      </el-table>
      <el-divider />
    </div>
 
    <!-- 独立建档:录入患者信息 -->
    <div class="archive-section" v-if="standalone">
      <div class="section-title">患者基本信息</div>
      <el-form :model="standalonePatient" label-width="100px" size="small" inline>
        <el-form-item label="姓名" required>
          <el-input v-model="standalonePatient.patname" placeholder="请输入" style="width:150px" />
        </el-form-item>
        <el-form-item label="性别" required>
          <el-select v-model="standalonePatient.sex" style="width:80px">
            <el-option :value="1" label="男" />
            <el-option :value="2" label="女" />
          </el-select>
        </el-form-item>
        <el-form-item label="年龄">
          <el-input v-model="standalonePatient.age" placeholder="年龄" style="width:80px" />
        </el-form-item>
        <el-form-item label="联系电话">
          <el-input v-model="standalonePatient.telcode" placeholder="联系电话" style="width:150px" />
        </el-form-item>
        <el-form-item label="科室">
          <el-input v-model="standalonePatient.deptname" placeholder="科室" style="width:150px" />
        </el-form-item>
        <el-form-item label="诊断">
          <el-input v-model="standalonePatient.diagname" placeholder="诊断" style="width:200px" />
        </el-form-item>
      </el-form>
      <el-divider />
    </div>
 
    <!-- 儿保科:家长信息(必填) -->
    <div class="archive-section" v-if="mainCategory === 'child'">
      <div class="section-title">家长/监护人信息</div>
      <el-form :model="parentInfo" label-width="100px" size="small" inline>
        <el-form-item label="家长姓名" required>
          <el-input v-model="parentInfo.parentName" placeholder="请输入" style="width:150px" />
        </el-form-item>
        <el-form-item label="与儿童关系">
          <el-select v-model="parentInfo.relation" style="width:120px">
            <el-option label="父亲" value="father" />
            <el-option label="母亲" value="mother" />
            <el-option label="祖父" value="grandfather" />
            <el-option label="祖母" value="grandmother" />
            <el-option label="其他" value="other" />
          </el-select>
        </el-form-item>
        <el-form-item label="联系电话" required>
          <el-input v-model="parentInfo.parentPhone" placeholder="联系电话" style="width:150px" />
        </el-form-item>
        <el-form-item label="身份证号">
          <el-input v-model="parentInfo.parentIdCard" placeholder="身份证号" style="width:200px" />
        </el-form-item>
        <el-form-item label="联系地址">
          <el-input v-model="parentInfo.address" placeholder="联系地址" style="width:300px" />
        </el-form-item>
      </el-form>
      <el-divider />
    </div>
 
    <!-- 建档主分类 -->
    <div class="archive-section">
      <div class="section-title">选择建档类型</div>
      <el-radio-group v-model="mainCategory" size="medium" @change="onMainCategoryChange">
        <el-radio-button label="child">儿保科建档</el-radio-button>
        <el-radio-button label="maternal">妇保科建档</el-radio-button>
      </el-radio-group>
    </div>
 
    <!-- 子类型 -->
    <div class="archive-section" v-if="mainCategory">
      <div class="section-title">选择专案类型</div>
      <el-radio-group v-model="subType" size="small" @change="onSubTypeChange">
        <template v-if="mainCategory === 'child'">
          <el-radio-button label="highRisk">高危儿专案管理</el-radio-button>
          <el-radio-button label="nutrition">营养性疾病专案管理</el-radio-button>
          <el-radio-button label="learning">学习困难专案管理</el-radio-button>
        </template>
        <template v-else>
          <el-radio-button label="pregnancy">孕妇随访</el-radio-button>
          <el-radio-button label="menopause">更年期随访</el-radio-button>
        </template>
      </el-radio-group>
    </div>
 
    <!-- 建档专属字段 -->
    <div class="archive-section" v-if="subType">
      <div class="section-title">建档信息</div>
      <el-form :model="archiveForm" label-width="120px" size="small">
        <!-- 儿保科 - 高危儿 -->
        <template v-if="mainCategory === 'child' && subType === 'highRisk'">
          <el-form-item label="高危因素">
            <el-select v-model="archiveForm.riskFactor" multiple placeholder="可多选" style="width:100%">
              <el-option label="早产/低体重" value="preterm" />
              <el-option label="窒息史" value="asphyxia" />
              <el-option label="颅内出血" value="ich" />
              <el-option label="高胆红素血症" value="hyperbilirubinemia" />
              <el-option label="宫内感染" value="intrauterine" />
              <el-option label="先天畸形" value="malformation" />
              <el-option label="其他" value="other" />
            </el-select>
          </el-form-item>
          <el-form-item label="出生体重(g)">
            <el-input-number v-model="archiveForm.birthWeight" :min="500" :max="6000" />
          </el-form-item>
          <el-form-item label="出生孕周">
            <el-input-number v-model="archiveForm.gestationalWeek" :min="22" :max="42" :precision="1" /> 周
          </el-form-item>
          <el-form-item label="建档医生">
            <el-input v-model="archiveForm.doctorName" placeholder="请输入建档医生" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
          </el-form-item>
        </template>
 
        <!-- 儿保科 - 营养性疾病 -->
        <template v-if="mainCategory === 'child' && subType === 'nutrition'">
          <el-form-item label="营养诊断" required>
            <el-select v-model="archiveForm.nutritionDiagnosis" placeholder="请选择" style="width:100%">
              <el-option label="营养不良" value="malnutrition" />
              <el-option label="超重" value="overweight" />
              <el-option label="肥胖" value="obesity" />
              <el-option label="微量元素缺乏" value="micronutrient" />
              <el-option label="喂养困难" value="feeding" />
            </el-select>
          </el-form-item>
          <el-form-item label="建档医生">
            <el-input v-model="archiveForm.doctorName" placeholder="请输入建档医生" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
          </el-form-item>
        </template>
 
        <!-- 儿保科 - 学习困难 -->
        <template v-if="mainCategory === 'child' && subType === 'learning'">
          <el-form-item label="学习问题" required>
            <el-select v-model="archiveForm.learningIssue" placeholder="请选择" style="width:100%">
              <el-option label="阅读障碍" value="dyslexia" />
              <el-option label="书写障碍" value="dysgraphia" />
              <el-option label="计算障碍" value="dyscalculia" />
              <el-option label="注意力缺陷" value="adhd" />
              <el-option label="混合型" value="mixed" />
            </el-select>
          </el-form-item>
          <el-form-item label="建档医生">
            <el-input v-model="archiveForm.doctorName" placeholder="请输入建档医生" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
          </el-form-item>
        </template>
 
        <!-- 妇保科 - 孕妇随访 -->
        <template v-if="mainCategory === 'maternal' && subType === 'pregnancy'">
          <el-form-item label="末次月经">
            <el-date-picker v-model="archiveForm.lmp" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" style="width:100%" />
          </el-form-item>
          <el-row :gutter="12">
            <el-col :span="8"><el-form-item label="孕周"><el-input-number v-model="archiveForm.gestationalWeek" :min="1" :max="42" :precision="1" /> 周</el-form-item></el-col>
            <el-col :span="8"><el-form-item label="孕次"><el-input-number v-model="archiveForm.gravidity" :min="1" :max="20" /></el-form-item></el-col>
            <el-col :span="8"><el-form-item label="产次"><el-input-number v-model="archiveForm.parity" :min="0" :max="20" /></el-form-item></el-col>
          </el-row>
          <el-form-item label="预产期">
            <el-date-picker v-model="archiveForm.edd" type="date" value-format="yyyy-MM-dd" placeholder="选择预产期" style="width:100%" />
          </el-form-item>
          <el-form-item label="高危妊娠">
            <el-switch v-model="archiveForm.highRiskPregnancy" active-text="是" inactive-text="否" />
          </el-form-item>
          <el-form-item label="建档医生">
            <el-input v-model="archiveForm.doctorName" placeholder="请输入建档医生" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
          </el-form-item>
        </template>
 
        <!-- 妇保科 - 更年期随访 -->
        <template v-if="mainCategory === 'maternal' && subType === 'menopause'">
          <el-form-item label="月经状态">
            <el-select v-model="archiveForm.menstrualStatus" placeholder="请选择" style="width:100%">
              <el-option label="月经紊乱" value="irregular" />
              <el-option label="闭经(<12个月)" value="amenorrhea_short" />
              <el-option label="绝经(≥12个月)" value="menopause" />
              <el-option label="人工绝经" value="surgical" />
            </el-select>
          </el-form-item>
          <el-form-item label="末次月经">
            <el-date-picker v-model="archiveForm.lmp" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" style="width:100%" />
          </el-form-item>
          <el-form-item label="建档医生">
            <el-input v-model="archiveForm.doctorName" placeholder="请输入建档医生" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="archiveForm.remark" type="textarea" :rows="2" />
          </el-form-item>
        </template>
      </el-form>
    </div>
 
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" :loading="submitting" @click="handleSubmit" :disabled="!canSubmit">
        确认建档
      </el-button>
    </div>
  </el-dialog>
</template>
 
<script>
export default {
  name: "ArchiveDialog",
  props: {
    visible: { type: Boolean, default: false },
    patients: { type: Array, default: () => [] },
    sourcePage: { type: String, default: "outpatient" },
    standalone: { type: Boolean, default: false },
  },
  data() {
    return {
      dialogVisible: false,
      mainCategory: "",
      subType: "",
      submitting: false,
      standalonePatient: { patname: "", sex: 2, age: "", telcode: "", deptname: "", diagname: "" },
      parentInfo: { parentName: "", relation: "", parentPhone: "", parentIdCard: "", address: "" },
      archiveForm: {
        riskFactor: [], birthWeight: null, gestationalWeek: null,
        nutritionDiagnosis: "", learningIssue: "",
        gravidity: 1, parity: 0, edd: "", lmp: "",
        highRiskPregnancy: false, menstrualStatus: "",
        doctorName: "", remark: "",
      },
    };
  },
  computed: {
    dialogTitle() {
      return this.standalone ? "新建建档" : "患者建档";
    },
    canSubmit() {
      if (!this.subType) return false;
      if (this.mainCategory === 'child' && !this.parentInfo.parentName) return false;
      if (this.standalone && !this.standalonePatient.patname) return false;
      return true;
    },
    selectedPatients() {
      return this.patients || [];
    },
  },
  watch: {
    visible(val) {
      this.dialogVisible = val;
      if (val) this.resetForm();
    },
    dialogVisible(val) {
      if (!val) this.$emit("update:visible", false);
    },
  },
  methods: {
    resetForm() {
      this.mainCategory = "";
      this.subType = "";
      this.standalonePatient = { patname: "", sex: 2, age: "", telcode: "", deptname: "", diagname: "" };
      this.parentInfo = { parentName: "", relation: "", parentPhone: "", parentIdCard: "", address: "" };
      this.archiveForm = {
        riskFactor: [], birthWeight: null, gestationalWeek: null,
        nutritionDiagnosis: "", learningIssue: "",
        gravidity: 1, parity: 0, edd: "", lmp: "",
        highRiskPregnancy: false, menstrualStatus: "",
        doctorName: "", remark: "",
      };
    },
    onMainCategoryChange() { this.subType = ""; },
    onSubTypeChange() {},
 
    getSubTypeLabel() {
      const map = { highRisk: "高危儿专案管理", nutrition: "营养性疾病专案管理", learning: "学习困难专案管理", pregnancy: "孕妇随访", menopause: "更年期随访" };
      return map[this.subType] || "";
    },
    getMainCategoryLabel() {
      return this.mainCategory === "child" ? "儿保科建档" : "妇保科建档";
    },
 
    handleSubmit() {
      if (!this.subType) { this.$message.warning("请选择专案类型"); return; }
      if (!this.standalone && this.selectedPatients.length === 0) { this.$message.warning("请选择患者"); return; }
      this.submitting = true;
 
      const archives = JSON.parse(localStorage.getItem("patientArchives") || "[]");
      const now = new Date().toISOString().replace("T", " ").substring(0, 19);
 
      // 确定患者列表
      const patientList = this.standalone
        ? [{ ...this.standalonePatient, patid: "sa_" + Date.now() }]
        : this.selectedPatients;
 
      patientList.forEach((patient) => {
        archives.push({
          id: "arc_" + Date.now() + "_" + Math.random().toString(36).substr(2, 6),
          patientId: patient.patid || patient.id,
          patname: patient.patname,
          sex: patient.sex,
          age: patient.age,
          telcode: patient.telcode || patient.phone || "",
          deptname: patient.deptname || "",
          diagname: patient.diagname || "",
          inhospno: patient.inhospno || "",
          outhospno: patient.outhospno || "",
          bedNo: patient.bedNo || "",
          drname: patient.drname || "",
          nurseName: patient.nurseName || "",
          starttime: patient.starttime || patient.admitdate || "",
          mainCategory: this.mainCategory,
          mainCategoryLabel: this.getMainCategoryLabel(),
          subType: this.subType,
          subTypeLabel: this.getSubTypeLabel(),
          archiveForm: JSON.parse(JSON.stringify(this.archiveForm)),
          parentInfo: this.mainCategory === 'child' ? JSON.parse(JSON.stringify(this.parentInfo)) : {},
          sourcePage: this.standalone ? "standalone" : this.sourcePage,
          status: "active",
          createTime: now,
          updateTime: now,
        });
      });
 
      localStorage.setItem("patientArchives", JSON.stringify(archives));
 
      this.submitting = false;
      this.dialogVisible = false;
      this.$message.success(`成功创建 ${patientList.length} 条建档记录`);
      this.$emit("created");
 
      // 跳转
      const routePath = this.mainCategory === "child"
        ? "/filing/childHealth"
        : "/filing/maternalHealth";
      this.$router.push({ path: routePath });
    },
    handleClose() { this.resetForm(); },
  },
};
</script>
 
<style lang="scss" scoped>
.archive-section { margin-bottom: 18px; }
.section-title { font-size: 15px; font-weight: 600; color: #303133; margin-bottom: 12px; padding-left: 10px; border-left: 3px solid #409eff; }
.dialog-footer { text-align: right; }
</style>