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
<template>
    <div class="dietarySurvey-home" >
        <el-row v-if="patientsInfo.id"  style="padding-left: 10px;">
            <el-form size="small" :inline="true" :model="state.formInline">
                <el-form-item label="填报日期">
                    <el-date-picker
                        v-model="state.formInline.date"
                        type="daterange"
                        unlink-panels
                        range-separator="To"
                        start-placeholder="开始"
                        end-placeholder="结束"
                        :shortcuts="shortcuts"
                        format="YYYY/MM/DD"
                        value-format="YYYY-MM-DD"
                    />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">查询</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" plain @click="addItem">添加</el-button>
                </el-form-item>
            </el-form>
        </el-row>
        <div v-if="patientsInfo.id"  class="divcont">
            <el-table size="default" :data="state.tableData" stripe style="width: 100%"  :height="tableHe">
                <el-table-column fixed label="NO" type="index" widtd="80" >
                        <template #header>
                            <el-icon @click="onSubmit"><RefreshRight /></el-icon>
                        </template>
                      
                    </el-table-column>
                    <el-table-column  prop="surveryTime" label="填表时间" show-overflow-tooltip >
                        <template #default="scope">
                            {{scope.row.updateTime?.substring(0,11)}}
                        </template>
                    </el-table-column>
                    <el-table-column   label="干体重" show-overflow-tooltip >
                        <template #default="scope">
                            {{scope.row.mode.干体重}}
                        </template>
                    </el-table-column>
                    <el-table-column   label="脱水量" show-overflow-tooltip >
                        <template #default="scope">
                            {{scope.row.mode.脱水量}}
                        </template>
                    </el-table-column>
                    <el-table-column   label="指导建议" show-overflow-tooltip >
                        <template #default="scope">
                            {{scope.row.mode.指导建议}}
                        </template>
                    </el-table-column>
                    <el-table-column   label="执行反馈" show-overflow-tooltip >
                        <template #default="scope">
                            {{scope.row.mode.执行反馈}}
                        </template>
                    </el-table-column>
                    <el-table-column  prop="surveryPersonName" label="填表人" show-overflow-tooltip />
                    <!-- <el-table-column  prop="updateTime" label="更新时间" show-overflow-tooltip /> -->
                    <el-table-column  label="操作" >
                        <template #default="scope">
                            <el-button size="small" @click="handleEdit(scope.$index, scope.row)">
                                    编辑
                            </el-button>
                            <el-button
                            size="small"
                            type="danger"
                            @click="handleDelete(scope.$index, scope.row)"
                            >
                                 删除
                            </el-button>
                        </template>
                    </el-table-column>
            </el-table>
            <el-pagination
                v-model:current-page="state.page"
                v-model:page-size="state.size"
                :page-sizes="[10, 20, 30, 40]"
                layout="total, sizes, prev, pager, next, jumper"
                :total="state.total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                />
        </div>
        <el-empty v-if="!patientsInfo.id" description="无数据,请先选择患者"></el-empty>
        <editDietary ref="editDietaryRef"  @shuaxin="onSubmit"></editDietary>
    </div>
</template>
 
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { usePatientsInfo } from '/@/stores/patientsInfo';
import {list,tiaochabiaoInfo,deleteId} from '/@/api/tiaochabiao/index'
import { computed, reactive, ref } from 'vue';
import { useRoute,useRouter } from 'vue-router';
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus';
import editDietary from './editDietary.vue'
const storesPat = usePatientsInfo();
const { patientsInfo } = storeToRefs(storesPat);
const props = defineProps(['tableHeight'])
const editDietaryRef=ref()
const router = useRouter()
const shortcuts = [
  {
    text: '上一周',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      return [start, end]
    },
  },
  {
    text: '上一个月',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      return [start, end]
    },
  },
  {
    text: '前三个月',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      return [start, end]
    },
  },
]
const state = reactive({
    tableData: [],
    page:1,
    size:10,
    total:0,
    loading: false,
    formInline:{
        user: '',
        formTableName:'随访记录',
        date: [],
    },
    dialogTableVisible:false
})
const tableHe = computed(() => {
    return (props.tableHeight-200)+'px'
})
const handleSizeChange = (val: number) => {
  console.log(`${val} items per page`)
  state.size=val
  onSubmit()
}
const handleCurrentChange = (val: number) => {
  console.log(`current page: ${val}`)
  state.page=val
  onSubmit()
}
 
const onSubmit=()=>{
    console.log(state.formInline)
    const pasm={
        page: state.page,
        size: state.size,
        wherecondition:`survery_form_type=0 and patient_code='${patientsInfo.value.code}'`,
        ordercondition: 'survery_time desc'
    }
    if(state.formInline?.date?.length===2){
        pasm.wherecondition+=` and survery_time BETWEEN '${state.formInline.date[0]} 00:00:00' AND '${state.formInline.date[1]} 23:59:59'`
    }
    if(state.formInline?.formTableName){
        pasm.wherecondition+=`and suvery_form_name='${state.formInline.formTableName}'`
    }
    const loading = ElLoading.service({
        lock: true,
        text: 'Loading',
        background: 'rgba(0, 0, 0, 0.7)',
    })
    list(pasm).then(re=>{
        state.tableData=re.data.list.map((v: any) => {
                v.mode=JSON.parse(v.surveryJsonBody)
                return v;
            })
        state.total=re.data.total
    }).finally(()=>{
        loading.close()
    })
}
const addItem=()=>{
    
    editDietaryRef.value.openShow('add')
    // router.push({path:'/tiaochabiao1',query:{type:'add',id:0}})
}
// 第一步:定义子组件里面的方法
const getData = (str: string) => {
    const pasm = {
        page: 1,
        size: 10,
        wherecondition:`survery_form_type=0 and patient_code='${patientsInfo.value.code}'`,
        ordercondition:'survery_time DESC'
    }
    if(state.formInline?.date?.length===2){
        pasm.wherecondition+=`and survery_time BETWEEN '${state.formInline.date[0]} 00:00:00' AND '${state.formInline.date[1]} 23:59:59'`
    }
    if(state.formInline.formTableName){
        pasm.wherecondition+=`and suvery_form_name='${state.formInline.formTableName}'`
    }
    const loading = ElLoading.service({
        lock: true,
        text: 'Loading',
        background: 'rgba(0, 0, 0, 0.7)',
    })
    list(pasm).then(re=>{
        console.log(re)
        state.tableData=re.data.list.map((v: any) => {
            v.mode=JSON.parse(v.surveryJsonBody)
            return v;
        })
        state.total=re.data.total
    }).finally(()=>{
        loading.close()
    })
 
    state.loading = true
 
}
 
// 第二步:暴露方法
defineExpose({ getData })
/**
 * 编辑
 */
const handleEdit = (index: number, row: any) => {
  console.log(index, row,state.formInline.formTableName)
  editDietaryRef.value.openShow('update',row)
}
const handleDelete = (index: number, row: any) => {
  console.log(index, row)
  ElMessageBox.confirm(
    '你确定要删除该条记录?',
    'Warning',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
        deleteId(`id=${row.id}`).then(re=>{
            ElMessage.success('删除成功')
            onSubmit()
        }).catch(e=>{
            ElMessage.error('删除失败!')
        })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消操作',
      })
    })
 
}
</script>
 
<style  lang="scss">
 
 
    .gridtable {font-family: verdana,arial,sans-serif;font-size:11px;color:#333333;border-width: 1px;border-color: #666666;border-collapse: collapse;width: 100%;}
 
    .gridtable th {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #dedede;}
 
    .gridtable td {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #ffffff;min-width: 100px;}
    .input-underline {
        border: none; /* 移除所有边框 */
        border-bottom: 1px solid #ccc; /* 显示下边框 */
        outline: none; /* 移除点击输入框时浏览器可能会提供的默认轮廓线 */
        text-align: center;
    }
    .width50{
        width: 50px;
    }
.infinite-list {
    overflow: auto;
    padding: 0;
    margin: 0;
    list-style: none;
}
.infinite-list .infinite-list-item {
  display: flex;
}
 
.divcont{
    overflow-y: auto; /* 垂直滚动条 */
}
 
</style>