backup: 完成 HR_position_ 表格前綴重命名與欄位對照表整理
變更內容: - 所有資料表加上 HR_position_ 前綴 - 整理完整欄位顯示名稱與 ID 對照表 - 模組化 JS 檔案 (admin.js, ai.js, csv.js 等) - 專案結構優化 (docs/, scripts/, tests/ 等) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
78
scripts/extract_dropdown_data.py
Normal file
78
scripts/extract_dropdown_data.py
Normal file
@@ -0,0 +1,78 @@
|
||||
"""
|
||||
從 excel_table copy.md 提取下拉選單資料
|
||||
"""
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
|
||||
# 讀取文件
|
||||
with open('excel_table copy.md', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 解析表格
|
||||
lines = content.strip().split('\n')
|
||||
data = []
|
||||
|
||||
for line in lines[2:]: # 跳過標題和分隔線
|
||||
if line.strip():
|
||||
# 使用正則表達式分割,處理可能的空白單元格
|
||||
cols = [col.strip() for col in line.split('|')[1:-1]] # 去掉首尾的空字符串
|
||||
if len(cols) == 4:
|
||||
data.append({
|
||||
'事業體': cols[0],
|
||||
'處級單位': cols[1],
|
||||
'部級單位': cols[2],
|
||||
'崗位名稱': cols[3]
|
||||
})
|
||||
|
||||
# 提取唯一值並保持順序
|
||||
business_units = list(OrderedDict.fromkeys([d['事業體'] for d in data if d['事業體']]))
|
||||
dept_level1 = list(OrderedDict.fromkeys([d['處級單位'] for d in data if d['處級單位']]))
|
||||
dept_level2 = list(OrderedDict.fromkeys([d['部級單位'] for d in data if d['部級單位']]))
|
||||
position_names = list(OrderedDict.fromkeys([d['崗位名稱'] for d in data if d['崗位名稱']]))
|
||||
|
||||
print("=" * 80)
|
||||
print("資料統計")
|
||||
print("=" * 80)
|
||||
print(f"總資料筆數: {len(data)}")
|
||||
print(f"事業體數量: {len(business_units)}")
|
||||
print(f"處級單位數量: {len(dept_level1)}")
|
||||
print(f"部級單位數量: {len(dept_level2)}")
|
||||
print(f"崗位名稱數量: {len(position_names)}")
|
||||
print()
|
||||
|
||||
# 生成 JavaScript 數組
|
||||
js_business_units = f"const businessUnits = {business_units};"
|
||||
js_dept_level1 = f"const deptLevel1Units = {dept_level1};"
|
||||
js_dept_level2 = f"const deptLevel2Units = {dept_level2};"
|
||||
js_position_names = f"const positionNames = {position_names};"
|
||||
|
||||
print("=" * 80)
|
||||
print("JavaScript 數組 (複製以下內容)")
|
||||
print("=" * 80)
|
||||
print()
|
||||
print("// 事業體")
|
||||
print(js_business_units)
|
||||
print()
|
||||
print("// 處級單位")
|
||||
print(js_dept_level1)
|
||||
print()
|
||||
print("// 部級單位")
|
||||
print(js_dept_level2)
|
||||
print()
|
||||
print("// 崗位名稱")
|
||||
print(js_position_names)
|
||||
print()
|
||||
|
||||
# 儲存到文件
|
||||
with open('dropdown_data.js', 'w', encoding='utf-8') as f:
|
||||
f.write("// 自動生成的下拉選單資料\n\n")
|
||||
f.write("// 事業體\n")
|
||||
f.write(js_business_units + "\n\n")
|
||||
f.write("// 處級單位\n")
|
||||
f.write(js_dept_level1 + "\n\n")
|
||||
f.write("// 部級單位\n")
|
||||
f.write(js_dept_level2 + "\n\n")
|
||||
f.write("// 崗位名稱\n")
|
||||
f.write(js_position_names + "\n")
|
||||
|
||||
print("已儲存到 dropdown_data.js")
|
||||
Reference in New Issue
Block a user