minor fixes
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
.venv/
|
/.venv
|
||||||
.vscode/
|
/.vscode
|
||||||
.workbooks/
|
/.workbooks
|
||||||
|
*.bat
|
||||||
*.xlsx
|
*.xlsx
|
||||||
*.xml
|
*.xml
|
||||||
47
销售订单自动导入.py
47
销售订单自动导入.py
@@ -87,7 +87,7 @@ def main(workbook=None):
|
|||||||
|
|
||||||
time.sleep(args.interval) #1
|
time.sleep(args.interval) #1
|
||||||
|
|
||||||
if data.tag == 'nil-classes': break
|
if data.tag in ['nil-classes', 'hash']: break
|
||||||
else: index += 1
|
else: index += 1
|
||||||
|
|
||||||
if root is None: root = data
|
if root is None: root = data
|
||||||
@@ -260,7 +260,10 @@ def main(workbook=None):
|
|||||||
print('[信息] 正在启动自动化程序')
|
print('[信息] 正在启动自动化程序')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
driver = webdriver.Chrome()
|
opts = webdriver.ChromeOptions()
|
||||||
|
opts.add_experimental_option("excludeSwitches", ["enable-logging"])
|
||||||
|
|
||||||
|
driver = webdriver.Chrome(opts)
|
||||||
driver.set_page_load_timeout(args.timeout)
|
driver.set_page_load_timeout(args.timeout)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'[!!!!] 初始化时发生了错误:{e}')
|
print(f'[!!!!] 初始化时发生了错误:{e}')
|
||||||
@@ -312,18 +315,19 @@ def main(workbook=None):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'[!!!!] 登录网页时发生了错误:{e}')
|
print(f'[!!!!] 登录网页时发生了错误:{e}')
|
||||||
return 81
|
return 81
|
||||||
else:
|
|
||||||
print("[警告] 未提供有效登录凭证")
|
print("[信息] 正在检测登录状态...")
|
||||||
key = input('[????] 请确认登录状态:已登录 (Y) / 取消操作 (N): ')
|
while True:
|
||||||
if key in ['Y', 'y']:
|
try:
|
||||||
print('[信息] 已确认操作')
|
driver.find_element(By.ID, 'container')
|
||||||
else:
|
print("[信息] 已登录")
|
||||||
print('[信息] 已取消操作')
|
break
|
||||||
return 0
|
except:
|
||||||
|
time.sleep(args.interval) #4
|
||||||
|
|
||||||
try:
|
try:
|
||||||
locate(".layout-sidebar ul li:nth-child(10) div div").click()
|
locate(".layout-sidebar ul li.list-none.cpq div div").click()
|
||||||
locate(".layout-sidebar .layout-second-menu li:nth-child(3) a").click()
|
locate(".layout-sidebar .layout-second-menu li.order a").click()
|
||||||
locate(".list-header-top button.okki-dropdown-trigger").click()
|
locate(".list-header-top button.okki-dropdown-trigger").click()
|
||||||
locate(".okki-dropdown-content button").click()
|
locate(".okki-dropdown-content button").click()
|
||||||
driver.switch_to.window(driver.window_handles[1])
|
driver.switch_to.window(driver.window_handles[1])
|
||||||
@@ -333,7 +337,7 @@ def main(workbook=None):
|
|||||||
|
|
||||||
# 状态菜单映射
|
# 状态菜单映射
|
||||||
status = { 'draft': 1, 'final': 6 }
|
status = { 'draft': 1, 'final': 6 }
|
||||||
time.sleep(args.interval) #4
|
time.sleep(args.interval) #5
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 变更状态
|
# 变更状态
|
||||||
@@ -351,7 +355,7 @@ def main(workbook=None):
|
|||||||
print(f'[!!!!] 上传文件时发生了错误:{e}')
|
print(f'[!!!!] 上传文件时发生了错误:{e}')
|
||||||
return 83
|
return 83
|
||||||
|
|
||||||
time.sleep(args.interval) #5
|
time.sleep(args.interval) #6
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 等待订单录入
|
# 等待订单录入
|
||||||
@@ -367,7 +371,7 @@ def main(workbook=None):
|
|||||||
return 84
|
return 84
|
||||||
|
|
||||||
# 设置每页显示记录数
|
# 设置每页显示记录数
|
||||||
time.sleep(args.interval) #6
|
time.sleep(args.interval) #7
|
||||||
url = driver.current_url
|
url = driver.current_url
|
||||||
param = f'%22page_size%22%3A{args.per_page}'
|
param = f'%22page_size%22%3A{args.per_page}'
|
||||||
|
|
||||||
@@ -381,11 +385,11 @@ def main(workbook=None):
|
|||||||
# 等待页面加载
|
# 等待页面加载
|
||||||
wait = WebDriverWait(driver, timeout=args.timeout)
|
wait = WebDriverWait(driver, timeout=args.timeout)
|
||||||
wait.until(lambda x: 'nprogress-busy' not in x.find_element(By.TAG_NAME, 'html').get_attribute('class'))
|
wait.until(lambda x: 'nprogress-busy' not in x.find_element(By.TAG_NAME, 'html').get_attribute('class'))
|
||||||
time.sleep(args.interval) #7
|
time.sleep(args.interval) #8
|
||||||
|
|
||||||
for idx in range(args.per_page):
|
for idx in range(args.per_page):
|
||||||
try:
|
try:
|
||||||
links = driver.find_elements(By.CSS_SELECTOR, ".list-frame-table .virtual-list-os-target .row-items .cell[data-cci='1'] a")
|
links = driver.find_elements(By.CSS_SELECTOR, ".list-frame-table .row-items .cell[data-cci='1'] a")
|
||||||
element = links[idx]
|
element = links[idx]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'[警告] 未找到记录: {e}')
|
print(f'[警告] 未找到记录: {e}')
|
||||||
@@ -422,7 +426,7 @@ def main(workbook=None):
|
|||||||
|
|
||||||
# 编辑运费
|
# 编辑运费
|
||||||
try:
|
try:
|
||||||
wrapper = locate(".order-edit-product-wrapper .virtual-list-os-target .row-items", condition=None)
|
wrapper = locate(".order-edit-product-wrapper .row-items", condition=None)
|
||||||
positions = lookup(number, '产品型号', workbook).unwrap()
|
positions = lookup(number, '产品型号', workbook).unwrap()
|
||||||
index = 0
|
index = 0
|
||||||
count = positions.count('port')
|
count = positions.count('port')
|
||||||
@@ -459,7 +463,7 @@ def main(workbook=None):
|
|||||||
button = locate(".order-edit-footer button.okki-btn-primary", condition=None)
|
button = locate(".order-edit-footer button.okki-btn-primary", condition=None)
|
||||||
driver.execute_script("arguments[0].click();", button)
|
driver.execute_script("arguments[0].click();", button)
|
||||||
|
|
||||||
time.sleep(args.interval) #8
|
time.sleep(args.interval) #9
|
||||||
print(f"[信息] {number}: 修改完成")
|
print(f"[信息] {number}: 修改完成")
|
||||||
modified.append(number)
|
modified.append(number)
|
||||||
|
|
||||||
@@ -513,8 +517,9 @@ class FieldArray[K, V]:
|
|||||||
|
|
||||||
def newrow(self, padding=None):
|
def newrow(self, padding=None):
|
||||||
for array in self.map.values():
|
for array in self.map.values():
|
||||||
if len(array) <= self.index:
|
limit = len(array) - 1
|
||||||
array.insert(self.index, padding)
|
delta = self.index - limit
|
||||||
|
array.extend([ padding for _ in range(delta) ])
|
||||||
self.index += 1
|
self.index += 1
|
||||||
|
|
||||||
class Result:
|
class Result:
|
||||||
|
|||||||
Reference in New Issue
Block a user