'use strict'; 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", 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) { $scope.langs = i18nService.getAllLangs(); $scope.lang = 'zh-cn'; i18nService.setCurrentLang($scope.lang); // $(window).resize(function() { // // console.log("1111") // }); // 来源 $scope.sourceTypes = [ {name:'事件生成',value:'pcIncident'}, {name:'自主报修',value:'wechatRequesterIncident'} ] //修改来源 $scope.seiminObj = { sourceType: null }; $scope.changeSourceType = function(item){ console.log(item); $scope.fileData.wxincident.sourceType = item.value; } var loginUser = $rootScope.user; //保存报修主体 $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main")); $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产 $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材 // ----------------分割线 start----------------- // 报修科室下拉 $scope.ks_pageNum = 0; //科室下拉列表分页 $scope.ks_len = 0; //科室所有数据列表数量 $scope.ks_arr = [];//科室所有数据 $scope.ksFlag = false;//默认下拉框列表隐藏 $scope.ksModel = '';//科室输入内容 //点击文本框 $scope.ksClickHandle = function () { $scope.ks_arr = []; $scope.ks_pageNum = 0; $scope.getDepartmentList($scope.ks_pageNum); angular.element('#bx_ks_ul').scrollTop(0); } //修改文字,实时监听 $scope.ksChangeHandle = _.debounce(function () { $scope.ks_arr = []; $scope.ks_pageNum = 0; $scope.getDepartmentList($scope.ks_pageNum); angular.element('#bx_ks_ul').scrollTop(0); }, 500) //滚动加载 $scope.ksScrollHandle = function () { var itemLen = $scope.ks_arr.length; $scope.ks_pageNum++; if ($scope.ks_len != itemLen) { $scope.ks_len = itemLen; $scope.getDepartmentList($scope.ks_pageNum); } } //获取科室列表seimin $scope.getDepartmentList = function (idx) { api_search_ks.getKsList({ "idx": idx, "sum": 50, "department": { "dept": $scope.ksModel } }) .then(res => { if (res.status == 200) { //添加分页数据,汇总 $scope.ks_arr = $scope.ks_arr.concat(res.list); $scope.ksFlag = true;//显示 } }) .catch(err => { console.log(err); }) } //下拉框列表选中 $scope.ksItemClick = function (obj) { $scope.ksModel = obj.dept;//文本框赋值 $scope.ksFlag = false;//隐藏 } //点击空白处隐藏 angular.element(document).on('click', function (e) { if (e.target !== angular.element('#bx_ks').get(0)) { $scope.ksFlag = false;//隐藏 //模拟placeholder // if ($('#bx_ks').val() == '') { // $('#bx_ks').val('请选择报修科室'); // } } }) // -----------------分割线 end---------------- // var voiceurl=$rootScope.audioiIp; // delete $rootScope.user.authority; var pdKey = $state.current.pdKey; $scope.gridOptions = {}; $scope.gridOptions.data = 'myData'; $scope.gridOptions.enableColumnResizing = true; $scope.gridOptions.enableFiltering = false; $scope.gridOptions.enableGridMenu = true; $scope.gridOptions.enableRowSelection = true; $scope.gridOptions.showGridFooter = true; $scope.gridOptions.showColumnFooter = false; $scope.gridOptions.fastWatch = true; // $scope.gridOptions.useExternalFiltering=true; $scope.gridOptions.useExternalPagination = true; $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100]; $scope.gridOptions.paginationPageSize = 10; $scope.gridOptions.multiSelect = true; var mun = $scope.gridOptions.paginationPageSize; $scope.gridOptions.rowTemplate = "
"; $scope.gridOptions.rowIdentity = function (row) { return row.id; }; $scope.gridOptions.getRowIdentity = function (row) { return row.id; }; //处理图标与文字 $scope.transfertip = function (item) { var tip = ""; if (item.operationLog) { tip = item.operationLog.userName; } return tip; } $scope.transferColor = function (item) { var color = ""; if (item.operationLog) { if (item.operationLog.opValue == 1) { color = "dash dash-lock redfont"; } else { color = "dash dash-unlock greenfont"; } } else { color = "dash dash-unlock greenfont"; } return color; } //表格列表显示 if ($scope.repairMain.valueconfig == 1) {//报修主体为报修人 $scope.gridOptions.columnDefs = [ { name: 'id', displayName: '', width: 35, cellTemplate: '
' + '
' + '' }, { name: 'item', displayName: '序号', width: 50, cellTemplate: '
' + '
{{row.entity.item}}
' + '
' }, { name: 'bxcode', displayName: '报修单号', width: 150, cellTemplate: '
' + '
{{row.entity.bxcode}}
' + '
' }, { name: 'incidentDescription', displayName: '故障描述', width: 150, cellTemplate: '
' + '
{{row.entity.incidentDescription}}
' + '
' }, // { // name: 'incidentDescription1', // displayName: '报修科室', // width: '12%', // cellTemplate: '
' + // '
{{row.entity.incidentDescription1}}
' + // '
' // }, { name: 'address', displayName: '故障地点', width: 150, cellTemplate: '
' + '
{{row.entity.place.place||""}} {{row.entity.address}}
' + '
' }, { name: 'contacts', displayName: '联系人', width: 150, cellTemplate: '
' + '
{{row.entity.contacts}}
' + '
' }, { name: 'requester.account', displayName: '学工号', width: 150, cellTemplate: '
' + '
{{row.entity.requester.account}}
' + '
' }, { name: 'contactsInformation', displayName: '联系电话', width: 150, cellTemplate: '
' + '
{{row.entity.contactsInformation}}
' + '
' }, { name: 'incident.acceptUser.name', displayName: '受理人', width: 150, cellTemplate: '
' + '
{{row.entity.incident.acceptUser.name||""}}
' + '
{{row.entity.rejectUser.name||""}}
' + '
' }, // { // name: 'requester.name', // displayName: '报修人', // width: '10%', // cellTemplate: '
' + // '
{{row.entity.requester.name}}
' + // '
' // }, { name: 'serviceState.name', displayName: '状态', width: 150, cellTemplate: '
' + '
{{row.entity.serviceState.name}}
' + '
' }, { name: 'createTime', displayName: '报修时间', width: 150, cellTemplate: '
' + '
{{grid.appScope.transferTime(row.entity.createTime)}}
' + '
' // }, // { // name: '生成事件', // width: 80, // cellTemplate: '' }, { name: '操作', width: 300, cellTemplate: '', enableFiltering: false } ]; // 是否展示资产 if ($scope.wxIncidentWithCmdb == 1) { let index = $scope.gridOptions.columnDefs.findIndex(v => v.name == 'address'); $scope.gridOptions.columnDefs.splice(index, 0, { name: 'assetId', displayName: '资产', width: 150 }) } } else if ($scope.repairMain.valueconfig == 2) {//报修主体为科室 $scope.gridOptions.columnDefs = [{ name: 'item', displayName: '序号', width: 50, cellTemplate: '
' + '
{{row.entity.item}}
' + '
' }, { name: 'bxcode', displayName: '报修单号', width: 150, cellTemplate: '
' + '
{{row.entity.bxcode}}
' + '
' }, { name: 'incidentDescription', displayName: '故障描述', width: 150, cellTemplate: '
' + '
{{row.entity.incidentDescription}}
' + '
' }, // { // name: 'incidentDescription1', // displayName: '报修科室', // width: '12%', // cellTemplate: '
' + // '
{{row.entity.incidentDescription1}}
' + // '
' // }, { name: 'address', displayName: '故障地点', width: 150, cellTemplate: '
' + '
{{row.entity.place.place||""}} {{row.entity.address}}
' + '
' }, { name: 'departmentDTO.dept', displayName: '报修科室', width: 150, cellTemplate: '
' + '
{{row.entity.departmentDTO.dept}}
' + '
' }, { name: 'contacts', displayName: '联系人', width: 150, cellTemplate: '
' + '
{{row.entity.contacts}}
' + '
' }, { name: 'contactsInformation', displayName: '联系电话', width: 150, cellTemplate: '
' + '
{{row.entity.contactsInformation}}
' + '
' }, // { // name: 'requester.name', // displayName: '报修人', // width: '10%', // cellTemplate: '
' + // '
{{row.entity.requester.name}}
' + // '
' // }, { name: 'serviceState.name', displayName: '状态', width: 150, cellTemplate: '
' + '
{{row.entity.serviceState.name}}
' + '
' }, { name: 'createTime', displayName: '报修时间', width: 150, cellTemplate: '
' + '
{{grid.appScope.transferTime(row.entity.createTime)}}
' + '
' // }, // { // name: '生成事件', // width: 80, // cellTemplate: '' }, { name: '操作', width: 300, cellTemplate: '', enableFiltering: false } ]; } $scope.value = 10; $scope.decrement = function () { $scope.value = $scope.value - 1; }; $scope.searchkeys = {}; //点击切换 $scope.onChange = function (searchType) { $scope.searchstate = searchType; // defaultFilterData = $scope.memoryfilterData; if (searchType) { $scope.fileData.wxincident.serviceState = { "id": searchType }; } else { delete $scope.fileData.wxincident.serviceState } // sessionStorage.searchchart.state = searchType; $scope.refreshData('expand-right', $scope.fileData); } $scope.record = function () { api_text.record($rootScope.takes).then(function (data) { if (data.errno == 0) { $scope.busy = false; } }) }; $scope.transferTime = function (time) { return moment(time).format('YYYY-MM-DD HH:mm'); } $scope.parameters = null; $scope.open = function ($event) { $event.preventDefault(); $event.stopPropagation(); $scope.opened = !$scope.opened; }; $scope.endOpen = function ($event) { $event.preventDefault(); $event.stopPropagation(); $scope.startOpened = false; $scope.endOpened = !$scope.endOpened; }; $scope.startOpen = function ($event) { $event.preventDefault(); $event.stopPropagation(); $scope.endOpened = false; $scope.startOpened = !$scope.startOpened; }; var getUser = function (fieldatas) { api_user_data.fetchDataList('requester', fieldatas).then(function (data) { $scope.requester = data.list; }); } $scope.onChangehandling = function (key) { var filuser = { "idx": 0, "sum": 10, "requester": { "name": key } } getUser(filuser); } getUser({ "idx": 0, "sum": 10 }); //搜索 $scope.chiceIncident = function (item) { if ($scope.fileData.wxincident.createTime) { $scope.fileData.wxincident.createTime = moment($scope.fileData.wxincident.createTime).format('YYYY-MM-DD HH:mm:ss'); } if ($scope.fileData.wxincident.createTimeEnd) { $scope.fileData.wxincident.createTimeEnd = moment($scope.fileData.wxincident.createTimeEnd).format('YYYY-MM-DD HH:mm:ss'); } $scope.refreshData('expand-right', $scope.fileData); } $scope.gridOptions.onRegisterApi = function (gridApi) { $scope.gridApi = gridApi; gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { var filtersData = $scope.memoryfilterData; filtersData.idx = newPage - 1; filtersData.sum = pageSize; $scope.fileData.idx = newPage - 1; $scope.fileData.sum = pageSize; $scope.refreshData('expand-right', $scope.fileData); // if (JSON.parse(sessionStorage.getItem("searchchart")).idx != filtersData.idx) { // $scope.refreshData('expand-right', filtersData); // } // $scope.refreshData('expand-right', filtersData); }); $scope.selected = { items: [] } }; $scope.memoryfilterData = defaultFilterData = { // "assignee":$rootScope.user.id, // "candidateGroups":$rootScope.user.group[0].id, "idx": 0, "wxincident": { "serviceState": { "id": 1650 } }, "sum": mun }; //收集搜索数据 $scope.fileData = { "idx": 0, "wxincident": { "serviceState": { "id": 1650 } }, "sum": 10 } $scope.selectRowFunction = function (data) { var formdata = { 'model': { 'incident': { 'requester': data.requester, 'area': data.place.area, 'place': data.place, 'houseNumber': data.address, 'contacts': data.contacts, 'contactsInformation': data.contactsInformation, // 'category': data.wxIncidentClassifyDTO.category, 'description': data.incidentDescription, 'source': { 'id': 1549 }, 'sourceType': data.sourceType, 'fileUrl': data.fileUrl }, 'requestershow': data.requester, 'flow': data.id } } // if (data.requester.requesterTypeDTO && data.requester.requesterTypeDTO.id == 2) { // angular.extend(formdata.model.incident, { 'priority': { 'id': 2 } }); // } $state.go('app.incident.chart', { 'model': JSON.stringify(formdata) }); }; $scope.lookFunction = function (data) { // // var data = row.entity; // var formdata = { // 'model': { // 'incident': { // 'requester': data.requester, // 'area': data.place.area.area, // 'place': data.place.place, // 'houseNumber': data.address, // 'contacts': data.contacts, // 'contactsInformation': data.contactsInformation, // // 'category': data.wxIncidentClassifyDTO.category, // 'incidentState':data.incidentState, // 'description': data.incidentDescription, // 'source': { // 'id': 1549 // }, // 'sourceType': data.sourceType, // 'fileUrl': data.fileUrl // }, // 'requestershow': data.requester, // 'flow': data.id // } // } // var modelfile = { // model: { // incident: data // } // }; // if (data.incidentState.name == "未受理") { // angular.extend(modelfile.model, { // 'gourl': 'app.incident.chart', // 'state_model': formdata // }) // angular.extend(modelfile.model.incident, { // status: 1 // }) // } else { // angular.extend(modelfile.model.incident, { // status: 0 // }) // } // $state.go('app.desk.form_editor', { // formKey: 'desk_detail', // service: 'api_user_data', // model: JSON.stringify(modelfile) // }); $state.go('app.desk.detail', { model: JSON.stringify(data) }); }; $scope.toHandleFunction = function (data) { // var data = row.entity; console.log(data) var formdata = { 'model': { 'incident': { 'requester': data.requester, // 'area': data.place.area.area, // 'place': data.place.place, 'houseNumber': data.address, 'contacts': data.contacts, 'contactsInformation': data.contactsInformation, // 'category': data.wxIncidentClassifyDTO.category, 'incidentState': data.incidentState, 'description': data.incidentDescription, 'source': { 'id': 1549 }, 'sourceType': data.sourceType, 'fileUrl': data.fileUrl }, 'requestershow': data.requester, 'flow': data.id, 'retractReason': data.retractReason } } var modelfile = { model: { incident: data } }; // if (data.incidentState.name == "未受理") { angular.extend(modelfile.model, { 'gourl': 'app.incident.chart', 'state_model': formdata }) angular.extend(modelfile.model.incident, { status: 1 }) // } else { // angular.extend(modelfile.model.incident, { // status: 0 // }) // } $state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) }); }; $scope.seeIncidentFunction = function (data) { // console.log(data); $state.go('app.incident.detail', { formKey: 'incident_back', pdKey: 'incident', dataId: data.incident.id, taskId: data.incident.taskId, processInstanceId: data.incident.processInstanceId, isChart: "ok" }); } //重置 $scope.cleanItem = function () { delete $scope.fileData.wxincident.contacts; delete $scope.fileData.wxincident.contactsInformation; delete $scope.fileData.wxincident.createTime; delete $scope.fileData.wxincident.createTimeEnd; delete $scope.fileData.wxincident.departmentDTO; delete $scope.fileData.wxincident.sourceType; $scope.seiminObj = null; $scope.ksModel = ''; $scope.refreshData('expand-right', $scope.fileData); } // $scope.followFunction = function(data){ // //console.log('data='+JSON.stringify(data)); // $state.go('app.detail', { formKey:'statusform', pdKey:'incident', dataId: data.id,processInstanceId: data.processInstanceId}); // }; // $scope.onDblClick = function (row) { // var data = row.entity; // var formdata = { // 'model': { // 'incident': { // 'requester': data.requester, // 'area': data.area, // 'place': data.place, // 'houseNumber': data.address, // 'contacts': data.contacts, // 'contactsInformation': data.contactsInformation, // // 'category': data.wxIncidentClassifyDTO.category, // 'description': data.incidentDescription, // 'source': { // 'id': 4 // }, // 'sourceType': data.sourceType, // 'fileUrl': data.fileUrl // }, // 'requestershow': data.requester, // 'flow': data.id // } // } // var modelfile = { // model: { // incident: row.entity // } // }; // if (row.entity.state == "未受理") { // angular.extend(modelfile.model, { // 'gourl': 'app.incident.chart', // 'state_model': formdata // }) // angular.extend(modelfile.model.incident, { // status: 1 // }) // } else { // angular.extend(modelfile.model.incident, { // status: 0 // }) // } // $state.go('app.desk.form_editor', { // formKey: 'desk_detail', // service: 'api_user_data', // model: JSON.stringify(modelfile) // }); // }; var defaultFilterData = { // "assignee":$rootScope.user.id, // "candidateGroups":$rootScope.user.group[0].id, "idx": 0, "wxincident": { "serviceState": { "id": 1650 } }, "sum": mun }; $scope.ldloading = {}; $scope.refreshData = function (style, filterData) { $scope.ldloading[style.replace('-', '_')] = true; // if (angular.isUndefined(filterData)) { // filterData = defaultFilterData; // } if (angular.isUndefined(filterData)) { // if (sessionStorage.searchchart) { // filterData = JSON.parse(sessionStorage.getItem("searchchart")); // $scope.searchkeys = filterData.wxincident; // // $scope.searchstate = filterData.state; // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx; // $scope.searchstate = filterData.wxincident.searchType; // } else { filterData = defaultFilterData; // } } $scope.myData = []; $scope.gridOptions['sum'] = filterData.sum; //科室列表选中数据,请求参数判断 if ($scope.repairMain.valueconfig == 2 && $scope.ksModel != '') {//报修科室且不是空字符 $scope.fileData.wxincident.departmentDTO = { dept: $scope.ksModel } } // 根据权限查询 if($rootScope.user.duty){ // 当前的所属责任科室 filterData.wxincident.duty = $rootScope.user.duty; }else if($rootScope.user.branch){ // 当前的所属院区 filterData.wxincident.branch = $rootScope.user.branch.id; } sessionStorage['searchchart'] = angular.copy(JSON.stringify(filterData)); //搜索接口 api_bpm_data.fetchDataList("wxincident", filterData).then(function (data) { // console.log(filterData) var myData = Restangular.stripRestangular(data); for (var i = 0; i < myData.list.length; i++) { myData.list[i].createTime = moment(myData.list[i].createTime).format('YYYY-MM-DD HH:mm:ss') } $scope.gridOptions['totalItems'] = myData.totalNum; $scope.myData = myData.list; for (var i = 0; i < $scope.myData.length; i++) { $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum } // console.log($scope.myData) $scope.ldloading[style.replace('-', '_')] = false; }, function () { $scope.ldloading[style.replace('-', '_')] = false; }); }; $scope.refreshData2 = function (style, filterData) { $scope.ldloading[style.replace('-', '_')] = true; // if (angular.isUndefined(filterData)) { // filterData = defaultFilterData; // } if (angular.isUndefined(filterData)) { // if (sessionStorage.searchchart) { // filterData = JSON.parse(sessionStorage.getItem("searchchart")); // $scope.searchkeys = filterData.wxincident; // // $scope.searchstate = filterData.state; // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx; // $scope.searchstate = filterData.wxincident.searchType; // } else { filterData = defaultFilterData; // } } // $scope.myData = []; $scope.gridOptions['sum'] = filterData.sum; // 根据权限查询 if($rootScope.user.duty){ // 当前的所属责任科室 filterData.wxincident.duty = $rootScope.user.duty; }else if($rootScope.user.branch){ // 当前的所属院区 filterData.wxincident.branch = $rootScope.user.branch.id; } sessionStorage['searchchart'] = angular.copy(JSON.stringify(filterData)); api_bpm_data.fetchDataList("wxincident", filterData).then(function (data) { console.log(222) var myData = Restangular.stripRestangular(data); for (var i = 0; i < myData.list.length; i++) { myData.list[i].createTime = moment(myData.list[i].createTime).format('YYYY-MM-DD HH:mm:ss') } $scope.gridOptions['totalItems'] = myData.totalNum; $scope.myData = myData.list; for (var i = 0; i < $scope.myData.length; i++) { $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum } // console.log($scope.myData) $scope.ldloading[style.replace('-', '_')] = false; }, function () { $scope.ldloading[style.replace('-', '_')] = false; }); }; $scope.timer = $interval(function () { $scope.refreshData2('expand-right', $scope.fileData); }, $rootScope.refreshTime); console.log($state.params); if ($state.params.tab) { if ($state.params.tab == '-1') { $scope.searchstate = ''; $scope.fileData.wxincident = {}; } else { $scope.searchstate = $state.params.tab; $scope.fileData.wxincident.serviceState.id = $scope.searchstate; } } else { //默认未受理 $scope.searchstate = 1650; if (sessionStorage.getItem('jry_data')) { $scope.searchstate = sessionStorage.getItem('jry_data'); $scope.fileData.wxincident.serviceState.id = sessionStorage.getItem('jry_data'); } } $scope.$on('$destroy', function () { sessionStorage.setItem('jry_data', $scope.searchstate); $interval.cancel($scope.timer) }); $scope.refreshData('expand-right', $scope.fileData); }]); app.controller('Wechatoperator', ['$rootScope', '$http', '$scope', '$modal', 'api_user_data', function ($rootScope, $http, $scope, $modal, api_user_data) { $scope.handle = false; $scope.see = false; $scope.toHandle = false; var loginUser = $rootScope.user; // 是否是服务台经理 $scope.isFuwutaijingli = loginUser.role.filter(v => v.rolecode == 'call center admin').length > 0; // 是否显示解除锁定 $scope.isUnLock = false; console.log($scope.item) if ($scope.item.operationLog) { $scope.isUnLock = ($scope.item.operationLog.userId == loginUser.id) && ($scope.item.operationLog.opValue == 1); } else { $scope.isUnLock = false; } // 是否显示处理--锁定相关的操作 $scope.isChuli = false; if ($scope.isFuwutaijingli) { //如果有服务台经理角色 $scope.isChuli = true; } else { //如果没有服务台经理角色 if ($scope.item.operationLog) { if ($scope.item.operationLog.opValue == 1) { //如果锁定 $scope.isChuli = $scope.item.operationLog.userId == loginUser.id; } else { //如果没锁定 $scope.isChuli = true; } } else { $scope.isChuli = true; } } $scope.chuli = false; for (var i = 0; i < loginUser.menu.length; i++) { if (loginUser.menu[i].link == "weixinbaozhang_chuli") { $scope.chuli = true } } if ($scope.item.serviceState.name == "已受理") { $scope.toHandle = true; } else { $scope.toHandle = false; } if ($scope.item.serviceState.name == "未受理") { $scope.handle = true; } else { $scope.handle = false; } if ($scope.item.serviceState.name == "已受理" || $scope.item.serviceState.name == "不受理" || $scope.item.serviceState.name == "未受理") { $scope.see = true; } else { $scope.see = false; } $scope.edit = function () { $scope.colobject.grid.appScope.selectRowFunction($scope.item); // $scope.doEdit($scope.item.id); } //查看,查看详情 $scope.look = function () { $scope.colobject.grid.appScope.lookFunction($scope.item); // $scope.doEdit($scope.item.id); } //处理 $scope.handleFn = function () { console.log($scope.item) // $scope.colobject.grid.appScope.toHandleFunction($scope.item); //是否包含服务台经理角色 var isFuwutaijingli = loginUser.role.filter(v => v.rolecode == 'call center admin').length > 0; if (!isFuwutaijingli) { if ($scope.item.operationLog) { //有锁定操作记录的 var p1 = { idx: 0, sum: 1000, operationLog: { id: $scope.item.operationLog.id, extra1: $scope.item.id, opType: 'wxincidentLock' } }; api_user_data.fetchDataList('operationLog', p1).then(function (result) { if (result.status == 200) { var opValue = result.list[0].opValue;//查询锁定状态 var userName = result.list[0].userName;//查询锁定人 var userId = result.list[0].userId;//查询锁定人ID if (opValue == 1&&userId!=loginUser.id) { //如果锁定了,并不是锁定人操作 $modal.open({ templateUrl: 'assets/views/delete.html', controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) { $scope.title = '提示'; $scope.connect = '该报修已被【' + userName + '】锁定!'; $scope.yesFlag = true; //选择“取消”或“确定” $scope.cancel = function () { $modalInstance.dismiss('cancel'); scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData); }; }, size: 'sm', resolve: { scope: function () { return $scope; } } }); } else if(opValue == 1&&userId==loginUser.id){ //如果锁定了,并是锁定人操作 $scope.colobject.grid.appScope.toHandleFunction($scope.item); }else{ //如果没有锁定 $scope.operateUnLock($scope.item.operationLog.id) } } }) } else { //没有锁定记录的 $scope.operateUnLock(); } } else { $scope.colobject.grid.appScope.toHandleFunction($scope.item); } // $scope.doEdit($scope.item.id); } //是否锁定,id是日志ID,有是修改,没有是新增 $scope.operateUnLock = function (id) { $modal.open({ templateUrl: 'assets/views/delete.html', controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) { $scope.title = '提示'; $scope.connect = '是否锁定?锁定后其他人(服务台经理除外)无法操作此报修!'; $scope.noFlag = true; //选择“是” $scope.yes = function () { if (scope.item) { var postData = { operationLog: { extra1: scope.item.id, userId: loginUser.id, userName: loginUser.name, opType: 'wxincidentLock', opValue: '1' } }; if(id){ postData.operationLog.id = id; } api_user_data.addData('operationLog', postData).then(function (response) { if (response.data) { $modalInstance.dismiss('cancel'); SweetAlert.swal({ title: "锁定成功!", type: "success", confirmButtonColor: "#007AFF" }, function () { scope.colobject.grid.appScope.toHandleFunction(scope.item); }); } else { SweetAlert.swal({ title: "操作异常!", text: "系统异常,请稍后重试,或者联系管理员!", type: "error" }); } }) } }; //选择“取消” $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; //选择“否” $scope.no = function () { $modalInstance.dismiss('cancel'); scope.colobject.grid.appScope.toHandleFunction(scope.item); }; }, size: 'sm', resolve: { scope: function () { return $scope; } } }); } //解锁 $scope.unLock = function(){ $modal.open({ templateUrl: 'assets/views/delete.html', controller: function ($scope, scope, $modalInstance, api_user_data, SweetAlert) { $scope.title = '提示'; $scope.connect = '是否解锁?'; $scope.noFlag = true; //选择“是” $scope.yes = function () { if (scope.item) { var postData = { operationLog: { id:scope.item.operationLog.id, extra1: scope.item.id, userId: loginUser.id, userName: loginUser.name, opType: 'wxincidentLock', opValue: '0' } }; api_user_data.addData('operationLog', postData).then(function (response) { if (response.data) { $modalInstance.dismiss('cancel'); SweetAlert.swal({ title: "解锁成功!", type: "success", confirmButtonColor: "#007AFF" }, function () { scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent.$parent.refreshData('expand-right', $scope.fileData); }); } else { SweetAlert.swal({ title: "操作异常!", text: "系统异常,请稍后重试,或者联系管理员!", type: "error" }); } }) } }; //选择“取消” $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; //选择“否” $scope.no = function () { $modalInstance.dismiss('cancel'); }; }, size: 'sm', resolve: { scope: function () { return $scope; } } }); } //查看事件 $scope.seeIncident = function () { $scope.colobject.grid.appScope.seeIncidentFunction($scope.item); // $scope.doEdit($scope.item.id); } }]); app.directive('wechatoperator', function () { return { restrict: 'E', scope: { item: '=', colobject: '=' }, controller: 'Wechatoperator', template: '' }; }); // app.factory('myFactory', function() { // //定义factory返回对象 // var myServices = {}; // //定义参数对象 // var myObject = {}; // var _set = function(data) { // myObject = data; // }; // })