未验证 提交 c414e03d 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k 提交者: GitHub

Merge pull request #6 from catouse/master

* fix create/edit form in modal not work sometimes.
......@@ -103,7 +103,13 @@ import {
export default {
name: 'ConfigEdit',
props: {
afterSave: Function
afterSave: Function,
id: {
type: [Number, String],
default: function() {
return this.$route.params.id;
}
},
},
data() {
return {
......@@ -130,31 +136,39 @@ export default {
],
},
id: 0,
model: { folder: 'yaml/'},
dirs: [],
workDir: '',
};
},
computed: {
},
created () {
this.id = parseInt(this.$route.params.id)
console.log(this.id)
this.loadData()
watch: {
id: function(newId, oldId) {
if (newId == oldId) {
return;
}
this.loadData();
}
},
mounted () {
this.loadData();
},
methods: {
loadData () {
getConfig(this.id).then(json => {
console.log('getConfig', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
let id = this.id;
if (id === null) {
return;
}
if (id) {
if (typeof id === 'string') id = Number.parseInt(id);
getConfig(id).then(json => {
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
} else {
this.reset();
}
},
save() {
console.log('save')
......@@ -176,6 +190,7 @@ export default {
},
reset() {
console.log('reset')
this.model = {folder: 'yaml/'};
this.$refs.editForm.reset()
},
}
......
......@@ -51,7 +51,13 @@ import {
export default {
name: 'TestEdit',
props: {
afterSave: Function
afterSave: Function,
id: {
type: [Number, String],
default: function() {
return this.$route.params.id;
}
},
},
data() {
return {
......@@ -75,33 +81,39 @@ export default {
],
},
id: 0,
model: { folder: 'data/'},
dirs: [],
workDir: '',
};
},
computed: {
},
created () {
this.id = parseInt(this.$route.params.id)
console.log(this.id)
this.loadData()
watch: {
id: function(newId, oldId) {
if (newId == oldId) {
return;
}
this.loadData();
}
},
mounted () {
this.loadData();
},
methods: {
loadData () {
if (!this.id) return
getExcel(this.id).then(json => {
console.log('getText', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
let id = this.id;
if (id === null) {
return;
}
if (id) {
if (typeof id === 'string') id = Number.parseInt(id);
getExcel(id).then(json => {
console.log('getText', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
} else {
this.reset();
}
},
save() {
console.log('save')
......@@ -123,6 +135,7 @@ export default {
},
reset() {
console.log('reset')
this.model = {folder: 'data/'};
this.$refs.editForm.reset()
},
}
......
......@@ -63,7 +63,13 @@ import {
export default {
name: 'RangesEdit',
props: {
afterSave: Function
afterSave: Function,
id: {
type: [Number, String],
default: function() {
return this.$route.params.id;
}
},
},
data() {
return {
......@@ -87,33 +93,39 @@ export default {
],
},
id: 0,
model: {folder: 'yaml/'},
dirs: [],
workDir: '',
};
},
computed: {
},
created () {
this.id = parseInt(this.$route.params.id)
console.log(this.id)
this.loadData()
watch: {
id: function(newId, oldId) {
if (newId == oldId) {
return;
}
this.loadData();
}
},
mounted () {
this.loadData();
},
methods: {
loadData () {
if (!this.id) return
getInstances(this.id).then(json => {
console.log('getInstances', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
let id = this.id;
if (id === null) {
return;
}
if (id) {
if (typeof id === 'string') id = Number.parseInt(id);
getInstances(id).then(json => {
console.log('getInstances', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
} else {
this.reset();
}
},
save() {
console.log('save')
......@@ -135,6 +147,7 @@ export default {
},
reset() {
console.log('reset')
this.model = {folder: 'yaml/'};
this.$refs.editForm.reset()
},
}
......
......@@ -65,7 +65,13 @@ import {
export default {
name: 'RangesEdit',
props: {
afterSave: Function
afterSave: Function,
id: {
type: [Number, String],
default: function() {
return this.$route.params.id;
}
},
},
data() {
return {
......@@ -89,33 +95,40 @@ export default {
],
},
id: 0,
model: {folder: 'yaml/'},
dirs: [],
workDir: '',
};
},
computed: {
},
created () {
this.id = parseInt(this.$route.params.id)
console.log(this.id)
this.loadData()
watch: {
id: function(newId, oldId) {
if (newId == oldId) {
return;
}
this.loadData();
}
},
mounted () {
this.loadData();
},
methods: {
loadData () {
if (!this.id) return
getRanges(this.id).then(json => {
console.log('getRanges', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
let id = this.id;
if (id === null) {
return;
}
if (id) {
if (typeof id === 'string') id = Number.parseInt(id);
getRanges(id).then(json => {
console.log('getRanges', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
} else {
this.reset();
}
},
save() {
console.log('save')
......@@ -137,6 +150,7 @@ export default {
},
reset() {
console.log('reset')
this.model = {folder: 'yaml/'};
this.$refs.editForm.reset()
},
}
......
......@@ -47,7 +47,13 @@ import {colsFull, colsHalf, labelColFull, wrapperColFull, labelColHalf, labelCol
export default {
name: 'TestEdit',
props: {
afterSave: Function
afterSave: Function,
id: {
type: [Number, String],
default: function() {
return this.$route.params.id;
}
},
},
data() {
return {
......@@ -71,28 +77,40 @@ export default {
],
},
id: 0,
model: {folder: 'yaml/'},
dirs: [],
workDir: '',
};
},
created () {
this.id = parseInt(this.$route.params.id)
console.log(this.id)
this.loadData()
watch: {
id: function(newId, oldId) {
if (newId == oldId) {
return;
}
this.loadData();
}
},
mounted () {
this.loadData();
},
methods: {
loadData () {
if (!this.id) return
getText(this.id).then(json => {
console.log('getText', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
let id = this.id;
if (id === null) {
return;
}
if (id) {
if (typeof id === 'string') id = Number.parseInt(id);
getText(id).then(json => {
console.log('getText', json)
this.model = json.data
this.dirs = json.res
this.workDir = json.workDir
})
} else {
this.reset();
}
},
save() {
console.log('save')
......@@ -114,6 +132,7 @@ export default {
},
reset() {
console.log('reset')
this.model = {folder: 'yaml/'};
this.$refs.editForm.reset()
},
}
......
......@@ -115,6 +115,7 @@ export default {
})
},
reset () {
this.model = { folder: 'users/', type: 'text' };
this.$refs.editForm.resetFields()
},
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册