接收response后更新Token
parent
a07b43605b
commit
65794e3e46
|
@ -47,11 +47,11 @@
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="重要程度" prop="projectImportance">
|
<el-form-item label="重要程度" prop="projectImportance">
|
||||||
<el-select v-model="ruleForm.projectImportance" placeholder="请选择">
|
<el-select v-model="ruleForm.projectImportance" placeholder="请选择">
|
||||||
<el-option label="极其重要" value="极其重要"></el-option>
|
<el-option label="A" value="A"></el-option>
|
||||||
<el-option label="很重要" value="很重要"></el-option>
|
<el-option label="B" value="B"></el-option>
|
||||||
<el-option label="较为重要" value="较为重要"></el-option>
|
<el-option label="C" value="C"></el-option>
|
||||||
<el-option label="不太重要" value="不太重要"></el-option>
|
<el-option label="D" value="D"></el-option>
|
||||||
<el-option label="不重要" value="不重要"></el-option>
|
<el-option label="E" value="E"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -352,39 +352,33 @@ export default {
|
||||||
},
|
},
|
||||||
//提交方法
|
//提交方法
|
||||||
submitForm(formName) {
|
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) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
console.log('submit')
|
console.log('submit')
|
||||||
ElMessage({
|
let form = this.ruleForm
|
||||||
message: 'submit',
|
form.projectFinalTestTime = form.projectFinalTestTime.getTime() / 1000
|
||||||
type: 'success',
|
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 {
|
} else {
|
||||||
console.log('error submit!!')
|
console.log('error submit!!')
|
||||||
|
|
|
@ -10,6 +10,9 @@ const store = createStore({
|
||||||
setStaff(state, staff) {
|
setStaff(state, staff) {
|
||||||
state.staff = staff
|
state.staff = staff
|
||||||
},
|
},
|
||||||
|
updateToken(state, Token) {
|
||||||
|
state.staff.Token = Token
|
||||||
|
},
|
||||||
clearStaff(state) {
|
clearStaff(state) {
|
||||||
state.staff = null
|
state.staff = null
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,10 @@ request.interceptors.response.use(
|
||||||
function (response) {
|
function (response) {
|
||||||
// 2xx 范围内的状态码都会触发该函数。
|
// 2xx 范围内的状态码都会触发该函数。
|
||||||
console.log("SUCCESS")
|
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
|
return response
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
console.log("ERROR")
|
console.log("ERROR")
|
||||||
|
|
Loading…
Reference in New Issue