This commit is contained in:
liushiwei
2023-08-08 04:14:08 +08:00
parent e8e3a497d7
commit 5bda5f83d8
3 changed files with 105 additions and 66 deletions

View File

@@ -8,8 +8,11 @@ export function sendChromeAPIMessage(message) {
message.type = 'api'
message.url = "https://kuajing.pinduoduo.com/" + message.url;
if (message.needMallId) {
// 如果参数中没有携带MallId则从state中获取
if (!message.mallId) {
message.mallId = store.state.mallId;
}
}
return new Promise((resolve) => {
// @ts-ignore
chrome.runtime.sendMessage(message, resolve)

View File

@@ -32,7 +32,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
"" + Math.random(), {
type: "basic",
title: "TEMU助手",
message: "您的商品【" + request.productName + "】成功加入发货台,请尽快处理",
message: "您店铺【" + request.mallName + "】的商品【" + request.productName + "】成功加入发货台,请尽快处理",
iconUrl: "./icons/48.png"
}, null
)

View File

@@ -10,20 +10,18 @@
<template slot="content">
<ai-search-bar>
<template #left>
<el-button type="primary" :disabled="isBegin" @click="isShow = true">选择商品</el-button>
<el-button type="primary" :loading="isBegin" @click="beginRob">{{ isBegin ? '结束抢仓': '开始抢仓' }}</el-button>
<el-button type="primary" :disabled="isBegin" @click="isShow = true">添加备货单</el-button>
<el-button type="button" :icon="isBegin? 'el-icon-loading': ''" :class="isBegin ? 'el-button el-button--danger': 'el-button el-button--primary'" @click="beginRob()">{{isBegin ? `结束抢仓(${choosedList.length}/${robTotal})`: '开始抢仓'}}</el-button>
</template>
<template #right>
<el-button size="small" circle icon="el-icon-refresh-right" @click="getList"></el-button>
</template>
</ai-search-bar>
<ai-table
:tableData="choosedList"
:col-configs="colConfigs"
:col-configs="robColConfigs"
:total="total"
:isShowPagination="false"
style="margin-top: 8px;"
@selection-change="handleSelectionChange"
@getList="getList">center
<el-table-column slot="productName" width="480px" label="商品信息" show-overflow-tooltip align="center">
<template slot-scope="scope">
@@ -39,7 +37,7 @@
</div>
</template>
</el-table-column>
<el-table-column slot="robInfo" label="抢仓信息" show-overflow-tooltip align="center">
<el-table-column slot="robInfo" label="抢仓信息" width="140px" show-overflow-tooltip fixed="right" align="center">
<template slot-scope="scope">
<div data-testid="beast-core-box" style="margin-right: 2px;">
已抢仓 <div style="color: red; display: inline;">{{ scope.row.robTotal }}</div>
@@ -62,26 +60,35 @@
</div>
</template>
</el-table-column>
<el-table-column slot="status" label="状态" show-overflow-tooltip align="center" fixed="right" width="120px">
<el-table-column slot="status" label="状态" show-overflow-tooltip align="center" width="120px">
<template slot-scope="scope">
<div data-testid="beast-core-box" class="outerWrapper-1-3-1 outerWrapper dot-module__dot___M-RuH " style="margin-right: 2px;">
<div class="dot-module__circle___2l2UV" style="background-color: var(--pc-dot-warn-bg-color,#ff6800);"></div>待发货
</div>
</template>
</el-table-column>
<el-table-column slot="options" label="操作" width="80px" v-if="!isBegin" show-overflow-tooltip align="center" fixed="right">
<template slot-scope="{ row }">
<div class="table-options">
<el-button type="text" @click="remove(row.subPurchaseOrderSn)">移除</el-button>
</div>
</template>
</el-table-column>
</ai-table>
<AiDialog
title="选择商品"
title="添加备货单"
:visible.sync="isShow"
:close-on-click-modal="false"
customFooter
@confirm="onConfirm"
width="1290px">
<el-select v-model="mallId" placeholder="请选择">
<label style="width:90px">店铺</label>
<el-select v-model="mallId" placeholder="请选择" @change="mallChange">
<el-option
v-for="item in mallList"
:key="item.mallId"
:label="item.mallName"
:value="item.mallName">
:value="item.mallId">
{{ item.mallName }}
</el-option>
</el-select>
@@ -124,6 +131,10 @@
</template>
</el-table-column>
</ai-table>
<span slot="footer" class="dialog-footer">
<el-button @click="isShow = false"> </el-button>
<el-button type="primary" @click="onConfirm">添加</el-button>
</span>
</AiDialog>
</template>
</ai-list>
@@ -148,59 +159,69 @@
{ slot: 'robInfo'},
{ slot: 'status' }
],
robColConfigs: [
{ prop: 'subPurchaseOrderSn', width: '180px', label: '备货单号', align: 'left' },
{ slot: 'productName' },
{ prop: 'mallName', label: '店铺来源', width: '120px', align: 'center' },
{ slot: 'className'},
{ slot: 'robInfo'},
{ slot: 'status' }
],
mallId: '',
mallName: '',
tableData: [],
total: 0,
ids: [],
isBegin: false,
timer: null,
choosedList: [],
arr: []
arr: [],
robTotal: 0
}
},
computed: {
...mapState(['mallName', 'mallList'])
...mapState(['mallList'])
},
created () {
setTimeout(() => {
this.isShow = true
}, 600)
this.getList()
},
activated () {
this.mallId = this.mallList[0].mallId
this.mallName = this.mallList[0].mallName
this.getList()
},
methods: {
onChooseChange (e) {
// this.choosedList = this.removeDuplicate([...this.choosedList, ...e])
this.arr = e
console.log(this.choosedList)
},
mallChange() {
let mallInfo = this.mallList.filter(item => {
return item.mallId == this.mallId
})
this.mallName = mallInfo.mallName
this.getList()
},
onConfirm () {
this.choosedList = this.arr
this.isShow = false
},
// 数组去重
removeDuplicate (arr) {
let map = {}
arr.forEach(item => {
if (!map[item.subPurchaseOrderSn]) {
map[item.subPurchaseOrderSn]=item
if (this.arr.length == 0) {
Message.error("请选择备货单")
return
}
this.arr.map(item => {
let temp = this.choosedList.filter(i => {
return i.subPurchaseOrderSn == item.subPurchaseOrderSn
})
if (temp.length == 0) {
this.choosedList.push(item)
}
})
return Object.values(map)
Message.success("添加成功,可继续添加")
},
getList () {
this.tableData = []
sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/purchase/manager/querySubOrderList',
needMallId: true,
mallId: this.mallId,
data: {
"pageNo": 1,
"pageSize": 100,
@@ -224,7 +245,10 @@
productSkcId: item.productSkcId,
productSkcPicture: item.productSkcPicture,
status: item.status,
detailList: item.skuQuantityDetailList
detailList: item.skuQuantityDetailList,
category: item.category,
mallId: this.mallId,
mallName: this.mallName
};
})
} else {
@@ -232,11 +256,14 @@
}
})
},
handleSelectionChange(e) {
this.ids = e.map(v => v.subPurchaseOrderSn)
remove(sn) {
for (let i = 0; i < this.choosedList.length; i++) {
if (this.choosedList[i].subPurchaseOrderSn == sn) {
this.choosedList.splice(i, 1)
break
}
}
},
getStyle(url) {
return "background-image: url(" + url + "); width: 72px; height: 72px; cursor: pointer; border-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.14);";
},
@@ -260,21 +287,25 @@
Message.error('您当前登录的TEMU账号与会员绑定账号不一致')
return;
}
if (this.ids.length <= 0) {
Message.error('请选择抢仓商品');
if (this.choosedList.length <= 0) {
Message.error('请选择备货单');
return;
}
this.robTotal = this.choosedList.length
this.isBegin = true;
this.timer = [];
for (let i = 0;i < this.ids.length; i++) {
let t = setInterval(this.robFunc(this.ids[i]), 1000);
this.timer.push({id: this.ids[i], timer: t})
for (let i = 0;i < this.choosedList.length; i++) {
setTimeout(() => {
let t = setInterval(this.robFunc(this.choosedList[i].subPurchaseOrderSn, this.choosedList[i].mallId), 1000);
this.timer.push({id: this.choosedList[i].subPurchaseOrderSn, timer: t})
}, 100 * i)
}
let _this = this;
let tt = setInterval(function() {
if (_this.ids.length == 0) {
if (_this.choosedList.length == 0) {
_this.isBegin = false;
clearInterval(tt);
}
@@ -285,23 +316,24 @@
});
},
robFunc(sn) {
robFunc(sn, mallId) {
let _this = this;
return function() {
_this.rob(sn);
_this.rob(sn, mallId);
}
},
rob(sn) {
rob(sn, mallId) {
sendChromeAPIMessage({
url: 'oms/bg/venom/api/supplier/purchase/manager/joinDeliveryGoodsOrderPlatform',
needMallId: true,
mallId: mallId,
data: {
"subPurchaseOrderSn": sn
}}).then((res) => {
if (res.errorCode == 1000000) {
for (let i = 0;i < this.ids.length; i++) {
if (this.ids[i] == sn) {
this.ids.splice(i, 1)
for (let i = 0;i < this.choosedList.length; i++) {
if (this.choosedList[i].subPurchaseOrderSn == sn) {
this.choosedList.splice(i, 1)
break;
}
}
@@ -313,35 +345,39 @@
clearInterval(t[0].timer)
}
for (let j = 0; j < this.tableData.length; j++) {
if (this.tableData[j].subPurchaseOrderSn == sn) {
this.sendSms(this.tableData[j].productName);
this.sendNotification(this.tableData[j].productName);
this.tableData.splice(j, 1);
for (let j = 0; j < this.choosedList.length; j++) {
if (this.choosedList[j].subPurchaseOrderSn == sn) {
this.addSuccessInfo(this.choosedList[j]);
this.sendNotification(this.choosedList[j]);
this.choosedList.splice(j, 1);
break;
}
}
} else {
for (let j = 0; j < this.tableData.length; j++) {
if (this.tableData[j].subPurchaseOrderSn == sn) {
this.tableData[j].robTotal ++;
for (let j = 0; j < this.choosedList.length; j++) {
if (this.choosedList[j].subPurchaseOrderSn == sn) {
this.choosedList[j].robTotal ++;
break;
}
}
}
})
},
sendSms(productName) {
this.$http.post(`/api/sms/sendSuccessSms`, null, {
addSuccessInfo(obj) {
this.$http.post(`/api/successInfo/add`, null, {
params: {
productName: productName
productName: obj.productName,
subPurchaseOrderSn: obj.subPurchaseOrderSn,
mallId: obj.mallId,
mallName: obj.mallName,
categoryName: obj.category
}
}).then(res => {
console.log(res)
})
},
sendNotification(productName) {
sendChromeNotification({productName: productName})
sendNotification(obj) {
sendChromeNotification({productName: obj.productName, mallName: obj.mallName})
}
}
}