|
|
@@ -1,9 +1,9 @@
|
|
|
define(['app/app'], function (app) {
|
|
|
app.register.controller('seekPurchaseCtrl',
|
|
|
['$scope', '$location', '$rootScope', '$stateParams', '$state', 'toaster',
|
|
|
- 'seekPurchase', 'BaseService', 'ngTableParams', '$modal', '$upload', '$http', 'Authority',
|
|
|
+ 'seekPurchase', 'BaseService', 'ngTableParams', '$modal', '$upload', '$http', 'Authority', 'Search',
|
|
|
function ($scope, $location, $rootScope, $stateParams, $state, toaster,
|
|
|
- seekPurchase, BaseService, ngTableParams, $modal, $upload, $http, Authority) {
|
|
|
+ seekPurchase, BaseService, ngTableParams, $modal, $upload, $http, Authority, Search) {
|
|
|
document.title = '求购询价-优软商城';
|
|
|
$rootScope.active = 'vendor_seek_purchase';
|
|
|
$scope.seekPurchaseRate = {};
|
|
|
@@ -11,17 +11,18 @@ define(['app/app'], function (app) {
|
|
|
seekPurchase.getSeekUrl({}, function(data) {
|
|
|
var seekUrl = data.url;
|
|
|
// var seekUrl = 'http://10.1.51.82:24002';
|
|
|
- $scope.initInquiryItem = function () {
|
|
|
+ var initInquiryItem = function () {
|
|
|
$scope.validSayPrice = {
|
|
|
leadtime: false,
|
|
|
repliesPrice: false,
|
|
|
repliesLapQty: false,
|
|
|
replaceBrand: false,
|
|
|
replaceCmpCode: false,
|
|
|
- replaceSpec: false
|
|
|
- }
|
|
|
+ replaceSpec: true
|
|
|
+ };
|
|
|
+ $scope.inquiryItem = {};
|
|
|
}
|
|
|
- $scope.initInquiryItem();
|
|
|
+ initInquiryItem();
|
|
|
|
|
|
$scope.setSayType = function (type) {
|
|
|
if (type == 'current') {
|
|
|
@@ -205,6 +206,15 @@ define(['app/app'], function (app) {
|
|
|
}
|
|
|
return len;
|
|
|
}
|
|
|
+ var cutOutString = function (str, length) {
|
|
|
+ for (var i = 1; i <= str.length; i++) {
|
|
|
+ if (getRealLen(str.substr(0, i)) > length){
|
|
|
+ str = str.substr(0, i-1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ };
|
|
|
|
|
|
$scope.onProduceDateChange = function () {
|
|
|
if ($scope.offer.produceDate && getRealLen($scope.offer.produceDate) > 12) {
|
|
|
@@ -340,6 +350,7 @@ define(['app/app'], function (app) {
|
|
|
$scope.isShowSayPriceBox = false;
|
|
|
/*设置列表状态*/
|
|
|
$scope.setSeekActive = function (seek, flag, index) {
|
|
|
+ $scope.setSayType('current');
|
|
|
Authority.getAuthority({resUrl: '/authInquiry/inquiry/sale/item/save'}, function (data) {
|
|
|
if (data.status == 'fail') {
|
|
|
toaster.pop('error', data.msg || '系统错误');
|
|
|
@@ -487,6 +498,155 @@ define(['app/app'], function (app) {
|
|
|
return {index: -1};
|
|
|
}*/
|
|
|
|
|
|
+ $scope.checkNull = function (code) {
|
|
|
+ var str = code;
|
|
|
+ var filterStr = new Array("空", "没", "无", "-", "—", "null", "#N/A");
|
|
|
+ var flag = true;
|
|
|
+ angular.forEach (filterStr, function(item) {
|
|
|
+ if (str == item){
|
|
|
+ flag = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.showSimilarCodeList = false;
|
|
|
+ $scope.isInCodeList = false;
|
|
|
+ $scope.showSimilarBrandList = false;
|
|
|
+ $scope.isInBrandList = false;
|
|
|
+
|
|
|
+ $scope.checkBrand = function () {
|
|
|
+ $scope.setShowSimilarBrandList($scope.isInBrandList);
|
|
|
+ $scope.validSayPrice.replaceBrand = $scope.inquiryItem.replaceBrand
|
|
|
+ && $scope.inquiryItem.replaceBrand !== '';
|
|
|
+ if (!$scope.validSayPrice.replaceBrand) {
|
|
|
+ toaster.pop('error', '品牌不能为空');
|
|
|
+ }
|
|
|
+ if (!$scope.checkNull($scope.inquiryItem.replaceBrand)){
|
|
|
+ toaster.pop('error', '品牌输入不合法');
|
|
|
+ $scope.validSayPrice.replaceBrand = false;
|
|
|
+ }
|
|
|
+ return $scope.validSayPrice.replaceBrand;
|
|
|
+ }
|
|
|
+ $scope.checkCode = function () {
|
|
|
+ $scope.setShowSimilarCodeList($scope.isInCodeList);
|
|
|
+ $scope.validSayPrice.replaceCmpCode = $scope.inquiryItem.replaceCmpCode && $scope.inquiryItem.replaceCmpCode !== '';
|
|
|
+ if (!$scope.validSayPrice.replaceCmpCode) {
|
|
|
+ toaster.pop('error', '型号不能为空');
|
|
|
+ }
|
|
|
+ if (!$scope.checkNull($scope.inquiryItem.replaceCmpCode)){
|
|
|
+ toaster.pop('error', '型号输入不合法');
|
|
|
+ $scope.validSayPrice.replaceCmpCode = false;
|
|
|
+ }
|
|
|
+ return $scope.validSayPrice.replaceCmpCode;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $scope.getSimilarCode = function () {
|
|
|
+ if ($scope.inquiryItem.replaceCmpCode) {
|
|
|
+ Search.getSimilarComponents({keyword : $scope.inquiryItem.replaceCmpCode}, function (data) {
|
|
|
+ $scope.similarCode = data || [];
|
|
|
+ $scope.setShowSimilarCodeList(data && data.length);
|
|
|
+ }, function (error) {
|
|
|
+ toaster.pop('error', '系统错误');
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.getSimilarBrand = function () {
|
|
|
+ if ($scope.inquiryItem.replaceBrand) {
|
|
|
+ Search.getSimilarBrands({keyword : $scope.inquiryItem.replaceBrand}, function (data) {
|
|
|
+ $scope.similarBrand = data || [];
|
|
|
+ $scope.setShowSimilarBrandList(data && data.length);
|
|
|
+ }, function (error) {
|
|
|
+ toaster.pop('error', '系统错误');
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $scope.setShowSimilarBrandList = function (flag) {
|
|
|
+ $scope.showSimilarBrandList = flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.setShowSimilarCodeList = function (flag) {
|
|
|
+ $scope.showSimilarCodeList = flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.onBrandChange = function () {
|
|
|
+ // $scope.applyObj.brand = $scope.applyObj.brand.trim();
|
|
|
+ if ((/[^\x00-\xff]/g).test($scope.inquiryItem.replaceBrand)) {
|
|
|
+ var chineseIndex = -1;
|
|
|
+ for (var i = 0; i < $scope.inquiryItem.replaceBrand.length; i++) {
|
|
|
+ if ((/[^\x00-\xff]/g).test($scope.inquiryItem.replaceBrand.charAt(i)) && !(/[\u4e00-\u9fa5]/).test($scope.inquiryItem.replaceBrand.charAt(i))) {
|
|
|
+ chineseIndex = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (chineseIndex > -1) {
|
|
|
+ $scope.inquiryItem.replaceBrand = $scope.inquiryItem.replaceBrand.substring(0, chineseIndex);
|
|
|
+ }
|
|
|
+ } else if ($scope.inquiryItem.replaceBrand && getRealLen($scope.inquiryItem.replaceBrand) > 50) {
|
|
|
+ $scope.inquiryItem.replaceBrand = cutOutString($scope.inquiryItem.replaceBrand, 50);
|
|
|
+ } else {
|
|
|
+ if ($scope.inquiryItem.replaceBrand) {
|
|
|
+ $scope.getSimilarBrand();
|
|
|
+ } else {
|
|
|
+ $scope.showSimilarBrandList = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.onCodeChange = function () {
|
|
|
+ // $scope.applyObj.code = $scope.applyObj.code.trim();
|
|
|
+ if ((/[^\x00-\xff]/g).test($scope.inquiryItem.replaceCmpCode)) {
|
|
|
+ var chineseIndex = -1;
|
|
|
+ for (var i = 0; i < $scope.inquiryItem.replaceCmpCode.length; i++) {
|
|
|
+ if ((/[^\x00-\xff]/g).test($scope.inquiryItem.replaceCmpCode.charAt(i))) {
|
|
|
+ chineseIndex = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.inquiryItem.replaceCmpCode = cutOutString($scope.inquiryItem.replaceCmpCode, chineseIndex);
|
|
|
+ } else if ($scope.inquiryItem.replaceCmpCode && getRealLen($scope.inquiryItem.replaceCmpCode) > 100) {
|
|
|
+ $scope.inquiryItem.replaceCmpCode = cutOutString($scope.inquiryItem.replaceCmpCode, 100);
|
|
|
+ } else {
|
|
|
+ if ($scope.inquiryItem.replaceCmpCode) {
|
|
|
+ $scope.getSimilarCode();
|
|
|
+ } else {
|
|
|
+ $scope.showSimilarCodeList = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.setBrand = function (brand) {
|
|
|
+ $scope.inquiryItem.replaceBrand = brand;
|
|
|
+ $scope.setShowSimilarBrandList(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.setCode = function (code) {
|
|
|
+ $scope.inquiryItem.replaceCmpCode = code;
|
|
|
+ $scope.setShowSimilarCodeList(false);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $scope.checkSpec = function () {
|
|
|
+ if (!$scope.checkNull($scope.inquiryItem.replaceSpec)){
|
|
|
+ toaster.pop('error', '规格输入不合法');
|
|
|
+ $scope.validSayPrice.replaceSpec = false;
|
|
|
+ } else {
|
|
|
+ $scope.validSayPrice.replaceSpec = true;
|
|
|
+ }
|
|
|
+ return $scope.validSayPrice.replaceSpec;
|
|
|
+ }
|
|
|
+ $scope.onSpecInput = function () {
|
|
|
+ if ($scope.inquiryItem.replaceSpec && getRealLen($scope.inquiryItem.replaceSpec) > 100) {
|
|
|
+ $scope.inquiryItem.replaceSpec = cutOutString($scope.inquiryItem.replaceSpec, 100);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
$scope.checkValid = function () {
|
|
|
var validReplace = $scope.sayType == 'replace' ? $scope.validSayPrice.replaceBrand && $scope.validSayPrice.replaceCmpCode && $scope.validSayPrice.replaceSpec : true;
|
|
|
for (var i = 0; i < $scope.inquiryItem.replies.length; i++) {
|