chartCtrl.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841
  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).endOf("day").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.incidentDetail', {
  357. id: data.incident.id,
  358. });
  359. }
  360. //点击查看报修图片
  361. $scope.clickImgs = function (item) {
  362. console.log(item)
  363. $modal.open({
  364. templateUrl: 'assets/views/showPictrueList.html',
  365. controller: function ($rootScope, $scope, scope, $modalInstance, api_user_data, SweetAlert) {
  366. $scope.title = '提示';
  367. $scope.content = '您申请的报修图片如下,请查看。';
  368. $scope.repairImgs = [];
  369. // 获取报修图片
  370. $scope.getRepairImgs = function() {
  371. $rootScope.isMask =true;
  372. api_wechatfile.listAttachment("wechatRequesterIncident", item.id).then(function (res) {
  373. $rootScope.isMask = false;
  374. res.data = res.data || [];
  375. res.data.forEach(v => {
  376. v.previewUrl = location.origin + "/file" + v.relativeFilePath;
  377. })
  378. $scope.repairImgs = res.data;
  379. });
  380. }
  381. //展示图片
  382. $scope.preview = function (url, idx) {
  383. var title = $scope.repairImgs[idx].title;
  384. $modal.open({
  385. backdrop: false,
  386. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  387. controller: function ($scope, $rootScope, scope, $modalInstance) {
  388. $scope.title = title;
  389. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  390. $scope.cancel = function () {
  391. $modalInstance.dismiss("cancel");
  392. };
  393. },
  394. resolve: {
  395. scope: function () {
  396. return $scope;
  397. },
  398. },
  399. });
  400. };
  401. $scope.getRepairImgs();
  402. //选择“取消”或“确定”
  403. $scope.cancel = function () {
  404. $modalInstance.dismiss('cancel');
  405. };
  406. },
  407. size: 'sm',
  408. resolve: {
  409. scope: function () {
  410. return $scope;
  411. }
  412. }
  413. });
  414. }
  415. //不受理
  416. $scope.rejectFn = function (model) {
  417. console.log(model)
  418. var modalInstance = $modal.open({
  419. backdrop: false,
  420. templateUrl: 'assets/views/incident/tpl/reject.tpl.html',
  421. controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
  422. console.log(model,loginUser);
  423. $scope.model = model;
  424. $scope.postData = {
  425. rejectRemark: '',
  426. }
  427. // 初始化
  428. $scope.ok = function () {
  429. if (!$scope.postData.rejectRemark){
  430. Alert.swal({
  431. title: "操作失败",
  432. text: "请填写不受理原因!",
  433. type: "error"
  434. });
  435. return;
  436. }
  437. let postData = {incident: {...model, ...{
  438. rejectRemark: $scope.postData.rejectRemark,
  439. }}};
  440. $rootScope.isMask = true;
  441. api_flow.accept("reject", postData).then(function (response) {
  442. console.log(response)
  443. $rootScope.isMask = false;
  444. if (response.state == 200) {
  445. Alert.swal({
  446. title: "操作成功!",
  447. confirmButtonColor: "#007AFF",
  448. type: "success"
  449. });
  450. $modalInstance.close('success');
  451. } else {
  452. Alert.swal({
  453. title: "操作失败",
  454. text: "操作失败, 请稍后再试!",
  455. type: "error"
  456. });
  457. }
  458. });
  459. }
  460. $scope.cancel = function () {
  461. $modalInstance.dismiss('cancel');
  462. }
  463. },
  464. size: 'sm',
  465. resolve: {
  466. modelData: function () {
  467. return model;
  468. },
  469. currentUserId: function () {
  470. return loginUser.id;
  471. },
  472. Alert: function () {
  473. return SweetAlert;
  474. },
  475. api_user_data: function () {
  476. return api_user_data;
  477. }
  478. }
  479. });
  480. modalInstance.result.then(function (selectedItem) {
  481. if (selectedItem == 'success') {
  482. $scope.refreshData('expand-right', defaultFilterData);
  483. }
  484. });
  485. };
  486. // 生成工单
  487. $scope.buildFn = function(model){
  488. $rootScope.newOrder({incident: model}, 'wx');
  489. }
  490. //重置
  491. $scope.cleanItem = function () {
  492. delete $scope.fileData.incident.contacts;
  493. delete $scope.fileData.incident.contactsInformation;
  494. delete $scope.fileData.incident.startDate_start;
  495. delete $scope.fileData.incident.startDate_end;
  496. delete $scope.fileData.incident.department;
  497. $scope.seiminObj = null;
  498. $scope.ksModel = '';
  499. $scope.refreshData('expand-right', $scope.fileData);
  500. }
  501. var defaultFilterData = {
  502. "idx": 0,
  503. "incident": {
  504. "serviceState": { "id": 1650 }
  505. },
  506. "sum": mun
  507. };
  508. $scope.ldloading = {};
  509. $scope.refreshData = function (style, filterData) {
  510. $scope.ldloading[style.replace('-', '_')] = true;
  511. if (angular.isUndefined(filterData)) {
  512. filterData = defaultFilterData;
  513. }
  514. $scope.myData = [];
  515. $scope.gridOptions['sum'] = filterData.sum;
  516. if ($scope.searchstate === 'all') {
  517. delete filterData.incident.notStatus;
  518. delete filterData.incident.state;
  519. } else if ($scope.searchstate === 'accept' || $scope.searchstate === 'reject') {
  520. delete filterData.incident.notStatus;
  521. filterData.incident.state = $scope.state.find(v => v.value == $scope.searchstate);
  522. } else if ($scope.searchstate === 'accepted') {
  523. delete filterData.incident.state;
  524. filterData.incident.notStatus = 'accept,reject,cancel';
  525. }
  526. //科室列表选中数据,请求参数判断
  527. if ($scope.repairMain.valueconfig == 2 && $scope.ksModel != '') {//报修科室且不是空字符
  528. $scope.fileData.incident.department = {
  529. dept: $scope.ksModel
  530. }
  531. }
  532. //搜索接口
  533. api_bpm_data.fetchDataList("incident", filterData).then(function (data) {
  534. var myData = Restangular.stripRestangular(data);
  535. $scope.gridOptions['totalItems'] = myData.totalNum;
  536. $scope.myData = myData.list;
  537. for (var i = 0; i < $scope.myData.length; i++) {
  538. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  539. }
  540. $scope.ldloading[style.replace('-', '_')] = false;
  541. }, function () {
  542. $scope.ldloading[style.replace('-', '_')] = false;
  543. });
  544. };
  545. $scope.timer = $interval(function () {
  546. $scope.refreshData('expand-right', $scope.fileData);
  547. }, $rootScope.refreshTime);
  548. console.log($state.params);
  549. if ($state.params.tab) {
  550. if ($state.params.tab == '-1') {
  551. $scope.searchstate = 'all';
  552. $scope.fileData.incident = {};
  553. } else {
  554. // $scope.searchstate = $state.params.tab;
  555. // $scope.fileData.incident.serviceState.id = $scope.searchstate;
  556. $scope.searchstate = 'accept';
  557. }
  558. } else {
  559. //默认未受理
  560. $scope.searchstate = 'accept';
  561. }
  562. $scope.$on('$destroy', function () {
  563. $interval.cancel($scope.timer)
  564. });
  565. //状态
  566. $scope.state = [];
  567. $scope.getIncidentStatus = function(){
  568. api_wechatfile.getDictionary({
  569. "type": "list",
  570. "key": "incident_status"
  571. }).then(function (response) {
  572. $scope.state = response || [];
  573. $scope.refreshData('expand-right', $scope.fileData);
  574. })
  575. }
  576. // 进入页面时
  577. $scope.getIncidentStatus();
  578. }]);
  579. app.controller('Wechatoperator', ['$rootScope', '$http', '$scope', '$modal', 'api_user_data', function ($rootScope, $http, $scope, $modal, api_user_data) {
  580. var loginUser = $rootScope.user;
  581. console.log($scope.item)
  582. $scope.weixinbaozhang_bushouli = false;
  583. $scope.weixinbaozhang_build = false;
  584. for (var i = 0; i < loginUser.menu.length; i++) {
  585. if (loginUser.menu[i].link == "weixinbaozhang_bushouli") {
  586. $scope.weixinbaozhang_bushouli = true
  587. }
  588. if (loginUser.menu[i].link == "weixinbaozhang_build") {
  589. $scope.weixinbaozhang_build = true
  590. }
  591. }
  592. $scope.edit = function () {
  593. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  594. }
  595. //查看,查看详情
  596. $scope.look = function () {
  597. $scope.colobject.grid.appScope.lookFunction($scope.item);
  598. }
  599. //处理
  600. $scope.handleFn = function () {
  601. console.log($scope.item)
  602. // $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  603. //是否包含服务台经理角色
  604. var isFuwutaijingli = loginUser.role.filter(v => v.rolecode == 'call center admin').length > 0;
  605. if (!isFuwutaijingli) {
  606. if ($scope.item.operationLog) {
  607. //有锁定操作记录的
  608. var p1 = {
  609. idx: 0,
  610. sum: 1000,
  611. operationLog: {
  612. id: $scope.item.operationLog.id,
  613. extra1: $scope.item.id,
  614. opType: 'wxincidentLock'
  615. }
  616. };
  617. api_user_data.fetchDataList('operationLog', p1).then(function (result) {
  618. if (result.status == 200) {
  619. var opValue = result.list[0].opValue;//查询锁定状态
  620. var userName = result.list[0].userName;//查询锁定人
  621. var userId = result.list[0].userId;//查询锁定人ID
  622. if (opValue == 1&&userId!=loginUser.id) {
  623. //如果锁定了,并不是锁定人操作
  624. $modal.open({
  625. templateUrl: 'assets/views/delete.html',
  626. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  627. $scope.title = '提示';
  628. $scope.connect = '该报修已被【' + userName + '】锁定!';
  629. $scope.yesFlag = true;
  630. //选择“取消”或“确定”
  631. $scope.cancel = function () {
  632. $modalInstance.dismiss('cancel');
  633. scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData);
  634. };
  635. },
  636. size: 'sm',
  637. resolve: {
  638. scope: function () {
  639. return $scope;
  640. }
  641. }
  642. });
  643. } else if(opValue == 1&&userId==loginUser.id){
  644. //如果锁定了,并是锁定人操作
  645. $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  646. }else{
  647. //如果没有锁定
  648. $scope.operateUnLock($scope.item.operationLog.id)
  649. }
  650. }
  651. })
  652. } else {
  653. //没有锁定记录的
  654. $scope.operateUnLock();
  655. }
  656. } else {
  657. $scope.colobject.grid.appScope.toHandleFunction($scope.item);
  658. }
  659. // $scope.doEdit($scope.item.id);
  660. }
  661. // 不受理
  662. $scope.rejectFn = function () {
  663. $scope.colobject.grid.appScope.rejectFn($scope.item);
  664. }
  665. // 生成工单
  666. $scope.buildFn = function () {
  667. $scope.colobject.grid.appScope.buildFn($scope.item);
  668. }
  669. //是否锁定,id是日志ID,有是修改,没有是新增
  670. $scope.operateUnLock = function (id) {
  671. $modal.open({
  672. templateUrl: 'assets/views/delete.html',
  673. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  674. $scope.title = '提示';
  675. $scope.connect = '是否锁定?锁定后其他人(服务台经理除外)无法操作此报修!';
  676. $scope.noFlag = true;
  677. //选择“是”
  678. $scope.yes = function () {
  679. if (scope.item) {
  680. var postData = {
  681. operationLog: {
  682. extra1: scope.item.id,
  683. userId: loginUser.id,
  684. userName: loginUser.name,
  685. opType: 'wxincidentLock',
  686. opValue: '1'
  687. }
  688. };
  689. if(id){
  690. postData.operationLog.id = id;
  691. }
  692. api_user_data.addData('operationLog', postData).then(function (response) {
  693. if (response.data) {
  694. $modalInstance.dismiss('cancel');
  695. SweetAlert.swal({
  696. title: "锁定成功!",
  697. type: "success",
  698. confirmButtonColor: "#007AFF"
  699. }, function () {
  700. scope.colobject.grid.appScope.toHandleFunction(scope.item);
  701. });
  702. } else {
  703. SweetAlert.swal({
  704. title: "操作异常!",
  705. text: "系统异常,请稍后重试,或者联系管理员!",
  706. type: "error"
  707. });
  708. }
  709. })
  710. }
  711. };
  712. //选择“取消”
  713. $scope.cancel = function () {
  714. $modalInstance.dismiss('cancel');
  715. };
  716. //选择“否”
  717. $scope.no = function () {
  718. $modalInstance.dismiss('cancel');
  719. scope.colobject.grid.appScope.toHandleFunction(scope.item);
  720. };
  721. },
  722. size: 'sm',
  723. resolve: {
  724. scope: function () {
  725. return $scope;
  726. }
  727. }
  728. });
  729. }
  730. //解锁
  731. $scope.unLock = function(){
  732. $modal.open({
  733. templateUrl: 'assets/views/delete.html',
  734. controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) {
  735. $scope.title = '提示';
  736. $scope.connect = '是否解锁?';
  737. $scope.noFlag = true;
  738. //选择“是”
  739. $scope.yes = function () {
  740. if (scope.item) {
  741. var postData = {
  742. operationLog: {
  743. id:scope.item.operationLog.id,
  744. extra1: scope.item.id,
  745. userId: loginUser.id,
  746. userName: loginUser.name,
  747. opType: 'wxincidentLock',
  748. opValue: '0'
  749. }
  750. };
  751. api_user_data.addData('operationLog', postData).then(function (response) {
  752. if (response.data) {
  753. $modalInstance.dismiss('cancel');
  754. SweetAlert.swal({
  755. title: "解锁成功!",
  756. type: "success",
  757. confirmButtonColor: "#007AFF"
  758. }, function () {
  759. scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData);
  760. });
  761. } else {
  762. SweetAlert.swal({
  763. title: "操作异常!",
  764. text: "系统异常,请稍后重试,或者联系管理员!",
  765. type: "error"
  766. });
  767. }
  768. })
  769. }
  770. };
  771. //选择“取消”
  772. $scope.cancel = function () {
  773. $modalInstance.dismiss('cancel');
  774. };
  775. //选择“否”
  776. $scope.no = function () {
  777. $modalInstance.dismiss('cancel');
  778. };
  779. },
  780. size: 'sm',
  781. resolve: {
  782. scope: function () {
  783. return $scope;
  784. }
  785. }
  786. });
  787. }
  788. //查看事件
  789. $scope.seeIncident = function () {
  790. $scope.colobject.grid.appScope.seeIncidentFunction($scope.item);
  791. // $scope.doEdit($scope.item.id);
  792. }
  793. }]);
  794. app.directive('wechatoperator', function () {
  795. return {
  796. restrict: 'E',
  797. scope: {
  798. item: '=',
  799. colobject: '='
  800. },
  801. controller: 'Wechatoperator',
  802. template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  803. '<a ng-click="rejectFn()" ng-show="{{item.state.value == \'accept\' && weixinbaozhang_bushouli}}" class="bianjifont">不受理</a>' +
  804. '<a ng-click="buildFn()" ng-show="{{item.state.value == \'accept\' && weixinbaozhang_build}}" class="bianjifont">生成工单</a>' +
  805. // '<a ng-click="handleFn()" ng-show="{{(handle&&chuli)&&isChuli}}" class="bianjifont">处理</a>' +
  806. // '<a ng-click="unLock()" ng-show="{{isUnLock}}" class="bianjifont">解除锁定</a>' +
  807. // '<a ng-click="look()" ng-show="{{see}}" class="bianjifont">查看</a>' +
  808. // '<a ng-click="seeIncident()" ng-show="{{toHandle}}" class="bianjifont">查看事件</a>' +
  809. '</div>'
  810. };
  811. });
  812. // app.factory('myFactory', function() {
  813. // //定义factory返回对象
  814. // var myServices = {};
  815. // //定义参数对象
  816. // var myObject = {};
  817. // var _set = function(data) {
  818. // myObject = data;
  819. // };
  820. // })