finished form

This commit is contained in:
Mike 2019-09-19 11:37:29 +01:00
parent d82422b723
commit 5953709816
2 changed files with 12 additions and 26 deletions

View File

@ -2,6 +2,10 @@ import axios from 'axios'
const apiUrl = 'https://localhost:3000' const apiUrl = 'https://localhost:3000'
// export function fetchList(query) {
// return axios.get(`${apiUrl}/fuels`, { params: query })
// }
export function fetchActiveSymbol() { export function fetchActiveSymbol() {
return axios.get(`${apiUrl}/symbol/future/active/`) return axios.get(`${apiUrl}/symbol/future/active/`)
} }

View File

@ -63,7 +63,7 @@
<script> <script>
/* eslint-disable */ /* eslint-disable */
import Sticky from '@/components/Sticky' // header import Sticky from '@/components/Sticky' // header
// import { fetchActiveSymbol, createActiveSymbol } from '@/api/active-symbol' import { fetchActiveSymbol, createActiveSymbol } from '@/api/active-symbol'
const defaultForm = { const defaultForm = {
type: '', type: '',
@ -136,19 +136,9 @@ export default {
}, },
methods: { methods: {
fetchData(id) { fetchData(id) {
fetchProduct(id).then(response => { fetchActiveSymbol(id).then(response => {
const product = response.data const activeSymbol = response.data
this.postForm = activeSymbol
if (!product.meta) {
product.meta = {
ebv: '',
category: '',
seasonality: '',
price: ''
}
}
this.postForm = product
// // set tagsview title // // set tagsview title
this.setTagsViewTitle() this.setTagsViewTitle()
@ -159,15 +149,7 @@ export default {
console.log(err) console.log(err)
}) })
}, },
setTagsViewTitle() {
const title = 'Edit Product'
const route = Object.assign({}, this.tempRoute, { title: `${title} - ${this.postForm.name}` })
this.$store.dispatch('tagsView/updateVisitedView', route)
},
setPageTitle() {
const title = 'Edit Product'
document.title = `${title} - ${this.postForm.id}`
},
submitForm() { submitForm() {
this.$refs.postForm.validate(valid => { this.$refs.postForm.validate(valid => {
if (valid) { if (valid) {
@ -178,17 +160,17 @@ export default {
this.postForm.type === 'EX-RACK' this.postForm.type === 'EX-RACK'
} }
// Save the account // Save the account
const methodToCall = this.isEdit ? updateProduct : createProduct const methodToCall = this.isEdit ? updateActiveSymbol : createActiveSymbol
methodToCall(this.postForm).then((r) => { methodToCall(this.postForm).then((r) => {
this.$notify({ this.$notify({
title: 'Success', title: 'Success',
message: 'Product Saved', message: 'Ice Pricing Saved',
type: 'success', type: 'success',
duration: 2000 duration: 2000
}) })
// Redirect to the edit page when we create a new one // Redirect to the edit page when we create a new one
if (!this.isEdit) { this.$router.push(`/products/edit/${r.data.createdFuel._id}`) } // if (!this.isEdit) { this.$router.push(`/products/edit/${r.data.createdFuel._id}`) }
this.loading = false this.loading = false
}).catch((e) => { }).catch((e) => {