实现表单异步提交并显示消息
This commit is contained in:
46
src/main/resources/static/js/admin.js
Normal file
46
src/main/resources/static/js/admin.js
Normal file
@@ -0,0 +1,46 @@
|
||||
var Main = {
|
||||
data() {
|
||||
return {
|
||||
activeIndex: '1',
|
||||
formInline: {
|
||||
user: '',
|
||||
region: ''
|
||||
},
|
||||
form: {
|
||||
name: '',
|
||||
region: '',
|
||||
date1: '',
|
||||
date2: '',
|
||||
delivery: false,
|
||||
type: [],
|
||||
resource: '',
|
||||
desc: ''
|
||||
},
|
||||
feedbackData:[
|
||||
{
|
||||
content:'bug',
|
||||
time:'2018-2-3',
|
||||
username:'root'
|
||||
}
|
||||
],
|
||||
logData:[
|
||||
{
|
||||
ip:'127.0.0.1',
|
||||
header:'bug',
|
||||
time:'2018-2-3',
|
||||
username:'root'
|
||||
}
|
||||
],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSelect(key, keyPath) {
|
||||
console.log(key, keyPath);
|
||||
},
|
||||
onSubmit() {
|
||||
console.log('submit!');
|
||||
}
|
||||
}
|
||||
}
|
||||
var Ctor = Vue.extend(Main)
|
||||
new Ctor().$mount('#app')
|
||||
@@ -160,16 +160,50 @@ var Main = {
|
||||
|
||||
},
|
||||
methods: {
|
||||
openNotiSuccess(title,content) {
|
||||
this.$notify({
|
||||
title: title,
|
||||
message: content,
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
openSuccess(content) {
|
||||
this.$message({
|
||||
message: content,
|
||||
type: 'success'
|
||||
});
|
||||
},
|
||||
uploadURL(row){
|
||||
return "http://localhost:8080/cms/moreUpload?courseName="+row.coursename+"&folder="+row.workfolder;
|
||||
},
|
||||
limitTime(row){
|
||||
return DateDiff(row.worktime.replace(/([^\s]+)\s.*/, "$1"), cur);
|
||||
},
|
||||
submitForm(formName) {
|
||||
submitForm(formName,url) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
alert('submit!');
|
||||
axios({
|
||||
url: 'http://localhost:8080/cms/'+url,
|
||||
method: 'post',
|
||||
data: {
|
||||
content: this.$refs.content.value
|
||||
},
|
||||
transformRequest: [function (data) {
|
||||
// Do whatever you want to transform the data
|
||||
let ret = ''
|
||||
for (let it in data) {
|
||||
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
|
||||
}
|
||||
return ret
|
||||
}],
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
})
|
||||
console.log(this.$refs.content.value)
|
||||
this.openSuccess("成功","反馈成功!")
|
||||
//this.$options.methods.openNotiSuccess.bind(this)();
|
||||
//alert('submit!');
|
||||
} else {
|
||||
console.log('error submit!!');
|
||||
return false;
|
||||
@@ -189,7 +223,7 @@ var Main = {
|
||||
console.log(file, fileList);
|
||||
},
|
||||
ClickToJump(targe){
|
||||
window.open("http://localhost:8080/cms/" + targe);
|
||||
window.location.href="http://localhost:8080/cms/" + targe;
|
||||
},
|
||||
handleDownload(row) {
|
||||
/*var url = window.location.protocol+"://"+window.location.host+":"+window.location.port+"/"*/
|
||||
|
||||
Reference in New Issue
Block a user