• 平台功能
  • 功能介绍
    • 配置文件
    • 系统函数
    • 组态图形
    • 页面集成
    • 功能扩展
    • SSL TLS
  • 本地部署
    • 数据库备份与还原
  • 协议处理
    • WebSocket
    • 国标协议
    • JT808协议
    • MQTT协议
    • OPC网关
    • 自定义协议(my)
    • 自定义协议(di)
    • 平台主动发给终端
    • 串口功能
    • 客户端功能
  • 完整案例演示
  • 系统函数源代码
  • 简洁的Ajax代码
  • 图形设计器
  • 图形运行时
  • 脚本函数
  • 图形控件
    • mypage(嵌入页面)
    • myui(UIKIT)
  • myechart(echarts控件)
  • 3D 相关
    • getcontext
    • getobject
    • getpoint
  • 函数源码
    文档主题
    https://twuyun.com/help/doc/0/index?id=61736ab2a5a79a1bac0c2c61
    功能
    模板管理图形管理脚本测试文档管理系统日志
    0

    组态图形

    组态图形是在浏览器中完全自定义的展示方式,可以做到无代码或很少的代码实现展示实时数据。

    图形设计器

    • 标准控件
    • 属性与动画
    • 动作脚本
    • 嵌入图形

    图形运行时

    • 自定义属性
    • 动画行为
    • 执行脚本

    脚本函数

    • 提供便于操作的内置函数以及可以直接调用js函数能力。用组件实例的名称可以操作组件行为。

    几个特殊变量功能:

    名称 说明
    this 获取到图形定义的自定义属性:this.自定义属性1
    me 获取到图形中脚本所在的组件:me.x; me.y; me.width;me.height; me.text; me.show();me.hide()
    $$.value 数据变化执行时,获取到变化量的值
    $$.time 数据变化执行时,获取到变化量的时间
    1. //位置
    2. me.x;me.y;me.width;me.height;
    3. //文本
    4. me.text
    5. //方法
    6. me.show();
    7. me.hide();
    8. //前后
    9. front(me);
    10. back(me);
    11. //在定义了组件的自定义函数后,也可以调用:
    12. me.自定义函数1();
    13. //动态将实例绑定到图形组件的属性上:
    14. //组件名.bind(组件属性,实例地址或表达式)
    15. Embed3.bind("显示值","/test/新实例.Interval")

    图形控件

    mypage(嵌入页面)

    图片alt

    利用iframe加载存在的网页

    属性:

    名称 说明
    地址 提供一个定义好的网页地址
    滚动条 是否加载滚动条
    加载完成后执行 加载完成后执行一段脚本

    特殊函数:

    名称 说明
    me.window() 获取iframe页面的window,这样可以调用该网页的js函数

    myui(UIKIT)

    该控件利用开源框架提供自定义展示内容:
    图片alt

    1. 支持elementplus https://element-plus.org/zh-CN/component/button.html
    2. 支持UIKIT http://www.uikitcss.com/doc/v3/getting-started/introduction.html

    属性:

    名称 说明
    HTML 提供运行的展示内容:可以是任意HTML
    脚本 提供设计的展示内容

    下面的body可以展示一个按钮

    1. <button type="button" name="mybutton" style="width:100%;height:100%;font-size:20px" onclick="me(this).setdata()">确定 {自定义属性1}</button>

    elementplus例子:
    直接在HTML属性中写:

    1. <template>
    2. <el-table :data="tableData" style="width: 100%">
    3. <el-table-column prop="date" label="Date" width="180" />
    4. <el-table-column prop="name" label="Name" width="180" />
    5. <el-table-column prop="address" label="Address" />
    6. </el-table>
    7. </template>
    8. <script lang="ts" setup>
    9. const tableData = [
    10. {
    11. date: '2016-05-03',
    12. name: 'Tom',
    13. address: 'No. 189, Grove St, Los Angeles',
    14. },
    15. {
    16. date: '2016-05-02',
    17. name: 'Tom',
    18. address: 'No. 189, Grove St, Los Angeles',
    19. },
    20. {
    21. date: '2016-05-04',
    22. name: 'Tom',
    23. address: 'No. 189, Grove St, Los Angeles',
    24. },
    25. {
    26. date: '2016-05-01',
    27. name: 'Tom',
    28. address: 'No. 189, Grove St, Los Angeles',
    29. },
    30. ]
    31. </script>

    说明: 可以用 {自定义属性} 获取到自定义属性

    特殊函数:

    名称 说明
    me(this) 这个在body的HTML中调用可以获取到当前组件,相对于组件脚本中的me
    find(name) 组件事件中调用可以获取到body中指定name的一个HTML元素
    finds(name) 组件事件中调用可以获取到body中指定name的所有HTML元素
    getcontext() 获取到组件中的最外层DIV

    如在当前组件的点击事件:

    1. me.find("mybutton").onclick=function(){
    2. alert(this.innerHTML)
    3. }

    myechart(echarts控件)

    利用echarts提供图表的定制:https://echarts.apache.org/examples/zh/index.html
    图片alt

    属性:

    名称 说明
    渲染 svg/canvas 默认是canvas渲染
    配置 定义一个option,最后返回,如:return option

    特殊函数:

    名称 说明
    setoption(option) 设置option

    一个折线图的配置例子:

    1. option = {
    2. //color: ['#80FFA5', '#00DDFF', '#37A2FF',],
    3. title: {
    4. // text: 'Gradient Stacked Area Chart'
    5. },
    6. tooltip: {
    7. trigger: 'axis',
    8. axisPointer: {
    9. type: 'cross',
    10. label: {
    11. backgroundColor: '#6a7985'
    12. }
    13. }
    14. },
    15. legend: {
    16. data: ['Ia', 'Ib', 'Ic'],
    17. textStyle: {
    18. color: "#ffff",
    19. },
    20. },
    21. toolbox: {
    22. // feature: {
    23. // saveAsImage: {}
    24. // }
    25. },
    26. grid: {
    27. left: '3%',
    28. right: '4%',
    29. bottom: '3%',
    30. containLabel: true
    31. },
    32. xAxis: [
    33. {
    34. type: 'category',
    35. boundaryGap: false,
    36. data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    37. }
    38. ],
    39. yAxis: [
    40. {
    41. type: 'value',
    42. name: '电流/A',
    43. nameTextStyle: {
    44. color: "#ffff"
    45. },
    46. //scale: true,
    47. //min: 0,
    48. //max: 400,
    49. //interval: 1,
    50. //splitNumber: 6, //设置坐标轴的分割段数
    51. axisLabel: {
    52. color: "#ffff"
    53. }
    54. }
    55. ],
    56. series: [
    57. {
    58. name: 'Ia',
    59. type: 'line',
    60. stack: 'Total',
    61. smooth: true,
    62. lineStyle: {
    63. width: 3
    64. },
    65. showSymbol: true,
    66. emphasis: {
    67. focus: 'series'
    68. },
    69. data: [60, 80, 50]
    70. },
    71. {
    72. name: 'Ib',
    73. type: 'line',
    74. stack: 'Total',
    75. smooth: true,
    76. lineStyle: {
    77. width: 3
    78. },
    79. showSymbol: true,
    80. emphasis: {
    81. focus: 'series'
    82. },
    83. data: [20, 60, 30]
    84. },
    85. {
    86. name: 'Ic',
    87. type: 'line',
    88. stack: 'Total',
    89. smooth: true,
    90. lineStyle: {
    91. width: 3
    92. },
    93. showSymbol: true,
    94. emphasis: {
    95. focus: 'series'
    96. },
    97. data: [10, 50, 90]
    98. },
    99. ]
    100. };
    101. return option

    组件的数据变化事件实现动态数据:

    1. //数据格式:{"电流Ia":10,"电流Ib":11.2,"电流Ic":20.5}
    2. value = obj($$.value)
    3. //在组件自身me上存储自定义变量
    4. if (me.xdata == null) {
    5. me.xdata = []
    6. }
    7. if (me.data1 == null) {
    8. me.data1 = []
    9. }
    10. if (me.data2 == null) {
    11. me.data2 = []
    12. }
    13. if (me.data3 == null) {
    14. me.data3 = []
    15. }
    16. me.xdata.push($$.time);
    17. me.data1.push(value.电流Ia)
    18. me.data2.push(value.电流Ib)
    19. me.data3.push(value.电流Ic)
    20. //固定显示数据个数
    21. if (me.xdata.length > 10) {
    22. me.xdata.shift();
    23. me.data1.shift();
    24. me.data2.shift();
    25. me.data3.shift();
    26. }
    27. //option里面用变量代替,可以去掉其他不变的部分,会自动合并内容
    28. option = {
    29. xAxis: [
    30. {
    31. type: 'category',
    32. boundaryGap: false,
    33. data: xdata
    34. }
    35. ],
    36. yAxis: [
    37. {
    38. type: 'value',
    39. }
    40. ],
    41. series: [
    42. {
    43. name: 'Ia',
    44. type: 'line',
    45. data: me.data1
    46. },
    47. {
    48. name: 'Ib',
    49. type: 'line',
    50. data: me.data2
    51. },
    52. {
    53. name: 'Ic',
    54. type: 'line',
    55. data: me.data3
    56. }
    57. ],
    58. }
    59. me.setoption(option)

    3D 相关

    getcontext

    根据3d场景

    1. me.getcontext();

    getobject

    根据3d物体名称获取的物体对象

    1. me.getobject("L7-1");

    利用旧位置,改变到新位置

    1. var obj = my3d3.getobject("shengjiang")
    2. if (!obj.old) {
    3. obj.old = {};
    4. obj.old.x = obj.position.x;
    5. obj.old.y = obj.position.y;
    6. obj.old.z = obj.position.z;
    7. }
    8. obj.position.y = obj.old.y + a;

    getpoint

    根据3d物体名称获取的物体对象的2维坐标

    1. //参数1:物体对象名称
    2. //参数2:函数带坐标x和y参数,x,y就是显示对象的位置
    3. me.getpoint("L7-1", function (x, y) {
    4. //移动图形元素a的位置
    5. a.x = x;
    6. a.y = y - a.height;
    7. });

    函数源码

    可以 ctrl+F 查找函数

    1. switch (method) {
    2. case ";":
    3. for (var i = 0; i < pm.length; i++) {
    4. result = getvalue(pm[i]);
    5. }
    6. return result;
    7. case "continue":
    8. o.iscontinue = true;
    9. return null;
    10. case "break":
    11. o.isbreak = true;
    12. return null;
    13. case "=":
    14. switch (pm.length) {
    15. case 0:
    16. o.isreturn = true;
    17. return null;
    18. case 1:
    19. o.isreturn = true;
    20. return getvalue(pm[0]);
    21. case 2:
    22. setvalue(pm[0], pm[1]);
    23. break;
    24. }
    25. break;
    26. case "set":
    27. setvalue(pm[0], pm[1], pm[2]);
    28. break;
    29. case "!":
    30. var p1 = getvalue(pm[0]);
    31. return !mxUtils.TypeConvert.bool(p1);
    32. case "+":
    33. var p1 = getvalue(pm[0]);
    34. var p2 = getvalue(pm[1]);
    35. return p1 + p2;
    36. case "-":
    37. var p1 = getvalue(pm[0]);
    38. if (pm.length == 1) {
    39. return p1 * (-1);
    40. }
    41. var p2 = getvalue(pm[1]);
    42. return p1 - p2;
    43. case "%":
    44. var p1 = getvalue(pm[0]);
    45. var p2 = getvalue(pm[1]);
    46. return p1 % p2;
    47. case "*":
    48. var p1 = getvalue(pm[0]);
    49. var p2 = getvalue(pm[1]);
    50. return p1 * p2;
    51. case "/":
    52. var p1 = getvalue(pm[0]);
    53. var p2 = getvalue(pm[1]);
    54. return p1 / p2;
    55. case "+=":
    56. var p1 = getvalue(pm[0]);
    57. var p2 = getvalue(pm[1]);
    58. if (typeof p1 === 'number') {
    59. p2 = Number(p2);
    60. if (window.isNaN(p2)) {
    61. p2 = 0;
    62. }
    63. }
    64. setvalue(pm[0], {
    65. "ResultType": "Const",
    66. "value": p1 + p2
    67. });
    68. return null;
    69. case "++":
    70. var p1 = getvalue(pm[0]);
    71. setvalue(pm[0], {
    72. "ResultType": "Const",
    73. "value": p1 + 1
    74. });
    75. if (resultObj.IsPre) {
    76. return p1 + 1;
    77. } else {
    78. return p1;
    79. }
    80. case "--":
    81. var p1 = getvalue(pm[0]);
    82. setvalue(pm[0], {
    83. "ResultType": "Const",
    84. "value": p1 - 1
    85. });
    86. if (resultObj.IsPre) {
    87. return p1 - 1;
    88. } else {
    89. return p1;
    90. }
    91. case "-=":
    92. var p1 = getvalue(pm[0]);
    93. var p2 = getvalue(pm[1]);
    94. if (typeof p1 === 'number') {
    95. p2 = Number(p2);
    96. if (window.isNaN(p2)) {
    97. p2 = 0;
    98. }
    99. }
    100. setvalue(pm[0], {
    101. "ResultType": "Const",
    102. "value": p1 - p2
    103. });
    104. return null;
    105. case "==":
    106. var p1 = getvalue(pm[0]);
    107. var p2 = getvalue(pm[1]);
    108. return p1 == p2;
    109. case "===":
    110. var p1 = getvalue(pm[0]);
    111. var p2 = getvalue(pm[1]);
    112. return p1 === p2;
    113. case "!=":
    114. var p1 = getvalue(pm[0]);
    115. var p2 = getvalue(pm[1]);
    116. return p1 != p2;
    117. case ">":
    118. var p1 = getvalue(pm[0]);
    119. var p2 = getvalue(pm[1]);
    120. return p1 > p2;
    121. case ">=":
    122. var p1 = getvalue(pm[0]);
    123. var p2 = getvalue(pm[1]);
    124. return p1 >= p2;
    125. case "<":
    126. var p1 = getvalue(pm[0]);
    127. var p2 = getvalue(pm[1]);
    128. return p1 < p2;
    129. case "<=":
    130. var p1 = getvalue(pm[0]);
    131. var p2 = getvalue(pm[1]);
    132. return p1 <= p2;
    133. case "&&":
    134. var p1 = getvalue(pm[0]);
    135. if (!mxUtils.TypeConvert.bool(p1)) {
    136. return false;
    137. }
    138. var p2 = getvalue(pm[1]);
    139. if (!mxUtils.TypeConvert.bool(p2)) {
    140. return false;
    141. }
    142. return true;
    143. case "||":
    144. var p1 = getvalue(pm[0]);
    145. if (mxUtils.TypeConvert.bool(p1)) {
    146. return true;
    147. }
    148. var p2 = getvalue(pm[1]);
    149. if (mxUtils.TypeConvert.bool(p2)) {
    150. return true;
    151. }
    152. return false;
    153. case "math.round": //小数处理
    154. var p1 = getvalue(pm[0]);
    155. return Math.round(p1);
    156. case "number": //转为数字
    157. var p1 = getvalue(pm[0]);
    158. return Number(p1);
    159. case "now": //获取当前时间
    160. return new Date();
    161. case "addyears": //时间增加n年
    162. var date = getvalue(pm[0]);
    163. var n = getvalue(pm[1]);
    164. date.setFullYear(date.getFullYear() + n);
    165. return date;
    166. case "addmonths": //时间增加n个月
    167. var date = getvalue(pm[0]);
    168. var n = getvalue(pm[1]);
    169. date.setMonth(date.getMonth() + n);
    170. return date;
    171. case "adddays": //时间增加n天
    172. var date = getvalue(pm[0]);
    173. var n = getvalue(pm[1]);
    174. date.setDate(date.getDate() + n);
    175. return date;
    176. case "addhours": //时间增加n小时
    177. var date = getvalue(pm[0]);
    178. var n = getvalue(pm[1]);
    179. date.setHours(date.getHours() + n);
    180. return date;
    181. case "addminutes": //时间增加n分钟
    182. var date = getvalue(pm[0]);
    183. var n = getvalue(pm[1]);
    184. date.setMinutes(date.getMinutes() + n);
    185. return date;
    186. case "addseconds": //时间增加n秒
    187. var date = getvalue(pm[0]);
    188. var n = getvalue(pm[1]);
    189. date.setSeconds(date.getSeconds() + n);
    190. return date;
    191. case "local": //时间转换为本地时间并且可格式化:yyyy-MM-dd hh:mm:ss
    192. var p1 = getvalue(pm[0]);
    193. var p2 = getvalue(pm[1]);
    194. return mxUtils.localtime(p1, p2);
    195. case "distance": //求两点距离
    196. var p1 = getvalue(pm[0]); //1
    197. var p2 = getvalue(pm[1]); //2
    198. dx = Math.abs(p2[0] - p1[0]);
    199. dy = Math.abs(p2[1] - p1[1]);
    200. var dis = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
    201. return dis;
    202. case "angle": //获取两点对于中心点的夹角
    203. if (pm.length == 2) {
    204. var p1 = getvalue(pm[0]); //中心点
    205. var p2 = getvalue(pm[1]); //点开始
    206. return mxUtils.GetAngel(p1[0], p1[1], p2[0], p2[1]);
    207. }
    208. var p1 = getvalue(pm[0]); //中心点
    209. var p2 = getvalue(pm[1]); //点开始
    210. var p3 = getvalue(pm[2]); //点结束
    211. var pointA = {
    212. X: p1[0],
    213. Y: p1[1]
    214. };
    215. var pointB = {
    216. X: p2[0],
    217. Y: p2[1]
    218. };
    219. var pointC = {
    220. X: p3[0],
    221. Y: p3[1]
    222. };
    223. var AB = {};
    224. var AC = {};
    225. AB.X = (pointB.X - pointA.X);
    226. AB.Y = (pointB.Y - pointA.Y);
    227. AC.X = (pointC.X - pointA.X);
    228. AC.Y = (pointC.Y - pointA.Y); // 分别求出AB,AC的向量坐标表示
    229. var direct = (AB.X * AC.Y) - (AB.Y * AC.X); // AB与AC叉乘求出逆时针还是顺时针旋转
    230. var lengthAB = Math.sqrt(Math.pow(pointA.X - pointB.X, 2) +
    231. Math.pow(pointA.Y - pointB.Y, 2)),
    232. lengthAC = Math.sqrt(Math.pow(pointA.X - pointC.X, 2) +
    233. Math.pow(pointA.Y - pointC.Y, 2)),
    234. lengthBC = Math.sqrt(Math.pow(pointB.X - pointC.X, 2) +
    235. Math.pow(pointB.Y - pointC.Y, 2));
    236. var len = 2 * lengthAB * lengthAC;
    237. var cosA = 1;
    238. if (len != 0) {
    239. cosA = (Math.pow(lengthAB, 2) + Math.pow(lengthAC, 2) - Math.pow(
    240. lengthBC, 2)) / len; // 余弦定理求出旋转角
    241. }
    242. if (cosA < -1) {
    243. cosA = -1;
    244. } else if (cosA > 1) {
    245. cosA = 1;
    246. }
    247. var angleA = Math.acos(cosA) * 180 / Math.PI;
    248. //var angleA = Math.round(Math.acos(cosA) * 180 / Math.PI);
    249. var a = 0;
    250. if (direct < 0) {
    251. a = -1 * angleA; //叉乘结果为负表示逆时针旋转, 逆时针旋转减度数
    252. } else {
    253. a = angleA;
    254. }
    255. if (a >= 360) {
    256. a = a - 360;
    257. }
    258. if (a < 0) {
    259. a = a + 360;
    260. }
    261. return a;
    262. case "date": //转为日期时间
    263. if (pm.length == 3) {
    264. return new Date(getvalue(pm[0]), getvalue(pm[1]), getvalue(pm[2]));
    265. }
    266. if (pm.length == 6) {
    267. return new Date(getvalue(pm[0]), getvalue(pm[1]), getvalue(pm[2]), getvalue(pm[
    268. 3]), getvalue(pm[4]), getvalue(pm[5]));
    269. }
    270. var p1 = getvalue(pm[0]);
    271. return new Date(p1);
    272. case "year": //获取给定时间的年
    273. var p1 = getvalue(pm[0]);
    274. return p1.getFullYear();
    275. case "month": //获取给定时间的月
    276. var p1 = getvalue(pm[0]);
    277. return p1.getMonth() + 1;
    278. case "day": //获取给定时间的日
    279. var p1 = getvalue(pm[0]);
    280. return p1.getDate();
    281. case "hour": //获取给定时间的小时
    282. var p1 = getvalue(pm[0]);
    283. return p1.getHours();
    284. case "minute": //获取给定时间的分钟
    285. var p1 = getvalue(pm[0]);
    286. return p1.getMinutes();
    287. case "second": //获取给定时间的秒
    288. var p1 = getvalue(pm[0]);
    289. return p1.getSeconds();
    290. case "alert":
    291. var p1 = getvalue(pm[0]);
    292. alert(p1);
    293. return null;
    294. case "switch":
    295. var p1 = getvalue(pm[0]);
    296. return p1;
    297. case "if":
    298. case "else":
    299. case "elseif":
    300. if (pm.length == 0) {
    301. return true;
    302. }
    303. var p1 = getvalue(pm[0]);
    304. return mxUtils.TypeConvert.bool(p1);
    305. case "index": //获取给定cell的索引
    306. var p1 = getvalue(pm[0]);
    307. var parent = p1.parent;
    308. var index = parent.getIndex(p1);
    309. return index;
    310. case "fit": //适应屏幕
    311. graph.model.root.maxbounds = null;
    312. graph.Fit(graph.model.root);
    313. return null;
    314. case "clone": //克隆一个元素
    315. var p1 = getvalue(pm[0]);
    316. var p2 = getvalue(pm[2]);
    317. var index = getvalue(pm[1]);
    318. if (p2 == null) {
    319. p2 = p1.parent;
    320. }
    321. if (index != null) {
    322. //
    323. } else {
    324. var parent = p2;
    325. index = parent.children.length; // parent.getIndex(p1);
    326. }
    327. var clone = graph.cloneCell(p1, parent, index);
    328. clone.name = "";
    329. graph.checkAnimation3(clone);
    330. return clone;
    331. case "delete": //删除一个字典属性
    332. var p1 = getvalue(pm[0]);
    333. var p2 = getvalue(pm[1]);
    334. delete p1[p2];
    335. return p1;
    336. case "remove": //删除一个元素
    337. var p1 = getvalue(pm[0]);
    338. graph.removeCells([p1]);
    339. return p1;
    340. case "append": //增加一个元素到指定元素中
    341. var p1 = getvalue(pm[0]); //待增加的元素
    342. var parent = getvalue(pm[1]); //增加到元素
    343. var index = parseInt(getvalue(pm[2])); //增加到位置
    344. graph.cellsAdded([p1], parent, index,
    345. null, null, true);
    346. return p1;
    347. case "show": //显示一个元素
    348. var p1 = getvalue(pm[0]);
    349. var props = {};
    350. props["hide"] = "0";
    351. graph.setCellStyles2(p1, props);
    352. return null;
    353. case "hide": //隐藏一个元素
    354. var p1 = getvalue(pm[0]);
    355. var props = {};
    356. props["hide"] = "1";
    357. graph.setCellStyles2(p1, props);
    358. return null;
    359. case "back": //将一个元素放在另一个后面
    360. var p1 = getvalue(pm[0]);
    361. // var state = graph.view.getState(p1);
    362. // //graph.view.canvas.lastChild
    363. // var p2 = getvalue(pm[1]);
    364. // if (p2 == null) {
    365. // p2 = null;
    366. // } else {
    367. // var state2 = graph.view.getState(p2);
    368. // p2 = state2.shape.node.previousSibling;
    369. // }
    370. //graph.cellRenderer.insertStateAfter(state, p2, null);
    371. graph.cellsOrdered2([p1], true);
    372. return p1;
    373. case "front": //将一个元素放在另一个前面
    374. var p1 = getvalue(pm[0]);
    375. // var state = graph.view.getState(p1);
    376. // var p2 = getvalue(pm[1]);
    377. // if (p2 == null) {
    378. // p2 = graph.view.canvas.lastChild;
    379. // } else {
    380. // var state2 = graph.view.getState(p2);
    381. // p2 = state2.shape.node;
    382. // }
    383. //graph.cellRenderer.insertStateAfter(state, p2, null);
    384. graph.cellsOrdered2([p1], false);
    385. return p1;
    386. case "showfull": //全屏
    387. showFull();
    388. return null;
    389. case "exitfull": //退出全屏
    390. exitFullscreen();
    391. return null;
    392. //
    393. case "json": //将对象转换为json字符串
    394. var p1 = getvalue(pm[0]);
    395. if (p1 && p1.constructor.name == "String") {
    396. return p1;
    397. }
    398. return JSON.stringify(p1);
    399. case "obj": //将json字符串转换为对象
    400. var p1 = getvalue(pm[0]);
    401. if (p1 && p1.constructor.name != "String") {
    402. return p1;
    403. }
    404. if (p1 == null || p1 == "") {
    405. return {};
    406. }
    407. return eval("(" + p1 + ")");
    408. //
    409. case "bind": //绑定一个属性,变化后执行函数
    410. var p1 = getvalue(pm[0]); //cell
    411. if (p1 == null) {
    412. return null;
    413. }
    414. var p2 = getvalue(pm[1]); //属性
    415. var p3 = getvalue(pm[2]); //function
    416. if (!p1.custombinding) {
    417. p1.custombinding = {};
    418. }
    419. p1.custombinding[p2] = p3;
    420. p3(null, [p1]);
    421. return null;
    422. case "instance": //设置实例
    423. var p1 = getvalue(pm[0]);
    424. var p3 = getvalue(pm[1]); //成功后回调:定义一个function,这里指function名称
    425. mxUtils.processExpression(graph, shape, p1, {}, function (value, para, cp) {
    426. //
    427. if (p3) {
    428. if (cp && cp.mycp) {
    429. var data = {};
    430. data.value = cp.mycp.value;
    431. data.time = cp.mycp.time;
    432. data.tag = cp.mycp.tag;
    433. runfunction(p3, [data]);
    434. }
    435. }
    436. });
    437. return null;
    438. case "runscript": //调用一个api,获取结果后再调用回调
    439. var p1 = "./api/runscript.ds";
    440. var para = {};
    441. para.script = getvalue(pm[0]);
    442. mxUtils.mypost(p1, para, {}, function (data) {
    443. var p3 = getvalue(pm[1]); //成功后回调:定义一个function,这里指function名称
    444. if (p3) {
    445. runfunction(p3, [data]);
    446. }
    447. }, function (data) {
    448. var p4 = getvalue(pm[2]); //失败后回调:定义一个function,这里指function名称
    449. if (p4) {
    450. runfunction(p4, [data]);
    451. }
    452. });
    453. return null;
    454. case "instancehistory": //调用一个api,获取结果后再调用回调
    455. var p1 = "./api/instancehistory.ds";
    456. var p2 = getvalue(pm[0]); //参数:
    457. /*
    458. var p2 = {
    459. instance: instance,
    460. start: starttime,
    461. end: end
    462. }
    463. */
    464. mxUtils.mypost(p1, p2, {}, function (data) {
    465. var p3 = getvalue(pm[1]); //成功后回调:定义一个function,这里指function名称
    466. if (p3) {
    467. runfunction(p3, [data]);
    468. }
    469. }, function (data) {
    470. var p4 = getvalue(pm[2]); //失败后回调:定义一个function,这里指function名称
    471. if (p4) {
    472. runfunction(p4, [data]);
    473. }
    474. });
    475. return null;
    476. case "get": //调用一个api,获取结果后再调用回调
    477. var p1 = getvalue(pm[0]); //api:如/admin/api/a.ds
    478. if (graph.model.path) {
    479. var index = graph.model.path.lastIndexOf("/");
    480. var path = graph.model.path.substring(0, index + 1);
    481. p1 = mxUtils.aburl(p1, "/" + path);
    482. }
    483. var owner = shape.getOwner();
    484. if (owner && p1.indexOf("/this/") == 0) {
    485. p1 = "/" + owner + p1.substring(5);
    486. }
    487. var p2 = getvalue(pm[1]); //参数:如 {"a":1,"b":2}
    488. mxUtils.myget(p1, p2, {}, function (data) {
    489. var p3 = getvalue(pm[2]); //成功后回调:定义一个function,这里指function名称
    490. if (p3) {
    491. runfunction(p3, [data]);
    492. }
    493. }, function (data) {
    494. var p4 = getvalue(pm[3]); //失败后回调:定义一个function,这里指function名称
    495. if (p4) {
    496. runfunction(p4, [data]);
    497. }
    498. });
    499. return null;
    500. case "path":
    501. var p1 = getvalue(pm[0]);
    502. if (graph.model.path) {
    503. var index = graph.model.path.lastIndexOf("/");
    504. var path = graph.model.path.substring(0, index + 1);
    505. p1 = mxUtils.aburl(p1, "/" + path);
    506. }
    507. return p1;
    508. case "post": //调用一个api,获取结果后再调用回调
    509. $$.$$isrunning = true;
    510. var p1 = getvalue(pm[0]); //api:如/admin/api/a.ds
    511. if (p1 == null || p1 == "") {
    512. var p4 = getvalue(pm[3]); //失败后回调:定义一个function,这里指function名称
    513. if (p4) {
    514. runfunction(p4, ["第一个参数不能为空"]);
    515. }
    516. $$.$$isrunning = false;
    517. return null;
    518. }
    519. if (graph.model.path) {
    520. var index = graph.model.path.lastIndexOf("/");
    521. var path = graph.model.path.substring(0, index + 1);
    522. p1 = mxUtils.aburl(p1, "/" + path);
    523. }
    524. var owner = shape.getOwner();
    525. if (owner && p1.indexOf("/this/") == 0) {
    526. p1 = "/" + owner + p1.substring(5);
    527. }
    528. var p2 = getvalue(pm[1]); //参数:如 {"a":1,"b":2}
    529. mxUtils.mypost(p1, p2, {}, function (data) {
    530. var p3 = getvalue(pm[2]); //成功后回调:定义一个function,这里指function名称
    531. if (p3) {
    532. runfunction(p3, [data]);
    533. }
    534. $$.$$isrunning = false;
    535. }, function (data) {
    536. var p4 = getvalue(pm[3]); //失败后回调:定义一个function,这里指function名称
    537. if (p4) {
    538. runfunction(p4, [data]);
    539. }
    540. $$.$$isrunning = false;
    541. }, null, null, getvalue(pm[4]), getvalue(pm[5]));
    542. return null;
    543. case "postsync": //调用一个api,获取结果后再调用回调
    544. var p1 = getvalue(pm[0]); //api:如/admin/api/a.ds
    545. if (graph.model.path) {
    546. var index = graph.model.path.lastIndexOf("/");
    547. var path = graph.model.path.substring(0, index + 1);
    548. p1 = mxUtils.aburl(p1, "/" + path);
    549. }
    550. var owner = shape.getOwner();
    551. if (owner && p1.indexOf("/this/") == 0) {
    552. p1 = "/" + owner + p1.substring(5);
    553. }
    554. var p2 = getvalue(pm[1]); //参数:如 {"a":1,"b":2}
    555. var data = mxUtils.mypost(p1, p2, {});
    556. var p3 = getvalue(pm[2]); //成功后回调:定义一个function,这里指function名称
    557. if (p3) {
    558. runfunction(p3, [data]);
    559. }
    560. return data;
    561. case "getsync": //调用一个api,获取结果后再调用回调
    562. var p1 = getvalue(pm[0]); //api:如/admin/api/a.ds
    563. if (graph.model.path) {
    564. var index = graph.model.path.lastIndexOf("/");
    565. var path = graph.model.path.substring(0, index + 1);
    566. p1 = mxUtils.aburl(p1, "/" + path);
    567. }
    568. var owner = shape.getOwner();
    569. if (owner && p1.indexOf("/this/") == 0) {
    570. p1 = "/" + owner + p1.substring(5);
    571. }
    572. var p2 = getvalue(pm[1]); //参数:如 {"a":1,"b":2}
    573. var data = mxUtils.myget(p1, p2);
    574. var p3 = getvalue(pm[2]); //成功后回调:定义一个function,这里指function名称
    575. if (p3) {
    576. runfunction(p3, [data]);
    577. }
    578. return data;
    579. case "blob": //调用一个api,获取结果后再调用回调
    580. var p1 = getvalue(pm[0]); //api:如/admin/api/a.ds
    581. if (graph.model.path) {
    582. var index = graph.model.path.lastIndexOf("/");
    583. var path = graph.model.path.substring(0, index + 1);
    584. p1 = mxUtils.aburl(p1, "/" + path);
    585. }
    586. var owner = shape.getOwner();
    587. if (owner && p1.indexOf("/this/") == 0) {
    588. p1 = "/" + owner + p1.substring(5);
    589. }
    590. var p2 = getvalue(pm[1]); //参数:如 {"a":1,"b":2}
    591. mxUtils.mypost(p1, p2, {}, function (data) {
    592. var p3 = getvalue(pm[2]); //成功后回调:定义一个function,这里指function名称
    593. if (p3) {
    594. runfunction(p3, [data]);
    595. }
    596. }, function (data) {
    597. var p4 = getvalue(pm[3]); //失败后回调:定义一个function,这里指function名称
    598. if (p4) {
    599. runfunction(p4, [data]);
    600. }
    601. }, null, null, "blob");
    602. return null;
    603. case "change": //动态改变图形源
    604. var ename = getvalue(pm[0]); //图形元素名
    605. var element = null;
    606. if (ename.constructor.name == "mxCell") {
    607. element = ename;
    608. }
    609. else {
    610. element = shape.getElement(ename, override);
    611. }
    612. var state = graph.view.getState(element);
    613. var url = getvalue(pm[1]); //新的图形
    614. var para = getvalue(pm[2]); //新图形的自定义属性值
    615. state.shape.ChangeSymbol(url, para);
    616. // var element = shape.getElement(ename, override);
    617. // var cellStyle = model.getStyle(element);
    618. // cellStyle = mxUtils.setStyle(
    619. // cellStyle, "shape", "Embed");
    620. // cellStyle = mxUtils.setStyle(
    621. // cellStyle, "url", url);
    622. // element.$$para$$ = para;
    623. // model.setStyle(element, cellStyle);
    624. return null;
    625. case "mydata": //获取当前图形的自定义属性表
    626. var p2 = graph.getCustomProperties();
    627. return p2;
    628. case "submit": //调用一个api,将结果赋值到一个自定义属性上
    629. var p1 = getvalue(pm[0]); //api地址
    630. var p2 = getvalue(pm[1]); //参数
    631. var p3 = getvalue(pm[2]); //自定义属性名
    632. MyPost(p1, {
    633. data: JSON.stringify(p2)
    634. }, {},
    635. function (s) {
    636. var mycp = graph.getCustomProperty(p3);
    637. if (mycp != null) {
    638. mycp.setvalue(s, null, null, null, true);
    639. }
    640. });
    641. return null;
    642. case "play": //执行一个音频文件
    643. var p1 = getvalue(pm[0]); //音频文件地址
    644. var audio = document.createElement('audio');
    645. var source = document.createElement('source');
    646. source.type = "audio/mpeg";
    647. if (p1.endWith(".wav")) {
    648. source.type = "audio/wav";
    649. }
    650. source.src = p1;
    651. source
    652. .autoplay = "autoplay";
    653. source.controls = "controls";
    654. audio.appendChild(
    655. source);
    656. audio.play();
    657. return audio;
    658. case "redirect":
    659. var p1 = getvalue(pm[0]);
    660. location.href = p1;
    661. return null;
    662. case "setcookie":
    663. var cname = getvalue(pm[0]);
    664. var cvalue = getvalue(pm[1]);
    665. var exdays = getvalue(pm[2]);
    666. var d = new Date();
    667. d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    668. var expires = "expires=" + d.toGMTString();
    669. document.cookie = cname + "=" + cvalue + "; " + expires;
    670. return null;
    671. case "getcookie":
    672. var cname = getvalue(pm[0]);
    673. var name = cname + "=";
    674. var decodedCookie = decodeURIComponent(document.cookie);
    675. var ca = decodedCookie.split(';');
    676. for (var i = 0; i < ca.length; i++) {
    677. var c = ca[i];
    678. while (c.charAt(0) == ' ') {
    679. c = c.substring(1);
    680. }
    681. if (c.indexOf(name) == 0) {
    682. return c.substring(name.length, c.length);
    683. }
    684. }
    685. return "";
    686. case "input":
    687. return myinput;
    688. case "group":
    689. return graph.groupCells(getvalue(pm[1]), null, getvalue(pm[0]));
    690. case "scale":
    691. if (pm.length == 0) {
    692. return graph.view.scale;
    693. }
    694. var p1 = getvalue(pm[0]);
    695. var s = Number(p1);
    696. graph.view.setScale(s);
    697. graph.view.getsvg().style.width = graph.view.bounds.width * s;
    698. graph.view.getsvg().style.height = graph.view.bounds.height * s;
    699. return graph.view.scale;
    700. case "isruntime":
    701. case "runtime":
    702. return graph.isRuntime();
    703. case "getsize":
    704. var p1 = getvalue(pm[0]);
    705. var state = graph.view.getState(p1);
    706. var rect = state.shape.node.getBoundingClientRect();
    707. rect.x -= graph.container.offsetLeft;
    708. rect.y -= graph.container.offsetTop;
    709. return rect;
    710. case "image":
    711. var p1 = getvalue(pm[0]);
    712. var rect = null;
    713. if (p1 == graph) {
    714. rect = graph.view.getsvg().getBoundingClientRect();
    715. } else {
    716. var state = graph.view.getState(p1);
    717. rect = state.shape.node.getBoundingClientRect();
    718. }
    719. var container = graph.container;
    720. while (true) {
    721. if (container.tagName == "DIV") {
    722. break;
    723. }
    724. container = container.parentElement;
    725. }
    726. rect.x -= container.offsetLeft;
    727. rect.y -= container.offsetTop;
    728. domtoimage.toPng(container)
    729. .then(function (dataUrl) {
    730. var img = new Image();
    731. img.src = dataUrl;
    732. img.onload = function () {
    733. var canvas = document.createElement("canvas");
    734. canvas.width = rect.width;
    735. canvas.height = rect.height;
    736. canvas.style.width = rect.width + "px";
    737. canvas.style.height = rect.height + "px";
    738. //canvas.scale = 5;
    739. // 坐标(0,0) 表示从此处开始绘制,相当于偏移。
    740. canvas.getContext("2d").drawImage(img, rect.x, rect.y,
    741. rect.width,
    742. rect.height, 0,
    743. 0, rect.width, rect.height);
    744. //
    745. //新Image对象,可以理解为DOM
    746. //var image = new Image();
    747. // canvas.toDataURL 返回的是一串Base64编码的URL
    748. // 指定格式 PNG
    749. //image.src = canvas.toDataURL("image/png");
    750. var src = canvas.toDataURL("image/png", 1.0);
    751. var index = src.indexOf(",");
    752. src = src.substring(index + 1);
    753. var p3 = getvalue(pm[1]); //成功后回调:定义一个function,这里指function名称
    754. if (p3) {
    755. runfunction(p3, [src]);
    756. }
    757. // image.onload = function() {
    758. // var p3 = getvalue(pm[1]); //成功后回调:定义一个function,这里指function名称
    759. // if (p3) {
    760. // runfunction(p3, [image]);
    761. // }
    762. // }
    763. }
    764. //return dataUrl;
    765. })
    766. .catch(function (error) {
    767. console.error('oops, something went wrong!',
    768. error);
    769. });
    770. return null;
    771. case "download":
    772. var blob = getvalue(pm[0]);
    773. var filename = getvalue(pm[1]);
    774. if (filename == null) {
    775. filename = "下载的文件";
    776. }
    777. var reader = new FileReader();
    778. reader.readAsDataURL(blob); // 转换为base64,可以直接放入a表情href
    779. reader.onload = function (e) {
    780. // 转换完成,创建一个a标签用于下载
    781. var a = document.createElement('a');
    782. a.download = filename;
    783. a.href = e.target.result;
    784. document.body.appendChild(a); // 修复firefox中无法触发click
    785. a.click();
    786. a.remove();
    787. return null;
    788. }
    789. case "loadjs":
    790. var url = getvalue(pm[0]);
    791. var callback = getvalue(pm[1]);
    792. var param = getvalue(pm[2]);
    793. //
    794. mxUtils.loadJs(url, callback, param);
    795. return null;
    796. case "debug":
    797. var p1 = getvalue(pm[0]);
    798. console.log(p1);
    799. return null;
    800. case "add":
    801. var count3 = pm.length;
    802. var result = getvalue(pm[0]);
    803. for (var i = 1; i < count3; i++) {
    804. var r = getvalue(pm[i]);
    805. if (r.ismyfunction) {
    806. r = r();
    807. }
    808. result = result + r;
    809. }
    810. return result;
    811. case "rotate":
    812. // var newpoint = mxUtils.MyRotatedPoint(getvalue(pm[0]), getvalue(pm[1]), getvalue(pm[
    813. // 2]), getvalue(pm[3]), getvalue(pm[4]));
    814. var p1 = getvalue(pm[0]);
    815. var p2 = getvalue(pm[1]);
    816. var angel = getvalue(pm[2]);
    817. var newpoint = mxUtils.MyRotatedPoint(p2[0], p2[1], p1[0], p1[1], angel);
    818. return newpoint;
    819. case "bounds":
    820. return mxUtils.getBoundingBox(new mxRectangle(getvalue(pm[0]), getvalue(pm[1]),
    821. getvalue(pm[
    822. 2]), getvalue(pm[3])), getvalue(pm[4]))
    823. case "time":
    824. var sobj = $$.getServerTag(pm[0]);
    825. if (sobj) {
    826. return sobj.time;
    827. }
    828. return null;
    829. case "value":
    830. var p1 = getvalue(pm[0]);
    831. return p1;
    832. case "element":
    833. var ename = getvalue(pm[0]).toLowerCase();
    834. return shape.getElement(ename, override);
    835. case "query":
    836. if (pm.length == 2) {
    837. var url = window.location.href.toString();
    838. url = mxUtils.replaceParamVal(url, getvalue(pm[0]), getvalue(pm[1]));
    839. mxUtils.replaceUrl(url);
    840. return null;
    841. } else {
    842. return mxUtils.getQueryString(getvalue(pm[0]));
    843. }
    844. case "removeevent":
    845. var p1 = getvalue(pm[0]);
    846. if (p1._animations && p1._animations._es) {
    847. //
    848. for (var i = 0; i < p1._animations._es.length; i++) {
    849. var es = p1._animations._es[i];
    850. var index = es.list.indexOf(es.item);
    851. es.list.splice(index, 1);
    852. }
    853. p1._animations._es = null;
    854. }
    855. return null;
    856. case "refresh":
    857. var p1 = getvalue(pm[0]);
    858. graph.myRefresh2(p1, true);
    859. return null;
    860. case "console.log":
    861. var p1 = getvalue(pm[0]);
    862. console.log(p1);
    863. return null;
    864. case "console.error":
    865. var p1 = getvalue(pm[0]);
    866. console.error(p1);
    867. return null;
    868. case "console.info":
    869. var p1 = getvalue(pm[0]);
    870. console.info(p1);
    871. return null;
    872. case "console.warning":
    873. var p1 = getvalue(pm[0]);
    874. console.warning(p1);
    875. return null;
    876. case "?":
    877. var checkresult = {};
    878. checkresult.check = mxUtils.TypeConvert.bool(getvalue(pm[0]));
    879. if (checkresult.check) {
    880. checkresult.value = getvalue(pm[1]);
    881. }
    882. return checkresult;
    883. case ":":
    884. var pm0 = getvalue(pm[0]);
    885. if (pm0 && pm0.check !== undefined) {
    886. if (pm0.check) {
    887. return pm0.value;
    888. } else {
    889. return getvalue(pm[1]);
    890. }
    891. }
    892. var dic = {};
    893. var ro = pm[0];
    894. var key = "";
    895. if (ro.ResultType == "Variable") {
    896. key = ro.Name;
    897. } else {
    898. key = pm0;
    899. }
    900. dic[key] = getvalue(pm[1]);
    901. return dic;
    902. default:
    903. switch (resultObj.Opstart) {
    904. case "{":
    905. if (pm.length == 0) {
    906. return {};
    907. }
    908. var p0 = getvalue(pm[0]);
    909. if (p0 instanceof Object) {
    910. var kv = {};
    911. for (var i = 0; i < pm.length; i++) {
    912. var p1 = getvalue(pm[i]);
    913. if (p1 == null) {
    914. continue;
    915. }
    916. for (var p in p1) {
    917. if (kv[p]) {
    918. throw "字典字段不能重复:" + p;
    919. }
    920. kv[p] = p1[p];
    921. }
    922. }
    923. result = kv;
    924. } else if (pm.length == 1) {
    925. return p0;
    926. } else {
    927. var kv = {};
    928. kv[p0] = getvalue(pm[1]);
    929. result = kv;
    930. }
    931. return result;
    932. case "[":
    933. if (resultObj.Optype == "Connector") {
    934. var para = [];
    935. for (var i = 0; i < pm.length; i++) {
    936. var pm0 = getvalue(pm[i]);
    937. para.push(pm0);
    938. }
    939. //result = para;
    940. return para;
    941. }
    942. var value = getvalue(pm[0]);
    943. if (value == null) {
    944. return null;
    945. }
    946. var pa = getvalue(pm[1]);
    947. var result = value[pa];
    948. return result;
    949. }
    950. var nindex = resultObj.Name.indexOf("new ");
    951. var start = 0;
    952. if (nindex == 0) {
    953. var name = resultObj.Name.substring(3).trim();
    954. var w = window;
    955. while (w) {
    956. var index = name.indexOf(".");
    957. if (index == -1) {
    958. break;
    959. }
    960. var vv1 = name.substring(0, index);
    961. name = name.substring(index + 1);
    962. w = w[vv1];
    963. }
    964. //var v3 = w[name];
    965. var para = [];
    966. for (var i = start; i < pm.length; i++) {
    967. var pm0 = getvalue(pm[i]);
    968. para.push(pm0);
    969. }
    970. if (!w[name]) {
    971. throw "w[name]不存在:" + name;
    972. }
    973. // var a = new w[name];
    974. // if (para.length == 0) {
    975. // return a;
    976. // }
    977. var ret = Function.prototype.bind.apply(w[name], [null].concat(para));
    978. return new ret();
    979. }
    980. var dot = resultObj.Name.lastIndexOf(".");
    981. var cellfunction = null;
    982. var cellstate = null;
    983. //
    984. var _functionrun = function (name) {
    985. if (cellfunction == null) {
    986. cellfunction = functions[name.toLowerCase()];
    987. }
    988. if (cellfunction) {
    989. //
    990. var pm2 = [];
    991. var j = 0;
    992. for (var i = start; i < pm.length; i++) {
    993. pm2[j] = getvalue(pm[i]);
    994. j++;
    995. }
    996. var cellshape = shape;
    997. if (cellstate) {
    998. cellshape = cellstate.shape;
    999. }
    1000. return runfunction(cellfunction, pm2, cellshape);
    1001. } else {
    1002. var name2 = resultObj.Name;
    1003. var w = window;
    1004. var ind = 0;
    1005. while (w) {
    1006. ind++;
    1007. var index = name2.indexOf(".");
    1008. if (index == -1) {
    1009. break;
    1010. }
    1011. var vv1 = name2.substring(0, index);
    1012. name2 = name2.substring(index + 1);
    1013. var w2 = w[vv1];
    1014. if (!w2) {
    1015. w = w[vv1.toLowerCase()];
    1016. } else {
    1017. w = w2;
    1018. }
    1019. if (ind == 1 && w == null) {
    1020. w = getvalue({
    1021. "ResultType": "Variable",
    1022. "Name": vv1
    1023. });
    1024. }
    1025. }
    1026. if (w) {
    1027. var n = name2;
    1028. if (!w[n]) {
    1029. n = n.toLowerCase();
    1030. }
    1031. if (w[n]) {
    1032. var wn = w[n];
    1033. var para = [];
    1034. for (var i = start; i < pm.length; i++) {
    1035. var pm0 = getvalue(pm[i]);
    1036. para.push(pm0);
    1037. }
    1038. var r = wn.apply($$, para);
    1039. return r;
    1040. }
    1041. }
    1042. }
    1043. var mycp = shape.getCustomProperty(method, true, override);
    1044. if (mycp == null) {
    1045. mycp = shape.state.cell[method];
    1046. }
    1047. if (mycp != null) {
    1048. var para = [];
    1049. for (var i = start; i < pm.length; i++) {
    1050. var pm0 = getvalue(pm[i]);
    1051. para.push(pm0);
    1052. }
    1053. if (mycp.value) {
    1054. return mycp.value.apply($$, para);
    1055. }
    1056. //var myf = mycp.value();
    1057. return mycp.apply($$, para);
    1058. }
    1059. throw "方法没有实现:" + method;
    1060. };
    1061. //
    1062. if (dot != -1) {
    1063. var v2 = null;
    1064. var m2 = null;
    1065. var v3 = null;
    1066. if (dot == 0) {
    1067. v3 = getvalue(pm[0]);
    1068. if (v3 == null) {
    1069. var firstprop = pm[0].Opprop;
    1070. if (firstprop != "") {
    1071. throw "不存在:" + firstprop;
    1072. }
    1073. }
    1074. start = 1;
    1075. m2 = resultObj.Name.substring(1);
    1076. } else {
    1077. v2 = resultObj.Name.substring(0, dot);
    1078. v2 = v2.trim();
    1079. m2 = resultObj.Name.substring(dot + 1);
    1080. var checknumber = Number(v2);
    1081. if (!window.isNaN(checknumber)) {
    1082. v3 = checknumber;
    1083. } else if (v2 == "this") {
    1084. v3 = shape;
    1085. } else {
    1086. v3 = getvalue({
    1087. "ResultType": "Variable",
    1088. "Name": v2
    1089. });
    1090. }
    1091. if (v3 == null) {
    1092. var w = window;
    1093. var ind = 0;
    1094. while (w && v2 && v2.indexOf) {
    1095. ind++;
    1096. v2 = v2.trim();
    1097. var index = v2.indexOf(".");
    1098. if (index == -1) {
    1099. break;
    1100. }
    1101. var vv1 = v2.substring(0, index);
    1102. v2 = v2.substring(index + 1);
    1103. w = w[vv1];
    1104. if (ind == 1 && w == null) {
    1105. w = getvalue({
    1106. "ResultType": "Variable",
    1107. "Name": vv1
    1108. });
    1109. }
    1110. }
    1111. v3 = w[v2];
    1112. }
    1113. }
    1114. //
    1115. if (v3 == null) {
    1116. throw "不存在:" + resultObj.Name;
    1117. }
    1118. var lm2 = m2.toLowerCase();
    1119. if (v3.getCustomProperty) {
    1120. var mycp = v3.getCustomProperty(lm2);
    1121. if (mycp != null) {
    1122. if (mycp.type == "function") {
    1123. var para = [];
    1124. for (var i = start; i < pm.length; i++) {
    1125. var pm0 = getvalue(pm[i]);
    1126. para.push(pm0);
    1127. }
    1128. var myf = mycp.value();
    1129. while (true) {
    1130. if (myf.IsFunction) {
    1131. myf = run2(myf);
    1132. }
    1133. else if (myf.iscpfunction) {
    1134. myf = myf(para);
    1135. }
    1136. else {
    1137. break;
    1138. }
    1139. }
    1140. return myf.apply($$, para);
    1141. } else {
    1142. var para = [];
    1143. for (var i = start; i < pm.length; i++) {
    1144. var pm0 = getvalue(pm[i]);
    1145. para.push(pm0);
    1146. }
    1147. return mycp.value(para);
    1148. }
    1149. }
    1150. }
    1151. if (v3.functions && v3.functions.Functions && v3.functions.Functions[
    1152. lm2]) {
    1153. cellfunction = v3.functions.Functions[lm2];
    1154. if (cellfunction) {
    1155. cellstate = graph.view.getState(v3);
    1156. cellfunction.Functions = v3.functions.Functions;
    1157. }
    1158. } else {
    1159. var vm = null;
    1160. var vm = v3[lm2];
    1161. if (!vm) {
    1162. vm = v3[m2];
    1163. }
    1164. if (vm == null && v3.constructor.name == "Window") {
    1165. var myready = function (v3, lm2, m2, start, pm, count) {
    1166. if (count > 200) {
    1167. throw "不存在:window." + m2;
    1168. return;
    1169. }
    1170. vm = v3[lm2];
    1171. if (!vm) {
    1172. vm = v3[m2];
    1173. }
    1174. if (vm == null) {
    1175. window.setTimeout(function () {
    1176. myready(v3, lm2, m2, start, pm, count + 1);
    1177. }, 5);
    1178. return;
    1179. }
    1180. // 页面加载完毕
    1181. var para = [];
    1182. for (var i = start; i < pm.length; i++) {
    1183. var pm0 = getvalue(pm[i]);
    1184. para.push(pm0);
    1185. }
    1186. //var vm = v3[m2];
    1187. if (vm.IsFunction && vm.FunctionName == "-") {
    1188. cellfunction = vm;
    1189. if (cellfunction) {
    1190. cellstate = graph.view.getState(v3);
    1191. }
    1192. } else {
    1193. //var r = null;
    1194. // if (vm.ismyfunction) {
    1195. // r = vm(para, v3);
    1196. // } else {
    1197. var r = vm.apply(v3, para);
    1198. // }
    1199. if (v3.$setvalue) {
    1200. v3.$setvalue();
    1201. }
    1202. return r;
    1203. }
    1204. }
    1205. myready(v3, lm2, m2, start, pm, 1);
    1206. return;
    1207. }
    1208. if (vm) {
    1209. var para = [];
    1210. for (var i = start; i < pm.length; i++) {
    1211. var pm0 = getvalue(pm[i]);
    1212. para.push(pm0);
    1213. }
    1214. //var vm = v3[m2];
    1215. if (vm.IsFunction && vm.FunctionName == "-") {
    1216. cellfunction = vm;
    1217. if (cellfunction) {
    1218. cellstate = graph.view.getState(v3);
    1219. }
    1220. } else {
    1221. //var r = null;
    1222. // if (vm.ismyfunction) {
    1223. // r = vm(para, v3);
    1224. // } else {
    1225. var r = vm.apply(v3, para);
    1226. // }
    1227. if (v3.$setvalue) {
    1228. v3.$setvalue();
    1229. }
    1230. return r;
    1231. }
    1232. }
    1233. }
    1234. }
    1235. return _functionrun(name);
    1236. }