This commit is contained in:
parent
545797ef8d
commit
e89dbd6fa5
@ -3,3 +3,5 @@ import {mande} from "mande";
|
||||
const spider = mande('/api/v1/spider')
|
||||
|
||||
export const GetSpiderCfg = ()=> spider.get("cfg")
|
||||
|
||||
export const SetSpiderCfg = (cfg)=> spider.post("cfg",cfg)
|
@ -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="flex justify-between">
|
||||
<div class="flex items-center space-x-16">
|
||||
<div>当前汇率:<span class="text-xl">{{spiderCfg.exchangeRate}}</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 class="flex space-x-4">
|
||||
<a-input placeholder="请输入关键词" v-model:value="query.keyword" @pressEnter="search"></a-input>
|
||||
@ -117,6 +119,22 @@
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</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>
|
||||
<script setup>
|
||||
|
||||
@ -124,10 +142,10 @@ import {computed, h, onMounted, reactive, ref} from "vue";
|
||||
import {GetProduct, ListProducts, UpdateProduct} from "@/api/product.js";
|
||||
import moment from "moment/moment.js";
|
||||
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 {CreateWatcher} from "@/api/watcher.js";
|
||||
import {GetSpiderCfg} from "@/api/spider.js";
|
||||
import {GetSpiderCfg, SetSpiderCfg} from "@/api/spider.js";
|
||||
|
||||
onMounted(()=>{
|
||||
list()
|
||||
@ -337,7 +355,8 @@ const PRICE_STATUS = {
|
||||
|
||||
const spiderCfg = ref({
|
||||
exchangeRate: 0,
|
||||
freight: 0
|
||||
freight: 0,
|
||||
discount: 100
|
||||
})
|
||||
|
||||
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>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user