mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
添加成本设置
This commit is contained in:
parent
f45ea03e44
commit
cf1ea6b9dc
1
.gitignore
vendored
1
.gitignore
vendored
@ -108,3 +108,4 @@ dist
|
|||||||
.idea/
|
.idea/
|
||||||
data/*.db
|
data/*.db
|
||||||
build/*.exe
|
build/*.exe
|
||||||
|
/build/bin/go-stock-dev.exe
|
||||||
|
Binary file not shown.
@ -12,18 +12,14 @@ const ticker=ref({})
|
|||||||
const stockList=ref([])
|
const stockList=ref([])
|
||||||
const followList=ref([])
|
const followList=ref([])
|
||||||
const options=ref([])
|
const options=ref([])
|
||||||
|
const modalShow = ref(false)
|
||||||
const formModel = ref({
|
const formModel = ref({
|
||||||
|
name: "",
|
||||||
|
code: "",
|
||||||
costPrice: 0.000,
|
costPrice: 0.000,
|
||||||
volume: 0
|
volume: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
const form = h(NForm, { labelPlacement: 'left',model: formModel}, [
|
|
||||||
h(NFormItem, { label: '成本(元)',path:"costPrice" }, [h(NInputNumber, {path:"costPrice", onUpdateValue: updateCostPrice, clearable: true,precision:3, placeholder: '买入成本价(元)', })]),
|
|
||||||
h(NFormItem, { label: '数量(股)',path:"volume" }, [h(NInputNumber, {path:"volume",onUpdateValue: updateVolume, clearable: true,precision:0, placeholder: '买入股数,1手=100股', })]),
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
name: "",
|
name: "",
|
||||||
code: "",
|
code: "",
|
||||||
@ -160,55 +156,21 @@ function search(code,name){
|
|||||||
window.open("https://xueqiu.com/S/"+code)
|
window.open("https://xueqiu.com/S/"+code)
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
function updateCostPrice(v) {
|
|
||||||
console.log(formModel.value.costPrice)
|
|
||||||
formModel.value.costPrice=v
|
|
||||||
console.log(formModel.value.costPrice)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateVolume(v) {
|
|
||||||
console.log(formModel.value.volume)
|
|
||||||
formModel.value.volume=v
|
|
||||||
console.log(formModel.value.volume)
|
|
||||||
}
|
|
||||||
|
|
||||||
function setStock(code,name){
|
function setStock(code,name){
|
||||||
|
|
||||||
let res=followList.value.filter(item => item.StockCode===code)
|
let res=followList.value.filter(item => item.StockCode===code)
|
||||||
console.log("res:",res)
|
console.log("res:",res)
|
||||||
|
formModel.value.name=name
|
||||||
|
formModel.value.code=code
|
||||||
formModel.value.volume=res[0].Volume
|
formModel.value.volume=res[0].Volume
|
||||||
formModel.value.costPrice=res[0].CostPrice
|
formModel.value.costPrice=res[0].CostPrice
|
||||||
|
modalShow.value=true
|
||||||
const m = modal.create({
|
|
||||||
title: name,
|
|
||||||
preset: 'card',
|
|
||||||
style: {
|
|
||||||
width: '400px'
|
|
||||||
},
|
|
||||||
content: () => form,
|
|
||||||
footer: () =>
|
|
||||||
h(NFlex, { justify: 'center' },[
|
|
||||||
h(
|
|
||||||
NButton,
|
|
||||||
{size:'small', type: 'primary', onClick: () =>updateCostPriceAndVolume(m,code,formModel.value.costPrice,formModel.value.volume) },
|
|
||||||
() => '保存'
|
|
||||||
),
|
|
||||||
h(
|
|
||||||
NButton,
|
|
||||||
{ size:'small', type: 'warning', onClick: () => m.destroy() },
|
|
||||||
() => '关闭'
|
|
||||||
),
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
function updateCostPriceAndVolume(m,code,price,volume){
|
|
||||||
|
function updateCostPriceAndVolumeNew(code,price,volume){
|
||||||
console.log(code,price,volume)
|
console.log(code,price,volume)
|
||||||
SetCostPriceAndVolume(code,price,volume).then(result => {
|
SetCostPriceAndVolume(code,price,volume).then(result => {
|
||||||
|
modalShow.value=false
|
||||||
message.success(result)
|
message.success(result)
|
||||||
m.destroy()
|
|
||||||
GetFollowList().then(result => {
|
GetFollowList().then(result => {
|
||||||
followList.value = result
|
followList.value = result
|
||||||
for (const followedStock of result) {
|
for (const followedStock of result) {
|
||||||
@ -267,6 +229,20 @@ function updateCostPriceAndVolume(m,code,price,volume){
|
|||||||
placeholder="股票名称或者代码"
|
placeholder="股票名称或者代码"
|
||||||
clearable class="input" @input="getStockList" :on-select="onSelect"/>
|
clearable class="input" @input="getStockList" :on-select="onSelect"/>
|
||||||
<n-button type="info" @click="AddStock"> 添加 </n-button>
|
<n-button type="info" @click="AddStock"> 添加 </n-button>
|
||||||
|
|
||||||
|
<n-modal transform-origin="center" size="small" v-model:show="modalShow" :title="formModel.name" style="width: 400px" :preset="'card'">
|
||||||
|
<n-form :model="formModel" :rules="{ costPrice: { required: true, message: '请输入成本'}, volume: { required: true, message: '请输入数量'} }" label-placement="left" label-width="80px">
|
||||||
|
<n-form-item label="成本(元)" path="costPrice">
|
||||||
|
<n-input-number v-model:value="formModel.costPrice" min="0" placeholder="请输入股票成本" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="数量(股)" path="volume">
|
||||||
|
<n-input-number v-model:value="formModel.volume" min="0" placeholder="请输入股票数量" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<n-button type="primary" @click="updateCostPriceAndVolumeNew(formModel.code,formModel.costPrice,formModel.volume)">保存</n-button>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
4
main.go
4
main.go
@ -45,11 +45,11 @@ func main() {
|
|||||||
err := wails.Run(&options.App{
|
err := wails.Run(&options.App{
|
||||||
Title: "go-stock",
|
Title: "go-stock",
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
Height: 768,
|
Height: 860,
|
||||||
MinWidth: 1024,
|
MinWidth: 1024,
|
||||||
MinHeight: 768,
|
MinHeight: 768,
|
||||||
MaxWidth: 1280,
|
MaxWidth: 1280,
|
||||||
MaxHeight: 800,
|
MaxHeight: 960,
|
||||||
DisableResize: false,
|
DisableResize: false,
|
||||||
Fullscreen: false,
|
Fullscreen: false,
|
||||||
Frameless: false,
|
Frameless: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user