This commit is contained in:
liushiwei
2023-08-18 10:03:50 +08:00
parent 27f9c7a874
commit e7200de6a0
4 changed files with 160 additions and 6 deletions

109
src/components/AiSelect.vue Normal file
View File

@@ -0,0 +1,109 @@
<template>
<div class="ai-select">
<el-select
style="width: 100%;"
:clearable="clearable"
:value="value"
:size="$attrs.size || 'small'"
v-bind="$attrs"
v-on="$listeners">
<el-option
v-for="(item, index) in selectList"
:key="index"
:label="item.dictName"
:value="item.dictValue">
<slot :info="item"></slot>
</el-option>
</el-select>
</div>
</template>
<script>
export default {
name: 'AiSelect',
model: {
prop: 'value',
event: 'change'
},
watch: {
instance: {
deep: true,
handler(v) {
v && this.isAction && !this.options.toString() && this.getOptions()
}
}
},
props: {
value: {
type: [String, Number, Array]
},
clearable: {
type: Boolean,
default: true
},
selectList: {
type: Array
},
width: {
type: String,
default: '216'
},
instance: Function,
action: {default: ""},
prop: {
default: () => ({})
}
},
data() {
return {
options: [],
filter: ""
}
},
computed: {
selectWidth() {
if (this.width.indexOf('px') > -1) {
return this.width
}
return `${this.width}px`
},
isAction() {
return !!this.action
},
actionOps() {
return this.options.filter(e => !this.filter || e[this.actionProp.label].indexOf(this.filter) > -1)
},
actionProp() {
return {
label: 'label',
value: 'id',
...this.prop
}
}
},
methods: {
getOptions() {
this.instance?.post(this.action, null, {
params: {size: 999}
}).then(res => {
if (res?.data) {
this.options = res.data.records || res.data
}
})
}
},
created() {
this.getOptions()
}
}
</script>
<style lang="scss" scoped>
::v-deep .ai-select .el-select {
width: 100%;
}
</style>

View File

@@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "TEMU助手",
"description": "TEMU助手 - 自动化提高生产效率",
"version": "2.0.3",
"version": "2.1.0",
"background": {
"service_worker": "/background.js"
},

View File

@@ -3,7 +3,7 @@ import store from '../store'
import { Message } from 'element-ui'
const dict = {
url: "/dictionary/queryValsByCodeList",
url: "/api/dictionary/queryValsByCodeList",
loading: [],
resolves: [],
getStorage() {

View File

@@ -19,7 +19,7 @@
<!--<el-button type="primary" :disabled="isBegin" @click="isShow = true">添加备货单</el-button>
<el-button type="primary" :disabled="isBegin" @click="loadAll">一键加载全部</el-button>-->
</el-dropdown>
<el-button v-if="!isBegin" type="button" :class="'el-button el-button--primary'" @click="handleRobClick('normal')">开始抢仓</el-button>
<el-button v-if="!isBegin" type="button" :class="'el-button el-button--primary'" @click="robDlgShow = true">开始抢仓</el-button>
<!--<el-dropdown @command="handleRobClick" v-if="!isBegin">
<el-button type="button" :class="'el-button el-button--primary'">开始抢仓</el-button>
<el-dropdown-menu slot="dropdown">
@@ -192,6 +192,38 @@
<el-button @click="successDlgShow = false"> </el-button>
</span>
</AiDialog>
<AiDialog
title="抢仓设置"
:visible.sync="robDlgShow"
:close-on-click-modal="false"
customFooter
width="600px">
<el-alert
title="抢仓速度 = 频率 + 0~变动值之间的随机数如频率设置为1.5秒变动值为500毫秒则抢仓速度为1.5秒~2秒。"
type="success"
:closable="false">
</el-alert>
<el-form :model="robForm" ref="robForm" label-width="120px" class="form">
<el-form-item
prop="step"
label="频率:"
:rules="[{ required: true, message: '请选择抢仓频率', trigger: 'blur' }]">
<ai-select :selectList="$dict.getDict('rob_frequency')" v-model="robForm.step"></ai-select>
</el-form-item>
<el-form-item
prop="randomValue"
label="变动值(毫秒)"
:rules="[{ required: true, message: '请输入变动值', trigger: 'blur' }]">
<el-input size="small" placeholder="请输入变动值" type="number" v-model="robForm.randomValue"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="robDlgShow = false"> </el-button>
<el-button type="primary" @click="beforeBegin"> </el-button>
</span>
</AiDialog>
</template>
</ai-list>
</div>
@@ -240,8 +272,10 @@
robTotal: 0,
pageSize: 100,
currentPage: 1,
step: 500,
randomValue: 500,
robForm: {
step: "1000",
randomValue: 1000
},
timer: [],
loadMallIndex: 0,
loadMode: 0, // 加载模式0表示单个店铺加载1表示一键加载
@@ -254,6 +288,8 @@
successDlgShow: false,
successMallId: '',
successList: [],
robDlgShow: false,
}
},
@@ -270,6 +306,7 @@
},
created () {
this.$dict.load('rob_frequency');
},
methods: {
@@ -323,6 +360,14 @@
this.loadAll()
}
},
beforeBegin() {
this.$refs.robForm.validate((valid) => {
if (valid) {
this.handleRobClick('normal')
this.robDlgShow = false
}
})
},
handleRobClick (e) {
this.networkErrorCount = 0
@@ -513,7 +558,7 @@
// 继续抢
setTimeout(() => {
this.rob()
}, this.step + Math.floor(Math.random() * this.randomValue))
}, parseInt(this.robForm.step) + Math.floor(Math.random() * parseInt(this.robForm.randomValue)))
}
})
},