Interview.vue
5.54 KB
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
<template>
<p class="sub_back" @click="handleBack"><返回</p>
<p class="sub_title">{{readonly?'心理咨询':'个案辅导'}}</p>
<el-card class="account-container interview">
<div class="control">
<p class="control_name">访谈记录</p>
<el-button type="primary" @click="addInterviewRecord" v-if="!isEdit&&!readonly">保存</el-button>
</div>
<el-form :model="form" :rules="rules" ref="formRef" v-if="!readonly">
<el-form-item label="学生记录:" prop="studentInterviewRecord">
<el-input type="textarea" :autosize="{ minRows: 4}" v-model="form.studentInterviewRecord"></el-input>
</el-form-item>
<div class="btn_box">
<el-button type="primary" @click="editStudent" v-if="isEdit">保存</el-button>
</div>
<el-form-item label="家长记录:" prop="parentInterviewRecord">
<el-input type="textarea" :autosize="{ minRows: 4}" v-model="form.parentInterviewRecord"></el-input>
</el-form-item>
<div class="btn_box">
<el-button type="primary" @click="editParent" v-if="isEdit">保存</el-button>
</div>
<el-form-item label="班主任记录:" prop="teacherInterviewRecord">
<el-input type="textarea" :autosize="{ minRows: 4}" v-model="form.teacherInterviewRecord"></el-input>
</el-form-item>
<div class="btn_box">
<el-button type="primary" @click="editTeacher" v-if="isEdit">保存</el-button>
</div>
</el-form>
<div v-else>
<p class="title">学生记录:</p>
<p>{{form.studentInterviewRecord?form.studentInterviewRecord:'暂无'}}</p>
<p class="title">家长记录:</p>
<p>{{form.parentInterviewRecord?form.parentInterviewRecord:'暂无'}}</p>
<p class="title">老师记录:</p>
<p>{{form.teacherInterviewRecord?form.teacherInterviewRecord:'暂无'}}</p>
</div>
</el-card>
</template>
<script>
import { onMounted, reactive, ref, toRefs } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useStore } from 'vuex'
import { ElMessage } from 'element-plus'
import axios from '@/utils/axios'
export default {
name: 'Interview',
setup () {
const formRef = ref(null)
const route = useRoute()
const router = useRouter()
const store = useStore()
const { detailId, readonly } = route.query
const state = reactive({
isEdit: false,//新增或者修改的状态
form: {
id: '0',
studentInterviewRecord: '',
parentInterviewRecord: '',
teacherInterviewRecord: '',
},
UserId: store.state.userInfo?.userId,
rules: {
},
})
onMounted(() => {
getInterviewRecord()
})
// 访谈记录
const getInterviewRecord = () => {
state.loading = true
axios.get(`/Counse/InterviewRecord?userId=${state.UserId}&detailId=${detailId}`).then(res => {
// console.log('访谈记录:', res)
if (res) {
state.isEdit = true
state.form = res
}
}).catch(err => {
console.log('err', err)
})
}
// 新增
const addInterviewRecord = () => {
axios.post('/Counse/InterviewRecord', {
"Id": 0,
"DetailId": detailId,
"UserId": state.UserId,
"StudentInterviewRecord": state.form.studentInterviewRecord,
"ParentInterviewRecord": state.form.parentInterviewRecord,
"TeacherInterviewRecord": state.form.teacherInterviewRecord
}).then(() => {
ElMessage.success('保存成功')
getInterviewRecord()
})
}
// 修改学生
const editStudent = () => {
axios.put('/Counse/StudentInterviewRecord', {
"Id": state.form.id,
"DetailId": detailId,
"UserId": state.UserId,
"StudentInterviewRecord": state.form.studentInterviewRecord,
"ParentInterviewRecord": state.form.parentInterviewRecord,
"TeacherInterviewRecord": state.form.teacherInterviewRecord
}).then(() => {
ElMessage.success('保存成功')
})
}
// 修改家长
const editParent = () => {
axios.put('/Counse/ParentInterviewRecord', {
"Id": state.form.id,
"DetailId": detailId,
"UserId": state.UserId,
"StudentInterviewRecord": state.form.studentInterviewRecord,
"ParentInterviewRecord": state.form.parentInterviewRecord,
"TeacherInterviewRecord": state.form.teacherInterviewRecord
}).then(() => {
ElMessage.success('保存成功')
})
}
// 修改老师
const editTeacher = () => {
axios.put('/Counse/TeacherInterviewRecord', {
"Id": state.form.id,
"DetailId": detailId,
"UserId": state.UserId,
"StudentInterviewRecord": state.form.studentInterviewRecord,
"ParentInterviewRecord": state.form.parentInterviewRecord,
"TeacherInterviewRecord": state.form.teacherInterviewRecord
}).then(() => {
ElMessage.success('保存成功')
})
}
const handleBack = () => {
router.back()
}
return {
...toRefs(state),
formRef,
handleBack,
addInterviewRecord,
editStudent,
editParent,
editTeacher,
readonly
}
}
}
</script>
<style lang="scss" scoped>
.control {
display: flex;
align-items: center;
justify-content: space-between;
.control_name {
font-size: 23px;
font-weight: bold;
}
}
.interview {
background: #fff;
padding: 0 20px;
padding-bottom: 40px;
}
.btn_box {
width: 100%;
margin-bottom: 40px;
display: flex;
flex-direction: row-reverse;
}
.title {
font-weight: bold;
margin-top: 40px;
}
</style>