Flow.js 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. var FlowConfigObject = {
  2. FlowType: "",
  3. scdin_cnf: "",
  4. node_list: "",
  5. CurrNode: null,
  6. StationID: "",
  7. Init: function(contentEle, flowType) {
  8. this.FlowType = flowType;
  9. this.CurrNode = null;
  10. this.scdin_cnf = contentEle;
  11. this.node_list = this.scdin_cnf.find("#node_list");
  12. this.scdin_cnf.find("#tree_area").height($(".main-body").height() - 80);
  13. this.node_list.height($(".main-body").height() - this.scdin_cnf.find("#opt_caption").height() - 80);
  14. Global.Ztree.Init(this.scdin_cnf.find("#tree"), {
  15. url: Global.AccessUrl + "/api/area/children/list",
  16. idKey: "id",
  17. pidKey: "pid",
  18. nameKey: "title",
  19. callback: {
  20. onClick: function(event, treeId, treeNode) {
  21. if (treeNode.id != "0") {
  22. FlowConfigObject.StationID = ParentPage.StationID = treeNode.id;
  23. FlowConfigObject.scdin_cnf.find("#opt_caption>span").html(treeNode.title);
  24. FlowConfigObject.LoadNodeInfo(treeNode.id);
  25. } else {
  26. layer.msg("请先选择变电站!")
  27. }
  28. }
  29. }
  30. });
  31. },
  32. LoadNodeInfo: function(stationid) {
  33. ParentPage.CurrentUserIds = {};
  34. var nodeListEle = this.node_list;
  35. nodeListEle.html(Tools.LoadingText("正在加载签入节点信息...", "#cccccc"));
  36. $.getJSON(Global.AccessUrl + "/api/flow/cnf/getinfo", {
  37. "station_id": stationid,
  38. "flow_type": this.FlowType
  39. }, function(r) {
  40. if (r.code != 0) {
  41. nodeListEle.html(Tools.LoadingText("审核节点加载失败:" + r.msg, "red"));
  42. return;
  43. }
  44. if (r.data == null || r.data.length == 0) {
  45. nodeListEle.html(Tools.LoadingText("未定义SCD签入审核的节点!", "red"));
  46. return;
  47. }
  48. var nodes = [];
  49. for (var i = 0; i < r.data.length; i++) {
  50. var item = r.data[i];
  51. if (item.staffs == null) item.staffs = [];
  52. nodes.push(item);
  53. }
  54. nodeListEle.html("");
  55. var nodeLen = nodes.length;
  56. for (var i = 0; i < nodeLen; i++) {
  57. var eleId = nodes[i].flow_type + nodes[i].node_id;
  58. nodeListEle.append('<div id="' + eleId + '" style="left:' + ((i + 1) * 20) + 'rem" class="flow_node">' + nodes[i].node_name + '</div>');
  59. }
  60. for (var i = 0; i < nodeLen; i++) {
  61. var nodeid = nodes[i].node_id;
  62. var ele = $("#" + nodes[i].flow_type + nodes[i].node_id),
  63. next = ele.next();
  64. var w = 0,
  65. l = 0,
  66. t = 0;
  67. var eleXY = ele.position();
  68. if (i < (nodeLen - 1)) {
  69. w = next.position().left - eleXY.left - ele.width();
  70. t = eleXY.top + (ele.height() / 2);
  71. l = eleXY.left + ele.width();
  72. nodeListEle.append('<div class="flow_node_line" style="width:' + w + 'px;left:' + l + 'px;top:' + t + 'px"></div>');
  73. nodeListEle.append('<div class="flow_node_line_point" style="left:' + (l + w - 5) + 'px;top:' + (t - 5) + 'px"></div>');
  74. }
  75. //人员指示连线
  76. l = eleXY.left + (ele.width() / 2) + 1;
  77. t = eleXY.top + ele.height() + 2;
  78. var isBindStaffCssName = "";
  79. if ($.trim(nodes[i].staff_name)) isBindStaffCssName = "bind";
  80. nodeListEle.append('<div class="flow_node_person_line" style="height:7rem;left:' + l + 'px;top:' + t + 'px"></div>');
  81. //生成人员关联按钮
  82. nodeListEle.append('<div title="选择人员" class="flow_node_person" node_id="' + nodeid + '" style="left:' + (eleXY.left) + 'px;top:' + (t + 70 * hRate) + 'px;width:' + ele.width() + 'px"><i class="fa fa-user"></i><span class="name">+</span></div>');
  83. //生成已关联的人员列表
  84. var startttop = 70 * hRate;
  85. if (nodes[i].staffs.length > 0) {
  86. for (var s = 0; s < nodes[i].staffs.length; s++) {
  87. var staffinfo = nodes[i].staffs[s];
  88. nodeListEle.append('<div class="flow_node_person text_overflow" node_id="' + nodeid + '" node_inst_id="' + staffinfo.node_inst_id + '" staff_id="' + staffinfo.staff_id + '" style="left:' + (eleXY.left) + 'px;top:' + (t + startttop * (s + 2)) + 'px;width:' + ele.width() + 'px"><i class="fa fa-user bind"></i><span class="name bind">' + (staffinfo.staff_name || '') + '</span><i title="删除该人员" class="fa fa-times"></i></div>');
  89. }
  90. }
  91. }
  92. nodeListEle.find(".flow_node_person").off().on('click', function() {
  93. //打开用户选择窗口
  94. ParentPage.CurrentUserIds = {};
  95. if ($.trim($(this).attr("node_inst_id")) != "") return;
  96. FlowConfigObject.node_list.find(".flow_node_person[node_id='" + $(this).attr("node_id") + "'][node_inst_id]").each(function() {
  97. ParentPage.CurrentUserIds[$(this).attr("staff_id")] = 1;
  98. });
  99. FlowConfigObject.NodeBindPerson($(this));
  100. });
  101. //删除指定的人员
  102. nodeListEle.find(".fa-times").off().on('click', function(e) {
  103. var t = $(this).parent();
  104. e.stopPropagation();
  105. var cNodeId = t.attr("node_id");
  106. var nodeName = FlowConfigObject.node_list.find("#" + FlowConfigObject.FlowType + cNodeId);
  107. var hint = "";
  108. if ($("#node_list .flow_node_person[node_id='" + cNodeId + "'][staff_id]").length == 1) {
  109. //判断是否是第一个节点
  110. if (nodeName.prev().length == 0) {
  111. if ($("#node_list .flow_node_person[staff_id]").length == 1)
  112. hint = "删除人员后,该流程将无法使用。";
  113. else {
  114. layer.msg("流程第一个节点的人员不允许为空!", {
  115. icon: Global.ICON_ERROR
  116. })
  117. return
  118. }
  119. } else {
  120. //当前节点下最的一个人员
  121. hint = "删除人员后,流程流转时将忽略该节点环节。";
  122. }
  123. }
  124. layer.confirm(hint + '确认要删除' + t.find(".name").text() + '的<b>' + nodeName.text() + '</b>权限吗?', {
  125. icon: Global.ICON_ASK,
  126. btn: ['确定', '取消'] //按钮
  127. }, function(index) {
  128. layer.close(index);
  129. $.post(Global.AccessUrl + "/api/flow/cnf/deleteuser", {
  130. node_inst_id: t.attr("node_inst_id"),
  131. user_id: t.attr("staff_id")
  132. }, function(r) {
  133. if (r.code != 0) {
  134. layer.msg("人员节点权限删除失败:" + r.msg);
  135. return;
  136. }
  137. layer.msg("人员节点权限删除成功");
  138. FlowConfigObject.LoadNodeInfo(FlowConfigObject.StationID);
  139. });
  140. });
  141. });
  142. });
  143. },
  144. NodeBindPerson: function(eleObj) {
  145. this.CurrNode = eleObj;
  146. layui.layer.open({
  147. type: 2,
  148. resize: false,
  149. scrollbar: false,
  150. title: "人员选择",
  151. area: ['600px', '530px'],
  152. content: "/static/module/childmodule/select_user.html"
  153. });
  154. },
  155. SaveSelectedUser: function(selectUserList) {
  156. var uids = [],
  157. unames = [];
  158. for (var i = 0; i < selectUserList.length; i++) {
  159. uids.push(selectUserList[i].userid);
  160. unames.push(selectUserList[i].username);
  161. }
  162. if (uids.length > 0) {
  163. layer.msg("正在保存节点人员信息...");
  164. $.post(Global.AccessUrl + "/api/flow/node/refuser", {
  165. "station_id": FlowConfigObject.StationID,
  166. "node_inst_id": $.trim(FlowConfigObject.CurrNode.attr("node_inst_id")),
  167. "node_id": $.trim(this.CurrNode.attr("node_id")),
  168. "user_ids": uids.join(",")
  169. }, function(r) {
  170. if (r.code != 0) {
  171. layer.msg("节点人员信息保存失败:" + r.msg);
  172. return;
  173. }
  174. layer.msg("节点人员信息保存成功");
  175. FlowConfigObject.LoadNodeInfo(FlowConfigObject.StationID);
  176. });
  177. }
  178. }
  179. };
  180. var FlowObject = {
  181. paginationLoaded: false,
  182. //是否有文件正在上传.0表示没有,大于0则表示有文件上传中
  183. fileUploading: 0,
  184. StationID: "",
  185. FlowType: "",
  186. CurrNodeCode: "", //当前正在处理的节点编码
  187. NodeListEle: null,
  188. Win: null,
  189. FlowRunID: "", //当前流程实例ID
  190. CheckTypeCodes: [], //签入签出类型代码表
  191. CheckChildTypeCodes: [], //签入签出子类型代码表
  192. Init: function(win) {
  193. this.Win = win;
  194. },
  195. //获取锁定的任务
  196. GetLockScd: function(callback) {
  197. $.getJSON(Global.AccessUrl + "/api/flow/lock/list", {
  198. "station_id": this.StationID
  199. }, function(r) {
  200. if (callback != null) return callback(r);
  201. })
  202. },
  203. //获取正在处理中的最近一条任务
  204. GetLastDealIng: function(callback) {
  205. $.getJSON(Global.AccessUrl + "/api/flow/run/list", {
  206. "station_id": this.StationID,
  207. "flowstate": "",
  208. "pageno": 1,
  209. "pagesize": 1
  210. }, function(r) {
  211. if (r.code != 0) {
  212. return;
  213. }
  214. if (r.data == null || r.data.length == 0) {
  215. //没有正在流转中的scd.可进行签入签出操作
  216. $("#scdin_btn").removeClass("stop_action").attr("title", "");
  217. $("#scdout_btn").addClass("stop_action").attr("title", "禁止操作");
  218. return;
  219. }
  220. var hasCheckOut = r.data[0].flow_type == "scdout";
  221. var hasCheckIn = r.data[0].flow_type == "scdin";
  222. var ischeckout_lock = r.data[0].checkout_lock;
  223. if (r.data[0].deal_state == "1" && ischeckout_lock == "1") {
  224. //有锁定等待签入的scd时,不能进行签出
  225. $("#scdin_btn").removeClass("stop_action").attr("title", "");
  226. $("#scdout_btn").addClass("stop_action").attr("title", "禁止操作");
  227. return;
  228. }
  229. if (ischeckout_lock == "0") {
  230. //强制终止的签出时,只能进行签出
  231. $("#scdin_btn").addClass("stop_action").attr("title", "禁止操作");
  232. $("#scdout_btn").removeClass("stop_action").attr("title", "");
  233. }
  234. if (r.data[0].deal_state != "1") {
  235. $("#scdin_btn").addClass("stop_action").attr("title", "禁止操作");
  236. $("#scdout_btn").addClass("stop_action").attr("title", "禁止操作");
  237. }
  238. })
  239. },
  240. //获取当前站的scd签入签出记录
  241. GetScdInoutRecord: function(pageno, pagesize, callback) {
  242. layer.msg("正在加载数据中...");
  243. var dt1 = $("#cond_dt1").val();
  244. var dt2 = $("#cond_dt2").val();
  245. $.getJSON(Global.AccessUrl + "/api/flow/run/list", {
  246. "station_id": this.StationID,
  247. "dt1": dt1,
  248. "dt2": dt2,
  249. "name": $("#cond_name").val(),
  250. "flowtype": $("#cond_flowtype").val(),
  251. "flowstate": $("#cond_flowstate").val(),
  252. "pageno": pageno,
  253. "pagesize": pagesize
  254. }, function(r) {
  255. layer.closeAll();
  256. if (callback != null) return callback(r);
  257. })
  258. this.GetLastDealIng();
  259. },
  260. LoadNodeInfo: function(nodeListEle, islook) {
  261. this.NodeListEle = nodeListEle;
  262. nodeListEle.html(Tools.HintText("正在加载节点信息...", "#cccccc").replace("15%", "4%"));
  263. $.getJSON(Global.AccessUrl + "/api/flow/cnf/getinfo", {
  264. "station_id": this.StationID,
  265. "flow_type": this.FlowType,
  266. "userfilter": "1" //根据当前登录人进行节点过滤
  267. }, function(r) {
  268. if (r.code != 0) {
  269. nodeListEle.html(Tools.HintText("审核节点加载失败:" + r.msg, "red").replace("15%", "4%"));
  270. return;
  271. }
  272. if (r.data == null || r.data.length == 0) {
  273. nodeListEle.html(Tools.HintText("未定义SCD签入审核的节点!", "red").replace("15%", "4%"));
  274. return;
  275. }
  276. var nodes = [];
  277. for (var i = 0; i < r.data.length; i++) {
  278. var item = r.data[i];
  279. //未设置处理人员的节点,直接跳过
  280. if (item.staffs == null || item.staffs.length == 0) continue;
  281. nodes.push(item);
  282. }
  283. if (nodes.length == 0) {
  284. nodeListEle.html(Tools.HintText("您还未分配任何SCD签入节点的操作权限!", "red").replace("15%", "4%"));
  285. return;
  286. }
  287. nodeListEle.html("");
  288. var nodeLen = nodes.length;
  289. //计算节点left位置
  290. var initleft = (nodeListEle.width() - (nodeLen * 170 - 100)) / 2;
  291. var nhtmls = [];
  292. for (var i = 0; i < nodeLen; i++) {
  293. nhtmls.push('<div id="' + nodes[i].node_code + '" style="left:' + ((i + 1) * initleft) + 'px" class="flow_node disable"><span class="number">' + (i + 1) + '</span><span class="nodetext">' + nodes[i].node_name + '</span>');
  294. if (i < nodeLen - 1) {
  295. nhtmls.push('<span style="vertical-align: middle;height:1px;width:10rem;display: inline-block;background: #00C968;margin: 0 0.5rem;"></span>');
  296. }
  297. nhtmls.push('</div>');
  298. }
  299. nodeListEle.html(nhtmls.join(""));
  300. nodeListEle.find(".flow_node").off().on('click', function() {
  301. var t = $(this);
  302. if (t.hasClass("disable")) return;
  303. //显示当前点击节点的表单
  304. FlowObject.ShowWorkBook(t.attr("id"));
  305. }).each(function(ind) {
  306. if (ind == 0) {
  307. return;
  308. }
  309. var t = $(this),
  310. t0 = t.prev();
  311. t.css("left", t0.width() + t0.position().left);
  312. });
  313. if (FlowObject.CurrNodeCode != "") {
  314. FlowObject.SetDealNode(FlowObject.CurrNodeCode, islook);
  315. if (islook == "islook" && FlowObject.CurrNodeCode != "all") {
  316. //查看流程时,只能查看当前节点之前的节点信息
  317. var prevEle = nodeListEle.find("#" + FlowObject.CurrNodeCode).prev();
  318. if (prevEle.length > 0) FlowObject.ShowWorkBook(prevEle.attr("id"), islook);
  319. else {
  320. prevEle = nodeListEle.find(".flow_node:first");
  321. if (prevEle.length > 0) {
  322. FlowObject.ShowWorkBook(prevEle.attr("id"), islook);
  323. }
  324. }
  325. } else if (islook == "islook" && FlowObject.CurrNodeCode == "all") {
  326. //查看流程时,如果流程已结束,默认查看第一个节点信息
  327. FlowObject.ShowWorkBook(nodeListEle.children(".flow_node:first").attr("id"), islook);
  328. } else {
  329. FlowObject.ShowWorkBook(FlowObject.CurrNodeCode, islook);
  330. }
  331. return;
  332. }
  333. FlowObject.SetDealNode(nodes[0].node_code, islook);
  334. //默认显示编制节点的表单
  335. FlowObject.ShowWorkBook(nodes[0].node_code, islook);
  336. });
  337. },
  338. FlowUnlock: function(evt, scdid, flowRunID, reason) {
  339. var $evt = $(evt);
  340. if ($.trim($evt.attr("isbusy")) == "1") {
  341. layer.msg("不能重复操作!");
  342. return;
  343. }
  344. layer.confirm("<div style='text-align:center;'><textarea style='width: 100%;height: 10rem;' id='flow_reason' value='' placeholder='请输入原因,100字符内' maxlenght=100></textarea></div>", {
  345. "title": "终止原因"
  346. },
  347. function(index) {
  348. var v = $.trim($("#flow_reason").val());
  349. $evt.attr("isbusy", "1").html(Tools.LoadingText("..."));
  350. $.post(Global.AccessUrl + "/api/screen/scd/unlock", {
  351. "scd_id": scdid,
  352. "flow_run_id": flowRunID,
  353. "reason": v
  354. }, function(r) {
  355. $evt.attr("isbusy", "0").html("终止");
  356. if (r.code != 0) {
  357. layer.msg("操作失败:" + r.msg);
  358. return;
  359. }
  360. layer.msg("终止操作成功!");
  361. $("#scdout_btn").removeClass("stop_action").attr("title", "");
  362. FlowObject.GetScdInoutRecord(1, 10, MakeScdInoutRecord);
  363. layer.closeAll();
  364. });
  365. });
  366. },
  367. //设置当前正在处理的节点
  368. SetDealNode: function(nodecode, islook) {
  369. this.CurrNodeCode = nodecode;
  370. if (nodecode == null || nodecode == 0) {
  371. this.NodeListEle.find(".flow_node:first").attr("class", "flow_node active");
  372. return;
  373. }
  374. if (nodecode == "all") {
  375. this.NodeListEle.find(".flow_node").attr("class", "flow_node deal");
  376. return;
  377. }
  378. var ind = this.NodeListEle.find("#" + nodecode).attr("class", islook == "islook" ? "flow_node disable" : "flow_node active");
  379. this.NodeListEle.find(".flow_node:lt(" + ind.index() + ")").attr("class", "flow_node deal");
  380. },
  381. //查看指定节点数据信息
  382. ShowWorkBook: function(nodecode, islook) {
  383. var ele = this.Win.find(".dataitemlist").attr("node_code", nodecode);
  384. ele.height(this.Win.height() - this.Win.find(".caption").height() - this.Win.find(".node_area").height() - 10)
  385. var tplID = "form_" + nodecode + "_tpl";
  386. var h = template(tplID, {});
  387. ele.html(h);
  388. //加载签入类型
  389. //如果已经签入过scd,则不能再选择“新建”
  390. var newInTypeList = [];
  391. if (PoliceObject.ScdList != null && PoliceObject.ScdList.length > 0) {
  392. for (var i = 0; i < FlowObject.CheckTypeCodes.length; i++) {
  393. if (FlowObject.CheckTypeCodes[i].name == "新建") continue;
  394. newInTypeList.push(FlowObject.CheckTypeCodes[i]);
  395. }
  396. } else {
  397. //第一次签入,只有新建
  398. for (var i = 0; i < FlowObject.CheckTypeCodes.length; i++) {
  399. if (FlowObject.CheckTypeCodes[i].name != "新建") continue;
  400. newInTypeList.push(FlowObject.CheckTypeCodes[i]);
  401. }
  402. }
  403. ele.find("#checkintype").html(template('system_code_item_tpl', {
  404. data: newInTypeList
  405. }));
  406. //签出时,不需要”新建“类型
  407. var newOutTypelist = [];
  408. for (var i = 0; i < FlowObject.CheckTypeCodes.length; i++) {
  409. if (FlowObject.CheckTypeCodes[i].name == "新建") continue;
  410. newOutTypelist.push(FlowObject.CheckTypeCodes[i]);
  411. }
  412. ele.find("#checkouttype").html(template('system_code_item_tpl', {
  413. data: newOutTypelist
  414. }));
  415. if (FlowObject.FlowType == "scdout") {
  416. //加载scd列表
  417. if (PoliceObject.ScdList == null || PoliceObject.ScdList.length == 0) {
  418. layer.msg("请先确定当前的在运版SCD!", {
  419. icon: Global.ICON_HINT
  420. })
  421. return
  422. }
  423. ele.find("#scd_list").val(PoliceObject.ScdList[0].id);
  424. ele.find("#scd_name").val(PoliceObject.ScdList[0].scd_name);
  425. }
  426. //如果非第一次签入时,需要显示上一次签出工作内容
  427. if (nodecode == "checkinstart" && PoliceObject.ScdList != null && PoliceObject.ScdList.length > 0) {
  428. var divEle = $("#checkout_workbook").removeClass("hidden");
  429. $("#checkout_workarea").removeClass("hidden");
  430. $.getJSON(Global.AccessUrl + "/api/flow/getlastoutworkbook", {
  431. "station_id": FlowObject.StationID
  432. }, function(r) {
  433. if (r.code != 0) {
  434. return;
  435. }
  436. var content = r.data;
  437. if (content == null || content == "") {
  438. return;
  439. }
  440. content = JSON.parse(content);
  441. var work_area_name = $.trim(content.work_area_name);
  442. $("#checkout_workarea #work_area_name").val(work_area_name);
  443. var workbookno = content.workbookno;
  444. var workbookno_file = content.workbookno_file;
  445. var workbookno_name = content.workbookno_name;
  446. divEle.find("#checkout_workboono").val(workbookno).attr("title", workbookno);
  447. if (workbookno_file != "") {
  448. divEle.find(".file-name").html('<a download="' + workbookno_name + '" href="' + workbookno_file + '">' + workbookno_name + '</a>');
  449. }
  450. });
  451. }
  452. layui.use(['form', 'layer', 'upload', "laydate"], function() {
  453. layui.form.render("select");
  454. layui.laydate.render({
  455. elem: "#overdate"
  456. });
  457. //文件上传绑定
  458. var uploadInst = layui.upload.render({
  459. elem: '.file_upload_btn',
  460. url: Global.AccessUrl + '/api/uploadfile',
  461. accept: "file",
  462. size: 1024 * 1024, //文件大小限制为不超过1G
  463. auto: false,
  464. choose: function(obj) {
  465. obj.preview(function(index, file) {
  466. var fix = file.name.split(".");
  467. if (fix.length == 1) {
  468. layer.msg("该类型文件不允许上传!", {
  469. icon: Global.ICON_ERROR
  470. })
  471. return false;
  472. }
  473. fix = fix[fix.length - 1].toLocaleLowerCase();
  474. if (fix == "bat" || fix == "sh" || fix == "sql" || fix == "exe") {
  475. layer.msg("该类型文件不允许上传!", {
  476. icon: Global.ICON_ERROR
  477. })
  478. return false;
  479. }
  480. if (fix == "rar") {
  481. layer.msg("不支持rar压缩包,请上传zip格式的压缩包!", {
  482. icon: Global.ICON_ERROR
  483. })
  484. return false;
  485. }
  486. obj.upload(index, file) //上传文件操作
  487. });
  488. },
  489. before: function(obj) {
  490. this.data = {
  491. data_type: $.trim(this.item.attr("datatype")),
  492. station_id: PoliceObject.AreaID,
  493. is_checkin: 1
  494. };
  495. var targetEle = this.item.parent().parent();
  496. targetEle.find(".file-path").val('');
  497. var filename = targetEle.find(".file-name");
  498. filename.each(function() {
  499. var fele = $(this);
  500. if (fele[0].tagName == 'INPUT') fele.val('正在上传文件中...');
  501. else fele.html('正在上传文件中...');
  502. })
  503. FlowObject.fileUploading++;
  504. FlowObject.Win.find(".file_upload_btn").attr("disabled", true).attr("title", "请等待正在上传的文件完成");
  505. //预读本地文件示例,不支持ie8
  506. //obj.preview(function(index, file, result) {
  507. // $('#demo1').attr('src', result); //图片链接(base64)
  508. //});
  509. },
  510. done: function(res) {
  511. FlowObject.Win.find(".file_upload_btn").attr("disabled", false).attr("title", "");
  512. var targetEle = this.item.parent().parent();
  513. FlowObject.fileUploading--;
  514. //如果上传失败
  515. if (res.code != 0) {
  516. targetEle.find(".file-name").val('');
  517. return layer.msg('上传失败:' + res.msg, {
  518. icon: Global.ICON_ERROR
  519. });
  520. }
  521. //var demoText = $('#demoText');
  522. // demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
  523. //$("#imagepath").val(res.image)
  524. layer.msg("上传成功", {
  525. icon: Global.ICON_OK
  526. })
  527. targetEle.find(".file-path").val(res.data.path);
  528. if (this.item.attr("datatype") == "scd") {
  529. //进行scd解析过程进行mqtt发布消息提示时需要使用到该变量值
  530. PoliceObject.CurentParseScdName = res.data.filename;
  531. }
  532. var filename = targetEle.find(".file-name");
  533. filename.each(function() {
  534. var fele = $(this);
  535. if (fele[0].tagName == 'INPUT') fele.val(res.data.filename);
  536. else fele.html(res.data.filename);
  537. });
  538. },
  539. error: function() {
  540. //演示失败状态,并实现重传
  541. return layer.msg('上传失败', {
  542. icon: Global.ICON_ERROR
  543. });
  544. }
  545. });
  546. var getChildType = function(pcode, cldele) {
  547. //加载子类型
  548. $.getJSON(Global.AccessUrl + "/api/getGlobalCode", {
  549. "pcode": pcode + "_cld"
  550. }, function(r) {
  551. cldele.html(template('system_code_item_tpl', {
  552. data: r.data || []
  553. }));
  554. layui.form.render("select");
  555. });
  556. }
  557. //类型选择框事件绑定
  558. layui.form.on("select(checkintype)", function(data) {
  559. var checkTxt = $.trim($("#checkintype option:checked").text());
  560. if (checkTxt != "" && "新建".indexOf(checkTxt.substring(0, 2)) > -1) {
  561. ele.find("#checkinchildtype").parent().addClass("hidden").parent().parent().addClass("hidden");
  562. } else {
  563. ele.find("#checkinchildtype").parent().removeClass("hidden").parent().parent().removeClass("hidden");
  564. }
  565. ele.find("#checkintype_text").val(checkTxt);
  566. $("#checkinchildtype_memo").html("").val("").parent().addClass("hidden");
  567. getChildType($(data.elem).find("option:checked").attr("code"), ele.find("#checkinchildtype"));
  568. });
  569. layui.form.on("select(checkouttype)", function(data) {
  570. var checkTxt = $.trim($("#checkouttype option:checked").text());
  571. if (checkTxt != "" && "新建".indexOf(checkTxt.substring(0, 2)) > -1) {
  572. ele.find("#checkoutchildtype").parent().parent().parent().addClass("hidden");
  573. } else {
  574. ele.find("#checkoutchildtype").parent().parent().parent().removeClass("hidden");
  575. }
  576. ele.find("#checkouttype_text").val(checkTxt);
  577. $("#checkoutchildtype_memo").html("").val("").parent().addClass("hidden");
  578. getChildType($(data.elem).find("option:checked").attr("code"), ele.find("#checkoutchildtype"));
  579. });
  580. //子类型选择框事件绑定
  581. layui.form.on("select(checkinchildtype)", function(data) {
  582. var checkTxt = $.trim($("#checkinchildtype option:checked").text());
  583. if (checkTxt != "" && "其他,其它".indexOf(checkTxt.substring(0, 2)) > -1) {
  584. ele.find("#checkinchildtype_memo").removeClass("hidden").focus().parent().removeClass("hidden");
  585. } else {
  586. ele.find("#checkinchildtype_memo").addClass("hidden").html("").val("").parent().addClass("hidden");
  587. }
  588. ele.find("#checkinchildtype_text").val(checkTxt);
  589. });
  590. layui.form.on("select(checkoutchildtype)", function(data) {
  591. var checkTxt = $.trim($("#checkoutchildtype option:checked").text());
  592. if (checkTxt != "" && "其他,其它".indexOf(checkTxt.substring(0, 2)) > -1) {
  593. ele.find("#checkoutchildtype_memo").removeClass("hidden").focus().parent().removeClass("hidden");
  594. } else {
  595. ele.find("#checkoutchildtype_memo").addClass("hidden").html("").val("").parent().addClass("hidden");
  596. }
  597. ele.find("#checkoutchildtype_text").val(checkTxt);
  598. });
  599. //scd选择框事件绑定
  600. layui.form.on("select(scd_list)", function(data) {
  601. if (data.value == "") {
  602. $("#scd_name,#scd_file").val('');
  603. return;
  604. }
  605. var checkTxt = $.trim($("#scd_list option:checked").text());
  606. for (var i = 0; i < PoliceObject.ScdList.length; i++) {
  607. if (PoliceObject.ScdList[i].id == data.value) {
  608. $("#scd_name").val(PoliceObject.ScdList[i].name);
  609. $("#scd_file").val(PoliceObject.ScdList[i].path);
  610. break;
  611. }
  612. }
  613. });
  614. });
  615. var ReadonlyForm = function(ele) {
  616. ele.find("input,select,textarea").removeClass("layui-input").addClass("input2span").attr({
  617. "disabled": true,
  618. "placeholder": ""
  619. });
  620. ele.find("select").each(function() {
  621. var selEle = $(this);
  622. var selId = selEle.attr("id");
  623. selEle.next().remove();
  624. selEle.remove();
  625. $("#" + selId + "_text").attr("type", "text");
  626. });
  627. }
  628. //如果点击的节点是已经处理过的,则不显示tools栏
  629. if (this.Win.find("#" + nodecode).hasClass("deal") || islook == "islook") {
  630. ele.find(".layui-tools,button").remove();
  631. ReadonlyForm(ele);
  632. }
  633. ele.find(".layui-form:eq(0)").slimScroll({
  634. height: ele.height() - ele.children(".layui-tools").height() - ele.children(".layui-tops").height() - ele.children(".pagebar").height() - ((ele.children(".pagebar").css("margin-top") || "").replace("px", "") * 1) + "px",
  635. width: "100%",
  636. alwaysVisible: false,
  637. wheelStep: 10,
  638. size: "6px",
  639. color: "#03aee7"
  640. }).css({
  641. "width": "98%"
  642. });
  643. if (FlowObject.FlowRunID != "") {
  644. //加载当前节点的表单信息
  645. //如果当前节点为checkinaudit审核时,加载编制节点的基本信息以及校验结果
  646. //如果当前节点不是签出编制节点时,加载签出编制节点的基本信息
  647. var queryNode = nodecode;
  648. if (nodecode == "checkinaudit" || nodecode == "checkinend") queryNode = "checkinstart";
  649. if (nodecode == "checkoutcheck" || nodecode == "checkoutend") queryNode = "checkoutstart";
  650. $.getJSON(Global.AccessUrl + "/api/flow/node/getdata", {
  651. "flow_run_id": FlowObject.FlowRunID,
  652. "station_id": FlowObject.StationID,
  653. "flow_type": FlowObject.FlowType,
  654. "node_code": queryNode
  655. }, function(r) {
  656. if (r.code != 0) {
  657. layer.msg(r.msg);
  658. return;
  659. }
  660. var scd_name = r.data.scd_name;
  661. var scd_path = r.data.scd_path;
  662. ///api/scd/check/resultlist
  663. if (nodecode == "checkincheck" || nodecode == "checkinaudit" || nodecode == "checkinend") {
  664. //只有校验节点才查询校验结果信息
  665. function getCheckResultList(pageno, level) {
  666. $.getJSON(Global.AccessUrl + "/api/scd/check/resultlist", {
  667. "scd_name": scd_name,
  668. "scd_path": scd_path,
  669. "level": level,
  670. "pageno": pageno,
  671. "pagesize": 20
  672. }, function(r) {
  673. var h = template('form_checkincheck_result_tpl', r);
  674. FlowObject.Win.find(".layui-form[lay-filter='checkincheck']").html(h);
  675. //生成分页
  676. if (!FlowObject.paginationLoaded) {
  677. FlowObject.Win.find(".pagebar").pagination(r.count, {
  678. num_edge_entries: 2,
  679. num_display_entries: 6,
  680. prev_show_always: false,
  681. next_show_always: false,
  682. prev_text: "&lt;",
  683. next_text: "&gt;",
  684. callback: function(page_index, jq) {
  685. getCheckResultList(page_index + 1, level);
  686. },
  687. items_per_page: 20
  688. });
  689. FlowObject.paginationLoaded = true;
  690. //查询告警统计.只查询一次告警统计数量
  691. $.getJSON(Global.AccessUrl + "/api/scd/check/stat/level", {
  692. "scd_name": scd_name,
  693. "scd_path": scd_path
  694. }, function(r1) {
  695. if (r1.data == null) return;
  696. for (var i = 0; i < r1.data.length; i++) {
  697. var item = r1.data[i];
  698. var alertlevel = item["alert_level"];
  699. FlowObject.Win.find(".layui-tops span[alert_level='" + alertlevel + "']>b").html(item.cnt);
  700. }
  701. FlowObject.Win.find(".layui-tops span[alert_level]").off().on("click", function() {
  702. FlowObject.paginationLoaded = false;
  703. getCheckResultList(1, $(this).attr("alert_level"));
  704. });
  705. });
  706. }
  707. });
  708. }
  709. getCheckResultList(1, "");
  710. }
  711. var job_content = r.data.job_content || "";
  712. if (job_content == "") return;
  713. job_content = JSON.parse(job_content);
  714. for (var attr in job_content) {
  715. var inputele = FlowObject.Win.find("#" + attr);
  716. if (inputele.length == 0) continue;
  717. var v = job_content[attr] || "";
  718. if (inputele[0].tagName == "INPUT" || inputele[0].tagName == "SELECT" || inputele[0].tagName == "TEXTAREA") inputele.val(v);
  719. else inputele.html(v);
  720. if (attr == "checkintype" && v == "新建") {
  721. //不显示子类型
  722. $("#checkinchildtype").parent().parent().parent().addClass("hidden");
  723. }
  724. }
  725. layui.form.render("select");
  726. //if (nodecode == "checkinaudit" || nodecode == "checkinend" || nodecode == "checkoutcheck" || nodecode == "checkoutend") {
  727. //审核和发布节点时,表单内容都只是查看,不进行编辑
  728. ReadonlyForm(ele);
  729. ele.find("input.file-name").each(function() {
  730. var t = $(this),
  731. fname = t.val(),
  732. fpath = t.next().val();
  733. t.attr("type", "text");
  734. if (t.attr("id") == "scd_name" || fname == "") return;
  735. t.parent().next().html("<a style='color: #5656b0;border-bottom: 1px solid #5656b0;cursor: pointer;' download='" + fname + "' href='" + fpath + "'>下载</a>");
  736. });
  737. //}
  738. });
  739. }
  740. },
  741. //查看流转过程
  742. LookFlow: function(e) {
  743. var t = $(e);
  744. var flow_run_id = t.attr("flow_run_id");
  745. var flow_type = t.attr("flow_type");
  746. var node_code = t.attr("node_code");
  747. FlowObject.CurrNodeCode = t.attr("isend") == "1" ? "all" : node_code;
  748. FlowObject.FlowType = flow_type;
  749. FlowObject.FlowRunID = flow_run_id;
  750. DialogObject.Open($("#dialog_public"), {
  751. size: ["100rem", "70rem"],
  752. para: {
  753. "flow_type": flow_type,
  754. "flow_run_id": flow_run_id
  755. },
  756. callback: function(win, para) {
  757. win.find(".caption>b").html(para.flow_type == "scdin" ? "SCD文件签入" : "SCD文件签出");
  758. FlowObject.Init(win);
  759. FlowObject.LoadNodeInfo(win.find(".node_area"), "islook");
  760. }
  761. });
  762. },
  763. DealNode: function(e) {
  764. if (FlowObject.fileUploading > 0) {
  765. layer.msg("还有文件正在上传中,请在上传完成后重试!")
  766. return;
  767. }
  768. var t = $(e);
  769. var flow_run_id = t.attr("flow_run_id");
  770. var node_code = t.attr("node_code");
  771. FlowObject.FlowType = t.attr("flow_type");
  772. FlowObject.FlowRunID = flow_run_id;
  773. FlowObject.CurrNodeCode = node_code;
  774. FlowObject.isCommit = false;
  775. DialogObject.Open($("#dialog_public"), {
  776. size: ["100rem", "70rem"],
  777. para: {},
  778. callback: function(win, para) {
  779. win.find(".caption>b").html(FlowObject.FlowType == "scdin" ? "SCD文件签入" : "SCD文件签出");
  780. FlowObject.Init(win);
  781. FlowObject.paginationLoaded = false;
  782. FlowObject.LoadNodeInfo(win.find(".node_area"));
  783. },
  784. onSave: function(win, para, clickbtn) {
  785. if (FlowObject.isCommit) {
  786. layer.msg("不允许重复提交数据!")
  787. return;
  788. }
  789. if ("0" == $(clickbtn).attr("notcheck")) {
  790. layer.msg("需要先进行SCD校核才能提交!")
  791. return;
  792. }
  793. var formItems = Global.GetFormData("", win.find(".layui-form"));
  794. if (formItems == null) return;
  795. var optvalue = "";
  796. if (clickbtn != null) optvalue = $.trim($(clickbtn).attr("opt"));
  797. if (optvalue == "0") {
  798. //驳回
  799. }
  800. layer.msg("正在提交数据中...", {
  801. time: 0
  802. });
  803. FlowObject.isCommit = true;
  804. $.post(Global.AccessUrl + "/api/flow/run/nodedeal/save", {
  805. "flow_run_id": FlowObject.FlowRunID,
  806. "station_id": FlowObject.StationID,
  807. "flow_type": FlowObject.FlowType,
  808. "node_code": FlowObject.CurrNodeCode,
  809. "opt": optvalue, //1:通过 0 驳回
  810. "content": JSON.stringify(formItems)
  811. }, function(r) {
  812. FlowObject.isCommit = false;
  813. layer.closeAll();
  814. if (r.code != 0) {
  815. layer.msg("数据提交失败:" + r.msg);
  816. return;
  817. }
  818. layer.msg("操作数据提交成功!", {
  819. time: 5000,
  820. icon: Global.ICON_OK
  821. });
  822. $("#scdin_btn").addClass("stop_action");
  823. setTimeout(function() {
  824. FlowObject.GetScdInoutRecord(1, 10, MakeScdInoutRecord);
  825. win.find(".fa-times").trigger("click");
  826. }, 5000);
  827. });
  828. }
  829. });
  830. },
  831. //查看流程详情
  832. Detail: function(e) {
  833. var t = $(e);
  834. DialogObject.Open($("#dialog_public"), {
  835. size: ["100rem", "50rem"],
  836. para: {
  837. detail_id: t.attr("detail_id")
  838. },
  839. callback: function(win, para) {
  840. win.find(".caption>b").html("审批流程详情");
  841. }
  842. });
  843. }
  844. }