| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- angular.module('app.business').controller("pageEditCtrl", function ($scope, $http, $stateParams, $state, $rootScope, APP_CONFIG, $uibModal, pageListService, warehouseService) {
- $scope.title = $stateParams.title;
- $scope.sealedStorage = {};
- // console.log("userInfoAllData", $rootScope.userInfoAllData)
- // 根据id查询数据
- $scope.getDataById = function (id) {
- pageListService.getDataById(id).then(function (data) {
- $scope.sealedStorage = data.data;
- $scope.auditList = data.data.processList;
- if ($scope.sealedStorage.auditState === 1 || $scope.sealedStorage.auditState === 3) {
- $scope.isNotEdit = false; // 审批状态
- } else {
- $scope.isNotEdit = true; // 审批状态
- }
- $scope.loadWare();
- }, function (data) {
- console.log(data);
- });
- };
- if ($stateParams.editType === 'add' && $stateParams.auditState === '1') {
- // 下拉编辑
- $scope.isNotEdit = false;
- $scope.showNotCommit = false; // 通过,驳回
- $scope.showCommit = true; // 保存,提交
- $scope.isNotEdit = false; // 审批信息
- } else if ($stateParams.editType === 'update') {
- console.log("$stateParams.editType-->", $stateParams.editType)
- // 下拉编辑
- $scope.isNotEdit = false;
- $scope.showNotCommit = false; // 通过,驳回
- $scope.showCommit = true; // 保存,提交
- $scope.isNotEdit = false; // 审批信息
- $scope.getDataById($stateParams.id);
- } else if ($stateParams.editType === 'audit') {
- // 下拉编辑
- $scope.isNotEdit = true;
- $scope.showNotCommit = true; // 通过,驳回
- $scope.showCommit = false; // 保存,提交
- $scope.isNotEdit = true; // 审批信息
- $scope.getDataById($stateParams.id);
- } else {
- // 下拉编辑
- $scope.isNotEdit = true;
- // 显示提交按钮
- $scope.showCommit = true;
- $scope.showNotCommit = false; // 通过,驳回
- $scope.showCommit = false; // 保存,提交
- $scope.isNotEdit = true; // 审批信息
- $scope.getDataById($stateParams.id);
- }
- // 新增,修改按钮判断
- $scope.editData = function (audit, auditType) {
- $scope.sealedStorage.saveProcess = {};
- $scope.sealedStorage.saveProcess.auditState = auditType;
- $scope.sealedStorage.saveProcess.taskType = 'storage_sealed_confirmation';
- $scope.sealedStorage.saveProcess.applyNameId = $rootScope.userInfo.userId;
- $scope.sealedStorage.saveProcess.applyName = $rootScope.userInfo.realName;
- if (auditType === '2' && $scope.sealedStorage.auditState === 1) {
- $scope.sealedStorage.saveProcess.taskName = '员工提交';
- $scope.sealedStorage.saveProcess.applyResult = '待审批';
- $scope.sealedStorage.saveProcess.applyContent = $rootScope.userInfo.realName + '提交';
- $scope.sealedStorage.auditState = auditType;
- } else if (auditType === '3') {
- $scope.sealedStorage.saveProcess.taskName = '驳回';
- $scope.sealedStorage.saveProcess.applyResult = '审批结束';
- $scope.sealedStorage.saveProcess.applyContent = audit.applyContent;
- $scope.sealedStorage.auditState = 3;
- } else if (auditType === '4' && $scope.sealedStorage.auditState === 2) {
- $scope.sealedStorage.saveProcess.taskName = '部门审核';
- $scope.sealedStorage.saveProcess.applyResult = '已审批';
- $scope.sealedStorage.auditState = auditType;
- } else if (auditType === '4' && $scope.sealedStorage.auditState === 4) {
- $scope.sealedStorage.saveProcess.taskName = '单位领导审核';
- $scope.sealedStorage.saveProcess.applyResult = '审批结束';
- $scope.sealedStorage.saveProcess.applyContent = audit.applyContent;
- $scope.sealedStorage.auditState = 5;
- } else {
- $scope.sealedStorage.auditState = auditType;
- }
- if ($stateParams.id === '0') {
- // 新增
- $scope.save(audit);
- } else {
- $scope.update(audit);
- }
- };
- // 获取入库中的仓房油罐
- $scope.selectNotSealedStorageList = function () {
- pageListService.selectNotSealedStorage($rootScope.userInfo.orgId).then(function (data) {
- $scope.sealedStorageList = data.data;
- }, function (data) {
- console.log(data);
- });
- };
- $scope.selectNotSealedStorageList();
- // 货位列表
- $scope.loadWare = function () {
- // datatype 0:仓房,1:油罐
- // console.log($rootScope.storehouseObj[$scope.sealedStorage.houseId].datatype)
- if ($rootScope.storehouseObj[$scope.sealedStorage.houseId].datatype == 1) {
- // 油罐,没有货位
- $scope.warelist = [];
- $scope.checkGrainAttribute();
- } else {
- // 仓房获取货位
- warehouseService.getStorehouse($rootScope.orgInfo.orgId, $scope.sealedStorage.houseId).then(function (data) {
- $scope.warelist = data.wareList;
- }, function (data) {
- console.log(data);
- });
- }
- };
- // 获取封仓数据
- $scope.checkGrainAttribute = function () {
- pageListService.checkGrainAttribute($rootScope.orgInfo.orgId, $scope.sealedStorage.houseId, $scope.sealedStorage.warehouseId).then(function (data) {
- let sealedStorage = data.data;
- if (sealedStorage === null) {
- alert("未查询到关联数据");
- } else {
- $scope.sealedStorage = data.data;
- console.log("sealedStorage:", $scope.sealedStorage)
- for (let i = 0; i < $scope.warelist.length; i++) {
- if ($scope.sealedStorage.warehouseId === $scope.warelist[i].warehouseId) {
- // 存放粮油类型(0:原粮/油,1:成品粮/油)
- if ('0' === $scope.warelist[i].lylx) {// 效验性质转变单审批状态
- pageListService.checkAuditState($scope.sealedStorage.houseId, $scope.sealedStorage.harvestYear, $scope.sealedStorage.warehouseId).then(function (data) {
- // 审批状态(0:仓储部经理审批,1:质检部经理审批,2:统计经理审批,3:会计审批,4:库领导审批,5:审批结束)
- let auditState = data.data;
- if (auditState !== '5') {
- alert("性质转变单审批未通过");
- $scope.sealedStorage = {};
- }
- }, function (data) {
- console.log(data);
- });
- }
- }
- }
- }
- console.log($scope.sealedStorage)
- }, function (data) {
- console.log(data);
- });
- };
- // 表单效验
- var validator = $("#storageSealed-form").validate();
- // 保存
- $scope.save = function () {
- if (validator.form()) {
- pageListService.saveData($scope.sealedStorage).then(function (data) {
- if (data.retCode === '200') {
- alert('保存成功');
- $state.go('app.business.grainReservesManage.storageSealedConfirmation.getPageList');
- } else {
- alert(data.message);
- }
- }, function (data) {
- console.log(data);
- });
- }
- };
- // 修改
- $scope.update = function () {
- if (validator.form()) {
- pageListService.updateData($scope.sealedStorage).then(function (data) {
- if (data.retCode === '200') {
- alert('修改成功');
- if ($stateParams.auditState === '1') {
- $state.go('app.business.grainReservesManage.storageSealedConfirmation.getPageList');
- }
- if ($stateParams.auditState === '2') {
- $state.go('app.business.grainReservesManage.storageSealedConfirmation.getPageList-audit');
- }
- if ($stateParams.auditState === '3') {
- $state.go('app.business.grainReservesManage.storageSealedConfirmation.getPageList-auditEnd');
- }
- } else {
- alert(data.message);
- }
- }, function (data) {
- console.log(data);
- });
- }
- };
- // 返回
- $scope.retList = function () {
- if ($rootScope.previousState_name !== '') {
- $rootScope.back();
- } else {
- $state.go('app.business.grainReservesManage.storageSealedConfirmation.getPageList');
- }
- }
- });
|