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

View File

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

View File

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