chartCtrl.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. 'use strict';
  2. app.controller('chartCtrl', ["$scope", "i18nService", "$rootScope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_data", "api_text", "api_user_data", "api_wechatfile", "api_search_ks", "api_flow", function ($scope, i18nService, $rootScope, $state, $timeout, $interval, $modal, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_data, api_text, api_user_data, api_wechatfile, api_search_ks, api_flow) {
  3. $scope.langs = i18nService.getAllLangs();
  4. $scope.lang = 'zh-cn';
  5. i18nService.setCurrentLang($scope.lang);
  6. var loginUser = $rootScope.user;
  7. $scope.tabs = [
  8. {key: 'all', value: '全部', num: ''},
  9. {key: 'accept', value: '待受理', num: ''},
  10. {key: 'accepted', value: '已受理', num: ''},
  11. {key: 'reject', value: '不受理', num: ''},
  12. ]
  13. //保存报修主体
  14. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  15. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  16. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  17. // ----------------分割线 start-----------------
  18. // 报修科室下拉
  19. $scope.ks_pageNum = 0; //科室下拉列表分页
  20. $scope.ks_len = 0; //科室所有数据列表数量
  21. $scope.ks_arr = [];//科室所有数据
  22. $scope.ksFlag = false;//默认下拉框列表隐藏
  23. $scope.ksModel = '';//科室输入内容
  24. //点击文本框
  25. $scope.ksClickHandle = function () {
  26. $scope.ks_arr = [];
  27. $scope.ks_pageNum = 0;
  28. $scope.getDepartmentList($scope.ks_pageNum);
  29. angular.element('#bx_ks_ul').scrollTop(0);
  30. }
  31. //修改文字,实时监听
  32. $scope.ksChangeHandle = _.debounce(function () {
  33. $scope.ks_arr = [];
  34. $scope.ks_pageNum = 0;
  35. $scope.getDepartmentList($scope.ks_pageNum);
  36. angular.element('#bx_ks_ul').scrollTop(0);
  37. }, 500)
  38. //滚动加载
  39. $scope.ksScrollHandle = function () {
  40. var itemLen = $scope.ks_arr.length;
  41. $scope.ks_pageNum++;
  42. if ($scope.ks_len != itemLen) {
  43. $scope.ks_len = itemLen;
  44. $scope.getDepartmentList($scope.ks_pageNum);
  45. }
  46. }
  47. //获取科室列表seimin
  48. $scope.getDepartmentList = function (idx) {
  49. api_search_ks.getKsList({ "idx": idx, "sum": 50, "department": { "dept": $scope.ksModel } })
  50. .then(res => {
  51. if (res.status == 200) {
  52. //添加分页数据,汇总
  53. $scope.ks_arr = $scope.ks_arr.concat(res.list);
  54. $scope.ksFlag = true;//显示
  55. }
  56. })
  57. .catch(err => {
  58. console.log(err);
  59. })
  60. }
  61. //下拉框列表选中
  62. $scope.ksItemClick = function (obj) {
  63. $scope.ksModel = obj.dept;//文本框赋值
  64. $scope.ksFlag = false;//隐藏
  65. }
  66. //点击空白处隐藏
  67. angular.element(document).on('click', function (e) {
  68. if (e.target !== angular.element('#bx_ks').get(0)) {
  69. $scope.ksFlag = false;//隐藏
  70. }
  71. })
  72. // -----------------分割线 end----------------
  73. var pdKey = $state.current.pdKey;
  74. $scope.gridOptions = {};
  75. $scope.gridOptions.data = 'myData';
  76. $scope.gridOptions.rowHeight = 54;
  77. $scope.gridOptions.enableColumnResizing = true;
  78. $scope.gridOptions.enableFiltering = false;
  79. $scope.gridOptions.enableGridMenu = true;
  80. $scope.gridOptions.enableRowSelection = true;
  81. $scope.gridOptions.showGridFooter = true;
  82. $scope.gridOptions.showColumnFooter = false;
  83. $scope.gridOptions.fastWatch = true;
  84. // $scope.gridOptions.useExternalFiltering=true;
  85. $scope.gridOptions.useExternalPagination = true;
  86. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  87. $scope.gridOptions.paginationPageSize = 10;
  88. $scope.gridOptions.multiSelect = true;
  89. var mun = $scope.gridOptions.paginationPageSize;
  90. $scope.gridOptions.rowTemplate = "<div ng-click=\"lookFunction(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  91. $scope.gridOptions.rowIdentity = function (row) {
  92. return row.id;
  93. };
  94. $scope.gridOptions.getRowIdentity = function (row) {
  95. return row.id;
  96. };
  97. //处理图标与文字
  98. $scope.transfertip = function (item) {
  99. var tip = "";
  100. if (item.operationLog) {
  101. tip = item.operationLog.userName;
  102. }
  103. return tip;
  104. }
  105. $scope.transferColor = function (item) {
  106. var color = "";
  107. if (item.operationLog) {
  108. if (item.operationLog.opValue == 1) {
  109. color = "dash dash-lock redfont";
  110. } else {
  111. color = "dash dash-unlock greenfont";
  112. }
  113. } else {
  114. color = "dash dash-unlock greenfont";
  115. }
  116. return color;
  117. }
  118. //表格列表显示
  119. $scope.gridOptions.columnDefs = [{
  120. name: 'item',
  121. displayName: '序号',
  122. width: 50,
  123. cellTemplate: '<div>' +
  124. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  125. '</div>'
  126. }, {
  127. name: 'startDate',
  128. displayName: '申请时间',
  129. width: 150,
  130. cellTemplate: '<div>' +
  131. '<div class="ui-grid-cell-contents">{{row.entity.startDate | date:"yyyy-MM-dd HH:mm" }}</div>' +
  132. '</div>'
  133. }, {
  134. name: 'description',
  135. displayName: '故障描述',
  136. width: '20%',
  137. cellTemplate: '<div style="width: 100%;">' +
  138. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.description}}</div>' +
  139. '</div>'
  140. },
  141. {
  142. name: 'row4',
  143. displayName: '科室/地址',
  144. width: '20%',
  145. cellTemplate: '<div style="width: 100%;">' +
  146. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.department ? row.entity.department.dept : "无"}}<br><span ng-bind-html="grid.appScope.areaplace(row.entity)"></span></div>' +
  147. '</div>'
  148. }, {
  149. name: 'row5',
  150. displayName: '联系人/联系电话',
  151. width: 150,
  152. cellTemplate: '<div>' +
  153. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.contacts}}<br>{{row.entity.contactsInformation}}</div>' +
  154. '</div>'
  155. },
  156. {
  157. name: 'state.name',
  158. displayName: '状态',
  159. width: 150,
  160. cellTemplate: '<div>' +
  161. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{row.entity.state.name}}</div>' +
  162. '</div>'
  163. },
  164. {
  165. name: 'reqAttachment',
  166. displayName: '图片',
  167. width: 150,
  168. cellTemplate: '<div>' +
  169. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" ng-if="row.entity.reqAttachment" ng-click="grid.appScope.clickImgs(row.entity)"><span class="newicon newicon-a-11111"></span></div>' +
  170. '</div>'
  171. },
  172. {
  173. name: '操作',
  174. width: 300,
  175. cellTemplate: '<wechatoperator item="row.entity" colobject="col">',
  176. enableFiltering: false
  177. }
  178. ];
  179. $scope.value = 10;
  180. $scope.decrement = function () {
  181. $scope.value = $scope.value - 1;
  182. };
  183. $scope.searchkeys = {};
  184. //点击切换
  185. $scope.searchstate = 'accept';
  186. $scope.onChange = function (searchstate) {
  187. $scope.searchstate = searchstate;
  188. $scope.refreshData('expand-right', $scope.fileData);
  189. }
  190. $scope.record = function () {
  191. api_text.record($rootScope.takes).then(function (data) {
  192. if (data.errno == 0) {
  193. $scope.busy = false;
  194. }
  195. })
  196. };
  197. $scope.areaplace = function (data) {
  198. var str = '';
  199. str += '<strong>' + data.branchName + '</strong>';
  200. str += (data.place ? (data.place.area ? data.place.area.area : '') : '');
  201. str += (data.place ? (data.place.place ? data.place.place : '') : '');
  202. str += (data.houseNumber ? data.houseNumber : '');
  203. return str || '无';
  204. }
  205. $scope.transferTime = function (time) {
  206. return moment(time).format('YYYY-MM-DD HH:mm');
  207. }
  208. $scope.parameters = null;
  209. $scope.open = function ($event) {
  210. $event.preventDefault();
  211. $event.stopPropagation();
  212. $scope.opened = !$scope.opened;
  213. };
  214. $scope.endOpen = function ($event) {
  215. $event.preventDefault();
  216. $event.stopPropagation();
  217. $scope.startOpened = false;
  218. $scope.endOpened = !$scope.endOpened;
  219. };
  220. $scope.startOpen = function ($event) {
  221. $event.preventDefault();
  222. $event.stopPropagation();
  223. $scope.endOpened = false;
  224. $scope.startOpened = !$scope.startOpened;
  225. };
  226. var getUser = function (fieldatas) {
  227. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  228. $scope.requester = data.list;
  229. });
  230. }
  231. $scope.onChangehandling = function (key) {
  232. var filuser = {
  233. "idx": 0,
  234. "sum": 10,
  235. "user": {
  236. "name": key,
  237. selectType: "pinyin_all",
  238. engineer: undefined,
  239. }
  240. }
  241. getUser(filuser);
  242. }
  243. getUser({
  244. "idx": 0,
  245. "sum": 10,
  246. user: {engineer: undefined,}
  247. });
  248. //搜索
  249. $scope.chiceIncident = function (item) {
  250. if ($scope.fileData.incident.startDate_start) {
  251. $scope.fileData.incident.startDate_start = moment($scope.fileData.incident.startDate_start).format('YYYY-MM-DD HH:mm:ss');
  252. }
  253. if ($scope.fileData.incident.startDate_end) {
  254. $scope.fileData.incident.startDate_end = moment($scope.fileData.incident.startDate_end).format('YYYY-MM-DD HH:mm:ss');
  255. }
  256. $scope.refreshData('expand-right', $scope.fileData);
  257. }
  258. $scope.gridOptions.onRegisterApi = function (gridApi) {
  259. $scope.gridApi = gridApi;
  260. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  261. var filtersData = $scope.memoryfilterData;
  262. filtersData.idx = newPage - 1;
  263. filtersData.sum = pageSize;
  264. $scope.fileData.idx = newPage - 1;
  265. $scope.fileData.sum = pageSize;
  266. $scope.refreshData('expand-right', $scope.fileData);
  267. });
  268. $scope.selected = {
  269. items: []
  270. }
  271. };
  272. $scope.memoryfilterData = defaultFilterData = {
  273. "idx": 0,
  274. "incident": {
  275. source:{'value':'im'}
  276. },
  277. "sum": mun
  278. };
  279. //收集搜索数据
  280. $scope.fileData = {
  281. "idx": 0,
  282. "incident": {
  283. source:{'value':'im'}
  284. },
  285. "sum": 10
  286. }
  287. $scope.selectRowFunction = function (data) {
  288. var formdata = {
  289. 'model': {
  290. 'incident': {
  291. 'requester': data.requester,
  292. 'area': data.place.area,
  293. 'place': data.place,
  294. 'houseNumber': data.address,
  295. 'contacts': data.contacts,
  296. 'contactsInformation': data.contactsInformation,
  297. 'description': data.incidentDescription,
  298. 'source': {
  299. 'id': 1549
  300. },
  301. 'fileUrl': data.fileUrl
  302. },
  303. 'requestershow': data.requester,
  304. 'flow': data.id
  305. }
  306. }
  307. $state.go('app.incident.chart', {
  308. 'model': JSON.stringify(formdata)
  309. });
  310. };
  311. $scope.lookFunction = function (data) {
  312. $state.go('app.desk.detail', {
  313. model: JSON.stringify(data)
  314. });
  315. };
  316. $scope.toHandleFunction = function (data) {
  317. console.log(data)
  318. var formdata = {
  319. 'model': {
  320. 'incident': {
  321. 'requester': data.requester,
  322. 'houseNumber': data.address,
  323. 'contacts': data.contacts,
  324. 'contactsInformation': data.contactsInformation,
  325. 'incidentState': data.incidentState,
  326. 'description': data.incidentDescription,
  327. 'source': {
  328. 'id': 1549
  329. },
  330. 'fileUrl': data.fileUrl
  331. },
  332. 'requestershow': data.requester,
  333. 'flow': data.id,
  334. 'retractReason': data.retractReason
  335. }
  336. }
  337. var modelfile = {
  338. model: {
  339. incident: data
  340. }
  341. };
  342. angular.extend(modelfile.model, {
  343. 'gourl': 'app.incident.chart',
  344. 'state_model': formdata
  345. })
  346. angular.extend(modelfile.model.incident, {
  347. status: 1
  348. })
  349. $state.go('app.desk.form_editor', {
  350. formKey: 'desk_detail',
  351. service: 'api_user_data',
  352. model: JSON.stringify(modelfile)
  353. });
  354. };
  355. $scope.seeIncidentFunction = function (data) {
  356. $state.go('app.incident.detail', {
  357. formKey: 'incident_back',
  358. pdKey: 'incident',
  359. dataId: data.incident.id,
  360. taskId: data.incident.taskId,
  361. processInstanceId: data.incident.processInstanceId,
  362. isChart: "ok"
  363. });
  364. }
  365. //点击查看报修图片
  366. $scope.clickImgs = function (item) {
  367. console.log(item)
  368. $modal.open({
  369. templateUrl: 'assets/views/showPictrueList.html',
  370. controller: function ($rootScope, $scope, scope, $modalInstance, api_user_data, SweetAlert) {
  371. $scope.title = '提示';
  372. $scope.content = '您申请的报修图片如下,请查看。';
  373. $scope.repairImgs = [];
  374. // 获取报修图片
  375. $scope.getRepairImgs = function() {
  376. $rootScope.isMask =true;
  377. api_wechatfile.listAttachment("wechatRequesterIncident", item.id).then(function (res) {
  378. $rootScope.isMask = false;
  379. res.data = res.data || [];
  380. res.data.forEach(v => {
  381. v.previewUrl = location.origin + "/file" + v.relativeFilePath;
  382. })
  383. $scope.repairImgs = res.data;
  384. });
  385. }
  386. //展示图片
  387. $scope.preview = function (url, idx) {
  388. var title = $scope.repairImgs[idx].title;
  389. $modal.open({
  390. backdrop: false,
  391. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  392. controller: function ($scope, $rootScope, scope, $modalInstance) {
  393. $scope.title = title;
  394. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  395. $scope.cancel = function () {
  396. $modalInstance.dismiss("cancel");
  397. };
  398. },
  399. resolve: {
  400. scope: function () {
  401. return $scope;
  402. },
  403. },
  404. });
  405. };
  406. $scope.getRepairImgs();
  407. //选择“取消”或“确定”
  408. $scope.cancel = function () {
  409. $modalInstance.dismiss('cancel');
  410. };
  411. },
  412. size: 'sm',
  413. resolve: {
  414. scope: function () {
  415. return $scope;
  416. }
  417. }
  418. });
  419. }
  420. //不受理
  421. $scope.rejectFn = function (model) {
  422. console.log(model)
  423. var modalInstance = $modal.open({
  424. backdrop: false,
  425. templateUrl: 'assets/views/incident/tpl/reject.tpl.html',
  426. controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
  427. console.log(model,loginUser);
  428. $scope.model = model;
  429. $scope.postData = {
  430. rejectRemark: '',
  431. }
  432. // 初始化
  433. $scope.ok = function () {
  434. if (!$scope.postData.rejectRemark){
  435. Alert.swal({
  436. title: "操作失败",
  437. text: "请填写不受理原因!",
  438. type: "error"
  439. });
  440. return;
  441. }
  442. let postData = {incident: {...model, ...{
  443. rejectRemark: $scope.postData.rejectRemark,
  444. }}};
  445. $rootScope.isMask = true;
  446. api_flow.accept("reject", postData).then(function (response) {
  447. console.log(response)
  448. $rootScope.isMask = false;
  449. if (response.state == 200) {
  450. Alert.swal({
  451. title: "操作成功!",
  452. confirmButtonColor: "#007AFF",
  453. type: "success"
  454. });
  455. $modalInstance.close('success');
  456. } else {
  457. Alert.swal({
  458. title: "操作失败",
  459. text: "操作失败, 请稍后再试!",
  460. type: "error"
  461. });
  462. }
  463. });
  464. }
  465. $scope.cancel = function () {
  466. $modalInstance.dismiss('cancel');
  467. }
  468. },
  469. size: 'sm',
  470. resolve: {
  471. modelData: function () {
  472. return model;
  473. },
  474. currentUserId: function () {
  475. return loginUser.id;
  476. },
  477. Alert: function () {
  478. return SweetAlert;
  479. },
  480. api_user_data: function () {
  481. return api_user_data;
  482. }
  483. }
  484. });
  485. modalInstance.result.then(function (selectedItem) {
  486. if (selectedItem == 'success') {
  487. $scope.refreshData('expand-right', defaultFilterData);
  488. }
  489. });
  490. };
  491. // 生成工单
  492. $scope.buildFn = function(model){
  493. $rootScope.newOrder({incident: model});
  494. }
  495. //重置
  496. $scope.cleanItem = function () {
  497. delete $scope.fileData.incident.contacts;
  498. delete $scope.fileData.incident.contactsInformation;
  499. delete $scope.fileData.incident.startDate_start;
  500. delete $scope.fileData.incident.startDate_end;
  501. delete $scope.fileData.incident.department;
  502. $scope.seiminObj = null;
  503. $scope.ksModel = '';
  504. $scope.refreshData('expand-right', $scope.fileData);
  505. }
  506. var defaultFilterData = {
  507. "idx": 0,
  508. "incident": {
  509. "serviceState": { "id": 1650 }
  510. },
  511. "sum": mun
  512. };
  513. $scope.ldloading = {};
  514. $scope.refreshData = function (style, filterData) {
  515. $scope.ldloading[style.replace('-', '_')] = true;
  516. if (angular.isUndefined(filterData)) {
  517. filterData = defaultFilterData;
  518. }
  519. $scope.myData = [];
  520. $scope.gridOptions['sum'] = filterData.sum;
  521. if ($scope.searchstate === 'all') {
  522. delete filterData.incident.notStatus;
  523. delete filterData.incident.state;
  524. } else if ($scope.searchstate === 'accept' || $scope.searchstate === 'reject') {
  525. delete filterData.incident.notStatus;
  526. filterData.incident.state = $scope.state.find(v => v.value == $scope.searchstate);
  527. } else if ($scope.searchstate === 'accepted') {
  528. delete filterData.incident.state;
  529. filterData.incident.notStatus = 'accept,reject,cancel';
  530. }
  531. //科室列表选中数据,请求参数判断
  532. if ($scope.repairMain.valueconfig == 2 && $scope.ksModel != '') {//报修科室且不是空字符
  533. $scope.fileData.incident.department = {
  534. dept: $scope.ksModel
  535. }
  536. }
  537. //搜索接口
  538. api_bpm_data.fetchDataList("incident", filterData).then(function (data) {
  539. var myData = Restangular.stripRestangular(data);
  540. $scope.gridOptions['totalItems'] = myData.totalNum;
  541. $scope.myData = myData.list;
  542. for (var i = 0; i < $scope.myData.length; i++) {
  543. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  544. }
  545. $scope.ldloading[style.replace('-', '_')] = false;
  546. }, function () {
  547. $scope.ldloading[style.replace('-', '_')] = false;
  548. });
  549. };
  550. $scope.timer = $interval(function () {
  551. $scope.refreshData('expand-right', $scope.fileData);
  552. }, $rootScope.refreshTime);
  553. console.log($state.params);
  554. if ($state.params.tab) {
  555. if ($state.params.tab == '-1') {
  556. $scope.searchstate = 'all';
  557. $scope.fileData.incident = {};
  558. } else {
  559. // $scope.searchstate = $state.params.tab;
  560. // $scope.fileData.incident.serviceState.id = $scope.searchstate;
  561. $scope.searchstate = 'accept';
  562. }
  563. } else {
  564. //默认未受理
  565. $scope.searchstate = 'accept';
  566. }
  567. $scope.$on('$destroy', function () {
  568. $interval.cancel($scope.timer)
  569. });
  570. //状态
  571. $scope.state = [];
  572. $scope.getIncidentStatus = function(){
  573. api_wechatfile.getDictionary({
  574. "type": "list",
  575. "key": "incident_status"
  576. }).then(function (response) {
  577. $scope.state = response || [];
  578. $scope.refreshData('expand-right', $scope.fileData);
  579. })
  580. }
  581. // 进入页面时
  582. $scope.getIncidentStatus();
  583. }]);
  584. app.controller('Wechatoperator', ['$rootScope', '$http', '$scope', '$modal', 'api_user_data', function ($rootScope, $http, $scope, $modal, api_user_data) {
  585. var loginUser = $rootScope.user;
  586. console.log($scope.item)
  587. $scope.weixinbaozhang_bushouli = false;
  588. $scope.weixinbaozhang_build = false;
  589. for (var i = 0; i < loginUser.menu.length; i++) {
  590. if (loginUser.menu[i].link == "weixinbaozhang_bushouli") {
  591. $scope.weixinbaozhang_bushouli = true
  592. }
  593. if (loginUser.menu[i].link == "weixinbaozhang_build") {
  594. $scope.weixinbaozhang_build = true
  595. }
  596. }
  597. $scope.edit = function () {
  598. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  599. }
  600. //查看,查看详情
  601. $scope.look = function () {
  602. $scope.colobject.grid.appScope.lookFunction($scope.item);
  603. }
  604. //处理
  605. $scope.handleFn = function () {
  606. console.log($scope.item)
  607. // $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  608. //是否包含服务台经理角色
  609. var isFuwutaijingli = loginUser.role.filter(v => v.rolecode == 'call center admin').length > 0;
  610. if (!isFuwutaijingli) {
  611. if ($scope.item.operationLog) {
  612. //有锁定操作记录的
  613. var p1 = {
  614. idx: 0,
  615. sum: 1000,
  616. operationLog: {
  617. id: $scope.item.operationLog.id,
  618. extra1: $scope.item.id,
  619. opType: 'wxincidentLock'
  620. }
  621. };
  622. api_user_data.fetchDataList('operationLog', p1).then(function (result) {
  623. if (result.status == 200) {
  624. var opValue = result.list[0].opValue;//查询锁定状态
  625. var userName = result.list[0].userName;//查询锁定人
  626. var userId = result.list[0].userId;//查询锁定人ID
  627. if (opValue == 1&&userId!=loginUser.id) {
  628. //如果锁定了,并不是锁定人操作
  629. $modal.open({
  630. templateUrl: 'assets/views/delete.html',
  631. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  632. $scope.title = '提示';
  633. $scope.connect = '该报修已被【' + userName + '】锁定!';
  634. $scope.yesFlag = true;
  635. //选择“取消”或“确定”
  636. $scope.cancel = function () {
  637. $modalInstance.dismiss('cancel');
  638. scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData);
  639. };
  640. },
  641. size: 'sm',
  642. resolve: {
  643. scope: function () {
  644. return $scope;
  645. }
  646. }
  647. });
  648. } else if(opValue == 1&&userId==loginUser.id){
  649. //如果锁定了,并是锁定人操作
  650. $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  651. }else{
  652. //如果没有锁定
  653. $scope.operateUnLock($scope.item.operationLog.id)
  654. }
  655. }
  656. })
  657. } else {
  658. //没有锁定记录的
  659. $scope.operateUnLock();
  660. }
  661. } else {
  662. $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  663. }
  664. // $scope.doEdit($scope.item.id);
  665. }
  666. // 不受理
  667. $scope.rejectFn = function () {
  668. $scope.colobject.grid.appScope.rejectFn($scope.item);
  669. }
  670. // 生成工单
  671. $scope.buildFn = function () {
  672. $scope.colobject.grid.appScope.buildFn($scope.item);
  673. }
  674. //是否锁定,id是日志ID,有是修改,没有是新增
  675. $scope.operateUnLock = function (id) {
  676. $modal.open({
  677. templateUrl: 'assets/views/delete.html',
  678. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  679. $scope.title = '提示';
  680. $scope.connect = '是否锁定?锁定后其他人(服务台经理除外)无法操作此报修!';
  681. $scope.noFlag = true;
  682. //选择“是”
  683. $scope.yes = function () {
  684. if (scope.item) {
  685. var postData = {
  686. operationLog: {
  687. extra1: scope.item.id,
  688. userId: loginUser.id,
  689. userName: loginUser.name,
  690. opType: 'wxincidentLock',
  691. opValue: '1'
  692. }
  693. };
  694. if(id){
  695. postData.operationLog.id = id;
  696. }
  697. api_user_data.addData('operationLog', postData).then(function (response) {
  698. if (response.data) {
  699. $modalInstance.dismiss('cancel');
  700. SweetAlert.swal({
  701. title: "锁定成功!",
  702. type: "success",
  703. confirmButtonColor: "#007AFF"
  704. }, function () {
  705. scope.colobject.grid.appScope.toHandleFunction(scope.item);
  706. });
  707. } else {
  708. SweetAlert.swal({
  709. title: "操作异常!",
  710. text: "系统异常,请稍后重试,或者联系管理员!",
  711. type: "error"
  712. });
  713. }
  714. })
  715. }
  716. };
  717. //选择“取消”
  718. $scope.cancel = function () {
  719. $modalInstance.dismiss('cancel');
  720. };
  721. //选择“否”
  722. $scope.no = function () {
  723. $modalInstance.dismiss('cancel');
  724. scope.colobject.grid.appScope.toHandleFunction(scope.item);
  725. };
  726. },
  727. size: 'sm',
  728. resolve: {
  729. scope: function () {
  730. return $scope;
  731. }
  732. }
  733. });
  734. }
  735. //解锁
  736. $scope.unLock = function(){
  737. $modal.open({
  738. templateUrl: 'assets/views/delete.html',
  739. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  740. $scope.title = '提示';
  741. $scope.connect = '是否解锁?';
  742. $scope.noFlag = true;
  743. //选择“是”
  744. $scope.yes = function () {
  745. if (scope.item) {
  746. var postData = {
  747. operationLog: {
  748. id:scope.item.operationLog.id,
  749. extra1: scope.item.id,
  750. userId: loginUser.id,
  751. userName: loginUser.name,
  752. opType: 'wxincidentLock',
  753. opValue: '0'
  754. }
  755. };
  756. api_user_data.addData('operationLog', postData).then(function (response) {
  757. if (response.data) {
  758. $modalInstance.dismiss('cancel');
  759. SweetAlert.swal({
  760. title: "解锁成功!",
  761. type: "success",
  762. confirmButtonColor: "#007AFF"
  763. }, function () {
  764. scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData);
  765. });
  766. } else {
  767. SweetAlert.swal({
  768. title: "操作异常!",
  769. text: "系统异常,请稍后重试,或者联系管理员!",
  770. type: "error"
  771. });
  772. }
  773. })
  774. }
  775. };
  776. //选择“取消”
  777. $scope.cancel = function () {
  778. $modalInstance.dismiss('cancel');
  779. };
  780. //选择“否”
  781. $scope.no = function () {
  782. $modalInstance.dismiss('cancel');
  783. };
  784. },
  785. size: 'sm',
  786. resolve: {
  787. scope: function () {
  788. return $scope;
  789. }
  790. }
  791. });
  792. }
  793. //查看事件
  794. $scope.seeIncident = function () {
  795. $scope.colobject.grid.appScope.seeIncidentFunction($scope.item);
  796. // $scope.doEdit($scope.item.id);
  797. }
  798. }]);
  799. app.directive('wechatoperator', function () {
  800. return {
  801. restrict: 'E',
  802. scope: {
  803. item: '=',
  804. colobject: '='
  805. },
  806. controller: 'Wechatoperator',
  807. template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  808. '<a ng-click="rejectFn()" ng-show="{{item.state.value == \'accept\' && weixinbaozhang_bushouli}}" class="bianjifont">不受理</a>' +
  809. '<a ng-click="buildFn()" ng-show="{{item.state.value == \'accept\' && weixinbaozhang_build}}" class="bianjifont">生成工单</a>' +
  810. // '<a ng-click="handleFn()" ng-show="{{(handle&&chuli)&&isChuli}}" class="bianjifont">处理</a>' +
  811. // '<a ng-click="unLock()" ng-show="{{isUnLock}}" class="bianjifont">解除锁定</a>' +
  812. // '<a ng-click="look()" ng-show="{{see}}" class="bianjifont">查看</a>' +
  813. // '<a ng-click="seeIncident()" ng-show="{{toHandle}}" class="bianjifont">查看事件</a>' +
  814. '</div>'
  815. };
  816. });
  817. // app.factory('myFactory', function() {
  818. // //定义factory返回对象
  819. // var myServices = {};
  820. // //定义参数对象
  821. // var myObject = {};
  822. // var _set = function(data) {
  823. // myObject = data;
  824. // };
  825. // })