chenyc
2025-06-13 6cc31048cb4c1f7a97d845217485ae317f6cf627
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
<template>
    <div class="dietarySurvey-item">
        <el-dialog  v-model="state.dialogTableVisible" title="随访记录" :show-close="false" :fullscreen="true" width="100%">
            <div style="width: 100%; height: 100%;overflow: auto;">
                <div id="printFrom1">
                    <div>
                        <el-form size="small">
                            <div style="width: 100%">
                                <table id="tabledome" class="gridtable">
 
                                    <tr>
                                        <th colspan="2">
                                            <el-form-item label="初次调查日期">
                                                <el-date-picker v-model="state.tableData.初次调查日期" type="date" style="width: 100px;"
                                                    placeholder="" readonly format="YYYY/MM/DD" value-format="YYYY-MM-DD" />
                                            </el-form-item>
 
                                        </th>
                                        <th colspan="2">
                                            <el-form-item label="更新日期">
                                                <el-date-picker v-model="state.tableData.更新日期" type="date" style="width: 100px;"
                                                    placeholder="" readonly format="YYYY/MM/DD" value-format="YYYY-MM-DD" />
                                            </el-form-item>
                                        </th>
                                        <th colspan="2">
                                            <el-form-item label="记录者">
                                                <el-input readonly v-model="state.tableData.记录者"   placeholder="" />
                                            </el-form-item>
                                            
                                        </th>
 
                                    </tr>
                                    <tr>
                                        <td colspan="3">
                                            <el-form-item label="干体重">
                                                <el-input readonly v-model="state.tableData.干体重"  placeholder="" />
                                            </el-form-item>
                                        </td>
                                        <td colspan="3">
                                            <el-form-item label="脱水量">
                                                <el-input readonly v-model="state.tableData.脱水量"  placeholder="" />
                                            </el-form-item>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="background-color: antiquewhite;">
                                           指导建议
                                        </td>
                                        <td style="background-color: antiquewhite;" colspan="5">
                                            <el-form-item>
                                                <el-input  v-model="state.tableData.指导建议" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="指导建议" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td style="background-color: antiquewhite;">
                                           执行反馈
                                        </td>
                                        <td colspan="5" style="background-color: antiquewhite;">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.执行反馈" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="执行反馈" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>
                                            睡眠近况
                                        </td>
                                        <td  colspan="5">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.睡眠近况" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="睡眠近况" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>
                                            运动近况
                                        </td>
                                        <td  colspan="5">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.运动近况" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="运动近况" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>
                                            排便近况
                                        </td>
                                        <td  colspan="5">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.排便近况" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="排便近况" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>
                                            食欲近况
                                        </td>
                                        <td  colspan="5">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.食欲近况" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="食欲近况" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>
                                            皮肤瘙痒
                                        </td>
                                        <td  colspan="5">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.皮肤瘙痒" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="皮肤瘙痒" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>
                                            心肺功能
                                        </td>
                                        <td  colspan="5">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.心肺功能" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="心肺功能" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>
                                            用药情况
                                        </td>
                                        <td  colspan="5">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.用药情况" type="textarea"
                                                    :autosize="{ minRows: 1, maxRows: 6 }" placeholder="用药情况" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                    <tr>
                                        <td>
                                            其他(烟酒、过敏,发热)
                                        </td>
                                        <td  colspan="5">
                                            <el-form-item>
                                                <el-input v-model="state.tableData.其他" type="textarea"
                                                    :autosize="{ minRows: 2, maxRows: 6 }" placeholder="其他" />
                                            </el-form-item>
                                        </td>
                                       
                                    </tr>
                                </table>
                            </div>
                        </el-form>
                    </div>
 
                </div>
            </div>
            <template #footer>
                <div class="dialog-footer" style="text-align: center">
                    <el-button @click="funhui">取消</el-button>
                    <el-button type="primary" @click="onSubmit">
                        保存
                    </el-button>
                    <el-button v-if="state.viewInfo.id" type="primary" v-print="'#printFrom1'">
                        <el-icon><Printer /></el-icon>
                        打印
                    </el-button>
                    <el-button type="primary" v-if="state.viewInfo.id" @click="generatePDF">
                        <el-icon><Position /></el-icon>
                        导出
                    </el-button>
                    
                </div>
            </template>
        </el-dialog>
 
 
    </div>
 
</template>
 
<script setup lang="ts" name="visualizingLinkDemo2">
import html2pdf from 'html2pdf.js';
import { reactive, onMounted, onUnmounted, ref } from 'vue';
import { formatDate } from '/@/utils/formatTime';
import { NextLoading } from '/@/utils/loading';
import { useUserInfo } from '/@/stores/userInfo';
import { usePatientsInfo } from '/@/stores/patientsInfo';
import { getPatData} from '/@/api/Patients';
const storesPat = usePatientsInfo();
import {Add,update,deleteId,tiaochabiaoInfo} from '/@/api/tiaochabiao/index'
import { storeToRefs } from 'pinia';
import { useRoute,useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
const stores = useUserInfo();
const { patientsInfo } = storeToRefs(storesPat);
const { userInfos } = storeToRefs(stores);
const router = useRouter()
const emit = defineEmits([ "shuaxin" ]);
const state = reactive({
    patientData:{干体重:0,脱水量:0},
    dialogTableVisible:false,
    
    tableData: {
        表名: '随访记录',
        初次调查日期:"",
        填表日期: '',
        更新日期: '',
        记录者: '陈银成',
        干体重:0,
        脱水量:0,
        指导建议:'',
        执行反馈:'',
        睡眠近况:'',
        运动近况:'',
        排便近况:'',
        食欲近况:'',
        皮肤瘙痒:'',
        心肺功能:'',
        用药情况:'',
        其他:''
    },
    loading: false,
    viewInfo:{
        id: 0,
        code: '',
        clientCode: userInfos.value.clientCode,
        patientCode: patientsInfo.value.code,
        surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
        surveryPerson: userInfos.value.code,
        surveryJsonBody: '',
        suveryFormName:'随访记录',
        surveryFormType:0,
        updateTime: ''
    },
    保存状态:{}
 
})
 
 
const generatePDF=()=> {
      const element = document.getElementById('printFrom1');
      const opt = {
        margin: 10,
        filename: `${state.tableData.表名}.pdf`,
        image: { type: 'jpeg', quality: 0.98 },
        html2canvas: { scale: 2 },
        jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
      };
      html2pdf().set(opt).from(element).save();
 
}
// 提交
const onSubmit = () => {
  console.log('submit!')
  console.log(state.tableData)
  const info:tiaochabiaoInfo={
    id: state.viewInfo.id,
    surveryFormType:0,
    code: state.viewInfo.code,
    clientCode: userInfos.value.clientCode,
    patientCode: patientsInfo.value.code,
    surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
    surveryPerson: userInfos.value.code,
    surveryJsonBody: JSON.stringify(state.tableData),
    suveryFormName:'随访记录',
    updateTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS')
  }
  console.log(info)
  if(info.id===0){
    Add(info).then(re=>{
        console.log(re.data)
        state.dialogTableVisible=false
        emit('shuaxin')
    })
  }else if(info.id>0){
    info.surveryTime=state.viewInfo.surveryTime
    update(info).then(re=>{
        console.log(re.data)
        state.dialogTableVisible=false
        emit('shuaxin')
    })
    
  }
  
}
const getPageInfo=()=>{
    state.tableData={
        表名: '随访记录',
        初次调查日期: formatDate(new Date(),'YYYY-mm-dd'),
        填表日期: '',
        更新日期: formatDate(new Date(),'YYYY-mm-dd'),
        记录者: userInfos.value.userName,
        干体重:state.patientData?.干体重,
        脱水量:state.patientData?.上一次超滤总量,
        指导建议:'无',
        执行反馈:'无',
        睡眠近况:'无',
        运动近况:'无',
        排便近况:'无',
        食欲近况:'无',
        皮肤瘙痒:'无',
        心肺功能:'无',
        用药情况:'无',
        其他:'无'
    }
    state.viewInfo={
        id: 0,
        code: '',
        clientCode: userInfos.value.clientCode,
        patientCode: patientsInfo.value.code,
        surveryTime: formatDate(new Date(), 'YYYY-mm-dd HH:MM:SS'),
        surveryPerson: userInfos.value.code,
        surveryJsonBody: '',
        suveryFormName:'随访记录',
        surveryFormType:0,
        updateTime: ''
    }
}
onMounted(()=>{
   
})
 
// 第一步:定义子组件里面的方法
const getData = (str: string) => {
    console.log("子组件获取显示数据!" + str);
    state.loading = true
 
}
// 打开查看或者编辑明细
const openShow = async (type: string,mode:tiaochabiaoInfo) => {
    console.log(type)
    var pam = {
        patCode: patientsInfo.value.code,
    }
    const res= await getPatData(pam)
    state.patientData = res.data
    if(type==='add'){
        getPageInfo()
        state.dialogTableVisible = true
    }
    else if(type==='update'){
        console.log(mode)
        state.viewInfo=mode
        state.tableData=JSON.parse(mode.surveryJsonBody)
        state.tableData.初次调查日期=mode.surveryTime
        state.tableData.更新日期=mode.updateTime
        state.dialogTableVisible = true
 
 
    }
    state.保存状态=JSON.parse(JSON.stringify(state.tableData))
 
 
   
}
const funhui=()=>{
    
    console.log(JSON.stringify(state.保存状态))
    console.log('------------')
    console.log(JSON.stringify(state.tableData))
    if(JSON.stringify(state.保存状态)===JSON.stringify(state.tableData)){
        state.dialogTableVisible=false
    }else{
        ElMessageBox.confirm(
            '你的表单数据有变动还没有保存,你是否要保存?',
            '提示',
            {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning',
            }
        )
            .then(() => {
                onSubmit()
            })
            .catch(() => {
                state.dialogTableVisible=false
        })
    }
   
}
 
// 第二步:暴露方法
defineExpose({ getData, openShow })
</script>
 
 
<style scoped lang="scss">
 
.gridtable {
    font-family: verdana, arial, sans-serif;
    font-size: 11px;
    color: #333333;
    border-width: 1px;
    border-color: #666666;
    border-collapse: collapse;
   
}
 
.gridtable th {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #666666;
    background-color: #a4b0e2;
}
 
.gridtable td {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #666666;
    background-color: #ffffff;
}
input {
    /* 去除所有边框 */
    border: none;
    text-align: center;
    font-size: 12px;
    
    /* 设置下边框 */
    border-bottom: 1px solid #000; /* 您可以根据需要调整颜色和宽度 */
    
    /* 可选:设置背景透明 */
    background-color: transparent;
    
    /* 移除内边距和外边距 */
    padding: 5px 0; /* 根据需要调整上下内边距,确保文本与线条之间有足够的空间 */
    margin: 0;
    
    /* 移除默认轮廓 */
    outline: none;
    
    /* 移除浏览器默认样式 */
    appearance: none;
    -webkit-appearance: none;
}
 
/* 可选:为聚焦状态添加自定义样式 */
input:focus {
    /* 当输入框获得焦点时,改变下边框的颜色或增加一些视觉提示 */
    border-bottom-color: #007BFF; /* 聚焦时的下边框颜色 */
    
    /* 可选:添加轻微的阴影效果来突出显示 */
    box-shadow: 0 1px 0 0 #007BFF; /* 在下边框下方添加一条颜色相同的阴影 */
}
</style>