template_es6+.js 3.87 KB
Newer Older
Scott Sun's avatar
s  
Scott Sun committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/*
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>	
*/
function o(t,e){var r,o=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)),o}function e(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){a(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function i(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}var t=require("topcam.scriptfunc").argv(),s=require("fs"),c=require("lodash"),u=t.ikm?"topcam":"aimdfm";t.ikm||(t.ikm=require("topcam.ikm6")(t));var b=t.ikm,p=t.gen,m=t.job||t.job_name,f=t.job_id,d=t.db||b.db,l=t.gui,g={};t.par?g=t.par:t.hasOwnProperty("script_parameter")&&(g=JSON.parse(t.script_parameter)),"aimdfm"===u&&b.crud("updateRow",{table:"pdm_aimdfm_task",data:{current_process_title:t.process_title},where:{id:t.task_id}});var j,h="ok",y=[],O=g,_={step:"orig",auto_save:"No",units:"mm"};for(j in _)O.hasOwnProperty(j)&&""!=O[j]||(O[j]=_[j]);var v=m.toLowerCase();try{if(!p.isJobExists({job:v}))throw"料号"+v+"不存在";if(p.isJobOpen({job:v})||p.openJob({job:v}),"aimdfm"==u){if(0!=p.checkInout({job:v,mode:"test"}))throw"the job check";p.checkInout({job:v,mode:"out"})}var w={name:"xiaobai"},k=function(){function t(e){r(this,t),this.name=e.name,this.age=e.age,this.data=e.data}return i(t,[{key:"say",value:function(){b.msg("my age is ".concat(this.age,", my data is ").concat(c.toString(this.data)))}}]),t}(),S=[1,2,[3,4,5]],P=new k(e(e({},w),{},{age:18,data:S}));P.say(),/yes/gi.test(O.auto_save)&&(p.checkInout({job:v,mode:"out"}),p.saveJob({job:v}),p.checkInout({job:v,mode:"in"}));var E,T="Done";"aimdfm"===u&&(b.crud("updateRow",{table:"pdm_aimdfm_task",data:{progress:100},where:{id:t.task_id}}),E={type:"info",title:"操作完成, 请注意检查!"},p.hasError()&&(E={type:h="error",title:"GEN错误!",detail:[{desc:p.STATUS.join("\n")}]}),y.push(E),T={status:status,result_data:y});return T}catch(e){0<p.STATUS.length&&b.msg(p.STATUS.join("\n")),b.msg(e),y.push({type:h="error",title:"脚本执行出错!",detail:[{desc:c.toString(e)}]});return "aimdfm"===u?{status:h,result_data:y}:"Error"}function R(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},i=p.getMatrix({job:v});return Object.keys(i).reduce(function(e,t){var r,o=i[t],a=!0;for(r in n)o[r]&&(/object string|object number/gi.test({}.toString.call(n[r]))&&n[r]!=o[r]&&(a=!1),/object RegExp/gi.test({}.toString.call(n[r]))&&(new RegExp(n[r],"ig").test(o[r])||(a=!1)),/object function/gi.test({}.toString.call(n[r]))&&(n[r](o[r])||(a=!1)));return a&&e.push("info"==n.res?o:t),e},[])}