@@ -251,6 +251,7 @@
class = "w-16 p-1 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"
class = "w-16 p-1 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"
id = "BoardWidth"
id = "BoardWidth"
type = "number"
type = "number"
step = "0.01"
value = "10"
value = "10"
/ >
/ >
< span class = "text-gray-700" > CM × 宽(y)< / span >
< span class = "text-gray-700" > CM × 宽(y)< / span >
@@ -258,6 +259,7 @@
class = "w-16 p-1 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"
class = "w-16 p-1 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"
id = "BoardHeight"
id = "BoardHeight"
type = "number"
type = "number"
step = "0.01"
value = "10"
value = "10"
/ >
/ >
< span class = "text-gray-700" > CM, 数量< / span >
< span class = "text-gray-700" > CM, 数量< / span >
@@ -853,6 +855,12 @@
>
>
删除预设
删除预设
< / button >
< / button >
< button
class = "px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors duration-200 ease-in-out"
id = "saveToPCB"
>
内嵌预设
< / button >
< / div >
< / div >
< / div >
< / div >
@@ -1376,6 +1384,18 @@
< script >
< script >
document . addEventListener ( 'DOMContentLoaded' , ( ) => {
document . addEventListener ( 'DOMContentLoaded' , ( ) => {
eda . pcb _Layer . getAllLayers ( ) . then ( ( layers ) => {
const data _layer = layers . filter ( ( layer ) => layer . id >= 71 && layer . id <= 270 && layer . name . startsWith ( '【勿动】捷配下单数据' ) ) ;
if ( data _layer . length === 0 ) {
return ;
}
const craft _data = JSON . parse ( data _layer [ 0 ] . name . split ( '=' ) [ 1 ] ) ;
// console.log(craft_data);
presetList [ 'InnerData' ] = craft _data ;
autoSetupPreset ( 'InnerData' ) ;
eda . sys _Message . showToastMessage ( '成功读取内嵌预设' , 'success' ) ;
} ) ;
setupRadioGroup ( 'proCategory' , 'proCategory' , 'fr4Item' , updateBoardCraft ) ;
setupRadioGroup ( 'proCategory' , 'proCategory' , 'fr4Item' , updateBoardCraft ) ;
updateBoardCraft ( document . getElementById ( 'proCategory' ) . getValue ( ) ) ;
updateBoardCraft ( document . getElementById ( 'proCategory' ) . getValue ( ) ) ;
setupRadioGroup ( 'BoardLayers' , 'BoardLayers' , '2' ) ;
setupRadioGroup ( 'BoardLayers' , 'BoardLayers' , '2' ) ;
@@ -1464,8 +1484,6 @@
const WhitePaperService = document . querySelector ( 'input[name="WhitePaperService"]:checked' ) ? . value || '' ;
const WhitePaperService = document . querySelector ( 'input[name="WhitePaperService"]:checked' ) ? . value || '' ;
const IsNoneFont = document . querySelector ( 'input[name="IsNoneFont"]:checked' ) ? . value || '' ;
const IsNoneFont = document . querySelector ( 'input[name="IsNoneFont"]:checked' ) ? . value || '' ;
// 拼接 url: https://www.jiepei.com/pcb/pcbquote?proCategory=fr4Item&BoardHeight=10&BoardWidth=10&num=4&BoardLayers=2&BoardType=set&BoardThickness=2
let url = ` https://www.jiepei.com/pcb/pcbquote?proCategory= ${ encodeURIComponent ( proCategory ) } &BoardHeight= ${ encodeURIComponent ( boardHeight ) } &BoardWidth= ${ encodeURIComponent ( boardWidth ) } &num= ${ encodeURIComponent ( num ) } &BoardLayers= ${ encodeURIComponent ( boardLayers ) } &BoardType= ${ encodeURIComponent ( boardType ) } &OrderStage= ${ encodeURIComponent ( orderStage ) } ` ;
let url = ` https://www.jiepei.com/pcb/pcbquote?proCategory= ${ encodeURIComponent ( proCategory ) } &BoardHeight= ${ encodeURIComponent ( boardHeight ) } &BoardWidth= ${ encodeURIComponent ( boardWidth ) } &num= ${ encodeURIComponent ( num ) } &BoardLayers= ${ encodeURIComponent ( boardLayers ) } &BoardType= ${ encodeURIComponent ( boardType ) } &OrderStage= ${ encodeURIComponent ( orderStage ) } ` ;
url += mixedCategory ? ` &MixedCategory= ${ encodeURIComponent ( mixedCategory ) } ` : '' ;
url += mixedCategory ? ` &MixedCategory= ${ encodeURIComponent ( mixedCategory ) } ` : '' ;
@@ -1496,6 +1514,17 @@
url += WhitePaperService ? ` &WhitePaperService= ${ encodeURIComponent ( WhitePaperService ) } ` : '' ;
url += WhitePaperService ? ` &WhitePaperService= ${ encodeURIComponent ( WhitePaperService ) } ` : '' ;
url += IsNoneFont ? ` &IsNoneFont= ${ encodeURIComponent ( IsNoneFont ) } ` : '' ;
url += IsNoneFont ? ` &IsNoneFont= ${ encodeURIComponent ( IsNoneFont ) } ` : '' ;
// 保存制板文件
eda . pcb _ManufactureData . getGerberFile ( ) . then ( ( file ) => {
eda . dmt _Board . getCurrentBoardInfo ( ) . then ( ( board ) => {
const board _name = board . name ;
const pcb _name = board . pcb . name ;
const date = new Date ( ) ;
const file _name = ` ${ board _name } _ ${ pcb _name } _ ${ date . getFullYear ( ) } - ${ date . getMonth ( ) } - ${ date . getDate ( ) } .zip ` ;
eda . sys _FileSystem . saveFile ( file , file _name ) ;
} ) ;
} ) ;
// 打开新窗口
// 打开新窗口
// window.open(url, '_blank');
// window.open(url, '_blank');
dialog (
dialog (
@@ -1532,8 +1561,8 @@
const BBox = await eda . pcb _Primitive . getPrimitivesBBox ( [ selectedPrimitives [ 0 ] . getState _PrimitiveId ( ) ] ) ;
const BBox = await eda . pcb _Primitive . getPrimitivesBBox ( [ selectedPrimitives [ 0 ] . getState _PrimitiveId ( ) ] ) ;
const boardHeight = eda . sys _Unit . milToMm ( BBox . maxY - BBox . minY - 10 ) / 10 ;
const boardHeight = eda . sys _Unit . milToMm ( BBox . maxY - BBox . minY - 10 ) / 10 ;
const boardWidth = eda . sys _Unit . milToMm ( BBox . maxX - BBox . minX - 10 ) / 10 ;
const boardWidth = eda . sys _Unit . milToMm ( BBox . maxX - BBox . minX - 10 ) / 10 ;
document . getElementById ( 'BoardHeight' ) . value = boardHeight ;
document . getElementById ( 'BoardHeight' ) . value = boardHeight . toFixed ( 2 ) ;
document . getElementById ( 'BoardWidth' ) . value = boardWidth ;
document . getElementById ( 'BoardWidth' ) . value = boardWidth . toFixed ( 2 ) ;
eda . sys _Message . showToastMessage ( '已自动识别板子大小' , 'success' ) ;
eda . sys _Message . showToastMessage ( '已自动识别板子大小' , 'success' ) ;
} else {
} else {
eda . sys _Message . showToastMessage ( '所选图元非板框' , 'error' ) ;
eda . sys _Message . showToastMessage ( '所选图元非板框' , 'error' ) ;
@@ -1550,7 +1579,6 @@
} ) ;
} ) ;
function dialog ( title , content , cmd ) {
function dialog ( title , content , cmd ) {
// tailwind css 实现,带半透明背景
let dialogHtml = `
let dialogHtml = `
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity z-50" id="dialogOverlay">
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity z-50" id="dialogOverlay">
<div class="flex items-center justify-center min-h-screen">
<div class="flex items-center justify-center min-h-screen">
@@ -1996,6 +2024,45 @@
setupRadioGroup ( 'FlyingProbe' , 'FlyingProbe' , selectedFlyingProbe ) ;
setupRadioGroup ( 'FlyingProbe' , 'FlyingProbe' , selectedFlyingProbe ) ;
setupRadioGroup ( 'SurfaceFinish' , 'SurfaceFinish' , selectedSurfaceFinish ) ;
setupRadioGroup ( 'SurfaceFinish' , 'SurfaceFinish' , selectedSurfaceFinish ) ;
}
}
function getAllBoardCreaft ( ) {
return {
proCategory : document . querySelector ( 'input[name="proCategory"]:checked' ) ? . value || '' ,
BoardHeight : document . getElementById ( 'BoardHeight' ) . value ,
BoardWidth : document . getElementById ( 'BoardWidth' ) . value ,
num : document . getElementById ( 'num' ) . value ,
MixedCategory : document . querySelector ( 'input[name="MixedCategory"]:checked' ) ? . value || '' ,
BoardLayers : document . querySelector ( 'input[name="BoardLayers"]:checked' ) ? . value || '' ,
BoardType : document . querySelector ( 'input[name="BoardType"]:checked' ) ? . value || '' ,
OrderStage : document . querySelector ( 'input[name="OrderStage"]:checked' ) ? . value || '' ,
BoardThickness : document . querySelector ( 'input[name="BoardThickness"]:checked' ) ? . value || '' ,
CopperThickness : document . querySelector ( 'input[name="CopperThickness"]:checked' ) ? . value || '' ,
InnerCopperThickness : document . querySelector ( 'input[name="InnerCopperThickness"]:checked' ) ? . value || '' ,
AluminumType : document . querySelector ( 'input[name="AluminumType"]:checked' ) ? . value || '' ,
CopperStructure : document . querySelector ( 'input[name="CopperStructure"]:checked' ) ? . value || '' ,
Invoice : document . querySelector ( 'input[name="Invoice"]:checked' ) ? . value || '' ,
SolderColor : document . querySelector ( 'input[name="SolderColor"]:checked' ) ? . value || '' ,
FontColor : document . querySelector ( 'input[name="FontColor"]:checked' ) ? . value || '' ,
LineWeight : document . querySelector ( 'input[name="LineWeight"]:checked' ) ? . value || '' ,
Vias : document . querySelector ( 'input[name="Vias"]:checked' ) ? . value || '' ,
SolderCover : document . querySelector ( 'input[name="SolderCover"]:checked' ) ? . value || '' ,
FlyingProbe : document . querySelector ( 'input[name="FlyingProbe"]:checked' ) ? . value || '' ,
SurfaceFinish : document . querySelector ( 'input[name="SurfaceFinish"]:checked' ) ? . value || '' ,
ImGoldThinckness : document . querySelector ( 'input[name="ImGoldThinckness"]:checked' ) ? . value || '' ,
HalfHole : document . querySelector ( 'input[name="HalfHole"]:checked' ) ? . value || '' ,
HoleThickness _ : document . querySelector ( 'input[name="HoleThickness_"]:checked' ) ? . value || '' ,
ImpedanceSize : document . querySelector ( 'input[name="ImpedanceSize"]:checked' ) ? . value || '' ,
WithstandVoltage : document . querySelector ( 'input[name="WithstandVoltage"]:checked' ) ? . value || '' ,
QualityCompensation : document . querySelector ( 'input[name="QualityCompensation"]:checked' ) ? . value || '' ,
LowResistanceTest : document . querySelector ( 'input[name="LowResistanceTest"]:checked' ) ? . value || '' ,
ProductFileSure : document . querySelector ( 'input[name="ProductFileSure"]:checked' ) ? . value || '' ,
ReportMaterial : document . querySelector ( 'input[name="ReportMaterial"]:checked' ) ? . value || '' ,
GongBoundaryTolerance : document . querySelector ( 'input[name="GongBoundaryTolerance"]:checked' ) ? . value || '' ,
PanelAppearanceRequire : document . querySelector ( 'input[name="PanelAppearanceRequire"]:checked' ) ? . value || '' ,
WhitePaperService : document . querySelector ( 'input[name="WhitePaperService"]:checked' ) ? . value || '' ,
IsNoneFont : document . querySelector ( 'input[name="IsNoneFont"]:checked' ) ? . value || '' ,
} ;
}
< / script >
< / script >
< script >
< script >
@@ -2058,43 +2125,7 @@
document . getElementById ( 'savePreset' ) . addEventListener ( 'click' , ( ) => {
document . getElementById ( 'savePreset' ) . addEventListener ( 'click' , ( ) => {
if ( presetName ) {
if ( presetName ) {
presetList [ presetName ] = {
presetList [ presetName ] = getAllBoardCreaft ( ) ;
proCategory : document . querySelector ( 'input[name="proCategory"]:checked' ) ? . value || '' ,
BoardHeight : document . getElementById ( 'BoardHeight' ) . value ,
BoardWidth : document . getElementById ( 'BoardWidth' ) . value ,
num : document . getElementById ( 'num' ) . value ,
MixedCategory : document . querySelector ( 'input[name="MixedCategory"]:checked' ) ? . value || '' ,
BoardLayers : document . querySelector ( 'input[name="BoardLayers"]:checked' ) ? . value || '' ,
BoardType : document . querySelector ( 'input[name="BoardType"]:checked' ) ? . value || '' ,
OrderStage : document . querySelector ( 'input[name="OrderStage"]:checked' ) ? . value || '' ,
BoardThickness : document . querySelector ( 'input[name="BoardThickness"]:checked' ) ? . value || '' ,
CopperThickness : document . querySelector ( 'input[name="CopperThickness"]:checked' ) ? . value || '' ,
InnerCopperThickness : document . querySelector ( 'input[name="InnerCopperThickness"]:checked' ) ? . value || '' ,
AluminumType : document . querySelector ( 'input[name="AluminumType"]:checked' ) ? . value || '' ,
CopperStructure : document . querySelector ( 'input[name="CopperStructure"]:checked' ) ? . value || '' ,
Invoice : document . querySelector ( 'input[name="Invoice"]:checked' ) ? . value || '' ,
SolderColor : document . querySelector ( 'input[name="SolderColor"]:checked' ) ? . value || '' ,
FontColor : document . querySelector ( 'input[name="FontColor"]:checked' ) ? . value || '' ,
LineWeight : document . querySelector ( 'input[name="LineWeight"]:checked' ) ? . value || '' ,
Vias : document . querySelector ( 'input[name="Vias"]:checked' ) ? . value || '' ,
SolderCover : document . querySelector ( 'input[name="SolderCover"]:checked' ) ? . value || '' ,
FlyingProbe : document . querySelector ( 'input[name="FlyingProbe"]:checked' ) ? . value || '' ,
SurfaceFinish : document . querySelector ( 'input[name="SurfaceFinish"]:checked' ) ? . value || '' ,
ImGoldThinckness : document . querySelector ( 'input[name="ImGoldThinckness"]:checked' ) ? . value || '' ,
HalfHole : document . querySelector ( 'input[name="HalfHole"]:checked' ) ? . value || '' ,
HoleThickness _ : document . querySelector ( 'input[name="HoleThickness_"]:checked' ) ? . value || '' ,
ImpedanceSize : document . querySelector ( 'input[name="ImpedanceSize"]:checked' ) ? . value || '' ,
WithstandVoltage : document . querySelector ( 'input[name="WithstandVoltage"]:checked' ) ? . value || '' ,
QualityCompensation : document . querySelector ( 'input[name="QualityCompensation"]:checked' ) ? . value || '' ,
LowResistanceTest : document . querySelector ( 'input[name="LowResistanceTest"]:checked' ) ? . value || '' ,
ProductFileSure : document . querySelector ( 'input[name="ProductFileSure"]:checked' ) ? . value || '' ,
ReportMaterial : document . querySelector ( 'input[name="ReportMaterial"]:checked' ) ? . value || '' ,
GongBoundaryTolerance : document . querySelector ( 'input[name="GongBoundaryTolerance"]:checked' ) ? . value || '' ,
PanelAppearanceRequire : document . querySelector ( 'input[name="PanelAppearanceRequire"]:checked' ) ? . value || '' ,
WhitePaperService : document . querySelector ( 'input[name="WhitePaperService"]:checked' ) ? . value || '' ,
IsNoneFont : document . querySelector ( 'input[name="IsNoneFont"]:checked' ) ? . value || '' ,
} ;
eda . sys _Storage . setExtensionUserConfig ( 'PresetList' , presetList ) ;
eda . sys _Storage . setExtensionUserConfig ( 'PresetList' , presetList ) ;
}
}
} ) ;
} ) ;
@@ -2111,10 +2142,29 @@
}
}
} ) ;
} ) ;
document . getElementById ( 'saveToPCB' ) . addEventListener ( 'click' , ( ) => {
eda . pcb _Layer . getAllLayers ( ) . then ( async ( layers ) => {
const property = {
name : '【勿动】捷配下单数据=' + JSON . stringify ( getAllBoardCreaft ( ) ) ,
color : '#881415' ,
transparency : 100 ,
} ;
const data _layer = layers . filter ( ( layer ) => layer . id >= 71 && layer . id <= 270 && layer . name . startsWith ( '【勿动】捷配下单数据' ) ) ;
const layer = data _layer . length === 0 ? await eda . pcb _Layer . addCustomLayer ( ) : data _layer [ 0 ] . id ;
eda . pcb _Layer . modifyLayer ( layer , property ) . then ( ( ) => {
dialog ( '成功' , '已将下单预设内嵌到PCB中, 请勿删除、修改标有【勿动】字样的层, 下次打开扩展将自动识别' ) ;
} ) ;
} ) ;
} ) ;
function showPresetList ( ) {
function showPresetList ( ) {
const presetListContainer = document . getElementById ( 'PresetList' ) ;
const presetListContainer = document . getElementById ( 'PresetList' ) ;
presetListContainer . innerHTML = '' ; // 清空现有内容
presetListContainer . innerHTML = '' ; // 清空现有内容
for ( const name in presetList ) {
for ( const name in presetList ) {
if ( name === 'InnerData' ) continue ;
const iconList = {
const iconList = {
'fr4Item' : '/iframe/img/img_pro_FR4.png' ,
'fr4Item' : '/iframe/img/img_pro_FR4.png' ,
'rogersItem' : '/iframe/img/img_pro_Rogers.png' ,
'rogersItem' : '/iframe/img/img_pro_Rogers.png' ,