Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
T
topjs3 study
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Scott Sun
topjs3 study
Commits
0aa051d4
Commit
0aa051d4
authored
Apr 02, 2021
by
Scott Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s
parent
40893ecc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
289 additions
and
24 deletions
+289
-24
template_es6+.js
turncam/dist/template_es6+.js
+268
-0
template_es6+.js
turncam/src/template_es6+.js
+21
-24
No files found.
turncam/dist/template_es6+.js
0 → 100644
View file @
0aa051d4
"use strict"
;
require
(
"core-js/modules/es.array.join.js"
);
require
(
"core-js/modules/es.object.to-string.js"
);
require
(
"core-js/modules/es.regexp.to-string.js"
);
require
(
"core-js/modules/es.date.to-string.js"
);
require
(
"core-js/modules/es.array.reduce.js"
);
require
(
"core-js/modules/es.object.keys.js"
);
require
(
"core-js/modules/es.regexp.constructor.js"
);
require
(
"core-js/modules/es.regexp.exec.js"
);
/*
NAME:
DESCRIPTION: 描述;
PARAMETER:
[
{
name : 'step',
title : 'step',
type : 'LineEdit',
property : {tool_tip : '目标step,默认是orig'}
},
{
name : 'auto_save',
title : '自动保存',
type : 'RadioBox',
property : {
item_list:[
{name:'yes',text:'YES'},
{name:'no',text:'NO'},
],
tool_tip:'是否自动保存料号开关'
}
}
]
VERSION_HISTORY:
V1.00 2021-03-08 Scott Sun
1.新版本
HELP:
<html><body bgcolor="#DDECFE">
<font size="3" color="#003DB2"><p>功能简介</p></font>
<p> 标题 </ p>
<br>
<font size="3" color="#003DB2"><p>参数配置</p></font>
<p> step信息 </p>
<br>
<font size="3" color="#003DB2"><p>注意事项</p></font>
<p> 无 </p>
<br>
</body></html>
*/
// 引入模块 包 外部参数
var
$
=
require
(
'topcam.scriptfunc'
).
argv
();
var
fs
=
require
(
"fs"
);
var
_
=
require
(
'lodash'
);
var
mode
=
$
.
ikm
?
"topcam"
:
"aimdfm"
;
if
(
!
$
.
ikm
)
{
$
.
ikm
=
require
(
'topcam.ikm6'
)(
$
);
}
var
IKM
=
$
.
ikm
;
var
GEN
=
$
.
gen
;
var
Job
=
$
.
job
||
$
.
job_name
;
var
JobId
=
$
.
job_id
;
var
db
=
$
.
db
||
IKM
.
db
;
var
GUI
=
$
.
gui
;
var
PAR
=
{};
if
(
$
.
par
)
{
PAR
=
$
.
par
;
}
else
if
(
$
.
hasOwnProperty
(
'script_parameter'
))
{
PAR
=
JSON
.
parse
(
$
.
script_parameter
);
}
if
(
mode
===
"aimdfm"
)
{
IKM
.
crud
(
"updateRow"
,
{
table
:
"pdm_aimdfm_task"
,
data
:
{
current_process_title
:
$
.
process_title
},
where
:
{
id
:
$
.
task_id
}
});
}
var
Status
=
'ok'
;
var
resultData
=
[];
var
par
=
PAR
;
// 接收参数
var
default_par
=
{
// 设置默认参数
step
:
"orig"
,
auto_save
:
"No"
,
units
:
"mm"
};
for
(
var
key
in
default_par
)
{
if
(
!
par
.
hasOwnProperty
(
key
)
||
par
[
key
]
==
""
)
{
par
[
key
]
=
default_par
[
key
];
}
}
// 定义变量;
var
job
=
Job
.
toLowerCase
();
try
{
// 常规验证 准备工作
if
(
!
GEN
.
isJobExists
({
job
:
job
}))
{
throw
"料号"
+
job
+
"不存在"
;
}
if
(
!
GEN
.
isJobOpen
({
job
:
job
}))
{
GEN
.
openJob
({
job
:
job
});
}
if
(
mode
==
"aimdfm"
)
{
if
(
GEN
.
checkInout
({
job
:
job
,
mode
:
"test"
})
!=
0
)
{
throw
"the job check"
;
}
GEN
.
checkInout
({
job
:
job
,
mode
:
"out"
});
}
IKM
.
msg
(
IKM
.
command
(
"function(props){
\n
\
t
\
treturn GUI.showForm({
\n
\
t
\
t
\
t'title':
\"
Add Script
\"
,
\n
\
t
\
t
\
t'use_core_engine': true,
\n
\
t
\
t
\
t'size': '400x300',
\n
\
t
\
t
\
t'items': {
\n
\
t
\
t
\
t
\
tname:
\"
user
\"
,
\n
\
t
\
t
\
t
\
ttype:
\"
LineEdit
\"
,
\n
\
t
\
t
\
t
\
ttitle:
\"
User
\"
,
\n
\
t
\
t
\
t
\
tproperty:{},
\n
\
t
\
t
\
t
\
tpack:{
\n
\
t
\
t
\
t
\
t
\
tlabel:
\"
User
\"\n
\
t
\
t
\
t
\
t}
\n
\
t
\
t
\
t},
\n
\
t
\
t
\
t'values':{
\n
\
t
\
t
\
t
\
t'user':'TestUserName'
\n
\
t
\
t
\
t},
\n
\
t
\
t
\
t'include_hidden_items': true,
\n
\
t
\
t})
\n
\
t}"
,
{},
1
).
data
);
// 保存料号
if
(
/yes/ig
.
test
(
par
.
auto_save
))
{
GEN
.
checkInout
({
job
:
job
,
mode
:
"out"
});
GEN
.
saveJob
({
job
:
job
});
GEN
.
checkInout
({
job
:
job
,
mode
:
"in"
});
}
// 结尾返回 固定写法
var
Return
=
"Done"
;
if
(
mode
===
"aimdfm"
)
{
IKM
.
crud
(
"updateRow"
,
{
table
:
"pdm_aimdfm_task"
,
data
:
{
progress
:
100
},
where
:
{
id
:
$
.
task_id
}
});
var
tmperr
=
{
type
:
"info"
,
title
:
"操作完成, 请注意检查!"
};
if
(
GEN
.
hasError
())
{
Status
=
'error'
;
tmperr
=
{
type
:
"error"
,
title
:
"GEN错误!"
,
detail
:
[{
desc
:
GEN
.
STATUS
.
join
(
"
\n
"
)
}]
};
}
resultData
.
push
(
tmperr
);
Return
=
{
status
:
Status
,
result_data
:
resultData
};
}
_Return_Label_
=
Return
;
}
catch
(
e
)
{
if
(
GEN
.
STATUS
.
length
>
0
)
{
IKM
.
msg
(
GEN
.
STATUS
.
join
(
"
\n
"
));
}
IKM
.
msg
(
e
);
Status
=
'error'
;
resultData
.
push
({
type
:
"error"
,
title
:
"脚本执行出错!"
,
detail
:
[{
desc
:
_
.
toString
(
e
)
}]
});
_Return_Label_
=
mode
===
"aimdfm"
?
{
status
:
Status
,
result_data
:
resultData
}
:
"Error"
;
}
/**
* 获取层别
* @param {Object} 过滤选项
* @returns {Array}
*/
function
getLayer
()
{
var
props
=
arguments
.
length
>
0
&&
arguments
[
0
]
!==
undefined
?
arguments
[
0
]
:
{};
var
matrix
=
GEN
.
getMatrix
({
job
:
job
});
return
Object
.
keys
(
matrix
).
reduce
(
function
(
a
,
b
)
{
var
info
=
matrix
[
b
];
var
ret
=
true
;
for
(
var
_key
in
props
)
{
if
(
info
[
_key
])
{
if
(
/object string|object number/ig
.
test
({}.
toString
.
call
(
props
[
_key
])))
{
if
(
props
[
_key
]
!=
info
[
_key
])
{
ret
=
false
;
}
}
if
(
/object RegExp/ig
.
test
({}.
toString
.
call
(
props
[
_key
])))
{
var
reg
=
new
RegExp
(
props
[
_key
],
"ig"
);
if
(
!
reg
.
test
(
info
[
_key
]))
{
ret
=
false
;
}
}
if
(
/object function/ig
.
test
({}.
toString
.
call
(
props
[
_key
])))
{
if
(
!
props
[
_key
](
info
[
_key
]))
{
ret
=
false
;
}
}
}
}
if
(
ret
)
{
a
.
push
(
props
.
res
==
"info"
?
info
:
b
);
}
return
a
;
},
[]);
}
\ No newline at end of file
turncam/src/template_es6+.js
View file @
0aa051d4
...
@@ -54,8 +54,7 @@ let GEN = $.gen;
...
@@ -54,8 +54,7 @@ let GEN = $.gen;
let
Job
=
$
.
job
||
$
.
job_name
;
let
Job
=
$
.
job
||
$
.
job_name
;
let
JobId
=
$
.
job_id
;
let
JobId
=
$
.
job_id
;
let
db
=
$
.
db
||
IKM
.
db
;
let
db
=
$
.
db
||
IKM
.
db
;
let
gui_piug
=
require
(
'topsin.gengui'
);
let
GUI
=
$
.
gui
;
let
GUI
=
gui_piug
.
newGui
(
gui_piug
.
__dirname
);
let
PAR
=
{};
let
PAR
=
{};
if
(
$
.
par
)
{
PAR
=
$
.
par
}
else
if
(
$
.
hasOwnProperty
(
'script_parameter'
))
{
PAR
=
JSON
.
parse
(
$
.
script_parameter
);
}
if
(
$
.
par
)
{
PAR
=
$
.
par
}
else
if
(
$
.
hasOwnProperty
(
'script_parameter'
))
{
PAR
=
JSON
.
parse
(
$
.
script_parameter
);
}
if
(
mode
===
"aimdfm"
)
{
if
(
mode
===
"aimdfm"
)
{
...
@@ -93,29 +92,27 @@ try {
...
@@ -93,29 +92,27 @@ try {
GEN
.
checkInout
({
job
:
job
,
mode
:
"out"
});
GEN
.
checkInout
({
job
:
job
,
mode
:
"out"
});
}
}
IKM
.
msg
(
IKM
.
command
(
`function(props){
let
obj
=
{
return GUI.showForm({
name
:
"123"
'title': "Add Script",
}
'use_core_engine': true,
'size': '400x300',
obj
=
{
...
obj
,
age
:
1
}
'items': {
name:"user",
IKM
.
msg
(
obj
);
type:"LineEdit",
title:"User",
let
arr
=
[
1
,
2
,
[
3
,
4
]]
property:{},
pack:{
IKM
.
msg
(
arr
.
flat
())
label:"User"
}
class
Person
{
},
name
;
'values':{
constructor
(
props
){
'user':'TestUserName'
this
.
name
=
props
.
name
},
}
'include_hidden_items': true,
}
})
}`
,{},
1
).
data
)
let
p
=
new
Person
({
name
:
"a"
})
IKM
.
msg
(
p
)
// 保存料号
// 保存料号
if
(
/yes/ig
.
test
(
par
.
auto_save
))
{
if
(
/yes/ig
.
test
(
par
.
auto_save
))
{
GEN
.
checkInout
({
job
,
mode
:
"out"
});
GEN
.
checkInout
({
job
,
mode
:
"out"
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment