plantScreen/src/components/index/leftBottom.vue

60 lines
1.4 KiB
Vue
Raw Normal View History

2023-12-15 18:20:02 +08:00
<template>
<scrollTable :config="config2" style="width:100%;height:100%" v-if="config2.data.length"></scrollTable>
</template>
<script setup>
import scrollTable from "@/components/scrollTable.vue"
import { ref, reactive, onMounted } from "vue"
import { plantProductCountApi } from "@/api.js"
const alignFn = (num) => {
let arr = []
for (let i = 0; i < num; i++) {
arr.push('center')
}
return arr
}
const config2 = reactive({
header: ['产品名称', '溯源码', '产品名称', '溯源码',],
headerBGC: "#092757",
oddRowBGC: "#0C2045",
headerStyle: "background:#0E316B",
align: alignFn(4),
data: [ ]
})
const correctionListFn = (list) => {
const originalArray = list;
const transformedArray = originalArray.reduce((acc, curr, index) => {
if (index % 2 === 0) {
acc.push([curr]);
} else {
acc[acc.length - 1].push(curr);
}
return acc;
}, []);
return transformedArray
}
plantProductCountApi(
{
areaCode: 510521,
streetCode: 510521100
}
).then(res => {
correctionListFn(res.data.list).forEach(item => {
config2.data.push(
[item[0].kind, `<img src=${ item[0].qr_code} style='width:25px;height:25px;transform: translateY(5PX);'/>` , item[1].kind,`<img src=${ item[1].qr_code} style='width:25px;height:25px;transform: translateY(5PX);'/>` ]
)
})
})
</script>