Added payment terms
This commit is contained in:
parent
101408b1da
commit
1260989d87
|
@ -0,0 +1,31 @@
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
const PaymentTermsEndpointUrl = 'https://metadata.service.development.therig.onlinefuelslabs.io'
|
||||||
|
|
||||||
|
export function fetchList(query) {
|
||||||
|
return axios.get(`${PaymentTermsEndpointUrl}/payment-terms`, { params: query })
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchPaymentTerm(id) {
|
||||||
|
return axios.get(`${PaymentTermsEndpointUrl}/payment-terms/${id}?platform=OLFDE`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createPaymentTerm(data) {
|
||||||
|
const dto = {
|
||||||
|
'name': data.name,
|
||||||
|
'days': Number(data.days),
|
||||||
|
'platform': data.platform || 'OLFDE'
|
||||||
|
}
|
||||||
|
|
||||||
|
return axios.post(`${PaymentTermsEndpointUrl}/payment-terms`, dto)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updatePaymentTerm(data) {
|
||||||
|
const dto = {
|
||||||
|
'name': data.name,
|
||||||
|
'days': Number(data.days),
|
||||||
|
'platform': data.platform || 'OLFDE'
|
||||||
|
}
|
||||||
|
|
||||||
|
return axios.put(`${PaymentTermsEndpointUrl}/payment-terms/${data._id}`, dto)
|
||||||
|
}
|
|
@ -298,6 +298,37 @@ export const asyncRoutes = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/payment-terms',
|
||||||
|
component: Layout,
|
||||||
|
redirect: '/payment-terms/list',
|
||||||
|
name: 'PaymentTerms',
|
||||||
|
meta: {
|
||||||
|
title: 'Payment Terms',
|
||||||
|
icon: 'example'
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'create',
|
||||||
|
component: () => import('@/views/paymentterms/create'),
|
||||||
|
name: 'CreatePaymentTerm',
|
||||||
|
meta: { title: 'Create Payment Terms', icon: 'edit' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'edit/:id',
|
||||||
|
component: () => import('@/views/paymentterms/edit'),
|
||||||
|
name: 'EditPaymentTerm',
|
||||||
|
meta: { title: 'Edit Payment Terms', noCache: true, activeMenu: '/paymentterms/list' },
|
||||||
|
hidden: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'list',
|
||||||
|
component: () => import('@/views/paymentterms/list'),
|
||||||
|
name: 'LiftingPaymentTerm',
|
||||||
|
meta: { title: 'Payment Terms List', icon: 'list' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/faqs',
|
path: '/faqs',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
|
|
|
@ -0,0 +1,210 @@
|
||||||
|
<template>
|
||||||
|
<div class="createAccount-container">
|
||||||
|
<el-form ref="postForm" :model="postForm" :rules="rules" class="form-container">
|
||||||
|
|
||||||
|
<sticky :z-index="10" :class-name="'sub-navbar ' + postForm.status">
|
||||||
|
<el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm">
|
||||||
|
Save
|
||||||
|
</el-button>
|
||||||
|
</sticky>
|
||||||
|
|
||||||
|
<div class="createPost-main-container">
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="20">
|
||||||
|
<div class="postInfo-container">
|
||||||
|
<el-row v-if="isEdit">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label-width="120px" label="Id" class="postInfo-container-item">
|
||||||
|
<el-input v-model="postForm._id" placeholder="Id" readonly />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label-width="120px" label="Name" class="postInfo-container-item">
|
||||||
|
<el-input v-model="postForm.name" placeholder="Lifting Period Name" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label-width="120px" label="Days" class="postInfo-container-item">
|
||||||
|
<el-input v-model="postForm.days" placeholder="Lifting Period Days" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Sticky from '@/components/Sticky' // 粘性header组件
|
||||||
|
import { fetchPaymentTerm, updatePaymentTerm, createPaymentTerm } from '@/api/paymentTerm'
|
||||||
|
|
||||||
|
const defaultForm = {
|
||||||
|
id: '',
|
||||||
|
name: '',
|
||||||
|
days: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'AccountDetail',
|
||||||
|
components: { Sticky },
|
||||||
|
props: {
|
||||||
|
isEdit: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
const validateRequire = (rule, value, callback) => {
|
||||||
|
if (value === '') {
|
||||||
|
this.$message({
|
||||||
|
message: rule.field + 'Epic Success brudda',
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
callback(new Error(rule.field + ' ERRRR'))
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
postForm: Object.assign({}, defaultForm),
|
||||||
|
loading: false,
|
||||||
|
userListOptions: [],
|
||||||
|
rules: {
|
||||||
|
// image_uri: [{ validator: validateRequire }],
|
||||||
|
name: [{ validator: validateRequire }]
|
||||||
|
// content: [{ validator: validateRequire }],
|
||||||
|
// source_uri: [{ validator: validateSourceUri, trigger: 'blur' }]
|
||||||
|
},
|
||||||
|
tempRoute: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
displayTime: {
|
||||||
|
// set and get is useful when the data
|
||||||
|
// returned by the back end api is different from the front end
|
||||||
|
// back end return => "2013-06-25 06:59:25"
|
||||||
|
// front end need timestamp => 1372114765000
|
||||||
|
get() {
|
||||||
|
return (+new Date(this.postForm.display_time))
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.postForm.display_time = new Date(val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
if (this.isEdit) {
|
||||||
|
const id = this.$route.params && this.$route.params.id
|
||||||
|
this.fetchData(id)
|
||||||
|
} else {
|
||||||
|
this.postForm = Object.assign({}, defaultForm)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Why need to make a copy of this.$route here?
|
||||||
|
// Because if you enter this page and quickly switch tag, may be in the execution of the setTagsViewTitle function, this.$route is no longer pointing to the current page
|
||||||
|
// https://github.com/PanJiaChen/vue-element-admin/issues/1221
|
||||||
|
this.tempRoute = Object.assign({}, this.$route)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchData(id) {
|
||||||
|
fetchPaymentTerm(id).then(response => {
|
||||||
|
this.postForm = response.data.paymentTerms
|
||||||
|
|
||||||
|
// // set tagsview title
|
||||||
|
this.setTagsViewTitle()
|
||||||
|
|
||||||
|
// // set page title
|
||||||
|
this.setPageTitle()
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
setTagsViewTitle() {
|
||||||
|
const title = 'Edit Payment Terms'
|
||||||
|
const route = Object.assign({}, this.tempRoute, { title: `${title} - ${this.postForm.name}` })
|
||||||
|
this.$store.dispatch('tagsView/updateVisitedView', route)
|
||||||
|
},
|
||||||
|
setPageTitle() {
|
||||||
|
const title = 'Edit Payment Terms'
|
||||||
|
document.title = `${title} - ${this.postForm.name}`
|
||||||
|
},
|
||||||
|
submitForm() {
|
||||||
|
this.$refs.postForm.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.loading = true
|
||||||
|
|
||||||
|
// Save the account
|
||||||
|
const methodToCall = this.isEdit ? updatePaymentTerm : createPaymentTerm
|
||||||
|
methodToCall(this.postForm).then((r) => {
|
||||||
|
this.$notify({
|
||||||
|
title: 'Success',
|
||||||
|
message: 'Payment Terms Saved',
|
||||||
|
type: 'success',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
|
||||||
|
// Redirect to the edit page when we create a new one
|
||||||
|
if (!this.isEdit) { this.$router.push(`/payment-terms/edit/${r.data.createdPaymentTerms._id}`) }
|
||||||
|
|
||||||
|
this.loading = false
|
||||||
|
}).catch((e) => {
|
||||||
|
console.dir(e)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('error submit!!')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import "~@/styles/mixin.scss";
|
||||||
|
|
||||||
|
.createPost-container {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.createPost-main-container {
|
||||||
|
padding: 40px 45px 20px 50px;
|
||||||
|
|
||||||
|
.postInfo-container {
|
||||||
|
position: relative;
|
||||||
|
@include clearfix;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
|
||||||
|
.postInfo-container-item {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.word-counter {
|
||||||
|
width: 40px;
|
||||||
|
position: absolute;
|
||||||
|
right: 10px;
|
||||||
|
top: 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-textarea /deep/ {
|
||||||
|
textarea {
|
||||||
|
padding-right: 40px;
|
||||||
|
resize: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0px;
|
||||||
|
border-bottom: 1px solid #bfcbd9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<template>
|
||||||
|
<payment-terms-details :is-edit="false" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import PaymentTermsDetails from './components/PaymentTermsDetails'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'CreateForm',
|
||||||
|
components: { PaymentTermsDetails }
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<template>
|
||||||
|
<payment-terms-details :is-edit="true" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import PaymentTermsDetails from './components/PaymentTermsDetails'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'EditForm',
|
||||||
|
components: { PaymentTermsDetails }
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
|
||||||
|
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
|
||||||
|
<el-table-column align="center" label="Name" width="200">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.name }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column align="center" label="Name" width="200">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.days }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column align="center" label="Actions" width="120">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<router-link :to="'/payment-terms/edit/' + scope.row._id">
|
||||||
|
<el-button type="primary" size="small" icon="el-icon-edit">
|
||||||
|
Edit
|
||||||
|
</el-button>
|
||||||
|
</router-link>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { fetchList } from '@/api/paymentTerm'
|
||||||
|
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'PaymentTermsList',
|
||||||
|
components: { Pagination },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
list: null,
|
||||||
|
total: 0,
|
||||||
|
listLoading: true,
|
||||||
|
listQuery: {
|
||||||
|
page: 1,
|
||||||
|
limit: 20
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// Set the type for the query
|
||||||
|
this.listQuery.platform = 'OLFDE'
|
||||||
|
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getList() {
|
||||||
|
this.listLoading = true
|
||||||
|
fetchList(this.listQuery).then(response => {
|
||||||
|
this.list = response.data.paymentTerms
|
||||||
|
this.total = response.data.paymentTerms.length
|
||||||
|
this.listLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.edit-input {
|
||||||
|
padding-right: 100px;
|
||||||
|
}
|
||||||
|
.cancel-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 15px;
|
||||||
|
top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in New Issue