|
|
@@ -25,6 +25,7 @@
|
|
|
size="default"
|
|
|
placeholder="请输入货号"
|
|
|
:bordered="false"
|
|
|
+ readonly
|
|
|
class="full-width-input"
|
|
|
@input="saveProduct(index)"
|
|
|
/>
|
|
|
@@ -79,12 +80,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ElLoading,ElMessageBox } from 'element-plus'
|
|
|
+import {ElLoading, ElMessageBox} from 'element-plus'
|
|
|
import {computed, onMounted, ref} from 'vue'
|
|
|
-import { useRouter } from 'vue-router'
|
|
|
+import {useRouter} from 'vue-router'
|
|
|
import {Document, PriceTag} from '@element-plus/icons-vue'
|
|
|
-import {HandlerOutPutDirectory,MakeProducts} from '../../wailsjs/go/main/App'
|
|
|
+import {HandlerOutPutDirectory, MakeProducts} from '../../wailsjs/go/main/App'
|
|
|
import {handlers} from "../../wailsjs/go/models";
|
|
|
+
|
|
|
const router = useRouter()
|
|
|
// 当前日期
|
|
|
const currentDate = computed(() => {
|
|
|
@@ -97,6 +99,7 @@ let products = ref<handlers.ImageResult[]>([])
|
|
|
// 生成报价图册方法
|
|
|
const generateCatalog = async () => {
|
|
|
let productList = JSON.parse(JSON.stringify(products.value));
|
|
|
+ localStorage.setItem('products', JSON.stringify(productList))
|
|
|
for (let i = 0; i < productList.length; i++) {
|
|
|
productList[i].image_base64 = "";
|
|
|
}
|
|
|
@@ -128,8 +131,41 @@ const fetchOutPut = async () => {
|
|
|
background: 'rgba(0, 0, 0, 0.7)',
|
|
|
})
|
|
|
try {
|
|
|
- products.value = await HandlerOutPutDirectory()
|
|
|
- // 例如:username.value = result.username
|
|
|
+ // 先尝试从本地缓存获取数据
|
|
|
+ const cachedProducts = localStorage.getItem('products')
|
|
|
+ let cachedData: handlers.ImageResult[] = []
|
|
|
+ if (cachedProducts) {
|
|
|
+ cachedData = JSON.parse(cachedProducts)
|
|
|
+ }
|
|
|
+ // 获取最新的产品数据
|
|
|
+ const freshProducts = await HandlerOutPutDirectory()
|
|
|
+
|
|
|
+ // 货号匹配逻辑
|
|
|
+ if (cachedData.length > 0) {
|
|
|
+ // 遍历最新数据,匹配缓存中的货号
|
|
|
+ products.value = freshProducts.map(freshProduct => {
|
|
|
+ // 在缓存数据中查找相同货号的产品
|
|
|
+ const cachedMatch = cachedData.find(cached =>
|
|
|
+ cached.goods_art_no === freshProduct.goods_art_no
|
|
|
+ )
|
|
|
+
|
|
|
+ // 如果找到匹配项,使用缓存的数据覆盖默认值
|
|
|
+ if (cachedMatch) {
|
|
|
+ return {
|
|
|
+ ...freshProduct,
|
|
|
+ category: cachedMatch.category || freshProduct.category,
|
|
|
+ description: cachedMatch.description || freshProduct.description,
|
|
|
+ price: cachedMatch.price || freshProduct.price
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 没有匹配项则使用原始数据
|
|
|
+ return freshProduct
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 没有缓存数据,直接使用新数据
|
|
|
+ products.value = freshProducts
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
console.error("获取应用参数失败:", error)
|
|
|
}finally {
|