| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156 |
- define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'service/Make', 'ui.router','service/Fa','ui.bootstrap' ], function() {
- 'use strict';
- var app = angular.module('myApp', ['ngAnimate', 'toaster', 'ui.router', 'common.services', 'PurcServices', 'MakeServices', 'FaServices' , 'ui.bootstrap']);
- app.init = function() {
- angular.bootstrap(document, [ 'myApp' ]);
- };
- app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
- $urlRouterProvider.otherwise('/index');
- $stateProvider.state('index', {
- url : "/index",
- templateUrl : "static/tpl/index_mobile/home/index.html"
- }).state('sale', {// 销售
- url : "/sale",
- templateUrl : "static/tpl/index_mobile/sale/sale.html"
- }).state('make', {// 委外
- url : "/make",
- templateUrl : "static/tpl/index_mobile/make/make.html"
- }).state('sale.order', {// 销售,订单列表
- url : "/order",
- templateUrl : "static/tpl/index_mobile/sale/order_list.html",
- controller: 'SaleOrderListCtrl'
- }).state('sale.sample', {// 销售,送样申请列表
- url : "/sample",
- templateUrl : "static/tpl/index_mobile/sale/sample.html",
- controller: 'SaleSampleCtrl'
- }).state('sale.sample_detail', {
- url : "/sample/:id",
- templateUrl : "static/tpl/index_mobile/sale/sample_detail.html",
- controller: 'SaleSampleDetailCtrl'
- }).state('sale.approval', {// 销售,客户认定列表
- url : "/approval",
- templateUrl : "static/tpl/index_mobile/sale/approval.html",
- controller: 'SaleApprovalCtrl'
- }).state('sale.approval_detail', {
- url : "/approval/:id",
- templateUrl : "static/tpl/index_mobile/sale/approval_detail.html",
- controller: 'SaleApprovalDetailCtrl'
- }).state('sale.change', {// 销售,变更单列表
- url : "/change",
- templateUrl : "static/tpl/index_mobile/sale/change_list.html",
- controller: 'SaleChangeListCtrl'
- }).state('sale.inquiry', {// 销售,询价单列表
- url : "/inquiry",
- templateUrl : "static/tpl/index_mobile/sale/inquiry_list.html",
- controller: 'SaleInquiryListCtrl'
- }).state('sale.notice', {// 销售,发货提醒列表
- url : "/notice",
- templateUrl : "static/tpl/index_mobile/sale/notice_list.html",
- controller: 'SaleNoticeListCtrl'
- }).state('sale.accept', {// 销售,验收单列表
- url : "/accept",
- templateUrl : "static/tpl/index_mobile/sale/accept_list.html",
- controller: 'SaleAcceptListCtrl'
- }).state('sale.return', {// 销售,退货单列表
- url : "/return",
- templateUrl : "static/tpl/index_mobile/sale/return_list.html",
- controller: 'SaleReturnListCtrl'
- }).state('make.order', {// 委外,加工单列表
- url : "/order",
- templateUrl : "static/tpl/index_mobile/make/order_list.html",
- controller: 'MakeOrderListCtrl'
- }).state('make.change', {// 委外,变更单列表
- url : "/change",
- templateUrl : "static/tpl/index_mobile/make/change_list.html",
- controller: 'MakeChangeListCtrl'
- }).state('make.accept', {// 委外,验收单列表
- url : "/accept",
- templateUrl : "static/tpl/index_mobile/make/accept_list.html",
- controller: 'MakeAcceptListCtrl'
- }).state('make.return', {// 委外,退货单列表
- url : "/return",
- templateUrl : "static/tpl/index_mobile/make/return_list.html",
- controller: 'MakeReturnListCtrl'
- }).state('sale.send', {// 销售,客户发货单
- url : "/send",
- templateUrl : "static/tpl/index_mobile/sale/send.html",
- controller: 'SaleSendCtrl'
- }).state('sale.send_detail', {
- url : "/send/:id",
- templateUrl : "static/tpl/index_mobile/sale/send_detail.html",
- controller: 'SaleSendDetailCtrl'
- }).state('sale.order_detail', {// 销售,订单详情
- url : "/order/:id",
- templateUrl : "static/tpl/index_mobile/sale/order_detail.html",
- controller: 'SaleOrderCtrl'
- }).state('sale.change_detail', {// 销售,变更单详情
- url: '/change/:id',
- templateUrl: 'static/tpl/index_mobile/sale/change_detail.html',
- controller: 'SaleChangeCtrl'
- }).state('sale.inquiry_detail', {// 销售,询价单详情
- url: '/inquiry/:itemId',
- templateUrl: 'static/tpl/index_mobile/sale/inquiry_detail.html',
- controller: 'SaleInquiryCtrl'
- }).state('sale.notice_detail', {// 销售,发货提醒详情
- url: '/notice/:id',
- templateUrl: 'static/tpl/index_mobile/sale/notice_detail.html',
- controller: 'SaleNoticeCtrl'
- }).state('sale.accept_detail', {// 销售,验收单详情
- url: '/accept/:id',
- templateUrl: 'static/tpl/index_mobile/sale/accept_detail.html',
- controller: 'SaleAcceptCtrl'
- }).state('sale.return_detail', {// 销售,退货单详情
- url: '/return/:id',
- templateUrl: 'static/tpl/index_mobile/sale/return_detail.html',
- controller: 'SaleReturnCtrl'
- }).state('fa', {//财务
- url : "/fa",
- templateUrl : "static/tpl/index_mobile/financial/financial.html"
- }).state('fa.apBill', {//财务,客户应付发票
- url : "/apBill",
- templateUrl : "static/tpl/index_mobile/financial/apBill_list.html",
- controller : 'SaleApBillCtrl'
- }).state('fa.arCheck', {//财务,应付对账单
- url : "/arCheck",
- templateUrl : "static/tpl/index_mobile/financial/arCheck_list.html",
- controller: 'SaleArCheckCtrl'
- }).state('fa.receCheck', {//财务,应收对账单
- url : "/receCheck",
- templateUrl : "static/tpl/index_mobile/financial/receCheck_list.html",
- controller : "SaleReceCheckCtrl"
- }).state('fa.arCheck_detail', {// 财务,应付对账详情页
- url : "/arCheck/:id",
- templateUrl : "static/tpl/index_mobile/financial/arCheck_detail.html",
- controller: 'SaleArCheckDetailCtrl'
- }).state('fa.apBill_detail', {
- url : '/apBill/:id',
- templateUrl : "static/tpl/index_mobile/financial/apBill_detail.html",
- controller: 'FaApBillDetailCtrl'
- }).state('make.order_detail', {// 委外,加工单详情
- url: '/order/:id',
- templateUrl: 'static/tpl/index_mobile/make/order_detail.html',
- controller: 'MakeOrderCtrl'
- }).state('make.change_detail', {// 委外,变更单详情
- url: '/change/:id',
- templateUrl: 'static/tpl/index_mobile/make/change_detail.html',
- controller: 'MakeChangeCtrl'
- }).state('make.accept_detail', {// 委外,验收单详情
- url: '/accept/:id',
- templateUrl: 'static/tpl/index_mobile/make/accept_detail.html',
- controller: 'MakeAcceptCtrl'
- }).state('make.return_detail', {// 委外,退货单详情
- url: '/return/:id',
- templateUrl: 'static/tpl/index_mobile/make/return_detail.html',
- controller: 'MakeReturnCtrl'
- }).state('qc', {// 品质管理
- url : "/qc",
- templateUrl : "static/tpl/index_mobile/qc/qc.html"
- }).state('qc.badIn', {// 不良品入库
- url : "/badIn",
- templateUrl : "static/tpl/index_mobile/qc/badIn.html",
- controller: 'SaleBadInCtrl'
- }).state('qc.badIn_detail', {
- url : "/badIn/:id",
- templateUrl : "static/tpl/index_mobile/qc/badIn_detail.html",
- controller: 'SaleBadInDetailCtrl'
- }).state('qc.badOut', {// 不良品出库
- url : "/badOut",
- templateUrl : "static/tpl/index_mobile/qc/badOut.html",
- controller: 'SaleBadOutCtrl'
- }).state('qc.badOut_detail', {
- url : "/badOut/:id",
- templateUrl : "static/tpl/index_mobile/qc/badOut_detail.html",
- controller: 'SaleBadOutDetailCtrl'
- }).state('qc.MRB', {// MRB
- url : "/MRB",
- templateUrl : "static/tpl/index_mobile/qc/MRB.html",
- controller: 'SaleMRBCtrl'
- }).state('qc.MRB_detail', {
- url : "/MRB/:id",
- templateUrl : "static/tpl/index_mobile/qc/MRB_detail.html",
- controller: 'SaleMRBDetailCtrl'
- })
- }]);
-
- app.factory('StatusCode', function(){
- var statusConfig = {
- '101' : '已提交',
- '102' : '已审核',
- '103' : '未通过',
- '313' : '已激活',
- '316' : '已过账',
- '311' : '申请中',
- '312' : '未激活',
- '200' : '未回复',
- '203' : '已下载',
- '201' : '已回复'
- };
- return {
- get: function(code) {
- return statusConfig[code];
- }
- };
- }).filter('status', ['StatusCode', function(StatusCode){
- return function(data) {
- return StatusCode.get(data);
- }
- }]);
-
- app.factory('Symbol', function(){
- return {
- currency: function(cur) {
- if(cur == 'RMB') return '¥';
- else if(cur == 'USD') return '$';
- else if(cur == 'EUR') return '€';
- else return cur;
- }
- };
- });
-
- app.controller('MyCtrl', ['$scope', '$rootScope','$window', 'AuthenticationService', function($scope, $rootScope,$window,AuthenticationService) {
- $scope.logout = function() {
- AuthenticationService.logout().success(function() {
- $window.location.reload();
- });
- };
- $rootScope.$on('$locationChangeSuccess', function(evt, newUrl) {
- var routeState = newUrl.substr(newUrl.indexOf('#/') + 2);
- if (routeState.indexOf('/') > -1)
- routeState = routeState.substring(0, routeState.indexOf('/'));
- if (routeState.indexOf('.') > -1)
- routeState = routeState.substring(0, routeState.indexOf('.'));
- $scope.routeState = routeState || 'home';
- });
- }]);
-
- //切换账套
- app.controller('ChooseEnterpriseCtrl', ['$scope', '$modalInstance', 'enterprises', 'enterprise', function($scope, $modalInstance, enterprises, enterprise){
- $scope.choose = enterprise.uu;
- $scope.enterprises = enterprises;
- $scope.cancel = function() {
- $modalInstance.close();
- };
- $scope.login = function(uu) {
- $modalInstance.close(uu);
- };
- }]);
-
- app.controller('AuthCtrl', ['$scope', '$window', 'AuthenticationService', '$modal', 'BaseService', function($scope, $window, AuthenticationService, $modal, BaseService) {
- $scope.isAuthed = AuthenticationService.isAuthed(); //AuthenticationService模块在common/下
- $scope.userInfo = {};
- AuthenticationService.getAuthentication().success(function(data) {
- if(data.enterprises) {
- data.enterprise = data.enterprises[data.enterprises.length - 1];
- if(data.enterprises.length > 1) {
- var enSelect = [];
- angular.forEach(data.enterprises, function(e){
- if(e.current)
- data.enterprise = e;
- else
- enSelect.push(e);
- });
- data.enSelect = enSelect;
- }
- }
- $scope.userInfo = data;
- if (data == null || !data.userUU) {
- $scope.isAuthed = false;
- $window.location.href = BaseService.getRootPath() + "/signin";
- }
- });
- $scope.logout = function() {
- AuthenticationService.logout().success(function() {
- $window.location.href = BaseService.getRootPath() + "/signin";
- });
- };
-
- $scope.switchto = function(enUU) {// 切换企业
- AuthenticationService.reSignin(enUU).success(function(){
- $window.location.reload();
- });
- };
-
- //切换帐套信息方法
- $scope.changeMaster = function() {
- $modal.open({
- templateUrl: 'chooseEnterprise.html',
- controller: 'ChooseEnterpriseCtrl',
- size: 'sm',
- resolve: {
- enterprises: function() {
- return $scope.userInfo.enterprises;
- },
- enterprise: function() {
- return $scope.userInfo.enterprise;
- }
- }
- }).result.then(function(enUU){
- $scope.switchto(enUU);
- });
- }
- }]);
-
-
-
- // 根据状态分类得到获取数据的方法
- var getState = function(active) {
- var fn = 'get';
- switch(active) {
- case 'done':
- fn = 'getDone';break;
- case 'todo':
- fn = 'getTodo';break;
- case 'end':
- fn = 'getEnd';break;
- case 'waiting':
- fn = 'getWaiting';break;
- }
- return fn;
- };
-
- /**
- * 待处理数据统计
- */
- app.controller('TodoCtrl', ['$rootScope', '$scope', 'SnapshotService', function($rootScope, $scope, SnapshotService){
- SnapshotService.getTodo(function(data){
- $scope.todo = data;
- });
- if(!$rootScope.active) {
- $rootScope.active = [true, false, false, false];
- };
- $scope.active =$rootScope.active;
- $scope.showMake = function(index) {
- for (var i=0;i<$scope.active.length;i++) {
- if($scope.active[i] == true) {
- $scope.active[i] = false;
- $rootScope.active[i] = false;
- }
- if(index == i) {
- $scope.active[i] = true;
- $rootScope.active[i] = true;
- }
- }
- }
- }]);
-
- /**
- * 客户采购订单列表
- */
- app.controller('SaleOrderListCtrl', ['$scope', 'BaseService', 'PurcOrderItem', 'toaster', function($scope, BaseService, PurcOrderItem, toaster) {
- $scope.data = {};// 列表数据
-
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- },
- searchFilter: { // 筛选条件
- keyword: null
- }
- };
-
- $scope._state = 'todo';
-
- // 切换单据类型
- $scope.setState = function(state) {
- if($scope._state != state) {
- $scope._state = state;
- if(pageParams.page == 1)
- getData();
- else {
- pageParams.page = 1;
- getData();
- }
- }
- };
-
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.searchFilter.keyword = $scope.keyword;
- PurcOrderItem[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- $scope.onSearch = function() {
- getData();
- }
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- // 获取订单的总金额
- $scope.getTotal = function(order) {
- var total = 0;
- angular.forEach(order.orderItems, function(item){
- total += (item.qty||0) * (item.price||0);
- });
- return total;
- };
-
- // 获取物料总数
- $scope.getProdCount = function(order) {
- var count = 0;
- angular.forEach(order.orderItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
-
- }]);
-
- /**
- * 客户采购订单详情
- */
- app.controller('SaleOrderCtrl', ['$scope', '$filter', '$stateParams', 'toaster', 'PurcOrder', 'PurcOrderItem', 'Symbol', function($scope, $filter, $stateParams, toaster, PurcOrder, PurcOrderItem, Symbol){
- $scope.loading = true;
- $scope.symbol = Symbol.currency;
-
- $scope.getOrderTotal = function(items) {
- var sum = 0;
- angular.forEach(items, function(item){
- sum += item.qty * item.price;
- });
- return parseFloat(sum).toFixed(2);//四舍五入取两位小数
- };
-
- PurcOrder.get({id: $stateParams.id}, function(data) {
- $scope.purcOrder = data;
- $scope.loading = false;
- });
-
- // 展开回复
- $scope.expandReply = function(orderItem) {
- if(!orderItem.replys) {
- PurcOrderItem.getReply({orderItemId: orderItem.id}, function(data){
- orderItem.replys = data;
- }, function(){
- orderItem.replysError = true;
- });
- }
- angular.forEach($scope.purcOrder.orderItems, function(item, index){
- if(item.number != orderItem.number) item.expand = false;
- });
- orderItem.expand = !orderItem.expand;
- };
-
- // 全选
- $scope.checkAll = function(value) {
- angular.forEach($scope.purcOrder.orderItems, function(item, index){
- item.checked = value;
- });
- };
-
- // 选中一个
- $scope.checkOne = function(value) {
- if(value) {
- // angular.forEach($scope.purcOrder.orderItems, function(item, index){
- // if(item.checked == false) {
- // $scope.check_all = false; return ;
- // }
- // });
- } else {
- $scope.check_all = false;
- }
- };
-
- $scope.open = function($event, orderItem) {
- $event.preventDefault();
- $event.stopPropagation();
- orderItem.opened = !orderItem.opened;
- };
-
-
- $scope.reply = function(item) {
- $scope.loading = true;
- if(item.reply && item.reply.qty && item.reply.delivery) {
- var reply = angular.copy(item.reply),
- dateFilter = $filter('date');
- if(reply.delivery) {
- reply.delivery = reply.delivery.getTime();
- }
- PurcOrderItem.reply({orderItemId: item.id}, reply, function(){
- PurcOrder.get({id: $stateParams.id}, function(data) {
- $scope.purcOrder = data;
- $scope.loading = false;
- toaster.pop('success', '提示', '回复成功:' + reply.qty);
- });
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- } else {
- $scope.loading = false;
- toaster.pop('warning', '提示', '请填写回复的具体内容');
- }
- };
-
- $scope.replyByBatch = function() {
- $scope.loading = true;
- var str = '';
- angular.forEach($scope.purcOrder.orderItems, function(item) {
- if(item.checked == true) {
- str += item.id + ",";
- }
- });
- if(str) {
- str = str.substr(0, str.length-1);
- PurcOrderItem.replyByBatch(str, function(){
- $scope.loading = false;
- PurcOrder.get({id: $stateParams.id}, function(data) {
- $scope.purcOrder = data;
- $scope.loading = false;
- toaster.pop('success', '提示', '回复成功');
- });
- }, function(data){
- $scope.loading = false;
- toaster.pop('error', '回复失败', data);
- });
- } else {
- $scope.loading = false;
- toaster.pop('warning', '警告', '请勾选要回复的明细行');
- }
-
- };
- }]);
-
- /**
- * 客户采购变更列表
- */
- app.controller('SaleChangeListCtrl', ['$scope', 'PurcChange', 'toaster', 'BaseService', function($scope, PurcChange, toaster, BaseService) {
- $scope.data = {};// 列表数据
-
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- },
- searchFilter: { // 筛选条件
- keyword: null
- }
- };
-
- $scope._state = 'todo';
-
- // 切换单据类型
- $scope.setState = function(state) {
- if($scope._state != state) {
- $scope._state = state;
- if(pageParams.page == 1)
- getData();
- else {
- pageParams.page = 1;
- getData();
- }
- }
- };
-
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.keyword = $scope.keyword;
- PurcChange[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- $scope.onSearch = function() {
- getData();
- }
- }]);
-
- /**
- * 客户采购变更详情
- */
- app.controller('SaleChangeCtrl', ['$scope', '$stateParams', 'toaster', 'PurcChange', function($scope, $stateParams, toaster, PurcChange){
- $scope.loading = true;
- $scope.remark = '';
-
- //获取变更单
- PurcChange.get({id: $stateParams.id}, function(data){
- $scope.purcChange = data;
- $scope.remark = data.replyRemark;
- $scope.loading = false;
- }, function(response){
- toaster.pop('error', '数据加载失败', response.data);
- });
-
- $scope.onReplyClick = function(change) {
- $scope.loading = true;
- var reply = {id: change.id, agreed: Number(change.agreed), replyRemark: change.replyRemark};
- PurcChange.reply({changeId: change.id}, reply, function(){
- toaster.pop('info', '提示', '回复成功');
- PurcChange.get({id: $stateParams.id}, function(data){
- $scope.purcChange = data;
- $scope.remark = data.replyRemark;
- $scope.loading = false;
- }, function(response){
- console.log(response);
- });
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- };
- }]);
-
- /**
- * 客户询价单列表
- */
- app.controller('SaleInquiryListCtrl', ['$scope', 'BaseService', 'PurcInquiry', 'toaster', function($scope, BaseService, PurcInquiry, toaster) {
- $scope.data = {};// 列表数据
-
- var pageParams = {// 页面参数
- page : 1,
- count : 5,
- sorting: {
- 'inquiry.date': 'desc'
- },
- searchFilter: { // 筛选条件
- keyword: null
- }
- };
-
- $scope._state = 'todo';
-
- // 切换单据类型
- $scope.setState = function(state) {
- if($scope._state != state) {
- $scope._state = state;
- if(pageParams.page == 1)
- getData();
- else {
- pageParams.page = 1;
- getData();
- }
- }
- };
-
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.keyword = $scope.keyword;
- PurcInquiry[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- $scope.onSearch = function() {
- getData();
- }
-
- }]);
-
- /**
- * 客户询价单详情
- */
- app.controller('SaleInquiryCtrl', ['$scope', '$stateParams', 'toaster', 'PurcInquiry', 'Symbol', function($scope, $stateParams, toaster, PurcInquiry, Symbol){
- $scope.loading = true;
- $scope.vendFromDateOpen = false;
- $scope.vendToDateOpen = false;
- var inquiry = null;
-
- $scope.symbol = Symbol.currency;//把币别转化为符号
-
- PurcInquiry.getItem({itemId: $stateParams.itemId}, function(data){
- $scope.purcInquiry = data;
- inquiry = angular.copy(data);
- $scope.loading = false;
- }, function(response){
- toaster.pop('error', '加载失败', response.data);
- });
-
- $scope.openF = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.vendFromDateOpen = !$scope.vendFromDateOpen;
- };
-
- $scope.openT = function($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.vendToDateOpen = !$scope.vendToDateOpen;
- };
-
- $scope.addNewReply = function(reply) {
- $scope.purcInquiry.replies.push({price: null, lapQty: null, id: null, editing: true});
- reply.editing = false;
- };
-
- $scope.save = function(item) {
- $scope.loading = true;
- if(angular.equals($scope.purcInquiry, inquiry)) {
- $scope.loading = false;
- toaster.pop('warning', '提示', '没有修改,不需要保存');
- return;
- }
- if(angular.isDate(item.vendFromDate)) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if(angular.isDate(item.vendToDate)) {
- item.vendToDate = item.vendToDate.getTime();
- }
- PurcInquiry.saveItem({itemId: item.id}, item, function(data) {
- toaster.pop('info', '提示', '保存成功');
- PurcInquiry.getItem({itemId: $stateParams.itemId}, function(data){
- $scope.purcInquiry = data;
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载失败', response.data);
- });
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
-
- $scope.reply = function(item) {
- $scope.loading = true;
- if(item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if(item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- PurcInquiry.reply({itemId: item.id}, item, function(data) {
- toaster.pop('info', '提示', '回复成功');
- PurcInquiry.getItem({itemId: $stateParams.itemId}, function(data){
- $scope.purcInquiry = data;
- $scope.loading = false;
- }, function(data){
- $scope.loading = false;
- toaster.pop('error', '加载失败', response.data);
- });
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- };
- }]);
-
- /**
- * 客户发货提醒列表
- */
- app.controller('SaleNoticeListCtrl', ['$scope', 'PurcNotice', 'toaster', 'BaseService', 'SaleTruck', 'Symbol', '$state', function($scope, PurcNotice, toaster, BaseService, SaleTruck, Symbol, $state) {
- $scope.data = {};// 列表数据
-
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- 'delivery': 'asc',
- 'orderItemOrderCode': 'asc',
- 'orderItemNumber': 'asc'
- },
- searchFilter: { // 筛选条件
- keyword: null
- }
- };
-
- $scope._state = 'todo';
-
- // 切换单据类型
- $scope.setState = function(state) {
- if($scope._state != state) {
- $scope._state = state;
- if(pageParams.page == 1)
- getData();
- else {
- pageParams.page = 1;
- getData();
- }
- }
- };
-
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.keyword = $scope.keyword;
- PurcNotice[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- $scope.onSearch = function() {
- getData();
- }
- }]);
-
- /**
- * 客户发货提醒详情
- */
- app.controller('SaleNoticeCtrl', ['$scope', '$stateParams', 'toaster', 'PurcNotice', 'Symbol', function($scope, $stateParams, toaster, PurcNotice, Symbol){
- $scope.loading = true;
- $scope.symbol = Symbol.currency;//把币别转化为符号
- $scope.logShow = false;
-
- $scope.notice = PurcNotice.get({id: $stateParams.id}, function(data){
- $scope.loading = false;
- }, function(response){
- toaster.pop('error', '加载失败', response.data);
- });
-
- $scope.getSends = function(){
- if(! $scope.notice.sendLogs) {
- $scope.loading = true;
- $scope.notice.sendLogs = PurcNotice.getSends({id: $stateParams.id}, function(data){
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载失败', response.data);
- });
- }
- };
-
- $scope.onReplyClick = function(notice) {
- if(notice.send.qty > notice.qty - (notice.endQty || 0)) {
- toaster.pop('warning', '警告', '本次发货数量超出!');
- } else {
- var send = {code: notice.send.code, sendItems: [{qty: notice.send.qty}]};
- $scope.loading = true;
- PurcNotice.save({id: notice.id}, send, function(){
- $scope.loading = false;
- $scope.notice = PurcNotice.get({id: $stateParams.id}, function(data){
- }, function(response){
- toaster.pop('error', '加载失败', response.data);
- });
- toaster.pop('success', '提示', '发货成功');
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '失败', response);
- });
- $scope.logShow = false;
- }
- };
- }]);
-
- /**
- * 客户打样申请
- */
- app.controller('SaleSampleCtrl', ['$scope', 'PurcSample','BaseService' ,function($scope, PurcSample,BaseService){
- $scope.data = {};// 列表数据
-
- // 搜索框回车
- $scope.onSearch = function() {
- pageParams.keyword = $scope.keyword;
- getData();
- };
-
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- proofingDate: 'desc'
- },
- keyword: null
- };
-
- $scope._state = 'done';
-
- // 切换单据类型
- $scope.setState = function(state) {
- if($scope._state != state) {
- $scope._state = state;
- if(pageParams.page == 1)
- getData();
- else {
- pageParams.page = 1;
- getData();
- }
- }
- };
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.keyword = $scope.keyword;
- PurcSample[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- $scope.onSearch = function() {
- getData();
- }
-
- }]);
-
- /**
- * 客户打样申请详情
- */
- app.controller('SaleSampleDetailCtrl', ['$scope', '$stateParams', 'PurcSample', function($scope, $stateParams, PurcSample){
- var loading = true;
- var loadData = function() {
- PurcSample.get({id: $stateParams.id}, function(data){
- $scope.sample = data;
- if(!$scope.sample.send){
- $scope.sample.getSendInfo = '加载中...';
- PurcSample.getSend({id: $stateParams.id}, function(sendData){
- if(sendData) {
- $scope.sample.getSendInfo = null;
- $scope.sample.send = sendData;
- } else {
- $scope.sample.getSendInfo = '无送样信息';
- $scope.sample.send = '无送样信息';
- }
- }, function(response){
- $scope.sample.getSendInfo = '加载失败!';
- });
- }
- $scope.loading = false;
- }, function(response){
- loading = false;
- toaster.pop('error', '获取数据失败', response.data);
- });
- };
- loadData();
- }]);
-
- /**
- * 客户发货单列表
- */
- app.controller('SaleSendCtrl', ['$scope', 'SaleSend', 'toaster', 'BaseService', 'SaleTruck', 'Symbol', '$state', function($scope, SaleSend, toaster, BaseService, SaleTruck, Symbol, $state) {
- $scope.data = {};// 列表数据
-
- // 搜索框回车
- $scope.onSearch = function() {
- pageParams.keyword = $scope.keyword;
- getData();
- };
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- },
- keyword : null
- };
-
- $scope._state = 'todo';
-
- // 切换单据类型
- $scope.setState = function(state) {
- if($scope._state != state) {
- $scope._state = state;
- if(pageParams.page == 1)
- getData();
- else {
- pageParams.page = 1;
- getData();
- }
- }
- };
-
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.keyword = $scope.keyword;
- SaleSend[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- $scope.onSearch = function() {
- getData();
- }
-
- // 获取物料总数
- $scope.getProdCount = function(send) {
- var count = 0;
- angular.forEach(send.sendItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
- }]);
-
- /**
- * 客户发货单列表
- */
- app.controller('SaleSendDetailCtrl', ['$scope','$stateParams', 'SaleSend', 'toaster', 'Symbol', function($scope,$stateParams, SaleSend, toaster, Symbol) {
- $scope.symbol = Symbol.currency;
- // 加载数据
- $scope.loading = true;
- SaleSend.get({id: $stateParams.id}, function(data){
- $scope.send = data;
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
-
- }]);
-
- /**
- * 客户认定单
- */
- app.controller('SaleApprovalCtrl', ['$scope', 'PurcApproval','toaster', 'BaseService' ,function($scope, PurcApproval,toaster,BaseService){
- $scope.data = {};// 列表数据
-
- // 搜索框回车
- $scope.onSearch = function() {
- pageParams.keyword = $scope.keyword;
- getData();
- };
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- inDate: 'desc'
- },
- keyword: null
- };
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.keyword = $scope.keyword;
- PurcApproval.get(BaseService.parseParams(pageParams), null, function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- $scope.onSearch = function() {
- getData();
- }
-
- }]);
-
- /**
- * 客户认定单详情
- */
- app.controller('SaleApprovalDetailCtrl', ['$scope', '$stateParams','toaster', 'PurcApproval', function($scope, $stateParams,toaster, PurcApproval){
- var loading = true;
- var loadData = function() {
- PurcApproval.getItem({id: $stateParams.id},function(data) {
- $scope.approval = data;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- })
- }
- loadData();
- }]);
-
- /**
- * 客户验收单列表*/
- app.controller('SaleAcceptListCtrl',['$scope','BaseService','PurcAccept','toaster',function($scope,BaseService,PurcAccept,toaster){
- $scope.data = {};// 列表数据
- var pageParams = {// 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- }
- };
-
- // 加载数据
- var getData = function(add) {
- PurcAccept.getAll(BaseService.parseParams(pageParams),null,function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();//初始获取数据
-
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- // 获取物料种类数
- $scope.getProdKind = function(accept) {
- var kind = 0;
- angular.forEach(accept.acceptItems, function(item){
- kind = item.number;
- });
- return kind;
- };
-
- // 获取物料总数
- $scope.getProdCount = function(accept) {
- var count = 0;
- angular.forEach(accept.acceptItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
-
- $scope.onSearch = function() {
- getData();
- }
- }]);
-
- /**
- * 客户应付发票
- */
- app.controller('SaleApBillCtrl', ['$scope', '$stateParams', 'Symbol', 'toaster', 'FaApBill', 'BaseService', function($scope, $stateParams, Symbol, toaster, FaApBill, BaseService){
- $scope.active = 'all';
- $scope.data = {};
- var pageParam = {
- count : 5,
- page : 1,
- sorting : {
- date : 'DESC'
- }
- };
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
-
- var getData = function(add) {
- $scope.loading = true;
- pageParam.keyword = $scope.keyword;
- FaApBill.get(BaseService.parseParams(pageParam), null, function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- }
- $scope.data = data;
- $scope.loading = false;
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- }
-
- getData();
-
- $scope.getMoreData = function() {
- pageParam.page++;
- getData(true);
- }
-
- // 搜索框回车
- $scope.onSearch = function() {
- getData();
- };
- }]);
-
- /*
- * 应付对账单列表
- */
- app.controller('SaleArCheckCtrl',['$scope', '$stateParams', 'Symbol', 'toaster', 'FaArCheck', 'BaseService', function($scope, $stateParams, Symbol, toaster, FaArCheck, BaseService) {
- $scope.data = {};
- $scope._state = "all";
- var pageParam = {
- page : 1,
- count : 5,
- sorting : {
- date : 'DESC'
- }
- };
- $scope.currency = Symbol.currency;
- var getData = function(add) {
- $scope.loading = true;
- pageParam.keyword = $scope.keyword;
- FaArCheck[getState($scope._state)](BaseService.parseParams(pageParam), null, function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- }
- $scope.data = data;
- $scope.loading = false;
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- })
- };
-
- getData();
-
- $scope.getMoreData = function() {
- pageParam.page++;
- getData(true);
- };
-
- //计算商品的总数
- $scope.getTotalProd = function(check) {
- var total = 0;
- if(check.items){
- angular.forEach(check.items, function(value) {
- total += value.qty;
- });
- }
- return total;
- };
-
- $scope.onSearch = function() {
- getData();
- };
-
- $scope.setState = function(state) {
- if($scope._state !=state) {
- $scope._state = state;
- pageParam.page = 1;
- getData();
- }
- }
- }]);
-
- /*
- * 应收对账单
- */
- app.controller('SaleReceCheckCtrl', function() {
- //TODO
- });
-
- /*
- * 应付对账单详情页
- */
- app.controller('SaleArCheckDetailCtrl', ['$scope', '$stateParams', 'FaArCheck', 'toaster', '$state', function($scope, $stateParams, FaArCheck, toaster, $state) {
- var loadData = function() {
- FaArCheck.get({id: $stateParams.id}, function(data) {
- $scope.check = data;
- $scope.loading = false;
- })
- }
-
- loadData(); //加载初始的信息
-
- $scope.onReplyClick = function(item, isAgreed) {
- if(isAgreed) {// 同意确认
- FaArCheck.agree({itemId: item.id}, {}, function(data){
- toaster.pop('success', '确认成功', '确认供应商对账数量成功');
- }, function(response){
- toaster.pop('danger', '确认失败', response.data);
- });
- } else {// 不同意回复
- FaArCheck.disagree({itemId: item.id}, {qty: item.$replyQty, remark: item.$replyRemark}, function(data) {
- item.$editing = false;
- toaster.pop('success', '确认成功', '您提交的数量将发送给供应商确认');
- loadData();
- }, function(response) {
- item.$editing = false;
- toaster.pop('danger', '确认失败', response.data);
- loadData();
-
- });
- }
- };
-
- // 获取明细的回复记录
- $scope.getReplies = function(item) {
- if(!item.replies) {
- FaArCheck.getReplies({itemId: item.id}, function(data) {
- item.replies = data;
- }, function(response) {
- toaster.pop('danger', '获取对账记录失败', response.data);
- });
- }
- };
- }]);
-
- /*
- * 客户应付发票详情页
- */
- app.controller('FaApBillDetailCtrl', ['$scope', '$stateParams', 'Symbol', 'toaster', 'FaApBill', 'BaseService', function($scope, $stateParams, Symbol, toaster, FaApBill, BaseService) {
- $scope.apBill = {};
- $scope.currency = Symbol.currency;
- FaApBill.get({id: $stateParams.id}, function(data) {
- $scope.apBill = data;
- console.log($scope.apBill);
- $scope.loading = false;
- }, function(response) {
- toaster.pop('error', '获取记录失败', response.data);
- $scope.loading = false;
- });
- }]);
-
- /**
- * 客户验收单详情
- */
- app.controller('SaleAcceptCtrl',['$scope','$stateParams','PurcAccept','Symbol','toaster',function($scope,$stateParams,PurcAccept,Symbol,toaster){
- $scope.loading = true;
- $scope.symbol = Symbol.currency;//把币别转化为符号
-
- PurcAccept.get({id:$stateParams.id}, function(data){
- $scope.accept = data;
- $scope.loading = false;
- },function(response){
- $scope.loading = false;
- toaster.pop('error', '加载失败', response.data);
- });
-
- //查看更多
- $scope.page = 1;
- $scope.count = 4;
- $scope.showMore = function(length){
- length = $scope.accept.acceptItems.length;
- $scope.page ++;
- }
- }]);
- /**
- * 客户验退单列表
- */
- app.controller('SaleReturnListCtrl',['$scope','BaseService','PurcReturn','toaster',function($scope,BaseService,PurcReturn,toaster){
- $scope.data = {};// 列表数据
- var pageParams = {// 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- }
- };
-
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.keyword = $scope.keyword;
- PurcReturn.getAll(BaseService.parseParams(pageParams),null,function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();
-
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- // 获取物料种类数
- $scope.getProdKind = function(returns) {
- var kind = 0;
- angular.forEach(returns.returnItems, function(item){
- kind = item.number;
- });
- return kind;
- };
-
- // 获取物料总数
- $scope.getProdCount = function(returns) {
- var count = 0;
- angular.forEach(returns.returnItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
-
- $scope.onSearch = function() {
- getData();
- }
- }]);
-
- /**
- * 客户验退单详情
- * */
- app.controller('SaleReturnCtrl',['$scope','$stateParams','PurcReturn','Symbol','toaster',function($scope,$stateParams,PurcReturn,Symbol,toaster){
- $scope.symbol = Symbol.currency;//把币别转化为符号
- $scope.loading = true;
- PurcReturn.get({id:$stateParams.id},function(data){
- $scope.returns = data;
- $scope.loading = false;
- },function(response) {
- $scope.loading = false;
- toaster.pop('error', '加载失败', response.data);
- });
-
- //点击加载更多
- $scope.page = 1;
- $scope.count = 4;
- $scope.showMore = function(length){
- length = $scope.accept.acceptItems.length;
- $scope.page ++;
- }
- }]);
-
-
-
- /**
- * 委外加工单列表
- * */
- app.controller("MakeOrderListCtrl",['$scope','BaseService','MakeOrder','toaster',function($scope,BaseService,MakeOrder,toaster){
- $scope.data = {};// 列表数据
-
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- },
- searchFilter: { // 筛选条件
- }
- };
-
- $scope._state = 'todo';
-
- // 切换单据类型
- $scope.setState = function(state) {
- if($scope._state != state) {
- $scope._state = state;
- if(pageParams.page == 1)
- getData();
- else {
- pageParams.page = 1;
- getData();
- }
- }
- };
-
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- MakeOrder[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- // 按条件查询
- $scope.onClick = function() {
- getData();
- };
- }]);
-
- /**
- * 委外加工单详情
- * */
- app.controller("MakeOrderCtrl",['$scope' , '$filter' , '$stateParams' , 'MakeOrder' , 'toaster' , 'Symbol' , function($scope , $filter , $stateParams , MakeOrder , toaster , Symbol){
- $scope.loading = true;
- $scope.symbol = Symbol.currency;
-
- var loadData = function(){
- MakeOrder.get({id:$stateParams.id}, function(data){
- $scope.order = data;
- $scope.loading = false;
- },function(response){
- $scope.loading = false;
- toaster.pop('error', '加载失败', response.data);
- });
- };
- loadData();
-
- $scope.open = function($event, order) {
- $event.preventDefault();
- $event.stopPropagation();
- order.opened = !order.opened;
- };
-
- // 展开回复
- $scope.expandReply = function(order) {
- if(!order.replys) {
- MakeOrder.getReply({orderId:order.id}, function(data){
- order.replys = data;
- }, function(){
- order.replysError = true;
- });
- }
- order.expand = !order.expand;
-
- };
- //点击回复
- $scope.reply = function(order) {
- $scope.loading = true;
- if(order.reply && order.reply.qty && order.reply.delivery) {
- var reply = angular.copy(order.reply),
- dateFilter = $filter('date');
- if(reply.delivery) {
- reply.delivery = reply.delivery.getTime();
- }
- MakeOrder.reply({orderId: order.id}, reply, function(){
- $scope.loading = false;
- order.expand = false;
- loadData();
- toaster.pop('success', '提示', '回复成功:' + reply.qty);
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- } else {
- $scope.loading = false;
- toaster.pop('warning', '提示', '请填写回复的具体内容');
- }
- };
-
- }]);
-
-
- /**
- * 委外变更单列表
- * */
- app.controller("MakeChangeListCtrl",['$scope','BaseService','MakeChange','toaster',function($scope,BaseService,MakeChange,toaster){
-
- // 列表数据
- $scope.data = {};
-
- // 页面参数
- $scope.pageParams = {
- page : 1,
- count : 5,
- sorting: {
- orderChangeDate: 'desc'
- }
- };
-
- // 加载数据
- $scope.getData = function(add) {
- $scope.loading = true;
- $scope.pageParams.searchFilter = {};
- $scope.pageParams.searchFilter.keyword = $scope.keyword;
- MakeChange.getAll(BaseService.parseParams($scope.pageParams),null,function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- //初始获取数据
- $scope.getData();
-
- //加载更多数据
- $scope.getMoreData = function() {
- $scope.pageParams.page ++;
- $scope.getData(true);
- };
-
- // 按条件查询
- $scope.onClick = function() {
- $scope.getData();
- };
- }]);
-
- /**
- * 委外变更单详情
- * */
- app.controller("MakeChangeCtrl",['$scope','$stateParams','MakeChange','toaster',function($scope,$stateParams,MakeChange,toaster){
- $scope.loading = true;
- $scope.remark = '';
-
- //获取变更单
- MakeChange.get({id: $stateParams.id}, function(data){
- $scope.makeChange = data;
- $scope.remark = data.replyRemark;
- $scope.loading = false;
- }, function(response){
- toaster.pop('error', '数据加载失败', response.data);
- });
-
- //点击回复
- $scope.onReplyClick = function(change) {
- $scope.loading = true;
- var reply = {id: change.id, agreed: Number(change.agreed), replyRemark: change.replyRemark};
- MakeChange.reply({itemId: change.id}, reply, function(){
- toaster.pop('info', '提示', '回复成功');
- MakeChange.get({id: $stateParams.id}, function(data){
- $scope.makeChange = data;
- $scope.remark = data.replyRemark;
- $scope.loading = false;
- }, function(response){
- console.log(response);
- });
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- };
- }]);
-
-
- /**
- * 委外验收单列表
- * */
- app.controller("MakeAcceptListCtrl",['$scope','BaseService','MakeAccept','toaster',function($scope,BaseService,MakeAccept,toaster){
-
- // 列表数据
- $scope.data = {};
-
- // 页面参数
- $scope.pageParams = {
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- }
- };
-
- // 加载数据
- $scope.getData = function(add) {
- $scope.loading = true;
- $scope.pageParams.searchFilter = {};
- $scope.pageParams.searchFilter.keyword = $scope.keyword;
- MakeAccept.getAll(BaseService.parseParams($scope.pageParams),null,function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- //初始获取数据
- $scope.getData();
-
- //加载更多数据
- $scope.getMoreData = function() {
- $scope.pageParams.page ++;
- $scope.getData(true);
- };
-
- // 按条件查询
- $scope.onClick = function() {
- $scope.getData();
- };
-
- // 获取物料种类数
- $scope.getProdKind = function(accept) {
- var kind = 0;
- angular.forEach(accept.acceptItems, function(item){
- kind = item.number;
- });
- return kind;
- };
-
- // 获取物料总数
- $scope.getProdCount = function(accept) {
- var count = 0;
- angular.forEach(accept.acceptItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
- }]);
-
- /**
- * 委外验收单详情
- * */
- app.controller('MakeAcceptCtrl',['$scope','$stateParams','MakeAccept','toaster',function($scope,$stateParams,MakeAccept,toaster){
- $scope.loading = true;
- MakeAccept.get({id:$stateParams.id}, function(data){
- $scope.accept = data;
- $scope.loading = false;
- },function(response){
- $scope.loading = false;
- toaster.pop('error', '加载失败', response.data);
- });
-
- //查看更多
- $scope.page = 1;
- $scope.count = 4;
- $scope.showMore = function(length){
- length = $scope.accept.acceptItems.length;
- $scope.page ++;
- }
- }]);
-
-
- /**
- * 委外退货单列表
- * */
- app.controller("MakeReturnListCtrl",['$scope','BaseService','MakeReturn','toaster',function($scope,BaseService,MakeReturn,toaster){
-
- // 列表数据
- $scope.data = {};
-
- // 页面参数
- $scope.pageParams = {
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- }
- };
-
- // 加载数据
- $scope.getData = function(add) {
- $scope.loading = true;
- $scope.pageParams.searchFilter = {};
- $scope.pageParams.searchFilter.keyword = $scope.keyword;
- MakeReturn.getAll(BaseService.parseParams($scope.pageParams),null,function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- //初始获取数据
- $scope.getData();
-
- //加载更多数据
- $scope.getMoreData = function() {
- $scope.pageParams.page ++;
- $scope.getData(true);
- };
-
- // 按条件查询
- $scope.onClick = function() {
- $scope.getData();
- };
-
- // 获取物料种类数
- $scope.getProdKind = function(returns) {
- var kind = 0;
- angular.forEach(returns.returnItems, function(item){
- kind = item.number;
- });
- return kind;
- };
-
- // 获取物料总数
- $scope.getProdCount = function(returns) {
- var count = 0;
- angular.forEach(returns.returnItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
- }]);
-
- /**
- * 委外退货单详情
- * */
- app.controller('MakeReturnCtrl',['$scope','$stateParams','MakeReturn','toaster',function($scope,$stateParams,MakeReturn,toaster){
- $scope.loading = true;
- MakeReturn.get({id:$stateParams.id}, function(data){
- $scope.returns = data;
- $scope.loading = false;
- },function(response){
- $scope.loading = false;
- toaster.pop('error', '加载失败', response.data);
- });
-
- //查看更多
- $scope.page = 1;
- $scope.count = 4;
- $scope.showMore = function(length){
- length = $scope.returns.returnItems.length;
- $scope.page ++;
- }
- }]);
-
- /**
- * 客户不良品入库
- */
- app.controller('SaleBadInCtrl', ['$scope', 'PurcBadIn','BaseService' ,function($scope, PurcBadIn,BaseService){
- $scope.data = {};// 列表数据
-
- //搜索功能
- $scope.onSearch = function() {
- pageParams.keyword = $scope.keyword;
- getData();
- }
-
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- },
- keyword: null
- };
-
- $scope._state = 'all';
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- PurcBadIn[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 获取物料总数
- $scope.getProdCount = function(order) {
- var count = 0;
- angular.forEach(order.badInItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- }]);
-
- /**
- * 客户不良品入库详情
- */
- app.controller('SaleBadInDetailCtrl', ['$scope','$stateParams', 'toaster','Symbol', 'PurcBadIn' ,function($scope,$stateParams,toaster,Symbol, PurcBadIn){
- $scope.symbol = Symbol.currency;
- // 加载数据
- $scope.loading = true;
- PurcBadIn.get({id:$stateParams.id}, function(data){
- $scope.badIn = data;
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- }]);
- /**
- * 客户不良品出库
- */
- app.controller('SaleBadOutCtrl', ['$scope', 'PurcBadOut','BaseService' ,function($scope, PurcBadOut,BaseService){
- $scope.data = {};// 列表数据
-
- //搜索功能
- $scope.onSearch = function() {
- pageParams.keyword = $scope.keyword;
- getData();
- }
-
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- },
- keyword: null
- };
-
- $scope._state = 'all';
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- PurcBadOut[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 获取物料总数
- $scope.getProdCount = function(order) {
- var count = 0;
- angular.forEach(order.badOutItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- }]);
-
- /**
- * 客户不良品出库详情
- */
- app.controller('SaleBadOutDetailCtrl', ['$scope','$stateParams', 'toaster', 'Symbol','PurcBadOut' ,function($scope,$stateParams, toaster, Symbol,PurcBadOut){
- $scope.symbol = Symbol.currency;
- // 加载数据
- $scope.loading = true;
- PurcBadOut.get({id:$stateParams.id}, function(data){
- $scope.badOut = data;
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- }]);
-
- /**
- * 客户MRB
- */
- app.controller('SaleMRBCtrl', ['$scope', 'PurcMRB','BaseService' ,function($scope, PurcMRB,BaseService){
- $scope.data = {};// 列表数据
-
- //搜索功能
- $scope.onSearch = function() {
- pageParams.keyword = $scope.keyword;
- getData();
- }
-
- var pageParams = { // 页面参数
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- },
- keyword: null
- };
-
- $scope._state = 'all';
- // 加载数据
- var getData = function(add) {
- $scope.loading = true;
- PurcMRB[getState($scope._state)].call(null, BaseService.parseParams(pageParams), function(data){
- if(add) {
- data.content = $scope.data.content.concat(data.content);
- $scope.data = data;
- } else {
- $scope.data = data;
- }
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- };
-
- getData();// 初始获取数据
-
- // 获取物料总数
- $scope.getProdCount = function(order) {
- var count = 0;
- angular.forEach(order.badOutItems, function(item){
- count += (item.qty || 0);
- });
- return count;
- };
-
- // 加载更多数据
- $scope.getMoreData = function() {
- pageParams.page ++;
- getData(true);
- };
-
- }]);
-
- /**
- * 客户不良品入库详情
- */
- app.controller('SaleMRBDetailCtrl', ['$scope','$stateParams', 'toaster', 'PurcMRB' ,function($scope,$stateParams,toaster, PurcMRB){
- // 加载数据
- $scope.loading = true;
- PurcMRB.get({id:$stateParams.id}, function(data){
- $scope.MRB = data;
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '加载数据失败', response.data);
- });
- }]);
-
- /**
- * 搜索框,回车触发
- */
- app.directive('ngSearch', ['$parse', function($parse) {
- return {
- require : '?ngModel',
- restrict : 'A',
- link : function(scope, element, attrs, ngModel) {
- var searchFn = $parse(attrs.ngSearch);
- element.bind('keypress', function(event) {
- if (event.keyCode == '13') {
- event.preventDefault();
- event.stopPropagation();
- searchFn(scope, {$data: ngModel.$modelValue, $event: event});
- }
- });
- }
- };
- }]);
-
-
-
- return app;
- });
|