Commit c1a04b5c authored by liuyanfang's avatar liuyanfang

添加选项和时间选择

parent 5593231e
{
"name": "辅助发货易打单1.1.0",
"name": "菜芽-自动约单",
"version": "1.0.0",
"description": "辅助手机壳厂家打印发货易的快递单",
......@@ -10,7 +10,7 @@
"browser_action": {
"default_popup": "popup.html",
"default_icon": "icon.png",
"default_title": "辅助发货易打单"
"default_title": "菜芽-自动约单"
},
"icons": {
"128": "icon.png"
......
import { platformObj } from "../types";
let domEle = {
inputOrderId: document.querySelector("#orderFilterPane > div > form > ul > li:nth-child(4) > input") as HTMLInputElement,
......@@ -13,8 +14,13 @@ let domEle = {
btnClose: document.querySelector("#printEwaybillResultDialog > div > div > div.modal-footer > button.btn.btn-default") as HTMLButtonElement,
btnDeliver: document.querySelector("#printEwaybillResultDialog > div > div > div.modal-footer > button.btn.ship-now-btn") as HTMLButtonElement,
}
async function booking(wayCompanyId: string, orderNo: string) {
// 发货易订单类型:10淘宝;20拼多多;30分销淘宝;40分销拼多多;50分销抖店;60分销其他代发;
async function booking(wayCompanyId: string, orderNo: string,fhy_type:number) {
let checkOptionObj = platformObj
chrome.storage.local.get({ checkOptionObj: platformObj }, function (res) {
console.log('旧版app',res.checkOptionObj);
checkOptionObj = res.checkOptionObj
})
domEle.inputOrderId.value = orderNo;
domEle.checkBoxSelectAll.checked = true;
domEle.btnSearch.click();
......@@ -80,15 +86,20 @@ async function booking(wayCompanyId: string, orderNo: string) {
if(rowResultList.every((item:any)=>item.includes('打印失败'))){
chooseIndex = -1
}
console.log(result);
// 等会再发货
if(chooseIndex===-1){
console.log('等会再发货');
domEle.btnClose.click();
}else{
// 马上发货
console.log('马上发货');
domEle.btnDeliver.click()
if((fhy_type===10&&checkOptionObj['jiu-taobao'])||(fhy_type===20&&checkOptionObj['jiu-pdd'])){
// 马上发货
console.log('马上发货');
domEle.btnDeliver.click()
}else{
console.log('等会再发货');
domEle.btnClose.click();
}
}
return result;
}
......
import {PlatformCode} from "./index"
import { platformObj } from "../types";
let domEle = {
divNav:document.getElementsByClassName("nav-link") as HTMLCollection,
inputOrderId: "#originalIds",
......@@ -21,7 +23,12 @@ let domEle = {
deliverResult:():any=>document.querySelector(".ant-modal-body>div.ant-table-wrapper .ant-table-tbody"),
deliverClose: ():any=>document.querySelector("div.ant-modal-footer button") ,
}
async function booking(waybillTemplateTitle: string, orderNo: string,shopId:string) {
async function booking(waybillTemplateTitle: string, orderNo: string,shopId:string,fhy_type:number) {
let checkOptionObj = platformObj
chrome.storage.local.get({ checkOptionObj: platformObj }, function (res) {
console.log('新版V2',res.checkOptionObj);
checkOptionObj = res.checkOptionObj
})
let result = {
status: 4,
msg: "未找到店铺",
......@@ -131,12 +138,18 @@ async function booking(waybillTemplateTitle: string, orderNo: string,shopId:stri
}
// 等会再发货
if(chooseIndex===-1){
console.log('等会再发货');
console.log('等会再发货1');
simulateMouseClick(domEle.btnClose());
}else{
// 马上发货
console.log('马上发货');
simulateMouseClick(domEle.btnDeliver());
console.log('发货',fhy_type,checkOptionObj);
if((fhy_type===30&&checkOptionObj['xin-taobao'])||(fhy_type===40&&checkOptionObj['xin-pdd'])||(fhy_type===50&&checkOptionObj['xin-dy']||(fhy_type===60&&checkOptionObj['xin-other']))){
// 马上发货
console.log('马上发货');
simulateMouseClick(domEle.btnDeliver());
}else{
console.log('等会再发货2');
simulateMouseClick(domEle.btnClose());
}
}
await delayDate(1000);
// console.log('xxxx',domEle.deliverResult(),domEle.deliverClose());
......
......@@ -21,10 +21,12 @@ type Params = {
orderNo: string// 订单号
wayCompanyId: string// 快递公司的Id
platform: PlatformCode,// 平台编码,淘系及其他平台订单模板的为0,拼多多订单的为1,京东订单的为2
fhy_type:number
}& {
orderNo: string// 订单号
waybillTemplateTitle: string// 快递单模板
shopId: string,// 店铺Id
fhy_type:number
}
interface Response {
......@@ -192,7 +194,8 @@ const printWayBillByNew = function ({ orderNo, wayCompanyId, platform }: Pick<Pa
// web页面通信
window.addEventListener("message",function(message:any){
console.log(111111,message);
if(message.data.action == ACTION.BookingApp){
chrome.runtime.sendMessage(message.data,(ret)=>{
window.postMessage({isResult:1,...ret},"*")
......@@ -223,7 +226,7 @@ chrome.runtime.onMessage.addListener(function (message: Message, sender, respons
console.log("recive BookingV2",message);
let result=null;
(async () => {
result = await BookingV2.booking(message.value.waybillTemplateTitle,message.value.orderNo,message.value.shopId);
result = await BookingV2.booking(message.value.waybillTemplateTitle,message.value.orderNo,message.value.shopId,message.value.fhy_type);
response(result);
})();
......@@ -233,7 +236,7 @@ chrome.runtime.onMessage.addListener(function (message: Message, sender, respons
hookConfirm();
let result=null;
(async () => {
result = await BookingApp.booking(message.value.wayCompanyId,message.value.orderNo);
result = await BookingApp.booking(message.value.wayCompanyId,message.value.orderNo,message.value.fhy_type);
response(result);
})();
......
import React,{ useCallback, useContext, useEffect, useState } from "react";
import { Checkbox } from "antd";
const IsAutoEmit = function () {
const [checked, setChecked] = useState<boolean>(true)
import { platformObj } from "../../../types";
const changeRadio = useCallback((e) => {
setChecked(e.target.checked)
}, [])
const IsAutoEmit = function () {
let [checkObj, setChecked] = useState<any>({})
const changeRadio = useCallback((e,name:string) => {
const obj = {...checkObj,[name]:e.target.checked}
setChecked(obj)
}, [checkObj])
useEffect(() => {
chrome.storage.local.get({ isAutoEmit: false }, function (res) {
setChecked(res.isAutoEmit)
chrome.storage.local.get({ checkOptionObj: platformObj }, function (res) {
// console.log('checkOptionObj',res.checkOptionObj);
setChecked(res.checkOptionObj)
})
}, [])
useEffect(() => {
chrome.storage.local.set({isAutoEmit:checked})
},[checked])
// console.log('checkOptionObj11111111',checkObj);
chrome.storage.local.set({checkOptionObj:checkObj})
},[checkObj])
return <>
<span className="waybill-panel-title">自动发货</span>
<Checkbox checked={ checked } onChange={ changeRadio } style={ { marginLeft: "13px" } }>打印成功后自动发货</Checkbox>
<span className="waybill-panel-title">自动发货设置</span>
<span className="waybill-panel-title">旧版发货易</span>
<Checkbox checked={checkObj['jiu-taobao']} onChange={ (e) =>changeRadio(e,'jiu-taobao') } style={ { marginLeft: "13px" } }>淘宝-打印成功后自动发货</Checkbox>
<Checkbox checked={checkObj['jiu-pdd']} onChange={ (e) =>changeRadio(e,'jiu-pdd') } style={ { marginLeft: "13px" } }>拼多多-打印成功后自动发货</Checkbox>
<span className="waybill-panel-title">新版发货易</span>
<Checkbox checked={checkObj['xin-taobao']} onChange={ (e) =>changeRadio(e,'xin-taobao') } style={ { marginLeft: "13px" } }>淘宝-打印成功后自动发货</Checkbox>
<Checkbox checked={checkObj['xin-pdd']} onChange={ (e) =>changeRadio(e,'xin-pdd') } style={ { marginLeft: "13px" } }>拼多多-打印成功后自动发货</Checkbox>
<Checkbox checked={checkObj['xin-dy']} onChange={ (e) =>changeRadio(e,'xin-dy') } style={ { marginLeft: "13px" } }>抖音-打印成功后自动发货</Checkbox>
<Checkbox checked={checkObj['xin-other']} onChange={ (e) =>changeRadio(e,'xin-other') } style={ { marginLeft: "13px" } }>其他-打印成功后自动发货</Checkbox>
</>
}
......
......@@ -14,6 +14,7 @@ interface Item {
}
type List = Item[]
//
const AllWayCompany = [
{ name: "圆通速递", value: "YTO" }
......
import React,{ useCallback, useContext, useEffect, useState } from "react";
import { TimePicker } from "antd";
import type { Moment } from 'moment';
import moment from 'moment';
const format = 'HH:mm';
const Timer = function () {
const [value, setValue] = useState<Moment | null>(null);
const [pro_value, setProValue] = useState<Moment | null>(null);
const onChange = (time:any) => {
setValue(time);
};
const onChangePro =(time:any) => {
setProValue(time);
};
useEffect(() => {
chrome.storage.local.get({ AutoTime:null,proAutoTime:null }, function (res) {
console.log(res.AutoTime,res.proAutoTime);
if(res.AutoTime){
setValue(moment(res.AutoTime, 'HH:mm'))
window.postMessage({AutoTime:res.AutoTime})
// chrome.runtime.sendMessage({AutoTime:res.AutoTime})
}
if(res.proAutoTime){
setProValue(moment(res.proAutoTime, 'HH:mm'))
window.postMessage({proAutoTime:res.proAutoTime})
// chrome.runtime.sendMessage({proAutoTime:res.proAutoTime})
}
})
}, [])
useEffect(() => {
if(value){
let time = moment(value).format('HH:mm')
chrome.storage.local.set({AutoTime:time})
window.postMessage({AutoTime:time})
// chrome.runtime.sendMessage({AutoTime:time})
}
if(pro_value){
let pro_time = moment(pro_value).format('HH:mm')
chrome.storage.local.set({proAutoTime:pro_time})
window.postMessage({proAutoTime:pro_time})
// chrome.runtime.sendMessage({proAutoTime:pro_time})
}
},[value,pro_value])
return <>
<span className="waybill-panel-title">自动约单的时间间隔</span>
<div className="picker"><TimePicker value={value} onChange={onChange} format={format}/></div>
<span className="waybill-panel-title">自动生成生产图的时间间隔</span>
<div className="picker"><TimePicker value={pro_value} onChange={onChangePro} format={format}/></div>
</>
}
export default Timer
\ No newline at end of file
......@@ -4,7 +4,7 @@
justify-content: flex-start;
align-items: stretch;
height:400px;
width: 800px;
width: 400px;
.popup-page-title{
padding:10px 0;
font-size: 16px;
......@@ -25,4 +25,10 @@
}
}
.waybill-bottom{
padding-bottom: 40px;
.picker{
margin-left: 10px;
}
}
}
\ No newline at end of file
import React from "react";
import WayBillModel from "./components/WayBillModel";
import IsAutoEmit from "./components/IsAutoEmit";
import Timer from "./components/timer";
import "./popup.scss"
......@@ -9,17 +10,20 @@ const Popup = function () {
return (
<div className="popup-page">
{/* <span className="popup-page-title">打单设置</span>
<div className="waybill-panel">
<span className="popup-page-title">打单设置</span>
{/* <div className="waybill-panel">
<span className="waybill-panel-title">电子面单模板</span>
<div className="waybill-model-wrap">
<WayBillModel />
</div>
</div>
</div> */}
<div className="waybill-panel">
<IsAutoEmit />
</div> */}
</div>
<div className="waybill-panel waybill-bottom">
<Timer />
</div>
</div>
)
}
......
......@@ -9,7 +9,14 @@ export enum ACTION{
BookingApp="BookingApp"
}
export const platformObj ={
'jiu-taobao':false,
'jiu-pdd': false,
'xin-taobao': false,
'xin-pdd': false,
'xin-dy': false,
'xin-other': false,
}
export const StartPrint = "StartPrint"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment