4747 <el-col :key =" key" :span =" size" >
4848 <el-card
4949 :body-style =" { padding: '0px' }"
50- :data =" getImage(keyValue.resourceReference)"
5150 shadow =" always"
5251 >
5352 <span >
5453 <p style =" padding-left : 10px ; font-size : 12px ; color : #0e2ea4 " >
5554 <b >{{ keyValue.name }}</b >
5655 </p >
57- <!--
58- <b style="padding-left: 10px; font-size: 10px; color: #359e43">
59- Available
60- </b>
61- -->
6256 </span >
6357 <div @click =" setKeyActionToOrderLine(keyValue)" >
6458 <el-image
65- v-if =" getDefaultImage(keyValue)"
6659 :src =" getImageFromSource(keyValue)"
6760 class =" key-layout"
6861 fit =" contain"
6962 />
70- <vue-content-loading v-else :width =" 300" :height =" 300" />
7163 </div >
7264 <div class =" footer-product" >
7365 <p class =" quantity" >
10193</template >
10294
10395<script >
104- import VueContentLoading from ' @/components/ADempiere/ContentLoader'
105- import { requestImage } from ' @/api/ADempiere/common/resource.js'
106- import { buildImageFromArrayBuffer } from ' @/utils/ADempiere/resource.js'
96+ import { getImagePath } from ' @/utils/ADempiere/resource.js'
10797import { formatQuantity } from ' @/utils/ADempiere/valueFormat.js'
108-
10998export default {
11099 name: ' KeyLayout' ,
111- components: {
112- VueContentLoading
113- },
114100 data () {
115101 return {
116102 resource: {},
@@ -119,7 +105,8 @@ export default {
119105 identifier: ' undefined' ,
120106 value: ' ' ,
121107 isLoaded: true
122- }]
108+ }],
109+ hola: ' '
123110 }
124111 },
125112 computed: {
@@ -133,7 +120,16 @@ export default {
133120 return this .$store .getters .getKeyLayout
134121 },
135122 getKeyList () {
136- return this .getKeyLayout .keysList
123+ const keylist = this .getKeyLayout .keysList
124+ if (! this .isEmptyValue ) {
125+ return keylist .map (item => {
126+ return {
127+ ... item,
128+ isLoaded: true
129+ }
130+ })
131+ }
132+ return keylist
137133 },
138134 getLayoutHeader () {
139135 const keyLayout = this .getKeyLayout
@@ -188,55 +184,6 @@ export default {
188184 this .isLoadedKeyLayout = true
189185 })
190186 },
191- getImage (resource ) {
192- if (this .isEmptyValue (resource) || this .isEmptyValue (resource .fileName )) {
193- return
194- }
195-
196- const { fileName , contentType } = resource
197- if (! this .valuesImage .some (item => item .identifier === fileName)) {
198- this .valuesImage .push ({
199- identifier: fileName,
200- value: ' ' ,
201- isLoaded: false
202- })
203- }
204- if (this .resource [fileName]) {
205- this .valuesImage .forEach (item => {
206- if (item .identifier === fileName) {
207- item .value = this .resource [fileName]
208- item .isLoaded = true
209- }
210- })
211- } else { // Reload
212- if (! this .valuesImage .some (item => item .identifier === fileName)) {
213- this .valuesImage .push ({
214- identifier: fileName,
215- value: ' ' ,
216- isLoaded: false
217- })
218- }
219- // the name of the image plus the height and width of the container is sent
220- requestImage ({
221- file: fileName,
222- width: 300 ,
223- height: 300
224- }).then (responseImage => {
225- const arrayBufferAsImage = buildImageFromArrayBuffer ({
226- arrayBuffer: responseImage,
227- contentType
228- })
229-
230- this .resource [fileName] = arrayBufferAsImage
231- this .valuesImage .forEach (item => {
232- if (item .identifier === fileName) {
233- item .value = arrayBufferAsImage
234- item .isLoaded = true
235- }
236- })
237- })
238- }
239- },
240187 setKeyActionToOrderLine (keyValue ) {
241188 if (! this .isEmptyValue (keyValue .subKeyLayoutUuid )) {
242189 this .loadKeyLayout (keyValue .subKeyLayoutUuid )
@@ -274,18 +221,17 @@ export default {
274221 return image .isLoaded
275222 },
276223 getImageFromSource (keyValue ) {
277- const { fileName } = keyValue .resourceReference
224+ const fileName = keyValue .resourceReference . fileName
278225
279226 if (this .isEmptyValue (fileName)) {
280227 return this .defaultImage
281228 }
282-
283- // const image = this.valuesImage.find(item => item.identifier === fileName).value
284- const image = this .resource [fileName]
285- if (this .isEmptyValue (image)) {
286- return this .defaultImage
287- }
288- return image
229+ const image = getImagePath ({
230+ file: fileName,
231+ width: 300 ,
232+ height: 300
233+ })
234+ return image .uri
289235 }
290236 }
291237}
0 commit comments