Commit 0ab0d6ca authored by 顾俭's avatar 顾俭

aship/aship#3 防伪码功能-作废重打:UI

parent ab33641d
......@@ -184,7 +184,9 @@ combineJs {
'src/main/resources/static/app/srm/invoice/view/view.js',
'src/main/resources/static/app/srm/session/session.js',
'src/main/resources/static/app/srm/session/query/query.js'
'src/main/resources/static/app/srm/session/query/query.js',
'src/main/resources/static/app/srm/barcode/barcode.js',
'src/main/resources/static/app/srm/barcode/query/query.js'
)
dest = file("src/main/resources/static/all.js")
......
......@@ -2,22 +2,32 @@ package com.i1.srm.purchaseOrder.web;
import com.i1.base.exception.IOneWebRestfulException;
import com.i1.erp.barcode.soap.BarcodeGetStatusClient;
import com.i1.erp.barcode.soap.BarcodePrintClient;
import com.i1.erp.barcode.soap.BarcodeVoidClient;
import com.i1.erp.base.web.dto.SyncResponse;
import com.i1.erp.base.web.dto.SyncResponseWithList;
import com.i1.srm.am.entity.Function;
import com.i1.srm.am.entity.Resource;
import com.i1.srm.am.service.ResourcePermission;
import com.i1.srm.am.service.SecuredPage;
import com.i1.srm.purchaseOrder.web.dto.PoBarcodePrintDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import static com.i1.erp.barcode.soap.BarcodePrintClient.TYPE_REPRINT;
import static com.i1.erp.base.web.dto.SyncResponseCode.SUCCESS_CODE;
/**
* 申请防伪码在/purchaseOrders/genBarcode
* 获取防伪码打印url在/purchaseOrderDetails/{id}/printBarcode
*
* 按项次首次获取防伪码打印url在/purchaseOrderDetails/{id}/printBarcode
*/
@RestController
@RequestMapping("/barcode")
......@@ -30,11 +40,13 @@ public class BarcodeController {
@Autowired
private BarcodeVoidClient barcodeVoidClient;
@Autowired
private BarcodePrintClient barCodePrintClient;
private Logger logger = LoggerFactory.getLogger(BarcodeController.class);
@RequestMapping(value = "/status", method = RequestMethod.GET)
@ResourcePermission(values = {Resource.GET_BARCODE_STATUS})
@ResponseStatus(HttpStatus.CREATED)
public SyncResponse getBarCodeStatus(@RequestParam String factoryUid, @RequestParam String barcode) throws IOneWebRestfulException {
return barcodeGetStatusClient.getBarcodeStatus(factoryUid, barcode);
}
......@@ -46,4 +58,16 @@ public class BarcodeController {
return barcodeVoidClient.voidBarcode(factoryUid, barcode);
}
@RequestMapping(value = "/print", method = RequestMethod.GET)
@ResourcePermission(values = {Resource.PRINT_BARCODE})
public PoBarcodePrintDto printBarCodeStatus(@RequestParam String factoryUid, @RequestParam String barcode) throws IOneWebRestfulException {
List<String> urls = new ArrayList<>();
SyncResponseWithList responseWithList = barCodePrintClient.getBarcodePrintUrls(
factoryUid, "", "", barcode, TYPE_REPRINT);
if (SUCCESS_CODE.equals(responseWithList.getCode())) {
urls.addAll(responseWithList.getContent());
}
return new PoBarcodePrintDto(responseWithList.getCode(), responseWithList.getMessage(), urls);
}
}
......@@ -60,6 +60,7 @@
// icon: 'fa fa-book',
// acl: 'PURCHASE_ORDER_CHANGE_FUNCTION'
// }
{name: '防伪码管理', url: '/#!/barcode', icon: 'fa fa-book', acl: 'BARCODE_FUNCTION'}
]
},
//2
......
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>防伪码管理
<small>{{vm.subPages[vm.currentPage].name}}</small>
</h1>
</section>
<!-- Main content -->
<section class="content">
<div multiple-tabs sub-pages="vm.subPages" current-page="vm.currentPage" vm="vm">
</div>
</section>
<!-- /.content -->
\ No newline at end of file
(function () {
angular.module('IOne').config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/barcode', {
controller: 'BarcodeController',
templateUrl: 'app/srm/barcode/barcode.html',
controllerAs: 'vm',
resolve: {
currentAcl: function (AuthService) {
return AuthService.getCurrentAcl();
}
}
});
}]);
angular.module('IOne').factory('BarcodeService', function ($http) {
return angular.extend(new BaseService('/barcode', $http), {
voidBarcode: function (factoryUid, barcode) {
return this.httpService.delete('/barcode/void?factoryUid=' + factoryUid + '&barcode=' + barcode);
},
getBarcodeStatus: function (factoryUid, barcode) {
return this.httpService.get('/barcode/status?factoryUid=' + factoryUid + '&barcode=' + barcode);
},
printBarcode: function (factoryUid, barcode) {
return this.httpService.get('/barcode/print?factoryUid=' + factoryUid + '&barcode=' + barcode);
}
});
});
angular.module('IOne').controller('BarcodeController', BarcodeController);
BarcodeController.$inject = ['$rootScope', 'currentAcl'];
function BarcodeController($rootScope, currentAcl) {
var vm = this;
vm.currentAcl = currentAcl.data;
//variables
vm.subPages = {
'index': {name: '防伪码作废/重打', show: true, closable: false, url: 'app/srm/barcode/query/query.html'},
};
}
})();
\ No newline at end of file
<div ng-controller="BarcodeQueryController">
<form name="barcodeForm">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>营运中心</label>
<select class="form-control select2" ng-model="queryCondition.factory.id" required style="width: 100%;">
<option ng-repeat="factory in factories" value="{{factory.id}}">{{factory.name}}</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>防伪码</label>
<input class="form-control" ng-change="barcodeChange()" ng-model="queryCondition.barcode" required
type="text">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>&nbsp;</label>
<div>
<button acl-check class="btn btn-primary" func=" 'BARCODE_FUNCTION' " ng-click="query()"
ng-disabled="!barcodeForm.$valid" resource=" 'QUERY' " type="button"><i class="fa fa-search"></i> 查询状态
</button>
<span ng-if="loading"><img src="img/spinner.gif" style="width: 30px;"/></span>
</div>
</div>
</div>
</div>
</form>
<div class="button-bar" style="height: 200px">
<div class="row">
<div class="col-md-8">
<h1 class="pam">条码状态:有效</h1>
<h5 class="pam">条码状态:有效</h5>
</div>
</div>
</div>
<div class="button-bar">
<div class="row">
<div class="col-md-6">
<button acl-check class="btn btn-primary plm prm mrm" func=" 'BARCODE_FUNCTION' " ng-click="void()"
ng-disabled="!okStats" resource=" 'VOID_BARCODE' ">
<i class="fa fa-times"></i>&nbsp;&nbsp;作废
</button>
<button acl-check class="btn btn-primary plm prm" func=" 'BARCODE_FUNCTION' " ng-click="print()"
ng-disabled="!okStats" resource=" 'PRINT_BARCODE' ">
<i class='fa fa-print'></i>&nbsp;&nbsp;重打
</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
angular.module('IOne').controller('BarcodeQueryController', function ($scope, Constants, $interval, $uibModal, UtilService,
BaseFactoryFileService, AuthService, BarcodeService) {
$scope.queryCondition = {
factory: {id: null},
barcode: null
};
$scope.okStatus = false;
$scope.dtlMessage = "";
$scope.query = function () {
if (AuthService.hasAcl($scope.vm.currentAcl, 'BARCODE_FUNCTION', 'QUERY')) {
BarcodeService.getBarcodeStatus($scope.queryCondition.factory.factoryUid, $scope.queryCondition.barcode).then(
function (response) {
if (response.data.code == '0') {
$scope.okStatus = true;
UtilService.showInfo(response.data.message);
$scope.dtlMessage = response.data.message;
} else {
UtilService.showError(response.data.message);
$scope.dtlMessage = response.data.message;
}
},
function (response) {
UtilService.showError(response.data.error);
$scope.dtlMessage = response.data.message;
}
);
}
};
$scope.void = function () {
UtilService.showConfirm('确认作废' + $scope.queryCondition.barcode + '?', '', function () {
BarcodeService.voidBarcode($scope.queryCondition.factory.factoryUid, $scope.queryCondition.barcode).then(
function (response) {
if (response.data.code == '0') {
UtilService.showInfo(response.data.message);
} else {
UtilService.showError("作废失败:<br>" + response.data.message);
}
},
function (response) {
UtilService.showError("作废失败:<br>" + response.data.error);
}
);
});
};
$scope.print = function () {
BarcodeService.printBarcode($scope.queryCondition.factory.factoryUid, $scope.queryCondition.barcode).then(
function (response) {
if (response.data && response.data.code === '0') {
if (response.data.printUrls.length === 0) {
UtilService.showWarn("没有可打印的防伪码");
return;
}
angular.forEach(response.data.printUrls, function (url) {
try {
$window.open(url);
} catch (e) {
console.error(e);
}
});
} else {
UtilService.showError("打印防伪码失败:<br>" + response.data.message);
}
}, function (response) {
UtilService.showError("打印防伪码失败:<br>" + response.data);
}
)
};
$scope.barcodeChange = function () {
$scope.okStatus = false;
$scope.dtlMessage = "";
};
$scope.init = function () {
$scope.loading = false;
BaseFactoryFileService.getByAccount().then(function (response) {
$scope.factories = response;
if ($scope.factories.length > 0) {
$scope.queryCondition.factory.id = $scope.factories[0].id;
}
});
};
$scope.init();
});
......@@ -363,6 +363,9 @@
<script th:if="${dev}" src="app/srm/session/session.js"></script>
<script th:if="${dev}" src="app/srm/session/query/query.js"></script>
<script th:if="${dev}" src="app/srm/barcode/barcode.js"></script>
<script th:if="${dev}" src="app/srm/barcode/query/query.js"></script>
<script th:if="${dev}" src="app/srm/zTest/test.js"></script>
<script th:if="${dev}" src="app/srm/zTest/chart/chart.js"></script>
<script th:if="${dev}" src="app/srm/zTest/uiGrid/uiGrid.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment