feat 增加一键蹲货

This commit is contained in:
timerzz 2024-05-15 16:33:22 +08:00
parent 10fba9c57c
commit 4d94feff03

View File

@ -8,7 +8,7 @@
</div>
<div class="h-full border-0 border-t-1 border-solid border-gray-300 pt-4">
<a-spin :spinning="loading" :indicator="indicator">
<a-table :dataSource="data.list" :columns="columns" :pagination="false">
<a-table :dataSource="data.list" :columns="columns" :pagination="false" @change="tableChange">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'name'">
<a v-if="record.name !== '' " :href="record.link" target="_blank">{{record.name}}</a>
@ -47,10 +47,15 @@
<span class="cursor-pointer">{{parseFloat(record.cnyPrice).toFixed(2)}}</span>
</a-popover>
</template>
<template v-else-if="column.key === 'orderable'">
<span :class="[record.orderable ? '':'text-red']">{{record.orderable?'是':'否'}}</span>
</template>
<template v-else-if="column.key === 'opt'">
<a-popover title="" placement="bottom">
<template #content>
<a-button type="text" block @click="onEdit(record, 'modal')">编辑</a-button>
<a-button type="text" block @click="onWatch(record.pid, record.name)">一键蹲货</a-button>
</template>
<SettingOutlined class="cursor-pointer" />
</a-popover>
@ -86,19 +91,21 @@
</template>
<script setup>
import {h, onMounted, onUpdated, reactive, ref} from "vue";
import {computed, h, onMounted, reactive, ref} from "vue";
import {ListProducts, UpdateProduct} from "@/api/product.js";
import moment from "moment/moment.js";
import { clone } from 'radash'
import {LoadingOutlined, SaveOutlined,SettingOutlined} from "@ant-design/icons-vue";
import {message} from "ant-design-vue";
import {message, Modal} from "ant-design-vue";
import {CreateWatcher} from "@/api/watcher.js";
onMounted(()=>{
list()
})
const query = reactive({
page: 1,
size:6
size:6,
rate_sort: null
})
const loading = ref(false)
@ -119,7 +126,7 @@ const list = ()=>{
})
}
const columns = [
const columns = computed(()=>[
{
title: '名称',
dataIndex: 'name',
@ -160,6 +167,13 @@ const columns = [
title: '收益率',
dataIndex: 'rate',
key: 'rate',
sorter:true,
sortOrder: query.rate_sort
},
{
title: '可购买',
dataIndex: 'orderable',
key: 'orderable',
},
{
title: '抓取时间',
@ -175,7 +189,7 @@ const columns = [
title: '操作',
key: 'opt',
},
]
])
const indicator = h(LoadingOutlined, {
style: {
@ -218,6 +232,37 @@ const doUpdate=()=>{
editData.editModal = false
})
}
const tableChange = (pagination, filters, sorter, { action, currentDataSource })=>{
if(sorter.columnKey === 'rate') {
query.rate_sort = sorter.order
}
list()
}
//
const onWatch = (pid, name)=>{
Modal.confirm({
title: '确定要蹲该商品',
content: name,
okText: '确定',
cancelText: '取消',
onOk() {
CreateWatcher({
pid: pid,
remark:'',
pusherIds:[1]
}).then(res=>{
message.success("添加成功")
}).catch(err => {
message.error("添加失败")
console.log(err)
}).finally(()=>{
list()
})
},
});
}
</script>