Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit aa77d6d

Browse files
authored
Merge pull request #271 from FlowzPlatform/develop
Develop
2 parents 592ec2e + a4f5729 commit aa77d6d

File tree

4 files changed

+123
-76
lines changed

4 files changed

+123
-76
lines changed

client/src/components/addconfig.vue

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
<script>
3232
import asconfigurationModel from '@/api/asconfiguration'
3333
import _ from 'lodash'
34+
import config from '@/config'
35+
import axios from 'axios'
3436
3537
export default {
3638
name: 'addconfig',
@@ -161,18 +163,39 @@ export default {
161163
this.loading = true
162164
let isExist = await (this.checkExist(this.formItem))
163165
if (isExist) {
164-
await asconfigurationModel.post(this.formItem).then(res => {
165-
this.$Notice.success({title: 'Success', desc: 'Successfully saved.', duration: 3})
166-
this.$router.push('/settings')
167-
}).catch(err => {
168-
console.log('Error', err)
166+
let asiauth = await this.asiAuth(this.formItem)
167+
if (asiauth.valid) {
168+
await asconfigurationModel.post(this.formItem).then(res => {
169+
this.$Notice.success({title: 'Success', desc: 'Successfully saved.', duration: 3})
170+
this.$router.push('/settings')
171+
}).catch(err => {
172+
console.log('Error', err)
173+
this.loading = false
174+
this.$Notice.error({title: 'Error', desc: 'Not Saved.', duration: 3})
175+
})
176+
} else {
169177
this.loading = false
170-
this.$Notice.error({title: 'Error', desc: 'Not Saved.', duration: 3})
171-
})
178+
this.$Notice.error({title: 'ASI Error', desc: 'Please Add Authorized Credential.', duration: 5})
179+
}
172180
}
173181
}
174182
})
175183
},
184+
async asiAuth (formItem) {
185+
let mdata = {
186+
asi: formItem.number,
187+
username: formItem.user,
188+
password: formItem.password
189+
}
190+
let res = await axios.post(config.asiUrl + 'Login', mdata).then(res => {
191+
console.log('res=>', res)
192+
return { valid: true }
193+
}).catch(err => {
194+
console.log('ASI Auth Error', err)
195+
return {valid: false, msg: err.message}
196+
})
197+
return res
198+
},
176199
async checkExist (formItem, value) {
177200
let res = await (asconfigurationModel.get({
178201
number: formItem.number,
Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,80 @@
11
<template>
22
<div>
3-
<Row class="expand-row">
4-
<div class="schema-form ivu-table-wrapper">
5-
<div class="ivu-table ivu-table-border">
6-
<div class="ivu-table-body">
7-
<table cellspacing="0" cellpadding="0" border="0" style="width: 100%;">
8-
<colgroup>
9-
<col width="25">
10-
<col width="75">
11-
</colgroup>
12-
<thead>
13-
<tr>
14-
<th class="">
15-
<div class="ivu-table-cell">
16-
<span>SKU</span>
17-
</div>
18-
</th>
19-
<th class="">
20-
<div class="ivu-table-cell">
21-
<span>Error</span>
22-
</div>
23-
</th>
24-
</tr>
25-
</thead>
26-
<tbody class="ivu-table-tbody">
27-
<tr v-if="row.asiError.length > 0" class="ivu-table-row" v-for="(item, index) in row.asiError">
28-
<td class="">
29-
<div class="ivu-table-cell">
30-
<span class="list-color">{{item.sku}}</span>
31-
</div>
32-
</td>
33-
<td class="">
34-
<div class="ivu-table-cell">
35-
<ul class="" v-for="err in item.error">
36-
<li class="list-color">{{err.Reason}}</li>
37-
</ul>
38-
</div>
39-
</td>
40-
</tr>
41-
<tr v-else>
42-
<td style="text-align:center;" colspan="2">No Data</td>
43-
</tr>
44-
</tbody>
45-
</table>
46-
</div>
47-
</div>
48-
</div>
49-
</Row>
3+
<div>
4+
<Table :columns="tcols" :data="calculateData" stripe border class="tableclass"></Table>
5+
</div>
6+
<div style="float:right; padding-top:10px;">
7+
<Page :page-size="5" :total="tdata.length" @on-change="handleChange"></Page>
8+
</div>
509
</div>
5110
</template>
5211

5312
<script>
54-
export default {
55-
props: {
56-
row: Object
57-
},
58-
data () {
59-
return {
60-
}
61-
},
62-
mounted () {
63-
console.log('this.row', this.row)
64-
},
65-
feathers: {
66-
'product-sync': {
67-
created (data) {
13+
import _ from 'lodash'
14+
export default {
15+
props: {
16+
row: Object
17+
},
18+
data () {
19+
return {
20+
tcols: [{
21+
title: 'SKU',
22+
key: 'sku',
23+
className: 'list-color'
24+
}, {
25+
title: 'Error',
26+
key: '',
27+
className: 'list-color',
28+
render: (h, params) => {
29+
// console.log(params.row)
30+
let abc = []
31+
for (let item of params.row.error) {
32+
abc.push(h('li', item.Reason))
6833
}
34+
return h('ul', abc)
6935
}
36+
}],
37+
tdata: [],
38+
mdata: [],
39+
page: 1
40+
}
41+
},
42+
computed: {
43+
calculateData () {
44+
return this.mdata[this.page - 1]
45+
}
46+
},
47+
methods: {
48+
handleChange (page) {
49+
this.page = page
50+
}
51+
},
52+
mounted () {
53+
console.log('this.row', this.row)
54+
if (this.row.asiError !== undefined) {
55+
this.tdata = this.row.asiError
56+
this.mdata = _.chunk(this.tdata, 5)
57+
}
58+
},
59+
feathers: {
60+
'product-sync': {
61+
created (data) {
7062
}
7163
}
64+
}
65+
}
7266
</script>
7367

7468
<style scoped>
7569
.expand-row{
7670
margin-bottom: 16px;
7771
}
78-
.list-color {
72+
73+
</style>
74+
<style>
75+
.list-color {
7976
color: #a94442;
77+
padding: 10px;
78+
background-color: #fff !important;
8079
}
8180
</style>

client/src/components/syncstatus.vue

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ export default {
6060
},
6161
{
6262
title: 'Id',
63-
key: 'id'
63+
key: 'id',
64+
width: 300
6465
// align: 'center'
6566
},
6667
{
@@ -75,7 +76,7 @@ export default {
7576
render: (h, params) => {
7677
let finx = _.findIndex(this.asiconfig, {id: params.row.asiConfig})
7778
if (finx !== -1) {
78-
console.log(finx, this.asiconfig[finx].name)
79+
// console.log(finx, this.asiconfig[finx].name)
7980
return h('div', this.asiconfig[finx].name)
8081
} else {
8182
return h('div', '-')
@@ -98,7 +99,14 @@ export default {
9899
},
99100
{
100101
title: 'Total Records',
101-
key: 'total'
102+
key: 'total',
103+
render: (h, params) => {
104+
if (params.row.total === undefined) {
105+
return h('div', '-')
106+
} else {
107+
return h('div', params.row.total)
108+
}
109+
}
102110
// align: 'center',
103111
// width: 120
104112
},
@@ -185,6 +193,7 @@ export default {
185193
vid: this.vid,
186194
'no-product-process': 0
187195
}).then(resp => {
196+
this.isresync = false
188197
this.$Notice.success({title: 're-sync Started'})
189198
}).catch(err => {
190199
console.log('Error: ', err)
@@ -224,11 +233,20 @@ export default {
224233
}).then(resp => {
225234
// console.log(resp)
226235
this.statusData = _.filter(resp.data.data, {syncOn: 'ASI'})
236+
_.map(this.statusData, (m) => {
237+
if (m.asiStatus !== 'completed') {
238+
m._disableExpand = true
239+
} else {
240+
m._disableExpand = false
241+
}
242+
})
227243
this.loading = false
228244
}).catch(errr => {
229245
this.loading = false
230246
console.log('Error', errr)
231247
})
248+
} else {
249+
this.loading = false
232250
}
233251
}).catch(err => {
234252
this.loading = false
@@ -241,6 +259,7 @@ export default {
241259
created (data) {
242260
console.log('Created ............', data)
243261
if (data.vid === this.vid && data.syncOn === 'ASI') {
262+
data._disableExpand = true
244263
let finx = _.findIndex(this.statusData, {id: data.id})
245264
if (finx === -1) {
246265
this.statusData.splice(0, 0, data)
@@ -250,7 +269,12 @@ export default {
250269
updated (data) {
251270
console.log('Updated..............', data)
252271
if (data.vid === this.vid && data.syncOn === 'ASI') {
253-
console.log('Match')
272+
// console.log('Match')
273+
if (data.asiStatus !== 'completed') {
274+
data._disableExpand = true
275+
} else {
276+
data._disableExpand = false
277+
}
254278
let finx = _.findIndex(this.statusData, {id: data.id})
255279
if (finx !== -1) {
256280
this.statusData.splice(finx, 1, data)

client/src/config/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ var temp = {
3939
crmUrl: 'https://www.crm.' + domainkey,
4040
websiteBuilderUrl: 'https://www.webbuilder.' + domainkey,
4141
cloudinaryUrl: 'https://api.' + domainkey + '/crm/cloudinaryupload',
42-
vshopUrl: 'https://api.flowzcluster.tk/pdmnew/vshop-list?supplier=true&all=1'
42+
vshopUrl: 'https://api.flowzcluster.tk/pdmnew/vshop-list?supplier=true&all=1',
43+
asiUrl: 'https://sandbox-productservice.asicentral.com/api/v4/'
4344
}
4445
if (process.env.MYENV !== 'development') {
4546
temp = {
@@ -71,8 +72,8 @@ if (process.env.MYENV !== 'development') {
7172
crmUrl: 'https://www.crm.' + domainkey,
7273
websiteBuilderUrl: 'https://www.webbuilder.' + domainkey,
7374
cloudinaryUrl: 'https://api.' + domainkey + '/crm/cloudinaryupload',
74-
vshopUrl: 'https://api.' + domainkey + '/pdmnew/vshop-list?supplier=true&all=1'
75-
75+
vshopUrl: 'https://api.' + domainkey + '/pdmnew/vshop-list?supplier=true&all=1',
76+
asiUrl: 'https://sandbox-productservice.asicentral.com/api/v4/'
7677
}
7778
}
7879

0 commit comments

Comments
 (0)