|
@@ -45,14 +45,17 @@ export default {
|
|
|
default: () => []
|
|
|
}
|
|
|
},
|
|
|
- data() {
|
|
|
+ data () {
|
|
|
return {}
|
|
|
},
|
|
|
+ mounted () {
|
|
|
+ this.setItemwidth()
|
|
|
+ },
|
|
|
methods: {
|
|
|
- handleError(img) {
|
|
|
+ handleError (img) {
|
|
|
img.target.src = require('../assets/images/error.png')
|
|
|
},
|
|
|
- SetViewUnit(num) {
|
|
|
+ SetViewUnit (num) {
|
|
|
let newNum = 0
|
|
|
if (!num) return 0
|
|
|
if (num > 10000) {
|
|
@@ -62,8 +65,21 @@ export default {
|
|
|
}
|
|
|
return newNum
|
|
|
},
|
|
|
- goContent(item) {
|
|
|
+ goContent (item) {
|
|
|
this.$emit('click', item)
|
|
|
+ },
|
|
|
+ setItemwidth () { // 适配嵌入工作台内
|
|
|
+ const bodyWidth = document.body.clientWidth
|
|
|
+ if (window.goTemplateData && window.goTemplateData.inIframe && bodyWidth > 1248) {
|
|
|
+ const element = document.getElementsByClassName('card-item')[0]
|
|
|
+ const itemwidth = element.offsetWidth + 104 // 104是margin
|
|
|
+ const num = Math.floor(bodyWidth / itemwidth)
|
|
|
+ const newwidth = (Math.floor((bodyWidth - (itemwidth * num)) / num)) + itemwidth
|
|
|
+ var elements = document.querySelectorAll('.card-item')
|
|
|
+ elements.forEach(function (ele) {
|
|
|
+ ele.style.width = newwidth + 'px' // 设置新的宽度
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|