feat 增加历史价格
All checks were successful
Build image / build (push) Successful in 1m57s

This commit is contained in:
timerzz 2024-05-15 21:10:36 +08:00
parent 1f07d5db26
commit 4d9450a335
2 changed files with 29 additions and 2 deletions

View File

@ -8,4 +8,8 @@ export const ListProducts = (query) => {
export const UpdateProduct=(p)=>{ export const UpdateProduct=(p)=>{
return product.post(p) return product.post(p)
}
export const GetProduct = (pid) => {
return product.get(`p/${pid}`)
} }

View File

@ -12,7 +12,7 @@
</div> </div>
<div class="h-full border-0 border-t-1 border-solid border-gray-300 pt-4"> <div class="h-full border-0 border-t-1 border-solid border-gray-300 pt-4">
<a-spin :spinning="loading" :indicator="indicator"> <a-spin :spinning="loading" :indicator="indicator">
<a-table :dataSource="data.list" :columns="columns" :custom-row="customRow" :pagination="false" @change="tableChange"> <a-table :dataSource="data.list" :columns="columns" :custom-row="customRow" :pagination="false" @change="tableChange" rowKey="pid" @expand="expand">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'name'"> <template v-if="column.key === 'name'">
<a v-if="record.name !== '' " :href="record.link" target="_blank">{{record.name}}</a> <a v-if="record.name !== '' " :href="record.link" target="_blank">{{record.name}}</a>
@ -71,6 +71,18 @@
</a-popover> </a-popover>
</template> </template>
</template> </template>
<template #expandedRowRender="{ record }">
<a-spin :spinning="!record.historyPrices">
<div class="px-4">
<div class="text-xl">历史价格</div>
<div class="flex space-x-16 my-2 text-lg" v-for="h in record.historyPrices">
<div>{{moment(h.createdAt).format('YYYY-MM-DD HH:mm:ss')}}</div>
<div>${{h.usPrice}}</div>
</div>
</div>
</a-spin>
</template>
</a-table> </a-table>
</a-spin> </a-spin>
</div> </div>
@ -102,7 +114,7 @@
<script setup> <script setup>
import {computed, h, onMounted, reactive, ref} from "vue"; import {computed, h, onMounted, reactive, ref} from "vue";
import {ListProducts, UpdateProduct} from "@/api/product.js"; import {GetProduct, ListProducts, UpdateProduct} from "@/api/product.js";
import moment from "moment/moment.js"; import moment from "moment/moment.js";
import { clone } from 'radash' import { clone } from 'radash'
import {LoadingOutlined, SaveOutlined,SettingOutlined,CaretUpOutlined,CaretDownOutlined} from "@ant-design/icons-vue"; import {LoadingOutlined, SaveOutlined,SettingOutlined,CaretUpOutlined,CaretDownOutlined} from "@ant-design/icons-vue";
@ -312,6 +324,17 @@ const customRow=(record, index)=>{
}, // }, //
} }
} }
const expand = (expanded, record)=>{
if(expanded && !record.historyPrices){
GetProduct(record.pid).then(res=>{
record.historyPrices = res.historyPrices
}).catch(err=>{
message.error("获取历史价格失败")
console.log(err)
})
}
}
</script> </script>