mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 12:01:57 +08:00
Support for image loading at the point of sale (#868)
* Support for image loading at the point of sale * minimal changes * rename variables * change defaul * remove comment Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
parent
e6a9315390
commit
88acb270dc
@ -9,7 +9,7 @@
|
|||||||
"timeout": 10000
|
"timeout": 10000
|
||||||
},
|
},
|
||||||
"images": {
|
"images": {
|
||||||
"url": "https://api.erpya.com/api/adempiere/"
|
"url": "https://api.erpya.com/adempiere-api/img/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -47,27 +47,19 @@
|
|||||||
<el-col :key="key" :span="size">
|
<el-col :key="key" :span="size">
|
||||||
<el-card
|
<el-card
|
||||||
:body-style="{ padding: '0px' }"
|
:body-style="{ padding: '0px' }"
|
||||||
:data="getImage(keyValue.resourceReference)"
|
|
||||||
shadow="always"
|
shadow="always"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
<p style="padding-left: 10px; font-size: 12px; color: #0e2ea4">
|
<p style="padding-left: 10px; font-size: 12px; color: #0e2ea4">
|
||||||
<b>{{ keyValue.name }}</b>
|
<b>{{ keyValue.name }}</b>
|
||||||
</p>
|
</p>
|
||||||
<!--
|
|
||||||
<b style="padding-left: 10px; font-size: 10px; color: #359e43">
|
|
||||||
Available
|
|
||||||
</b>
|
|
||||||
-->
|
|
||||||
</span>
|
</span>
|
||||||
<div @click="setKeyActionToOrderLine(keyValue)">
|
<div @click="setKeyActionToOrderLine(keyValue)">
|
||||||
<el-image
|
<el-image
|
||||||
v-if="getDefaultImage(keyValue)"
|
|
||||||
:src="getImageFromSource(keyValue)"
|
:src="getImageFromSource(keyValue)"
|
||||||
class="key-layout"
|
class="key-layout"
|
||||||
fit="contain"
|
fit="contain"
|
||||||
/>
|
/>
|
||||||
<vue-content-loading v-else :width="300" :height="300" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="footer-product">
|
<div class="footer-product">
|
||||||
<p class="quantity">
|
<p class="quantity">
|
||||||
@ -101,16 +93,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import VueContentLoading from '@/components/ADempiere/ContentLoader'
|
import { getImagePath } from '@/utils/ADempiere/resource.js'
|
||||||
import { requestImage } from '@/api/ADempiere/common/resource.js'
|
|
||||||
import { buildImageFromArrayBuffer } from '@/utils/ADempiere/resource.js'
|
|
||||||
import { formatQuantity } from '@/utils/ADempiere/valueFormat.js'
|
import { formatQuantity } from '@/utils/ADempiere/valueFormat.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'KeyLayout',
|
name: 'KeyLayout',
|
||||||
components: {
|
|
||||||
VueContentLoading
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
resource: {},
|
resource: {},
|
||||||
@ -119,7 +105,8 @@ export default {
|
|||||||
identifier: 'undefined',
|
identifier: 'undefined',
|
||||||
value: '',
|
value: '',
|
||||||
isLoaded: true
|
isLoaded: true
|
||||||
}]
|
}],
|
||||||
|
hola: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -133,7 +120,16 @@ export default {
|
|||||||
return this.$store.getters.getKeyLayout
|
return this.$store.getters.getKeyLayout
|
||||||
},
|
},
|
||||||
getKeyList() {
|
getKeyList() {
|
||||||
return this.getKeyLayout.keysList
|
const keylist = this.getKeyLayout.keysList
|
||||||
|
if (!this.isEmptyValue) {
|
||||||
|
return keylist.map(item => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
isLoaded: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return keylist
|
||||||
},
|
},
|
||||||
getLayoutHeader() {
|
getLayoutHeader() {
|
||||||
const keyLayout = this.getKeyLayout
|
const keyLayout = this.getKeyLayout
|
||||||
@ -188,55 +184,6 @@ export default {
|
|||||||
this.isLoadedKeyLayout = true
|
this.isLoadedKeyLayout = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getImage(resource) {
|
|
||||||
if (this.isEmptyValue(resource) || this.isEmptyValue(resource.fileName)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const { fileName, contentType } = resource
|
|
||||||
if (!this.valuesImage.some(item => item.identifier === fileName)) {
|
|
||||||
this.valuesImage.push({
|
|
||||||
identifier: fileName,
|
|
||||||
value: '',
|
|
||||||
isLoaded: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (this.resource[fileName]) {
|
|
||||||
this.valuesImage.forEach(item => {
|
|
||||||
if (item.identifier === fileName) {
|
|
||||||
item.value = this.resource[fileName]
|
|
||||||
item.isLoaded = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else { // Reload
|
|
||||||
if (!this.valuesImage.some(item => item.identifier === fileName)) {
|
|
||||||
this.valuesImage.push({
|
|
||||||
identifier: fileName,
|
|
||||||
value: '',
|
|
||||||
isLoaded: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// the name of the image plus the height and width of the container is sent
|
|
||||||
requestImage({
|
|
||||||
file: fileName,
|
|
||||||
width: 300,
|
|
||||||
height: 300
|
|
||||||
}).then(responseImage => {
|
|
||||||
const arrayBufferAsImage = buildImageFromArrayBuffer({
|
|
||||||
arrayBuffer: responseImage,
|
|
||||||
contentType
|
|
||||||
})
|
|
||||||
|
|
||||||
this.resource[fileName] = arrayBufferAsImage
|
|
||||||
this.valuesImage.forEach(item => {
|
|
||||||
if (item.identifier === fileName) {
|
|
||||||
item.value = arrayBufferAsImage
|
|
||||||
item.isLoaded = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setKeyActionToOrderLine(keyValue) {
|
setKeyActionToOrderLine(keyValue) {
|
||||||
if (!this.isEmptyValue(keyValue.subKeyLayoutUuid)) {
|
if (!this.isEmptyValue(keyValue.subKeyLayoutUuid)) {
|
||||||
this.loadKeyLayout(keyValue.subKeyLayoutUuid)
|
this.loadKeyLayout(keyValue.subKeyLayoutUuid)
|
||||||
@ -274,18 +221,17 @@ export default {
|
|||||||
return image.isLoaded
|
return image.isLoaded
|
||||||
},
|
},
|
||||||
getImageFromSource(keyValue) {
|
getImageFromSource(keyValue) {
|
||||||
const { fileName } = keyValue.resourceReference
|
const fileName = keyValue.resourceReference.fileName
|
||||||
|
|
||||||
if (this.isEmptyValue(fileName)) {
|
if (this.isEmptyValue(fileName)) {
|
||||||
return this.defaultImage
|
return this.defaultImage
|
||||||
}
|
}
|
||||||
|
const image = getImagePath({
|
||||||
// const image = this.valuesImage.find(item => item.identifier === fileName).value
|
file: fileName,
|
||||||
const image = this.resource[fileName]
|
width: 300,
|
||||||
if (this.isEmptyValue(image)) {
|
height: 300
|
||||||
return this.defaultImage
|
})
|
||||||
}
|
return image.uri
|
||||||
return image
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,11 @@ export function buildImageFromArrayBuffer({
|
|||||||
*/
|
*/
|
||||||
export function getImagePath({
|
export function getImagePath({
|
||||||
file,
|
file,
|
||||||
width = 300,
|
width,
|
||||||
height = 300,
|
height,
|
||||||
operation = 'fit'
|
operation = 'fit'
|
||||||
}) {
|
}) {
|
||||||
const url = config.adempiere.images.fullPath
|
const url = config.adempiere.images.url
|
||||||
const urn = `/img?action=${operation}&width=${width}&height=${height}&url=${file}`
|
const urn = `/img?action=${operation}&width=${width}&height=${height}&url=${file}`
|
||||||
const uri = `${url}${urn}`
|
const uri = `${url}${urn}`
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user