|
|
@@ -1,6 +1,6 @@
|
|
|
-define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives', 'service/Purc', 'service/Make', 'service/Fa', 'service/Account', 'service/Alert', 'service/CheckTel', 'ui.router', 'ui.bootstrap', 'file-upload', 'ngSanitize', 'service/BaseInfo', 'service/Cart', 'service/ApprovalFlow', 'service/DeputyOrder', 'service/Product', 'service/Token', 'service/ProductUsers', 'service/File', 'service/PublicInquiry', 'service/Customer'], function () {
|
|
|
+define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives', 'service/Purc', 'service/Make', 'service/Fa', 'service/Account', 'service/Alert', 'service/CheckTel', 'ui.router', 'ui.bootstrap', 'file-upload', 'ngSanitize', 'service/BaseInfo', 'service/Cart', 'service/ApprovalFlow', 'service/DeputyOrder', 'service/Product', 'service/Token', 'service/ProductUsers', 'service/File', 'service/PublicInquiry', 'service/Customer', 'service/PurcChange'], function () {
|
|
|
'use strict';
|
|
|
- var app = angular.module('myApp', ['toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'common.directives', 'PurcServices', 'MakeServices', 'FaServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize', 'CheckTelModule', 'ProductServices', 'CartServices', 'ApprvoalFlowService', 'DeputyOrderService', 'ProductInfoServices', 'TokenService', 'ProductUserService', 'ui.tour', 'FileService', 'publicInquiryService', 'CustomerService']);
|
|
|
+ var app = angular.module('myApp', ['toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'common.directives', 'PurcServices', 'MakeServices', 'FaServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize', 'CheckTelModule', 'ProductServices', 'CartServices', 'ApprvoalFlowService', 'DeputyOrderService', 'ProductInfoServices', 'TokenService', 'ProductUserService', 'ui.tour', 'FileService', 'publicInquiryService', 'CustomerService', 'changeService']);
|
|
|
app.init = function () {
|
|
|
angular.bootstrap(document, ['myApp']);
|
|
|
};
|
|
|
@@ -128,6 +128,19 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
url: "/deputy/:id",
|
|
|
templateUrl: "static/tpl/index/purc/deputyOrder_detail.html",
|
|
|
controller: 'DeputyOrderDetailCtrl'
|
|
|
+ }).state('purc.changeList', {// 新增采购变更单
|
|
|
+ url: "/change",
|
|
|
+ templateUrl: "static/tpl/index/purc/changeList.html",
|
|
|
+ controller: 'PurcChangeListCtrl'
|
|
|
+ /* 采购变更单详情 */
|
|
|
+ }).state('purc.change_detail', {
|
|
|
+ url: "/change/:id",
|
|
|
+ templateUrl: "static/tpl/index/purc/change_detail.html",
|
|
|
+ controller: 'PurcChangeDetailCtrl'
|
|
|
+ }).state('purc.changeNew', {// 新增采购变更单
|
|
|
+ url: "/change_new",
|
|
|
+ templateUrl: "static/tpl/index/purc/change_new.html",
|
|
|
+ controller: 'PurcChangeNewCtrl'
|
|
|
/* 招标列表 */
|
|
|
}).state('purc.tenderlist', {
|
|
|
url: "/tender",
|
|
|
@@ -3487,7 +3500,6 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
$scope.$dateOpen = !openParam;
|
|
|
};
|
|
|
|
|
|
-
|
|
|
// 取消
|
|
|
$scope.cancel = function () {
|
|
|
$modalInstance.dismiss();
|
|
|
@@ -23931,6 +23943,416 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}
|
|
|
|
|
|
}]);
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 采购变更单列表
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ * @date 2018-06-25 17:13
|
|
|
+ */
|
|
|
+ app.controller('PurcChangeListCtrl', ['$scope', '$filter', 'change', 'ngTableParams', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $filter, change, ngTableParams, toaster, BaseService, CurrentRole) {
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+
|
|
|
+ $scope.active = 'todo';
|
|
|
+ $scope.agreedText = '全部';
|
|
|
+ $scope.dateZoneText = '一个月内';
|
|
|
+ $scope.condition = {dateZone: 1};
|
|
|
+
|
|
|
+ /* 时间筛选初始化*/
|
|
|
+ var fromDate = new Date();
|
|
|
+ var toDate = new Date();
|
|
|
+ fromDate.setMonth(fromDate.getMonth() - 1);
|
|
|
+ fromDate.setHours(0, 0, 0, 0);
|
|
|
+ toDate.setHours(23, 59, 59, 999);
|
|
|
+ $scope.condition.dateFrom = fromDate;
|
|
|
+ $scope.condition.dateTo = toDate;
|
|
|
+
|
|
|
+ $scope.changeAgreed = function (agreed) {
|
|
|
+ $scope.condition.agreed = agreed;
|
|
|
+ $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
|
|
|
+ $scope.condition.$agreedOpen = false;
|
|
|
+ };
|
|
|
+ $scope.changeDateZone = function (zone) {
|
|
|
+ $scope.condition.dateZone = zone;
|
|
|
+ $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
|
|
|
+ $scope.condition.$dateZoneOpen = false;
|
|
|
+ getDateCondition(zone, $scope.condition);
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+ $scope.setActive = function (state) {
|
|
|
+ if ($scope.active != state) {
|
|
|
+ $scope.active = state;
|
|
|
+ if ($scope.tableParams.page() == 1)
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ else
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ var getService = function () {
|
|
|
+ return change;
|
|
|
+ };
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 20,
|
|
|
+ sorting: {
|
|
|
+ date: 'desc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ pageParams.searchFilter = {
|
|
|
+ keyword: $scope.keyword,
|
|
|
+ fromDate: getDateTime($scope.condition.dateFrom),
|
|
|
+ endDate: getDateTime($scope.condition.dateTo)
|
|
|
+ };
|
|
|
+ getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
|
|
|
+ $scope.loading = false;
|
|
|
+ if (page) {
|
|
|
+ params.total(page.totalElement);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.openDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openFilterDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function (keyword) {
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 导出
|
|
|
+ $scope.exportXls = function () {
|
|
|
+ change.exportXls({}, {}, function (data) {
|
|
|
+ if (data.success){
|
|
|
+ window.location.href = 'purc/change/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增采购变更单
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ * @date 2018-06-25 16:38
|
|
|
+ */
|
|
|
+ app.controller('PurcChangeNewCtrl', ['$scope', 'toaster', 'BaseService', 'AuthenticationService', '$modal', '$filter', 'change',
|
|
|
+ function ($scope, toaster, BaseService, AuthenticationService, $modal, $filter, change) {
|
|
|
+ // 获取登录人员信息
|
|
|
+ AuthenticationService.getAuthentication().success(function (data) {
|
|
|
+ $scope.user = data;
|
|
|
+ initChange();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 初始化变更单信息
|
|
|
+ var initChange = function () {
|
|
|
+ $scope.change = {
|
|
|
+ date: new Date(),
|
|
|
+ recorder: $scope.user.userName,
|
|
|
+ orderCode: null,
|
|
|
+ code: 'B2BPC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
|
|
|
+ orderId: null,
|
|
|
+ orderChangeItems: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.getEnableOrders = function() {
|
|
|
+ initChange();
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ size: 'lg',
|
|
|
+ templateUrl: 'static/tpl/index/purc/modal/enableOrderList.html',
|
|
|
+ controller: 'EnableChangeListCtrl',
|
|
|
+ resolve: {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function (data) {
|
|
|
+ $scope.change.orderCode = data.code;
|
|
|
+ $scope.change.orderId = data.id;
|
|
|
+ $scope.orderItems = data.orderItems;
|
|
|
+ $scope.change.oldCurrency = data.currency;
|
|
|
+ $scope.change.oldPayments = data.payments;
|
|
|
+ $scope.change.oldRate = data.rate;
|
|
|
+ $scope.change.vendUU = data.vendUU;
|
|
|
+ $scope.change.apVendorName = data.receiveName;
|
|
|
+ $scope.change.vendUserUU = data.vendUserUU;
|
|
|
+ $scope.change.newCurrency = data.currency != null ? data.currency :null;
|
|
|
+ $scope.change.newPayments = data.payments != null ? data.payments :null;
|
|
|
+ angular.forEach($scope.orderItems, function (item, index) {
|
|
|
+ $scope.change.orderChangeItems.push({
|
|
|
+ oldProductId: item.productId,
|
|
|
+ orderItemId: item.id,
|
|
|
+ orderItemNumber: item.number,
|
|
|
+ oldQty: item.qty,
|
|
|
+ oldPrice: item.price,
|
|
|
+ oldTaxrate: item.taxrate,
|
|
|
+ oldDelivery: item.delivery,
|
|
|
+ newQty: item.qty != null ? item.qty :null,
|
|
|
+ newPrice: item.price != null ? item.price :null,
|
|
|
+ newTaxrate: item.taxrate != null ? item.taxrate :null,
|
|
|
+ newDelivery: item.delivery != null ? item.delivery :null,
|
|
|
+ oldProduct: item.product,
|
|
|
+ number: index + 1
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除明细
|
|
|
+ $scope.del = function (index) {
|
|
|
+ $scope.change.orderChangeItems.splice(index, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.getMinDate = function () {
|
|
|
+ return $filter('date')(new Date, 'yyyy-MM-dd');
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openDatePicker = function ($event, openParam, index) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ $scope.change.orderChangeItems[index].$dateOpen = !openParam;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.save = function() {
|
|
|
+ if ($scope.change.unNeedReply == null) {
|
|
|
+ toaster.pop('error', '请选择是否需要供应商确认');
|
|
|
+ } else if ($scope.change.orderChangeItems.length == 0) {
|
|
|
+ toaster.pop('error', '请至少选择一条采购明细')
|
|
|
+ } else {
|
|
|
+ change.save({}, $scope.change, function (data) {
|
|
|
+ window.location.hash = "/purc/change/" + data.id;
|
|
|
+ toaster.pop('success', '采购变更单保存成功');
|
|
|
+ }, function(res) {
|
|
|
+ toaster.pop('error','请输入正确的信息')
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取可以作为采购变更单的采购单
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ * @date 2018-06-25 18:41
|
|
|
+ */
|
|
|
+ app.controller('EnableChangeListCtrl', ['$scope', 'change', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance',
|
|
|
+ function ($scope, change, BaseService, ngTableParams, toaster, $modalInstance) {
|
|
|
+
|
|
|
+ $scope.dateZoneText = '一个月内';
|
|
|
+ $scope.condition = {dateZone: 1};
|
|
|
+
|
|
|
+ /* 时间筛选初始化*/
|
|
|
+ var fromDate = new Date();
|
|
|
+ var toDate = new Date();
|
|
|
+ fromDate.setMonth(fromDate.getMonth() - 1);
|
|
|
+ fromDate.setHours(0, 0, 0, 0);
|
|
|
+ toDate.setHours(23, 59, 59, 999);
|
|
|
+ $scope.condition.dateFrom = fromDate;
|
|
|
+ $scope.condition.dateTo = toDate;
|
|
|
+
|
|
|
+ $scope.changeDateZone = function (zone) {
|
|
|
+ $scope.condition.dateZone = zone;
|
|
|
+ $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
|
|
|
+ $scope.condition.$dateZoneOpen = false;
|
|
|
+ getDateCondition(zone, $scope.condition);
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openFilterDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 5,
|
|
|
+ sorting: {
|
|
|
+ 'id': 'desc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [],
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ pageParams.searchFilter = { // 筛选条件
|
|
|
+ keyword: $scope.keyword,
|
|
|
+ fromDate: getDateTime($scope.condition.dateFrom),
|
|
|
+ endDate: getDateTime($scope.condition.dateTo)
|
|
|
+ };
|
|
|
+ change.getEnableOrderList.call(null, BaseService.parseParams(pageParams), function (page) {
|
|
|
+ $scope.loading = false;
|
|
|
+ if (page) {
|
|
|
+ params.total(page.totalElement);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.checkedOrder = null;
|
|
|
+ var checkItems = [];
|
|
|
+ // 单选
|
|
|
+ $scope.checkOne = function (order) {
|
|
|
+ var changeflag = false;
|
|
|
+ order.checked = !order.checked;
|
|
|
+ if ((order.checked) && ($scope.checkedOrder != null) && ($scope.checkedOrder != order)) {
|
|
|
+ $scope.checkedOrder.checked = false;
|
|
|
+ angular.forEach($scope.checkedOrder.orderItems, function (item) {
|
|
|
+ item.checked = false;
|
|
|
+ });
|
|
|
+ $scope.checkedOrder = null;
|
|
|
+ checkItems = [];
|
|
|
+ }
|
|
|
+ if (order.checked) {
|
|
|
+ $scope.checkedOrder = order;
|
|
|
+ angular.forEach(order.orderItems, function (item) {
|
|
|
+ if (item.change) {
|
|
|
+ item.checked = false;
|
|
|
+ changeflag = true;
|
|
|
+ } else {
|
|
|
+ item.checked = true;
|
|
|
+ checkItems.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.checkedOrder = null;
|
|
|
+ angular.forEach(order.orderItems, function (item) {
|
|
|
+ item.checked = false;
|
|
|
+ });
|
|
|
+ checkItems = [];
|
|
|
+ }
|
|
|
+ if (checkItems.length == 0 && changeflag) {
|
|
|
+ order.checked =false;
|
|
|
+ toaster.pop('warning', '提示', "该采购单所有明细正在变更中,在供应商确认之前不可再次变更");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 明细
|
|
|
+ $scope.checkItem = function (item, order) {
|
|
|
+ // 先判断选中信息
|
|
|
+ if (item.change) {
|
|
|
+ toaster.pop('warning', '提示', "该明细正在变更中,在供应商确认之前不可再次变更");
|
|
|
+ item.checked = null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ order.checked = true;
|
|
|
+ if ($scope.checkedOrder != null && order.id != $scope.checkedOrder.id) {
|
|
|
+ $scope.checkedOrder.checked = false;
|
|
|
+ $scope.checkedOrder = order;
|
|
|
+ order.checked = true;
|
|
|
+ angular.forEach(checkItems, function (checkItem) {
|
|
|
+ checkItem.checked = false;
|
|
|
+ });
|
|
|
+ checkItems = [];
|
|
|
+ }
|
|
|
+ item.checked = !item.checked;
|
|
|
+ if (item.checked) {
|
|
|
+ checkItems.push(item);
|
|
|
+ if ($scope.checkedOrder == null) {
|
|
|
+ $scope.checkedOrder = order;
|
|
|
+ }
|
|
|
+ order.checked = true;
|
|
|
+ } else {
|
|
|
+ angular.forEach(checkItems, function (checkItem, index) {
|
|
|
+ if (checkItem.id == item.id) {
|
|
|
+ checkItems.splice(index, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (checkItems.length == 0) {
|
|
|
+ $scope.checkedOrder = null;
|
|
|
+ order.checked = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function (keyword) {
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.getCartTotal = function (items) {
|
|
|
+ var sum = 0;
|
|
|
+ angular.forEach(items, function (item) {
|
|
|
+ sum += item.qty * item.price;
|
|
|
+ });
|
|
|
+ return sum;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 选择
|
|
|
+ $scope.choose = function () {
|
|
|
+ if ($scope.checkedOrder == null || checkItems.length == 0) {
|
|
|
+ toaster.pop('error', '请先选择采购单信息');
|
|
|
+ } else {
|
|
|
+ $scope.checkedOrder.orderItems = checkItems;
|
|
|
+ $modalInstance.close($scope.checkedOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 关闭
|
|
|
+ $scope.close = function () {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 采购变更单详情
|
|
|
+ */
|
|
|
+ app.controller('PurcChangeDetailCtrl', ['$scope', '$stateParams', 'change', 'toaster', 'CurrentRole',
|
|
|
+ function ($scope, $stateParams, change, toaster, CurrentRole) {
|
|
|
+ // 获取当前用户是否为普通用户
|
|
|
+ CurrentRole.isUser({}, {}, function (data) {
|
|
|
+ $scope.isUser = data.isUser;
|
|
|
+ });
|
|
|
+ var loadData = function () {
|
|
|
+ change.getItem({id: $stateParams.id}, function (data) {
|
|
|
+ $scope.change = data;
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ loadData();
|
|
|
+ $scope.openDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
return app;
|
|
|
});
|