接收response后更新Token

main
wuyize 2022-07-01 21:18:46 +08:00
parent a07b43605b
commit 65794e3e46
3 changed files with 33 additions and 33 deletions

View File

@ -47,11 +47,11 @@
<el-col :span="6">
<el-form-item label="重要程度" prop="projectImportance">
<el-select v-model="ruleForm.projectImportance" placeholder="请选择">
<el-option label="极其重要" value="极其重要"></el-option>
<el-option label="很重要" value="很重要"></el-option>
<el-option label="较为重要" value="较为重要"></el-option>
<el-option label="不太重要" value="不太重要"></el-option>
<el-option label="不重要" value="不重要"></el-option>
<el-option label="A" value="A"></el-option>
<el-option label="B" value="B"></el-option>
<el-option label="C" value="C"></el-option>
<el-option label="D" value="D"></el-option>
<el-option label="E" value="E"></el-option>
</el-select>
</el-form-item>
</el-col>
@ -352,39 +352,33 @@ export default {
},
//
submitForm(formName) {
console.log(this.projectClasses)
let form = this.ruleForm
form.projectFinalTestTime = form.projectFinalTestTime.getTime() / 1000
form.projectEndTime = form.projectEndTime.getTime() / 1000
form.projectFirstTestTime = form.projectFirstTestTime.getTime() / 1000
form.projectOnlineTime = form.projectOnlineTime.getTime() / 1000
form.projectStartTime = form.projectStartTime.getTime() / 1000
request({
url: 'project/create',
method: 'post',
data: form
}).then(response => {
console.log(response)
if (response.data.code === 200) {
//console.log(response.data.data.records)
ElMessage({
message: '成功',
type: 'success',
})
}
}).catch(function (error) {
console.log(error)
})
//
this.$refs[formName].validate((valid) => {
if (valid) {
console.log('submit')
ElMessage({
message: 'submit',
type: 'success',
let form = this.ruleForm
form.projectFinalTestTime = form.projectFinalTestTime.getTime() / 1000
form.projectEndTime = form.projectEndTime.getTime() / 1000
form.projectFirstTestTime = form.projectFirstTestTime.getTime() / 1000
form.projectOnlineTime = form.projectOnlineTime.getTime() / 1000
form.projectStartTime = form.projectStartTime.getTime() / 1000
request({
url: 'project',
method: 'post',
data: form
}).then(response => {
console.log(response)
if (response.data.code === 200) {
//console.log(response.data.data.records)
ElMessage({
message: '新增项目成功',
type: 'success',
})
}
}).catch(function (error) {
console.log(error)
})
//
} else {
console.log('error submit!!')

View File

@ -10,6 +10,9 @@ const store = createStore({
setStaff(state, staff) {
state.staff = staff
},
updateToken(state, Token) {
state.staff.Token = Token
},
clearStaff(state) {
state.staff = null
},

View File

@ -22,7 +22,10 @@ request.interceptors.response.use(
function (response) {
// 2xx 范围内的状态码都会触发该函数。
console.log("SUCCESS")
//let staff = store.state.staff
//staff.Token = response.config.headers.Token
//console.log(response)
store.commit('updateToken', response.config.headers.token)
return response
}, function (error) {
console.log("ERROR")