Widget.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. import BaseWidget = require('core/BaseWidget.class');
  2. import AjaxSend = require("common/AjaxSend.class");
  3. import MapSet = require("common/MapSet.class");
  4. import VerificationHelper = require("common/VerificationHelper.class");
  5. import GraphicsLayer = require("esri/layers/GraphicsLayer");
  6. import Graphic = require("esri/graphic");
  7. import Point = require("esri/geometry/Point");
  8. import Polyline = require('esri/geometry/Polyline');
  9. import { data } from 'jquery';
  10. enum operation {
  11. create, destroy, clear
  12. }
  13. export = HiddenTroubleTransAudit;
  14. class HiddenTroubleTransAudit extends BaseWidget {
  15. baseClass = "widget-HiddenTroubleTransAudit";
  16. preLayerId = 'HalfPanel' + this.baseClass;
  17. clusters = this.preLayerId + 'Clusters';
  18. popClass = this.baseClass + 'PopClass';
  19. map = null;
  20. toast = null;
  21. popup = null;
  22. loadWait = null;
  23. ajaxSend = null;
  24. fristSearch = true;
  25. dataTable = null;
  26. searchInfo = null;
  27. verificationHelper = null;
  28. selectTableGraphic = null;//点击列表显示的图层
  29. selectTablePoint = null;
  30. selectTableLine = null;
  31. mapSet = null;
  32. /**
  33. * @function 初始化启动
  34. */
  35. startup() {
  36. this.configure();
  37. this.initHtml();
  38. this.initEvent();
  39. this.getInfoList();
  40. this.getAllInfo();
  41. this.getGroup();
  42. }
  43. /**
  44. * @function 页面初始化
  45. */
  46. initHtml() {
  47. var html = _.template(this.template.split('$$')[0] + "</div>")();
  48. this.setHtml(html);
  49. this.ready();
  50. }
  51. configure() {
  52. this.toast = this.AppX.runtimeConfig.toast;
  53. this.popup = this.AppX.runtimeConfig.popup;
  54. this.map = this.AppX.runtimeConfig.map;
  55. this.ajaxSend = new AjaxSend();
  56. this.loadWait = this.AppX.runtimeConfig.loadWait;
  57. this.verificationHelper = new VerificationHelper();
  58. this.mapSet = new MapSet();
  59. //隐患选中后的颜色设置
  60. this.selectTablePoint = this.mapSet.setGraphSymbol("point");
  61. this.selectTableLine = this.mapSet.setGraphSymbol("polyline");
  62. }
  63. /**
  64. * 选中列表图层的渲染创建、销毁、清理
  65. * @param action 通过枚举operation控制操作
  66. */
  67. initSelectTableGraphic(action) {
  68. if (action == operation.destroy && this.selectTableGraphic) {
  69. this.map.removeLayer(this.selectTableGraphic);
  70. this.selectTableGraphic = null;
  71. }
  72. if (action == operation.create && !this.selectTableGraphic) {
  73. this.selectTableGraphic = new GraphicsLayer();
  74. this.selectTableGraphic.id = this.preLayerId + "selectTableGraphic";
  75. this.map.addLayer(this.selectTableGraphic);
  76. }
  77. if (action == operation.clear && this.selectTableGraphic) {
  78. this.selectTableGraphic.clear();
  79. }
  80. }
  81. /**
  82. * 初始化事件
  83. */
  84. initEvent() {
  85. this.initSelectTableGraphic(operation.create);
  86. this.domObj.find(".btn_search").off().click(e => {
  87. this.getInfoList();
  88. });
  89. //部门列表
  90. this.domObj.find('.department').on("change", function () {
  91. this.getUser( this.domObj.find(".department").val());
  92. }.bind(this));
  93. }
  94. /**
  95. * 初始化班组长审核环节
  96. */
  97. initPage(dataInfo) {
  98. this.popup.setSize(1000, 730);
  99. var Obj = this.popup.Show("隐患转派", this.template.split('$$')[1]);
  100. let getHtml = this.AppX.runtimeConfig.hiddenPageInfo;
  101. let dataState=[];
  102. dataState.push(getHtml.state.hiddenReport);//1 /**上报信息*/
  103. if(dataInfo.isDiscretionId != '1'){
  104. dataState.push(getHtml.state.dispatchAudit);//2 /**派工审核*/
  105. }
  106. dataState.push(getHtml.state.transfer)//5审核
  107. getHtml.getLinkHtml(this, Obj.conObj.find('.widget-HiddenTroubleTransAudit-pop'), dataState, getHtml.state.transfer, dataInfo);
  108. getHtml.setDepartmentAndUser(this, Obj.conObj.find('.transDepartment'), Obj.conObj.find('.transferHandleUser'));
  109. Obj.submitObj.off("click").on("click", function () {
  110. let data = this.getWriteInfo(Obj.conObj);
  111. let sendData= new FormData();
  112. sendData.append("isTransfer",'1');
  113. sendData.append("id",this.dataTable.aExtentData.currentTableData.id);
  114. sendData.append("troubleTransfer.transferHandleUser",data.transferHandleUser);
  115. sendData.append("troubleTransfer.transferReason",data.transferReason);
  116. sendData.append("troubleTransfer.troubleId",this.dataTable.aExtentData.currentTableData.id);
  117. this.ajaxSend.sendFileAjax(this, sendData, this.config.backTrouble, this.ajaxSend.type.post, this.HiddenReport.bind(this));
  118. }.bind(this))
  119. // }
  120. }
  121. /**
  122. * 班组长后的回调
  123. * @param results 班组长后的回调
  124. */
  125. HiddenReport(results) {
  126. if (this.ajaxSend.checkResults(this, results)) {
  127. this.popup.close();
  128. this.toast.show("处理成功");
  129. this.getInfoList();
  130. }
  131. }
  132. /**
  133. * 获取pop表单里面的数据(通过name属性进行json化)
  134. * @param obj pop表单的jq对象
  135. * */
  136. getWriteInfo(obj) {
  137. let data = new Object();
  138. //获取input里面的数据
  139. let dataDom = obj.find('.form-group.form-inline input:not([readonly])')
  140. for (var i = 0; i < dataDom.length; i++) {
  141. if (dataDom[i].type != 'file') {
  142. Object.defineProperty(data, dataDom[i].name, {
  143. configurable: true,
  144. writable: true,
  145. enumerable: true,
  146. value: dataDom[i].value
  147. })
  148. } else {
  149. Object.defineProperty(data, dataDom[i].name, {
  150. configurable: true,
  151. writable: true,
  152. enumerable: true,
  153. value: dataDom[i].dataInfomation
  154. });
  155. }
  156. };
  157. //获取textarea里面的数据
  158. dataDom = obj.find('.form-group.form-inline textarea:not([readonly])')
  159. for (var i = 0; i < dataDom.length; i++) {
  160. Object.defineProperty(data, dataDom[i].name, {
  161. configurable: true,
  162. writable: true,
  163. enumerable: true,
  164. value: dataDom[i].value
  165. })
  166. };
  167. dataDom = obj.find('.form-group.form-inline select')
  168. for (var i = 0; i < dataDom.length; i++) {
  169. let optionDom = $(dataDom[i]).find("option:selected");
  170. let value = [];
  171. for (var i2 = 0; i2 < optionDom.length; i2++) {
  172. value.push(optionDom[i2]['value'])
  173. };
  174. Object.defineProperty(data, dataDom[i].name, {
  175. configurable: true,
  176. writable: true,
  177. enumerable: true,
  178. value: value.join(',')
  179. })
  180. };
  181. return data;
  182. }
  183. /**
  184. * 获取所有信息
  185. * */
  186. getAllInfo() {
  187. let data = {
  188. current: 1,
  189. size: 10000,
  190. //1派工审核,2现场处理,3协调处理,4完成处理
  191. processId: '2',
  192. }
  193. this.ajaxSend.sendAjax(this, data, this.config.troubleInfo, this.ajaxSend.type.get, function (results) {
  194. if (this.ajaxSend.checkResults(this, results)) {
  195. this.allList = results.result.records;
  196. this.renderPoint(this.allList);
  197. }
  198. }.bind(this));
  199. }
  200. /**
  201. *根据数据渲染站点
  202. *@param results 查询数据
  203. * **/
  204. renderPoint(data) {
  205. this.AppX.runtimeConfig.hiddenPageInfo.addClusters(data, this.clusters, this.popClass, '审核');
  206. $('.body').off('click', '.' + this.popClass + " .hiddenPageInfoPopInfoLook").on('click', '.' + this.popClass + " .hiddenPageInfoPopInfoLook", function (e) {
  207. let index = parseInt($(e.currentTarget).attr('index'));
  208. this.AppX.runtimeConfig.hiddenPageInfo.getInfoByid(data[index].id, this.initPage.bind(this))
  209. }.bind(this));
  210. }
  211. /**
  212. * 获取查询条件
  213. */
  214. getSearchInfo() {
  215. this.searchInfo = {
  216. //1派工审核,2现场处理,3协调处理,4完成处理
  217. processId: '2',
  218. troubleName: this.domObj.find(".troubleTypeName").val(),
  219. address: this.domObj.find(".address").val(),
  220. userId: this.domObj.find(".users").val(),
  221. findUserDeptId: this.domObj.find(".department").val(),
  222. "orders[0].asc":false,
  223. "orders[0].column":"report_time"
  224. }
  225. }
  226. /**
  227. * 渲染出隐患列表点选的点和线
  228. * */
  229. showTrouble() {
  230. this.initSelectTableGraphic(operation.clear);
  231. let data = this.dataTable.aExtentData.currentTableData;
  232. if (data) {
  233. if (data.pipeInfos) {
  234. for (var item of data.pipeInfos) {
  235. let graphic = new Graphic(new Polyline(JSON.parse(item.geometry)), this.selectTableLine);
  236. this.selectTableGraphic.add(graphic);
  237. }
  238. }
  239. if (data.deviceInfos) {
  240. for (var item of data.deviceInfos) {
  241. let graphic = new Graphic(new Point(JSON.parse(item.geometry)), this.selectTablePoint);
  242. this.selectTableGraphic.add(graphic);
  243. }
  244. }
  245. }
  246. }
  247. /**
  248. * 渲染出列表点选的点和线
  249. * */
  250. getInfoList() {
  251. this.loadWait.show("正在查询数据,请耐心等待...", this.domObj);
  252. let that = this;
  253. this.getSearchInfo();
  254. this.initSelectTableGraphic(operation.clear);
  255. if (that.dataTable) {
  256. that.dataTable.ajax.reload();
  257. return;
  258. };
  259. let option = {
  260. that: this,
  261. dataTable: that.dataTable,
  262. elementId: "HiddenTroubleTransAuditinfodata",
  263. url: that.config.troubleInfo,
  264. isCheck: false,
  265. searchInfo: that.searchInfo,//条件在不断变化,故需要有全局的条件监听
  266. //displayTitle: ["隐患名称", "隐患地址", "派工人", "处理人员", "派工时间","转派人","转派后处理人员","转派原因","转派时间",],
  267. displayTitle: ["隐患名称", "所属单位", "隐患地址", "上报人", "详情"],
  268. displayField: ["troubleName", "unitName", "address", "findUserName", "troubleInfo"],
  269. extentDisplayTitle: ['转派'],
  270. // testData:this.config.dataInfo,
  271. extentDisplayContent: [{
  272. field: "infoWrite",
  273. fieldContent: "<a class='infoWrite opreationName'>转派</a>"
  274. }],
  275. beforeTrClickEvent: undefined,
  276. afterTrClickEvent: function () {
  277. this.domObj.off('click', '#HiddenTroubleTransAuditinfodata tr').on('click', "#HiddenTroubleTransAuditinfodata tr", e => {
  278. this.showTrouble();
  279. this.AppX.runtimeConfig.hiddenPageInfo.goPoint(this.dataTable.aExtentData.currentTableData);
  280. })
  281. }.bind(this),
  282. drawEvent: function () {
  283. this.domObj.off('click', '.infoWrite').on('click', ".infoWrite", e => {
  284. this.AppX.runtimeConfig.hiddenPageInfo.getInfoByid(this.dataTable.aExtentData.currentTableData.id, this.initPage.bind(this))
  285. });
  286. this.loadWait.hide();
  287. }.bind(this),
  288. serachCallBack: function (results) {
  289. if (this.fristSearch) {
  290. this.fristSearch = false
  291. } else {
  292. if (results.result.records) {
  293. this.renderPoint(results.result.records);
  294. }
  295. }
  296. }.bind(this),
  297. errmassage: "隐患信息查询失败",
  298. nullmessage: undefined,
  299. exportTitle: "隐患信息"
  300. }
  301. that.dataTable = this.ajaxSend.DataTables_check(option);
  302. }
  303. /**
  304. * @function 获取部门列表
  305. */
  306. getGroup() {
  307. let data = {
  308. // id: this.AppX.appConfig.deptId
  309. current: 1,
  310. size: 10000
  311. }
  312. this.ajaxSend.sendAjax(this, data, this.config.getGroupList, this.ajaxSend.type.get, this.getGroupListCallback.bind(this,));
  313. }
  314. getGroupListCallback(results) {
  315. if (results.code != 1) {
  316. this.toast.Show(results.message);
  317. return;
  318. }
  319. let strdepartment = ("<option selected='selected' value=''>全部</option>");
  320. $.each(results.result.records, function (index, item) {
  321. strdepartment += "<option value='" + item.id + "'>" + item.name + "</option>";
  322. }.bind(this));
  323. this.domObj.find(".department").empty().append(strdepartment);
  324. // this.getUser(optionType, this.domObj.find(".department").val());
  325. }
  326. /**
  327. * @function 根据部门id获取用户列表,空代表查询全部
  328. * @param isall 是否全部
  329. */
  330. getUser(companyid) {
  331. if(!companyid){
  332. this.domObj.find(".users").empty();
  333. return
  334. }
  335. let data = {
  336. "current": 1,
  337. "size": 1000,
  338. "departmentId": companyid
  339. }
  340. this.ajaxSend.sendAjax(this, data, this.config.getUserList, this.ajaxSend.type.get, function (results) {
  341. var that = this;
  342. if (results.code != 1) {
  343. that.toast.Show(results.message);
  344. return;
  345. }
  346. let strusers = "<option selected value=''>全部</option>";
  347. if (results.result.records.length == 0) {
  348. strusers = "<option selected value=''>暂无巡检人员</option>"
  349. } else {
  350. $.each(results.result.records, function (index, item) {
  351. strusers += "<option value='" + item.id + "'>" + item.realName + "</option>";
  352. }.bind(this));
  353. }
  354. this.domObj.find(".users").empty().append(strusers);
  355. }.bind(this));
  356. }
  357. /**
  358. * 销毁对象
  359. */
  360. destroy() {
  361. this.AppX.runtimeConfig.hiddenPageInfo.clearClusters(this.clusters);
  362. this.initSelectTableGraphic(operation.destroy);
  363. this.domObj.remove();
  364. this.afterDestroy();
  365. }
  366. }