整理

上级 57cce4a8
......@@ -161,387 +161,389 @@
<script>
import axios from 'axios'
export default {
name: 'MyInterview',
name: 'MyInterview',
data() {
return {
// 用户列表数据
algorithmicList: [],
randomAlgorithmic: {
questionName: '',
leetcodeNumber: '',
leetcodeLink: '',
},
loading: false,
elementui_page_component_key: 0,
currentPage: Number(localStorage.getItem('algorithmLastPage')) || 1,
pageSize: 9,
total: 0,
formInline: {
questionName: '',
},
options: [],
allOptions: [],
questionType: 0,
// 新增的内容
dialogFormVisible: false,
randomFormVisible: false,
dialogMutiFormVisible: false,
form: {
questionName: '',
questionType: 0,
degreeOfImportance: 5,
degreeOfDifficulty: 1,
difficultyOfScore: 1200,
leetcodeNumber: '',
leetcodeLink: '',
},
formLabelWidth: '120px',
dialogVisible: false,
editVisible: false,
currentRowId: null,
colorMap: {}, // 创建一个空的颜色映射关系对象
}
},
watch: {
'formInline.questionName'(newVal) {
if (newVal === '') {
this.currentPage = 1
localStorage.setItem('algorithmLastPage', this.currentPage)
this.getQuestionType()
}
},
// 监听currentPage的变化,将新值保存到localStorage中
currentPage(newPage) {
localStorage.setItem('algorithmLastPage', newPage.toString())
},
},
created() {
//获取问题类型的枚举
this.getQuestionType()
//获取问题类型的枚举
this.getAllQuestionType()
},
mounted() {
// 在页面加载时从localStorage中获取currentPage的值
const storedPage = localStorage.getItem('algorithmLastPage')
if (storedPage) {
this.currentPage = parseInt(storedPage)
}
},
methods: {
prepareAdd() {
this.form.questionName = ''
this.form.questionType = 0
this.dialogFormVisible = true
//获取问题类型的枚举
this.getAllQuestionType()
},
prepareRandom() {
this.randomAlgorithmic = []
this.randomFormVisible = true
this.interviewRandom()
},
prepareMutiAdd() {
this.form.questionName = ''
this.form.questionType = 0
this.dialogMutiFormVisible = true
},
data() {
return {
// 用户列表数据
algorithmicList: [],
randomAlgorithmic: {
questionName: '',
leetcodeNumber: '',
leetcodeLink: '',
},
loading: false,
elementui_page_component_key: 0,
currentPage: Number(localStorage.getItem('algorithmLastPage')) || 1,
pageSize: 9,
total: 0,
formInline: {
questionName: '',
},
options: [],
allOptions: [],
questionType: 0,
// 新增的内容
dialogFormVisible: false,
randomFormVisible: false,
dialogMutiFormVisible: false,
form: {
questionName: '',
questionType: 0,
degreeOfImportance: 5,
degreeOfDifficulty: 1,
difficultyOfScore: 1200,
leetcodeNumber: '',
leetcodeLink: '',
},
formLabelWidth: '120px',
dialogVisible: false,
editVisible: false,
currentRowId: null,
colorMap: {}, // 创建一个空的颜色映射关系对象
}
},
watch: {
'formInline.questionName'(newVal) {
if (newVal === '') {
this.currentPage = 1
localStorage.setItem('algorithmLastPage', this.currentPage)
this.getQuestionType()
}
},
// 监听currentPage的变化,将新值保存到localStorage中
currentPage(newPage) {
localStorage.setItem('algorithmLastPage', newPage.toString())
},
},
created() {
//获取问题类型的枚举
this.getQuestionType()
//获取问题类型的枚举
this.getAllQuestionType()
},
mounted() {
this.currentPage = 1
// // 在页面加载时从localStorage中获取currentPage的值
// const storedPage = localStorage.getItem('algorithmLastPage')
// if (storedPage) {
// this.currentPage = parseInt(storedPage)
// }
},
methods: {
prepareAdd() {
this.form.questionName = ''
this.form.questionType = 0
this.dialogFormVisible = true
//获取问题类型的枚举
this.getAllQuestionType()
},
prepareRandom() {
this.randomAlgorithmic = []
this.randomFormVisible = true
this.interviewRandom()
},
prepareMutiAdd() {
this.form.questionName = ''
this.form.questionType = 0
this.dialogMutiFormVisible = true
},
prepareDelete(id) {
this.currentRowId = id
this.dialogVisible = true
},
preEdit(id, questionName, questionTypeName, degreeOfImportance, degreeOfDifficulty, difficultyOfScore, leetcodeNumber, leetcodeLink) {
this.form.questionName = questionName
this.form.degreeOfImportance = degreeOfImportance
this.form.degreeOfDifficulty = degreeOfDifficulty
this.form.difficultyOfScore = difficultyOfScore
this.form.leetcodeNumber = leetcodeNumber
this.form.leetcodeLink = leetcodeLink
prepareDelete(id) {
this.currentRowId = id
this.dialogVisible = true
},
preEdit(id, questionName, questionTypeName, degreeOfImportance, degreeOfDifficulty, difficultyOfScore, leetcodeNumber, leetcodeLink) {
this.form.questionName = questionName
this.form.degreeOfImportance = degreeOfImportance
this.form.degreeOfDifficulty = degreeOfDifficulty
this.form.difficultyOfScore = difficultyOfScore
this.form.leetcodeNumber = leetcodeNumber
this.form.leetcodeLink = leetcodeLink
// 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {}
this.options.forEach((option) => {
questionTypeToNameMap[option.name] = option.questionType
})
this.form.questionType = questionTypeToNameMap[questionTypeName]
this.currentRowId = id
this.editVisible = true
},
handleClose(done) {
this.$confirm('确认关闭?')
.then((_) => {
done()
})
.catch((_) => {})
},
handleConfirm(addType) {
this.dialogFormVisible = false // 关闭对话框
this.dialogMutiFormVisible = false
this.addQuestion(addType) // 发送请求
},
// 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {}
this.options.forEach((option) => {
questionTypeToNameMap[option.name] = option.questionType
})
this.form.questionType = questionTypeToNameMap[questionTypeName]
this.currentRowId = id
this.editVisible = true
},
handleClose(done) {
this.$confirm('确认关闭?')
.then((_) => {
done()
})
.catch((_) => {})
},
handleConfirm(addType) {
this.dialogFormVisible = false // 关闭对话框
this.dialogMutiFormVisible = false
this.addQuestion(addType) // 发送请求
},
async addQuestion(addType) {
try {
this.loading = true
const { data: res } = await axios.post('http://120.79.36.53:8888/algorithmicProblem/add', {
addType: addType,
questionName: this.form.questionName,
questionType: this.form.questionType,
degreeOfImportance: this.form.degreeOfImportance,
degreeOfDifficulty: this.form.degreeOfDifficulty,
difficultyOfScore: this.form.difficultyOfScore,
leetcodeNumber: this.form.leetcodeNumber,
leetcodeLink: this.form.leetcodeLink,
})
if (res.code === 200) {
this.form.questionName = ''
this.form.questionType = 0
this.form.degreeOfImportance = 5
this.form.degreeOfDifficulty = 1
this.form.difficultyOfScore = 1200
this.form.leetcodeNumber = ''
this.form.leetcodeLink = ''
this.getQuestionType()
} else {
console.error('Received non-200 status code', res)
this.errorMsg(res.message)
}
} catch (error) {
console.error('An error occurred while adding the questionName:', error)
// 异常处理逻辑
} finally {
this.loading = false
}
},
errorMsg(msg) {
this.$message({
showClose: true,
message: msg,
type: 'error',
})
},
async editConfirm() {
try {
this.loading = true
const { data: res } = await axios.post('http://120.79.36.53:8888/algorithmicProblem/update', {
id: this.currentRowId,
questionName: this.form.questionName,
questionType: this.form.questionType,
degreeOfImportance: this.form.degreeOfImportance,
degreeOfDifficulty: this.form.degreeOfDifficulty,
difficultyOfScore: this.form.difficultyOfScore,
leetcodeNumber: this.form.leetcodeNumber,
leetcodeLink: this.form.leetcodeLink,
})
if (res.code === 200) {
this.form.questionName = ''
this.form.questionType = 0
this.editVisible = false
currentRowId: null
this.getQuestionType()
} else {
console.error('Received non-200 status code', res)
}
} catch (error) {
console.error('An error occurred while adding the questionName:', error)
// 异常处理逻辑
} finally {
this.loading = false
}
},
async addQuestion(addType) {
try {
this.loading = true
const { data: res } = await axios.post('http://120.79.36.53:8888/algorithmicProblem/add', {
addType: addType,
questionName: this.form.questionName,
questionType: this.form.questionType,
degreeOfImportance: this.form.degreeOfImportance,
degreeOfDifficulty: this.form.degreeOfDifficulty,
difficultyOfScore: this.form.difficultyOfScore,
leetcodeNumber: this.form.leetcodeNumber,
leetcodeLink: this.form.leetcodeLink,
})
if (res.code === 200) {
this.currentPage = 1
this.form.questionName = ''
this.form.questionType = 0
this.form.degreeOfImportance = 5
this.form.degreeOfDifficulty = 1
this.form.difficultyOfScore = 1200
this.form.leetcodeNumber = ''
this.form.leetcodeLink = ''
this.getQuestionType()
} else {
console.error('Received non-200 status code', res)
this.errorMsg(res.message)
}
} catch (error) {
console.error('An error occurred while adding the questionName:', error)
// 异常处理逻辑
} finally {
this.loading = false
}
},
errorMsg(msg) {
this.$message({
showClose: true,
message: msg,
type: 'error',
})
},
async editConfirm() {
try {
this.loading = true
const { data: res } = await axios.post('http://120.79.36.53:8888/algorithmicProblem/update', {
id: this.currentRowId,
questionName: this.form.questionName,
questionType: this.form.questionType,
degreeOfImportance: this.form.degreeOfImportance,
degreeOfDifficulty: this.form.degreeOfDifficulty,
difficultyOfScore: this.form.difficultyOfScore,
leetcodeNumber: this.form.leetcodeNumber,
leetcodeLink: this.form.leetcodeLink,
})
if (res.code === 200) {
this.form.questionName = ''
this.form.questionType = 0
this.editVisible = false
currentRowId: null
this.getQuestionType()
} else {
console.error('Received non-200 status code', res)
}
} catch (error) {
console.error('An error occurred while adding the questionName:', error)
// 异常处理逻辑
} finally {
this.loading = false
}
},
async onDelete(id) {
this.dialogVisible = false
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/delete', {
params: {
id: id,
},
})
this.getQuestionType()
this.loading = false
},
refreshPage() {
//获取问题类型的枚举
this.getQuestionType()
location.reload()
},
async onDelete(id) {
this.dialogVisible = false
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/delete', {
params: {
id: id,
},
})
this.getQuestionType()
this.loading = false
},
refreshPage() {
//获取问题类型的枚举
this.getQuestionType()
location.reload()
},
async getQuestionType() {
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/questionType', { params: {} })
if (res.code === 200) {
this.options = res.result
console.log(this.options)
//获取问题列表
this.interviewPage()
}
},
async getQuestionType() {
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/questionType', { params: {} })
if (res.code === 200) {
this.options = res.result
console.log(this.options)
//获取问题列表
this.interviewPage()
}
},
async getAllQuestionType() {
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/allQuestionType', { params: {} })
if (res.code === 200) {
this.allOptions = res.result
}
},
async getAllQuestionType() {
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/allQuestionType', { params: {} })
if (res.code === 200) {
this.allOptions = res.result
}
},
async interviewPage() {
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/page', {
params: {
page: this.currentPage,
pageSize: this.pageSize,
questionName: this.formInline.questionName,
questionType: this.questionType,
},
})
if (res.code === 200) {
this.total = res.result.totalElements
// 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {}
this.options.forEach((option) => {
questionTypeToNameMap[option.questionType] = option.name
})
// 修改 algorithmicList 中的每一个元素,将 questionType 转换为 name
res.result.content.forEach((item) => {
item.questionTypeName = questionTypeToNameMap[item.questionType]
})
this.algorithmicList = res.result.content
}
this.loading = false
},
async interviewRandom() {
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/random', { params: {} })
if (res.code === 200) {
this.randomAlgorithmic.questionName = res.result.questionName
this.randomAlgorithmic.leetcodeNumber = res.result.leetcodeNumber
this.randomAlgorithmic.leetcodeLink = res.result.leetcodeLink
}
this.loading = false
},
handleCurrentChange(currentPage) {
this.currentPage = currentPage
this.getQuestionType()
},
getColorForValue(value) {
// 检查颜色映射关系中是否已经有该值对应的颜色
if (!this.colorMap[value]) {
// 如果没有,随机生成一个颜色并将其关联到该值
this.colorMap[value] = this.getRandomColor()
}
// 返回值对应的颜色
return this.colorMap[value]
},
getRandomColor() {
// 从颜色数组中随机选取一个颜色
const colorArray = [
'red',
'blue',
'green',
'yellow',
'purple',
'orange',
'pink',
'brown',
'cyan',
'magenta',
'maroon',
'navy',
'olive',
'teal',
'lime',
'aqua',
'silver',
'gray',
'white',
'indigo',
'violet',
'lavender',
'coral',
'gold',
'salmon',
'turquoise',
'orchid',
'khaki',
'slategray',
'thistle',
'burlywood',
'cadetblue',
'chartreuse',
'chocolate',
'crimson',
'darkblue',
'darkcyan',
'darkgoldenrod',
'darkgray',
'darkgreen',
'darkkhaki',
'darkmagenta',
'darkolivegreen',
'darkorange',
'darkorchid',
'darkred',
'darksalmon',
'darkseagreen',
'darkslateblue',
'darkslategray',
'darkturquoise',
'darkviolet',
'deeppink',
'deepskyblue',
'dodgerblue',
'firebrick',
'forestgreen',
'fuchsia',
'gold',
'greenyellow',
'hotpink',
'indianred',
'lawngreen',
'lightcoral',
'lightgreen',
'lightpink',
'lightsalmon',
'lightseagreen',
'lightskyblue',
'lightslategray',
'lightsteelblue',
'mediumaquamarine',
'mediumblue',
'mediumorchid',
'mediumpurple',
'mediumseagreen',
'mediumslateblue',
'mediumspringgreen',
'mediumturquoise',
'mediumvioletred',
'midnightblue',
'orangered',
'palegoldenrod',
'palegreen',
'paleturquoise',
'palevioletred',
'peru',
'powderblue',
'rosybrown',
'saddlebrown',
'seagreen',
'sienna',
'skyblue',
'slateblue',
'springgreen',
'tan',
'thistle',
'tomato',
'turquoise',
'violet',
]
const randomIndex = Math.floor(Math.random() * colorArray.length)
return colorArray[randomIndex]
},
},
async interviewPage() {
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/page', {
params: {
page: this.currentPage,
pageSize: this.pageSize,
questionName: this.formInline.questionName,
questionType: this.questionType,
},
})
if (res.code === 200) {
this.total = res.result.totalElements
// 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {}
this.options.forEach((option) => {
questionTypeToNameMap[option.questionType] = option.name
})
// 修改 algorithmicList 中的每一个元素,将 questionType 转换为 name
res.result.content.forEach((item) => {
item.questionTypeName = questionTypeToNameMap[item.questionType]
})
this.algorithmicList = res.result.content
}
this.loading = false
},
async interviewRandom() {
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/algorithmicProblem/random', { params: {} })
if (res.code === 200) {
this.randomAlgorithmic.questionName = res.result.questionName
this.randomAlgorithmic.leetcodeNumber = res.result.leetcodeNumber
this.randomAlgorithmic.leetcodeLink = res.result.leetcodeLink
}
this.loading = false
},
handleCurrentChange(currentPage) {
this.currentPage = currentPage
this.getQuestionType()
},
getColorForValue(value) {
// 检查颜色映射关系中是否已经有该值对应的颜色
if (!this.colorMap[value]) {
// 如果没有,随机生成一个颜色并将其关联到该值
this.colorMap[value] = this.getRandomColor()
}
// 返回值对应的颜色
return this.colorMap[value]
},
getRandomColor() {
// 从颜色数组中随机选取一个颜色
const colorArray = [
'red',
'blue',
'green',
'yellow',
'purple',
'orange',
'pink',
'brown',
'cyan',
'magenta',
'maroon',
'navy',
'olive',
'teal',
'lime',
'aqua',
'silver',
'gray',
'white',
'indigo',
'violet',
'lavender',
'coral',
'gold',
'salmon',
'turquoise',
'orchid',
'khaki',
'slategray',
'thistle',
'burlywood',
'cadetblue',
'chartreuse',
'chocolate',
'crimson',
'darkblue',
'darkcyan',
'darkgoldenrod',
'darkgray',
'darkgreen',
'darkkhaki',
'darkmagenta',
'darkolivegreen',
'darkorange',
'darkorchid',
'darkred',
'darksalmon',
'darkseagreen',
'darkslateblue',
'darkslategray',
'darkturquoise',
'darkviolet',
'deeppink',
'deepskyblue',
'dodgerblue',
'firebrick',
'forestgreen',
'fuchsia',
'gold',
'greenyellow',
'hotpink',
'indianred',
'lawngreen',
'lightcoral',
'lightgreen',
'lightpink',
'lightsalmon',
'lightseagreen',
'lightskyblue',
'lightslategray',
'lightsteelblue',
'mediumaquamarine',
'mediumblue',
'mediumorchid',
'mediumpurple',
'mediumseagreen',
'mediumslateblue',
'mediumspringgreen',
'mediumturquoise',
'mediumvioletred',
'midnightblue',
'orangered',
'palegoldenrod',
'palegreen',
'paleturquoise',
'palevioletred',
'peru',
'powderblue',
'rosybrown',
'saddlebrown',
'seagreen',
'sienna',
'skyblue',
'slateblue',
'springgreen',
'tan',
'thistle',
'tomato',
'turquoise',
'violet',
]
const randomIndex = Math.floor(Math.random() * colorArray.length)
return colorArray[randomIndex]
},
},
}
</script>
......
......@@ -144,11 +144,12 @@ export default {
this.interviewPage()
},
mounted() {
// 在页面加载时从localStorage中获取currentPage的值
const storedPage = localStorage.getItem('poetryLastPage')
if (storedPage) {
this.currentPage = parseInt(storedPage)
}
this.currentPage = 1
// // 在页面加载时从localStorage中获取currentPage的值
// const storedPage = localStorage.getItem('poetryLastPage')
// if (storedPage) {
// this.currentPage = parseInt(storedPage)
// }
},
methods: {
prepareAdd() {
......@@ -203,6 +204,8 @@ export default {
})
if (res.code === 200) {
this.form.poetryText = ''
this.currentPage=1
this.interviewPage()
} else {
console.error('Received non-200 status code', res)
this.errorMsg(res.message)
......
......@@ -105,330 +105,332 @@
<script>
import axios from 'axios'
export default {
name: 'MyInterview',
name: 'MyInterview',
data() {
return {
// 用户列表数据
userlist: [],
loading: false,
elementui_page_component_key: 0,
currentPage: Number(localStorage.getItem('interviewLastPage')) || 1,
pageSize: 9,
total: 0,
formInline: {
question: '',
},
options: [],
questionType: 0,
// 新增的内容
dialogFormVisible: false,
dialogMutiFormVisible: false,
form: {
question: '',
questionType: 0,
},
formLabelWidth: '120px',
dialogVisible: false,
editVisible: false,
currentRowId: null,
colorMap: {}, // 创建一个空的颜色映射关系对象
}
},
watch: {
'formInline.question'(newVal) {
if (newVal === '') {
this.currentPage = 1
localStorage.setItem('interviewLastPage', this.currentPage)
this.getQuestionType()
}
},
// 监听currentPage的变化,将新值保存到localStorage中
currentPage(newPage) {
localStorage.setItem('interviewLastPage', newPage.toString())
},
},
created() {
//获取问题列表
this.getQuestionType()
},
mounted() {
// 在页面加载时从localStorage中获取currentPage的值
const storedPage = localStorage.getItem('interviewLastPage')
if (storedPage) {
this.currentPage = parseInt(storedPage)
}
},
methods: {
prepareAdd() {
this.form.question = ''
this.form.questionType = 0
this.dialogFormVisible = true
},
prepareMutiAdd() {
this.form.question = ''
this.form.questionType = 0
this.dialogMutiFormVisible = true
},
data() {
return {
// 用户列表数据
userlist: [],
loading: false,
elementui_page_component_key: 0,
currentPage: Number(localStorage.getItem('interviewLastPage')) || 1,
pageSize: 9,
total: 0,
formInline: {
question: '',
},
options: [],
questionType: 0,
// 新增的内容
dialogFormVisible: false,
dialogMutiFormVisible: false,
form: {
question: '',
questionType: 0,
},
formLabelWidth: '120px',
dialogVisible: false,
editVisible: false,
currentRowId: null,
colorMap: {}, // 创建一个空的颜色映射关系对象
}
},
watch: {
'formInline.question'(newVal) {
if (newVal === '') {
this.currentPage = 1
localStorage.setItem('interviewLastPage', this.currentPage)
this.getQuestionType()
}
},
// 监听currentPage的变化,将新值保存到localStorage中
currentPage(newPage) {
localStorage.setItem('interviewLastPage', newPage.toString())
},
},
created() {
//获取问题列表
this.getQuestionType()
},
mounted() {
this.currentPage = 1
// // 在页面加载时从localStorage中获取currentPage的值
// const storedPage = localStorage.getItem('interviewLastPage')
// if (storedPage) {
// this.currentPage = parseInt(storedPage)
// }
},
methods: {
prepareAdd() {
this.form.question = ''
this.form.questionType = 0
this.dialogFormVisible = true
},
prepareMutiAdd() {
this.form.question = ''
this.form.questionType = 0
this.dialogMutiFormVisible = true
},
prepareDelete(id) {
this.currentRowId = id
this.dialogVisible = true
},
preEdit(id, question, questionTypeName) {
this.form.question = question
prepareDelete(id) {
this.currentRowId = id
this.dialogVisible = true
},
preEdit(id, question, questionTypeName) {
this.form.question = question
// 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {}
this.options.forEach((option) => {
questionTypeToNameMap[option.name] = option.questionType
})
this.form.questionType = questionTypeToNameMap[questionTypeName]
this.currentRowId = id
this.editVisible = true
},
handleClose(done) {
this.$confirm('确认关闭?')
.then((_) => {
done()
})
.catch((_) => {})
},
handleConfirm(addType) {
this.dialogFormVisible = false // 关闭对话框
this.dialogMutiFormVisible = false
this.addQuestion(addType) // 发送请求
},
// 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {}
this.options.forEach((option) => {
questionTypeToNameMap[option.name] = option.questionType
})
this.form.questionType = questionTypeToNameMap[questionTypeName]
this.currentRowId = id
this.editVisible = true
},
handleClose(done) {
this.$confirm('确认关闭?')
.then((_) => {
done()
})
.catch((_) => {})
},
handleConfirm(addType) {
this.dialogFormVisible = false // 关闭对话框
this.dialogMutiFormVisible = false
this.addQuestion(addType) // 发送请求
},
async addQuestion(addType) {
try {
this.loading = true
async addQuestion(addType) {
try {
this.loading = true
const { data: res } = await axios.post('http://120.79.36.53:8888/interviewQuestion/add', {
addType: addType,
question: this.form.question,
questionType: this.form.questionType,
})
if (res.code === 200) {
this.form.question = ''
this.form.questionType = 0
this.getQuestionType() // 确保这个方法是有效的
} else {
console.error('Received non-200 status code', res)
this.errorMsg(res.message)
}
} catch (error) {
console.error('An error occurred while adding the question:', error)
// 异常处理逻辑
} finally {
this.loading = false
}
},
errorMsg(msg) {
this.$message({
showClose: true,
message: msg,
type: 'error',
})
},
async editConfirm() {
try {
this.loading = true
const { data: res } = await axios.post('http://120.79.36.53:8888/interviewQuestion/add', {
addType: addType,
question: this.form.question,
questionType: this.form.questionType,
})
if (res.code === 200) {
this.currentPage = 1
this.form.question = ''
this.form.questionType = 0
this.getQuestionType() // 确保这个方法是有效的
} else {
console.error('Received non-200 status code', res)
this.errorMsg(res.message)
}
} catch (error) {
console.error('An error occurred while adding the question:', error)
// 异常处理逻辑
} finally {
this.loading = false
}
},
errorMsg(msg) {
this.$message({
showClose: true,
message: msg,
type: 'error',
})
},
async editConfirm() {
try {
this.loading = true
const { data: res } = await axios.post('http://120.79.36.53:8888/interviewQuestion/update', {
id: this.currentRowId,
question: this.form.question,
questionType: this.form.questionType,
})
if (res.code === 200) {
this.form.question = ''
this.form.questionType = 0
this.editVisible = false
currentRowId: null
this.getQuestionType() // 确保这个方法是有效的
} else {
console.error('Received non-200 status code', res)
}
} catch (error) {
console.error('An error occurred while adding the question:', error)
// 异常处理逻辑
} finally {
this.loading = false
}
},
const { data: res } = await axios.post('http://120.79.36.53:8888/interviewQuestion/update', {
id: this.currentRowId,
question: this.form.question,
questionType: this.form.questionType,
})
if (res.code === 200) {
this.form.question = ''
this.form.questionType = 0
this.editVisible = false
currentRowId: null
this.getQuestionType() // 确保这个方法是有效的
} else {
console.error('Received non-200 status code', res)
}
} catch (error) {
console.error('An error occurred while adding the question:', error)
// 异常处理逻辑
} finally {
this.loading = false
}
},
async onDelete(id) {
this.dialogVisible = false
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/interviewQuestion/delete', {
params: {
id: id,
},
})
this.getQuestionType()
this.loading = false
},
async onDelete(id) {
this.dialogVisible = false
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/interviewQuestion/delete', {
params: {
id: id,
},
})
this.getQuestionType()
this.loading = false
},
refreshPage() {
//获取问题类型的枚举
this.getQuestionType()
location.reload()
},
refreshPage() {
//获取问题类型的枚举
this.getQuestionType()
location.reload()
},
async getQuestionType() {
const { data: res } = await axios.get('http://120.79.36.53:8888/interviewQuestion/questionType', { params: {} })
if (res.code === 200) {
this.options = res.result
this.interviewPage()
}
},
async getQuestionType() {
const { data: res } = await axios.get('http://120.79.36.53:8888/interviewQuestion/questionType', { params: {} })
if (res.code === 200) {
this.options = res.result
this.interviewPage()
}
},
async interviewPage() {
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/interviewQuestion/page', {
params: {
page: this.currentPage,
pageSize: this.pageSize,
question: this.formInline.question,
questionType: this.questionType,
},
})
if (res.code === 200) {
this.total = res.result.totalElements
// 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {}
this.options.forEach((option) => {
questionTypeToNameMap[option.questionType] = option.name
})
// 修改 userlist 中的每一个元素,将 questionType 转换为 name
res.result.content.forEach((user) => {
user.questionTypeName = questionTypeToNameMap[user.questionType] || 'Unknown'
})
this.userlist = res.result.content
}
this.loading = false
},
handleCurrentChange(currentPage) {
this.currentPage = currentPage
this.getQuestionType()
},
getColorForValue(value) {
// 检查颜色映射关系中是否已经有该值对应的颜色
if (!this.colorMap[value]) {
// 如果没有,随机生成一个颜色并将其关联到该值
this.colorMap[value] = this.getRandomColor()
}
// 返回值对应的颜色
return this.colorMap[value]
},
getRandomColor() {
// 从颜色数组中随机选取一个颜色
const colorArray = [
'red',
'blue',
'green',
'yellow',
'purple',
'orange',
'pink',
'brown',
'cyan',
'magenta',
'maroon',
'navy',
'olive',
'teal',
'lime',
'aqua',
'silver',
'gray',
'white',
'indigo',
'violet',
'lavender',
'coral',
'gold',
'salmon',
'turquoise',
'orchid',
'khaki',
'slategray',
'thistle',
'burlywood',
'cadetblue',
'chartreuse',
'chocolate',
'crimson',
'darkblue',
'darkcyan',
'darkgoldenrod',
'darkgray',
'darkgreen',
'darkkhaki',
'darkmagenta',
'darkolivegreen',
'darkorange',
'darkorchid',
'darkred',
'darksalmon',
'darkseagreen',
'darkslateblue',
'darkslategray',
'darkturquoise',
'darkviolet',
'deeppink',
'deepskyblue',
'dodgerblue',
'firebrick',
'forestgreen',
'fuchsia',
'gold',
'greenyellow',
'hotpink',
'indianred',
'lawngreen',
'lightcoral',
'lightgreen',
'lightpink',
'lightsalmon',
'lightseagreen',
'lightskyblue',
'lightslategray',
'lightsteelblue',
'mediumaquamarine',
'mediumblue',
'mediumorchid',
'mediumpurple',
'mediumseagreen',
'mediumslateblue',
'mediumspringgreen',
'mediumturquoise',
'mediumvioletred',
'midnightblue',
'orangered',
'palegoldenrod',
'palegreen',
'paleturquoise',
'palevioletred',
'peru',
'powderblue',
'rosybrown',
'saddlebrown',
'seagreen',
'sienna',
'skyblue',
'slateblue',
'springgreen',
'tan',
'thistle',
'tomato',
'turquoise',
'violet',
]
const randomIndex = Math.floor(Math.random() * colorArray.length)
return colorArray[randomIndex]
},
},
async interviewPage() {
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/interviewQuestion/page', {
params: {
page: this.currentPage,
pageSize: this.pageSize,
question: this.formInline.question,
questionType: this.questionType,
},
})
if (res.code === 200) {
this.total = res.result.totalElements
// 定义一个映射(map)来存储 questionType 到 name 的转换
const questionTypeToNameMap = {}
this.options.forEach((option) => {
questionTypeToNameMap[option.questionType] = option.name
})
// 修改 userlist 中的每一个元素,将 questionType 转换为 name
res.result.content.forEach((user) => {
user.questionTypeName = questionTypeToNameMap[user.questionType] || 'Unknown'
})
this.userlist = res.result.content
}
this.loading = false
},
handleCurrentChange(currentPage) {
this.currentPage = currentPage
this.getQuestionType()
},
getColorForValue(value) {
// 检查颜色映射关系中是否已经有该值对应的颜色
if (!this.colorMap[value]) {
// 如果没有,随机生成一个颜色并将其关联到该值
this.colorMap[value] = this.getRandomColor()
}
// 返回值对应的颜色
return this.colorMap[value]
},
getRandomColor() {
// 从颜色数组中随机选取一个颜色
const colorArray = [
'red',
'blue',
'green',
'yellow',
'purple',
'orange',
'pink',
'brown',
'cyan',
'magenta',
'maroon',
'navy',
'olive',
'teal',
'lime',
'aqua',
'silver',
'gray',
'white',
'indigo',
'violet',
'lavender',
'coral',
'gold',
'salmon',
'turquoise',
'orchid',
'khaki',
'slategray',
'thistle',
'burlywood',
'cadetblue',
'chartreuse',
'chocolate',
'crimson',
'darkblue',
'darkcyan',
'darkgoldenrod',
'darkgray',
'darkgreen',
'darkkhaki',
'darkmagenta',
'darkolivegreen',
'darkorange',
'darkorchid',
'darkred',
'darksalmon',
'darkseagreen',
'darkslateblue',
'darkslategray',
'darkturquoise',
'darkviolet',
'deeppink',
'deepskyblue',
'dodgerblue',
'firebrick',
'forestgreen',
'fuchsia',
'gold',
'greenyellow',
'hotpink',
'indianred',
'lawngreen',
'lightcoral',
'lightgreen',
'lightpink',
'lightsalmon',
'lightseagreen',
'lightskyblue',
'lightslategray',
'lightsteelblue',
'mediumaquamarine',
'mediumblue',
'mediumorchid',
'mediumpurple',
'mediumseagreen',
'mediumslateblue',
'mediumspringgreen',
'mediumturquoise',
'mediumvioletred',
'midnightblue',
'orangered',
'palegoldenrod',
'palegreen',
'paleturquoise',
'palevioletred',
'peru',
'powderblue',
'rosybrown',
'saddlebrown',
'seagreen',
'sienna',
'skyblue',
'slateblue',
'springgreen',
'tan',
'thistle',
'tomato',
'turquoise',
'violet',
]
const randomIndex = Math.floor(Math.random() * colorArray.length)
return colorArray[randomIndex]
},
},
}
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册