Compare commits

...

2 Commits

Author SHA1 Message Date
e89dbd6fa5 feat 支持修改爬取配置
All checks were successful
Build image / build (push) Successful in 26s
2024-05-23 21:18:01 +08:00
545797ef8d fix 修复推送显示问题 2024-05-23 21:01:59 +08:00
3 changed files with 56 additions and 9 deletions

View File

@ -3,3 +3,5 @@ import {mande} from "mande";
const spider = mande('/api/v1/spider') const spider = mande('/api/v1/spider')
export const GetSpiderCfg = ()=> spider.get("cfg") export const GetSpiderCfg = ()=> spider.get("cfg")
export const SetSpiderCfg = (cfg)=> spider.post("cfg",cfg)

View File

@ -1,9 +1,11 @@
<template> <template>
<div class="h-full m-4 bg-white rounded-2 shadow-lg p-8 flex flex-col justify-between space-y-4 overscroll-auto"> <div class="h-full m-4 bg-white rounded-2 shadow-lg p-8 flex flex-col justify-between space-y-4 overscroll-auto">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex items-center space-x-16"> <div class="flex items-center space-x-16">
<div>当前汇率<span class="text-xl">{{spiderCfg.exchangeRate}}</span></div> <div>当前汇率<span class="text-xl">{{spiderCfg.exchangeRate}}</span></div>
<div>当前默认运费<span class="text-xl">{{spiderCfg.freight}}</span></div> <div>当前默认运费<span class="text-xl">{{spiderCfg.freight}}</span></div>
<div>当前折扣<span class="text-xl">{{spiderCfg.discount}}% </span></div>
<FormOutlined class="cursor-pointer" @click="editSpiderCfg"/>
</div> </div>
<div class="flex space-x-4"> <div class="flex space-x-4">
<a-input placeholder="请输入关键词" v-model:value="query.keyword" @pressEnter="search"></a-input> <a-input placeholder="请输入关键词" v-model:value="query.keyword" @pressEnter="search"></a-input>
@ -117,6 +119,22 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-modal> </a-modal>
<a-modal v-model:open="spiderCfgModal.visible" @ok="updateSpiderCfg" centered>
<template #title>
编辑
</template>
<a-form :model="spiderCfgModal.data" :labelCol="{span: 6}">
<a-form-item label="汇率">
<a-input-number v-model:value="spiderCfgModal.data.exchangeRate" :min="1" />
</a-form-item>
<a-form-item label="运费">
<a-input-number v-model:value="spiderCfgModal.data.freight" :min="1"/>
</a-form-item>
<a-form-item label="折扣">
<a-input-number addon-after="%" v-model:value="spiderCfgModal.data.discount" :min="1" :max="100"/>
</a-form-item>
</a-form>
</a-modal>
</template> </template>
<script setup> <script setup>
@ -124,10 +142,10 @@ import {computed, h, onMounted, reactive, ref} from "vue";
import {GetProduct, 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, FormOutlined} from "@ant-design/icons-vue";
import {message, Modal} from "ant-design-vue"; import {message, Modal} from "ant-design-vue";
import {CreateWatcher} from "@/api/watcher.js"; import {CreateWatcher} from "@/api/watcher.js";
import {GetSpiderCfg} from "@/api/spider.js"; import {GetSpiderCfg, SetSpiderCfg} from "@/api/spider.js";
onMounted(()=>{ onMounted(()=>{
list() list()
@ -337,7 +355,8 @@ const PRICE_STATUS = {
const spiderCfg = ref({ const spiderCfg = ref({
exchangeRate: 0, exchangeRate: 0,
freight: 0 freight: 0,
discount: 100
}) })
const loadSpiderCfg = ()=>{ const loadSpiderCfg = ()=>{
@ -367,6 +386,32 @@ const expand = (expanded, record)=>{
}) })
} }
} }
const spiderCfgModal = reactive({
data: {
exchangeRate: 0,
freight: 0,
discount: 100
},
visible: false,
})
const editSpiderCfg = ()=>{
spiderCfgModal.data = clone(spiderCfg.value)
spiderCfgModal.visible = true
}
const updateSpiderCfg = ()=>{
SetSpiderCfg(spiderCfgModal.data).then(res=>{
message.success('修改成功')
}).catch(err=>{
message.error('修改失败')
console.log(err)
}).finally(()=>{
spiderCfgModal.visible = false
loadSpiderCfg()
})
}
</script> </script>

View File

@ -25,8 +25,8 @@
<span>{{moment(record.updatedAt).format('YYYY-MM-DD HH:mm:ss')}}</span> <span>{{moment(record.updatedAt).format('YYYY-MM-DD HH:mm:ss')}}</span>
</template> </template>
<template v-else-if="column.key === 'pushers'"> <template v-else-if="column.key === 'pushers'">
<template v-if="record.pushers.length>0" v-for="id in record.pushers"> <template v-if="record.pushers.length>0" v-for="pusher in record.pushers">
<a-tag :bordered="false" color="processing" v-for="pusher in record.pushers">{{pusher.name}}</a-tag> <a-tag :bordered="false" color="processing" >{{pusher.name}}</a-tag>
</template> </template>
<span v-else>-</span> <span v-else>-</span>
</template> </template>
@ -235,7 +235,7 @@ const columns = [
}, },
{ {
title: '推送', title: '推送',
key: 'pusherIds', key: 'pushers',
}, },
{ {
title: '备注', title: '备注',