提交 8f451560 编写于 作者: 檀越@新空间's avatar 檀越@新空间 🐭

整理

上级 b8328147
...@@ -105,238 +105,242 @@ ...@@ -105,238 +105,242 @@
<script> <script>
import axios from 'axios' import axios from 'axios'
export default { export default {
name: 'MyInterview', name: 'MyInterview',
data() { data() {
return { return {
// 用户列表数据 // 用户列表数据
userlist: [], userlist: [],
loading: false, loading: false,
elementui_page_component_key: 0, elementui_page_component_key: 0,
currentPage: Number(localStorage.getItem('lastPage')) || 1, currentPage: Number(localStorage.getItem('lastPage')) || 1,
pageSize: 9, pageSize: 9,
total: 0, total: 0,
formInline: { formInline: {
question: '', question: '',
}, },
options: [], options: [],
questionType: 0, questionType: 0,
// 新增的内容 // 新增的内容
dialogFormVisible: false, dialogFormVisible: false,
dialogMutiFormVisible: false, dialogMutiFormVisible: false,
form: { form: {
question: '', question: '',
questionType: 0, questionType: 0,
}, },
formLabelWidth: '120px', formLabelWidth: '120px',
dialogVisible: false, dialogVisible: false,
editVisible: false, editVisible: false,
currentRowId: null, currentRowId: null,
} }
}, },
watch: { watch: {
'formInline.question'(newVal) { 'formInline.question'(newVal) {
if (newVal === '') { if (newVal === '') {
this.currentPage = 1 this.currentPage = 1
localStorage.setItem('lastPage', this.currentPage) localStorage.setItem('lastPage', this.currentPage)
this.interviewPage() this.interviewPage()
} }
}, },
}, },
mounted() {}, created() {
created() { //获取问题类型的枚举
//获取问题类型的枚举 this.getQuestionType()
this.getQuestionType() //获取问题列表
//获取问题列表 this.interviewPage()
this.interviewPage() },
}, mounted() {},
methods: { methods: {
prepareAdd() { prepareAdd() {
this.form.question = '' this.form.question = ''
this.form.questionType = 0 this.form.questionType = 0
this.dialogFormVisible = true this.dialogFormVisible = true
}, },
prepareMutiAdd() { prepareMutiAdd() {
this.form.question = '' this.form.question = ''
this.form.questionType = 0 this.form.questionType = 0
this.dialogMutiFormVisible = true this.dialogMutiFormVisible = true
}, },
prepareDelete(id) { prepareDelete(id) {
this.currentRowId = id this.currentRowId = id
this.dialogVisible = true this.dialogVisible = true
}, },
preEdit(id, question, questionTypeName) { preEdit(id, question, questionTypeName) {
this.form.question = question this.form.question = question
// 定义一个映射(map)来存储 questionType 到 name 的转换 // 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {} const questionTypeToNameMap = {}
this.options.forEach((option) => { this.options.forEach((option) => {
questionTypeToNameMap[option.name] = option.questionType questionTypeToNameMap[option.name] = option.questionType
}) })
this.form.questionType = questionTypeToNameMap[questionTypeName] this.form.questionType = questionTypeToNameMap[questionTypeName]
this.currentRowId = id this.currentRowId = id
this.editVisible = true this.editVisible = true
}, },
handleClose(done) { handleClose(done) {
this.$confirm('确认关闭?') this.$confirm('确认关闭?')
.then((_) => { .then((_) => {
done() done()
}) })
.catch((_) => {}) .catch((_) => {})
}, },
handleConfirm(addType) { handleConfirm(addType) {
this.dialogFormVisible = false // 关闭对话框 this.dialogFormVisible = false // 关闭对话框
this.dialogMutiFormVisible = false this.dialogMutiFormVisible = false
this.addQuestion(addType) // 发送请求 this.addQuestion(addType) // 发送请求
}, },
async addQuestion(addType) { async addQuestion(addType) {
try { try {
this.loading = true this.loading = true
const { data: res } = await axios.post('http://localhost:8080/interviewQuestion/add', { const { data: res } = await axios.post('http://localhost:8080/interviewQuestion/add', {
addType: addType, addType: addType,
question: this.form.question, question: this.form.question,
questionType: this.form.questionType, questionType: this.form.questionType,
}) })
if (res.code === 200) { if (res.code === 200) {
this.form.question = '' this.form.question = ''
this.form.questionType = 0 this.form.questionType = 0
this.interviewPage() // 确保这个方法是有效的 this.interviewPage() // 确保这个方法是有效的
} else { } else {
console.error('Received non-200 status code', res) console.error('Received non-200 status code', res)
this.errorMsg(res.message) this.errorMsg(res.message)
} }
} catch (error) { } catch (error) {
console.error('An error occurred while adding the question:', error) console.error('An error occurred while adding the question:', error)
// 异常处理逻辑 // 异常处理逻辑
} finally { } finally {
this.loading = false this.loading = false
} }
}, },
errorMsg(msg) { errorMsg(msg) {
this.$message({ this.$message({
showClose: true, showClose: true,
message: msg, message: msg,
type: 'error', type: 'error',
}) })
}, },
async editConfirm() { async editConfirm() {
try { try {
this.loading = true this.loading = true
const { data: res } = await axios.post('http://localhost:8080/interviewQuestion/update', { const { data: res } = await axios.post('http://localhost:8080/interviewQuestion/update', {
id: this.currentRowId, id: this.currentRowId,
question: this.form.question, question: this.form.question,
questionType: this.form.questionType, questionType: this.form.questionType,
}) })
if (res.code === 200) { if (res.code === 200) {
this.form.question = '' this.form.question = ''
this.form.questionType = 0 this.form.questionType = 0
this.editVisible = false this.editVisible = false
currentRowId: null currentRowId: null
this.interviewPage() // 确保这个方法是有效的 this.interviewPage() // 确保这个方法是有效的
} else { } else {
console.error('Received non-200 status code', res) console.error('Received non-200 status code', res)
} }
} catch (error) { } catch (error) {
console.error('An error occurred while adding the question:', error) console.error('An error occurred while adding the question:', error)
// 异常处理逻辑 // 异常处理逻辑
} finally { } finally {
this.loading = false this.loading = false
} }
}, },
async onDelete(id) { async onDelete(id) {
this.dialogVisible = false this.dialogVisible = false
this.loading = true this.loading = true
const { data: res } = await axios.get('http://localhost:8080/interviewQuestion/delete', { const { data: res } = await axios.get('http://localhost:8080/interviewQuestion/delete', {
params: { params: {
id: id, id: id,
}, },
}) })
this.interviewPage() this.interviewPage()
this.loading = false this.loading = false
}, },
refreshPage() { refreshPage() {
//获取问题类型的枚举 //获取问题类型的枚举
this.getQuestionType() this.getQuestionType()
location.reload() location.reload()
}, },
async getQuestionType() { async getQuestionType() {
const { data: res } = await axios.get('http://localhost:8080/interviewQuestion/questionType', { params: {} }) const { data: res } = await axios.get('http://localhost:8080/interviewQuestion/questionType', { params: {} })
if (res.code === 200) { if (res.code === 200) {
this.options = res.result this.options = res.result
} }
}, },
async interviewPage() { async interviewPage() {
this.loading = true this.loading = true
const { data: res } = await axios.get('http://localhost:8080/interviewQuestion/page', { const { data: res } = await axios.get('http://localhost:8080/interviewQuestion/page', {
params: { params: {
page: this.currentPage, page: this.currentPage,
pageSize: this.pageSize, pageSize: this.pageSize,
question: this.formInline.question, question: this.formInline.question,
questionType: this.questionType, questionType: this.questionType,
}, },
}) })
if (res.code === 200) { if (res.code === 200) {
this.total = res.result.totalElements this.total = res.result.totalElements
// 定义一个映射(map)来存储 questionType 到 name 的转换 // 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {} const questionTypeToNameMap = {}
this.options.forEach((option) => { this.options.forEach((option) => {
questionTypeToNameMap[option.questionType] = option.name questionTypeToNameMap[option.questionType] = option.name
}) })
// 修改 userlist 中的每一个元素,将 questionType 转换为 name // 修改 userlist 中的每一个元素,将 questionType 转换为 name
res.result.content.forEach((user) => { res.result.content.forEach((user) => {
user.questionTypeName = questionTypeToNameMap[user.questionType] || 'Unknown' user.questionTypeName = questionTypeToNameMap[user.questionType] || 'Unknown'
}) })
this.userlist = res.result.content this.userlist = res.result.content
} }
this.loading = false this.loading = false
}, },
getClassForValue(value) { getClassForValue(value) {
// 根据值返回相应的类名 // 根据值返回相应的类名
// 您可以根据需要编写逻辑来决定何时使用相同的类名 // 您可以根据需要编写逻辑来决定何时使用相同的类名
// 这里只是一个示例 // 这里只是一个示例
if (value === '基础知识') { if (value === '基础知识') {
return 'reddish-purple-value' return 'reddish-purple-value'
} else if (value === '集合') { } else if (value === '集合') {
return 'new-orange-value' return 'new-orange-value'
} else if (value === 'JVM') { } else if (value === 'JVM') {
return 'clove-tea-value' return 'clove-tea-value'
} else if (value === '并发编程') { } else if (value === '并发编程') {
return 'grassy-value' return 'grassy-value'
} else if (value === 'MySql') { } else if (value === 'MySql') {
return 'daylily-value' return 'daylily-value'
} else if (value === 'Redis') { } else if (value === 'Redis') {
return 'balloon-flower-value' return 'balloon-flower-value'
} else if (value === '中间件') { } else if (value === '中间件') {
return 'pink-value' return 'pink-value'
} else if (value === 'Spring') { } else if (value === 'Spring') {
return 'purple-value' return 'purple-value'
} else if (value === '微服务') { } else if (value === '微服务') {
return 'sapphire-blue-value' return 'sapphire-blue-value'
} else if (value === '分布式') { } else if (value === '分布式') {
return 'green-value' return 'green-value'
} else if (value === '项目') { } else if (value === '项目') {
return 'black-value' return 'black-value'
} else if (value === '算法') { } else if (value === '算法') {
return 'rose-hermosa-value' return 'rose-hermosa-value'
} else if (value === '其他') { } else if (value === '反问环节') {
return 'magenta-value' return 'white-dress-value'
} else { } else if (value === '设计模式') {
return 'dark-blue-value' return 'prunus-gracilis-value'
} } else if (value === '其他') {
}, return 'magenta-value'
} else {
return 'dark-blue-value'
}
},
handleCurrentChange(currentPage) { handleCurrentChange(currentPage) {
this.currentPage = currentPage this.currentPage = currentPage
this.interviewPage() this.interviewPage()
}, },
}, },
} }
</script> </script>
...@@ -425,6 +429,12 @@ export default { ...@@ -425,6 +429,12 @@ export default {
.rose-hermosa-value { .rose-hermosa-value {
color: #ff6fd8; /* 不同值的颜色 */ color: #ff6fd8; /* 不同值的颜色 */
} }
.white-dress-value {
color: #83ccd2; /* 不同值的颜色 */
}
.prunus-gracilis-value {
color: #5a79ba; /* 不同值的颜色 */
}
.custom-textarea { .custom-textarea {
width: 100%; width: 100%;
text-align: left; text-align: left;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册