Add ability to manage account lifting periods and payment terms in admin
This commit is contained in:
parent
1260989d87
commit
fd265ae8bb
|
@ -30,7 +30,9 @@ export function createAccount(data) {
|
||||||
'country': data.address.country,
|
'country': data.address.country,
|
||||||
'postCode': data.address.postCode,
|
'postCode': data.address.postCode,
|
||||||
'fuelRestrictions': data.restrictions.fuels,
|
'fuelRestrictions': data.restrictions.fuels,
|
||||||
'terminalRestrictions': data.restrictions.terminals
|
'terminalRestrictions': data.restrictions.terminals,
|
||||||
|
'paymentTermsRestrictions': data.restrictions.paymentTerms,
|
||||||
|
'liftingPeriodRestrictions': data.restrictions.liftingPeriods
|
||||||
}
|
}
|
||||||
|
|
||||||
return axios.post(`${apiUrl}/account/create`, dto)
|
return axios.post(`${apiUrl}/account/create`, dto)
|
||||||
|
@ -52,7 +54,9 @@ export function updateAccount(data) {
|
||||||
'country': data.address.country,
|
'country': data.address.country,
|
||||||
'postCode': data.address.postCode,
|
'postCode': data.address.postCode,
|
||||||
'fuelRestrictions': data.restrictions.fuels,
|
'fuelRestrictions': data.restrictions.fuels,
|
||||||
'terminalRestrictions': data.restrictions.terminals
|
'terminalRestrictions': data.restrictions.terminals,
|
||||||
|
'paymentTermsRestrictions': data.restrictions.paymentTerms,
|
||||||
|
'liftingPeriodRestrictions': data.restrictions.liftingPeriods
|
||||||
}
|
}
|
||||||
|
|
||||||
return axios.put(`${apiUrl}/account/${data.id}`, dto)
|
return axios.put(`${apiUrl}/account/${data.id}`, dto)
|
||||||
|
|
|
@ -115,6 +115,28 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label-width="120px" label="Lifting Restriction" class="postInfo-container-item">
|
||||||
|
<el-transfer
|
||||||
|
v-model="postForm.restrictions.liftingPeriods"
|
||||||
|
:titles="['Disabled', 'Enabled']"
|
||||||
|
:data="liftingPeriodsAvailable"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label-width="120px" label="Payment Restriction" class="postInfo-container-item">
|
||||||
|
<el-transfer
|
||||||
|
v-model="postForm.restrictions.paymentTerms"
|
||||||
|
:titles="['Disabled', 'Enabled']"
|
||||||
|
:data="paymentTermsAvailable"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label-width="120px" label="Status" class="postInfo-container-item">
|
<el-form-item label-width="120px" label="Status" class="postInfo-container-item">
|
||||||
|
@ -140,6 +162,8 @@ import Sticky from '@/components/Sticky' // 粘性header组件
|
||||||
import { fetchAccount, updateAccount, createAccount } from '@/api/account'
|
import { fetchAccount, updateAccount, createAccount } from '@/api/account'
|
||||||
const fetchFuelList = require('@/api/product').fetchList
|
const fetchFuelList = require('@/api/product').fetchList
|
||||||
const fetchTerminalList = require('@/api/terminal').fetchList
|
const fetchTerminalList = require('@/api/terminal').fetchList
|
||||||
|
const fetchLiftingPeriodsList = require('@/api/liftingPeriod').fetchList
|
||||||
|
const fetchPaymentTermsList = require('@/api/paymentTerm').fetchList
|
||||||
|
|
||||||
const defaultForm = {
|
const defaultForm = {
|
||||||
id: '',
|
id: '',
|
||||||
|
@ -149,7 +173,9 @@ const defaultForm = {
|
||||||
orderConfirmationEmail: '',
|
orderConfirmationEmail: '',
|
||||||
restrictions: {
|
restrictions: {
|
||||||
fuels: [],
|
fuels: [],
|
||||||
terminals: []
|
terminals: [],
|
||||||
|
liftingPeriods: [],
|
||||||
|
paymentTerms: []
|
||||||
},
|
},
|
||||||
address: {
|
address: {
|
||||||
addressLine1: '',
|
addressLine1: '',
|
||||||
|
@ -194,6 +220,8 @@ export default {
|
||||||
tempRoute: {},
|
tempRoute: {},
|
||||||
terminals: [],
|
terminals: [],
|
||||||
fuels: [],
|
fuels: [],
|
||||||
|
paymentTerms: [],
|
||||||
|
liftingPeriods: [],
|
||||||
fuelRestrictions: []
|
fuelRestrictions: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -235,6 +263,32 @@ export default {
|
||||||
set(value) {
|
set(value) {
|
||||||
this.postForm.restrictions.terminals = value
|
this.postForm.restrictions.terminals = value
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
liftingPeriodsAvailable: {
|
||||||
|
get() {
|
||||||
|
return this.liftingPeriods.map(f => {
|
||||||
|
return {
|
||||||
|
label: f.name,
|
||||||
|
key: f._id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.postForm.restrictions.liftingPeriods = value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
paymentTermsAvailable: {
|
||||||
|
get() {
|
||||||
|
return this.paymentTerms.map(f => {
|
||||||
|
return {
|
||||||
|
label: f.name,
|
||||||
|
key: f._id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.postForm.restrictions.paymentTerms = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -246,10 +300,18 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the fuels and terminals, to be used as part of the restriction process
|
// Fetch the fuels and terminals, to be used as part of the restriction process
|
||||||
const requestPromises = [fetchFuelList({ platform: 'OLFDE' }), fetchTerminalList({ platform: 'OLFDE' })]
|
const requestPromises = [
|
||||||
|
fetchFuelList({ platform: 'OLFDE' }),
|
||||||
|
fetchTerminalList({ platform: 'OLFDE' }),
|
||||||
|
fetchLiftingPeriodsList({ platform: 'OLFDE' }),
|
||||||
|
fetchPaymentTermsList({ platform: 'OLFDE' })
|
||||||
|
]
|
||||||
|
|
||||||
Promise.all(requestPromises).then((responses) => {
|
Promise.all(requestPromises).then((responses) => {
|
||||||
this.fuels = responses[0].data.fuels
|
this.fuels = responses[0].data.fuels
|
||||||
this.terminals = responses[1].data.terminals
|
this.terminals = responses[1].data.terminals
|
||||||
|
this.liftingPeriods = responses[2].data.liftingPeriods
|
||||||
|
this.paymentTerms = responses[3].data.paymentTerms
|
||||||
})
|
})
|
||||||
|
|
||||||
// Why need to make a copy of this.$route here?
|
// Why need to make a copy of this.$route here?
|
||||||
|
@ -264,17 +326,28 @@ export default {
|
||||||
if (!account.restrictions) {
|
if (!account.restrictions) {
|
||||||
account.restrictions = {
|
account.restrictions = {
|
||||||
fuels: [],
|
fuels: [],
|
||||||
terminals: []
|
terminals: [],
|
||||||
|
paymentTerms: [],
|
||||||
|
liftingPeriods: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account.restrictions.fuels.length === 0) {
|
if (account.restrictions.fuels.length === 0) {
|
||||||
account.restrictions.fuels = this.fuels.map(f => f._id)
|
account.restrictions.fuels = this.fuels.map(f => f._id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account.restrictions.terminals.length === 0) {
|
if (account.restrictions.terminals.length === 0) {
|
||||||
account.restrictions.terminals = this.terminals.map(f => f._id)
|
account.restrictions.terminals = this.terminals.map(f => f._id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (account.restrictions.paymentTerms != null && account.restrictions.paymentTerms.length === 0) {
|
||||||
|
account.restrictions.paymentTerms = this.paymentTerms.map(f => f._id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account.restrictions.liftingPeriods != null && account.restrictions.liftingPeriods.length === 0) {
|
||||||
|
account.restrictions.liftingPeriods = this.liftingPeriods.map(f => f._id)
|
||||||
|
}
|
||||||
|
|
||||||
this.postForm = account
|
this.postForm = account
|
||||||
|
|
||||||
// // set tagsview title
|
// // set tagsview title
|
||||||
|
@ -303,15 +376,6 @@ export default {
|
||||||
// Make a clone of the object
|
// Make a clone of the object
|
||||||
const accountToSave = Object.assign({}, this.postForm)
|
const accountToSave = Object.assign({}, this.postForm)
|
||||||
|
|
||||||
// If we have selected *all* the fuels/terminals available, then send an empty array back. As this means we want *everything*
|
|
||||||
if (accountToSave.restrictions.fuels.length === this.fuels.length) {
|
|
||||||
accountToSave.restrictions.fuels = []
|
|
||||||
}
|
|
||||||
|
|
||||||
if (accountToSave.restrictions.terminals.length === this.terminals.length) {
|
|
||||||
accountToSave.restrictions.terminals = []
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the account
|
// Save the account
|
||||||
const methodToCall = this.isEdit ? updateAccount : createAccount
|
const methodToCall = this.isEdit ? updateAccount : createAccount
|
||||||
methodToCall(accountToSave).then((r) => {
|
methodToCall(accountToSave).then((r) => {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
<span style="color: green">B: Enabled<br></span>
|
<span style="color: green">B: Enabled<br></span>
|
||||||
|
|
||||||
<span v-if="relationshipMatrix[`${buyerAccounts[scope.$index].id}-${seller.id}`].other" style="color: green">S: Enabled<br></span>
|
<span v-if="relationshipMatrix[`${buyerAccounts[scope.$index].id}-${seller.id}`].other.enabled_spot" style="color: green">S: Enabled<br></span>
|
||||||
<span v-else style="color: red">S: Disabled<br></span>
|
<span v-else style="color: red">S: Disabled<br></span>
|
||||||
</span>
|
</span>
|
||||||
<span v-else style="color: red;">
|
<span v-else style="color: red;">
|
||||||
|
|
Loading…
Reference in New Issue