|
|
@@ -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'], 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'], 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']);
|
|
|
+ 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']);
|
|
|
app.init = function () {
|
|
|
angular.bootstrap(document, ['myApp']);
|
|
|
};
|
|
|
@@ -211,6 +211,20 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
url: "/inquiry_unapply",
|
|
|
templateUrl: "static/tpl/index/purc/inquiry_unapply.html",
|
|
|
controller: 'UnapplyInquiryCtrl'
|
|
|
+ }).state('purc.pubInquiry', {
|
|
|
+ /**
|
|
|
+ * 针对客户,查询已转报价的公共询价单列表
|
|
|
+ */
|
|
|
+ url: "/publicInquiry",
|
|
|
+ templateUrl: "static/tpl/index/purc/pubInquiry.html",
|
|
|
+ controller: 'PurcPubInquiryCtrl'
|
|
|
+ }).state('purc.pubInquiry_detail', {
|
|
|
+ /**
|
|
|
+ * 针对客户,查询已转报价单的公共询价详情
|
|
|
+ */
|
|
|
+ url: "/publicInquiry/:id",
|
|
|
+ templateUrl: "static/tpl/index/purc/pubInquiry_detail.html",
|
|
|
+ controller: 'PurcPubInquiryDetailCtrl'
|
|
|
}).state('purc.product', {
|
|
|
url: "/product",
|
|
|
templateUrl: "static/tpl/index/purc/prodList.html",
|
|
|
@@ -304,6 +318,20 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
url: "/inquiry",
|
|
|
templateUrl: "static/tpl/index/sale/inquiry.html",
|
|
|
controller: 'SaleInquiryCtrl'
|
|
|
+ }).state('sale.pubinquiry', {
|
|
|
+ /**
|
|
|
+ * 针对卖家,展示已转询价报价的公共询价单列表
|
|
|
+ */
|
|
|
+ url: "/pubinquiry",
|
|
|
+ templateUrl: "static/tpl/index/sale/pubinquiry.html",
|
|
|
+ controller: 'SalePubInquiryCtrl'
|
|
|
+ }).state('sale.pubinquiry_detail', {
|
|
|
+ /**
|
|
|
+ * 针对卖家,已转询价报价单的公共询价单详情
|
|
|
+ */
|
|
|
+ url: "/pubinquiry/:id",
|
|
|
+ templateUrl: "static/tpl/index/sale/pubinquiry_detail.html",
|
|
|
+ controller: 'SalePubInquiryDetailCtrl'
|
|
|
}).state('sale.inquirymould', {
|
|
|
url: "/mould",
|
|
|
templateUrl: "static/tpl/index/sale/inquiry_mould.html",
|
|
|
@@ -5200,7 +5228,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}]);
|
|
|
|
|
|
// 公共询价列表
|
|
|
- app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry) {
|
|
|
+ app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', 'publicInquiry', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry, publicInquiry) {
|
|
|
BaseService.scrollBackToTop();
|
|
|
/**
|
|
|
* 改变单据日期范围
|
|
|
@@ -5365,27 +5393,33 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
|
|
|
// 转客户询价
|
|
|
$scope.transtoInquiry = function (id) {
|
|
|
- PurchaseInquiry.transtoInquiry({id: id}, {}, function (data) {
|
|
|
+ publicInquiry.turnToInquiry({id: id}, {}, function (data) {
|
|
|
if (data.success) {
|
|
|
toaster.pop('success', '提示', data.success);
|
|
|
- window.location.hash = "sale/inquiry/" + data.id;
|
|
|
+ window.location.hash = "sale/pubinquiry/" + data.id;
|
|
|
}
|
|
|
if (data.error) {
|
|
|
toaster.pop('error', '提示', data.error);
|
|
|
}
|
|
|
if (data.info) {
|
|
|
toaster.pop('info', '提示', data.info);
|
|
|
+ window.open("#/sale/pubinquiry/" + data.inid);
|
|
|
}
|
|
|
}, function (response) {
|
|
|
toaster.pop('error', '提示', response.data);
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ // 跳转到我的报价列表
|
|
|
+ $scope.linkToInquiry = function () {
|
|
|
+ window.open("#/sale/pubinquiry");
|
|
|
+ }
|
|
|
}]);
|
|
|
|
|
|
/**
|
|
|
* 公共询价详情
|
|
|
*/
|
|
|
- app.controller('PublicInquiryListDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'AccountEnterprise', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, AccountEnterprise) {
|
|
|
+ app.controller('PublicInquiryListDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'AccountEnterprise', 'publicInquiry', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, AccountEnterprise, publicInquiry) {
|
|
|
BaseService.scrollBackToTop();
|
|
|
$scope.currentHasBid = false;
|
|
|
var loadData = function () {
|
|
|
@@ -5411,7 +5445,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
|
|
|
// 转客户询价
|
|
|
$scope.transtoInquiry = function (id) {
|
|
|
- PurchaseInquiry.transtoInquiry({id: id}, {}, function (data) {
|
|
|
+ publicInquiry.turnToInquiry({id: id}, {}, function (data) {
|
|
|
if (data.success) {
|
|
|
toaster.pop('success', '提示', data.success);
|
|
|
window.location.hash = "sale/inquiry/" + data.id;
|
|
|
@@ -5427,6 +5461,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
});
|
|
|
}
|
|
|
}]);
|
|
|
+
|
|
|
// 询价单明细
|
|
|
app.controller('PurcInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', '$filter', 'toaster', 'CurrentRole', function ($scope, $stateParams, PurcInquiry, $filter, toaster, CurrentRole) {
|
|
|
// 获取当前用户是否为普通用户
|
|
|
@@ -22765,6 +22800,931 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
|
|
|
}
|
|
|
}]);
|
|
|
|
|
|
+ /**
|
|
|
+ * 针对卖家,已转询价的公共询价单列表
|
|
|
+ */
|
|
|
+ app.controller('SalePubInquiryCtrl', ['$scope', '$filter', 'PubInquirySearchInfo', 'ngTableParams', 'toaster', 'BaseService', 'PubInquiryNoSearchInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', 'publicInquiry', function ($scope, $filter, PubInquirySearchInfo, ngTableParams, toaster, BaseService, PubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry) {
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+
|
|
|
+ // 获取当前用户是否为普通用户
|
|
|
+ CurrentRole.isUser({}, {}, function (data) {
|
|
|
+ $scope.isUser = data.isUser;
|
|
|
+ });
|
|
|
+
|
|
|
+ if ($rootScope.active) {
|
|
|
+ $scope.active = $rootScope.active;
|
|
|
+ $rootScope.active = null;
|
|
|
+ } else {
|
|
|
+ $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 == 3 ? '最近六个月' : '自定义'));
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // // 设置阅读状态
|
|
|
+ // $scope.setReadStatus = function(msg) {
|
|
|
+ // if(!msg.read) {
|
|
|
+ // PurcInquiry.setStatus({id: msg.inid}, {}, function(data) {
|
|
|
+ //
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ $scope.searchMethod = false;
|
|
|
+ var getService = function () {
|
|
|
+ return $scope.searchMethod ? PubInquirySearchInfo : PubInquiryNoSearchInfo;
|
|
|
+ };
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 20,
|
|
|
+ sorting: {
|
|
|
+ 'inquiry.date': 'desc',
|
|
|
+ 'inquiry.enterprise.enName': 'asc',
|
|
|
+ 'inquiry.code': 'asc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ var realActive = {};
|
|
|
+ pageParams.searchFilter = { // 筛选条件
|
|
|
+ keyword: $scope.keyword,
|
|
|
+ fromDate: getDateTime($scope.condition.dateFrom),
|
|
|
+ endDate: getDateTime($scope.condition.dateTo)
|
|
|
+ };
|
|
|
+ if ($scope.active == 'overdue') {
|
|
|
+ $scope.active = 'end';
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //获得各分类未阅读数量
|
|
|
+ // var getUnreadCount = function () {
|
|
|
+ // PurcInquiry.getUnreadCount(null, function (data) {
|
|
|
+ // $scope.unread = data;
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+ // getUnreadCount();
|
|
|
+
|
|
|
+ // //设置单据已读
|
|
|
+ // $scope.setOrdersRead = function (id) {
|
|
|
+ // // 如果单据本身已读,则不发送请求修改数据
|
|
|
+ // if (!$scope.isUnread(id)){
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // var sourceId = [];
|
|
|
+ // sourceId.push(id);
|
|
|
+ // PurcInquiry.setRead({}, sourceId, function (message) {
|
|
|
+ // getUnreadCount();
|
|
|
+ // removeByValue($scope.unreadCode, id);
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+
|
|
|
+ // $scope.setOrdersReadByState = function () {
|
|
|
+ // if (!$scope.unread.replied || $scope.unread.replied == 0) {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // PurcInquiry.setReadByState({}, function () {
|
|
|
+ // getUnreadIds();
|
|
|
+ // getUnreadCount();
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+
|
|
|
+ // var getUnreadIds = function () {
|
|
|
+ // PurcInquiry.getUnreadIds({}, "", function (message) {
|
|
|
+ // $scope.unreadCode = message.content;
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+ // getUnreadIds();
|
|
|
+
|
|
|
+ $scope.isUnread = function (id) {
|
|
|
+ for (var i in $scope.unreadCode) {
|
|
|
+ if (id == $scope.unreadCode[i]) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.getMinDate = function (item) {
|
|
|
+ return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
|
|
|
+ };
|
|
|
+ $scope.replyPrices = [];
|
|
|
+ $scope.replylapQtys = [];
|
|
|
+ $scope.replyPrices.push(true);
|
|
|
+ $scope.replylapQtys.push(true);
|
|
|
+ $scope.addStep = function (inquiryItem) {
|
|
|
+ $scope.replyPrices.push(true);
|
|
|
+ if (inquiryItem.replies.length >= 10) {
|
|
|
+ toaster.pop('warning', '提示', '最多支持10个分段!');
|
|
|
+ } else {
|
|
|
+ inquiryItem.replies.push({});
|
|
|
+ if (inquiryItem.replies.length != 1) {
|
|
|
+ $scope.replyPrices.push(true);
|
|
|
+ $scope.replylapQtys.push(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ $scope.removeStep = function (inquiryItem, stepIndex) {
|
|
|
+ inquiryItem.replies.splice(stepIndex, 1);
|
|
|
+ $scope.replyPrices.splice(stepIndex, 1);
|
|
|
+ $scope.replylapQtys.splice(stepIndex, 1);
|
|
|
+ };
|
|
|
+
|
|
|
+ $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.getHistory = function (item) {
|
|
|
+ if (!item.history) {
|
|
|
+ publicInquiry.getHistory({itemId: item.id}, function (data) {
|
|
|
+ item.history = data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取token信息
|
|
|
+ $scope.getToken = function() {
|
|
|
+ token.info({userType: 'saleinquiry'}, {}, function(data) {
|
|
|
+ $scope.token = data.token;
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.deleteAttach = function (attaches, index) {
|
|
|
+ attaches.splice(index, 1);
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.onReplyClick = function (item, withSteps) {
|
|
|
+ if (item.vendFromDate instanceof Date) {
|
|
|
+ item.vendFromDate = item.vendFromDate.getTime();
|
|
|
+ }
|
|
|
+ if (item.vendToDate instanceof Date) {
|
|
|
+ item.vendToDate = item.vendToDate.getTime();
|
|
|
+ }
|
|
|
+ if (item.vendFromDate > item.vendToDate) {
|
|
|
+ toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var replies = [];
|
|
|
+ // 判断分段数是否合法
|
|
|
+ var valid = true;
|
|
|
+ var validLapQty = 0;
|
|
|
+ angular.forEach(item.replies, function (r, i) {
|
|
|
+ if ((i > 0 ? r.lapQty : 1) || r.price) {
|
|
|
+ replies.push(r);
|
|
|
+ }
|
|
|
+ // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
|
|
|
+ if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
|
|
|
+ valid = false;
|
|
|
+ validLapQty = r.lapQty;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ item.replies = replies;
|
|
|
+ $scope.loading = true;
|
|
|
+ if (!valid) {
|
|
|
+ if (validLapQty) {
|
|
|
+ toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
|
|
|
+ } else {
|
|
|
+ toaster.pop('info', '提示', '分段数量不合法,不能保存!');
|
|
|
+ }
|
|
|
+ $scope.loading = false;
|
|
|
+ } else {
|
|
|
+ var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
|
|
|
+ if (withSteps) { // 保存并报价
|
|
|
+ if(null != file) {
|
|
|
+ $upload.upload({
|
|
|
+ url: 'sale/pubInquiry/addAttach',
|
|
|
+ file: file,
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ item: item,
|
|
|
+ method: 'reply'
|
|
|
+ }
|
|
|
+ }).success(function (data) {
|
|
|
+ if (data.item) {
|
|
|
+ item = data.item;
|
|
|
+ }
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('info', '提示', '报价成功');
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }).error(function (data) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '附件上传失败');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ publicInquiry.reply({itemId: item.id, token: $scope.token}, item, function (data) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('info', '提示', '报价成功');
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '询价失效', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else { // 保存
|
|
|
+ if(null != file) {
|
|
|
+ $upload.upload({
|
|
|
+ url: 'sale/pubInquiry/addAttach',
|
|
|
+ file: file,
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ item: item,
|
|
|
+ method: 'save'
|
|
|
+ }
|
|
|
+ }).success(function (data) {
|
|
|
+ if (data.item) {
|
|
|
+ item = data.item;
|
|
|
+ }
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('info', '提示', '保存成功');
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }).error(function (data) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '附件上传失败');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ publicInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function (data) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('info', '提示', '保存成功');
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '保存失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.isValid = function (item, withSteps) {
|
|
|
+ var bool = item.leadtime && item.replies && item.replies[0].price > 0;
|
|
|
+ if (!withSteps || !bool)
|
|
|
+ return bool;
|
|
|
+ angular.forEach(item.replies, function (r, i) {
|
|
|
+ $scope.verifylapQty(r.lapQty, i, item);
|
|
|
+ bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
|
|
|
+ });
|
|
|
+ return bool;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.verifylapQty = function (value, index, inquiryItem) {
|
|
|
+ value = parseInt(value);
|
|
|
+ var regex = /^\d+(.\d{1,5})?$/;
|
|
|
+ var valid = true;
|
|
|
+ angular.forEach(inquiryItem.replies, function(reply, $index) {
|
|
|
+ if ($index < index && reply.lapQty >= value) {
|
|
|
+ valid = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.replylapQtys[index] = regex.test(value) && valid;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
|
|
|
+ $scope.verify = function (value, type) {
|
|
|
+ var regex = /^\d+(.\d{1,5})?$/;//
|
|
|
+ switch (type) {
|
|
|
+ case 'minOrderQty':
|
|
|
+ $scope.minOrderQtyVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ case 'minPackQty':
|
|
|
+ $scope.minPackQtyVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ case 'leadtime':
|
|
|
+ $scope.leadtimeVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $scope.replyPrices[type] = regex.test(value);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function (keyword) {
|
|
|
+ // 每次搜索重置获取数据方法
|
|
|
+ $scope.searchMethod = false;
|
|
|
+ if(keyword != null && keyword != '') {
|
|
|
+ $scope.searchMethod = true;
|
|
|
+ }
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 取消
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 导出
|
|
|
+ $scope.exportXls = function () {
|
|
|
+ PurcInquiry.exportXls({}, {}, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ window.location.href = 'sale/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 针对卖家,已转询价单的客户公共询价单明细
|
|
|
+ */
|
|
|
+ app.controller('SalePubInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', '$filter', 'toaster', '$upload', 'token', 'CurrentRole', 'publicInquiry', function ($scope, $stateParams, PurcInquiry, $filter, toaster, $upload, token, CurrentRole, publicInquiry) {
|
|
|
+ // 获取当前用户是否为普通用户
|
|
|
+ CurrentRole.isUser({}, {}, function (data) {
|
|
|
+ $scope.isUser = data.isUser;
|
|
|
+ });
|
|
|
+
|
|
|
+ var loadData = function () {
|
|
|
+ publicInquiry.inquiryDetail({id: $stateParams.id}, function (data) {
|
|
|
+ $scope.newinquiryItems = data;
|
|
|
+ var inquiry = data[0].inquiry;
|
|
|
+ //inquiry.inquiryItems = data;
|
|
|
+ angular.forEach(inquiry.attachs, function (attach) {
|
|
|
+ attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
|
|
|
+ });
|
|
|
+ $scope.inquiry = inquiry;
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ loadData();
|
|
|
+ $scope.getMinDate = function (item) {
|
|
|
+ return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.replyPrices = [];
|
|
|
+ $scope.replylapQtys = [];
|
|
|
+ $scope.replyPrices.push(true);
|
|
|
+ $scope.replylapQtys.push(true);
|
|
|
+ $scope.addStep = function (inquiryItem) {
|
|
|
+ if (inquiryItem.replies.length >= 10) {
|
|
|
+ toaster.pop('warning', '提示', '最多支持10个分段!');
|
|
|
+ } else
|
|
|
+ inquiryItem.replies.push({});
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.removeStep = function (inquiryItem, stepIndex) {
|
|
|
+ inquiryItem.replies.splice(stepIndex, 1);
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.openDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.getHistory = function (item) {
|
|
|
+ if (!item.history) {
|
|
|
+ publicInquiry.getHistory({itemId: item.id}, function (data) {
|
|
|
+ item.history = data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
|
|
|
+ $scope.verify = function (value, type) {
|
|
|
+ var regex = /^\d+(.\d{1,5})?$/;//
|
|
|
+ switch (type) {
|
|
|
+ case 'minOrderQty':
|
|
|
+ $scope.minOrderQtyVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ case 'minPackQty':
|
|
|
+ $scope.minPackQtyVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ case 'leadtime':
|
|
|
+ $scope.leadtimeVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $scope.replyPrices[type] = regex.test(value);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.verifylapQty = function (value, index, inquiryItem) {
|
|
|
+ value = parseInt(value);
|
|
|
+ var regex = /^\d+(.\d{1,5})?$/;
|
|
|
+ var valid = true;
|
|
|
+ angular.forEach(inquiryItem.replies, function(reply, $index) {
|
|
|
+ if ($index < index && reply.lapQty >= value) {
|
|
|
+ valid = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.replylapQtys[index] = regex.test(value) && valid;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.isValid = function (item, withSteps) {
|
|
|
+ var bool = item.leadtime && item.replies && item.replies[0].price > 0;
|
|
|
+ if (!withSteps || !bool)
|
|
|
+ return bool;
|
|
|
+ angular.forEach(item.replies, function (r, i) {
|
|
|
+ $scope.verifylapQty(r.lapQty, i, item);
|
|
|
+ bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
|
|
|
+ });
|
|
|
+ return bool;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取token信息
|
|
|
+ $scope.getToken = function() {
|
|
|
+ token.info({userType: 'salePubInquiry'}, {}, function(data) {
|
|
|
+ $scope.token = data.token;
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.deleteAttach = function (attaches, index) {
|
|
|
+ attaches.splice(index, 1);
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.onReplyClick = function (item, withSteps) {
|
|
|
+ if (item.vendFromDate instanceof Date) {
|
|
|
+ item.vendFromDate = item.vendFromDate.getTime();
|
|
|
+ }
|
|
|
+ if (item.vendToDate instanceof Date) {
|
|
|
+ item.vendToDate = item.vendToDate.getTime();
|
|
|
+ }
|
|
|
+ if (item.vendFromDate > item.vendToDate) {
|
|
|
+ toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var replies = [];
|
|
|
+ var valid = true;
|
|
|
+ var validLapQty = 0;
|
|
|
+ angular.forEach(item.replies, function (r, i) {
|
|
|
+ // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
|
|
|
+ if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
|
|
|
+ valid = false;
|
|
|
+ validLapQty = r.lapQty;
|
|
|
+ }
|
|
|
+ if ((i > 0 ? r.lapQty : 1) || r.price)
|
|
|
+ replies.push(r);
|
|
|
+ });
|
|
|
+ item.replies = replies;
|
|
|
+ $scope.loading = true;
|
|
|
+ if (!valid) { // 不合法时给出提示
|
|
|
+ if (validLapQty) {
|
|
|
+ toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
|
|
|
+ } else {
|
|
|
+ toaster.pop('info', '提示', '分段数量不合法,不能保存!');
|
|
|
+ }
|
|
|
+ $scope.loading = false;
|
|
|
+ } else {
|
|
|
+ var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
|
|
|
+ if (withSteps) {
|
|
|
+ if(null != file) {
|
|
|
+ $upload.upload({
|
|
|
+ url: 'sale/pubInquiry/addAttach',
|
|
|
+ file: file,
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ item: item,
|
|
|
+ method: 'reply'
|
|
|
+ }
|
|
|
+ }).success(function (data) {
|
|
|
+ if (data.item) {
|
|
|
+ item = data.item;
|
|
|
+ }
|
|
|
+ toaster.pop('success', '提示', '报价成功');
|
|
|
+ loadData();
|
|
|
+ }).error(function () {
|
|
|
+ toaster.pop('error', '提示', '报价失败');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ publicInquiry.reply({itemId: item.id, token: $scope.token}, item, function () {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('success', '提示', '报价成功');
|
|
|
+ loadData();
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '询价失效', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(null != file) {
|
|
|
+ $upload.upload({
|
|
|
+ url: 'sale/pubInquiry/addAttach',
|
|
|
+ file: file,
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ item: item,
|
|
|
+ method: 'save'
|
|
|
+ }
|
|
|
+ }).success(function (data) {
|
|
|
+ if (data.item) {
|
|
|
+ item = data.item;
|
|
|
+ }
|
|
|
+ toaster.pop('success', '提示', '保存成功');
|
|
|
+ loadData();
|
|
|
+ }).error(function () {
|
|
|
+ toaster.pop('error', '提示', '保存失败');
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ publicInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function () {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('info', '提示', '保存成功');
|
|
|
+ loadData();
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '保存失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 取消
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 针对买家,已转询价的公共询价单列表
|
|
|
+ */
|
|
|
+ app.controller('PurcPubInquiryCtrl', ['$scope', '$filter', 'PurcPubInquirySearchInfo', 'ngTableParams', 'toaster', 'BaseService', 'PurcPubInquiryNoSearchInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', 'publicInquiry', function ($scope, $filter, PurcPubInquirySearchInfo, ngTableParams, toaster, BaseService, PurcPubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry) {
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+
|
|
|
+ // 获取当前用户是否为普通用户
|
|
|
+ CurrentRole.isUser({}, {}, function (data) {
|
|
|
+ $scope.isUser = data.isUser;
|
|
|
+ });
|
|
|
+
|
|
|
+ if ($rootScope.active) {
|
|
|
+ $scope.active = $rootScope.active;
|
|
|
+ $rootScope.active = null;
|
|
|
+ } else {
|
|
|
+ $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 == 3 ? '最近六个月' : '自定义'));
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // // 设置阅读状态
|
|
|
+ // $scope.setReadStatus = function(msg) {
|
|
|
+ // if(!msg.read) {
|
|
|
+ // PurcInquiry.setStatus({id: msg.inid}, {}, function(data) {
|
|
|
+ //
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ $scope.searchMethod = false;
|
|
|
+ var getService = function () {
|
|
|
+ return $scope.searchMethod ? PurcPubInquirySearchInfo : PurcPubInquiryNoSearchInfo;
|
|
|
+ };
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 20,
|
|
|
+ sorting: {
|
|
|
+ 'inquiry.date': 'desc',
|
|
|
+ 'inquiry.enterprise.enName': 'asc',
|
|
|
+ 'inquiry.code': 'asc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [5, 10, 25, 50],
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ var realActive = {};
|
|
|
+ pageParams.searchFilter = { // 筛选条件
|
|
|
+ keyword: $scope.keyword,
|
|
|
+ fromDate: getDateTime($scope.condition.dateFrom),
|
|
|
+ endDate: getDateTime($scope.condition.dateTo)
|
|
|
+ };
|
|
|
+ if ($scope.active == 'overdue') {
|
|
|
+ $scope.active = 'end';
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //获得各分类未阅读数量
|
|
|
+ // var getUnreadCount = function () {
|
|
|
+ // PurcInquiry.getUnreadCount(null, function (data) {
|
|
|
+ // $scope.unread = data;
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+ // getUnreadCount();
|
|
|
+
|
|
|
+ // //设置单据已读
|
|
|
+ // $scope.setOrdersRead = function (id) {
|
|
|
+ // // 如果单据本身已读,则不发送请求修改数据
|
|
|
+ // if (!$scope.isUnread(id)){
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // var sourceId = [];
|
|
|
+ // sourceId.push(id);
|
|
|
+ // PurcInquiry.setRead({}, sourceId, function (message) {
|
|
|
+ // getUnreadCount();
|
|
|
+ // removeByValue($scope.unreadCode, id);
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+
|
|
|
+ // $scope.setOrdersReadByState = function () {
|
|
|
+ // if (!$scope.unread.replied || $scope.unread.replied == 0) {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // PurcInquiry.setReadByState({}, function () {
|
|
|
+ // getUnreadIds();
|
|
|
+ // getUnreadCount();
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+
|
|
|
+ // var getUnreadIds = function () {
|
|
|
+ // PurcInquiry.getUnreadIds({}, "", function (message) {
|
|
|
+ // $scope.unreadCode = message.content;
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+ // getUnreadIds();
|
|
|
+
|
|
|
+ $scope.isUnread = function (id) {
|
|
|
+ for (var i in $scope.unreadCode) {
|
|
|
+ if (id == $scope.unreadCode[i]) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.getMinDate = function (item) {
|
|
|
+ return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
|
|
|
+ };
|
|
|
+ $scope.replyPrices = [];
|
|
|
+ $scope.replylapQtys = [];
|
|
|
+ $scope.replyPrices.push(true);
|
|
|
+ $scope.replylapQtys.push(true);
|
|
|
+
|
|
|
+ $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.getHistory = function (item) {
|
|
|
+ if (!item.history) {
|
|
|
+ publicInquiry.getHistory({itemId: item.id}, function (data) {
|
|
|
+ item.history = data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ // 搜索框回车
|
|
|
+ $scope.onSearch = function (keyword) {
|
|
|
+ // 每次搜索重置获取数据方法
|
|
|
+ $scope.searchMethod = false;
|
|
|
+ if(keyword != null && keyword != '') {
|
|
|
+ $scope.searchMethod = true;
|
|
|
+ }
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 采纳
|
|
|
+ $scope.accept = function (id) {
|
|
|
+ publicInquiry.accept({id: id}, {}, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+ if (data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '提示', '采纳失败');
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ // 拒绝
|
|
|
+ $scope.refuse = function (id) {
|
|
|
+ publicInquiry.refuse({id: id}, {}, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+ if (data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '提示', '操作失败');
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 导出
|
|
|
+ $scope.exportXls = function () {
|
|
|
+ PurcInquiry.exportXls({}, {}, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ window.location.href = 'sale/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 针对卖家,已转询价单的客户公共询价单明细
|
|
|
+ */
|
|
|
+ app.controller('PurcPubInquiryDetailCtrl', ['$scope', '$stateParams', 'publicInquiry', '$filter', 'toaster', '$upload', 'token', 'CurrentRole', function ($scope, $stateParams, publicInquiry, $filter, toaster, $upload, token, CurrentRole) {
|
|
|
+ // 获取当前用户是否为普通用户
|
|
|
+ CurrentRole.isUser({}, {}, function (data) {
|
|
|
+ $scope.isUser = data.isUser;
|
|
|
+ });
|
|
|
+
|
|
|
+ var loadData = function () {
|
|
|
+ publicInquiry.detail({id: $stateParams.id}, function (data) {
|
|
|
+ $scope.newinquiryItems = data;
|
|
|
+ var inquiry = data;
|
|
|
+ //inquiry.inquiryItems = data;
|
|
|
+ angular.forEach(inquiry.attachs, function (attach) {
|
|
|
+ attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
|
|
|
+ });
|
|
|
+ $scope.inquiry = inquiry;
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ loadData();
|
|
|
+ $scope.getMinDate = function (item) {
|
|
|
+ return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.replyPrices = [];
|
|
|
+ $scope.replylapQtys = [];
|
|
|
+ $scope.replyPrices.push(true);
|
|
|
+ $scope.replylapQtys.push(true);
|
|
|
+
|
|
|
+ $scope.getHistory = function (item) {
|
|
|
+ if (!item.history) {
|
|
|
+ publicInquiry.getHistory({itemId: item.id}, function (data) {
|
|
|
+ item.history = data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
|
|
|
+ $scope.verify = function (value, type) {
|
|
|
+ var regex = /^\d+(.\d{1,5})?$/;//
|
|
|
+ switch (type) {
|
|
|
+ case 'minOrderQty':
|
|
|
+ $scope.minOrderQtyVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ case 'minPackQty':
|
|
|
+ $scope.minPackQtyVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ case 'leadtime':
|
|
|
+ $scope.leadtimeVerify = regex.test(value);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $scope.replyPrices[type] = regex.test(value);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 采纳
|
|
|
+ $scope.accept = function (id) {
|
|
|
+ publicInquiry.accept({id: id}, {}, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ loadData();
|
|
|
+ }
|
|
|
+ if (data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
+
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ // 拒绝
|
|
|
+ $scope.refuse = function (id) {
|
|
|
+ publicInquiry.refuse({id: id}, {}, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ toaster.pop('success', '提示', data.success);
|
|
|
+ loadData();
|
|
|
+ }
|
|
|
+ if (data.error) {
|
|
|
+ toaster.pop('error', '提示', data.error);
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '提示', response.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }]);
|
|
|
|
|
|
return app;
|
|
|
});
|