Skip to content

Commit

Permalink
nqm-target
Browse files Browse the repository at this point in the history
  • Loading branch information
CApopsicle committed Mar 21, 2017
1 parent b5d0124 commit fb4c4c8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 52 deletions.
16 changes: 7 additions & 9 deletions src/containers/nqm-target/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,11 @@ module.exports = {
: this.$refs.createTargetGroupTags.labelData.map((label, idx) => {
return label.name
}),
},
targetHeaders: {
headers: this.targetHeaders,
params : this.targetParams
}
})
.then(() => {
this.getTargets()
})
},
editTargetInfo(e) {
const { currentTargetInfo } = this.$store.state.nqmTarget
Expand All @@ -202,13 +201,12 @@ module.exports = {
editTarget: {
targetId: this.currentTargetId,
data
},
targetHeaders: {
headers: this.targetHeaders,
params : this.targetParams
}
})
this.currentTargetId = -1
.then(() => {
this.getTargets()
this.currentTargetId = -1
})
},
selectIsp(data) {
if (data.value) {
Expand Down
92 changes: 49 additions & 43 deletions src/store/nqm-target/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,28 @@ module.exports = {
})
},

'createTarget'({ commit, state, dispatch }, n) {
const opts = {
method: 'POST',
url: 'http://localhost:6040/api/v1/nqm/target',
data: {
...n.createTarget
'createTarget'({ commit, state }, n) {
return new Promise((resolve, reject) => {
const opts = {
method: 'POST',
url: 'http://localhost:6040/api/v1/nqm/target',
data: {
...n.createTarget
}
}
}

fetch(opts)
.then((res) => {
commit('createTarget.success', {
data: res.data
fetch(opts)
.then((res) => {
commit('createTarget.success', {
data: res.data
})
resolve()
})
dispatch('getTargets', n.targetHeaders)
})
.catch((err) => {
commit('createTarget.fail', {
err
.catch((err) => {
commit('createTarget.fail', {
err
})
reject()
})
})
},
Expand Down Expand Up @@ -151,34 +154,37 @@ module.exports = {
})
},

'editTarget'({ commit, state, dispatch }, n) {
const data = {
status: 1,
name: null,
comment: null,
isp_id: -1,
province_id: -1,
city_id: -1,
name_tag: null,
group_tag: [],
...n.editTarget.data
}
const opts = {
method: 'PUT',
url: `http://localhost:6040/api/v1/nqm/target/${n.editTarget.targetId}`,
data,
}
debugger
fetch(opts)
.then((res) => {
commit('editAgent.success', {
data: res.data
'editTarget'({ commit, state }, n) {
return new Promise((resolve, reject) => {
const data = {
status: 1,
name: null,
comment: null,
isp_id: -1,
province_id: -1,
city_id: -1,
name_tag: null,
group_tag: [],
...n.editTarget.data
}
const opts = {
method: 'PUT',
url: `http://localhost:6040/api/v1/nqm/target/${n.editTarget.targetId}`,
data,
}

fetch(opts)
.then((res) => {
commit('editAgent.success', {
data: res.data
})
resolve()
})
dispatch('getTargets', n.targetHeaders)
})
.catch((err) => {
commit('editAgent.fail', {
err
.catch((err) => {
commit('editAgent.fail', {
err
})
reject()
})
})
}
Expand Down

0 comments on commit fb4c4c8

Please sign in to comment.