Commit 40893ecc authored by Scott Sun's avatar Scott Sun

s

parent 0b111932
node_modules
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "turncam",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"babel": "babel src --out-dir dist -w",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@babel/cli": "^7.13.14",
"@babel/core": "^7.13.14",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.13.12",
"babel-plugin-transform-class-properties": "^6.24.1",
"core-js": "^3.10.0"
},
"babel": {
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": 3
}
]
],
"plugins": [
"@babel/plugin-syntax-class-properties",
"transform-class-properties"
]
}
}
/*
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>
*/
// 引入模块 包 外部参数
let $ = require('topcam.scriptfunc').argv();
let fs = require("fs");
let _ = require('lodash');
let mode = $.ikm ? "topcam" : "aimdfm";
if(!$.ikm) {
$.ikm = require('topcam.ikm6')($)
}
let IKM = $.ikm;
let GEN = $.gen;
let Job = $.job || $.job_name;
let JobId = $.job_id;
let db = $.db || IKM.db;
let gui_piug = require('topsin.gengui');
let GUI = gui_piug.newGui(gui_piug.__dirname);
let 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 }
})
}
let Status = 'ok';
let resultData = [];
let par = PAR; // 接收参数
let default_par = { // 设置默认参数
step: "orig",
auto_save: "No",
units: "mm"
}
for (let key in default_par) {
if (!par.hasOwnProperty(key) || par[key] == "") {
par[key] = default_par[key]
}
}
// 定义变量;
let 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"});
}
let obj = {
name: "123"
}
obj = { ... obj, age: 1}
IKM.msg(obj);
let arr = [1, 2, [3, 4]]
IKM.msg(arr.flat())
class Person {
name;
constructor (props){
this.name = props.name
}
}
let p = new Person({name:"a"})
IKM.msg(p)
// 保存料号
if (/yes/ig.test(par.auto_save)) {
GEN.checkInout({ job, mode: "out" });
GEN.saveJob({ job });
GEN.checkInout({ job, mode: "in" });
}
// 结尾返回 固定写法
let Return = "Done"
if (mode === "aimdfm") {
IKM.crud("updateRow", {
table: "pdm_aimdfm_task",
data: { progress: 100 },
where: { id: $.task_id }
})
let 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(props = {}){
let matrix = GEN.getMatrix({job:job})
return Object.keys(matrix).reduce((a,b)=>{
let info = matrix[b];
let ret = true;
for (let 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]))){
let 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
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