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
| <template>
| <div>
| <el-table :data="items" border size="small">
| <el-table-column prop="item" label="条目" width="280" />
| <el-table-column label="评分" align="center" width="120">
| <template slot-scope="scope">
| <el-select v-if="editing" v-model="scope.row.score" size="small">
| <el-option v-for="s in [0,1,2,3]" :key="s" :label="s" :value="s" />
| </el-select>
| <span v-else>{{ scope.row.score }}</span>
| </template>
| </el-table-column>
| </el-table>
| <div style="margin-top:10px;font-size:14px">PSQI总分:{{ totalScore }} 评价:{{ evaluation }}</div>
| </div>
| </template>
| <script>
| export default {
| name:"PSQIScoreTable",
| props:{ value:{ type:Object, default:()=>({}) }, editing:Boolean },
| computed:{
| items(){
| const names=["主观睡眠质量","入睡时间(分钟)","睡眠时长(小时)","睡眠效率(%)","睡眠障碍","催眠药物使用","日间功能障碍"];
| return names.map((n,i)=>({ item:n, key:'psqi_'+i, score:this.value['psqi_'+i]||0 }));
| },
| totalScore(){ return this.items.reduce((s,i)=>s+i.score,0); },
| evaluation(){ const t=this.totalScore; return t<=5?"睡眠质量良好":t<=10?"睡眠质量一般":t<=15?"睡眠质量较差":"睡眠质量很差"; },
| },
| watch:{
| items:{ deep:true, handler(v){
| const obj={...this.value, psqiTotal:this.totalScore, psqiEvaluation:this.evaluation};
| v.forEach(i=>{ obj[i.key]=i.score; });
| this.$emit('input',obj);
| }},
| },
| };
| </script>
|
|