This commit is contained in:
zmj 2024-03-06 17:08:23 +08:00
parent 89cdbecb01
commit 01717c590b
1 changed files with 14 additions and 18 deletions

View File

@ -1,13 +1,14 @@
<template> <template>
<scrollTable :config="config2" style="width:100%;height:100%" v-if="config2.data.length"></scrollTable> <scrollTable :config="config2" style="width:100%;height:100%" v-if="config2.data.length"></scrollTable>
</template> </template>
<script setup> <script setup>
import qrcode from "qrcode"
import scrollTable from "@/components/scrollTable.vue" import scrollTable from "@/components/scrollTable.vue"
import { ref, reactive, onMounted } from "vue" import { ref, reactive, onMounted } from "vue"
import { plantProductCountApi } from "@/api.js" import { plantProductCountApi } from "@/api.js"
import { areaObj } from "@/store/index.js" import { areaObj } from "@/store/index.js"
const userInfoStore = areaObj() const userInfoStore = areaObj()
// ...userInfoStore.userInfo
const alignFn = (num) => { const alignFn = (num) => {
let arr = [] let arr = []
for (let i = 0; i < num; i++) { for (let i = 0; i < num; i++) {
@ -20,13 +21,16 @@ const config2 = reactive({
headerBGC: "#092757", headerBGC: "#092757",
oddRowBGC: "#0C2045", oddRowBGC: "#0C2045",
headerStyle: "background:#0E316B", headerStyle: "background:#0E316B",
align: alignFn(4), align: alignFn(4),
data: [] data: []
}) })
const correctionListFn = (list) => { const correctionListFn = async (list) => {
for (let i = 0; i < list.length; i++) {
let res = await qrcode.toDataURL(`https://suyuan.lihaink.cn/api/index/suYuan?id=${8}`)
list[i].qr_code = res
}
const originalArray = list; const originalArray = list;
const transformedArray = originalArray.reduce((acc, curr, index) => { const transformedArray = originalArray.reduce((acc, curr, index) => {
if (index % 2 === 0) { if (index % 2 === 0) {
@ -36,31 +40,23 @@ const correctionListFn = (list) => {
} }
return acc; return acc;
}, []); }, []);
return transformedArray return transformedArray
} }
plantProductCountApi( plantProductCountApi(
{ {
...userInfoStore.userInfo ...userInfoStore.userInfo
} }
).then(res => { ).then(res => {
correctionListFn(res.data.list).then(res => {
correctionListFn(res.data.list).forEach(item => { res.forEach(item => {
config2.data.push( config2.data.push(
[item[0].kind, `<img src=${item[0].qr_code} style='width:25px;height:25px;transform: translateY(5PX);'/>`,item[1]? item[1].kind:'', item[1]? `<img src=${item[1].qr_code} style='width:25px;height:25px;transform: translateY(5PX);'/>`:""] [item[0].kind, `<img src=${item[0].qr_code} style='width:25px;height:25px;transform: translateY(5PX);'/>`, item[1] ? item[1].kind : '', item[1] ? `<img src=${item[1].qr_code} style='width:25px;height:25px;transform: translateY(5PX);'/>` : ""]
) )
}) })
})
}) })
</script> </script>